5#ifndef MALENA_LISTITEM_H
6#define MALENA_LISTITEM_H
32 enum class Flag { DISABLED };
95 bool _hasDescription =
false;
96 bool _hasCustomContent =
false;
101 float _width = 300.f;
104 std::function<void()> _onClickCb;
108 void applyVisualState();
109 float contentHeight()
const;
123 static_assert(std::is_base_of_v<ListItemSettings, S>,
124 "applySettings() requires a type derived from ListItemSettings");
132 static_assert(std::is_base_of_v<ListItemTheme, T>,
133 "applyTheme() requires a type derived from ListItemTheme");
139 template<
typename St>
142 static_assert(std::is_base_of_v<ListItemSettings, St> &&
143 std::is_base_of_v<ListItemTheme, St>,
144 "applyStyle() requires ListItemSettings and ListItemTheme");
207 [[nodiscard]]
float getWidth()
const {
return _width; }
218 template<
typename MANIFEST>
Virtual base class for all Malena framework objects.
static const sf::Font & getDefault()
Return the built-in Arial font.
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.
void setWidth(float width)
Set the total row width. Called automatically by List when the item is added.
sf::Vector2f getPosition() const override
std::string getLabel() const
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
void applyTheme(const T &t)
void onThemeApplied(const Theme &theme) override
Called by ThemeManager when the active theme changes.
void setDescription(const std::string &text)
Set an optional secondary description line below the label. Pass an empty string to remove.
ListItem(const sf::Font &font=FontManager<>::getDefault())
void setPosition(const sf::Vector2f &position) override
void onClick(std::function< void()> callback)
Register a callback fired when the row is clicked.
void setLabel(const std::string &text)
Set the primary label text.
void applySettings(const S &s)
void setContent(ml::Core &component)
Replace the built-in label/description with a custom component.
void setEnabled(bool enabled)
sf::FloatRect getGlobalBounds() const override
ListItemManifest::State State
ListItemManifest::Flag Flag
void applyStyle(const St &s)
std::string getDescription() const
ListItem(const sf::Font &font=FontManager<>::getDefault())
Base class for all Malena manifests.
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
@ HOVERED
Mouse is currently over this component (set by HoverableDispatcher).
Vector2< float > Vector2f
Layout and behaviour settings for ListItem.
Color and font tokens for ListItem.
Universal design token set applied across all Themeable components.