114 std::unique_ptr<ListItem> owned;
117 std::vector<Row> _rows;
118 std::vector<sf::RectangleShape> _dividers;
120 bool _hasPinnedBottom =
false;
125 float _width = 300.f;
130 void rebuildDividers();
131 void applyThemeToOwnedItems();
132 void applySettingsToOwnedItems();
149 static_assert(std::is_base_of_v<ListSettings, S>,
150 "applySettings() requires a type derived from ListSettings");
152 applySettingsToOwnedItems();
159 static_assert(std::is_base_of_v<ListTheme, T>,
160 "applyTheme() requires a type derived from ListTheme");
162 applyThemeToOwnedItems();
166 template<
typename St>
169 static_assert(std::is_base_of_v<ListSettings, St> &&
170 std::is_base_of_v<ListTheme, St>,
171 "applyStyle() requires ListSettings and ListTheme");
174 applyThemeToOwnedItems();
175 applySettingsToOwnedItems();
194 const std::string& description =
"",
195 std::function<
void()> onClick =
nullptr);
215 std::function<
void()> onClick =
nullptr);
243 [[nodiscard]] std::size_t
rowCount()
const {
return _rows.size(); }
256 if (_rows.empty())
return nullptr;
257 return dynamic_cast<ListItem*
>(_rows.back().component);
272 [[nodiscard]]
float getWidth()
const {
return _width; }
292 template<
typename MANIFEST>
Virtual base class for all Malena framework objects.
static const sf::Font & getDefault()
Return the built-in Arial font.
sf::Vector2f getPosition() const override
void applyTheme(const T &t)
std::size_t rowCount() const
Return the number of rows.
ListItem & addItem(const std::string &label, const std::string &description="", std::function< void()> onClick=nullptr)
Create and own a ListItem with a label.
float getTotalHeight() const
void applyStyle(const St &s)
void setIndentOffset(float offset)
Set the current indentation offset in pixels. Called automatically by a parent List when nesting.
void setSize(const sf::Vector2f &size)
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
void clear()
Remove all rows. Owned ListItem objects are destroyed.
void setPosition(const sf::Vector2f &position) override
ListItem & addPinnedBottom(const std::string &label, std::function< void()> onClick=nullptr)
Create a ListItem pinned to the bottom of the list.
List & operator=(const List &)=delete
void setWidth(float width)
Set the total width of the list.
bool remove(const ml::Core *component)
Remove a row by component pointer.
sf::FloatRect getGlobalBounds() const override
void add(ml::Core &component)
Add any ml::Core component as a row.
List(const List &)=delete
bool removeAt(std::size_t index)
Remove a row by index.
ListManifest::State State
ListItem * back()
Return a pointer to the last added owned ListItem, or nullptr if the list is empty or the last row is...
void applySettings(const S &s)
void onThemeApplied(const Theme &theme) override
Called by ThemeManager when the active theme changes.
List(const sf::Font &font=FontManager<>::getDefault())
A single row in a List with start, content and end slots.
List(const sf::Font &font=FontManager<>::getDefault())
Base class for all Malena manifests.
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
Vector2< float > Vector2f
Layout and behaviour settings for List.
Universal design token set applied across all Themeable components.