Rectangular button that changes color and label on toggle. More...
#include <Malena/Graphics/Controls/ButtonToggle.h>
Public Types | |
| using | Flag = ButtonToggleManifest::Flag |
| enum class | IconAlign { ICON_ONLY , ICON_LEFT , ICON_RIGHT , ICON_ABOVE } |
| using | State = ButtonToggleManifest::State |
Public Member Functions | |
| ButtonToggle () | |
| void | addItem (const std::string &label, const std::string &key) |
| ButtonTheme & | applyFrom (const Theme &t) override |
Populate all fields from the global Theme token set. | |
| template<typename S> | |
| void | applySettings (const S &s) |
| template<typename St> | |
| void | applyStyle (const St &s) |
| template<typename T> | |
| void | applyTheme (const T &t) |
| void | clearItems () |
| sf::Color | getActiveColor () const |
| sf::Color | getActiveTextColor () const |
| float | getAnimSpeed () const |
| sf::Color | getBorderColor () const |
| float | getBorderThickness () const |
| float | getButtonRadius () const |
| sf::Color | getDisabledColor () const |
| sf::Color | getDisabledTextColor () const |
| sf::Color | getErrorColor () const |
| sf::Color | getFillColor () const |
| sf::Color | getFocusColor () const |
| const sf::Font * | getFont () const |
| unsigned int | getFontSize () const |
| unsigned int | getFontSizeSmall () const |
| sf::FloatRect | getGlobalBounds () const override |
| sf::Color | getHoverColor () const |
| IconAlign | getIconAlign () const |
| const sf::Texture * | getIconOff () const |
| sf::IntRect | getIconOffRect () const |
| const sf::Texture * | getIconOn () const |
| sf::IntRect | getIconOnRect () const |
| float | getIconPadding () const |
| sf::Vector2f | getIconSize () const |
| sf::Color | getInactiveColor () const |
| const std::vector< std::pair< std::string, std::string > > & | getItems () const |
| sf::Color | getMutedColor () const |
| sf::Color | getOffColor () const |
| std::string | getOffLabel () const |
| sf::Color | getOffTextColor () const |
| sf::Color | getOnColor () const |
| std::string | getOnLabel () const |
| sf::Color | getOnTextColor () const |
| sf::Color | getOutlineColor () const |
| float | getOutlineThickness () const |
| float | getPadding () const |
| sf::Vector2f | getPosition () const override |
| float | getRadius () const |
| sf::Vector2f | getSize () const |
| sf::Color | getTextColor () const |
| bool | isEnabled () const |
| bool | isOn () const |
| bool | isSettingsLocked () const |
Return true if applySettings() is currently blocked. | |
| bool | isThemeLocked () const |
Return true if this component ignores theme changes. | |
| void | lockSettings () |
Prevent applySettings() from taking effect. | |
| void | lockTheme () |
| Prevent automatic re-styling when the global theme changes. | |
| void | onToggled (std::function< void(bool)> callback) |
| void | setActiveColor (const sf::Color &c) |
| void | setActiveTextColor (const sf::Color &c) |
| void | setAnimSpeed (float s) |
| void | setBorderColor (const sf::Color &c) |
| void | setBorderThickness (float t) |
| void | setButtonRadius (float r) |
| void | setDisabledColor (const sf::Color &c) |
| void | setDisabledTextColor (const sf::Color &c) |
| void | setEnabled (bool enabled) |
| void | setErrorColor (const sf::Color &c) |
| void | setFillColor (const sf::Color &c) |
| void | setFocusColor (const sf::Color &c) |
| void | setFont (const sf::Font &&)=delete |
| void | setFont (const sf::Font &f) |
| void | setFontSize (unsigned int s) |
| void | setFontSizeSmall (unsigned int s) |
| void | setHoverColor (const sf::Color &c) |
| void | setIconAlign (IconAlign a) |
| void | setIconOff (const sf::Texture *t) |
| void | setIconOffRect (const sf::IntRect &r) |
| void | setIconOn (const sf::Texture *t) |
| void | setIconOnRect (const sf::IntRect &r) |
| void | setIconPadding (float p) |
| void | setIcons (const sf::Texture *on, const sf::Texture *off=nullptr) |
| void | setIconSize (const sf::Vector2f &s) |
| void | setInactiveColor (const sf::Color &c) |
| void | setItems (std::vector< std::pair< std::string, std::string > > i) |
| void | setLabels (const std::string &on, const std::string &off) |
| void | setMutedColor (const sf::Color &c) |
| void | setOffColor (const sf::Color &c) |
| void | setOffLabel (const std::string &s) |
| void | setOffTextColor (const sf::Color &c) |
| void | setOn (bool on) |
| void | setOnColor (const sf::Color &c) |
| void | setOnLabel (const std::string &s) |
| void | setOnTextColor (const sf::Color &c) |
| void | setOutlineColor (const sf::Color &c) |
| void | setOutlineThickness (float t) |
| void | setPadding (float p) |
| void | setPosition (const sf::Vector2f &position) override |
| void | setRadius (float r) |
| void | setSize (const sf::Vector2f &s) |
| void | setTextColor (const sf::Color &c) |
| void | toggle () |
| void | unlockSettings () |
Allow applySettings() to take effect again. | |
| void | unlockTheme () |
| Resume reacting to global theme changes. | |
Protected Member Functions | |
| void | draw (sf::RenderTarget &target, sf::RenderStates states) const override |
| void | onThemeApplied (const Theme &theme) override |
Called by ThemeManager when the active theme changes. | |
Rectangular button that changes color and label on toggle.
Inherits ButtonSettings (geometry/labels/icons) and ButtonTheme (colors) as first-class members. The active theme is applied automatically via Themeable.
Definition at line 49 of file ButtonToggle.h.
Definition at line 55 of file ButtonToggle.h.
Definition at line 56 of file ButtonToggle.h.
|
stronginherited |
| Enumerator | |
|---|---|
| ICON_ONLY | |
| ICON_LEFT | |
| ICON_RIGHT | |
| ICON_ABOVE | |
Definition at line 43 of file ButtonSettings.h.
|
explicit |
|
inlineinherited |
Definition at line 57 of file ToggleSettings.h.
|
inlineoverridevirtualinherited |
Populate all fields from the global Theme token set.
Subclasses call GraphicTheme::applyFrom(t) first, then apply their own token mappings.
Reimplemented from ml::GraphicTheme.
Definition at line 39 of file ButtonTheme.h.
|
inline |
Definition at line 72 of file ButtonToggle.h.
|
inline |
Definition at line 90 of file ButtonToggle.h.
|
inline |
Definition at line 81 of file ButtonToggle.h.
|
inlineinherited |
Definition at line 60 of file ToggleSettings.h.
|
overrideprotected |
|
inlinenodiscardinherited |
Definition at line 63 of file ToggleTheme.h.
|
inlinenodiscardinherited |
Definition at line 65 of file ToggleTheme.h.
|
inlinenodiscardinherited |
Definition at line 48 of file ToggleSettings.h.
|
inlinenodiscardinherited |
Definition at line 78 of file ButtonTheme.h.
|
inlinenodiscardinherited |
Definition at line 79 of file ButtonTheme.h.
|
inlinenodiscardinherited |
Definition at line 80 of file ButtonTheme.h.
|
inlinenodiscardinherited |
Definition at line 75 of file ControlTheme.h.
|
inlinenodiscardinherited |
Definition at line 76 of file ControlTheme.h.
|
inlinenodiscardinherited |
Definition at line 74 of file ControlTheme.h.
|
inlinenodiscardinherited |
Definition at line 67 of file GraphicTheme.h.
|
inlinenodiscardinherited |
Definition at line 73 of file ControlTheme.h.
|
inlinenodiscardinherited |
Definition at line 80 of file ControlTheme.h.
|
inlinenodiscardinherited |
Definition at line 81 of file ControlTheme.h.
|
inlinenodiscardinherited |
Definition at line 82 of file ControlTheme.h.
|
override |
|
inlinenodiscardinherited |
Definition at line 72 of file ControlTheme.h.
|
inlinenodiscardinherited |
Definition at line 77 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 73 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 76 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 72 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 75 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 78 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 74 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 64 of file ToggleTheme.h.
|
inlinenodiscardinherited |
Definition at line 52 of file ToggleSettings.h.
|
inlinenodiscardinherited |
Definition at line 78 of file ControlTheme.h.
|
inlinenodiscardinherited |
Definition at line 75 of file ButtonTheme.h.
|
inlinenodiscardinherited |
Definition at line 71 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 77 of file ButtonTheme.h.
|
inlinenodiscardinherited |
Definition at line 74 of file ButtonTheme.h.
|
inlinenodiscardinherited |
Definition at line 70 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 76 of file ButtonTheme.h.
|
inlinenodiscardinherited |
Definition at line 68 of file GraphicTheme.h.
|
inlinenodiscardinherited |
Definition at line 69 of file GraphicTheme.h.
|
inlinenodiscardinherited |
Definition at line 79 of file ControlTheme.h.
|
override |
|
inlinenodiscardinherited |
Definition at line 70 of file GraphicTheme.h.
|
inlinenodiscardinherited |
Definition at line 69 of file ButtonSettings.h.
|
inlinenodiscardinherited |
Definition at line 77 of file ControlTheme.h.
|
nodiscard |
|
nodiscard |
|
inlinenodiscardinherited |
Return true if applySettings() is currently blocked.
Definition at line 115 of file Themeable.h.
|
inlinenodiscardinherited |
Return true if this component ignores theme changes.
Definition at line 97 of file Themeable.h.
|
inlineinherited |
Prevent applySettings() from taking effect.
Explicit individual setter calls still work normally. Only blocks the batch applySettings() path.
Definition at line 107 of file Themeable.h.
|
inlineinherited |
Prevent automatic re-styling when the global theme changes.
The component keeps its current visual state. Explicit individual setter calls still work normally.
Definition at line 85 of file Themeable.h.
|
overrideprotectedvirtual |
Called by ThemeManager when the active theme changes.
Override in your component to re-style from the new theme. Always check isThemeLocked() first:
| theme | The newly active theme. |
Implements ml::Themeable.
| void ml::ButtonToggle::onToggled | ( | std::function< void(bool)> | callback | ) |
|
inlineinherited |
Definition at line 67 of file ToggleTheme.h.
|
inlineinherited |
Definition at line 69 of file ToggleTheme.h.
|
inlineinherited |
Definition at line 49 of file ToggleSettings.h.
|
inlineinherited |
Definition at line 86 of file ButtonTheme.h.
|
inlineinherited |
Definition at line 87 of file ButtonTheme.h.
|
inlineinherited |
Definition at line 88 of file ButtonTheme.h.
|
inlineinherited |
Definition at line 87 of file ControlTheme.h.
|
inlineinherited |
Definition at line 88 of file ControlTheme.h.
| void ml::ButtonToggle::setEnabled | ( | bool | enabled | ) |
|
inlineinherited |
Definition at line 86 of file ControlTheme.h.
|
inlineinherited |
Definition at line 72 of file GraphicTheme.h.
|
inlineinherited |
Definition at line 85 of file ControlTheme.h.
|
deleteinherited |
|
inlineinherited |
Definition at line 92 of file ControlTheme.h.
|
inlineinherited |
Definition at line 94 of file ControlTheme.h.
|
inlineinherited |
Definition at line 95 of file ControlTheme.h.
|
inlineinherited |
Definition at line 84 of file ControlTheme.h.
|
inlineinherited |
Definition at line 93 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 89 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 92 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 88 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 91 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 94 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 85 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 90 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 68 of file ToggleTheme.h.
|
inlineinherited |
Definition at line 54 of file ToggleSettings.h.
|
inlineinherited |
Definition at line 83 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 90 of file ControlTheme.h.
|
inlineinherited |
Definition at line 83 of file ButtonTheme.h.
|
inlineinherited |
Definition at line 82 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 85 of file ButtonTheme.h.
| void ml::ButtonToggle::setOn | ( | bool | on | ) |
|
inlineinherited |
Definition at line 82 of file ButtonTheme.h.
|
inlineinherited |
Definition at line 81 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 84 of file ButtonTheme.h.
|
inlineinherited |
Definition at line 73 of file GraphicTheme.h.
|
inlineinherited |
Definition at line 74 of file GraphicTheme.h.
|
inlineinherited |
Definition at line 91 of file ControlTheme.h.
|
override |
|
inlineinherited |
Definition at line 75 of file GraphicTheme.h.
|
inlineinherited |
Definition at line 80 of file ButtonSettings.h.
|
inlineinherited |
Definition at line 89 of file ControlTheme.h.
| void ml::ButtonToggle::toggle | ( | ) |
|
inlineinherited |
Allow applySettings() to take effect again.
Definition at line 112 of file Themeable.h.
|
inlineinherited |
Resume reacting to global theme changes.
Does NOT immediately re-apply the current theme — call ThemeManager::get() and pass it to onThemeApplied() manually if you want to re-sync immediately after unlocking.
Definition at line 94 of file Themeable.h.
Definition at line 32 of file ToggleTheme.h.
|
inherited |
Definition at line 34 of file ToggleTheme.h.
|
inherited |
Definition at line 29 of file ToggleSettings.h.
Definition at line 33 of file ButtonTheme.h.
|
inherited |
Definition at line 34 of file ButtonTheme.h.
|
inherited |
Definition at line 35 of file ButtonTheme.h.
Definition at line 33 of file ControlTheme.h.
Definition at line 34 of file ControlTheme.h.
Definition at line 32 of file ControlTheme.h.
Definition at line 43 of file GraphicTheme.h.
Definition at line 31 of file ControlTheme.h.
|
inherited |
Definition at line 39 of file ControlTheme.h.
|
inherited |
Definition at line 40 of file ControlTheme.h.
|
inherited |
Definition at line 41 of file ControlTheme.h.
Definition at line 30 of file ControlTheme.h.
|
inherited |
Definition at line 44 of file ButtonSettings.h.
|
inherited |
Definition at line 38 of file ButtonSettings.h.
|
inherited |
Definition at line 41 of file ButtonSettings.h.
|
inherited |
Definition at line 37 of file ButtonSettings.h.
|
inherited |
Definition at line 40 of file ButtonSettings.h.
|
inherited |
Definition at line 45 of file ButtonSettings.h.
|
inherited |
{0,0} = native size
Definition at line 39 of file ButtonSettings.h.
Definition at line 33 of file ToggleTheme.h.
|
inherited |
Definition at line 30 of file ToggleSettings.h.
Definition at line 36 of file ControlTheme.h.
Definition at line 30 of file ButtonTheme.h.
|
inherited |
Definition at line 34 of file ButtonSettings.h.
Definition at line 32 of file ButtonTheme.h.
Definition at line 29 of file ButtonTheme.h.
|
inherited |
Definition at line 33 of file ButtonSettings.h.
|
inherited |
Definition at line 31 of file ButtonTheme.h.
Definition at line 44 of file GraphicTheme.h.
|
inherited |
Definition at line 45 of file GraphicTheme.h.
|
inherited |
Definition at line 37 of file ControlTheme.h.
|
inherited |
Definition at line 46 of file GraphicTheme.h.
|
inherited |
Definition at line 30 of file ButtonSettings.h.
|
inherited |
Definition at line 35 of file ControlTheme.h.