23#include <unordered_map>
74 using Row = std::vector<std::string>;
76 std::vector<Column> _columns;
77 std::vector<Row> _rows;
78 std::size_t _maxRows = 0;
79 std::unordered_map<std::size_t, sf::Color> _rowColors;
84 float _rowHeight = 28.f;
85 float _headerHeight= 32.f;
87 unsigned int _fontSize = 13u;
88 unsigned int _headerFontSize = 13u;
90 sf::Color _headerBgColor = sf::Color(55, 55, 65);
91 sf::Color _headerTxtColor = sf::Color(200, 200, 210);
92 sf::Color _rowBgColor = sf::Color(30, 30, 30);
93 sf::Color _altRowBgColor = sf::Color(38, 38, 45);
94 sf::Color _textColor = sf::Color(220, 220, 220);
95 sf::Color _dividerColor = sf::Color(70, 70, 80);
96 sf::Color _borderColor = sf::Color(70, 70, 80);
98 std::vector<float> resolveWidths()
const;
100 void drawHeader (sf::RenderTarget&,
const sf::RenderStates&,
101 const std::vector<float>& widths)
const;
102 void drawDataRow (sf::RenderTarget&,
const sf::RenderStates&,
103 const Row&,
float y,
bool alt,
104 const std::vector<float>& widths,
105 const sf::Color* bgOverride =
nullptr)
const;
107 static std::string clampText(
const sf::Font&,
unsigned charSize,
108 const std::string& text,
float maxWidth);
127 void addColumn(
const std::string& header,
float width = 0.f);
136 void addRow(
const std::vector<std::string>& cells);
167 [[nodiscard]] std::size_t
rowCount()
const {
return _rows.size(); }
168 [[nodiscard]] std::size_t
columnCount()
const {
return _columns.size(); }
195 template<
typename MANIFEST>
static const sf::Font & getDefault()
Return the built-in Arial font.
Base class for all Malena manifests.
void onThemeApplied(const Theme &theme) override
Called by ThemeManager when the active theme changes.
void setHeaderBgColor(const sf::Color &c)
void setHeaderTextColor(const sf::Color &c)
TableManifest::State State
void setMaxRows(std::size_t max)
Cap the number of stored rows; oldest are dropped on overflow. Pass 0 to disable the limit.
void setHeaderHeight(float h)
void setDividerColor(const sf::Color &c)
void setSize(const sf::Vector2f &size)
sf::FloatRect getGlobalBounds() const override
void setRowBgColor(const sf::Color &c)
void addColumn(const std::string &header, float width=0.f)
Define a column. Call before adding rows.
sf::Vector2f getPosition() const override
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
std::size_t rowCount() const
void reset()
Remove all data rows AND all column definitions.
void setRowColor(std::size_t rowIndex, sf::Color color)
Override the background colour of a specific row.
bool removeRow(std::size_t index)
Remove a row by index (0 = oldest).
void setTextColor(const sf::Color &c)
Table(const sf::Font &font=FontManager<>::getDefault())
void addRow(const std::vector< std::string > &cells)
Append a data row.
void setAltRowBgColor(const sf::Color &c)
sf::Vector2f getSize() const
void clearRowColor(std::size_t rowIndex)
Remove the colour override for a specific row.
void setFontSize(unsigned int s)
std::size_t columnCount() const
void setRowHeight(float h)
Table(const Table &)=delete
void setPosition(const sf::Vector2f &pos) override
void clear()
Remove all data rows (columns are kept).
Table & operator=(const Table &)=delete
void setBorderColor(const sf::Color &c)
Table(const sf::Font &font=FontManager<>::getDefault())
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
Vector2< float > Vector2f
Universal design token set applied across all Themeable components.