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

Look of a Material 3 floating action button (FAB): color variant, size and shadow. More...

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

Inheritance diagram for guillaume::components::FloatingActionButton:
Collaboration diagram for guillaume::components::FloatingActionButton:

Public Types

enum class  Variant { Surface , Primary , Secondary , Tertiary }
 Which theme colors fill the container and the icon. More...
enum class  Mode { Elevated , Flat }
 Whether the button casts a shadow (Elevated) or not (Flat). More...
enum class  Size { Small , Medium , Large }
 Size step: a 40, 56 or 96 dp square container around a 24, 24 or 36 dp icon. More...

Public Member Functions

 FloatingActionButton (void)=default
 Create the configuration of a medium, elevated, primary FAB.
 ~FloatingActionButton (void)=default
 Default destructor.
Variant getVariant (void) const noexcept
 Get the color variant.
FloatingActionButton & setVariant (Variant variant)
 Choose which theme colors the button uses.
Size getSize (void) const noexcept
 Get the size step.
FloatingActionButton & setSize (Size size)
 Choose the size step.
Mode getMode (void) const noexcept
 Get the shadow mode.
FloatingActionButton & setMode (Mode mode)
 Choose whether the button casts a shadow.
const std::optional< float > & getCustomSize (void) const noexcept
 Get the container size that replaces the one of the size step.
FloatingActionButton & setCustomSize (const std::optional< float > &size)
 Replace the container size of the size step.
bool isLowered (void) const noexcept
 Check whether the resting shadow is lowered.
FloatingActionButton & setLowered (bool lowered)
 Lower the resting shadow, or restore it.
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.

Detailed Description

Look of a Material 3 floating action button (FAB): color variant, size and shadow.

It sits on the same entity as components::Button, which holds the glyph and the interaction state. entities::FloatingActionButton writes it; systems::FloatingActionButton reads both, each frame in the Layout phase and at once after every input change, and writes the button's Color, Elevation, Borders and Bound and centers the icon child.

Hiding the button is done on components::Button (Button::setVisible(false)): the system then draws it transparent and without shadow.

Every setter compares before writing and marks the component changed only when the value differs.

See also
components::Button, systems::FloatingActionButton, components::ExtendedFloatingActionButton

Definition at line 53 of file floating_action_button.hpp.

Member Enumeration Documentation

◆ Mode

Whether the button casts a shadow (Elevated) or not (Flat).

Definition at line 68 of file floating_action_button.hpp.

◆ Size

Size step: a 40, 56 or 96 dp square container around a 24, 24 or 36 dp icon.

Definition at line 74 of file floating_action_button.hpp.

◆ Variant

Which theme colors fill the container and the icon.

Primary, Secondary and Tertiary use the matching container role. Surface uses the tonal surface color of the button's elevation with a primary icon.

Definition at line 63 of file floating_action_button.hpp.

Member Function Documentation

◆ getCustomSize()

const std::optional< float > & guillaume::components::FloatingActionButton::getCustomSize ( void ) const
noexcept

Get the container size that replaces the one of the size step.

Returns
The extent of the square container, in dp, or std::nullopt when the size step decides.

Definition at line 75 of file floating_action_button.cpp.

◆ getMode()

FloatingActionButton::Mode guillaume::components::FloatingActionButton::getMode ( void ) const
noexcept

Get the shadow mode.

Returns
The mode (Elevated by default).

Definition at line 60 of file floating_action_button.cpp.

◆ getSize()

FloatingActionButton::Size guillaume::components::FloatingActionButton::getSize ( void ) const
noexcept

Get the size step.

Returns
The size (Medium by default).

Definition at line 45 of file floating_action_button.cpp.

◆ getVariant()

FloatingActionButton::Variant guillaume::components::FloatingActionButton::getVariant ( void ) const
noexcept

Get the color variant.

Returns
The variant (Primary by default).

Definition at line 30 of file floating_action_button.cpp.

◆ isLowered()

bool guillaume::components::FloatingActionButton::isLowered ( void ) const
noexcept

Check whether the resting shadow is lowered.

Returns
True when the button rests at elevation level 1.

Definition at line 90 of file floating_action_button.cpp.

◆ setCustomSize()

FloatingActionButton & guillaume::components::FloatingActionButton::setCustomSize ( const std::optional< float > & size)

Replace the container size of the size step.

The corner radius follows: it is the custom size divided by 3.5. The icon keeps the font size of the size step.

Parameters
sizeThe extent of the square container, in dp, or std::nullopt to follow the size step.
Returns
This component, for chaining.

Definition at line 81 of file floating_action_button.cpp.

Here is the call graph for this function:

◆ setLowered()

FloatingActionButton & guillaume::components::FloatingActionButton::setLowered ( bool lowered)

Lower the resting shadow, or restore it.

An elevated button rests at elevation level 3, or level 1 when lowered. The Surface variant takes the surface tone of the same level.

Parameters
loweredTrue to rest at elevation level 1.
Returns
This component, for chaining.

Definition at line 95 of file floating_action_button.cpp.

Here is the call graph for this function:

◆ setMode()

FloatingActionButton & guillaume::components::FloatingActionButton::setMode ( Mode mode)

Choose whether the button casts a shadow.

Parameters
modeElevated for a shadow that rises one level on hover, Flat for no shadow at all.
Returns
This component, for chaining.

Definition at line 65 of file floating_action_button.cpp.

Here is the call graph for this function:

◆ setSize()

FloatingActionButton & guillaume::components::FloatingActionButton::setSize ( Size size)

Choose the size step.

Parameters
sizeThe size; it sets the container extent, the corner radius and the icon font size.
Returns
This component, for chaining.

Definition at line 50 of file floating_action_button.cpp.

Here is the call graph for this function:

◆ setVariant()

FloatingActionButton & guillaume::components::FloatingActionButton::setVariant ( Variant variant)

Choose which theme colors the button uses.

Parameters
variantThe color variant.
Returns
This component, for chaining.

Definition at line 35 of file floating_action_button.cpp.

Here is the call graph for this function:

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