Loading...
Searching...
No Matches
ml::List Class Reference

A vertically stacked list of rows with optional dividers and background. More...

#include <Malena/Graphics/Controls/List.h>

Inheritance diagram for ml::List:
[legend]

Public Types

using Flag = ListManifest::Flag
using State = ListManifest::State

Public Member Functions

 List (const List &)=delete
 List (const sf::Font &font=FontManager<>::getDefault())
void add (ml::Core &component)
 Add any ml::Core component as a row.
ListItemaddItem (const std::string &label, const std::string &description="")
 Create and own a ListItem with a label.
ListThemeapplyFrom (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 rows. Owned ListItem objects are destroyed.
sf::Color getBgColor () const
sf::Color getDisabledColor () const
sf::Color getDisabledTextColor () const
sf::Color getDividerColor () const
float getDividerThickness () const
sf::Color getErrorColor () const
sf::Color getFillColor () const
sf::Color getFocusColor () const
const sf::FontgetFont () const
unsigned int getFontSize () const
unsigned int getFontSizeSmall () const
sf::FloatRect getGlobalBounds () const override
sf::Color getHoverColor () const
float getIndent () const
sf::Color getMutedColor () const
sf::Color getOutlineColor () const
float getOutlineThickness () const
float getPadding () const
sf::Vector2f getPosition () const override
float getRadius () const
bool getShowBackground () const
bool getShowDividers () const
sf::Color getTextColor () const
float getTotalHeight () const
float getWidth () 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.
Listoperator= (const List &)=delete
std::size_t rowCount () const
 Return the number of rows.
void setBgColor (const sf::Color &c)
void setDisabledColor (const sf::Color &c)
void setDisabledTextColor (const sf::Color &c)
void setDividerColor (const sf::Color &c)
void setDividerThickness (float t)
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 setIndent (float i)
void setIndentOffset (float offset)
 Set the current indentation offset in pixels. Called automatically by a parent List when nesting.
void setMutedColor (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 setShowBackground (bool b)
void setShowDividers (bool b)
void setTextColor (const sf::Color &c)
void setWidth (float width)
 Set the total width of the list.
void unlockSettings ()
 Allow applySettings() to take effect again.
void unlockTheme ()
 Resume reacting to global theme changes.

Public Attributes

sf::Color bgColor = sf::Color(30, 30, 30)
sf::Color disabledColor = sf::Color(60, 60, 60)
sf::Color disabledTextColor = sf::Color(120, 120, 120)
sf::Color dividerColor = sf::Color(80, 80, 80)
float dividerThickness = 1.f
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::Fontfont = &FontManager<>::getDefault()
unsigned int fontSize = 14
unsigned int fontSizeSmall = 11
sf::Color hoverColor = sf::Color(70, 130, 230)
float indent = 20.f
 Indentation added to nested Lists.
sf::Color mutedColor = sf::Color(120, 120, 120)
sf::Color outlineColor = sf::Color(100, 100, 100)
float outlineThickness = 1.5f
float padding = 8.f
float radius = 8.f
bool showBackground = false
bool showDividers = true
sf::Color textColor = sf::Color::White

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.

Detailed Description

A vertically stacked list of rows with optional dividers and background.

List is a layout container that stacks rows vertically and optionally separates them with dividers. Each row is either:

  • A ListItem created internally via addItem() — owned and styled by the list. This is the typical path for standard rows.
  • Any ml::Core component passed to add() — not owned, not resized. Use this for custom rows, section headers, separators, etc.

Style changes via applySettings(), applyTheme() or applyStyle() automatically propagate to all internally owned ListItem rows.

Usage — standard rows

ml::List settings;
settings.setWidth(400.f);
settings.setPosition({40.f, 100.f});
// Row with label only
settings.addItem("Wi-Fi");
// Row with label + description
settings.addItem("Bluetooth", "Pair devices wirelessly");
// Row with end-slot toggle
ml::PillToggle darkMode;
auto& item = settings.addItem("Dark mode");
item.setEnd(darkMode);
// Row with start-slot icon and end-slot toggle
ml::Sprite wifiIcon;
wifiIcon.setTexture(wifiTexture);
ml::PillToggle wifiToggle;
auto& wifi = settings.addItem("Wi-Fi");
wifi.setStart(wifiIcon);
wifi.setEnd(wifiToggle);
addComponent(settings);
A vertically stacked list of rows with optional dividers and background.
Definition List.h:104
void setPosition(const sf::Vector2f &position) override
void setWidth(float width)
Set the total width of the list.
ListItem & addItem(const std::string &label, const std::string &description="")
Create and own a ListItem with a label.
void setEnd(ml::Core &component)
Assign a component to the end (right) slot.
void setStart(ml::Core &component)
Assign a component to the start (left) slot.
iOS-style oval pill switch with animated sliding thumb.
Definition PillToggle.h:70
A framework-integrated sprite.
Definition Sprite.h:47
void setTexture(const Texture &texture, bool resetRect=false)

Usage — custom row component

header.setFillColor(sf::Color(50, 50, 50));
settings.add(header); // not owned — do addComponent separately if needed
void add(ml::Core &component)
Add any ml::Core component as a row.
A framework-integrated rectangle with optional rounded corners.
Definition Rectangle.h:48
void setFillColor(Color color)

Nested lists

sub.addItem("Option A");
sub.addItem("Option B");
settings.add(sub); // sub draws indented via its own position
See also
ListItem, ListSettings, ListTheme, ListStyle

Definition at line 100 of file List.h.

Member Typedef Documentation

◆ Flag

Definition at line 106 of file List.h.

◆ State

Definition at line 107 of file List.h.

Constructor & Destructor Documentation

◆ List() [1/2]

ml::List::List ( const sf::Font & font = FontManager<>::getDefault())
explicit

◆ List() [2/2]

ml::List::List ( const List & )
delete

Member Function Documentation

◆ add()

void ml::List::add ( ml::Core & component)

Add any ml::Core component as a row.

The component is NOT owned by the list — the caller manages its lifetime. The list does not resize or restyle it; it simply positions it in the row sequence.

Parameters
componentAny ml::Core (including List for nesting).

◆ addItem()

ListItem & ml::List::addItem ( const std::string & label,
const std::string & description = "" )

Create and own a ListItem with a label.

Returns a reference to the created item so the caller can configure slots (setStart, setEnd, onClick etc.) immediately after.

Parameters
labelPrimary label text.
descriptionOptional secondary description line. Pass "" to omit.
Returns
Reference to the newly created ListItem.

◆ applyFrom()

ListTheme & ml::ListTheme::applyFrom ( const Theme & t)
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 30 of file ListTheme.h.

◆ applySettings()

template<typename S>
void ml::List::applySettings ( const S & s)
inline

Definition at line 145 of file List.h.

◆ applyStyle()

template<typename St>
void ml::List::applyStyle ( const St & s)
inline

Definition at line 165 of file List.h.

◆ applyTheme()

template<typename T>
void ml::List::applyTheme ( const T & t)
inline

Definition at line 155 of file List.h.

◆ clear()

void ml::List::clear ( )

Remove all rows. Owned ListItem objects are destroyed.

◆ draw()

void ml::List::draw ( sf::RenderTarget & target,
sf::RenderStates states ) const
overrideprotected

◆ getBgColor()

sf::Color ml::ListTheme::getBgColor ( ) const
inlinenodiscardinherited

Definition at line 48 of file ListTheme.h.

◆ getDisabledColor()

sf::Color ml::ControlTheme::getDisabledColor ( ) const
inlinenodiscardinherited

Definition at line 75 of file ControlTheme.h.

◆ getDisabledTextColor()

sf::Color ml::ControlTheme::getDisabledTextColor ( ) const
inlinenodiscardinherited

Definition at line 76 of file ControlTheme.h.

◆ getDividerColor()

sf::Color ml::ListTheme::getDividerColor ( ) const
inlinenodiscardinherited

Definition at line 49 of file ListTheme.h.

◆ getDividerThickness()

float ml::ListSettings::getDividerThickness ( ) const
inlinenodiscardinherited

Definition at line 42 of file ListSettings.h.

◆ getErrorColor()

sf::Color ml::ControlTheme::getErrorColor ( ) const
inlinenodiscardinherited

Definition at line 74 of file ControlTheme.h.

◆ getFillColor()

sf::Color ml::GraphicTheme::getFillColor ( ) const
inlinenodiscardinherited

Definition at line 67 of file GraphicTheme.h.

◆ getFocusColor()

sf::Color ml::ControlTheme::getFocusColor ( ) const
inlinenodiscardinherited

Definition at line 73 of file ControlTheme.h.

◆ getFont()

const sf::Font * ml::ControlTheme::getFont ( ) const
inlinenodiscardinherited

Definition at line 80 of file ControlTheme.h.

◆ getFontSize()

unsigned int ml::ControlTheme::getFontSize ( ) const
inlinenodiscardinherited

Definition at line 81 of file ControlTheme.h.

◆ getFontSizeSmall()

unsigned int ml::ControlTheme::getFontSizeSmall ( ) const
inlinenodiscardinherited

Definition at line 82 of file ControlTheme.h.

◆ getGlobalBounds()

sf::FloatRect ml::List::getGlobalBounds ( ) const
override

◆ getHoverColor()

sf::Color ml::ControlTheme::getHoverColor ( ) const
inlinenodiscardinherited

Definition at line 72 of file ControlTheme.h.

◆ getIndent()

float ml::ListSettings::getIndent ( ) const
inlinenodiscardinherited

Definition at line 43 of file ListSettings.h.

◆ getMutedColor()

sf::Color ml::ControlTheme::getMutedColor ( ) const
inlinenodiscardinherited

Definition at line 78 of file ControlTheme.h.

◆ getOutlineColor()

sf::Color ml::GraphicTheme::getOutlineColor ( ) const
inlinenodiscardinherited

Definition at line 68 of file GraphicTheme.h.

◆ getOutlineThickness()

float ml::GraphicTheme::getOutlineThickness ( ) const
inlinenodiscardinherited

Definition at line 69 of file GraphicTheme.h.

◆ getPadding()

float ml::ControlTheme::getPadding ( ) const
inlinenodiscardinherited

Definition at line 79 of file ControlTheme.h.

◆ getPosition()

sf::Vector2f ml::List::getPosition ( ) const
override

◆ getRadius()

float ml::GraphicTheme::getRadius ( ) const
inlinenodiscardinherited

Definition at line 70 of file GraphicTheme.h.

◆ getShowBackground()

bool ml::ListSettings::getShowBackground ( ) const
inlinenodiscardinherited

Definition at line 41 of file ListSettings.h.

◆ getShowDividers()

bool ml::ListSettings::getShowDividers ( ) const
inlinenodiscardinherited

Definition at line 40 of file ListSettings.h.

◆ getTextColor()

sf::Color ml::ControlTheme::getTextColor ( ) const
inlinenodiscardinherited

Definition at line 77 of file ControlTheme.h.

◆ getTotalHeight()

float ml::List::getTotalHeight ( ) const
nodiscard

◆ getWidth()

float ml::List::getWidth ( ) const
inlinenodiscard

Definition at line 221 of file List.h.

◆ isSettingsLocked()

bool ml::Themeable::isSettingsLocked ( ) const
inlinenodiscardinherited

Return true if applySettings() is currently blocked.

Definition at line 115 of file Themeable.h.

◆ isThemeLocked()

bool ml::Themeable::isThemeLocked ( ) const
inlinenodiscardinherited

Return true if this component ignores theme changes.

Definition at line 97 of file Themeable.h.

◆ lockSettings()

void ml::Themeable::lockSettings ( )
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.

◆ 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::List::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:

void onThemeApplied(const Theme& theme) override
{
if (isThemeLocked()) return;
MySettings::applyTheme(theme);
syncFromSettings();
}
void onThemeApplied(const Theme &theme) override
Called by ThemeManager when the active theme changes.
bool isThemeLocked() const
Return true if this component ignores theme changes.
Definition Themeable.h:97
Universal design token set applied across all Themeable components.
Definition Theme.h:70
Parameters
themeThe newly active theme.

Implements ml::Themeable.

◆ operator=()

List & ml::List::operator= ( const List & )
delete

◆ rowCount()

std::size_t ml::List::rowCount ( ) const
inlinenodiscard

Return the number of rows.

Definition at line 208 of file List.h.

◆ setBgColor()

void ml::ListTheme::setBgColor ( const sf::Color & c)
inlineinherited

Definition at line 51 of file ListTheme.h.

◆ setDisabledColor()

void ml::ControlTheme::setDisabledColor ( const sf::Color & c)
inlineinherited

Definition at line 87 of file ControlTheme.h.

◆ setDisabledTextColor()

void ml::ControlTheme::setDisabledTextColor ( const sf::Color & c)
inlineinherited

Definition at line 88 of file ControlTheme.h.

◆ setDividerColor()

void ml::ListTheme::setDividerColor ( const sf::Color & c)
inlineinherited

Definition at line 52 of file ListTheme.h.

◆ setDividerThickness()

void ml::ListSettings::setDividerThickness ( float t)
inlineinherited

Definition at line 47 of file ListSettings.h.

◆ setErrorColor()

void ml::ControlTheme::setErrorColor ( const sf::Color & c)
inlineinherited

Definition at line 86 of file ControlTheme.h.

◆ setFillColor()

void ml::GraphicTheme::setFillColor ( const sf::Color & c)
inlineinherited

Definition at line 72 of file GraphicTheme.h.

◆ setFocusColor()

void ml::ControlTheme::setFocusColor ( const sf::Color & c)
inlineinherited

Definition at line 85 of file ControlTheme.h.

◆ setFont() [1/2]

void ml::ControlTheme::setFont ( const sf::Font && )
deleteinherited

◆ setFont() [2/2]

void ml::ControlTheme::setFont ( const sf::Font & f)
inlineinherited

Definition at line 92 of file ControlTheme.h.

◆ setFontSize()

void ml::ControlTheme::setFontSize ( unsigned int s)
inlineinherited

Definition at line 94 of file ControlTheme.h.

◆ setFontSizeSmall()

void ml::ControlTheme::setFontSizeSmall ( unsigned int s)
inlineinherited

Definition at line 95 of file ControlTheme.h.

◆ setHoverColor()

void ml::ControlTheme::setHoverColor ( const sf::Color & c)
inlineinherited

Definition at line 84 of file ControlTheme.h.

◆ setIndent()

void ml::ListSettings::setIndent ( float i)
inlineinherited

Definition at line 48 of file ListSettings.h.

◆ setIndentOffset()

void ml::List::setIndentOffset ( float offset)
inline

Set the current indentation offset in pixels. Called automatically by a parent List when nesting.

Definition at line 230 of file List.h.

◆ setMutedColor()

void ml::ControlTheme::setMutedColor ( const sf::Color & c)
inlineinherited

Definition at line 90 of file ControlTheme.h.

◆ setOutlineColor()

void ml::GraphicTheme::setOutlineColor ( const sf::Color & c)
inlineinherited

Definition at line 73 of file GraphicTheme.h.

◆ setOutlineThickness()

void ml::GraphicTheme::setOutlineThickness ( float t)
inlineinherited

Definition at line 74 of file GraphicTheme.h.

◆ setPadding()

void ml::ControlTheme::setPadding ( float p)
inlineinherited

Definition at line 91 of file ControlTheme.h.

◆ setPosition()

void ml::List::setPosition ( const sf::Vector2f & position)
override

◆ setRadius()

void ml::GraphicTheme::setRadius ( float r)
inlineinherited

Definition at line 75 of file GraphicTheme.h.

◆ setShowBackground()

void ml::ListSettings::setShowBackground ( bool b)
inlineinherited

Definition at line 46 of file ListSettings.h.

◆ setShowDividers()

void ml::ListSettings::setShowDividers ( bool b)
inlineinherited

Definition at line 45 of file ListSettings.h.

◆ setTextColor()

void ml::ControlTheme::setTextColor ( const sf::Color & c)
inlineinherited

Definition at line 89 of file ControlTheme.h.

◆ setWidth()

void ml::List::setWidth ( float width)

Set the total width of the list.

Owned ListItem rows are automatically resized to this width. External rows added via add() are not resized.

Parameters
widthWidth in pixels.

◆ unlockSettings()

void ml::Themeable::unlockSettings ( )
inlineinherited

Allow applySettings() to take effect again.

Definition at line 112 of file Themeable.h.

◆ 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.

Member Data Documentation

◆ bgColor

sf::Color ml::ListTheme::bgColor = sf::Color(30, 30, 30)
inherited

Definition at line 25 of file ListTheme.h.

◆ disabledColor

sf::Color ml::ControlTheme::disabledColor = sf::Color(60, 60, 60)
inherited

Definition at line 33 of file ControlTheme.h.

◆ disabledTextColor

sf::Color ml::ControlTheme::disabledTextColor = sf::Color(120, 120, 120)
inherited

Definition at line 34 of file ControlTheme.h.

◆ dividerColor

sf::Color ml::ListTheme::dividerColor = sf::Color(80, 80, 80)
inherited

Definition at line 26 of file ListTheme.h.

◆ dividerThickness

float ml::ListSettings::dividerThickness = 1.f
inherited

Definition at line 27 of file ListSettings.h.

◆ errorColor

sf::Color ml::ControlTheme::errorColor = sf::Color(220, 70, 70)
inherited

Definition at line 32 of file ControlTheme.h.

◆ fillColor

sf::Color ml::GraphicTheme::fillColor = sf::Color(40, 40, 40)
inherited

Definition at line 43 of file GraphicTheme.h.

◆ focusColor

sf::Color ml::ControlTheme::focusColor = sf::Color(100, 60, 200)
inherited

Definition at line 31 of file ControlTheme.h.

◆ font

const sf::Font* ml::ControlTheme::font = &FontManager<>::getDefault()
inherited

Definition at line 39 of file ControlTheme.h.

◆ fontSize

unsigned int ml::ControlTheme::fontSize = 14
inherited

Definition at line 40 of file ControlTheme.h.

◆ fontSizeSmall

unsigned int ml::ControlTheme::fontSizeSmall = 11
inherited

Definition at line 41 of file ControlTheme.h.

◆ hoverColor

sf::Color ml::ControlTheme::hoverColor = sf::Color(70, 130, 230)
inherited

Definition at line 30 of file ControlTheme.h.

◆ indent

float ml::ListSettings::indent = 20.f
inherited

Indentation added to nested Lists.

Definition at line 28 of file ListSettings.h.

◆ mutedColor

sf::Color ml::ControlTheme::mutedColor = sf::Color(120, 120, 120)
inherited

Definition at line 36 of file ControlTheme.h.

◆ outlineColor

sf::Color ml::GraphicTheme::outlineColor = sf::Color(100, 100, 100)
inherited

Definition at line 44 of file GraphicTheme.h.

◆ outlineThickness

float ml::GraphicTheme::outlineThickness = 1.5f
inherited

Definition at line 45 of file GraphicTheme.h.

◆ padding

float ml::ControlTheme::padding = 8.f
inherited

Definition at line 37 of file ControlTheme.h.

◆ radius

float ml::GraphicTheme::radius = 8.f
inherited

Definition at line 46 of file GraphicTheme.h.

◆ showBackground

bool ml::ListSettings::showBackground = false
inherited

Definition at line 26 of file ListSettings.h.

◆ showDividers

bool ml::ListSettings::showDividers = true
inherited

Definition at line 25 of file ListSettings.h.

◆ textColor

sf::Color ml::ControlTheme::textColor = sf::Color::White
inherited

Definition at line 35 of file ControlTheme.h.


The documentation for this class was generated from the following file: