30#include "guillaume/ecs/component.hpp"
31#include "guillaume/ecs/entity.hpp"
66 enum class Variant { SingleLine, TwoLine, ThreeLine };
159 using Path = std::vector<std::size_t>;
174 Variant _variant { Variant::SingleLine };
175 std::vector<Item> _items {};
176 std::vector<Row> _rows {};
177 bool _rowsDirty {
true };
210 const std::vector<Item> &
getItems(
void)
const noexcept;
273 const std::vector<Row> &
getRows(
void)
const noexcept;
State of a divider: a thin horizontal line separating content.
const Item * findItem(const Path &path) const noexcept
Find an entry from its position in the tree.
static constexpr float DefaultWidth
Default width of a list, in dp.
List & setRows(const std::vector< Row > &rows)
Record the entities built for the entries.
Variant getVariant(void) const noexcept
Get the number of text lines a row is meant for.
List & setRowsDirty(bool dirty)
Mark the rows as out of date or as up to date.
ItemKind
What a list entry is.
@ Subheader
Section header (titleSmall text).
List & setVariant(Variant variant)
Set the number of text lines a row is meant for.
List & setItems(std::vector< Item > items)
Replace the entries.
~List(void)=default
Default destructor.
static constexpr const char * CollapsedGlyph
Glyph name of the trailing icon of a collapsed accordion.
Variant
Number of text lines a row is meant for.
static constexpr const char * ExpandedGlyph
Glyph name of the trailing icon of an expanded accordion.
List & setItemDisabled(std::size_t index, bool disabled)
Change the disabled flag recorded for one top-level entry.
bool isRowsDirty(void) const noexcept
Tell whether the rows must be rebuilt from the entries.
const std::vector< Row > & getRows(void) const noexcept
Get the entities built for the entries.
std::vector< std::size_t > Path
const std::vector< Item > & getItems(void) const noexcept
Get the description of every top-level entry.
List(void)=default
Create the configuration of an empty single-line list.
const Row * findRow(const Path &path) const noexcept
Find the entities built for an entry from its position in the tree.
static constexpr float IconSize
Size of the leading and trailing icons, in dp.
List & setItemExpanded(std::size_t index, bool expanded)
Record whether one top-level accordion shows its children.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
State. Every class here is plain data attached to an entity.
Description of one list entry, as given by the user.
ItemKind kind
What the entry is.
std::function< void(void)> onPress
Called on press.
std::string headline
Main text of the row.
std::vector< Item > children
Identifiers of the entities built for one entry.
ecs::Entity::Identifier headline
Headline text child.
std::vector< Row > children
ecs::Entity::Identifier leadingImage
Leading image child.
ecs::Entity::Identifier content
Column holding the headline and supporting text.
ecs::Entity::Identifier entity
Row root (container, subheader text or divider).
ecs::Entity::Identifier view
Pressable row container.
ecs::Entity::Identifier supporting
Supporting text child.
ecs::Entity::Identifier trailingIcon
Trailing icon child (the chevron of an accordion).
bool operator==(const Row &other) const noexcept
Compare two rows.
ecs::Entity::Identifier lead
Leading group.
ecs::Entity::Identifier leadingIcon
Leading icon child.
ecs::Entity::Identifier spacer
Nesting inset of an accordion child.