guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::entities::FloatingActionButtonMenu Class Reference

A floating action button menu (speed dial): a trigger FAB that shows a column of smaller action buttons above it when opened. More...

#include <headers/guillaume/entities/floating_action_button_menu.hpp>

Inheritance diagram for guillaume::entities::FloatingActionButtonMenu:
Collaboration diagram for guillaume::entities::FloatingActionButtonMenu:

Classes

class  Builder
 Configures, creates and registers FloatingActionButtonMenu widgets. More...

Public Types

using Action = components::FloatingActionButtonMenu::Action
Public Types inherited from guillaume::ecs::Entity
using Identifier = std::size_t
 The key under which an entity's components are stored. Systems and components refer to entities by this value.
using Signature = std::bitset<128>
 A set of component types, one bit per type (bit position given by ComponentTypeId, MaxComponentTypes bits).

Public Member Functions

 ~FloatingActionButtonMenu (void)
 Destructor.
FloatingActionButtonMenu & open (void)
 Open the menu: show the action buttons and the close glyph on the trigger, at once.
FloatingActionButtonMenu & close (void)
 Close the menu: hide the action buttons and restore the trigger icon, at once.
FloatingActionButtonMenu & toggle (void)
 Open the menu when it is closed, close it when it is open.
bool isOpen (void) const
 Get whether the menu is open.
FloatingActionButtonMenu & setOnStateChange (std::function< void(bool)> onStateChange)
 Set the handler called when the menu opens or closes (Paper onStateChange).
std::size_t getActionCount (void) const
 Get the number of actions.
ecs::Entity::Identifier getTriggerIdentifier (void) const
 Get the identifier of the trigger button, a FloatingActionButton child of the menu.
ecs::Entity::Identifier getActionIdentifier (std::size_t index) const
 Get the identifier of the button of one action.
Public Member Functions inherited from guillaume::ecs::ParentEntityFiller< components::Transform, components::Bound, components::Layout, components::FloatingActionButtonMenu >
 ParentEntityFiller (ComponentRegistry &componentRegistry)
 Create the entity, its listed components and its components::Hierarchy. It owns no child yet.
virtual ~ParentEntityFiller (void)=default
 Destroy the entity object and release the children it owns; components stay in the registry (see EntityRegistry::removeEntity).
Public Member Functions inherited from guillaume::ecs::Entity
 Entity (void)
 Create an entity with a fresh identifier, an empty signature, no parent and no component.
virtual ~Entity (void)=default
 Destroy the entity object.
Entity::Identifier getIdentifier (void) const noexcept
 Get the identifier of the entity.
Entity::Signature getSignature (void) const noexcept
 Get the set of component types the entity declares.
void setSignature (const Signature &signature)
 Replace the signature of the entity.
std::int32_t getLayer (void) const noexcept
 Get the depth of the entity in the tree.
Entity & setParent (std::shared_ptr< Entity > parent)
 Attach the entity under another one, or detach it.
std::vector< Identifier > releaseComponents (void)
 Drop the entity's place in the tree and all its components.
std::shared_ptr< Entity > getParent (void) const noexcept
 Get the parent entity.
Public Member Functions inherited from guillaume::ecs::EntityRegistry
 EntityRegistry (void)=default
 Create a registry.
virtual ~EntityRegistry (void)=default
 Virtual destructor.
void addEntity (std::shared_ptr< Entity > entity)
 Make this registry own an entity, so that it stays alive and systems visit it.
bool removeEntity (Entity::Identifier identifier)
 Remove an entity, with its children and all their components.
void clearEntities (void)
 Remove every entity owned by this registry, with everything they own and all their components.
const std::vector< std::shared_ptr< Entity > > & getEntities (void) const
 Get the entities this registry owns directly.
std::vector< std::shared_ptr< Entity > > getEntitiesBreadthFirst (void)
 List every entity of this registry and of the registries nested in it, level by level.
std::vector< std::shared_ptr< Entity > > getEntitiesBreadthFirst (void) const
 List every entity of this registry and of the registries nested in it, level by level (const overload).
