Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
navigationrail.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// NavigationRailBaselineItemTokens.kt, NavigationRailCollapsedTokens.kt,
16// NavigationRailExpandedTokens.kt, NavigationRailHorizontalItemTokens.kt, and
17// NavigationRailVerticalItemTokens.kt, VERSION: v0_11_0; ScrimTokens.kt, VERSION: v0_117.
18// ItemHorizontalPadding follows the AndroidX WideNavigationRail implementation at:
19// https://android.googlesource.com/platform/frameworks/support/+/8ac4ef277273e07d515f12ad4d71d517d7c57fef/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/WideNavigationRail.kt
20
21namespace Fluid {
22
25{
26 Q_GADGET
27 QML_ANONYMOUS
28
29 Q_PROPERTY(qreal containerElevation READ containerElevation CONSTANT FINAL)
30 Q_PROPERTY(Fluid::ShapeValue containerShape READ containerShape CONSTANT FINAL)
31 Q_PROPERTY(qreal collapsedContainerWidth READ collapsedContainerWidth CONSTANT FINAL)
32 Q_PROPERTY(
34 Q_PROPERTY(
36 Q_PROPERTY(qreal modalContainerElevation READ modalContainerElevation CONSTANT FINAL)
38 Q_PROPERTY(qreal topSpace READ topSpace CONSTANT FINAL)
39 Q_PROPERTY(qreal collapsedItemVerticalSpace READ collapsedItemVerticalSpace CONSTANT FINAL)
40 Q_PROPERTY(qreal itemContainerHeight READ itemContainerHeight CONSTANT FINAL)
41 Q_PROPERTY(Fluid::ShapeValue itemContainerShape READ itemContainerShape CONSTANT FINAL)
42 Q_PROPERTY(qreal itemContainerVerticalSpace READ itemContainerVerticalSpace CONSTANT FINAL)
43 Q_PROPERTY(qreal headerSpaceMinimum READ headerSpaceMinimum CONSTANT FINAL)
44 Q_PROPERTY(qreal iconSize READ iconSize CONSTANT FINAL)
46 Q_PROPERTY(
48 Q_PROPERTY(qreal activeIndicatorLeadingSpace READ activeIndicatorLeadingSpace CONSTANT FINAL)
49 Q_PROPERTY(qreal activeIndicatorTrailingSpace READ activeIndicatorTrailingSpace CONSTANT FINAL)
50 Q_PROPERTY(
52 Q_PROPERTY(qreal verticalActiveIndicatorWidth READ verticalActiveIndicatorWidth CONSTANT FINAL)
53 Q_PROPERTY(qreal verticalIconLabelSpace READ verticalIconLabelSpace CONSTANT FINAL)
54 Q_PROPERTY(qreal verticalLeadingSpace READ verticalLeadingSpace CONSTANT FINAL)
55 Q_PROPERTY(qreal verticalTrailingSpace READ verticalTrailingSpace CONSTANT FINAL)
57 FINAL)
59 FINAL)
61 FINAL)
62 Q_PROPERTY(qreal horizontalIconLabelSpace READ horizontalIconLabelSpace CONSTANT FINAL)
63 Q_PROPERTY(qreal horizontalLeadingSpace READ horizontalLeadingSpace CONSTANT FINAL)
64 Q_PROPERTY(qreal itemHorizontalPadding READ itemHorizontalPadding CONSTANT FINAL)
65 Q_PROPERTY(qreal hoverStateLayerOpacity READ hoverStateLayerOpacity CONSTANT FINAL)
66 Q_PROPERTY(qreal focusStateLayerOpacity READ focusStateLayerOpacity CONSTANT FINAL)
67 Q_PROPERTY(qreal pressedStateLayerOpacity READ pressedStateLayerOpacity CONSTANT FINAL)
68 Q_PROPERTY(qreal disabledContentOpacity READ disabledContentOpacity CONSTANT FINAL)
69 Q_PROPERTY(qreal modalScrimOpacity READ modalScrimOpacity CONSTANT FINAL)
70
71public:
73 constexpr qreal containerElevation() const
74 {
75 return ElevationTokens{ }.level0();
76 }
77
79 constexpr ShapeValue containerShape() const
80 {
81 return ShapeTokens{ }.cornerNone();
82 }
83
85 constexpr qreal collapsedContainerWidth() const
86 {
87 return 96.0;
88 }
89
91 constexpr qreal expandedContainerWidthMinimum() const
92 {
93 return 220.0;
94 }
95
97 constexpr qreal expandedContainerWidthMaximum() const
98 {
99 return 360.0;
100 }
101
103 constexpr qreal modalContainerElevation() const
104 {
105 return ElevationTokens{ }.level2();
106 }
107
110 {
111 return ShapeTokens{ }.cornerLarge();
112 }
113
115 constexpr qreal topSpace() const
116 {
117 return 44.0;
118 }
119
121 constexpr qreal collapsedItemVerticalSpace() const
122 {
123 return 4.0;
124 }
125
127 constexpr qreal itemContainerHeight() const
128 {
129 return 64.0;
130 }
131
134 {
135 return ShapeTokens{ }.cornerNone();
136 }
137
139 constexpr qreal itemContainerVerticalSpace() const
140 {
141 return 6.0;
142 }
143
145 constexpr qreal headerSpaceMinimum() const
146 {
147 return 40.0;
148 }
149
151 constexpr qreal iconSize() const
152 {
153 return 24.0;
154 }
155
158 {
159 return ShapeTokens{ }.cornerFull();
160 }
161
163 constexpr qreal activeIndicatorIconLabelSpace() const
164 {
165 return 8.0;
166 }
167
169 constexpr qreal activeIndicatorLeadingSpace() const
170 {
171 return 16.0;
172 }
173
175 constexpr qreal activeIndicatorTrailingSpace() const
176 {
177 return 16.0;
178 }
179
181 constexpr qreal verticalActiveIndicatorHeight() const
182 {
183 return 32.0;
184 }
185
187 constexpr qreal verticalActiveIndicatorWidth() const
188 {
189 return 56.0;
190 }
191
193 constexpr qreal verticalIconLabelSpace() const
194 {
195 return 4.0;
196 }
197
199 constexpr qreal verticalLeadingSpace() const
200 {
201 return 16.0;
202 }
203
205 constexpr qreal verticalTrailingSpace() const
206 {
207 return 16.0;
208 }
209
211 constexpr qreal horizontalActiveIndicatorHeight() const
212 {
213 return 56.0;
214 }
215
217 constexpr qreal horizontalFullWidthLeadingSpace() const
218 {
219 return 16.0;
220 }
221
223 constexpr qreal horizontalFullWidthTrailingSpace() const
224 {
225 return 16.0;
226 }
227
229 constexpr qreal horizontalIconLabelSpace() const
230 {
231 return 8.0;
232 }
233
235 constexpr qreal horizontalLeadingSpace() const
236 {
237 return 16.0;
238 }
239
241 constexpr qreal itemHorizontalPadding() const
242 {
243 return 20.0;
244 }
245
247 constexpr qreal hoverStateLayerOpacity() const
248 {
250 }
251
253 constexpr qreal focusStateLayerOpacity() const
254 {
256 }
257
259 constexpr qreal pressedStateLayerOpacity() const
260 {
262 }
263
265 constexpr qreal disabledContentOpacity() const
266 {
267 return 0.38;
268 }
269
271 constexpr qreal modalScrimOpacity() const
272 {
273 return 0.32;
274 }
275};
276
277} // namespace Fluid
Material Design 3 system elevation tokens.
QML_ANONYMOUSqreal level0
Material Design 3 Expressive navigation rail tokens.
constexpr qreal itemContainerVerticalSpace() const
Baseline vertical space between destination containers.
constexpr qreal horizontalIconLabelSpace() const
Space between icon and label in an expanded destination.
constexpr qreal topSpace() const
Vertical space between the rail edge and its content.
constexpr qreal verticalActiveIndicatorWidth() const
Width of the collapsed, vertically arranged active indicator.
constexpr ShapeValue containerShape() const
Shape of the persistent rail container.
constexpr qreal verticalTrailingSpace() const
Trailing space of a collapsed destination.
constexpr ShapeValue modalContainerShape() const
Shape of an expanded modal navigation rail.
constexpr qreal disabledContentOpacity() const
Opacity of disabled destination content.
constexpr qreal modalContainerElevation() const
Elevation of an expanded modal navigation rail.
constexpr qreal verticalLeadingSpace() const
Leading space of a collapsed destination.
constexpr qreal activeIndicatorLeadingSpace() const
Baseline leading space inside an active indicator.
constexpr ShapeValue activeIndicatorShape() const
Shape of the active destination indicator.
constexpr qreal expandedContainerWidthMaximum() const
Maximum width of an expanded Expressive navigation rail.
constexpr qreal itemContainerHeight() const
Baseline height of a navigation-rail destination.
constexpr qreal collapsedContainerWidth() const
Width of a collapsed Expressive navigation rail.
constexpr qreal activeIndicatorTrailingSpace() const
Baseline trailing space inside an active indicator.
Fluid::ShapeValue modalContainerShape
constexpr qreal verticalActiveIndicatorHeight() const
Height of the collapsed, vertically arranged active indicator.
constexpr qreal hoverStateLayerOpacity() const
Opacity of a hovered destination's state layer.
constexpr qreal modalScrimOpacity() const
Opacity of the scrim behind an expanded modal rail.
constexpr qreal focusStateLayerOpacity() const
Opacity of a keyboard-focused destination's state layer.
constexpr qreal horizontalActiveIndicatorHeight() const
Height of the expanded, horizontally arranged active indicator.
constexpr ShapeValue itemContainerShape() const
Baseline shape of a destination container.
QML_ANONYMOUSqreal containerElevation
constexpr qreal expandedContainerWidthMinimum() const
Minimum width of an expanded Expressive navigation rail.
constexpr qreal itemHorizontalPadding() const
Horizontal inset applied around expanded destinations by AndroidX.
constexpr qreal collapsedItemVerticalSpace() const
Space between consecutive collapsed destinations.
constexpr qreal pressedStateLayerOpacity() const
Opacity of a pressed destination's state layer.
constexpr qreal headerSpaceMinimum() const
Minimum space between a header and top-arranged destinations.
constexpr qreal verticalIconLabelSpace() const
Space between icon and label in a collapsed destination.
constexpr qreal horizontalLeadingSpace() const
Leading space of an expanded destination.
Fluid::ShapeValue containerShape
constexpr qreal horizontalFullWidthTrailingSpace() const
Trailing space inside a full-width expanded indicator.
constexpr qreal horizontalFullWidthLeadingSpace() const
Leading space inside a full-width expanded indicator.
constexpr qreal activeIndicatorIconLabelSpace() const
Baseline space between icon and label inside an active indicator.
Fluid::ShapeValue activeIndicatorShape
constexpr qreal iconSize() const
Size of a destination icon.
Fluid::ShapeValue itemContainerShape
Material Design 3 system shape tokens.
Definition shapetokens.h:48
Fluid::ShapeValue cornerFull
Definition shapetokens.h:59
Fluid::ShapeValue cornerLarge
Definition shapetokens.h:60
Fluid::ShapeValue cornerNone
Definition shapetokens.h:66
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