Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
fab.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include <QtCore/qobject.h>
7#include <QtQml/qqmlregistration.h>
8
9#include "elevationtokens.h"
10#include "shapetokens.h"
11#include "statetokens.h"
12
13// Component values map to the AndroidX Material 3 generated tokens:
14// https://android.googlesource.com/platform/frameworks/support/+/5ba2cdd61be7b6945db999b238d14f3c626136fb/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/tokens/
15// FabBaselineTokens.kt, FabMediumTokens.kt, FabLargeTokens.kt, and
16// FabPrimaryContainerTokens.kt (VERSION: v0_14_0); ExtendedFabPrimaryTokens.kt
17// (VERSION: v0_103); ExtendedFabSmallTokens.kt, ExtendedFabMediumTokens.kt, and
18// ExtendedFabLargeTokens.kt (VERSION: v0_14_0); and ../FloatingActionButton.kt for
19// the corrected Medium and Large labeled FAB icon-label spacing.
20
21namespace Fluid {
22
24struct Fab
25{
26 Q_GADGET
27 QML_ANONYMOUS
28
29 Q_PROPERTY(qreal containerHeight READ containerHeight CONSTANT FINAL)
30 Q_PROPERTY(Fluid::ShapeValue containerShape READ containerShape CONSTANT FINAL)
31 Q_PROPERTY(qreal containerWidth READ containerWidth CONSTANT FINAL)
32 Q_PROPERTY(qreal iconSize READ iconSize CONSTANT FINAL)
33 Q_PROPERTY(qreal mediumContainerHeight READ mediumContainerHeight CONSTANT FINAL)
35 Q_PROPERTY(qreal mediumContainerWidth READ mediumContainerWidth CONSTANT FINAL)
36 Q_PROPERTY(qreal mediumIconSize READ mediumIconSize CONSTANT FINAL)
37 Q_PROPERTY(qreal largeContainerHeight READ largeContainerHeight CONSTANT FINAL)
39 Q_PROPERTY(qreal largeContainerWidth READ largeContainerWidth CONSTANT FINAL)
40 Q_PROPERTY(qreal largeIconSize READ largeIconSize CONSTANT FINAL)
41 Q_PROPERTY(qreal leadingSpace READ leadingSpace CONSTANT FINAL)
42 Q_PROPERTY(qreal mediumLeadingSpace READ mediumLeadingSpace CONSTANT FINAL)
43 Q_PROPERTY(qreal largeLeadingSpace READ largeLeadingSpace CONSTANT FINAL)
44 Q_PROPERTY(qreal trailingSpace READ trailingSpace CONSTANT FINAL)
45 Q_PROPERTY(qreal mediumTrailingSpace READ mediumTrailingSpace CONSTANT FINAL)
46 Q_PROPERTY(qreal largeTrailingSpace READ largeTrailingSpace CONSTANT FINAL)
47 Q_PROPERTY(qreal iconLabelSpace READ iconLabelSpace CONSTANT FINAL)
48 Q_PROPERTY(qreal mediumIconLabelSpace READ mediumIconLabelSpace CONSTANT FINAL)
49 Q_PROPERTY(qreal largeIconLabelSpace READ largeIconLabelSpace CONSTANT FINAL)
50 Q_PROPERTY(qreal containerElevation READ containerElevation CONSTANT FINAL)
51 Q_PROPERTY(qreal focusContainerElevation READ focusContainerElevation CONSTANT FINAL)
52 Q_PROPERTY(qreal hoverContainerElevation READ hoverContainerElevation CONSTANT FINAL)
53 Q_PROPERTY(qreal pressedContainerElevation READ pressedContainerElevation CONSTANT FINAL)
54 Q_PROPERTY(qreal loweredContainerElevation READ loweredContainerElevation CONSTANT FINAL)
55 Q_PROPERTY(
57 Q_PROPERTY(
60 FINAL)
61 Q_PROPERTY(qreal hoverStateLayerOpacity READ hoverStateLayerOpacity CONSTANT FINAL)
62 Q_PROPERTY(qreal focusStateLayerOpacity READ focusStateLayerOpacity CONSTANT FINAL)
63 Q_PROPERTY(qreal pressedStateLayerOpacity READ pressedStateLayerOpacity CONSTANT FINAL)
64
65public:
66 constexpr qreal containerHeight() const
67 {
68 return 56.0;
69 }
70 constexpr ShapeValue containerShape() const
71 {
72 return ShapeTokens{ }.cornerLarge();
73 }
74 constexpr qreal containerWidth() const
75 {
76 return 56.0;
77 }
78 constexpr qreal iconSize() const
79 {
80 return 24.0;
81 }
82 constexpr qreal mediumContainerHeight() const
83 {
84 return 80.0;
85 }
87 {
89 }
90 constexpr qreal mediumContainerWidth() const
91 {
92 return 80.0;
93 }
94 constexpr qreal mediumIconSize() const
95 {
96 return 28.0;
97 }
98 constexpr qreal largeContainerHeight() const
99 {
100 return 96.0;
101 }
103 {
104 return ShapeTokens{ }.cornerExtraLarge();
105 }
106 constexpr qreal largeContainerWidth() const
107 {
108 return 96.0;
109 }
110 constexpr qreal largeIconSize() const
111 {
112 return 32.0;
113 }
115 constexpr qreal leadingSpace() const
116 {
117 return 16.0;
118 }
120 constexpr qreal mediumLeadingSpace() const
121 {
122 return 26.0;
123 }
125 constexpr qreal largeLeadingSpace() const
126 {
127 return 28.0;
128 }
130 constexpr qreal trailingSpace() const
131 {
132 return 16.0;
133 }
135 constexpr qreal mediumTrailingSpace() const
136 {
137 return 26.0;
138 }
140 constexpr qreal largeTrailingSpace() const
141 {
142 return 28.0;
143 }
145 constexpr qreal iconLabelSpace() const
146 {
147 return 8.0;
148 }
150 constexpr qreal mediumIconLabelSpace() const
151 {
152 return 12.0;
153 }
155 constexpr qreal largeIconLabelSpace() const
156 {
157 return 16.0;
158 }
159 constexpr qreal containerElevation() const
160 {
161 return ElevationTokens{ }.level3();
162 }
163 constexpr qreal focusContainerElevation() const
164 {
165 return ElevationTokens{ }.level3();
166 }
167 constexpr qreal hoverContainerElevation() const
168 {
169 return ElevationTokens{ }.level4();
170 }
171 constexpr qreal pressedContainerElevation() const
172 {
173 return ElevationTokens{ }.level3();
174 }
175 constexpr qreal loweredContainerElevation() const
176 {
177 return ElevationTokens{ }.level1();
178 }
179 constexpr qreal loweredFocusContainerElevation() const
180 {
181 return ElevationTokens{ }.level1();
182 }
183 constexpr qreal loweredHoverContainerElevation() const
184 {
185 return ElevationTokens{ }.level2();
186 }
187 constexpr qreal loweredPressedContainerElevation() const
188 {
189 return ElevationTokens{ }.level1();
190 }
191 constexpr qreal hoverStateLayerOpacity() const
192 {
194 }
195 constexpr qreal focusStateLayerOpacity() const
196 {
198 }
199 constexpr qreal pressedStateLayerOpacity() const
200 {
202 }
203};
204
205} // namespace Fluid
Material Design 3 system elevation tokens.
Material Design 3 Expressive floating action button tokens.
Definition fab.h:25
constexpr qreal largeLeadingSpace() const
Leading space of a large labeled FAB.
Definition fab.h:125
constexpr qreal iconSize() const
Definition fab.h:78
qreal loweredPressedContainerElevation
Definition fab.h:60
qreal containerElevation
Definition fab.h:50
qreal focusStateLayerOpacity
Definition fab.h:62
qreal hoverContainerElevation
Definition fab.h:52
qreal largeContainerWidth
Definition fab.h:39
qreal largeLeadingSpace
Definition fab.h:43
qreal focusContainerElevation
Definition fab.h:51
Fluid::ShapeValue largeContainerShape
Definition fab.h:38
qreal pressedContainerElevation
Definition fab.h:53
constexpr qreal leadingSpace() const
Leading space of a default-size labeled FAB.
Definition fab.h:115
qreal leadingSpace
Definition fab.h:41
constexpr qreal largeContainerHeight() const
Definition fab.h:98
qreal loweredFocusContainerElevation
Definition fab.h:56
qreal largeContainerHeight
Definition fab.h:37
constexpr qreal focusContainerElevation() const
Definition fab.h:163
qreal loweredHoverContainerElevation
Definition fab.h:58
QML_ANONYMOUSqreal containerHeight
Definition fab.h:29
qreal mediumContainerWidth
Definition fab.h:35
constexpr qreal largeIconLabelSpace() const
Space between the icon and label of a large labeled FAB.
Definition fab.h:155
constexpr qreal mediumTrailingSpace() const
Trailing space of a medium labeled FAB.
Definition fab.h:135
qreal hoverStateLayerOpacity
Definition fab.h:61
Fluid::ShapeValue containerShape
Definition fab.h:30
constexpr qreal loweredHoverContainerElevation() const
Definition fab.h:183
constexpr qreal largeContainerWidth() const
Definition fab.h:106
constexpr qreal mediumLeadingSpace() const
Leading space of a medium labeled FAB.
Definition fab.h:120
qreal largeTrailingSpace
Definition fab.h:46
qreal trailingSpace
Definition fab.h:44
constexpr qreal hoverContainerElevation() const
Definition fab.h:167
constexpr ShapeValue largeContainerShape() const
Definition fab.h:102
constexpr qreal mediumContainerHeight() const
Definition fab.h:82
constexpr qreal pressedStateLayerOpacity() const
Definition fab.h:199
constexpr qreal largeIconSize() const
Definition fab.h:110
constexpr qreal largeTrailingSpace() const
Trailing space of a large labeled FAB.
Definition fab.h:140
qreal largeIconLabelSpace
Definition fab.h:49
qreal mediumLeadingSpace
Definition fab.h:42
qreal mediumIconSize
Definition fab.h:36
qreal iconLabelSpace
Definition fab.h:47
constexpr ShapeValue mediumContainerShape() const
Definition fab.h:86
constexpr qreal hoverStateLayerOpacity() const
Definition fab.h:191
qreal mediumContainerHeight
Definition fab.h:33
constexpr qreal loweredContainerElevation() const
Definition fab.h:175
qreal loweredContainerElevation
Definition fab.h:54
constexpr qreal loweredPressedContainerElevation() const
Definition fab.h:187
constexpr qreal loweredFocusContainerElevation() const
Definition fab.h:179
qreal pressedStateLayerOpacity
Definition fab.h:63
constexpr qreal containerWidth() const
Definition fab.h:74
qreal iconSize
Definition fab.h:32
constexpr qreal mediumContainerWidth() const
Definition fab.h:90
constexpr qreal mediumIconSize() const
Definition fab.h:94
qreal containerWidth
Definition fab.h:31
qreal mediumIconLabelSpace
Definition fab.h:48
constexpr qreal containerElevation() const
Definition fab.h:159
qreal mediumTrailingSpace
Definition fab.h:45
constexpr ShapeValue containerShape() const
Definition fab.h:70
constexpr qreal pressedContainerElevation() const
Definition fab.h:171
constexpr qreal iconLabelSpace() const
Space between the icon and label of a default-size labeled FAB.
Definition fab.h:145
Fluid::ShapeValue mediumContainerShape
Definition fab.h:34
qreal largeIconSize
Definition fab.h:40
constexpr qreal focusStateLayerOpacity() const
Definition fab.h:195
constexpr qreal trailingSpace() const
Trailing space of a default-size labeled FAB.
Definition fab.h:130
constexpr qreal mediumIconLabelSpace() const
Space between the icon and label of a medium labeled FAB.
Definition fab.h:150
Material Design 3 system shape tokens.
Definition shapetokens.h:48
Fluid::ShapeValue cornerLarge
Definition shapetokens.h:60
Fluid::ShapeValue cornerLargeIncreased
Definition shapetokens.h:62
Fluid::ShapeValue cornerExtraLarge
Definition shapetokens.h:53
Material Design 3 system state tokens.
Definition statetokens.h:18
qreal focusStateLayerOpacity
Definition statetokens.h:23
qreal hoverStateLayerOpacity
Definition statetokens.h:24
qreal pressedStateLayerOpacity
Definition statetokens.h:25