23#include "guillaume/components/navigation_bar.hpp"
36 if (_variant != variant) {
43 const std::vector<NavigationBar::Destination> &
50 const std::vector<Destination> &destinations)
52 if (_destinations != destinations) {
53 _destinations = destinations;
61 _destinations.push_back(destination);
67 const std::string &badge)
69 if (index < _destinations.size()
70 && _destinations[index].badge != badge) {
71 _destinations[index].badge = badge;
77 const std::vector<ecs::Entity::Identifier> &
80 return _destinationEntities;
84 const std::vector<ecs::Entity::Identifier> &identifiers)
86 if (_destinationEntities != identifiers) {
87 _destinationEntities = identifiers;
96 return _onIndexChange;
101 _onIndexChange = std::move(handler);
113 _onTabPress = std::move(handler);
119 return _updatingSelection;
124 if (_updatingSelection != updating) {
125 _updatingSelection = updating;
NavigationBar & setVariant(Variant variant)
Choose whether every destination shows its label.
NavigationBar(void)=default
Create the configuration of a bar with labels and no destination.
NavigationBar & setDestinationBadge(std::size_t index, const std::string &badge)
Change the badge text recorded for one destination.
NavigationBar & setOnIndexChange(IndexHandler handler)
Set the callback run when a press changes the selected destination.
NavigationBar & addDestination(const Destination &destination)
Append the description of one destination.
const IndexHandler & getOnIndexChange(void) const noexcept
Get the callback run when a press changes the selected destination.
const IndexHandler & getOnTabPress(void) const noexcept
Get the callback run on every destination press.
Variant
Whether every destination shows its label (WithLabels) or only the selected one does (WithoutLabels).
Variant getVariant(void) const noexcept
Get the label visibility rule.
bool isUpdatingSelection(void) const noexcept
Tell whether systems::NavigationBar is changing the selection at this moment.
NavigationBar & setUpdatingSelection(bool updating)
Raise or lower the guard that stops a selection change from triggering another one.
NavigationBar & setDestinationEntities(const std::vector< ecs::Entity::Identifier > &identifiers)
Record the destination children.
std::function< void(std::size_t)> IndexHandler
Callback that receives the index of a destination, starting at 0.
NavigationBar & setOnTabPress(IndexHandler handler)
Set the callback run on every destination press.
const std::vector< ecs::Entity::Identifier > & getDestinationEntities(void) const noexcept
Get the destination children.
NavigationBar & setDestinations(const std::vector< Destination > &destinations)
Replace the description of every destination.
const std::vector< Destination > & getDestinations(void) const noexcept
Get the description of every destination.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
State. Every class here is plain data attached to an entity.
Description of one destination, as given by the user.