1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//! The sizes the stock widgets are built from, as one struct beside the
//! palette (backlog T2, the axis ADR 0019 scoped itself out of).
//!
//! `BUTTON_TEXT` 15, `MENU_WIDTH` 200, every `pad_xy(14.0, 8.0)` and
//! `radius(6.0)` in `widgets.rs` were hard-coded the way the colours were
//! before the theme, and for the same reason: nobody had asked. The
//! argument for a [`Metrics`] is ADR 0019's one axis over — the stock
//! widgets and an app's own controls should agree on a radius and a
//! padding without either copying a number out of the other — and the
//! two questions the backlog entry said to settle first are settled here:
//!
//! - **A metric does not scale by itself.** Every field is logical px (or
//! a text size in logical px), applied *before* `env.scale`, which is
//! the renderer's and multiplies everything the frame draws. Density is
//! the app's choice, the way the palette is: [`Metrics::compact`] is a
//! tighter set, [`Metrics::scaled`] is every length multiplied for a
//! density slider, and `Core::set_metrics` is the door. The day an OS
//! text-size setting is plumbed into `env.system`, `scaled` is the
//! arithmetic and a `MetricsSource` beside [`crate::theme::ThemeSource`]
//! is the shape; nothing here pre-empts it.
//! - **The default is the contract; a set metric is the app's.** The
//! corpus runs with [`Metrics::default`], which is byte for byte the
//! constants the widgets had, so no scene moved and the report pins the
//! stock geometry as it always did. An app that sets its own changes
//! what *its* frames draw, exactly as `set_theme` does, and a
//! conformance scene never sets one — which is what keeps "the stock
//! button is 15-px text in 14×8 padding" a sentence about kui and not
//! about an app.
//!
//! Roles, like the palette's: `control_pad_x` is *a button's horizontal
//! padding*, not "spacing unit 3", and a view that wants a number between
//! two has arithmetic.
/// The titlebar's height on Windows and everywhere else: the caption
/// height the OS draws, so the one metric that is the platform's rather
/// than a density's. Named here so [`Metrics::comfortable`] picks the
/// running one and the schema row (`MetricRole::platform`) carries both,
/// which is what keeps a generated table from saying which machine wrote
/// it (backlog W13).
pub const TITLEBAR_H_WINDOWS: f32 = 32.0;
pub const TITLEBAR_H_ELSEWHERE: f32 = 34.0;
/// The sizes the stock widgets are built from. Plain data and [`Copy`]: a
/// view reads it off `ui.metrics()` and may keep or change its own copy,
/// and `Core::set_metrics` makes one the frame's.