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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
//! Row/header/type-ramp sizing every Hyprforge app shares, derived from
//! font metrics rather than copied out of a mockup as pixel constants.
//!
//! Files' design came first and moved here when Settings adopted the
//! same one, so the two draw a row, a bar and a corner the same size.
//! What only Files needs — the grid, its menus, its sidebar — stayed in
//! `hyprforge-files-core`.
//!
//! The design specifies a 40px header, 28px rows, a 15px type ramp and a
//! 6px-inner/12px-outer radius pair — but those numbers are only true at
//! the theme's default text size and 100% [`FontScale`]. Pillar 7 puts
//! font scaling in the shared layer for exactly this reason: a `28.0`
//! literal for row height clips its own text the moment someone raises
//! the scale past 1.0, because the text grows and the row does not. So
//! every design pixel value here is stored as its *ratio* to
//! [`BASE_TEXT_SIZE`] at identity scale.
//!
//! Two different things come out of that ratio, deliberately kept apart:
//!
//! - A **text size** ([`ROW_TEXT_BASE`], [`META_TEXT_BASE`]) is left
//! unscaled and handed to [`crate::widgets::scaled_text`] (or
//! [`meta_text`](crate::widgets::meta_text)) the same way
//! [`BASE_TEXT_SIZE`] itself already is everywhere else in this crate
//! — applying `FontScale` a second time here would compound it rather
//! than replace it, the exact mistake [`FontScale::apply`]'s own doc
//! warns against.
//! - A **layout dimension** ([`row_height`], [`bar_height`]) is a
//! function that returns the final, already-scaled pixel value,
//! because a container's `Length::Fixed` needs a concrete number, not
//! something a widget will scale for it later.
//!
//! At 100% the numbers below reproduce the design's own values exactly
//! (pinned in the tests); above 100% the row, the header and the text
//! inside them grow together instead of the text alone overflowing a row
//! that stayed put.
//!
//! Radii take the same "ratio, not constant" shape but from
//! [`hyprforge_look::Theme::rounding`] instead of text size: the design's
//! outer/inner pair is preserved as a *relationship* (inner is exactly
//! half the outer) rather than as two independent magic numbers, so a
//! user who changes Hyprland's own `decoration:rounding` gets an inner
//! radius that stays visibly tighter than the outer one instead of one
//! that quietly drifts to match or overtake it.
use crate;
/// design px / [`BASE_TEXT_SIZE`], at identity scale.
const ROW_HEIGHT_RATIO: f32 = 28.0 / BASE_TEXT_SIZE;
/// The primary text size inside a row — a file's name — **unscaled**:
/// feed this straight to `scaled_text`/`meta_text` as the `base_size`
/// argument, which applies `FontScale` itself, the same way every other
/// call site feeds it [`BASE_TEXT_SIZE`]. It is already in the same
/// "logical px before scale" unit `BASE_TEXT_SIZE` is, so no further
/// division by it is needed — this constant *is* the design's 15px type
/// ramp at identity scale, not a ratio applied to something else.
pub const ROW_TEXT_BASE: f32 = 15.0;
/// The metadata text size inside a row — size, modified, kind — also
/// unscaled. The design only names the 15px primary size; this keeps the
/// 13/15 relationship the crate's earlier hand-picked `13.0`-vs-`14.0`
/// pairing already had, expressed as a ratio of the primary size instead
/// of a second independent constant.
pub const META_TEXT_BASE: f32 = ROW_TEXT_BASE * ;
/// Half the outer radius — see the module doc for why this is a
/// relationship, not a second magic number.
const INNER_OUTER_RATIO: f32 = 0.5;
/// A list row's final height in logical pixels, `FontScale` already
/// applied. `28.0` at [`FontScale::default`]; grows proportionally above
/// 100%.
/// The window's own corner radius — the design's "12px outer". Taken
/// straight from the active [`hyprforge_look::Theme`] rather than
/// duplicated: `Theme::rounding` already *is* Hyprland's own
/// `decoration:rounding`, and it happens to default to 12, which is a
/// measured fact about the default theme rather than a coincidence this
/// function relies on.
/// A row's/sidebar button's corner radius — the design's "6px inner".
/// See the module doc: this is deliberately half of [`outer_radius`]
/// rather than its own constant.
/// A card's corner — a setting row, a hero card, a table row. The
/// mockup's 9px, and its most common radius by far.
///
/// Three quarters of the window's radius: between the window (12) and a
/// top-level control (6), because a card is a level between the two.
const CARD_OUTER_RATIO: f32 = 0.75;
/// The header bar's height. 44px at 100% scale.
///
/// Taller than the 28px controls inside it on purpose: the difference is
/// what makes the bar read as a *plane* the controls sit on, rather than
/// as a row of controls with a background colour.
/// A text field — the path bar, the search field. 28px at 100%.
/// A glyph button — the nav cluster, a view-mode segment. 26px at 100%.
///
/// Two pixels shorter than a field, deliberately: enough difference that
/// a button feels pressable and a field feels typeable, close enough
/// that the row still baselines cleanly.
/// The radius on something nested *inside* a control — the path bar's
/// current-directory chip, a segment inside the view-mode track.
///
/// Third level of a deliberate ladder: 12 on the window, 6 on a
/// top-level control, 4 on something inside one. A nested thing sharing
/// its parent's radius reads as a second parent rather than as a child.
const BAR_HEIGHT_BASE: f32 = 44.0;
const FIELD_HEIGHT_BASE: f32 = 28.0;
const GLYPH_BUTTON_BASE: f32 = 26.0;
const NESTED_RADIUS_FRACTION: f32 = 4.0 / 6.0;
/// A sidebar section heading — `PLACES`, `PINNED`, `TRASH`.
///
/// Smaller than the meta text it is built from, because a heading in a
/// sidebar is a signpost rather than something to read: it should be
/// findable when looked for and invisible when not.
pub const SECTION_LABEL_BASE: f32 = META_TEXT_BASE * 0.85;
/// A setting row's least height — the design's 52px card row at 100%.
///
/// A floor, not a height: a row carrying a hint line under its label
/// grows past it rather than clipping the hint, and the floor is what
/// keeps a page of one-line rows on a steady rhythm.
const SETTING_ROW_HEIGHT_BASE: f32 = 52.0;