30#include "guillaume/ecs/component.hpp"
31#include "guillaume/ecs/entity.hpp"
62 enum class Variant { WithLabels, WithoutLabels };
86 static constexpr float Height = 80.0f;
89 Variant _variant { Variant::WithLabels };
90 std::vector<Destination> _destinations {};
91 std::vector<ecs::Entity::Identifier>
92 _destinationEntities {};
95 bool _updatingSelection {
false };
163 const std::string &badge);
170 const std::vector<ecs::Entity::Identifier> &
183 const std::vector<ecs::Entity::Identifier> &identifiers);
static constexpr float Height
Height of the bar, in dp.
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(void)=default
Default destructor.
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.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
State. Every class here is plain data attached to an entity.
Description of one destination, as given by the user.
std::string label
Text under the icon.
std::string icon
Icon glyph name while not selected.
std::string badge
Badge text; empty means no badge.
bool operator==(const Destination &other) const =default
Compare two destinations.