guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
floating_action_button.hpp
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#pragma once
24
25#include <optional>
26
27#include "guillaume/ecs/component.hpp"
28#include "guillaume/ecs/entity.hpp"
29
31{
32
54 {
55 public:
63 enum class Variant { Surface, Primary, Secondary, Tertiary };
64
68 enum class Mode { Elevated, Flat };
69
74 enum class Size { Small, Medium, Large };
75
76 private:
77 Variant _variant { Variant::Primary };
78 Size _size { Size::Medium };
79 Mode _mode { Mode::Elevated };
80 std::optional<float> _customSize {};
81 bool _lowered { false };
82
83 public:
88 FloatingActionButton(void) = default;
89
93 ~FloatingActionButton(void) = default;
94
99 Variant getVariant(void) const noexcept;
100
107
112 Size getSize(void) const noexcept;
113
121
126 Mode getMode(void) const noexcept;
127
135
142 const std::optional<float> &getCustomSize(void) const noexcept;
143
153 FloatingActionButton &setCustomSize(const std::optional<float> &size);
154
159 bool isLowered(void) const noexcept;
160
170 FloatingActionButton &setLowered(bool lowered);
171 };
172
173} // namespace guillaume::components
FloatingActionButton & setMode(Mode mode)
Choose whether the button casts a shadow.
Mode getMode(void) const noexcept
Get the shadow mode.
FloatingActionButton(void)=default
Create the configuration of a medium, elevated, primary FAB.
Size getSize(void) const noexcept
Get the size step.
Size
Size step: a 40, 56 or 96 dp square container around a 24, 24 or 36 dp icon.
~FloatingActionButton(void)=default
Default destructor.
FloatingActionButton & setVariant(Variant variant)
Choose which theme colors the button uses.
Mode
Whether the button casts a shadow (Elevated) or not (Flat).
const std::optional< float > & getCustomSize(void) const noexcept
Get the container size that replaces the one of the size step.
Variant getVariant(void) const noexcept
Get the color variant.
FloatingActionButton & setLowered(bool lowered)
Lower the resting shadow, or restore it.
Variant
Which theme colors fill the container and the icon.
FloatingActionButton & setSize(Size size)
Choose the size step.
bool isLowered(void) const noexcept
Check whether the resting shadow is lowered.
FloatingActionButton & setCustomSize(const std::optional< float > &size)
Replace the container size of the size step.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
Definition component.hpp:72
State. Every class here is plain data attached to an entity.
@ Secondary
Tones of the secondary accent color.
Definition theme.hpp:142
@ Tertiary
Tones of the tertiary accent color.
Definition theme.hpp:143
@ Primary
Tones of the primary accent color.
Definition theme.hpp:141