23#include "guillaume/components/list.hpp"
40 return left.headline == right.headline
41 && left.supporting == right.supporting
42 && left.leadingIcon == right.leadingIcon
43 && left.trailingIcon == right.trailingIcon
44 && left.leadingImage == right.leadingImage
45 && left.disabled == right.disabled && left.kind == right.kind
46 && left.expanded == right.expanded
47 && std::equal(left.children.begin(), left.children.end(),
48 right.children.begin(), right.children.end(),
55 return entity == other.entity &&
view == other.view
56 &&
lead == other.lead &&
spacer == other.spacer
70 if (_variant != variant) {
84 const bool same = std::equal(_items.begin(), _items.end(),
85 items.begin(), items.end(), sameItem);
87 _items = std::move(items);
96 if (path.empty() || path[0] >= _items.size()) {
100 const Item *item = &_items[path[0]];
101 for (std::size_t depth = 1; depth < path.size(); ++depth) {
102 if (path[depth] >= item->
children.size()) {
105 item = &item->
children[path[depth]];
112 if (path.empty() || path[0] >= _rows.size()) {
116 const Row *row = &_rows[path[0]];
117 for (std::size_t depth = 1; depth < path.size(); ++depth) {
118 if (path[depth] >= row->
children.size()) {
128 if (index < _items.size() && _items[index].disabled != disabled) {
129 _items[index].disabled = disabled;
137 if (index < _items.size() && !_items[index].children.empty()
138 && _items[index].expanded != expanded) {
139 _items[index].expanded = expanded;
166 if (_rowsDirty != dirty) {
const Item * findItem(const Path &path) const noexcept
Find an entry from its position in the tree.
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.
List & setVariant(Variant variant)
Set the number of text lines a row is meant for.
List & setItems(std::vector< Item > items)
Replace the entries.
Variant
Number of text lines a row is meant for.
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.
List & setItemExpanded(std::size_t index, bool expanded)
Record whether one top-level accordion shows its children.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
State. Every class here is plain data attached to an entity.
Description of one list entry, as given by the user.
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.