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

Look of a Material 3 extended floating action button: a FAB that shows a label next to its icon and can collapse to the icon alone. More...

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

Inheritance diagram for guillaume::components::ExtendedFloatingActionButton:
Collaboration diagram for guillaume::components::ExtendedFloatingActionButton:

Public Types

enum class  Variant { Surface , Primary , Secondary , Tertiary }
 Which theme colors fill the container, the icon and the label. 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 container 40, 56 or 96 dp high. More...

Public Member Functions

 ExtendedFloatingActionButton (void)=default
 Create the configuration of a medium, elevated, primary button with its label shown.
 ~ExtendedFloatingActionButton (void)=default
 Default destructor.
Variant getVariant (void) const noexcept
 Get the color variant.
ExtendedFloatingActionButton & setVariant (Variant variant)
 Choose which theme colors the button uses.
Size getSize (void) const noexcept
 Get the size step.
ExtendedFloatingActionButton & setSize (Size size)
 Choose the size step.
Mode getMode (void) const noexcept
 Get the shadow mode.
ExtendedFloatingActionButton & setMode (Mode mode)
 Choose whether the button casts a shadow.
const std::optional< float > & getCustomSize (void) const noexcept
 Get the container height that replaces the one of the size step.
ExtendedFloatingActionButton & setCustomSize (const std::optional< float > &size)
 Replace the container height of the size step.
bool isExtended (void) const noexcept
 Check whether the label is shown.
ExtendedFloatingActionButton & setExtended (bool extended)
 Show the label, or collapse the button to its icon.
bool isLowered (void) const noexcept
 Check whether the resting shadow is lowered.
ExtendedFloatingActionButton & 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 extended floating action button: a FAB that shows a label next to its icon and can collapse to the icon alone.

It sits on the same entity as components::Button, which holds the glyph, the label text and the interaction state. entities::ExtendedFloatingActionButton writes it; systems::ExtendedFloatingActionButton 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 places the icon and label children.

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::ExtendedFloatingActionButton, components::FloatingActionButton

Definition at line 56 of file extended_floating_action_button.hpp.

Member Enumeration Documentation

◆ Mode

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

Definition at line 72 of file extended_floating_action_button.hpp.

◆ Size

Size step: a container 40, 56 or 96 dp high.

Definition at line 77 of file extended_floating_action_button.hpp.

◆ Variant

Which theme colors fill the container, the icon and the label.

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

Definition at line 67 of file extended_floating_action_button.hpp.

Member Function Documentation

◆ getCustomSize()

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

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

Returns
The height, in dp, or std::nullopt when the size step decides.

Definition at line 78 of file extended_floating_action_button.cpp.

◆ getMode()

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

Get the shadow mode.

Returns
The mode (Elevated by default).

Definition at line 62 of file extended_floating_action_button.cpp.

◆ getSize()

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

Get the size step.

Returns
The size (Medium by default).

Definition at line 46 of file extended_floating_action_button.cpp.

◆ getVariant()

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

Get the color variant.

Returns
The variant (Primary by default).

Definition at line 30 of file extended_floating_action_button.cpp.

◆ isExtended()

bool guillaume::components::ExtendedFloatingActionButton::isExtended ( void ) const
noexcept

Check whether the label is shown.

Returns
True when extended, false when collapsed to the icon.

Definition at line 93 of file extended_floating_action_button.cpp.

◆ isLowered()

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

Check whether the resting shadow is lowered.

Returns
True when the button rests at elevation level 1.

Definition at line 108 of file extended_floating_action_button.cpp.

◆ setCustomSize()

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

Replace the container height of the size step.

It is also the width of the collapsed button. The corner radius follows: it is the custom size divided by 3.5.

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

Definition at line 83 of file extended_floating_action_button.cpp.

Here is the call graph for this function:

◆ setExtended()

ExtendedFloatingActionButton & guillaume::components::ExtendedFloatingActionButton::setExtended ( bool extended)

Show the label, or collapse the button to its icon.

Collapsed, the button is a square with the icon centered; the label child stays in the tree but is drawn transparent. An extended button whose label measures nothing is laid out as collapsed.

Parameters
extendedTrue to show the label.
Returns
This component, for chaining.

Definition at line 99 of file extended_floating_action_button.cpp.

Here is the call graph for this function:

◆ setLowered()

ExtendedFloatingActionButton & guillaume::components::ExtendedFloatingActionButton::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 114 of file extended_floating_action_button.cpp.

Here is the call graph for this function:

◆ setMode()

ExtendedFloatingActionButton & guillaume::components::ExtendedFloatingActionButton::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 68 of file extended_floating_action_button.cpp.

Here is the call graph for this function:

◆ setSize()

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

Choose the size step.

Parameters
sizeThe size; it sets the container height, the corner radius and the icon font size (18, 24 or 36 dp).
Returns
This component, for chaining.

Definition at line 52 of file extended_floating_action_button.cpp.

Here is the call graph for this function:

◆ setVariant()

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

Choose which theme colors the button uses.

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

Definition at line 36 of file extended_floating_action_button.cpp.

Here is the call graph for this function:

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