QmlMaterial 0.1.0
Loading...
Searching...
No Matches
type_scale.hpp
1#pragma once
2
3#include <QQmlEngine>
4#include <QFont>
5#include "qml_material/core.hpp"
6#include "qml_material/export.hpp"
7
8namespace qml_material::token
9{
10// Font.Thin 0
11// Font.ExtraLight 12
12// Font.Light 25
13// Font.Normal 50
14// Font.Medium 57
15// Font.DemiBold 63
16// Font.Bold 75
17// Font.ExtraBold 81
18// Font.Black 87
19
20// Value Common weight name
21// 100 Thin (Hairline)
22// 200 Extra Light (Ultra Light)
23// 300 Light
24// 400 Normal (Regular)
25// 500 Medium
26// 600 Semi Bold (Demi Bold)
27// 700 Bold
28// 800 Extra Bold (Ultra Bold)
29// 900 Black (Heavy)
30// 950 Extra Black (Ultra Black)
31
37 Q_GADGET_EXPORT(QML_MATERIAL_API)
38 QML_ELEMENT
39 QML_VALUE_TYPE(typescale)
40
41
42 Q_PROPERTY(qint32 size MEMBER size FINAL)
44 Q_PROPERTY(qint32 line_height MEMBER line_height FINAL)
46 Q_PROPERTY(QFont::Weight weight MEMBER weight FINAL)
48 Q_PROPERTY(QFont::Weight weight_prominent MEMBER weight_prominent FINAL)
50 Q_PROPERTY(qreal tracking MEMBER tracking FINAL)
51public:
52 Q_INVOKABLE TypeScaleItem fresh() const { return *this; }
53
54 i32 size { 14 };
55 i32 line_height { 24 };
56 QFont::Weight weight { QFont::Weight::Normal };
57 QFont::Weight weight_prominent { QFont::Weight::Normal };
58 qreal tracking { 0 };
59 bool operator==(const TypeScaleItem&) const = default;
60};
61
66class TypeScale : public QObject {
67 Q_OBJECT
68 QML_ELEMENT
69public:
70 using QObject::QObject;
71
72#define X(NAME, ...) \
73 Q_PROPERTY(qml_material::token::TypeScaleItem NAME READ NAME CONSTANT FINAL) \
74public: \
75 const TypeScaleItem& NAME() const noexcept { return default_##NAME; } \
76 inline static constexpr TypeScaleItem default_##NAME { __VA_ARGS__ };
77
78 // clang-format off
80 X(display_large , 57, 64, QFont::Normal, QFont::Normal, -0.25)
82 X(display_medium , 45, 52, QFont::Normal, QFont::Normal, 0.0 )
84 X(display_small , 36, 44, QFont::Normal, QFont::Normal, 0.0 )
86 X(headline_large , 32, 40, QFont::Medium, QFont::Medium, 0.0 )
88 X(headline_medium, 28, 36, QFont::Medium, QFont::Medium, 0.0 )
90 X(headline_small , 24, 32, QFont::Medium, QFont::Medium, 0.0 )
92 X(title_large , 22, 28, QFont::Normal, QFont::Normal, 0.0 )
94 X(title_medium , 16, 24, QFont::Medium, QFont::Medium, 0.15 )
96 X(title_small , 14, 20, QFont::Medium, QFont::Medium, 0.1 )
98 X(body_large , 16, 24, QFont::Normal, QFont::Normal, 0.5 )
100 X(body_medium , 14, 20, QFont::Normal, QFont::Normal, 0.25 )
102 X(body_small , 12, 16, QFont::Normal, QFont::Normal, 0.4 )
104 X(label_large , 14, 20, QFont::Medium, QFont::Bold , 0.1 )
106 X(label_medium , 12, 16, QFont::Medium, QFont::Bold , 0.5 )
108 X(label_small , 11, 16, QFont::Medium, QFont::Bold , 0.5 )
109 // clang-format on
110
111#undef X
112};
113
114} // namespace qml_material::token
TypeScale.
Definition type_scale.hpp:66
qml_material::token::TypeScaleItem label_medium
Medium-sized text labels.
Definition type_scale.hpp:106
qml_material::token::TypeScaleItem body_medium
Used for medium-sized body text.
Definition type_scale.hpp:100
qml_material::token::TypeScaleItem label_large
Large text labels for important interface elements.
Definition type_scale.hpp:104
qml_material::token::TypeScaleItem headline_large
Primary heading text, such as screen titles.
Definition type_scale.hpp:86
qml_material::token::TypeScaleItem label_small
Smallest text labels for interface elements.
Definition type_scale.hpp:108
qml_material::token::TypeScaleItem headline_small
Smallest heading text.
Definition type_scale.hpp:90
qml_material::token::TypeScaleItem title_large
Used for primary text in dialogs, cards.
Definition type_scale.hpp:92
qml_material::token::TypeScaleItem body_small
Used for small body text.
Definition type_scale.hpp:102
qml_material::token::TypeScaleItem title_small
Supporting text in components.
Definition type_scale.hpp:96
qml_material::token::TypeScaleItem body_large
Used for primary body text.
Definition type_scale.hpp:98
qml_material::token::TypeScaleItem headline_medium
Secondary heading text.
Definition type_scale.hpp:88
qml_material::token::TypeScaleItem title_medium
Secondary text in dialogs, cards.
Definition type_scale.hpp:94
qml_material::token::TypeScaleItem display_small
Used for smaller display text.
Definition type_scale.hpp:84
qml_material::token::TypeScaleItem display_large
Used for the largest text on the screen, such as app name on splash screen.
Definition type_scale.hpp:80
qml_material::token::TypeScaleItem display_medium
Used for medium-sized display text, secondary splash screen text.
Definition type_scale.hpp:82
TypeScaleItem.
Definition type_scale.hpp:36
QFont::Weight weight_prominent
Font weight for prominent (emphasized) text.
Definition type_scale.hpp:48
qreal tracking
Letter spacing (tracking) adjustment.
Definition type_scale.hpp:50
QFont::Weight weight
Font weight for normal text.
Definition type_scale.hpp:46
qint32 line_height
Line height in pixels.
Definition type_scale.hpp:44
qint32 size
Font size in pixels.
Definition type_scale.hpp:42