template<InheritFromEntity EntityType>
std::shared_ptr< EntityType > getEntity (Entity::Identifier identifier)
 Find an entity owned directly by this registry, by identifier.
template<InheritFromEntity EntityType>
std::shared_ptr< const EntityType > getEntity (Entity::Identifier identifier) const
 Find an entity owned directly by this registry, by identifier (const overload).
std::vector< Entity::Identifier > getEntityWithSignature (Entity::Signature systemSignature) const
 List the entities that have every component type of a signature, from the root down.
std::vector< Entity::Identifier > getEntityWithSignature (Entity::Signature systemSignature, const EntityTreeTraveler &traveler) const
 List the entities that have every component type of a signature, in the order chosen by a traveler.

Static Public Member Functions

template<typename... Arguments>
static std::shared_ptr< FloatingActionButtonMenu > create (Arguments &&...arguments)
 Create a menu with its trigger and action buttons, without registering it in an entity registry.
Static Public Member Functions inherited from guillaume::ecs::Entity
template<InheritFromComponent... ComponentTypes>
static Signature getSignatureFromTypes (void)
 Build the signature that has exactly the bits of the given component types.

Additional Inherited Members

Static Public Attributes inherited from guillaume::ecs::Entity
static constexpr Identifier InvalidIdentifier
 "No entity": never the identifier of a real entity
Protected Member Functions inherited from guillaume::ecs::ParentEntityFiller< components::Transform, components::Bound, components::Layout, components::FloatingActionButtonMenu >
ComponentRegistry & getComponentRegistry (void)
 Get the registry that stores this entity's components.
Protected Member Functions inherited from guillaume::ecs::ParentEntity
std::vector< std::shared_ptr< Entity > > & accessDirectEntities (void) override
 Give access to the list of entities this entity owns directly.
const std::vector< std::shared_ptr< Entity > > & accessDirectEntities (void) const override
 Give read access to the list of entities this entity owns directly.
Protected Member Functions inherited from guillaume::ecs::Entity
void attachHierarchy (ComponentRegistry &componentRegistry)
 Give the entity a components::Hierarchy in a registry and add that component to its signature.
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.

Detailed Description

A floating action button menu (speed dial): a trigger FAB that shows a column of smaller action buttons above it when opened.

Its state lives in components::FloatingActionButtonMenu (trigger icon, actions, open flag, callback, child identifiers); systems::FloatingActionButtonMenu shows or hides the action buttons, swaps the trigger icon for a close glyph while open and fills the column each frame, in the Layout phase. systems::Layout then places the column. The class itself holds no field: open(), close() and toggle() call the system.

getEntityRegistry());
auto menu = builder.addAction("mail", "Send", [] {
// called when the user clicks the "Send" action
})
.addAction("alarm", [] {})
.withAccessibilityLabel("Actions")
.makeFloatingActionButtonMenu(parent, "add");
menu->setOnStateChange([](bool open) {
// called when the menu opens or closes
});
Configures, creates and registers FloatingActionButtonMenu widgets.
FloatingActionButtonMenu & open(void)
Open the menu: show the action buttons and the close glyph on the trigger, at once.

FloatingActionButtonMenu::create(registry, iconGlyphName, actions, accessibilityLabel) builds the same widget without registering it in an entity registry.

The menu owns its trigger and action buttons: it is the entity registry they are registered in. The actions are fixed at creation. Clicking an action calls its handler and leaves the menu open; call close() from the handler to close it. open(), close() and toggle() call the state-change handler like a click on the trigger does. The click handler of the trigger and the menu's Layout configuration are set by the system; do not replace them.

See also
components::FloatingActionButtonMenu, systems::FloatingActionButtonMenu, FloatingActionButton

Definition at line 87 of file floating_action_button_menu.hpp.

Member Typedef Documentation

◆ Action

One action of the menu: a label (may be empty), an icon glyph name and a click handler.

