A fixed-size, multi-column data table with a header row.
More...
#include <Malena/Graphics/Controls/Table.h>
A fixed-size, multi-column data table with a header row.
Columns are defined once via addColumn(); rows are appended with addRow() and removed with clear() or removeRow(). When more rows exist than can fit in the visible area the table shows the newest rows (tail view) — no scrollbar, just a live window.
Usage
addComponent(table);
A fixed-size, multi-column data table with a header row.
void setMaxRows(std::size_t max)
Cap the number of stored rows; oldest are dropped on overflow. Pass 0 to disable the limit.
void setSize(const sf::Vector2f &size)
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 setPosition(const sf::Vector2f &pos) override
Column widths of 0 share whatever space remains after fixed columns.
- See also
- TableManifest
Definition at line 62 of file Table.h.
◆ Flag
◆ State
◆ Table() [1/2]
◆ Table() [2/2]
| ml::Table::Table |
( |
const Table & | | ) |
|
|
delete |
◆ addColumn()
| void ml::Table::addColumn |
( |
const std::string & | header, |
|
|
float | width = 0.f ) |
Define a column. Call before adding rows.
- Parameters
-
| header | Column header label. |
| width | Width in pixels; 0 = distribute remaining space evenly. |
◆ addRow()
| void ml::Table::addRow |
( |
const std::vector< std::string > & | cells | ) |
|
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 |
( |
| ) |
|
Remove all data rows (columns are kept).
◆ clearRowColor()
| void ml::Table::clearRowColor |
( |
std::size_t | rowIndex | ) |
|
Remove the colour override for a specific row.
◆ columnCount()
| std::size_t ml::Table::columnCount |
( |
| ) |
const |
|
inlinenodiscard |
◆ draw()
◆ getGlobalBounds()
◆ getPosition()
◆ getSize()
◆ 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::Table::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();
}
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.
Universal design token set applied across all Themeable components.
- Parameters
-
| theme | The newly active theme. |
Implements ml::Themeable.
◆ operator=()
◆ removeRow()
| bool ml::Table::removeRow |
( |
std::size_t | index | ) |
|
Remove a row by index (0 = oldest).
◆ reset()
| void ml::Table::reset |
( |
| ) |
|
Remove all data rows AND all column definitions.
◆ rowCount()
| std::size_t ml::Table::rowCount |
( |
| ) |
const |
|
inlinenodiscard |
◆ setAltRowBgColor()
| void ml::Table::setAltRowBgColor |
( |
const sf::Color & | c | ) |
|
|
inline |
◆ setBorderColor()
| void ml::Table::setBorderColor |
( |
const sf::Color & | c | ) |
|
|
inline |
◆ setDividerColor()
| void ml::Table::setDividerColor |
( |
const sf::Color & | c | ) |
|
|
inline |
◆ setFontSize()
| void ml::Table::setFontSize |
( |
unsigned int | s | ) |
|
|
inline |
◆ setHeaderBgColor()
| void ml::Table::setHeaderBgColor |
( |
const sf::Color & | c | ) |
|
|
inline |
◆ setHeaderHeight()
| void ml::Table::setHeaderHeight |
( |
float | h | ) |
|
|
inline |
◆ setHeaderTextColor()
| void ml::Table::setHeaderTextColor |
( |
const sf::Color & | c | ) |
|
|
inline |
◆ setMaxRows()
| void ml::Table::setMaxRows |
( |
std::size_t | max | ) |
|
Cap the number of stored rows; oldest are dropped on overflow. Pass 0 to disable the limit.
◆ setPadding()
| void ml::Table::setPadding |
( |
float | p | ) |
|
|
inline |
◆ setPosition()
◆ setRowBgColor()
| void ml::Table::setRowBgColor |
( |
const sf::Color & | c | ) |
|
|
inline |
◆ setRowColor()
| void ml::Table::setRowColor |
( |
std::size_t | rowIndex, |
|
|
sf::Color | color ) |
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
-
| rowIndex | 0-based index of the row to highlight. |
| color | Background colour to use instead of the default. |
◆ setRowHeight()
| void ml::Table::setRowHeight |
( |
float | h | ) |
|
|
inline |
◆ setSize()
◆ setTextColor()
| void ml::Table::setTextColor |
( |
const sf::Color & | c | ) |
|
|
inline |
◆ 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: