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

State of a floating action button menu (speed dial): a trigger button that expands into a column of action buttons above it. More...

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

Inheritance diagram for guillaume::components::FloatingActionButtonMenu:
Collaboration diagram for guillaume::components::FloatingActionButtonMenu:

Classes

struct  Action
 One entry of the menu: what its button shows and does. More...

Public Types

using StateChangeHandler = std::function<void(bool)>

Public Member Functions

 FloatingActionButtonMenu (void)=default
 Create the state of a closed menu with no action.
 ~FloatingActionButtonMenu (void)=default
 Default destructor.
const std::string & getIconGlyphName (void) const noexcept
 Get the icon the trigger shows while the menu is closed.
FloatingActionButtonMenu & setIconGlyphName (const std::string &name)
 Set the icon the trigger shows while the menu is closed.
const std::vector< Action > & getActions (void) const noexcept
 Get the actions of the menu.
FloatingActionButtonMenu & setActions (std::vector< Action > actions)
 Replace the actions of the menu.
const std::string & getAccessibilityLabel (void) const noexcept
 Get the accessibility label of the trigger button.
FloatingActionButtonMenu & setAccessibilityLabel (const std::string &label)
 Set the accessibility label of the trigger button.
bool isOpen (void) const noexcept
 Check whether the menu is open.
FloatingActionButtonMenu & setOpen (bool open)
 Store whether the menu is open.
const StateChangeHandler & getOnStateChange (void) const noexcept
 Get the callback run when the menu opens or closes.
FloatingActionButtonMenu & setOnStateChange (StateChangeHandler handler)
 Set the callback run when the menu opens or closes.
ecs::Entity::Identifier getTrigger (void) const noexcept
 Get the child entity of the trigger button.
FloatingActionButtonMenu & setTrigger (ecs::Entity::Identifier identifier)
 Record which child entity is the trigger button.
const std::vector< ecs::Entity::Identifier > & getActionButtons (void) const noexcept
 Get the child entities of the action buttons.
FloatingActionButtonMenu & setActionButtons (const std::vector< ecs::Entity::Identifier > &buttons)
 Record which child entities are the action buttons.
Public Member Functions inherited from guillaume::ecs::Component
bool hasChanged (void) const
 Tell whether a value of the component changed since the flags were last reset (the end of the previous frame).
void setHasChanged (bool hasChanged)
 Raise or lower the changed flag.
 Component (void)=default
 Create a component that is not marked as changed.
virtual ~Component (void)=default
 Virtual destructor, so components can be destroyed through the base class.

Static Public Attributes

static constexpr float Spacing = 16.0f
 Gap between the buttons of the column, in dp.

Detailed Description

State of a floating action button menu (speed dial): a trigger button that expands into a column of action buttons above it.

It holds the trigger's icon and accessibility label, the list of actions, whether the menu is open, and the identifiers of the button children.

Role in the frame:

  • entities::FloatingActionButtonMenu writes the configuration and creates one button child per action plus the trigger, then records their identifiers here.
  • systems::FloatingActionButtonMenu (Layout phase) reads it: it shows the action buttons only while open, swaps the trigger icon for a close glyph, and gives the visible buttons to the Layout component of the menu so they are stacked in a column.

setOpen() only stores the flag. To open or close the menu from code and have the state-change callback run, call systems::FloatingActionButtonMenu::setOpen(), open(), close() or toggle().

See also
systems::FloatingActionButtonMenu, components::Button, components::Layout

Definition at line 60 of file floating_action_button_menu.hpp.

Member Typedef Documentation

◆ StateChangeHandler

Called with the new open state (true when open) each time the menu opens or closes.

Definition at line 77 of file floating_action_button_menu.hpp.

Member Function Documentation

◆ getAccessibilityLabel()

const std::string & guillaume::components::FloatingActionButtonMenu::getAccessibilityLabel ( void ) const
noexcept

Get the accessibility label of the trigger button.

Returns
The label, empty when none was given.

Definition at line 60 of file floating_action_button_menu.cpp.

◆ getActionButtons()

const std::vector< ecs::Entity::Identifier > & guillaume::components::FloatingActionButtonMenu::getActionButtons ( void ) const
noexcept

Get the child entities of the action buttons.

Returns
Their identifiers, in action order; entry i is the button of getActions()[i].

Definition at line 119 of file floating_action_button_menu.cpp.

◆ getActions()

const std::vector< FloatingActionButtonMenu::Action > & guillaume::components::FloatingActionButtonMenu::getActions ( void ) const
noexcept

Get the actions of the menu.

Returns
The actions, in the order their buttons are stacked.

