A horizontal or vertical strip of buttons, separators, and components.
More...
#include <Malena/Graphics/Controls/Toolbar.h>
|
| sf::Color | barBg = sf::Color(28, 28, 36) |
| float | barPadding = 4.f |
| sf::Color | disabledColor = sf::Color(60, 60, 60) |
| sf::Color | disabledTextColor = sf::Color(120, 120, 120) |
| sf::Color | errorColor = sf::Color(220, 70, 70) |
| sf::Color | fillColor = sf::Color(40, 40, 40) |
| sf::Color | focusColor = sf::Color(100, 60, 200) |
| const sf::Font * | font = &FontManager<>::getDefault() |
| unsigned int | fontSize = 14 |
| unsigned int | fontSizeSmall = 11 |
| sf::Color | hoverColor = sf::Color(70, 130, 230) |
| sf::Color | itemActiveBg = sf::Color(70, 130, 230, 80) |
| sf::Color | itemHoverBg = sf::Color(255, 255, 255, 20) |
| sf::Vector2f | itemSize = {36.f, 36.f} |
| | default size for created buttons
|
| float | itemSpacing = 2.f |
| sf::Color | mutedColor = sf::Color(120, 120, 120) |
| Orientation | orientation = Orientation::HORIZONTAL |
| sf::Color | outlineColor = sf::Color(100, 100, 100) |
| float | outlineThickness = 1.5f |
| Overflow | overflow = Overflow::CLIP |
| float | padding = 8.f |
| float | radius = 8.f |
| sf::Color | separatorColor = sf::Color(70, 70, 90) |
| sf::Color | textColor = sf::Color::White |
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.
Usage
toolbar.
addButton(
"Open", [&]{ openFile(); });
ml::TextInput search;
addComponent(search);
addComponent(toolbar);
virtual void setSize(const sf::Vector2f &size)
void setPlaceholder(const std::string &text)
- See also
- ToolbarSettings, ToolbarTheme, ToolbarStyle
Definition at line 77 of file Toolbar.h.
◆ Flag
◆ Orientation
◆ Overflow
◆ State
◆ Toolbar() [1/2]
◆ Toolbar() [2/2]
| ml::Toolbar::Toolbar |
( |
const Toolbar & | | ) |
|
|
delete |
◆ add()
| void ml::Toolbar::add |
( |
ml::Core & | component | ) |
|
Add a component as a toolbar item.
The component is NOT owned — register it with addComponent separately so its events fire. The toolbar positions it; the component sizes itself.
◆ addButton()
| void ml::Toolbar::addButton |
( |
const std::string & | label, |
|
|
std::function< void()> | action = {} ) |
◆ addSeparator()
| void ml::Toolbar::addSeparator |
( |
| ) |
|
◆ applyFrom()
|
|
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 17 of file ToolbarTheme.h.
◆ applySettings()
template<typename S>
| void ml::Toolbar::applySettings |
( |
const S & | s | ) |
|
|
inline |
◆ applyStyle()
template<typename St>
| void ml::Toolbar::applyStyle |
( |
const St & | s | ) |
|
|
inline |
◆ applyTheme()
template<typename T>
| void ml::Toolbar::applyTheme |
( |
const T & | t | ) |
|
|
inline |
◆ clear()
| void ml::Toolbar::clear |
( |
| ) |
|
◆ draw()
◆ getBarLength()
| float ml::Toolbar::getBarLength |
( |
| ) |
const |
|
inlinenodiscard |
◆ getBarThickness()
| float ml::Toolbar::getBarThickness |
( |
| ) |
const |
|
nodiscard |
◆ getDisabledColor()
| sf::Color ml::ControlTheme::getDisabledColor |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getDisabledTextColor()
| sf::Color ml::ControlTheme::getDisabledTextColor |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getErrorColor()
| sf::Color ml::ControlTheme::getErrorColor |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getFillColor()
| sf::Color ml::GraphicTheme::getFillColor |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getFocusColor()
| sf::Color ml::ControlTheme::getFocusColor |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getFont()
| const sf::Font * ml::ControlTheme::getFont |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getFontSize()
| unsigned int ml::ControlTheme::getFontSize |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getFontSizeSmall()
| unsigned int ml::ControlTheme::getFontSizeSmall |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getGlobalBounds()
◆ getHoverColor()
| sf::Color ml::ControlTheme::getHoverColor |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getMutedColor()
| sf::Color ml::ControlTheme::getMutedColor |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getOutlineColor()
| sf::Color ml::GraphicTheme::getOutlineColor |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getOutlineThickness()
| float ml::GraphicTheme::getOutlineThickness |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getPadding()
| float ml::ControlTheme::getPadding |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getPosition()
◆ getRadius()
| float ml::GraphicTheme::getRadius |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ getTextColor()
| sf::Color ml::ControlTheme::getTextColor |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ isSettingsLocked()
| bool ml::Themeable::isSettingsLocked |
( |
| ) |
const |
|
inlinenodiscardinherited |
◆ isThemeLocked()
| bool ml::Themeable::isThemeLocked |
( |
| ) |
const |
|
inlinenodiscardinherited |
Return true if this component ignores theme changes.
Definition at line 97 of file Themeable.h.
◆ itemCount()
| std::size_t ml::Toolbar::itemCount |
( |
| ) |
const |
|
inlinenodiscard |
Return the number of items (including separators).
Definition at line 174 of file Toolbar.h.
◆ lockSettings()
| void ml::Themeable::lockSettings |
( |
| ) |
|
|
inlineinherited |
◆ lockTheme()
| void ml::Themeable::lockTheme |
( |
| ) |
|
|
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.
◆ onThemeApplied()
| void ml::Toolbar::onThemeApplied |
( |
const Theme & | theme | ) |
|
|
overrideprotectedvirtual |
Called by ThemeManager when the active theme changes.
Override in your component to re-style from the new theme. Always check isThemeLocked() first:
{
MySettings::applyTheme(theme);
syncFromSettings();
}
bool isThemeLocked() const
Return true if this component ignores theme changes.
Universal design token set applied across all Themeable components.
- Parameters
-
| theme | The newly active theme. |
Implements ml::Themeable.
◆ operator=()
◆ setBarBg()
| void ml::ToolbarTheme::setBarBg |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setBarLength()
| void ml::Toolbar::setBarLength |
( |
float | length | ) |
|
Override the bar length (width for H, height for V). By default fills the window width.
◆ setBarPadding()
| void ml::ToolbarSettings::setBarPadding |
( |
float | p | ) |
|
|
inlineinherited |
◆ setDisabledColor()
| void ml::ControlTheme::setDisabledColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setDisabledTextColor()
| void ml::ControlTheme::setDisabledTextColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setErrorColor()
| void ml::ControlTheme::setErrorColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setFillColor()
| void ml::GraphicTheme::setFillColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setFocusColor()
| void ml::ControlTheme::setFocusColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setFont() [1/2]
| void ml::ControlTheme::setFont |
( |
const sf::Font && | | ) |
|
|
deleteinherited |
◆ setFont() [2/2]
| void ml::ControlTheme::setFont |
( |
const sf::Font & | f | ) |
|
|
inlineinherited |
◆ setFontSize()
| void ml::ControlTheme::setFontSize |
( |
unsigned int | s | ) |
|
|
inlineinherited |
◆ setFontSizeSmall()
| void ml::ControlTheme::setFontSizeSmall |
( |
unsigned int | s | ) |
|
|
inlineinherited |
◆ setHoverColor()
| void ml::ControlTheme::setHoverColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setItemActiveBg()
| void ml::ToolbarTheme::setItemActiveBg |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setItemHoverBg()
| void ml::ToolbarTheme::setItemHoverBg |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setItemSize()
◆ setItemSpacing()
| void ml::ToolbarSettings::setItemSpacing |
( |
float | s | ) |
|
|
inlineinherited |
◆ setMutedColor()
| void ml::ControlTheme::setMutedColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setOrientation()
| void ml::ToolbarSettings::setOrientation |
( |
Orientation | o | ) |
|
|
inlineinherited |
◆ setOutlineColor()
| void ml::GraphicTheme::setOutlineColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setOutlineThickness()
| void ml::GraphicTheme::setOutlineThickness |
( |
float | t | ) |
|
|
inlineinherited |
◆ setOverflow()
| void ml::ToolbarSettings::setOverflow |
( |
Overflow | o | ) |
|
|
inlineinherited |
◆ setPadding()
| void ml::ControlTheme::setPadding |
( |
float | p | ) |
|
|
inlineinherited |
◆ setPosition()
| void ml::Toolbar::setPosition |
( |
const sf::Vector2f & | position | ) |
|
|
override |
◆ setRadius()
| void ml::GraphicTheme::setRadius |
( |
float | r | ) |
|
|
inlineinherited |
◆ setSeparatorColor()
| void ml::ToolbarTheme::setSeparatorColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ setTextColor()
| void ml::ControlTheme::setTextColor |
( |
const sf::Color & | c | ) |
|
|
inlineinherited |
◆ unlockSettings()
| void ml::Themeable::unlockSettings |
( |
| ) |
|
|
inlineinherited |
◆ unlockTheme()
| void ml::Themeable::unlockTheme |
( |
| ) |
|
|
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.
◆ barBg
◆ barPadding
| float ml::ToolbarSettings::barPadding = 4.f |
|
inherited |
◆ disabledColor
◆ disabledTextColor
◆ errorColor
◆ fillColor
◆ focusColor
◆ font
◆ fontSize
| unsigned int ml::ControlTheme::fontSize = 14 |
|
inherited |
◆ fontSizeSmall
| unsigned int ml::ControlTheme::fontSizeSmall = 11 |
|
inherited |
◆ hoverColor
◆ itemActiveBg
◆ itemHoverBg
◆ itemSize
◆ itemSpacing
| float ml::ToolbarSettings::itemSpacing = 2.f |
|
inherited |
◆ mutedColor
◆ orientation
| Orientation ml::ToolbarSettings::orientation = Orientation::HORIZONTAL |
|
inherited |
◆ outlineColor
◆ outlineThickness
| float ml::GraphicTheme::outlineThickness = 1.5f |
|
inherited |
◆ overflow
| Overflow ml::ToolbarSettings::overflow = Overflow::CLIP |
|
inherited |
◆ padding
| float ml::ControlTheme::padding = 8.f |
|
inherited |
◆ radius
| float ml::GraphicTheme::radius = 8.f |
|
inherited |
◆ separatorColor
◆ textColor
The documentation for this class was generated from the following file: