23#include "guillaume/components/navigation_drawer.hpp"
36 if (_variant != variant) {
43 const std::vector<NavigationDrawer::Entry> &
52 if (_entries != entries) {
63 std::size_t destinationIndex = 0;
65 for (
auto &entry: _entries) {
69 if (destinationIndex++ == index) {
70 if (entry.disabled != disabled) {
71 entry.disabled = disabled;
82 std::size_t count = 0;
84 for (
const auto &entry: _entries) {
92 const std::vector<ecs::Entity::Identifier> &
95 return _entryEntities;
99 const std::vector<ecs::Entity::Identifier> &identifiers)
101 if (_entryEntities != identifiers) {
102 _entryEntities = identifiers;
108 const std::vector<ecs::Entity::Identifier> &
111 return _destinationEntities;
115 const std::vector<ecs::Entity::Identifier> &identifiers)
117 if (_destinationEntities != identifiers) {
118 _destinationEntities = identifiers;
124 const std::vector<ecs::Entity::Identifier> &
127 return _sectionEntities;
131 const std::vector<ecs::Entity::Identifier> &identifiers)
133 if (_sectionEntities != identifiers) {
134 _sectionEntities = identifiers;
140 const std::vector<ecs::Entity::Identifier> &
143 return _dividerEntities;
147 const std::vector<ecs::Entity::Identifier> &identifiers)
149 if (_dividerEntities != identifiers) {
150 _dividerEntities = identifiers;
164 if (_backdrop != identifier) {
165 _backdrop = identifier;
174 return _onIndexChange;
179 _onIndexChange = std::move(handler);
185 return _updatingSelection;
190 if (_updatingSelection != updating) {
191 _updatingSelection = updating;
State of a navigation drawer: the side sheet that lists the destinations of an app,...
Variant
How the drawer is presented.
const std::vector< ecs::Entity::Identifier > & getSectionEntities(void) const noexcept
Get the section header children.
NavigationDrawer & setBackdrop(ecs::Entity::Identifier identifier)
Record the child that dims the content behind a modal drawer.
NavigationDrawer & setVariant(Variant variant)
Choose how the drawer is presented.
NavigationDrawer & setDestinationDisabled(std::size_t index, bool disabled)
Change the disabled flag recorded for one destination.
Variant getVariant(void) const noexcept
Get how the drawer is presented.
const IndexHandler & getOnIndexChange(void) const noexcept
Get the callback run when a press changes the selected destination.
std::function< void(std::size_t)> IndexHandler
Callback that receives a destination index, starting at 0.
NavigationDrawer & setEntries(const std::vector< Entry > &entries)
Replace the description of every entry.
const std::vector< ecs::Entity::Identifier > & getDestinationEntities(void) const noexcept
Get the destination children.
NavigationDrawer & setSectionEntities(const std::vector< ecs::Entity::Identifier > &identifiers)
Record the section header children.
NavigationDrawer(void)=default
Create the configuration of a standard drawer with no entry.
std::size_t getDestinationCount(void) const noexcept
Count the entries that are destinations.
NavigationDrawer & setEntryEntities(const std::vector< ecs::Entity::Identifier > &identifiers)
Record the child built for each entry, whatever its kind.
NavigationDrawer & setUpdatingSelection(bool updating)
Raise or lower the guard that stops a selection change from triggering another one.
const std::vector< ecs::Entity::Identifier > & getDividerEntities(void) const noexcept
Get the divider children.
NavigationDrawer & setOnIndexChange(IndexHandler handler)
Set the callback run when a press changes the selected destination.
const std::vector< Entry > & getEntries(void) const noexcept
Get the description of every entry.
@ Destination
Pressable destination.
NavigationDrawer & setDestinationEntities(const std::vector< ecs::Entity::Identifier > &identifiers)
Record the destination children.
NavigationDrawer & setDividerEntities(const std::vector< ecs::Entity::Identifier > &identifiers)
Record the divider children.
bool isUpdatingSelection(void) const noexcept
Tell whether systems::NavigationDrawer is changing the selection at this moment.
const std::vector< ecs::Entity::Identifier > & getEntryEntities(void) const noexcept
Get the child built for each entry, whatever its kind.
ecs::Entity::Identifier getBackdrop(void) const noexcept
Get the child that dims the content behind a modal drawer.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
State. Every class here is plain data attached to an entity.