Loading...
Searching...
No Matches
ml::TableWith< MANIFEST > Class Template Reference

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

Inheritance diagram for ml::TableWith< MANIFEST >:
[legend]

Public Types

using Flag = TableManifest::Flag
using manifest_type
 The manifest type, used by GatherFlags and GatherStates to locate this class's flag and state declarations.
using State = TableManifest::State

Public Member Functions

void addColumn (const std::string &header, float width=0.f)
 Define a column. Call before adding rows.
void addRow (const std::vector< std::string > &cells)
 Append a data row.
void clear ()
 Remove all data rows (columns are kept).
void clearRowColor (std::size_t rowIndex)
 Remove the colour override for a specific row.
std::size_t columnCount () const
sf::FloatRect getGlobalBounds () const override
sf::Vector2f getPosition () const override
sf::Vector2f getSize () const
std::enable_if_t<!std::is_void_v< T >, T > getState () const
 Return the current state value.
bool isSettingsLocked () const
 Return true if applySettings() is currently blocked.
std::enable_if_t<!std::is_void_v< T >, bool > isState (T state) const
 Return true if currently in state.
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.
std::enable_if_t<!std::is_void_v< T > > onStateEnter (std::function< void(T)> callback)
 Register a callback invoked after each state transition.
std::enable_if_t<!std::is_void_v< T > > onStateExit (std::function< void(T)> callback)
 Register a callback invoked before each state transition.
bool removeRow (std::size_t index)
 Remove a row by index (0 = oldest).
void reset ()
 Remove all data rows AND all column definitions.
std::size_t rowCount () const
void setAltRowBgColor (const sf::Color &c)
void setBorderColor (const sf::Color &c)
void setDividerColor (const sf::Color &c)
void setFontSize (unsigned int s)
void setHeaderBgColor (const sf::Color &c)
void setHeaderHeight (float h)
void setHeaderTextColor (const sf::Color &c)
void setMaxRows (std::size_t max)
 Cap the number of stored rows; oldest are dropped on overflow. Pass 0 to disable the limit.
void setPadding (float p)
void setPosition (const sf::Vector2f &pos) override
void setRowBgColor (const sf::Color &c)
void setRowColor (std::size_t rowIndex, sf::Color color)
 Override the background colour of a specific row.
void setRowHeight (float h)
void setSize (const sf::Vector2f &size)
std::enable_if_t<!std::is_void_v< T > > setState (T newState)
 Transition to a new state.
void setTextColor (const sf::Color &c)
 Table (const sf::Font &font=FontManager<>::getDefault())
 Table (const Table &)=delete
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.

Detailed Description

template<typename MANIFEST>
class ml::TableWith< MANIFEST >

Definition at line 196 of file Table.h.

Member Typedef Documentation

◆ Flag

Definition at line 65 of file Table.h.

◆ manifest_type

using ml::Customizable< MANIFEST >::manifest_type
inherited

The manifest type, used by GatherFlags and GatherStates to locate this class's flag and state declarations.

Definition at line 65 of file Customizable.h.

◆ State

Definition at line 66 of file Table.h.

Member Function Documentation

◆ addColumn()

void ml::Table::addColumn ( const std::string & header,
float width = 0.f )
inherited

Define a column. Call before adding rows.

Parameters
headerColumn header label.
widthWidth in pixels; 0 = distribute remaining space evenly.

◆ addRow()

void ml::Table::addRow ( const std::vector< std::string > & cells)
inherited

Append a data row.

Extra cells are ignored; missing cells are left blank. If setMaxRows() was called and the row count would exceed the limit, the oldest row is discarded first.

◆ clear()

void ml::Table::clear ( )
inherited

Remove all data rows (columns are kept).

◆ clearRowColor()

void ml::Table::clearRowColor ( std::size_t rowIndex)
inherited

Remove the colour override for a specific row.

◆ columnCount()

std::size_t ml::Table::columnCount ( ) const
inlinenodiscardinherited

Definition at line 168 of file Table.h.

◆ draw()

void ml::Table::draw ( sf::RenderTarget & target,
sf::RenderStates states ) const
overrideprotectedinherited

◆ getGlobalBounds()

sf::FloatRect ml::Table::getGlobalBounds ( ) const
overrideinherited

◆ getPosition()

sf::Vector2f ml::Table::getPosition ( ) const
overrideinherited

◆ getSize()

sf::Vector2f ml::Table::getSize ( ) const
inlineinherited

Definition at line 188 of file Table.h.

◆ getState()

std::enable_if_t<!std::is_void_v< T >, T > ml::StateManager< extract_State< MANIFEST >::type >::getState ( ) const
inherited