Definition at line 46 of file floating_action_button_menu.cpp.

◆ getIconGlyphName()

const std::string & guillaume::components::FloatingActionButtonMenu::getIconGlyphName ( void ) const
noexcept

Get the icon the trigger shows while the menu is closed.

Returns
The glyph name.

Definition at line 30 of file floating_action_button_menu.cpp.

◆ getOnStateChange()

const FloatingActionButtonMenu::StateChangeHandler & guillaume::components::FloatingActionButtonMenu::getOnStateChange ( void ) const
noexcept

Get the callback run when the menu opens or closes.

Returns
The callback, empty when none is set.

Definition at line 90 of file floating_action_button_menu.cpp.

◆ getTrigger()

ecs::Entity::Identifier guillaume::components::FloatingActionButtonMenu::getTrigger ( void ) const
noexcept

Get the child entity of the trigger button.

Returns
Its identifier, or ecs::Entity::InvalidIdentifier before the widget is built.

Definition at line 103 of file floating_action_button_menu.cpp.

Here is the caller graph for this function:

◆ isOpen()

bool guillaume::components::FloatingActionButtonMenu::isOpen ( void ) const
noexcept

Check whether the menu is open.

Returns
True when the action buttons are shown.

Definition at line 75 of file floating_action_button_menu.cpp.

◆ setAccessibilityLabel()

FloatingActionButtonMenu & guillaume::components::FloatingActionButtonMenu::setAccessibilityLabel ( const std::string & label)

Set the accessibility label of the trigger button.

systems::FloatingActionButtonMenu::install() copies it to the trigger's Accessibility. Marks the component changed when the label differs.

Parameters
labelThe text announced for the trigger.
Returns
This component, for chaining.

Definition at line 65 of file floating_action_button_menu.cpp.

Here is the call graph for this function:

◆ setActionButtons()

FloatingActionButtonMenu & guillaume::components::FloatingActionButtonMenu::setActionButtons ( const std::vector< ecs::Entity::Identifier > & buttons)

Record which child entities are the action buttons.

Marks the component changed when the list differs.

Parameters
buttonsTheir identifiers, in action order.
Returns
This component, for chaining.

Definition at line 124 of file floating_action_button_menu.cpp.

Here is the call graph for this function:

◆ setActions()

FloatingActionButtonMenu & guillaume::components::FloatingActionButtonMenu::setActions ( std::vector< Action > actions)

Replace the actions of the menu.

The widget class creates one button child per action from this list. Does not mark the component changed (actions carry callbacks, which cannot be compared).

Parameters
actionsThe new actions.
Returns
This component, for chaining.

Definition at line 52 of file floating_action_button_menu.cpp.

◆ setIconGlyphName()

FloatingActionButtonMenu & guillaume::components::FloatingActionButtonMenu::setIconGlyphName ( const std::string & name)

Set the icon the trigger shows while the menu is closed.

While open, the system shows systems::FloatingActionButtonMenu::CloseGlyph instead. Marks the component changed when the name differs.

Parameters
nameThe glyph name in the icon font.
Returns
This component, for chaining.

Definition at line 36 of file floating_action_button_menu.cpp.

Here is the call graph for this function:

◆ setOnStateChange()

FloatingActionButtonMenu & guillaume::components::FloatingActionButtonMenu::setOnStateChange ( StateChangeHandler handler)

Set the callback run when the menu opens or closes.

Does not mark the component changed.

Parameters
handlerThe callback; it receives true when the menu just opened and false when it just closed.
Returns
This component, for chaining.

Definition at line 96 of file floating_action_button_menu.cpp.

◆ setOpen()

FloatingActionButtonMenu & guillaume::components::FloatingActionButtonMenu::setOpen ( bool open)

Store whether the menu is open.

Marks the component changed when the state differs. It does not run the state-change callback; use systems::FloatingActionButtonMenu::setOpen() for that.

Parameters
openTrue to show the action buttons.
Returns
This component, for chaining.

Definition at line 80 of file floating_action_button_menu.cpp.

Here is the call graph for this function:

◆ setTrigger()

FloatingActionButtonMenu & guillaume::components::FloatingActionButtonMenu::setTrigger ( ecs::Entity::Identifier identifier)

Record which child entity is the trigger button.

Marks the component changed when the identifier differs.

Parameters
identifierThe trigger button child.
Returns
This component, for chaining.

Definition at line 109 of file floating_action_button_menu.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ Spacing

float guillaume::components::FloatingActionButtonMenu::Spacing = 16.0f
staticconstexpr

Gap between the buttons of the column, in dp.

Definition at line 80 of file floating_action_button_menu.hpp.


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