Definition at line 96 of file floating_action_button_menu.hpp.

Constructor & Destructor Documentation

◆ ~FloatingActionButtonMenu()

guillaume::entities::FloatingActionButtonMenu::~FloatingActionButtonMenu ( void )

Destructor.

Definition at line 116 of file floating_action_button_menu.cpp.

Member Function Documentation

◆ close()

FloatingActionButtonMenu & guillaume::entities::FloatingActionButtonMenu::close ( void )

Close the menu: hide the action buttons and restore the trigger icon, at once.

Calls the state-change handler with false. Does nothing when the menu is already closed.

Returns
Reference to this menu for chaining.

Definition at line 142 of file floating_action_button_menu.cpp.

Here is the call graph for this function:

◆ create()

template<typename... Arguments>
std::shared_ptr< FloatingActionButtonMenu > guillaume::entities::FloatingActionButtonMenu::create ( Arguments &&... arguments)
inlinestatic

Create a menu with its trigger and action buttons, without registering it in an entity registry.

The constructor is private because the buttons need a menu already held by a std::shared_ptr as parent: create() constructs the menu then calls build(), which creates them.

Template Parameters
ArgumentsThe types of the constructor arguments.
Parameters
argumentsThe arguments forwarded to the constructor: (registry, iconGlyphName, actions, accessibilityLabel).
Returns
The new menu, closed.

Definition at line 215 of file floating_action_button_menu.hpp.

Here is the caller graph for this function:

◆ getActionCount()

std::size_t guillaume::entities::FloatingActionButtonMenu::getActionCount ( void ) const

Get the number of actions.

Returns
The number of action buttons, shown or not.

Definition at line 168 of file floating_action_button_menu.cpp.

◆ getActionIdentifier()

ecs::Entity::Identifier guillaume::entities::FloatingActionButtonMenu::getActionIdentifier ( std::size_t index) const

Get the identifier of the button of one action.

Parameters
indexThe index of the action, in the order the actions were added (0 is the first).
Returns
The identifier of the action button, or ecs::Entity::InvalidIdentifier when index is out of range.

Definition at line 180 of file floating_action_button_menu.cpp.

◆ getTriggerIdentifier()

ecs::Entity::Identifier guillaume::entities::FloatingActionButtonMenu::getTriggerIdentifier ( void ) const

Get the identifier of the trigger button, a FloatingActionButton child of the menu.

Returns
The trigger identifier, or ecs::Entity::InvalidIdentifier before the children are built.

Definition at line 174 of file floating_action_button_menu.cpp.

◆ isOpen()

bool guillaume::entities::FloatingActionButtonMenu::isOpen ( void ) const

Get whether the menu is open.

Returns
True when the action buttons are shown. A new menu is closed.

Definition at line 163 of file floating_action_button_menu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open()

FloatingActionButtonMenu & guillaume::entities::FloatingActionButtonMenu::open ( void )

Open the menu: show the action buttons and the close glyph on the trigger, at once.

Calls the state-change handler with true. Does nothing when the menu is already open.

Returns
Reference to this menu for chaining.

Definition at line 135 of file floating_action_button_menu.cpp.

Here is the call graph for this function:

◆ setOnStateChange()

FloatingActionButtonMenu & guillaume::entities::FloatingActionButtonMenu::setOnStateChange ( std::function< void(bool)> onStateChange)

Set the handler called when the menu opens or closes (Paper onStateChange).

It is called after the change, by a click on the trigger and by open(), close() and toggle().

Parameters
onStateChangeThe function that receives the new open state (true when open). Pass an empty function to remove the handler.
Returns
Reference to this menu for chaining.

Definition at line 156 of file floating_action_button_menu.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toggle()

FloatingActionButtonMenu & guillaume::entities::FloatingActionButtonMenu::toggle ( void )

Open the menu when it is closed, close it when it is open.

Calls the state-change handler with the new state. A click on the trigger does the same.

Returns
Reference to this menu for chaining.

Definition at line 149 of file floating_action_button_menu.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: