32#include <utility/graphic/color.hpp>
33#include <utility/graphic/pose.hpp>
35#include "guillaume/ecs/component_registry.hpp"
36#include "guillaume/ecs/entity_builder.hpp"
38#include "guillaume/components/navigation_bar.hpp"
39#include "guillaume/components/selection.hpp"
41#include "guillaume/entities/builder_base.hpp"
42#include "guillaume/entities/surface.hpp"
96 components::NavigationBar>
115 Variant _variant { Variant::WithLabels };
116 std::vector<std::pair<std::string, std::string>>
118 std::vector<Destination> _specs {};
119 std::function<void(std::size_t)>
138 std::shared_ptr<NavigationBar>
buildEntity(
void)
override;
147 void reset(
void)
override;
177 const std::string &label,
178 const std::string &focusedIconGlyph =
"",
179 const std::string &badge =
"");
189 std::function<
void(std::size_t)> onIndexChange);
205 std::shared_ptr<ecs::Entity> parent,
Variant variant,
206 const std::vector<std::pair<std::string, std::string>>
218 void buildDestinations(
void);
236 template<
typename... Arguments>
237 static std::shared_ptr<NavigationBar>
create(Arguments &&...arguments)
239 std::shared_ptr<NavigationBar> entity(
240 new NavigationBar(std::forward<Arguments>(arguments)...));
273 const std::string &label);
402 const std::vector<std::pair<std::string, std::string>>
419 const std::vector<Destination> &destinations,
420 std::function<
void(std::size_t)> onIndexChange);
Variant
Whether every destination shows its label (WithLabels) or only the selected one does (WithoutLabels).
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
Owns entities and gives the systems the list of entities to visit.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
std::shared_ptr< NavigationBar > buildEntity(void) override
Build a navigation bar and its destinations from the current configuration, without registering it or...
Builder & withOnIndexChange(std::function< void(std::size_t)> onIndexChange)
Set the handler called when the user selects another destination (Paper onIndexChange).
Builder & withPose(const utility::graphic::PoseF &pose)
Set where the bar is placed.
std::shared_ptr< NavigationBar > makeNavigationBar(std::shared_ptr< ecs::Entity > parent, Variant variant, const std::vector< std::pair< std::string, std::string > > &destinations)
Build a navigation bar, register it under parent and reset the builder.
Builder & addDestination(const std::string &iconGlyph, const std::string &label, const std::string &focusedIconGlyph="", const std::string &badge="")
Append a destination after the ones already added.
Builder & withVariant(Variant variant)
Set the variant.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Create a builder set to the defaults of reset().
void reset(void) override
Restore the defaults.
A bottom bar of destinations (icon, label, optional badge) of which exactly one is selected.
NavigationBar & setOnTabPress(std::function< void(std::size_t)> onTabPress)
Set the handler called on every destination press, even on the selected one (Paper onTabPress).
std::size_t getSelectedIndex(void) const
Get the index of the selected destination.
components::NavigationBar::Destination Destination
ecs::Entity::Identifier getBadgeIdentifier(std::size_t index) const
Get the badge entity of a destination.
NavigationBar & setOnIndexChange(std::function< void(std::size_t)> onIndexChange)
Set the handler called when the user selects another destination (Paper onIndexChange).
components::NavigationBar::Variant Variant
NavigationBar & addDestination(const std::string &iconGlyph, const std::string &label)
Append a destination without focused icon or badge.
ecs::Entity::Identifier getLabelIdentifier(std::size_t index) const
Get the label entity of a destination.
NavigationBar & setVariant(Variant variant)
Change the variant. Restyles at once.
NavigationBar & setBadge(std::size_t index, const std::string &badge)
Change the badge label of a destination.
Variant getVariant(void) const
Get the variant.
std::size_t getDestinationCount(void) const
Get the number of destinations.
ecs::Entity::Identifier getIconIdentifier(std::size_t index) const
Get the icon entity of a destination.
NavigationBar & select(std::size_t index)
Select a destination and deselect the others.
ecs::Entity::Identifier getIndicatorIdentifier(std::size_t index) const
Get the active-indicator pill of a destination: the rounded shape behind the icon.
static std::shared_ptr< NavigationBar > create(Arguments &&...arguments)
Create a navigation bar and its destination children, without registering it in an entity registry.
ecs::Entity::Identifier getDestinationIdentifier(std::size_t index) const
Get the child entity of a destination: the pressable area holding its indicator, icon and label.
~NavigationBar(void) override
Default destructor.
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
Widgets: the classes used to create entities with the right components and children.
Description of one destination, as given by the user.
Everything needed to set up a surface in one value: where it is, how it looks and how it arranges its...