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
7namespace qml_material::token
8{
9// Font.Thin 0
10// Font.ExtraLight 12
11// Font.Light 25
12// Font.Normal 50
13// Font.Medium 57
14// Font.DemiBold 63
15// Font.Bold 75
16// Font.ExtraBold 81
17// Font.Black 87
18
19// Value Common weight name
20// 100 Thin (Hairline)
21// 200 Extra Light (Ultra Light)
22// 300 Light
23// 400 Normal (Regular)
24// 500 Medium
25// 600 Semi Bold (Demi Bold)
26// 700 Bold
27// 800 Extra Bold (Ultra Bold)
28// 900 Black (Heavy)
29// 950 Extra Black (Ultra Black)
30
36 Q_GADGET
37 QML_ELEMENT
38 QML_VALUE_TYPE(t_typescale)
39
40
41 Q_PROPERTY(qint32 size MEMBER size FINAL)
43 Q_PROPERTY(qint32 line_height MEMBER line_height FINAL)
45 Q_PROPERTY(QFont::Weight weight MEMBER weight FINAL)
47 Q_PROPERTY(QFont::Weight weight_prominent MEMBER weight_prominent FINAL)
49 Q_PROPERTY(qreal tracking MEMBER tracking FINAL)
50public:
51 Q_INVOKABLE TypeScaleItem fresh() const { return *this; }
52
53 i32 size { 14 };
54 i32 line_height { 24 };
55 QFont::Weight weight { QFont::Weight::Normal };
56 QFont::Weight weight_prominent { QFont::Weight::Normal };
57 qreal tracking { 0 };
58};
59
64class TypeScale : public QObject {
65 Q_OBJECT
66 QML_ELEMENT
67public:
68 using QObject::QObject;
69
70#define X(NAME, ...) \
71 Q_PROPERTY(qml_material::token::TypeScaleItem NAME READ NAME NOTIFY typescaleChanged FINAL) \
72public: \
73 const TypeScaleItem& NAME() const { return m_##NAME; } \
74 \
75private: \
76 TypeScaleItem m_##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 Q_SIGNAL void typescaleChanged();
114};
115
116} // namespace qml_material::token
TypeScale.
Definition type_scale.hpp:64
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:35
QFont::Weight weight_prominent
Font weight for prominent (emphasized) text.
Definition type_scale.hpp:47
qreal tracking
Letter spacing (tracking) adjustment.
Definition type_scale.hpp:49
QFont::Weight weight
Font weight for normal text.
Definition type_scale.hpp:45
qint32 line_height
Line height in pixels.
Definition type_scale.hpp:43
qint32 size
Font size in pixels.
Definition type_scale.hpp:41