A horizontal or vertical strip of buttons, separators, and components. More...
#include <Malena/Graphics/Controls/Toolbar.h>
Public Types | |
| using | Flag = ToolbarManifest::Flag |
| using | Orientation = ToolbarSettings::Orientation |
| using | Overflow = ToolbarSettings::Overflow |
| using | State = ToolbarManifest::State |
Public Member Functions | |
| Toolbar (const sf::Font &font=FontManager<>::getDefault()) | |
| Toolbar (const Toolbar &)=delete | |
| void | add (const ml::Core &component) |
Const overload — forwards to the non-const add(). | |
| void | add (ml::Core &component) |
Embed any ml::Core as a positioned toolbar item. | |
| std::size_t | addButton (const std::string &label, std::function< void()> action={}) |
| Add a text-only button. Returns the item index. | |
| void | addSeparator () |
| Add a visual separator. | |
| ToolbarTheme & | 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 | clear () |
| Remove all items. | |
| float | getBarLength () const |
| float | getBarThickness () const |
| height (H) or width (V) | |
| float | getContentExtent () const |
| Extent of the laid-out items along the bar (width for H, height for V), measured from the bar origin past the last item. Useful for placing sibling controls right after a toolbar whose bar spans the full window. | |
| 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 |
| sf::Color | getMutedColor () const |
| sf::Color | getOutlineColor () const |
| float | getOutlineThickness () const |
| float | getPadding () const |
| sf::Vector2f | getPosition () const override |
| float | getRadius () const |
| sf::Color | getTextColor () const |
| bool | isSettingsLocked () const |
Return true if applySettings() is currently blocked. | |
| bool | isThemeLocked () const |
Return true if this component ignores theme changes. | |
| std::size_t | itemCount () const |
| Return the number of items (including separators). | |
| void | lockSettings () |
Prevent applySettings() from taking effect. | |
| void | lockTheme () |
| Prevent automatic re-styling when the global theme changes. | |
| Toolbar & | operator= (const Toolbar &)=delete |
| void | setBarBg (const sf::Color &c) |
| void | setBarLength (float length) |
| Override the bar length (width for H, height for V). By default fills the window width. | |
| void | setBarPadding (float p) |
| void | setDisabledColor (const sf::Color &c) |
| void | setDisabledTextColor (const sf::Color &c) |
| 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 | setItemActiveBg (const sf::Color &c) |
| void | setItemEnabled (std::size_t index, bool enabled) |
| Enable or disable an owned button by item index. | |
| void | setItemHoverBg (const sf::Color &c) |
| void | setItemLabel (std::size_t index, const std::string &label) |
| Update the label of an owned button by item index. | |
| void | setItemSelected (std::size_t index, bool selected) |
| Set or clear the persistent selected highlight on an owned button. | |
| void | setItemSize (sf::Vector2f s) |
| void | setItemSpacing (float s) |
| void | setItemTextColor (const sf::Color &c) |
| void | setMutedColor (const sf::Color &c) |
| void | setOrientation (Orientation o) |
| void | setOutlineColor (const sf::Color &c) |
| void | setOutlineThickness (float t) |
| void | setOverflow (Overflow o) |
| void | setPadding (float p) |
| void | setPosition (const sf::Vector2f &position) override |
| void | setRadius (float r) |
| void | setSeparatorColor (const sf::Color &c) |
| void | setTextColor (const sf::Color &c) |
| 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. | |
A horizontal or vertical strip of buttons, separators, and components.
Items can be added three ways:
| Method | Result |
|---|---|
addButton(label, action) | Creates an owned text button |
addButton(label, icon, action) | Creates an owned icon+label button |
addSeparator() | Thin visual divider line |
add(component) | Any external ml::Core — not owned, not resized |
All interaction (hover highlight, click) is handled by the toolbar itself. External components added via add() retain their own event subscriptions.
|
explicit |
|
delete |
| void ml::Toolbar::add | ( | const ml::Core & | component | ) |
Const overload — forwards to the non-const add().
| void ml::Toolbar::add | ( | ml::Core & | component | ) |
Embed any ml::Core as a positioned toolbar item.
This handles visual placement only — the component is placed in the item flow and repositioned whenever the toolbar moves. It is NOT owned.
To also receive framework events (click, hover, update), you must also register the component with the host's component manager:
For display-only items that need no events, add() alone is sufficient.
setEnabled() on the toolbar propagates to all embedded components, including those added via this method.
| component | Any ml::Core. Not owned — caller manages lifetime. |
| std::size_t ml::Toolbar::addButton | ( | const std::string & | label, |
| std::function< void()> | action = {} ) |
Add a text-only button. Returns the item index.
| void ml::Toolbar::addSeparator | ( | ) |
Add a visual separator.
|
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::ControlTheme.
Definition at line 18 of file ToolbarTheme.h.
|
inline |
|
inline |
|
inline |
| void ml::Toolbar::clear | ( | ) |
Remove all items.
|
overrideprotected |
|
nodiscard |
height (H) or width (V)
|
nodiscard |
Extent of the laid-out items along the bar (width for H, height for V), measured from the bar origin past the last item. Useful for placing sibling controls right after a toolbar whose bar spans the full window.
|
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 78 of file ControlTheme.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 77 of file ControlTheme.h.
|
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.
|
inlinenodiscard |
|
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.
|
inlineinherited |
Definition at line 36 of file ToolbarTheme.h.
| void ml::Toolbar::setBarLength | ( | float | length | ) |
Override the bar length (width for H, height for V). By default fills the window width.
|
inlineinherited |
Definition at line 31 of file ToolbarSettings.h.
|
inlineinherited |
Definition at line 87 of file ControlTheme.h.
|
inlineinherited |
Definition at line 88 of file ControlTheme.h.
|
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 39 of file ToolbarTheme.h.
| void ml::Toolbar::setItemEnabled | ( | std::size_t | index, |
| bool | enabled ) |
Enable or disable an owned button by item index.
|
inlineinherited |
Definition at line 38 of file ToolbarTheme.h.
| void ml::Toolbar::setItemLabel | ( | std::size_t | index, |
| const std::string & | label ) |
Update the label of an owned button by item index.
| void ml::Toolbar::setItemSelected | ( | std::size_t | index, |
| bool | selected ) |
Set or clear the persistent selected highlight on an owned button.
|
inlineinherited |
Definition at line 29 of file ToolbarSettings.h.
|
inlineinherited |
Definition at line 30 of file ToolbarSettings.h.
|
inlineinherited |
Definition at line 40 of file ToolbarTheme.h.
|
inlineinherited |
Definition at line 90 of file ControlTheme.h.
|
inlineinherited |
Definition at line 27 of file ToolbarSettings.h.
|
inlineinherited |
Definition at line 73 of file GraphicTheme.h.
|
inlineinherited |
Definition at line 74 of file GraphicTheme.h.
|
inlineinherited |
Definition at line 28 of file ToolbarSettings.h.
|
inlineinherited |
Definition at line 91 of file ControlTheme.h.
|
override |
|
inlineinherited |
Definition at line 75 of file GraphicTheme.h.
|
inlineinherited |
Definition at line 37 of file ToolbarTheme.h.
|
inlineinherited |
Definition at line 89 of file ControlTheme.h.
|
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 12 of file ToolbarTheme.h.
|
inherited |
Definition at line 20 of file ToolbarSettings.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.
Definition at line 15 of file ToolbarTheme.h.
Definition at line 14 of file ToolbarTheme.h.
|
inherited |
default size for created buttons
Definition at line 18 of file ToolbarSettings.h.
|
inherited |
Definition at line 19 of file ToolbarSettings.h.
|
inherited |
button label color
Definition at line 16 of file ToolbarTheme.h.
Definition at line 36 of file ControlTheme.h.
|
inherited |
Definition at line 16 of file ToolbarSettings.h.
Definition at line 44 of file GraphicTheme.h.
|
inherited |
Definition at line 45 of file GraphicTheme.h.
|
inherited |
Definition at line 17 of file ToolbarSettings.h.
|
inherited |
Definition at line 37 of file ControlTheme.h.
|
inherited |
Definition at line 46 of file GraphicTheme.h.
Definition at line 13 of file ToolbarTheme.h.
|
inherited |
Definition at line 35 of file ControlTheme.h.