guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
floating_action_button_menu.cpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#include "guillaume/components/floating_action_button_menu.hpp"
24
25#include <utility>
26
28{
29 const std::string &
31 {
32 return _iconGlyphName;
33 }
34
37 {
38 if (_iconGlyphName != name) {
39 _iconGlyphName = name;
40 setHasChanged(true);
41 }
42 return *this;
43 }
44
45 const std::vector<FloatingActionButtonMenu::Action> &
47 {
48 return _actions;
49 }
50
52 FloatingActionButtonMenu::setActions(std::vector<Action> actions)
53 {
54 // Actions carry callbacks, which cannot be compared.
55 _actions = std::move(actions);
56 return *this;
57 }
58
59 const std::string &
61 {
62 return _accessibilityLabel;
63 }
64
66 const std::string &label)
67 {
68 if (_accessibilityLabel != label) {
69 _accessibilityLabel = label;
70 setHasChanged(true);
71 }
72 return *this;
73 }
74
75 bool FloatingActionButtonMenu::isOpen(void) const noexcept
76 {
77 return _open;
78 }
79
81 {
82 if (_open != open) {
83 _open = open;
84 setHasChanged(true);
85 }
86 return *this;
87 }
88
91 {
92 return _onStateChange;
93 }
94
97 {
98 _onStateChange = std::move(handler);
99 return *this;
100 }
101
104 {
105 return _trigger;
106 }
107
110 {
111 if (_trigger != identifier) {
112 _trigger = identifier;
113 setHasChanged(true);
114 }
115 return *this;
116 }
117
118 const std::vector<ecs::Entity::Identifier> &
120 {
121 return _actionButtons;
122 }
123
125 const std::vector<ecs::Entity::Identifier> &buttons)
126 {
127 if (_actionButtons != buttons) {
128 _actionButtons = buttons;
129 setHasChanged(true);
130 }
131 return *this;
132 }
133} // namespace guillaume::components
State of a floating action button menu (speed dial): a trigger button that expands into a column of a...
FloatingActionButtonMenu & setActions(std::vector< Action > actions)
Replace the actions of the menu.
const std::vector< Action > & getActions(void) const noexcept
Get the actions of the menu.
const std::vector< ecs::Entity::Identifier > & getActionButtons(void) const noexcept
Get the child entities of the action buttons.
bool isOpen(void) const noexcept
Check whether the menu is open.
FloatingActionButtonMenu & setOpen(bool open)
Store whether the menu is open.
FloatingActionButtonMenu & setAccessibilityLabel(const std::string &label)
Set the accessibility label of the trigger button.
const StateChangeHandler & getOnStateChange(void) const noexcept
Get the callback run when the menu opens or closes.
FloatingActionButtonMenu(void)=default
Create the state of a closed menu with no action.
ecs::Entity::Identifier getTrigger(void) const noexcept
Get the child entity of the trigger button.
const std::string & getIconGlyphName(void) const noexcept
Get the icon the trigger shows while the menu is closed.
FloatingActionButtonMenu & setTrigger(ecs::Entity::Identifier identifier)
Record which child entity is the trigger button.
FloatingActionButtonMenu & setActionButtons(const std::vector< ecs::Entity::Identifier > &buttons)
Record which child entities are the action buttons.
FloatingActionButtonMenu & setIconGlyphName(const std::string &name)
Set the icon the trigger shows while the menu is closed.
FloatingActionButtonMenu & setOnStateChange(StateChangeHandler handler)
Set the callback run when the menu opens or closes.
const std::string & getAccessibilityLabel(void) const noexcept
Get the accessibility label of the trigger button.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
Definition component.cpp:32
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
Definition entity.hpp:86
State. Every class here is plain data attached to an entity.