2#ifndef MALENA_ACCORDION_H
3#define MALENA_ACCORDION_H
79 std::unique_ptr<ListItem> header;
80 std::unique_ptr<List> content;
81 float contentHeight = 120.f;
82 bool expanded =
false;
85 std::vector<Section> _sections;
90 std::function<void(std::size_t,
bool)> _onSectionChanged;
111 static_assert(std::is_base_of_v<AccordionSettings, S>,
112 "applySettings() requires AccordionSettings");
120 static_assert(std::is_base_of_v<AccordionTheme, T>,
121 "applyTheme() requires AccordionTheme");
125 template<
typename St>
128 static_assert(std::is_base_of_v<AccordionSettings, St> &&
129 std::is_base_of_v<AccordionTheme, St>,
130 "applyStyle() requires AccordionSettings and AccordionTheme");
169 [[nodiscard]] std::size_t
sectionCount()
const {
return _sections.size(); }
178 [[nodiscard]]
float getWidth()
const {
return _width; }
188 template<
typename MANIFEST>
void onSectionChanged(std::function< void(std::size_t index, bool expanded)> cb)
Fired when a section is expanded or collapsed.
bool isExpanded(std::size_t index) const
Return whether a section is expanded.
SectionRef addSection(const std::string &label, float contentHeight=120.f)
Add a section, creating its ListItem header and List content.
std::size_t sectionCount() const
Return the number of sections.
void setWidth(float width)
Accordion(const sf::Font &font=FontManager<>::getDefault())
void setPosition(const sf::Vector2f &position) override
sf::Vector2f getPosition() const override
AccordionManifest::State State
void applyStyle(const St &s)
void applySettings(const S &s)
void expand(std::size_t index)
Expand a section by index. Collapses others if exclusive.
AccordionManifest::Flag Flag
sf::FloatRect getGlobalBounds() const override
void applyTheme(const T &t)
void setSize(const sf::Vector2f &size)
void onThemeApplied(const Theme &theme) override
Called by ThemeManager when the active theme changes.
void collapse(std::size_t index)
Collapse a section by index.
void toggle(std::size_t index)
Toggle a section's expanded state.
Accordion & operator=(const Accordion &)=delete
float getTotalHeight() const
void removeSection(std::size_t index)
Remove a section by index.
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
Accordion(const Accordion &)=delete
Accordion(const sf::Font &font=FontManager<>::getDefault())
static const sf::Font & getDefault()
Return the built-in Arial font.
A vertically stacked list of rows with optional dividers and background.
A single row in a List with start, content and end slots.
Base class for all Malena manifests.
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
Vector2< float > Vector2f
Universal design token set applied across all Themeable components.