Return the current state value.

Returns
The active StateEnum value.

◆ isSettingsLocked()

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

Return true if applySettings() is currently blocked.

Definition at line 115 of file Themeable.h.

◆ isState()

std::enable_if_t<!std::is_void_v< T >, bool > ml::StateManager< extract_State< MANIFEST >::type >::isState ( T state) const
inherited

Return true if currently in state.

Parameters
stateThe state value to compare against.
Returns
true if the current state equals state.

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

◆ onStateEnter()

std::enable_if_t<!std::is_void_v< T > > ml::StateManager< extract_State< MANIFEST >::type >::onStateEnter ( std::function< void(T)> callback)
inherited

Register a callback invoked after each state transition.

The callback receives the newly entered state. Only one enter callback is active at a time; calling this again replaces it.

Parameters
callbackFunction called with the new state after each transition.

◆ onStateExit()

std::enable_if_t<!std::is_void_v< T > > ml::StateManager< extract_State< MANIFEST >::type >::onStateExit ( std::function< void(T)> callback)
inherited

Register a callback invoked before each state transition.

The callback receives the state being left. Only one exit callback is active at a time; calling this again replaces it.

Parameters
callbackFunction called with the old state before each transition.

◆ onThemeApplied()

void ml::Table::onThemeApplied ( const Theme & theme)
overrideprotectedvirtualinherited

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.

◆ removeRow()

bool ml::Table::removeRow ( std::size_t index)
inherited

Remove a row by index (0 = oldest).

◆ reset()

void ml::Table::reset ( )
inherited

Remove all data rows AND all column definitions.

◆ rowCount()

std::size_t ml::Table::rowCount ( ) const
inlinenodiscardinherited

Definition at line 167 of file Table.h.

◆ setAltRowBgColor()

void ml::Table::setAltRowBgColor ( const sf::Color & c)
inlineinherited

Definition at line 180 of file Table.h.

◆ setBorderColor()

void ml::Table::setBorderColor ( const sf::Color & c)
inlineinherited

Definition at line 183 of file Table.h.

◆ setDividerColor()

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

Definition at line 182 of file Table.h.

◆ setFontSize()

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

Definition at line 174 of file Table.h.

◆ setHeaderBgColor()

void ml::Table::setHeaderBgColor ( const sf::Color & c)
inlineinherited

Definition at line 177 of file Table.h.

◆ setHeaderHeight()

void ml::Table::setHeaderHeight ( float h)
inlineinherited

Definition at line 173 of file Table.h.

◆ setHeaderTextColor()

void ml::Table::setHeaderTextColor ( const sf::Color & c)
inlineinherited

Definition at line 178 of file Table.h.

◆ setMaxRows()

void ml::Table::setMaxRows ( std::size_t max)
inherited

Cap the number of stored rows; oldest are dropped on overflow. Pass 0 to disable the limit.

◆ setPadding()

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

Definition at line 175 of file Table.h.

◆ setPosition()

void ml::Table::setPosition ( const sf::Vector2f & pos)
overrideinherited

◆ setRowBgColor()

void ml::Table::setRowBgColor ( const sf::Color & c)
inlineinherited

Definition at line 179 of file Table.h.

◆ setRowColor()

void ml::Table::setRowColor ( std::size_t rowIndex,
sf::Color color )
inherited

Override the background colour of a specific row.

The override persists until clearRowColor() or clear() is called. Indices shift automatically when rows are inserted or removed.

Parameters
rowIndex0-based index of the row to highlight.
colorBackground colour to use instead of the default.

◆ setRowHeight()

void ml::Table::setRowHeight ( float h)
inlineinherited

Definition at line 172 of file Table.h.

◆ setSize()

void ml::Table::setSize ( const sf::Vector2f & size)
inlineinherited

Definition at line 187 of file Table.h.

◆ setState()

std::enable_if_t<!std::is_void_v< T > > ml::StateManager< extract_State< MANIFEST >::type >::setState ( T newState)
inherited

Transition to a new state.

Fires the exit callback with the current state, updates the stored state to newState, then fires the enter callback with the new state. Either callback may be unset (nullptr), in which case it is skipped.

Parameters
newStateThe state to transition into.

◆ setTextColor()

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

Definition at line 181 of file Table.h.

◆ Table() [1/2]

template<typename MANIFEST>
ml::Table::Table ( const sf::Font & font = FontManager<>::getDefault())
explicit

◆ Table() [2/2]

template<typename MANIFEST>
ml::Table::Table ( const Table & )
delete

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


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