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_drawer.hpp"
39#include "guillaume/components/overlay.hpp"
40#include "guillaume/components/selection.hpp"
42#include "guillaume/entities/backdrop.hpp"
43#include "guillaume/entities/builder_base.hpp"
44#include "guillaume/entities/surface.hpp"
105 class NavigationDrawer:
106 public SurfaceBase<components::Overlay, components::SelectionGroup,
107 components::NavigationDrawer>
129 Variant _variant { Variant::Standard };
130 std::vector<Entry> _entries {};
131 std::function<void(std::size_t)>
149 std::shared_ptr<NavigationDrawer>
buildEntity(
void)
override;
159 void reset(
void)
override;
189 const std::string &label,
190 const std::string &right =
"",
191 bool disabled =
false);
218 std::function<
void(std::size_t)> onIndexChange);
234 std::shared_ptr<ecs::Entity> parent,
Variant variant,
235 const std::vector<std::pair<std::string, std::string>>
254 template<
typename... Arguments>
static std::shared_ptr<NavigationDrawer>
257 std::shared_ptr<NavigationDrawer> entity(
258 new NavigationDrawer(std::forward<Arguments>(arguments)...));
442 void buildDestinations(
void);
456 const std::vector<std::pair<std::string, std::string>>
474 const std::vector<Entry> &entries,
475 std::function<
void(std::size_t)> onIndexChange);
Variant
How the drawer is presented.
EntryKind
What a drawer entry is.
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)
Builder & withPose(const utility::graphic::PoseF &pose)
Set where the drawer is placed.
Builder & addDivider(void)
Append a horizontal divider after the entries already added.
Builder & withVariant(Variant variant)
Set the variant.
void reset(void) override
Restore the defaults.
Builder & addDestination(const std::string &iconGlyph, const std::string &label, const std::string &right="", bool disabled=false)
Append a destination after the entries already added.
std::shared_ptr< NavigationDrawer > buildEntity(void) override
Build a drawer and its children from the current configuration, without registering it or setting its...
Builder & addSection(const std::string &title)
Append a section title after the entries already added.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Create a builder set to the defaults of reset().
std::shared_ptr< NavigationDrawer > makeNavigationDrawer(std::shared_ptr< ecs::Entity > parent, Variant variant, const std::vector< std::pair< std::string, std::string > > &destinations)
Build a drawer, register it under parent and reset the builder.
Builder & withOnIndexChange(std::function< void(std::size_t)> onIndexChange)
Set the handler called when the user selects another destination.
A side sheet listing destinations, of which exactly one is selected, with optional section titles and...
NavigationDrawer & setDestinationDisabled(std::size_t index, bool disabled)
Enable or disable a destination. Restyles it at once.
NavigationDrawer & select(std::size_t index)
Select a destination and deselect the others.
components::NavigationDrawer::Variant Variant
Variant getVariant(void) const
Get the variant.
NavigationDrawer & close(void)
Close the drawer. Same as hide().
NavigationDrawer & open(void)
Open the drawer. Same as show().
static std::shared_ptr< NavigationDrawer > create(Arguments &&...arguments)
Create a drawer and its children, without registering it in an entity registry.
std::size_t getSelectedIndex(void) const
Get the index of the selected destination.
~NavigationDrawer(void) override
Default destructor.
bool isOpen(void) const
Whether the drawer is open. Same as isVisible().
NavigationDrawer & hide(void)
Hide the drawer and its backdrop.
ecs::Entity::Identifier getDestinationIdentifier(std::size_t index) const
Get the child entity of a destination: its pressable row.
NavigationDrawer & setVariant(Variant variant)
Change the variant.
std::size_t getDividerCount(void) const
Get the number of dividers.
components::NavigationDrawer::Entry Entry
NavigationDrawer & show(void)
Show the drawer, and its backdrop when the variant is Modal.
ecs::Entity::Identifier getBackdropIdentifier(void) const
Get the backdrop: the child that dims what is behind an open Modal drawer.
std::size_t getSectionCount(void) const
Get the number of section titles built.
components::NavigationDrawer::EntryKind EntryKind
Kind of a drawer entry: destination, section title or divider.
bool isVisible(void) const
Whether the drawer is shown.
std::size_t getDestinationCount(void) const
Get the number of destinations.
NavigationDrawer & setOnIndexChange(std::function< void(std::size_t)> onIndexChange)
Set the handler called when the user selects another destination.
ecs::Entity::Identifier getRightIdentifier(std::size_t index) const
Get the trailing text entity of a destination.
ecs::Entity::Identifier getSectionIdentifier(std::size_t index) const
Get the text entity of a section title.
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
Widgets: the classes used to create entities with the right components and children.
Description of one drawer entry, 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...