Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
switch.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 "shapetokens.h"
10#include "statetokens.h"
11
12// Component values map to the AndroidX Material 3 generated tokens where available:
13// https://android.googlesource.com/platform/frameworks/support/+/5ba2cdd61be7b6945db999b238d14f3c626136fb/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/tokens/
14// SwitchTokens.kt; system references are provided by ShapeTokens.kt and StateTokens.kt.
15
16namespace Fluid {
17
19struct Switch
20{
21 Q_GADGET
22 QML_ANONYMOUS
23
24 Q_PROPERTY(qreal trackWidth READ trackWidth CONSTANT FINAL)
25 Q_PROPERTY(qreal trackHeight READ trackHeight CONSTANT FINAL)
26 Q_PROPERTY(Fluid::ShapeValue trackShape READ trackShape CONSTANT FINAL)
27 Q_PROPERTY(qreal trackOutlineWidth READ trackOutlineWidth CONSTANT FINAL)
28 Q_PROPERTY(qreal stateLayerSize READ stateLayerSize CONSTANT FINAL)
29 Q_PROPERTY(Fluid::ShapeValue stateLayerShape READ stateLayerShape CONSTANT FINAL)
30 Q_PROPERTY(qreal contentPadding READ contentPadding CONSTANT FINAL)
31 Q_PROPERTY(qreal contentSpacing READ contentSpacing CONSTANT FINAL)
32 Q_PROPERTY(qreal selectedHandleSize READ selectedHandleSize CONSTANT FINAL)
33 Q_PROPERTY(qreal unselectedHandleSize READ unselectedHandleSize CONSTANT FINAL)
34 Q_PROPERTY(qreal withIconHandleSize READ withIconHandleSize CONSTANT FINAL)
35 Q_PROPERTY(qreal pressedHandleSize READ pressedHandleSize CONSTANT FINAL)
36 Q_PROPERTY(Fluid::ShapeValue handleShape READ handleShape CONSTANT FINAL)
37 Q_PROPERTY(qreal selectedIconSize READ selectedIconSize CONSTANT FINAL)
38 Q_PROPERTY(qreal unselectedIconSize READ unselectedIconSize CONSTANT FINAL)
39 Q_PROPERTY(qreal disabledTrackOpacity READ disabledTrackOpacity CONSTANT FINAL)
40 Q_PROPERTY(
43 FINAL)
44 Q_PROPERTY(qreal disabledSelectedIconOpacity READ disabledSelectedIconOpacity CONSTANT FINAL)
45 Q_PROPERTY(
47 Q_PROPERTY(qreal hoverStateLayerOpacity READ hoverStateLayerOpacity CONSTANT FINAL)
48 Q_PROPERTY(qreal focusStateLayerOpacity READ focusStateLayerOpacity CONSTANT FINAL)
49 Q_PROPERTY(qreal pressedStateLayerOpacity READ pressedStateLayerOpacity CONSTANT FINAL)
50
51public:
52 constexpr qreal trackWidth() const
53 {
54 return 52.0;
55 }
56 constexpr qreal trackHeight() const
57 {
58 return 32.0;
59 }
60 constexpr ShapeValue trackShape() const
61 {
62 return ShapeTokens{ }.cornerFull();
63 }
64 constexpr qreal trackOutlineWidth() const
65 {
66 return 2.0;
67 }
68 constexpr qreal stateLayerSize() const
69 {
70 return 40.0;
71 }
72 constexpr ShapeValue stateLayerShape() const
73 {
74 return ShapeTokens{ }.cornerFull();
75 }
76 // Fluid label/layout metrics; AndroidX SwitchTokens has no label composition tokens.
77 constexpr qreal contentPadding() const
78 {
79 return 8.0;
80 }
81 constexpr qreal contentSpacing() const
82 {
83 return 8.0;
84 }
85 constexpr qreal selectedHandleSize() const
86 {
87 return 24.0;
88 }
89 constexpr qreal unselectedHandleSize() const
90 {
91 return 16.0;
92 }
93 constexpr qreal withIconHandleSize() const
94 {
95 return 24.0;
96 }
97 constexpr qreal pressedHandleSize() const
98 {
99 return 28.0;
100 }
101 constexpr ShapeValue handleShape() const
102 {
103 return ShapeTokens{ }.cornerFull();
104 }
105 constexpr qreal selectedIconSize() const
106 {
107 return 16.0;
108 }
109 constexpr qreal unselectedIconSize() const
110 {
111 return 16.0;
112 }
113 constexpr qreal disabledTrackOpacity() const
114 {
115 return 0.12;
116 }
117 constexpr qreal disabledSelectedHandleOpacity() const
118 {
119 return 1.0;
120 }
121 constexpr qreal disabledUnselectedHandleOpacity() const
122 {
123 return 0.38;
124 }
125 constexpr qreal disabledSelectedIconOpacity() const
126 {
127 return 0.38;
128 }
129 constexpr qreal disabledUnselectedIconOpacity() const
130 {
131 return 0.38;
132 }
133 constexpr qreal hoverStateLayerOpacity() const
134 {
136 }
137 constexpr qreal focusStateLayerOpacity() const
138 {
140 }
141 constexpr qreal pressedStateLayerOpacity() const
142 {
144 }
145};
146
147} // namespace Fluid
Material Design 3 system shape tokens.
Definition shapetokens.h:48
Fluid::ShapeValue cornerFull
Definition shapetokens.h:59
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
Material Design 3 switch tokens.
Definition switch.h:20
constexpr qreal stateLayerSize() const
Definition switch.h:68
qreal selectedHandleSize
Definition switch.h:32
constexpr qreal unselectedHandleSize() const
Definition switch.h:89
qreal trackHeight
Definition switch.h:25
constexpr qreal focusStateLayerOpacity() const
Definition switch.h:137
constexpr qreal disabledTrackOpacity() const
Definition switch.h:113
qreal disabledSelectedIconOpacity
Definition switch.h:44
constexpr qreal trackOutlineWidth() const
Definition switch.h:64
constexpr qreal disabledUnselectedHandleOpacity() const
Definition switch.h:121
qreal disabledSelectedHandleOpacity
Definition switch.h:41
constexpr qreal unselectedIconSize() const
Definition switch.h:109
qreal hoverStateLayerOpacity
Definition switch.h:47
constexpr qreal disabledSelectedHandleOpacity() const
Definition switch.h:117
Fluid::ShapeValue trackShape
Definition switch.h:26
qreal stateLayerSize
Definition switch.h:28
qreal selectedIconSize
Definition switch.h:37
Fluid::ShapeValue handleShape
Definition switch.h:36
qreal unselectedIconSize
Definition switch.h:38
constexpr ShapeValue handleShape() const
Definition switch.h:101
qreal withIconHandleSize
Definition switch.h:34
constexpr qreal disabledSelectedIconOpacity() const
Definition switch.h:125
constexpr qreal contentSpacing() const
Definition switch.h:81
qreal pressedHandleSize
Definition switch.h:35
constexpr ShapeValue stateLayerShape() const
Definition switch.h:72
qreal disabledTrackOpacity
Definition switch.h:39
constexpr qreal selectedIconSize() const
Definition switch.h:105
constexpr qreal trackHeight() const
Definition switch.h:56
qreal disabledUnselectedHandleOpacity
Definition switch.h:43
qreal focusStateLayerOpacity
Definition switch.h:48
constexpr qreal pressedStateLayerOpacity() const
Definition switch.h:141
constexpr qreal disabledUnselectedIconOpacity() const
Definition switch.h:129
constexpr qreal hoverStateLayerOpacity() const
Definition switch.h:133
qreal pressedStateLayerOpacity
Definition switch.h:49
qreal disabledUnselectedIconOpacity
Definition switch.h:46
qreal trackOutlineWidth
Definition switch.h:27
Fluid::ShapeValue stateLayerShape
Definition switch.h:29
constexpr qreal withIconHandleSize() const
Definition switch.h:93
constexpr qreal selectedHandleSize() const
Definition switch.h:85
qreal unselectedHandleSize
Definition switch.h:33
constexpr qreal pressedHandleSize() const
Definition switch.h:97
constexpr qreal contentPadding() const
Definition switch.h:77
QML_ANONYMOUSqreal trackWidth
Definition switch.h:24
qreal contentSpacing
Definition switch.h:31
constexpr ShapeValue trackShape() const
Definition switch.h:60
qreal contentPadding
Definition switch.h:30