forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

theme.rs2309 lines, 94.9 KiBHistoryRawDownload
1//! The one place this editor knows a colour.
2//!
3//! Every paint in every region reads a token from this table and nothing else:
4//! a `0x` literal anywhere but this file is the bug the whole redesign is about
5//! (`no_colour_is_written_outside_the_theme` is the guard). Names say the
6//! *role*, never the shade -- `bg/panel`, not "the dark grey" -- so the palette
7//! can be swapped whole without touching a single element.
8//!
9//! Which is what the modules below are for. Every family carries the same role
10//! names, so the switch between them is one field lookup and no call site knows
11//! it happened -- and a role missing from any of them is a compile error rather
12//! than a region that quietly kept the old colour.
13//!
14//! * `darkroom` (default) -- the mock's near-black ground and neutral inks, one
15//! sage accent, one lamp-white playhead.
16//! * `cool` -- near-black ground, cool neutral chrome, one cyan accent.
17//! * `warm` -- a deep neutral warmed towards brown so no surface reads as
18//! office grey, with one coral accent.
19//! * `forest` -- a green-tinted ground under one emerald accent.
20//! * `violet` -- an indigo ground under one lavender accent.
21//! * `rose` -- a neutral ground the accent alone warms, in rose.
22//! * `amber` -- a graphite ground under one gold accent.
23//! * `ocean` -- a blue-black ground under one azure accent.
24//! * `ice` -- the crisp one: a near-black blue ground, pale ice-blue accent.
25//! * `orchid` -- a dark plum ground under one orchid accent.
26//! * `nord`, `gruvbox`, `dracula` -- the three open palettes people already
27//! have their editors in, mapped onto these roles rather than approximated.
28//!
29//! All thirteen are dark: colour work is judged against its surround, and a light
30//! ground pushes every clip body and every graded frame the wrong way -- which
31//! is why no editor of this kind ships one. The twelve hued families take the clip
32//! bodies from the cross-NLE kind convention (video blue, audio green, image teal,
33//! text purple) instead of four greys that differ by a hair, and all thirteen are held
34//! to the same measured floors: the contrast and tint guards in `main.rs` run
35//! against *every* palette in [`PaletteId::ALL`], so the thirteenth lands gated
36//! rather than untested.
37//!
38//! Which family is in force is the user's, picked from the toolbar's Theme
39//! button or its stroke and kept in `~/.config/edith/theme` beside the
40//! keybindings -- it used to be a compile feature, which is a choice only
41//! whoever built the binary could make. A token is a call now
42//! ([`BG_PANEL()`]): one relaxed load and one field read off a `'static`
43//! table, which is what "the palette can be swapped whole" costs at paint time.
44
45use std::path::PathBuf;
46use std::sync::atomic::{AtomicU8, AtomicU32, AtomicUsize, Ordering::Relaxed};
47use std::sync::{Mutex, RwLock};
48
49/// The whole table, once: every role and its type, gathered from each family's
50/// module below. One list, so a role added to [`Palette`] without a value in
51/// every family is a compile error, and a role read at a paint cannot come from
52/// anywhere but the palette in force.
53///
54/// corner-cut: the families are spelled out in [`PALETTES`] rather than derived
55/// from a second list -- `macro_rules!` cannot nest a repetition over families
56/// inside one over roles, and the escape hatch for that is unstable. Ceiling: a
57/// thirteenth family is one line there, one variant in [`PaletteId`], one
58/// module.
59macro_rules! palette {
60 ($($name:ident: $ty:ty),+ $(,)?) => {
61 /// One family's numbers, in a struct so the set can be swapped whole.
62 /// Field names are the role names the whole editor already paints by,
63 /// which is why they shout.
64 #[allow(non_snake_case)]
65 #[derive(Clone, Copy, PartialEq, Debug)]
66 pub struct Palette { $(pub $name: $ty,)+ }
67
68 /// The families in [`PaletteId::ALL`]'s order, so the index the atomic
69 /// holds is the id itself.
70 static PALETTES: [Palette; PaletteId::ALL.len()] = [
71 Palette { $($name: cool::$name,)+ },
72 Palette { $($name: warm::$name,)+ },
73 Palette { $($name: forest::$name,)+ },
74 Palette { $($name: violet::$name,)+ },
75 Palette { $($name: rose::$name,)+ },
76 Palette { $($name: amber::$name,)+ },
77 Palette { $($name: ocean::$name,)+ },
78 Palette { $($name: ice::$name,)+ },
79 Palette { $($name: orchid::$name,)+ },
80 Palette { $($name: nord::$name,)+ },
81 Palette { $($name: gruvbox::$name,)+ },
82 Palette { $($name: dracula::$name,)+ },
83 Palette { $($name: darkroom::$name,)+ },
84 ];
85
86 $(
87 #[allow(non_snake_case)]
88 // corner-cut: the Darkroom substrate roles (INK1.. SAFELIGHT_GLYPH)
89 // have no call site yet -- this task owns theme.rs only and wires
90 // the table, not the paints. Ceiling: drop this attribute once the
91 // render-side task in the same DESIGN §12 package reads them.
92 #[allow(dead_code)]
93 #[inline]
94 pub fn $name() -> $ty { palette().$name }
95 )+
96 };
97}
98
99palette! {
100 BG_CANVAS: u32,
101 BG_PANEL: u32,
102 BG_RAISED: u32,
103 BG_TIMELINE: u32,
104 BG_HOVER: u32,
105 BG_HOVER_DIM: u32,
106 BG_SELECTED: u32,
107 SCRIM: u32,
108 SCRIM_LIGHT: u32,
109 STROKE_DIVIDER: u32,
110 STROKE_SELECTED: u32,
111 FG_PRIMARY: u32,
112 FG_SECONDARY: u32,
113 FG_DISABLED: u32,
114 ACCENT_PRIMARY: u32,
115 ACCENT_HOVER: u32,
116 ACCENT_PLAYHEAD: u32,
117 ACCENT_WASH: u32,
118 CLIP_VIDEO: u32,
119 CLIP_AUDIO: u32,
120 CLIP_IMAGE: u32,
121 CLIP_TEXT: u32,
122 SOURCE_TINTS: [u32; 12],
123 STATUS_ERROR: u32,
124 STATUS_WARNING: u32,
125 STATUS_SUCCESS: u32,
126 STATUS_PROGRESS: u32,
127 DROP_REFUSE: u32,
128 SUB_FG: u32,
129 SUB_SHADE: u32,
130 EQ_GRID: u32,
131 EQ_SPECTRUM_INK: u32,
132 EQ_FILL_INK: u32,
133 EQ_BELL_INK: u32,
134 HIST_INK: [u32; 3],
135 // -- Darkroom token substrate (DESIGN.md §2) --------------------------------
136 INK1: u32,
137 INK2: u32,
138 INK3: u32,
139 INK4: u32,
140 DARK_CANVAS: u32,
141 DARK_PANEL: u32,
142 DARK_RAISED: u32,
143 DARK_HAIRLINE: u32,
144 DARK_EDGE: u32,
145 DARK_SEAM: u32,
146 LAMP_WHITE: u32,
147 NOTICE_TELL: u32,
148 NOTICE_LOOK: u32,
149 NOTICE_DECIDE: u32,
150 SAFELIGHT_GROUND: u32,
151 SAFELIGHT_GLYPH: u32,
152}
153
154/// Which family a person picked. An enum and not a bool: the door in the
155/// toolbar is a list rather than a toggle precisely because the next family
156/// must cost one variant here, one module below, and nothing anywhere else.
157#[derive(Clone, Copy, PartialEq, Eq, Debug)]
158pub enum PaletteId {
159 Cool,
160 Warm,
161 Forest,
162 Violet,
163 Rose,
164 Amber,
165 Ocean,
166 Ice,
167 Orchid,
168 Nord,
169 Gruvbox,
170 Dracula,
171 Darkroom,
172}
173
174impl PaletteId {
175 /// What a fresh install and an unreadable theme file get: the mock's own
176 /// room (DESIGN.md §2.1), not the first family in the list.
177 pub const DEFAULT: PaletteId = PaletteId::Darkroom;
178
179 /// Display order -- the picker lists them in it, and the index into
180 /// [`PALETTES`] *is* the position in it, so this order and that array are
181 /// the same order or every colour is wrong.
182 pub const ALL: [PaletteId; 13] = [
183 PaletteId::Cool,
184 PaletteId::Warm,
185 PaletteId::Forest,
186 PaletteId::Violet,
187 PaletteId::Rose,
188 PaletteId::Amber,
189 PaletteId::Ocean,
190 PaletteId::Ice,
191 PaletteId::Orchid,
192 PaletteId::Nord,
193 PaletteId::Gruvbox,
194 PaletteId::Dracula,
195 PaletteId::Darkroom,
196 ];
197
198 /// What the button and the picker row call it.
199 pub fn label(self) -> &'static str {
200 match self {
201 PaletteId::Cool => "Cool",
202 PaletteId::Warm => "Warm",
203 PaletteId::Forest => "Forest",
204 PaletteId::Violet => "Violet",
205 PaletteId::Rose => "Rose",
206 PaletteId::Amber => "Amber",
207 PaletteId::Ocean => "Ocean",
208 PaletteId::Ice => "Ice",
209 PaletteId::Orchid => "Orchid",
210 PaletteId::Nord => "Nord",
211 PaletteId::Gruvbox => "Gruvbox",
212 PaletteId::Dracula => "Dracula",
213 PaletteId::Darkroom => "Darkroom",
214 }
215 }
216
217 /// The small print beside the row: what the family actually looks like, so
218 /// the choice is made before the click rather than after it. Short enough
219 /// to sit in the list's right-hand column at the 640x360 floor -- past
220 /// thirty characters it is truncated mid-word, which is a description that
221 /// describes nothing.
222 pub fn detail(self) -> &'static str {
223 match self {
224 PaletteId::Cool => "Black with cyan",
225 PaletteId::Warm => "Warm grey with coral",
226 PaletteId::Forest => "Dark green with emerald",
227 PaletteId::Violet => "Indigo with lavender",
228 PaletteId::Rose => "Grey with rose",
229 PaletteId::Amber => "Graphite with gold",
230 PaletteId::Ocean => "Blue-black with azure",
231 PaletteId::Ice => "Navy black with pale blue",
232 PaletteId::Orchid => "Plum with orchid",
233 PaletteId::Nord => "Blue-grey with frost",
234 PaletteId::Gruvbox => "Brown with orange",
235 PaletteId::Dracula => "Purple-grey with pink",
236 PaletteId::Darkroom => "Dark with sage green",
237 }
238 }
239
240 /// What the file calls it: one word, never the label, which is free to be
241 /// reworded ([`crate::keymap`]'s rule for the same reason).
242 pub fn name(self) -> &'static str {
243 match self {
244 PaletteId::Cool => "cool",
245 PaletteId::Warm => "warm",
246 PaletteId::Forest => "forest",
247 PaletteId::Violet => "violet",
248 PaletteId::Rose => "rose",
249 PaletteId::Amber => "amber",
250 PaletteId::Ocean => "ocean",
251 PaletteId::Ice => "ice",
252 PaletteId::Orchid => "orchid",
253 PaletteId::Nord => "nord",
254 PaletteId::Gruvbox => "gruvbox",
255 PaletteId::Dracula => "dracula",
256 PaletteId::Darkroom => "darkroom",
257 }
258 }
259
260 fn from_name(name: &str) -> Option<Self> {
261 Self::ALL.into_iter().find(|p| p.name() == name)
262 }
263
264 /// The numbers themselves, for anything that has to measure a family that
265 /// is not the one in force -- which is only the contrast guards, so it sits
266 /// with them rather than in the binary.
267 #[cfg(test)]
268 pub fn palette(self) -> &'static Palette {
269 &PALETTES[self as usize]
270 }
271}
272
273/// The family in force, as an index into [`PALETTES`]. An atomic because a
274/// token is read from whatever thread happens to be painting and the value is
275/// one `usize`; relaxed because nothing is published *with* it -- the next
276/// repaint reads it, and the swap asks for that repaint itself.
277static ACTIVE: AtomicUsize = AtomicUsize::new(PaletteId::DEFAULT as usize);
278
279/// The numbers every token function reads. One load, one bounds-checked index
280/// into a `'static` table: no allocation, no hashing, no lock.
281#[inline]
282pub fn palette() -> &'static Palette {
283 PALETTES
284 .get(ACTIVE.load(Relaxed))
285 .unwrap_or(&PALETTES[PaletteId::DEFAULT as usize])
286}
287
288/// Which family is in force -- what the button says and the picker marks.
289pub fn active() -> PaletteId {
290 PaletteId::ALL
291 .get(ACTIVE.load(Relaxed))
292 .copied()
293 .unwrap_or(PaletteId::DEFAULT)
294}
295
296/// Puts `id` in force. Every paint after this reads the new numbers; asking for
297/// the repaint is the caller's, since only it holds the window.
298pub fn set(id: PaletteId) {
299 ACTIVE.store(id as usize, Relaxed);
300}
301
302/// The accent colour a person picked, on top of whichever family is in force.
303/// The six come from the sibling project's accent palette (its dark tokens):
304/// the accent, a lighter one for hover, and the dark ink that sits on a fill.
305/// `Custom` is a colour of the person's own ([`custom_colour`]).
306#[derive(Clone, Copy, PartialEq, Eq, Debug)]
307pub enum AccentId {
308 Sage,
309 Ocean,
310 Plum,
311 Rose,
312 Ochre,
313 Gold,
314 Custom,
315}
316
317/// The custom colour before anyone has typed one: a soft orchid.
318pub const CUSTOM_DEFAULT: u32 = 0xd49ae0;
319/// The Vivid at which an accent is exactly the colour as designed.
320pub const VIVID_DESIGNED: u8 = 50;
321/// How vivid the accents are as shipped: bold (since 2026-10-21; before, the designed 50).
322pub const VIVID_DEFAULT: u8 = 100;
323
324impl AccentId {
325 pub const DEFAULT: AccentId = AccentId::Sage;
326 pub const ALL: [AccentId; 7] = [
327 AccentId::Sage,
328 AccentId::Ocean,
329 AccentId::Plum,
330 AccentId::Rose,
331 AccentId::Ochre,
332 AccentId::Gold,
333 AccentId::Custom,
334 ];
335
336 pub fn label(self) -> &'static str {
337 match self {
338 AccentId::Sage => "Sage",
339 AccentId::Ocean => "Ocean",
340 AccentId::Plum => "Plum",
341 AccentId::Rose => "Rose",
342 AccentId::Ochre => "Ochre",
343 AccentId::Gold => "Gold",
344 AccentId::Custom => "Custom",
345 }
346 }
347
348 /// The word kept in the accent file.
349 pub fn name(self) -> &'static str {
350 match self {
351 AccentId::Sage => "sage",
352 AccentId::Ocean => "ocean",
353 AccentId::Plum => "plum",
354 AccentId::Rose => "rose",
355 AccentId::Ochre => "ochre",
356 AccentId::Gold => "gold",
357 AccentId::Custom => "custom",
358 }
359 }
360
361 /// The accent file's word for this accent; a file saved before the grey
362 /// Slate was replaced still reads "slate" and lands on Gold.
363 pub fn from_name(name: &str) -> Option<Self> {
364 match name {
365 "slate" => Some(AccentId::Gold),
366 _ => Self::ALL.into_iter().find(|a| a.name() == name),
367 }
368 }
369
370 /// `(accent, hover, ink on a fill)` as designed, before Vivid. A custom
371 /// colour has its hover and ink worked out from it.
372 pub fn base(self, custom: u32) -> (u32, u32, u32) {
373 match self {
374 AccentId::Sage => (0x9dbea2, 0xb5d2b9, 0x0f1510),
375 AccentId::Ocean => (0x86b9dd, 0x9fcbea, 0x061118),
376 AccentId::Plum => (0xbba9e0, 0xcbbceb, 0x110d18),
377 AccentId::Rose => (0xe79dad, 0xf3b2c0, 0x190a0e),
378 AccentId::Ochre => (0xd8a98a, 0xe4bca1, 0x170d07),
379 AccentId::Gold => (0xe3d372, 0xf7ea9b, 0x191606),
380 AccentId::Custom => {
381 let (l, c, h) = to_oklch(custom);
382 (custom, from_oklch((l + 0.06).min(1.), c * 0.9, h), from_oklch(0.17, c.min(0.03), h))
383 }
384 }
385 }
386
387 /// The swatch's colour: the accent as designed.
388 pub fn colours(self) -> (u32, u32, u32) {
389 self.base(custom_colour().unwrap_or(CUSTOM_DEFAULT))
390 }
391}
392
393/// The colour a swatch wears: the accent as the Vivid in force makes it, so it matches the button.
394pub fn swatch(a: AccentId) -> u32 {
395 vivid_adjust(a.colours().0, vivid())
396}
397
398/// What a person chose: the accent, how vivid, and the colour behind Custom.
399#[derive(Clone, Copy, PartialEq, Eq, Debug)]
400pub struct AccentSpec {
401 pub id: AccentId,
402 pub vivid: u8,
403 pub custom: u32,
404}
405
406impl AccentSpec {
407 #[cfg(test)]
408 pub const DEFAULT: AccentSpec = AccentSpec { id: AccentId::DEFAULT, vivid: VIVID_DEFAULT, custom: CUSTOM_DEFAULT };
409
410 /// `t` with its accent roles replaced by this accent. The primary fill is
411 /// the accent itself; press is the accent a little darker; the label on it
412 /// is whichever of the accent's dark ink and white reads better. The colour
413 /// itself is never moved to make anything readable: it is the person's.
414 fn apply(self, mut t: Tokens) -> Tokens {
415 let (base, base_hover, ink) = self.id.base(self.custom);
416 let accent = vivid_adjust(base, self.vivid);
417 let hover = match accent == base {
418 true => base_hover,
419 false => vivid_adjust(base_hover, self.vivid),
420 };
421 let press = mix(accent, 0x000000, 0.15);
422 let score = |ink: u32| contrast(ink, accent).min(contrast(ink, press));
423 t.accent = accent;
424 t.accent_hover = hover;
425 t.accent_press = press;
426 t.accent_fill = accent;
427 t.on_accent = match score(ink) >= score(0xffffff) {
428 true => ink,
429 false => 0xffffff,
430 };
431 t.accent_wash = with_alpha(accent, 0x33);
432 t.range_tint = with_alpha(accent, 0x1a);
433 t
434 }
435}
436
437// -- OKLab / OKLCH, for the Vivid setting and the hue slider -------------------
438
439fn srgb_to_lin(c: f64) -> f64 {
440 if c <= 0.04045 { c / 12.92 } else { ((c + 0.055) / 1.055).powf(2.4) }
441}
442
443fn lin_to_srgb(x: f64) -> f64 {
444 if x <= 0.0031308 { x * 12.92 } else { 1.055 * x.powf(1. / 2.4) - 0.055 }
445}
446
447/// `0xRRGGBB` to OKLCH: lightness 0..1, chroma, hue in degrees.
448pub fn to_oklch(rgb: u32) -> (f64, f64, f64) {
449 let ch = |s: u32| srgb_to_lin(f64::from((rgb >> s) & 0xff) / 255.);
450 let (r, g, b) = (ch(16), ch(8), ch(0));
451 let l = (0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b).cbrt();
452 let m = (0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b).cbrt();
453 let s = (0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b).cbrt();
454 let big_l = 0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s;
455 let a = 1.9779984951 * l - 2.4285922050 * m + 0.4505937099 * s;
456 let bb = 0.0259040371 * l + 0.7827717662 * m - 0.8086757660 * s;
457 (big_l, a.hypot(bb), bb.atan2(a).to_degrees().rem_euclid(360.))
458}
459
460/// The linear sRGB of an OKLCH colour, possibly outside 0..1.
461fn oklch_lin(l: f64, c: f64, h: f64) -> (f64, f64, f64) {
462 let (a, b) = (c * h.to_radians().cos(), c * h.to_radians().sin());
463 let l_ = (l + 0.3963377774 * a + 0.2158037573 * b).powi(3);
464 let m_ = (l - 0.1055613458 * a - 0.0638541728 * b).powi(3);
465 let s_ = (l - 0.0894841775 * a - 1.2914855480 * b).powi(3);
466 (
467 4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_,
468 -1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_,
469 -0.0041960863 * l_ - 0.7034186147 * m_ + 1.7076147010 * s_,
470 )
471}
472
473/// OKLCH to `0xRRGGBB`. A colour the screen cannot show keeps its lightness and
474/// hue and gives up chroma until it fits.
475pub fn from_oklch(l: f64, c: f64, h: f64) -> u32 {
476 let l = l.clamp(0., 1.);
477 let fits = |c: f64| {
478 let (r, g, b) = oklch_lin(l, c, h);
479 [r, g, b].iter().all(|v| (-0.0005..=1.0005).contains(v))
480 };
481 let mut c = c.max(0.);
482 if !fits(c) {
483 let (mut lo, mut hi) = (0., c);
484 for _ in 0..24 {
485 let mid = (lo + hi) / 2.;
486 match fits(mid) {
487 true => lo = mid,
488 false => hi = mid,
489 }
490 }
491 c = lo;
492 }
493 let (r, g, b) = oklch_lin(l, c, h);
494 let byte = |v: f64| (lin_to_srgb(v.clamp(0., 1.)) * 255.).round() as u32;
495 byte(r) << 16 | byte(g) << 8 | byte(b)
496}
497
498/// `rgb` with its chroma moved by Vivid (0..100). 50 is the colour untouched;
499/// 0 leaves a faint tint of it; 100 is bold, as far as the screen allows.
500/// Hue and lightness stay.
501pub fn vivid_adjust(rgb: u32, vivid: u8) -> u32 {
502 if vivid == VIVID_DESIGNED {
503 return rgb;
504 }
505 let (l, c, h) = to_oklch(rgb);
506 let v = f64::from(vivid.min(100));
507 let c = match v < 50. {
508 true => c * (0.08 + 0.92 * v / 50.),
509 false => c + (v - 50.) / 50. * ((c * 3.).max(0.17) - c),
510 };
511 from_oklch(l, c, h)
512}
513
514/// `#RRGGBB` (the `#` optional) to `0xRRGGBB`; anything else is `None`.
515pub fn parse_hex(text: &str) -> Option<u32> {
516 let t = text.trim().trim_start_matches('#');
517 match t.len() == 6 && t.chars().all(|c| c.is_ascii_hexdigit()) {
518 true => u32::from_str_radix(t, 16).ok(),
519 false => None,
520 }
521}
522
523/// The accent chosen, as a spec: three words in force at once.
524static ACCENT: AtomicUsize = AtomicUsize::new(AccentId::DEFAULT as usize);
525static VIVID: AtomicU8 = AtomicU8::new(VIVID_DEFAULT);
526/// The custom colour; above `0xffffff` means nobody has made one.
527static CUSTOM: AtomicU32 = AtomicU32::new(u32::MAX);
528
529pub fn accent() -> AccentId {
530 AccentId::ALL.get(ACCENT.load(Relaxed)).copied().unwrap_or(AccentId::DEFAULT)
531}
532
533pub fn vivid() -> u8 {
534 VIVID.load(Relaxed)
535}
536
537/// The custom colour, once there is one.
538pub fn custom_colour() -> Option<u32> {
539 Some(CUSTOM.load(Relaxed)).filter(|c| *c <= 0xffffff)
540}
541
542fn spec_in_force() -> AccentSpec {
543 AccentSpec { id: accent(), vivid: vivid(), custom: custom_colour().unwrap_or(CUSTOM_DEFAULT) }
544}
545
546/// Puts `a` in force; the caller asks for the repaint. Custom with no colour
547/// yet takes the default one, so the swatch has something to show.
548pub fn set_accent(a: AccentId) {
549 if a == AccentId::Custom && custom_colour().is_none() {
550 CUSTOM.store(CUSTOM_DEFAULT, Relaxed);
551 }
552 ACCENT.store(a as usize, Relaxed);
553 refresh();
554}
555
556pub fn set_vivid(v: u8) {
557 VIVID.store(v.min(100), Relaxed);
558 refresh();
559}
560
561/// Sets the custom colour and makes Custom the accent in force.
562pub fn set_custom(rgb: u32) {
563 CUSTOM.store(rgb & 0xffffff, Relaxed);
564 ACCENT.store(AccentId::Custom as usize, Relaxed);
565 refresh();
566}
567
568/// Beside the theme file: `~/.config/edith/accent`.
569pub fn accent_path() -> PathBuf {
570 config_path().with_file_name("accent")
571}
572
573/// Reads the accent file: `accent=sage`, `vivid=100`, `custom=#3ddc97`, one per
574/// line. The first version kept just the word (`sage`), which still reads.
575/// Anything unknown or unreadable leaves that part at its default.
576pub fn parse_accent(text: &str) -> (AccentId, u8, Option<u32>) {
577 let (mut id, mut vivid, mut custom) = (AccentId::DEFAULT, VIVID_DEFAULT, None);
578 for line in text.lines().map(str::trim) {
579 match line.split_once('=') {
580 Some(("accent", v)) => id = AccentId::from_name(v.trim()).unwrap_or(id),
581 Some(("vivid", v)) => vivid = v.trim().parse::<u32>().map_or(vivid, |n| n.min(100) as u8),
582 Some(("custom", v)) => custom = parse_hex(v).or(custom),
583 None => id = AccentId::from_name(line).unwrap_or(id),
584 _ => {}
585 }
586 }
587 (id, vivid, custom)
588}
589
590/// The accent file's text for what is in force.
591pub fn accent_text() -> String {
592 let mut text = format!("accent={}\nvivid={}\n", accent().name(), vivid());
593 if let Some(c) = custom_colour() {
594 text.push_str(&format!("custom=#{c:06x}\n"));
595 }
596 text
597}
598
599/// The accent from the last session; missing or unreadable leaves Sage.
600pub fn load_accent() {
601 if let Ok(text) = std::fs::read_to_string(accent_path()) {
602 let (id, vivid, custom) = parse_accent(&text);
603 if let Some(c) = custom {
604 CUSTOM.store(c, Relaxed);
605 }
606 VIVID.store(vivid, Relaxed);
607 set_accent(id);
608 }
609}
610
611/// Writes the accent in force, like [`save`].
612pub fn save_accent() -> std::io::Result<()> {
613 let path = accent_path();
614 if let Some(dir) = path.parent() {
615 std::fs::create_dir_all(dir)?;
616 }
617 std::fs::write(path, accent_text())
618}
619
620/// Where the pick lives: one word in a file beside the keybindings, so a
621/// desktop that names an XDG directory is obeyed for both.
622pub fn config_path() -> PathBuf {
623 crate::keymap::Keymap::config_path().with_file_name("theme")
624}
625
626/// The pick from the last session, if there was one. Anything unreadable or
627/// unknown leaves the default in force: a theme file is not the user's work,
628/// so a bad one is worth no message at startup.
629pub fn load() {
630 if let Ok(text) = std::fs::read_to_string(config_path())
631 && let Some(id) = PaletteId::from_name(text.trim())
632 {
633 set(id);
634 }
635}
636
637/// Writes the pick. One word, written whole -- a torn write costs the theme and
638/// nothing else, and [`load`] falls back to the default on one.
639pub fn save(id: PaletteId) -> std::io::Result<()> {
640 let path = config_path();
641 if let Some(dir) = path.parent() {
642 std::fs::create_dir_all(dir)?;
643 }
644 std::fs::write(path, format!("{}\n", id.name()))
645}
646
647/// Family B: near-black ground, cool neutral chrome, one cyan accent.
648pub mod cool {
649 // -- surfaces ---------------------------------------------------------------
650 /// The app's base, and the bed a picture is letterboxed against: darker than
651 /// every panel, so the picture is what the eye lands on.
652 pub const BG_CANVAS: u32 = 0x0b0d10;
653 /// The library, the inspector, the toolbar: the chrome the work sits between.
654 pub const BG_PANEL: u32 = 0x151a21;
655 /// Buttons, menu bodies, cards -- one plane up from the panel. Flat: the
656 /// separation is colour, never a shadow.
657 pub const BG_RAISED: u32 = 0x212936;
658 /// The lane bed, darker than the panel so a clip reads as an object on it.
659 pub const BG_TIMELINE: u32 = 0x0e1218;
660 /// One step lighter than whatever it sits on: the pointer's answer that this
661 /// is clickable.
662 pub const BG_HOVER: u32 = 0x2f3a4a;
663 /// The same answer for the things that stand on the panel rather than on a
664 /// button.
665 pub const BG_HOVER_DIM: u32 = 0x1d2531;
666 /// A picked row, a picked clip: the accent at surface brightness, so a
667 /// selection is tinted rather than lit up.
668 pub const BG_SELECTED: u32 = 0x0d4b5c;
669 /// What a card is floated over when it is genuinely modal (the export, the
670 /// actions list). Inspector sections never draw one -- they occlude nothing.
671 pub const SCRIM: u32 = 0x0b0d10cc;
672 /// The lighter scrim: the picker list floats over a card that is still being
673 /// read, so it dims rather than hides.
674 pub const SCRIM_LIGHT: u32 = 0x0b0d1055;
675
676 // -- strokes ----------------------------------------------------------------
677 pub const STROKE_DIVIDER: u32 = 0x2a3442;
678 pub const STROKE_SELECTED: u32 = 0x22d3ee;
679
680 // -- text -------------------------------------------------------------------
681 pub const FG_PRIMARY: u32 = 0xe9eff7;
682 /// Shortcuts, dismissal hints, detail lines. Past 4.5:1 on every surface
683 /// above.
684 pub const FG_SECONDARY: u32 = 0xa7b6c9;
685 pub const FG_DISABLED: u32 = 0x6c7a8b;
686
687 // -- interaction ------------------------------------------------------------
688 pub const ACCENT_PRIMARY: u32 = 0x22d3ee;
689 /// The accent under the pointer: lighter, still the accent.
690 pub const ACCENT_HOVER: u32 = 0x67e8f9;
691 /// Not the accent: the playhead crosses every clip colour there is and has
692 /// to stay the one line that is none of them.
693 pub const ACCENT_PLAYHEAD: u32 = 0xff9db0;
694 /// The accent as a translucent wash, for the marks drawn over a clip body.
695 pub const ACCENT_WASH: u32 = 0x22d3eeaa;
696
697 // -- clip kinds (cross-NLE convention) --------------------------------------
698 pub const CLIP_VIDEO: u32 = 0x2b5fa8;
699 pub const CLIP_AUDIO: u32 = 0x276b43;
700 pub const CLIP_IMAGE: u32 = 0x1a6a6a;
701 pub const CLIP_TEXT: u32 = 0x6b46c1;
702
703 /// One per source, so a clip that came from an imported file reads as coming
704 /// from somewhere else than its neighbour. The *kind* is the body colour now
705 /// ([`super::clip_kind`]); this is the identity stripe and the library
706 /// swatch, and it only has to be four things telling each other apart.
707 pub const SOURCE_TINTS: [u32; 12] = [
708 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6, 0x4f8fd6,
709 0xd69a4f, 0x4fd6a8, 0xb14fd6,
710 ];
711
712 // -- feedback ---------------------------------------------------------------
713 pub const STATUS_ERROR: u32 = 0xef4444;
714 pub const STATUS_WARNING: u32 = 0xf59e0b;
715 pub const STATUS_SUCCESS: u32 = 0x34d399;
716 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
717 /// The mirror of [`BG_SELECTED`]: a drop the lane will not take, tinting the
718 /// shadow the drag draws so a refusal is seen before the release.
719 pub const DROP_REFUSE: u32 = 0x8f2740;
720
721 // -- subtitles (drawn over the picture, so they own their own contrast) -----
722 pub const SUB_FG: u32 = 0xffffff;
723 pub const SUB_SHADE: u32 = 0x000000cc;
724
725 // -- the equalizer graph and the histogram ----------------------------------
726 pub const EQ_GRID: u32 = 0x2a3442;
727 pub const EQ_SPECTRUM_INK: u32 = 0x7f95ad66;
728 pub const EQ_FILL_INK: u32 = 0x22d3ee26;
729 pub const EQ_BELL_INK: u32 = 0x22d3ee66;
730 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
731 // -- Darkroom token substrate: aliased onto this family's nearest role -----
732 pub const INK1: u32 = FG_PRIMARY;
733 pub const INK2: u32 = FG_SECONDARY;
734 pub const INK3: u32 = 0x98a2af;
735 pub const INK4: u32 = FG_DISABLED;
736 pub const DARK_CANVAS: u32 = BG_CANVAS;
737 pub const DARK_PANEL: u32 = BG_PANEL;
738 pub const DARK_RAISED: u32 = BG_RAISED;
739 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
740 pub const DARK_EDGE: u32 = INK3;
741 pub const DARK_SEAM: u32 = SCRIM;
742 pub const LAMP_WHITE: u32 = 0xffffff;
743 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
744 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
745 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
746 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
747 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
748}
749
750/// Family A: a warm consumer-editor ground (Movavi's bed, CapCut's saturation)
751/// with one coral accent that is never used for anything but "this is live,
752/// press this". Same roles, same measured floors, different numbers.
753pub mod warm {
754 // -- surfaces ---------------------------------------------------------------
755 pub const BG_CANVAS: u32 = 0x0c0a09;
756 pub const BG_PANEL: u32 = 0x1d1917;
757 pub const BG_RAISED: u32 = 0x383029;
758 pub const BG_TIMELINE: u32 = 0x151211;
759 pub const BG_HOVER: u32 = 0x4a413b;
760 pub const BG_HOVER_DIM: u32 = 0x241f1d;
761 /// Darker than the family it came from: at V3's own `0x7a3a1c` the secondary
762 /// ink on a picked row measures 4.09:1 and WCAG 1.4.3 wants 4.5, which the
763 /// cool table's guard caught the moment this became a second palette.
764 pub const BG_SELECTED: u32 = 0x6a3118;
765 pub const SCRIM: u32 = 0x0c0a09cc;
766 pub const SCRIM_LIGHT: u32 = 0x0c0a0955;
767
768 // -- strokes ----------------------------------------------------------------
769 pub const STROKE_DIVIDER: u32 = 0x3a322e;
770 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
771
772 // -- text -------------------------------------------------------------------
773 pub const FG_PRIMARY: u32 = 0xf2ece6;
774 pub const FG_SECONDARY: u32 = 0xbdb1a8;
775 pub const FG_DISABLED: u32 = 0x8a7f78;
776
777 // -- interaction ------------------------------------------------------------
778 pub const ACCENT_PRIMARY: u32 = 0xff7a45;
779 pub const ACCENT_HOVER: u32 = 0xff9a6e;
780 /// Warmer still than the accent, because it crosses everything the accent is
781 /// drawn on and has to stay findable over a selected clip.
782 pub const ACCENT_PLAYHEAD: u32 = 0xffc23a;
783 pub const ACCENT_WASH: u32 = 0xff7a45aa;
784
785 // -- clip kinds (the same cross-NLE convention, at this family's weight) ----
786 pub const CLIP_VIDEO: u32 = 0x2b4c7e;
787 pub const CLIP_AUDIO: u32 = 0x2c5a3a;
788 pub const CLIP_IMAGE: u32 = 0x1f5560;
789 pub const CLIP_TEXT: u32 = 0x4a3070;
790
791 /// Warm-side identity stripes: the same four-way distinctness the cool
792 /// family's are held to, in hues that belong to this ground.
793 pub const SOURCE_TINTS: [u32; 12] = [
794 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8, 0xe08a4f,
795 0x4fa8d6, 0x8fc94f, 0xd67aa8,
796 ];
797
798 // -- feedback ---------------------------------------------------------------
799 pub const STATUS_ERROR: u32 = 0xc85050;
800 pub const STATUS_WARNING: u32 = 0xe0a53a;
801 pub const STATUS_SUCCESS: u32 = 0x4fbf72;
802 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
803 pub const DROP_REFUSE: u32 = 0x8a2f24;
804
805 // -- subtitles --------------------------------------------------------------
806 pub const SUB_FG: u32 = 0xffffff;
807 pub const SUB_SHADE: u32 = 0x000000cc;
808
809 // -- the equalizer graph and the histogram ----------------------------------
810 pub const EQ_GRID: u32 = 0x4a413b;
811 pub const EQ_SPECTRUM_INK: u32 = 0xbdb1a866;
812 pub const EQ_FILL_INK: u32 = 0xff7a4526;
813 pub const EQ_BELL_INK: u32 = 0xff7a4566;
814 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
815 // -- Darkroom token substrate: aliased onto this family's nearest role -----
816 pub const INK1: u32 = FG_PRIMARY;
817 pub const INK2: u32 = FG_SECONDARY;
818 pub const INK3: u32 = 0xaca5a0;
819 pub const INK4: u32 = FG_DISABLED;
820 pub const DARK_CANVAS: u32 = BG_CANVAS;
821 pub const DARK_PANEL: u32 = BG_PANEL;
822 pub const DARK_RAISED: u32 = BG_RAISED;
823 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
824 pub const DARK_EDGE: u32 = INK3;
825 pub const DARK_SEAM: u32 = SCRIM;
826 pub const LAMP_WHITE: u32 = 0xffffff;
827 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
828 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
829 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
830 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
831 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
832}
833
834/// Family C: the ground itself green, dark enough that a graded frame is still
835/// the brightest thing on screen, with one emerald accent. The playhead goes
836/// pink here for the same reason it is pink in `cool`: it crosses the emerald
837/// and every clip body, so it may belong to none of them.
838pub mod forest {
839 // -- surfaces ---------------------------------------------------------------
840 pub const BG_CANVAS: u32 = 0x080d0a;
841 pub const BG_PANEL: u32 = 0x121b16;
842 pub const BG_RAISED: u32 = 0x1e2c24;
843 pub const BG_TIMELINE: u32 = 0x0b1310;
844 pub const BG_HOVER: u32 = 0x2c4034;
845 pub const BG_HOVER_DIM: u32 = 0x1a2620;
846 /// Deeper than the accent it is made of: the dim ink on a picked row is held
847 /// to 4.5:1 like every other family's (WCAG 1.4.3), and emerald at surface
848 /// brightness will not carry it.
849 pub const BG_SELECTED: u32 = 0x14503a;
850 pub const SCRIM: u32 = 0x080d0acc;
851 pub const SCRIM_LIGHT: u32 = 0x080d0a55;
852
853 // -- strokes ----------------------------------------------------------------
854 pub const STROKE_DIVIDER: u32 = 0x25362c;
855 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
856
857 // -- text -------------------------------------------------------------------
858 pub const FG_PRIMARY: u32 = 0xe7f3eb;
859 pub const FG_SECONDARY: u32 = 0xa8c4b4;
860 pub const FG_DISABLED: u32 = 0x6e8579;
861
862 // -- interaction ------------------------------------------------------------
863 pub const ACCENT_PRIMARY: u32 = 0x34d399;
864 pub const ACCENT_HOVER: u32 = 0x6ee7b7;
865 pub const ACCENT_PLAYHEAD: u32 = 0xff9db0;
866 pub const ACCENT_WASH: u32 = 0x34d399aa;
867
868 // -- clip kinds (the cross-NLE convention, at this family's weight) ---------
869 pub const CLIP_VIDEO: u32 = 0x2b5fa8;
870 /// Darker than the other families' green: on a green ground a clip body has
871 /// to be the object and the bed the hole, and the dim ink on it still owes
872 /// 3:1 (WCAG 1.4.11).
873 pub const CLIP_AUDIO: u32 = 0x256b44;
874 pub const CLIP_IMAGE: u32 = 0x1a6a6a;
875 pub const CLIP_TEXT: u32 = 0x6b46c1;
876
877 pub const SOURCE_TINTS: [u32; 12] = [
878 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f, 0xd6a45f, 0x5fa8d6, 0xc15fd6, 0x5fd68f,
879 0xd6a45f, 0x5fa8d6, 0xc15fd6,
880 ];
881
882 // -- feedback ---------------------------------------------------------------
883 /// Not the accent family: a success that wore the emerald would say "this is
884 /// live" in the same colour the whole window says it in.
885 pub const STATUS_ERROR: u32 = 0xf07171;
886 pub const STATUS_WARNING: u32 = 0xe3b341;
887 pub const STATUS_SUCCESS: u32 = 0x7bd88f;
888 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
889 pub const DROP_REFUSE: u32 = 0x7a2a33;
890
891 // -- subtitles --------------------------------------------------------------
892 pub const SUB_FG: u32 = 0xffffff;
893 pub const SUB_SHADE: u32 = 0x000000cc;
894
895 // -- the equalizer graph and the histogram ----------------------------------
896 pub const EQ_GRID: u32 = 0x25362c;
897 pub const EQ_SPECTRUM_INK: u32 = 0xa8c4b466;
898 pub const EQ_FILL_INK: u32 = 0x34d39926;
899 pub const EQ_BELL_INK: u32 = 0x34d39966;
900 /// The three channel inks are the picture's own R, G and B: they mean the
901 /// same thing in every family, so they are the same numbers in every family.
902 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
903 // -- Darkroom token substrate: aliased onto this family's nearest role -----
904 pub const INK1: u32 = FG_PRIMARY;
905 pub const INK2: u32 = FG_SECONDARY;
906 pub const INK3: u32 = 0x95a79e;
907 pub const INK4: u32 = FG_DISABLED;
908 pub const DARK_CANVAS: u32 = BG_CANVAS;
909 pub const DARK_PANEL: u32 = BG_PANEL;
910 pub const DARK_RAISED: u32 = BG_RAISED;
911 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
912 pub const DARK_EDGE: u32 = INK3;
913 pub const DARK_SEAM: u32 = SCRIM;
914 pub const LAMP_WHITE: u32 = 0xffffff;
915 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
916 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
917 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
918 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
919 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
920}
921
922/// Family D: an indigo ground with one lavender accent -- the cold end of the
923/// set, where `cool` is neutral-cold and this one is frankly blue. The playhead
924/// is the yellow that is furthest from everything in it.
925pub mod violet {
926 // -- surfaces ---------------------------------------------------------------
927 pub const BG_CANVAS: u32 = 0x0a0a12;
928 pub const BG_PANEL: u32 = 0x171827;
929 pub const BG_RAISED: u32 = 0x252842;
930 pub const BG_TIMELINE: u32 = 0x0e0f1b;
931 pub const BG_HOVER: u32 = 0x353a5e;
932 pub const BG_HOVER_DIM: u32 = 0x1f2138;
933 pub const BG_SELECTED: u32 = 0x3b2a78;
934 pub const SCRIM: u32 = 0x0a0a12cc;
935 pub const SCRIM_LIGHT: u32 = 0x0a0a1255;
936
937 // -- strokes ----------------------------------------------------------------
938 pub const STROKE_DIVIDER: u32 = 0x2e3150;
939 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
940
941 // -- text -------------------------------------------------------------------
942 pub const FG_PRIMARY: u32 = 0xeceafb;
943 pub const FG_SECONDARY: u32 = 0xb6b4d8;
944 pub const FG_DISABLED: u32 = 0x7b79a0;
945
946 // -- interaction ------------------------------------------------------------
947 pub const ACCENT_PRIMARY: u32 = 0xa78bfa;
948 pub const ACCENT_HOVER: u32 = 0xc4b5fd;
949 pub const ACCENT_PLAYHEAD: u32 = 0xfacc15;
950 pub const ACCENT_WASH: u32 = 0xa78bfaaa;
951
952 // -- clip kinds -------------------------------------------------------------
953 pub const CLIP_VIDEO: u32 = 0x2f5a9e;
954 pub const CLIP_AUDIO: u32 = 0x2c6b49;
955 pub const CLIP_IMAGE: u32 = 0x1c6270;
956 /// A shade off the accent on purpose: a text clip and "press this" must not
957 /// be the same purple.
958 pub const CLIP_TEXT: u32 = 0x6d3fa8;
959
960 pub const SOURCE_TINTS: [u32; 12] = [
961 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8, 0xe8a97f, 0x7fc8e8, 0xe87fb4, 0x9b7fe8,
962 0xe8a97f, 0x7fc8e8, 0xe87fb4,
963 ];
964
965 // -- feedback ---------------------------------------------------------------
966 pub const STATUS_ERROR: u32 = 0xf87171;
967 pub const STATUS_WARNING: u32 = 0xfbbf24;
968 pub const STATUS_SUCCESS: u32 = 0x6ee7b7;
969 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
970 pub const DROP_REFUSE: u32 = 0x7c2440;
971
972 // -- subtitles --------------------------------------------------------------
973 pub const SUB_FG: u32 = 0xffffff;
974 pub const SUB_SHADE: u32 = 0x000000cc;
975
976 // -- the equalizer graph and the histogram ----------------------------------
977 pub const EQ_GRID: u32 = 0x2e3150;
978 pub const EQ_SPECTRUM_INK: u32 = 0xb6b4d866;
979 pub const EQ_FILL_INK: u32 = 0xa78bfa26;
980 pub const EQ_BELL_INK: u32 = 0xa78bfa66;
981 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
982 // -- Darkroom token substrate: aliased onto this family's nearest role -----
983 pub const INK1: u32 = FG_PRIMARY;
984 pub const INK2: u32 = FG_SECONDARY;
985 pub const INK3: u32 = 0xa4a3be;
986 pub const INK4: u32 = FG_DISABLED;
987 pub const DARK_CANVAS: u32 = BG_CANVAS;
988 pub const DARK_PANEL: u32 = BG_PANEL;
989 pub const DARK_RAISED: u32 = BG_RAISED;
990 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
991 pub const DARK_EDGE: u32 = INK3;
992 pub const DARK_SEAM: u32 = SCRIM;
993 pub const LAMP_WHITE: u32 = 0xffffff;
994 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
995 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
996 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
997 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
998 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
999}
1000
1001/// Family E: a ground with no cast at all -- the neutral one, for grading, where
1002/// nothing but the accent has a hue. That accent is rose, and the playhead is
1003/// the cyan on the other side of the wheel from it.
1004pub mod rose {
1005 // -- surfaces ---------------------------------------------------------------
1006 pub const BG_CANVAS: u32 = 0x0c0b0c;
1007 pub const BG_PANEL: u32 = 0x1a181a;
1008 pub const BG_RAISED: u32 = 0x2a272a;
1009 pub const BG_TIMELINE: u32 = 0x121012;
1010 pub const BG_HOVER: u32 = 0x3d383d;
1011 pub const BG_HOVER_DIM: u32 = 0x221f22;
1012 pub const BG_SELECTED: u32 = 0x6b1f38;
1013 pub const SCRIM: u32 = 0x0c0b0ccc;
1014 pub const SCRIM_LIGHT: u32 = 0x0c0b0c55;
1015
1016 // -- strokes ----------------------------------------------------------------
1017 pub const STROKE_DIVIDER: u32 = 0x332f33;
1018 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
1019
1020 // -- text -------------------------------------------------------------------
1021 pub const FG_PRIMARY: u32 = 0xf3edef;
1022 pub const FG_SECONDARY: u32 = 0xc0b4b8;
1023 pub const FG_DISABLED: u32 = 0x8a7e82;
1024
1025 // -- interaction ------------------------------------------------------------
1026 pub const ACCENT_PRIMARY: u32 = 0xfb7185;
1027 pub const ACCENT_HOVER: u32 = 0xfda4af;
1028 pub const ACCENT_PLAYHEAD: u32 = 0x67e8f9;
1029 pub const ACCENT_WASH: u32 = 0xfb7185aa;
1030
1031 // -- clip kinds -------------------------------------------------------------
1032 pub const CLIP_VIDEO: u32 = 0x2f5a9e;
1033 pub const CLIP_AUDIO: u32 = 0x2c6b49;
1034 pub const CLIP_IMAGE: u32 = 0x1c6270;
1035 pub const CLIP_TEXT: u32 = 0x6b46c1;
1036
1037 pub const SOURCE_TINTS: [u32; 12] = [
1038 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97, 0x7fc8e8, 0xe8c87f, 0x9b7fe8, 0xe87f97,
1039 0x7fc8e8, 0xe8c87f, 0x9b7fe8,
1040 ];
1041
1042 // -- feedback ---------------------------------------------------------------
1043 /// Brighter and more saturated than the accent it sits near on the wheel: on
1044 /// a rose window a failure has to be louder than "this is live", and the
1045 /// message's own first word says which it is either way ([`crate::notices::Tone::of`]).
1046 pub const STATUS_ERROR: u32 = 0xff4d4d;
1047 pub const STATUS_WARNING: u32 = 0xfacc15;
1048 pub const STATUS_SUCCESS: u32 = 0x4ade80;
1049 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
1050 pub const DROP_REFUSE: u32 = 0x8f2740;
1051
1052 // -- subtitles --------------------------------------------------------------
1053 pub const SUB_FG: u32 = 0xffffff;
1054 pub const SUB_SHADE: u32 = 0x000000cc;
1055
1056 // -- the equalizer graph and the histogram ----------------------------------
1057 pub const EQ_GRID: u32 = 0x332f33;
1058 pub const EQ_SPECTRUM_INK: u32 = 0xc0b4b866;
1059 pub const EQ_FILL_INK: u32 = 0xfb718526;
1060 pub const EQ_BELL_INK: u32 = 0xfb718566;
1061 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
1062 // -- Darkroom token substrate: aliased onto this family's nearest role -----
1063 pub const INK1: u32 = FG_PRIMARY;
1064 pub const INK2: u32 = FG_SECONDARY;
1065 pub const INK3: u32 = 0xa9a0a3;
1066 pub const INK4: u32 = FG_DISABLED;
1067 pub const DARK_CANVAS: u32 = BG_CANVAS;
1068 pub const DARK_PANEL: u32 = BG_PANEL;
1069 pub const DARK_RAISED: u32 = BG_RAISED;
1070 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
1071 pub const DARK_EDGE: u32 = INK3;
1072 pub const DARK_SEAM: u32 = SCRIM;
1073 pub const LAMP_WHITE: u32 = 0xffffff;
1074 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
1075 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
1076 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
1077 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
1078 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
1079}
1080
1081/// Family F: a graphite ground -- neutral, a touch warm -- under one gold
1082/// accent.
1083pub mod amber {
1084 // -- surfaces ---------------------------------------------------------------
1085 pub const BG_CANVAS: u32 = 0x0d0d0c;
1086 pub const BG_PANEL: u32 = 0x1b1b19;
1087 pub const BG_RAISED: u32 = 0x2b2b27;
1088 pub const BG_TIMELINE: u32 = 0x131311;
1089 pub const BG_HOVER: u32 = 0x3e3e38;
1090 pub const BG_HOVER_DIM: u32 = 0x232320;
1091 /// Gold at surface brightness carries neither ink at 4.5:1, so the picked
1092 /// row is the accent taken down to a bronze.
1093 pub const BG_SELECTED: u32 = 0x5e3a0b;
1094 pub const SCRIM: u32 = 0x0d0d0ccc;
1095 pub const SCRIM_LIGHT: u32 = 0x0d0d0c55;
1096
1097 // -- strokes ----------------------------------------------------------------
1098 pub const STROKE_DIVIDER: u32 = 0x35352f;
1099 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
1100
1101 // -- text -------------------------------------------------------------------
1102 pub const FG_PRIMARY: u32 = 0xf2f0e9;
1103 pub const FG_SECONDARY: u32 = 0xbdbaae;
1104 pub const FG_DISABLED: u32 = 0x87857c;
1105
1106 // -- interaction ------------------------------------------------------------
1107 pub const ACCENT_PRIMARY: u32 = 0xfbbf24;
1108 pub const ACCENT_HOVER: u32 = 0xfcd34d;
1109 pub const ACCENT_PLAYHEAD: u32 = 0x93c5fd;
1110 pub const ACCENT_WASH: u32 = 0xfbbf24aa;
1111
1112 // -- clip kinds -------------------------------------------------------------
1113 pub const CLIP_VIDEO: u32 = 0x2f5a9e;
1114 pub const CLIP_AUDIO: u32 = 0x2c6b49;
1115 pub const CLIP_IMAGE: u32 = 0x1c6270;
1116 pub const CLIP_TEXT: u32 = 0x6b46c1;
1117
1118 pub const SOURCE_TINTS: [u32; 12] = [
1119 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f, 0x5fa8e8, 0x7fd69b, 0xd68fc1, 0xe8b45f,
1120 0x5fa8e8, 0x7fd69b, 0xd68fc1,
1121 ];
1122
1123 // -- feedback ---------------------------------------------------------------
1124 /// The warning steps to orange: amber *is* the accent here, and a warning
1125 /// wearing it would be indistinguishable from every live control.
1126 pub const STATUS_ERROR: u32 = 0xf05252;
1127 pub const STATUS_WARNING: u32 = 0xfb923c;
1128 pub const STATUS_SUCCESS: u32 = 0x4ade80;
1129 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
1130 pub const DROP_REFUSE: u32 = 0x7a2f24;
1131
1132 // -- subtitles --------------------------------------------------------------
1133 pub const SUB_FG: u32 = 0xffffff;
1134 pub const SUB_SHADE: u32 = 0x000000cc;
1135
1136 // -- the equalizer graph and the histogram ----------------------------------
1137 pub const EQ_GRID: u32 = 0x35352f;
1138 pub const EQ_SPECTRUM_INK: u32 = 0xbdbaae66;
1139 pub const EQ_FILL_INK: u32 = 0xfbbf2426;
1140 pub const EQ_BELL_INK: u32 = 0xfbbf2466;
1141 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
1142 // -- Darkroom token substrate: aliased onto this family's nearest role -----
1143 pub const INK1: u32 = FG_PRIMARY;
1144 pub const INK2: u32 = FG_SECONDARY;
1145 pub const INK3: u32 = 0xa5a49d;
1146 pub const INK4: u32 = FG_DISABLED;
1147 pub const DARK_CANVAS: u32 = BG_CANVAS;
1148 pub const DARK_PANEL: u32 = BG_PANEL;
1149 pub const DARK_RAISED: u32 = BG_RAISED;
1150 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
1151 pub const DARK_EDGE: u32 = INK3;
1152 pub const DARK_SEAM: u32 = SCRIM;
1153 pub const LAMP_WHITE: u32 = 0xffffff;
1154 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
1155 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
1156 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
1157 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
1158 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
1159}
1160
1161/// Family G: a blue-black ground -- deeper and bluer than `cool`'s neutral --
1162/// under one azure accent. Where `cool` is a grey that leans cold, this one is
1163/// water: the panels themselves carry the hue and the accent is the light on it.
1164pub mod ocean {
1165 // -- surfaces ---------------------------------------------------------------
1166 pub const BG_CANVAS: u32 = 0x05080f;
1167 pub const BG_PANEL: u32 = 0x0d1524;
1168 pub const BG_RAISED: u32 = 0x172436;
1169 pub const BG_TIMELINE: u32 = 0x08101c;
1170 pub const BG_HOVER: u32 = 0x223449;
1171 pub const BG_HOVER_DIM: u32 = 0x14202f;
1172 pub const BG_SELECTED: u32 = 0x0f3a6b;
1173 pub const SCRIM: u32 = 0x05080fcc;
1174 pub const SCRIM_LIGHT: u32 = 0x05080f55;
1175
1176 // -- strokes ----------------------------------------------------------------
1177 pub const STROKE_DIVIDER: u32 = 0x1e2d42;
1178 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
1179
1180 // -- text -------------------------------------------------------------------
1181 pub const FG_PRIMARY: u32 = 0xe6eefb;
1182 pub const FG_SECONDARY: u32 = 0xa4bcd8;
1183 pub const FG_DISABLED: u32 = 0x6b8199;
1184
1185 // -- interaction ------------------------------------------------------------
1186 pub const ACCENT_PRIMARY: u32 = 0x38bdf8;
1187 pub const ACCENT_HOVER: u32 = 0x7dd3fc;
1188 pub const ACCENT_PLAYHEAD: u32 = 0xff9db0;
1189 pub const ACCENT_WASH: u32 = 0x38bdf8aa;
1190
1191 // -- clip kinds -------------------------------------------------------------
1192 pub const CLIP_VIDEO: u32 = 0x2f5a9e;
1193 pub const CLIP_AUDIO: u32 = 0x2c6b49;
1194 pub const CLIP_IMAGE: u32 = 0x1c6270;
1195 pub const CLIP_TEXT: u32 = 0x6b46c1;
1196
1197 pub const SOURCE_TINTS: [u32; 12] = [
1198 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8, 0xe8a95f, 0x5fd6a0, 0xc98fe8, 0x5fa8e8,
1199 0xe8a95f, 0x5fd6a0, 0xc98fe8,
1200 ];
1201
1202 // -- feedback ---------------------------------------------------------------
1203 pub const STATUS_ERROR: u32 = 0xf05252;
1204 pub const STATUS_WARNING: u32 = 0xfbbf24;
1205 pub const STATUS_SUCCESS: u32 = 0x4ade80;
1206 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
1207 pub const DROP_REFUSE: u32 = 0x8a2740;
1208
1209 // -- subtitles --------------------------------------------------------------
1210 pub const SUB_FG: u32 = 0xffffff;
1211 pub const SUB_SHADE: u32 = 0x000000cc;
1212
1213 // -- the equalizer graph and the histogram ----------------------------------
1214 pub const EQ_GRID: u32 = 0x1e2d42;
1215 pub const EQ_SPECTRUM_INK: u32 = 0xa4bcd866;
1216 pub const EQ_FILL_INK: u32 = 0x38bdf826;
1217 pub const EQ_BELL_INK: u32 = 0x38bdf866;
1218 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
1219 // -- Darkroom token substrate: aliased onto this family's nearest role -----
1220 pub const INK1: u32 = FG_PRIMARY;
1221 pub const INK2: u32 = FG_SECONDARY;
1222 pub const INK3: u32 = 0x92a3b4;
1223 pub const INK4: u32 = FG_DISABLED;
1224 pub const DARK_CANVAS: u32 = BG_CANVAS;
1225 pub const DARK_PANEL: u32 = BG_PANEL;
1226 pub const DARK_RAISED: u32 = BG_RAISED;
1227 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
1228 pub const DARK_EDGE: u32 = INK3;
1229 pub const DARK_SEAM: u32 = SCRIM;
1230 pub const LAMP_WHITE: u32 = 0xffffff;
1231 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
1232 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
1233 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
1234 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
1235 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
1236}
1237
1238/// Family H: the crisp one. A near-black blue ground with the widest ink range
1239/// in the set -- the primary text is nearly white and the canvas nearly black --
1240/// under a pale ice-blue accent, for the long grade where every other family
1241/// starts to read as soft.
1242pub mod ice {
1243 // -- surfaces ---------------------------------------------------------------
1244 pub const BG_CANVAS: u32 = 0x03060a;
1245 pub const BG_PANEL: u32 = 0x0b131c;
1246 pub const BG_RAISED: u32 = 0x18232f;
1247 pub const BG_TIMELINE: u32 = 0x060d15;
1248 pub const BG_HOVER: u32 = 0x24323f;
1249 pub const BG_HOVER_DIM: u32 = 0x121c26;
1250 /// A steel blue rather than the accent: ice at surface brightness is nearly
1251 /// white and would carry no ink at all (WCAG 1.4.3).
1252 pub const BG_SELECTED: u32 = 0x14476b;
1253 pub const SCRIM: u32 = 0x03060acc;
1254 pub const SCRIM_LIGHT: u32 = 0x03060a55;
1255
1256 // -- strokes ----------------------------------------------------------------
1257 pub const STROKE_DIVIDER: u32 = 0x223140;
1258 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
1259
1260 // -- text -------------------------------------------------------------------
1261 pub const FG_PRIMARY: u32 = 0xf4fafe;
1262 pub const FG_SECONDARY: u32 = 0xb8cfe0;
1263 pub const FG_DISABLED: u32 = 0x71889b;
1264
1265 // -- interaction ------------------------------------------------------------
1266 pub const ACCENT_PRIMARY: u32 = 0xa5f3fc;
1267 pub const ACCENT_HOVER: u32 = 0xcffafe;
1268 pub const ACCENT_PLAYHEAD: u32 = 0xff8fa3;
1269 pub const ACCENT_WASH: u32 = 0xa5f3fcaa;
1270
1271 // -- clip kinds -------------------------------------------------------------
1272 pub const CLIP_VIDEO: u32 = 0x2f5a9e;
1273 pub const CLIP_AUDIO: u32 = 0x2c6b49;
1274 pub const CLIP_IMAGE: u32 = 0x1c6270;
1275 pub const CLIP_TEXT: u32 = 0x6b46c1;
1276
1277 pub const SOURCE_TINTS: [u32; 12] = [
1278 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8, 0xe8b47f, 0x8fd69b, 0xc79be8, 0x7fd6e8,
1279 0xe8b47f, 0x8fd69b, 0xc79be8,
1280 ];
1281
1282 // -- feedback ---------------------------------------------------------------
1283 pub const STATUS_ERROR: u32 = 0xff6b6b;
1284 pub const STATUS_WARNING: u32 = 0xfbbf24;
1285 pub const STATUS_SUCCESS: u32 = 0x4ade80;
1286 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
1287 pub const DROP_REFUSE: u32 = 0x8f2740;
1288
1289 // -- subtitles --------------------------------------------------------------
1290 pub const SUB_FG: u32 = 0xffffff;
1291 pub const SUB_SHADE: u32 = 0x000000cc;
1292
1293 // -- the equalizer graph and the histogram ----------------------------------
1294 pub const EQ_GRID: u32 = 0x223140;
1295 pub const EQ_SPECTRUM_INK: u32 = 0xb8cfe066;
1296 pub const EQ_FILL_INK: u32 = 0xa5f3fc26;
1297 pub const EQ_BELL_INK: u32 = 0xa5f3fc66;
1298 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
1299 // -- Darkroom token substrate: aliased onto this family's nearest role -----
1300 pub const INK1: u32 = FG_PRIMARY;
1301 pub const INK2: u32 = FG_SECONDARY;
1302 pub const INK3: u32 = 0x97a8b6;
1303 pub const INK4: u32 = FG_DISABLED;
1304 pub const DARK_CANVAS: u32 = BG_CANVAS;
1305 pub const DARK_PANEL: u32 = BG_PANEL;
1306 pub const DARK_RAISED: u32 = BG_RAISED;
1307 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
1308 pub const DARK_EDGE: u32 = INK3;
1309 pub const DARK_SEAM: u32 = SCRIM;
1310 pub const LAMP_WHITE: u32 = 0xffffff;
1311 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
1312 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
1313 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
1314 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
1315 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
1316}
1317
1318/// Family I: a dark plum ground under one orchid accent -- the warm end of the
1319/// purples, where `violet` is the cold one. The text clip is pushed towards
1320/// indigo here for `violet`'s reason: a text clip and "press this" may not be
1321/// the same purple.
1322pub mod orchid {
1323 // -- surfaces ---------------------------------------------------------------
1324 pub const BG_CANVAS: u32 = 0x0c0712;
1325 pub const BG_PANEL: u32 = 0x1a0f24;
1326 pub const BG_RAISED: u32 = 0x2a1a38;
1327 pub const BG_TIMELINE: u32 = 0x120a19;
1328 pub const BG_HOVER: u32 = 0x3b2650;
1329 pub const BG_HOVER_DIM: u32 = 0x231530;
1330 pub const BG_SELECTED: u32 = 0x6b1f5e;
1331 pub const SCRIM: u32 = 0x0c0712cc;
1332 pub const SCRIM_LIGHT: u32 = 0x0c071255;
1333
1334 // -- strokes ----------------------------------------------------------------
1335 pub const STROKE_DIVIDER: u32 = 0x33203f;
1336 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
1337
1338 // -- text -------------------------------------------------------------------
1339 pub const FG_PRIMARY: u32 = 0xf6ecf8;
1340 pub const FG_SECONDARY: u32 = 0xc7b0cf;
1341 pub const FG_DISABLED: u32 = 0x8e7a97;
1342
1343 // -- interaction ------------------------------------------------------------
1344 pub const ACCENT_PRIMARY: u32 = 0xd946ef;
1345 pub const ACCENT_HOVER: u32 = 0xe879f9;
1346 pub const ACCENT_PLAYHEAD: u32 = 0xfbbf24;
1347 pub const ACCENT_WASH: u32 = 0xd946efaa;
1348
1349 // -- clip kinds -------------------------------------------------------------
1350 pub const CLIP_VIDEO: u32 = 0x2f5a9e;
1351 pub const CLIP_AUDIO: u32 = 0x2c6b49;
1352 pub const CLIP_IMAGE: u32 = 0x1c6270;
1353 pub const CLIP_TEXT: u32 = 0x5a45b8;
1354
1355 pub const SOURCE_TINTS: [u32; 12] = [
1356 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6, 0x8fc9e8, 0xe8c48f, 0x8fe8b4, 0xe88fd6,
1357 0x8fc9e8, 0xe8c48f, 0x8fe8b4,
1358 ];
1359
1360 // -- feedback ---------------------------------------------------------------
1361 pub const STATUS_ERROR: u32 = 0xf87171;
1362 pub const STATUS_WARNING: u32 = 0xfb923c;
1363 pub const STATUS_SUCCESS: u32 = 0x4ade80;
1364 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
1365 pub const DROP_REFUSE: u32 = 0x8f2740;
1366
1367 // -- subtitles --------------------------------------------------------------
1368 pub const SUB_FG: u32 = 0xffffff;
1369 pub const SUB_SHADE: u32 = 0x000000cc;
1370
1371 // -- the equalizer graph and the histogram ----------------------------------
1372 pub const EQ_GRID: u32 = 0x33203f;
1373 pub const EQ_SPECTRUM_INK: u32 = 0xc7b0cf66;
1374 pub const EQ_FILL_INK: u32 = 0xd946ef26;
1375 pub const EQ_BELL_INK: u32 = 0xd946ef66;
1376 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
1377 // -- Darkroom token substrate: aliased onto this family's nearest role -----
1378 pub const INK1: u32 = FG_PRIMARY;
1379 pub const INK2: u32 = FG_SECONDARY;
1380 pub const INK3: u32 = 0xa99ab0;
1381 pub const INK4: u32 = FG_DISABLED;
1382 pub const DARK_CANVAS: u32 = BG_CANVAS;
1383 pub const DARK_PANEL: u32 = BG_PANEL;
1384 pub const DARK_RAISED: u32 = BG_RAISED;
1385 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
1386 pub const DARK_EDGE: u32 = INK3;
1387 pub const DARK_SEAM: u32 = SCRIM;
1388 pub const LAMP_WHITE: u32 = 0xffffff;
1389 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
1390 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
1391 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
1392 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
1393 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
1394}
1395
1396/// Family J: Nord, the arctic palette (arcticicestudio/nord, MIT) -- Polar
1397/// Night for the surfaces, Snow Storm for the ink, Frost for the accent, Aurora
1398/// for everything that has to mean something. Its own numbers wherever they
1399/// clear the floors: `nord0`..`nord3` are the panels verbatim, and the canvas
1400/// and the lane bed are taken one step below `nord0`, which the set does not
1401/// name, because a bed lighter than its panel stops reading as a hole.
1402///
1403/// The clip bodies and the dim ink are the adapted ones. Aurora is a *text*
1404/// palette: `nord14` green under white is 2.6:1, and this editor draws a name
1405/// and a waveform on every clip body, so the four kinds are those hues taken
1406/// down to where WCAG 1.4.3 holds.
1407pub mod nord {
1408 // -- surfaces ---------------------------------------------------------------
1409 pub const BG_CANVAS: u32 = 0x21262e;
1410 pub const BG_PANEL: u32 = 0x2e3440;
1411 pub const BG_RAISED: u32 = 0x3b4252;
1412 pub const BG_TIMELINE: u32 = 0x272c36;
1413 pub const BG_HOVER: u32 = 0x434c5e;
1414 pub const BG_HOVER_DIM: u32 = 0x353c4a;
1415 /// `nord10` is Nord's own picked row and carries the dim ink at 2.9:1, so
1416 /// the row is that blue taken down until 4.5:1 holds (WCAG 1.4.3).
1417 pub const BG_SELECTED: u32 = 0x2e4a6e;
1418 pub const SCRIM: u32 = 0x21262ecc;
1419 pub const SCRIM_LIGHT: u32 = 0x21262e55;
1420
1421 // -- strokes ----------------------------------------------------------------
1422 pub const STROKE_DIVIDER: u32 = 0x434c5e;
1423 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
1424
1425 // -- text -------------------------------------------------------------------
1426 pub const FG_PRIMARY: u32 = 0xeceff4;
1427 pub const FG_SECONDARY: u32 = 0xd8dee9;
1428 /// Lighter than `nord3`, which is a *surface* in Nord and only 2.6:1 on the
1429 /// raised one: dimmed text still has to be read (WCAG 1.4.11).
1430 pub const FG_DISABLED: u32 = 0x8a94a8;
1431
1432 // -- interaction ------------------------------------------------------------
1433 pub const ACCENT_PRIMARY: u32 = 0x88c0d0;
1434 pub const ACCENT_HOVER: u32 = 0x8fbcbb;
1435 /// `nord13`. Orange (`nord12`) is the obvious playhead and is 2.3:1 on a
1436 /// video clip -- the line has to be findable on every body it crosses.
1437 pub const ACCENT_PLAYHEAD: u32 = 0xebcb8b;
1438 pub const ACCENT_WASH: u32 = 0x88c0d0aa;
1439
1440 // -- clip kinds (Aurora, taken down to where a name is legible on it) -------
1441 pub const CLIP_VIDEO: u32 = 0x3b5f8a;
1442 pub const CLIP_AUDIO: u32 = 0x4d6b3f;
1443 pub const CLIP_IMAGE: u32 = 0x3f6a69;
1444 pub const CLIP_TEXT: u32 = 0x6b4a78;
1445
1446 /// Aurora and Frost at full strength: a swatch carries no text, so these are
1447 /// Nord's own numbers.
1448 pub const SOURCE_TINTS: [u32; 12] = [
1449 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0, 0xd08770, 0xa3be8c, 0xb48ead, 0x88c0d0,
1450 0xd08770, 0xa3be8c, 0xb48ead,
1451 ];
1452
1453 // -- feedback ---------------------------------------------------------------
1454 pub const STATUS_ERROR: u32 = 0xbf616a;
1455 pub const STATUS_WARNING: u32 = 0xd08770;
1456 pub const STATUS_SUCCESS: u32 = 0xa3be8c;
1457 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
1458 pub const DROP_REFUSE: u32 = 0x7a3038;
1459
1460 // -- subtitles --------------------------------------------------------------
1461 pub const SUB_FG: u32 = 0xffffff;
1462 pub const SUB_SHADE: u32 = 0x000000cc;
1463
1464 // -- the equalizer graph and the histogram ----------------------------------
1465 pub const EQ_GRID: u32 = 0x434c5e;
1466 pub const EQ_SPECTRUM_INK: u32 = 0xd8dee966;
1467 pub const EQ_FILL_INK: u32 = 0x88c0d026;
1468 pub const EQ_BELL_INK: u32 = 0x88c0d066;
1469 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
1470 // -- Darkroom token substrate: aliased onto this family's nearest role -----
1471 pub const INK1: u32 = FG_PRIMARY;
1472 pub const INK2: u32 = FG_SECONDARY;
1473 pub const INK3: u32 = 0xbfc5d0;
1474 pub const INK4: u32 = FG_DISABLED;
1475 pub const DARK_CANVAS: u32 = BG_CANVAS;
1476 pub const DARK_PANEL: u32 = BG_PANEL;
1477 pub const DARK_RAISED: u32 = BG_RAISED;
1478 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
1479 pub const DARK_EDGE: u32 = INK3;
1480 pub const DARK_SEAM: u32 = SCRIM;
1481 pub const LAMP_WHITE: u32 = 0xffffff;
1482 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
1483 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
1484 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
1485 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
1486 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
1487}
1488
1489/// Family K: Gruvbox dark (morhetz/gruvbox, MIT) -- the retro brown-grey ground
1490/// and the warm ink that made it, under its own orange. `bg0_h`, `bg0`, `bg1`
1491/// and `bg2` are the surfaces verbatim and `fg1`..`fg4` the ink; the clip bodies
1492/// are the neutral-mode hues taken down for the same reason Nord's are.
1493///
1494/// Two of its colours do two jobs here rather than one: orange is the accent
1495/// and green the playhead -- so the family is recognisable from the chrome and
1496/// not only from the ground.
1497pub mod gruvbox {
1498 // -- surfaces ---------------------------------------------------------------
1499 pub const BG_CANVAS: u32 = 0x1d2021;
1500 pub const BG_PANEL: u32 = 0x282828;
1501 pub const BG_RAISED: u32 = 0x3c3836;
1502 pub const BG_TIMELINE: u32 = 0x232323;
1503 pub const BG_HOVER: u32 = 0x504945;
1504 pub const BG_HOVER_DIM: u32 = 0x32302f;
1505 /// The orange taken to where `fg2` clears 4.5:1 on it -- `bg2`, gruvbox's
1506 /// own selection, is a grey and says nothing about which row is picked.
1507 pub const BG_SELECTED: u32 = 0x7c3f12;
1508 pub const SCRIM: u32 = 0x1d2021cc;
1509 pub const SCRIM_LIGHT: u32 = 0x1d202155;
1510
1511 // -- strokes ----------------------------------------------------------------
1512 pub const STROKE_DIVIDER: u32 = 0x504945;
1513 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
1514
1515 // -- text -------------------------------------------------------------------
1516 pub const FG_PRIMARY: u32 = 0xebdbb2;
1517 pub const FG_SECONDARY: u32 = 0xd5c4a1;
1518 pub const FG_DISABLED: u32 = 0xa89984;
1519
1520 // -- interaction ------------------------------------------------------------
1521 pub const ACCENT_PRIMARY: u32 = 0xfe8019;
1522 pub const ACCENT_HOVER: u32 = 0xfabd2f;
1523 /// Bright green: it is the one gruvbox hue that clears 3:1 on all four clip
1524 /// bodies at once, which is what a line crossing every one of them owes.
1525 pub const ACCENT_PLAYHEAD: u32 = 0xb8bb26;
1526 pub const ACCENT_WASH: u32 = 0xfe8019aa;
1527
1528 // -- clip kinds -------------------------------------------------------------
1529 pub const CLIP_VIDEO: u32 = 0x35657e;
1530 pub const CLIP_AUDIO: u32 = 0x4b661c;
1531 pub const CLIP_IMAGE: u32 = 0x2f6a63;
1532 pub const CLIP_TEXT: u32 = 0x7a4a72;
1533
1534 pub const SOURCE_TINTS: [u32; 12] = [
1535 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019, 0x83a598, 0xb8bb26, 0xd3869b, 0xfe8019,
1536 0x83a598, 0xb8bb26, 0xd3869b,
1537 ];
1538
1539 // -- feedback ---------------------------------------------------------------
1540 pub const STATUS_ERROR: u32 = 0xfb4934;
1541 pub const STATUS_WARNING: u32 = 0xfabd2f;
1542 pub const STATUS_SUCCESS: u32 = 0x8ec07c;
1543 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
1544 pub const DROP_REFUSE: u32 = 0x9d0006;
1545
1546 // -- subtitles --------------------------------------------------------------
1547 pub const SUB_FG: u32 = 0xffffff;
1548 pub const SUB_SHADE: u32 = 0x000000cc;
1549
1550 // -- the equalizer graph and the histogram ----------------------------------
1551 pub const EQ_GRID: u32 = 0x504945;
1552 pub const EQ_SPECTRUM_INK: u32 = 0xd5c4a166;
1553 pub const EQ_FILL_INK: u32 = 0xfe801926;
1554 pub const EQ_BELL_INK: u32 = 0xfe801966;
1555 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
1556 // -- Darkroom token substrate: aliased onto this family's nearest role -----
1557 pub const INK1: u32 = FG_PRIMARY;
1558 pub const INK2: u32 = FG_SECONDARY;
1559 pub const INK3: u32 = 0xbaaf9e;
1560 pub const INK4: u32 = FG_DISABLED;
1561 pub const DARK_CANVAS: u32 = BG_CANVAS;
1562 pub const DARK_PANEL: u32 = BG_PANEL;
1563 pub const DARK_RAISED: u32 = BG_RAISED;
1564 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
1565 pub const DARK_EDGE: u32 = INK3;
1566 pub const DARK_SEAM: u32 = SCRIM;
1567 pub const LAMP_WHITE: u32 = 0xffffff;
1568 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
1569 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
1570 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
1571 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
1572 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
1573}
1574
1575/// Family L: Dracula (dracula/dracula-theme, MIT) -- its background, current
1576/// line and foreground verbatim, and its pink for the accent rather than the
1577/// purple, which `violet` already sits on. Comment (`#6272a4`) is Dracula's dim
1578/// ink and measures 2.4:1 on the raised surface, so the dim ink here is lifted
1579/// and the comment blue is what a *disabled* control wears.
1580pub mod dracula {
1581 // -- surfaces ---------------------------------------------------------------
1582 pub const BG_CANVAS: u32 = 0x1e1f29;
1583 pub const BG_PANEL: u32 = 0x282a36;
1584 pub const BG_RAISED: u32 = 0x343746;
1585 pub const BG_TIMELINE: u32 = 0x22232e;
1586 pub const BG_HOVER: u32 = 0x44475a;
1587 pub const BG_HOVER_DIM: u32 = 0x2f3141;
1588 pub const BG_SELECTED: u32 = 0x6b2a70;
1589 pub const SCRIM: u32 = 0x1e1f29cc;
1590 pub const SCRIM_LIGHT: u32 = 0x1e1f2955;
1591
1592 // -- strokes ----------------------------------------------------------------
1593 pub const STROKE_DIVIDER: u32 = 0x44475a;
1594 pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY;
1595
1596 // -- text -------------------------------------------------------------------
1597 pub const FG_PRIMARY: u32 = 0xf8f8f2;
1598 pub const FG_SECONDARY: u32 = 0xc3c5d8;
1599 pub const FG_DISABLED: u32 = 0x7b8bc4;
1600
1601 // -- interaction ------------------------------------------------------------
1602 pub const ACCENT_PRIMARY: u32 = 0xff79c6;
1603 pub const ACCENT_HOVER: u32 = 0xff92d0;
1604 pub const ACCENT_PLAYHEAD: u32 = 0xf1fa8c;
1605 pub const ACCENT_WASH: u32 = 0xff79c6aa;
1606
1607 // -- clip kinds -------------------------------------------------------------
1608 pub const CLIP_VIDEO: u32 = 0x3f5aa6;
1609 pub const CLIP_AUDIO: u32 = 0x2f7a48;
1610 pub const CLIP_IMAGE: u32 = 0x2b6e78;
1611 pub const CLIP_TEXT: u32 = 0x6a3fb0;
1612
1613 /// Dracula's own six, four of them: a swatch carries no text.
1614 pub const SOURCE_TINTS: [u32; 12] = [
1615 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6, 0x8be9fd, 0x50fa7b, 0xffb86c, 0xff79c6,
1616 0x8be9fd, 0x50fa7b, 0xffb86c,
1617 ];
1618
1619 // -- feedback ---------------------------------------------------------------
1620 pub const STATUS_ERROR: u32 = 0xff5555;
1621 pub const STATUS_WARNING: u32 = 0xffb86c;
1622 pub const STATUS_SUCCESS: u32 = 0x50fa7b;
1623 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
1624 pub const DROP_REFUSE: u32 = 0x8f2a3a;
1625
1626 // -- subtitles --------------------------------------------------------------
1627 pub const SUB_FG: u32 = 0xffffff;
1628 pub const SUB_SHADE: u32 = 0x000000cc;
1629
1630 // -- the equalizer graph and the histogram ----------------------------------
1631 pub const EQ_GRID: u32 = 0x44475a;
1632 pub const EQ_SPECTRUM_INK: u32 = 0xc3c5d866;
1633 pub const EQ_FILL_INK: u32 = 0xff79c626;
1634 pub const EQ_BELL_INK: u32 = 0xff79c666;
1635 pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0];
1636 // -- Darkroom token substrate: aliased onto this family's nearest role -----
1637 pub const INK1: u32 = FG_PRIMARY;
1638 pub const INK2: u32 = FG_SECONDARY;
1639 pub const INK3: u32 = 0xa6b0d7;
1640 pub const INK4: u32 = FG_DISABLED;
1641 pub const DARK_CANVAS: u32 = BG_CANVAS;
1642 pub const DARK_PANEL: u32 = BG_PANEL;
1643 pub const DARK_RAISED: u32 = BG_RAISED;
1644 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
1645 pub const DARK_EDGE: u32 = INK3;
1646 pub const DARK_SEAM: u32 = SCRIM;
1647 pub const LAMP_WHITE: u32 = 0xffffff;
1648 pub const NOTICE_TELL: u32 = STATUS_SUCCESS;
1649 pub const NOTICE_LOOK: u32 = STATUS_WARNING;
1650 pub const NOTICE_DECIDE: u32 = STATUS_ERROR;
1651 pub const SAFELIGHT_GROUND: u32 = BG_CANVAS;
1652 pub const SAFELIGHT_GLYPH: u32 = ACCENT_PRIMARY;
1653}
1654
1655/// Family M: Darkroom (DESIGN.md §2) -- the thirteenth family and the room the
1656/// redesign is named after. Chrome is achromatic: every pre-existing role below
1657/// is a grey, distinguished by luminance rather than hue ("loudness is
1658/// luminance"); the only colour anywhere in this family sits on the roles
1659/// DESIGN.md actually gives one -- the amber safelight glyph and the two loud
1660/// notice tones. Everything else is the token substrate itself, taken verbatim
1661/// from the spec table.
1662pub mod darkroom {
1663 // -- surfaces -----------------------------------------------------------
1664 pub const BG_CANVAS: u32 = 0x0b0c0e;
1665 pub const BG_PANEL: u32 = 0x131518;
1666 // DESIGN §2.1's `raised` (#1B1E22) and `hover` (#24282D) are the interaction
1667 // ladder in this room: a resting raised fill, one step up for hover.
1668 // Selection's real mark is the 1px `ink1` ring (§4), never a pale flood.
1669 //
1670 // These four used to carry the legacy tree's greys (hover #2A2E33,
1671 // selected #2E3237 -- two and three steps outside the band). Every
1672 // surface that paints a *role* rather than a Darkroom token -- the clip
1673 // menu, the library row menu, the keys overlay, the seven param cards --
1674 // read them, so each one opened a pale plate in a dim room while the
1675 // handful of surfaces written against `DARK_*`/`INK*` directly looked
1676 // right. That is the whole "some menus belong to old ui" class, and it
1677 // is fixed here, once, rather than by another per-call-site `if
1678 // darkroom` branch: role tokens ARE the theme's job (§2's guard).
1679 pub const BG_RAISED: u32 = 0x1b1e22;
1680 pub const BG_TIMELINE: u32 = 0x08090b;
1681 pub const BG_HOVER: u32 = 0x24282d;
1682 pub const BG_HOVER_DIM: u32 = 0x121418;
1683 pub const BG_SELECTED: u32 = 0x1c1f24;
1684 pub const SCRIM: u32 = 0x050607cc;
1685 pub const SCRIM_LIGHT: u32 = 0x05060755;
1686
1687 // -- strokes --------------------------------------------------------------
1688 pub const STROKE_DIVIDER: u32 = 0x2a2e34;
1689 /// "Focus/selection ring = 1px ink1 (lamp-adjacent, not coloured)."
1690 pub const STROKE_SELECTED: u32 = INK1;
1691
1692 // -- text -------------------------------------------------------------------
1693 pub const FG_PRIMARY: u32 = INK1;
1694 pub const FG_SECONDARY: u32 = INK2;
1695 pub const FG_DISABLED: u32 = INK4;
1696
1697 // -- interaction --------------------------------------------------------
1698 pub const ACCENT_PRIMARY: u32 = INK2;
1699 pub const ACCENT_HOVER: u32 = INK1;
1700 pub const ACCENT_PLAYHEAD: u32 = LAMP_WHITE;
1701 pub const ACCENT_WASH: u32 = 0xb4bac155;
1702
1703 // -- clip kinds (luminance steps, no hue -- held under the grey that still
1704 // carries FG_SECONDARY at 3:1, WCAG 1.4.11) -------------------------------
1705 pub const CLIP_VIDEO: u32 = 0x343434;
1706 pub const CLIP_AUDIO: u32 = 0x3d3d3d;
1707 pub const CLIP_IMAGE: u32 = 0x464646;
1708 pub const CLIP_TEXT: u32 = 0x4f4f4f;
1709
1710 // DESIGN §2 reference extraction, S/L clamped into the WCAG band and
1711 // walked around the wheel at 12 stops (30° apart) so the cap in the same
1712 // paragraph has one real value per hue rather than four greys repeated:
1713 // azure #64B5D1, magenta #D164B5, green #64D19A, violet #7F64D1, teal
1714 // #64D1D1 sit at indices 0, 4, 9(~), 2(~), 5(~) of this wheel.
1715 // hook: §12 step 5 -- real per-source extraction replaces this constant
1716 // wheel with a quantized dominant hue per import; until then the index
1717 // is `source % 12`, which still guarantees different sources differ.
1718 pub const SOURCE_TINTS: [u32; 12] = [
1719 0x64b5d1, 0x647ed1, 0x8064d1, 0xb664d1, 0xd164b5, 0xd1647e, 0xd18064, 0xd1b764, 0xb5d164,
1720 0x7ed164, 0x64d180, 0x64d1b7,
1721 ];
1722
1723 // -- feedback -------------------------------------------------------------
1724 pub const STATUS_ERROR: u32 = NOTICE_DECIDE;
1725 pub const STATUS_WARNING: u32 = NOTICE_LOOK;
1726 pub const STATUS_SUCCESS: u32 = INK1;
1727 pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY;
1728 pub const DROP_REFUSE: u32 = NOTICE_DECIDE;
1729
1730 // -- subtitles --------------------------------------------------------------
1731 pub const SUB_FG: u32 = LAMP_WHITE;
1732 pub const SUB_SHADE: u32 = 0x000000cc;
1733
1734 // -- the equalizer graph and the histogram -------------------------------
1735 pub const EQ_GRID: u32 = 0x22262b;
1736 pub const EQ_SPECTRUM_INK: u32 = 0xb4bac166;
1737 pub const EQ_FILL_INK: u32 = 0xb4bac126;
1738 pub const EQ_BELL_INK: u32 = 0xb4bac166;
1739 pub const HIST_INK: [u32; 3] = [0x767e87, 0x9ba3ac, 0xc7cdd3];
1740
1741 // -- Darkroom token substrate (DESIGN.md §2, verbatim) -----------------------
1742 pub const INK1: u32 = 0xe8eaed;
1743 pub const INK2: u32 = 0xb4bac1;
1744 pub const INK3: u32 = 0x8d959e;
1745 pub const INK4: u32 = 0x777f88;
1746 pub const DARK_CANVAS: u32 = BG_CANVAS;
1747 pub const DARK_PANEL: u32 = BG_PANEL;
1748 pub const DARK_RAISED: u32 = BG_RAISED;
1749 pub const DARK_HAIRLINE: u32 = STROKE_DIVIDER;
1750 /// The boundary of a control that has to be recognised as one (WCAG 1.4.11,
1751 /// 3:1 on every surface); `DARK_HAIRLINE` stays for dividers, which need not be.
1752 pub const DARK_EDGE: u32 = 0x6e757d;
1753 /// Seam: `rgba(0,0,0,.7)`, encoded the way `SCRIM`/`SCRIM_LIGHT` are --
1754 /// `0xRRGGBBAA` -- so `0xb3` (179/255 ~= 0.702) is the closest byte to 70%.
1755 pub const DARK_SEAM: u32 = 0x000000b3;
1756 pub const LAMP_WHITE: u32 = 0xffffff;
1757 pub const NOTICE_TELL: u32 = 0x5e656d;
1758 pub const NOTICE_LOOK: u32 = 0xd1b564;
1759 pub const NOTICE_DECIDE: u32 = 0xe07a7a;
1760 pub const SAFELIGHT_GROUND: u32 = 0x0a0908;
1761 pub const SAFELIGHT_GLYPH: u32 = 0xff9d57;
1762}
1763
1764// -- REDESIGN §1.3 tokens -----------------------------------------------------
1765//
1766// The elevation ladder, the ink and accent roles and the clip-type colours the
1767// redesigned regions paint by. They sit beside the legacy `palette!` roles
1768// rather than inside them: `darkroom` carries the spec's hard values, and the
1769// twelve other families get the same roles *derived* from the roles they
1770// already have ([`derive`]), so a thirteenth family still costs one module.
1771//
1772// Colour encoding is the theme's: `0xRRGGBB`, or `0xRRGGBBAA` for the few
1773// alpha roles (`line`, `line_hi`, `accent_wash`) which only ever go to `rgba()`.
1774
1775/// What kind of media a clip is. Colour is never the only cue: every kind has
1776/// a 16px icon too (`ui::icons`).
1777#[derive(Clone, Copy, PartialEq, Eq, Debug)]
1778pub enum ClipKind {
1779 Video,
1780 Image,
1781 Audio,
1782 /// Title and caption-generator clips.
1783 Title,
1784 /// Subtitle cues.
1785 Caption,
1786 /// A nested sequence.
1787 Compound,
1788 Multicam,
1789}
1790
1791impl ClipKind {
1792 pub const ALL: [ClipKind; 7] = [
1793 ClipKind::Video,
1794 ClipKind::Image,
1795 ClipKind::Audio,
1796 ClipKind::Title,
1797 ClipKind::Caption,
1798 ClipKind::Compound,
1799 ClipKind::Multicam,
1800 ];
1801}
1802
1803/// One clip kind's colours (§1.3): `strip` is the name strip and the lane
1804/// head dot, `body` shows behind transparent areas, `ink` tints waveforms and glyphs.
1805#[derive(Clone, Copy, PartialEq, Debug)]
1806pub struct ClipTone {
1807 pub strip: u32,
1808 pub body: u32,
1809 pub ink: u32,
1810 /// The name text on the strip: `ink1`, white or `e0`, whichever reads best on
1811 /// `strip` (the amber and grey strips need dark text).
1812 pub label: u32,
1813}
1814
1815/// The §1.3 role table of one family. Read it with [`tokens`].
1816#[derive(Clone, Copy, PartialEq, Debug)]
1817pub struct Tokens {
1818 /// Window, seams between regions, menu bar.
1819 pub e0: u32,
1820 /// Panels: dock body, lane heads, transport, toolbar, status bar.
1821 pub e1: u32,
1822 /// Raised: cards, fields, buttons at rest.
1823 pub e2: u32,
1824 /// Hover fill, popup plate, selected segment.
1825 pub e3: u32,
1826 /// Pressed fill.
1827 pub e4: u32,
1828 /// The timeline's lane area, recessed.
1829 pub well: u32,
1830 /// The viewer surround.
1831 pub matte: u32,
1832 /// Hairline inside a surface (`0xRRGGBBAA`).
1833 pub line: u32,
1834 /// The popup plate's border (`0xRRGGBBAA`).
1835 pub line_hi: u32,
1836 /// Boxes that must pass 3:1 and the focus-ring fallback.
1837 pub edge: u32,
1838 pub ink1: u32,
1839 pub ink2: u32,
1840 pub ink3: u32,
1841 /// Disabled only, never information.
1842 pub ink4: u32,
1843 pub accent: u32,
1844 pub accent_hover: u32,
1845 pub accent_press: u32,
1846 /// Primary button fill (the accent itself); `on_accent` sits on it.
1847 pub accent_fill: u32,
1848 /// The label and glyph on a filled accent: a near-black tint of its hue.
1849 pub on_accent: u32,
1850 /// Selected row / drop target (`0xRRGGBBAA`).
1851 pub accent_wash: u32,
1852 /// The In-Out range's tint across the lanes (`0xRRGGBBAA`): subtle, never hides a clip.
1853 pub range_tint: u32,
1854 pub err: u32,
1855 pub warn: u32,
1856 pub ok: u32,
1857 /// Clip colours by kind, in [`ClipKind::ALL`] order.
1858 pub clip: [ClipTone; 7],
1859}
1860
1861impl Tokens {
1862 pub fn clip(&self, kind: ClipKind) -> ClipTone {
1863 self.clip[kind as usize]
1864 }
1865}
1866
1867/// WCAG 2.x contrast ratio of two `0xRRGGBB` colours.
1868pub fn contrast(a: u32, b: u32) -> f64 {
1869 let lum = |hex: u32| {
1870 let lin = |shift: u32| {
1871 let c = f64::from((hex >> shift) & 0xff) / 255.;
1872 if c <= 0.03928 { c / 12.92 } else { ((c + 0.055) / 1.055).powf(2.4) }
1873 };
1874 0.2126 * lin(16) + 0.7152 * lin(8) + 0.0722 * lin(0)
1875 };
1876 let (a, b) = (lum(a), lum(b));
1877 (a.max(b) + 0.05) / (a.min(b) + 0.05)
1878}
1879
1880/// Linear mix of two `0xRRGGBB` colours, `t` of the way from `a` to `b`.
1881pub fn mix(a: u32, b: u32, t: f32) -> u32 {
1882 let ch = |s: u32| {
1883 let (x, y) = (((a >> s) & 0xff) as f32, ((b >> s) & 0xff) as f32);
1884 ((x + (y - x) * t).round() as u32).min(255) << s
1885 };
1886 ch(16) | ch(8) | ch(0)
1887}
1888
1889/// `0xRRGGBB` with an alpha byte: the `0xRRGGBBAA` the alpha roles use.
1890pub const fn with_alpha(rgb: u32, alpha: u8) -> u32 {
1891 ((rgb & 0xffffff) << 8) | alpha as u32
1892}
1893
1894const fn tone(strip: u32, body: u32, ink: u32) -> ClipTone {
1895 ClipTone { strip, body, ink, label: 0 }
1896}
1897
1898/// Darkroom's hard values, straight from REDESIGN §1.3.
1899const DARKROOM_TOKENS: Tokens = Tokens {
1900 e0: 0x0f0f11,
1901 e1: 0x17171a,
1902 e2: 0x202024,
1903 e3: 0x2a2a2f,
1904 e4: 0x35353b,
1905 well: 0x0c0c0e,
1906 matte: 0x08080a,
1907 line: 0xffffff12,
1908 line_hi: 0xffffff14,
1909 edge: 0x6e757d,
1910 ink1: 0xececef,
1911 ink2: 0xa9a9b2,
1912 ink3: 0x85858f,
1913 ink4: 0x5a5a63,
1914 accent: 0x9dbea2,
1915 accent_hover: 0xb5d2b9,
1916 accent_press: 0x86a18a,
1917 accent_fill: 0x9dbea2,
1918 on_accent: 0x0f1510,
1919 accent_wash: 0x9dbea233,
1920 range_tint: 0x9dbea21a,
1921 err: 0xf0707a,
1922 warn: 0xe2b860,
1923 ok: 0x5acb8e,
1924 clip: [
1925 tone(0x2f5f9e, 0x1c3350, 0xffffff),
1926 tone(0x2b8080, 0x183b3c, 0xffffff),
1927 tone(0x2e8b5e, 0x17291f, 0x6fd6a0),
1928 tone(0x7b5cc4, 0x2b2248, 0xc3b0f5),
1929 tone(0xb98a2e, 0x33280f, 0xf0cc82),
1930 tone(0x8b8f99, 0x25272c, 0xc9ccd4),
1931 tone(0xc25b8a, 0x3a1b2b, 0xf1a8c6),
1932 ],
1933};
1934
1935/// The twelve legacy families' §1.3 roles, from the roles they already carry:
1936/// the four backgrounds are the ladder's first four steps, pressed is hover
1937/// lifted towards `ink1`, the accent roles come from their accent, and the
1938/// clip kinds from their `CLIP_*` bodies (kinds the family has no role for
1939/// borrow the notice / ink / source-tint hues).
1940fn derive(p: &Palette) -> Tokens {
1941 let kind = |strip: u32, ink: u32| tone(strip, mix(strip, p.BG_CANVAS, 0.55), ink);
1942 let lift = |c: u32| mix(c, 0xffffff, 0.55);
1943 Tokens {
1944 e0: p.BG_CANVAS,
1945 e1: p.BG_PANEL,
1946 e2: p.BG_RAISED,
1947 e3: p.BG_HOVER,
1948 e4: mix(p.BG_HOVER, p.INK1, 0.08),
1949 well: p.BG_TIMELINE,
1950 matte: mix(p.BG_CANVAS, 0x000000, 0.35),
1951 line: 0xffffff12,
1952 line_hi: 0xffffff14,
1953 edge: p.DARK_EDGE,
1954 ink1: p.INK1,
1955 ink2: p.INK2,
1956 ink3: p.INK3,
1957 ink4: p.INK4,
1958 accent: p.ACCENT_PRIMARY,
1959 accent_hover: p.ACCENT_HOVER,
1960 accent_press: mix(p.ACCENT_PRIMARY, 0x000000, 0.2),
1961 accent_fill: p.ACCENT_PRIMARY,
1962 on_accent: 0x0f1510,
1963 accent_wash: with_alpha(p.ACCENT_PRIMARY, 0x33),
1964 range_tint: with_alpha(p.ACCENT_PRIMARY, 0x1a),
1965 err: p.STATUS_ERROR,
1966 warn: p.STATUS_WARNING,
1967 ok: p.STATUS_SUCCESS,
1968 clip: [
1969 kind(p.CLIP_VIDEO, 0xffffff),
1970 kind(p.CLIP_IMAGE, 0xffffff),
1971 kind(p.CLIP_AUDIO, lift(p.CLIP_AUDIO)),
1972 kind(p.CLIP_TEXT, lift(p.CLIP_TEXT)),
1973 kind(p.NOTICE_LOOK, lift(p.NOTICE_LOOK)),
1974 kind(p.INK3, lift(p.INK3)),
1975 kind(p.SOURCE_TINTS[4], lift(p.SOURCE_TINTS[4])),
1976 ],
1977 }
1978}
1979
1980/// Fills each clip tone's `label` with the better of `ink1` and `e0` on its strip.
1981fn with_labels(mut t: Tokens) -> Tokens {
1982 for tone in &mut t.clip {
1983 tone.label = [t.ink1, 0xffffff, t.e0]
1984 .into_iter()
1985 .max_by(|a, b| contrast(*a, tone.strip).total_cmp(&contrast(*b, tone.strip)))
1986 .unwrap_or(t.ink1);
1987 }
1988 t
1989}
1990
1991/// The §1.3 roles of the family in force: one relaxed load and one index, like
1992/// the legacy tokens. Darkroom is hard-coded; the others are [`derive`]d once.
1993pub fn tokens() -> &'static Tokens {
1994 // The slice is `'static` (leaked, one per accent setting ever shown), so the
1995 // lock is held for the pointer copy only.
1996 let load = || *LIVE.read().unwrap_or_else(|e| e.into_inner());
1997 let mut all = load();
1998 if all.is_empty() {
1999 refresh();
2000 all = load();
2001 }
2002 all.get(ACTIVE.load(Relaxed)).unwrap_or(&all[PaletteId::DEFAULT as usize])
2003}
2004
2005/// The roles of every family under the accent in force.
2006static LIVE: RwLock<&'static [Tokens]> = RwLock::new(&[]);
2007
2008/// Every family's roles before any accent is laid on them, once.
2009fn bases() -> &'static [Tokens] {
2010 static BASES: std::sync::OnceLock<Vec<Tokens>> = std::sync::OnceLock::new();
2011 BASES.get_or_init(|| PaletteId::ALL.iter().map(|&id| base_tokens(id)).collect())
2012}
2013
2014fn base_tokens(id: PaletteId) -> Tokens {
2015 match id {
2016 PaletteId::Darkroom => with_labels(DARKROOM_TOKENS),
2017 _ => with_labels(derive(&PALETTES[id as usize])),
2018 }
2019}
2020
2021/// Swaps in the tables of the accent now in force. A table is leaked once per
2022/// distinct setting; a slider drag visits a few dozen of them.
2023fn refresh() {
2024 static SEEN: Mutex<Vec<(AccentSpec, &'static [Tokens])>> = Mutex::new(Vec::new());
2025 let spec = spec_in_force();
2026 let Ok(mut seen) = SEEN.lock() else { return };
2027 let table = match seen.iter().find(|(s, _)| *s == spec) {
2028 Some((_, t)) => *t,
2029 None => {
2030 let t: &'static [Tokens] = Box::leak(bases().iter().map(|b| spec.apply(*b)).collect());
2031 seen.push((spec, t));
2032 t
2033 }
2034 };
2035 *LIVE.write().unwrap_or_else(|e| e.into_inner()) = table;
2036}
2037
2038/// The roles of family `id` under `accent`.
2039#[cfg(test)]
2040fn tokens_with(id: PaletteId, accent: AccentSpec) -> Tokens {
2041 accent.apply(base_tokens(id))
2042}
2043
2044/// [`tokens`] of a family that is not the one in force (the guards).
2045#[cfg(test)]
2046pub fn tokens_of(id: PaletteId) -> Tokens {
2047 tokens_with(id, AccentSpec::DEFAULT)
2048}
2049
2050/// White washes (`0xRRGGBBAA`, `rgba()` only) laid over a transparent rest
2051/// fill for hover and press (§1.5): 6%, 10%, and the 4% a list row uses.
2052pub const WASH_HOVER: u32 = 0xffffff0f;
2053pub const WASH_PRESS: u32 = 0xffffff1a;
2054#[allow(dead_code, reason = "media rows adopt it in P4")]
2055pub const WASH_ROW: u32 = 0xffffff0a;
2056
2057/// The popup plate's shadow colour (`0xRRGGBBAA`): `0 8 24 rgba(0,0,0,.5)`.
2058pub const PLATE_SHADOW: u32 = 0x00000080;
2059
2060/// The box a button's glyph sits in, whatever the glyph happens to measure: the
2061/// pause bars are 12 px wide and the play triangle 11, and a button that resized
2062/// itself when it was pressed moved every button to its right.
2063pub const GLYPH_SLOT: f32 = 14.;
2064
2065/// How solid the shadow a drag draws is (`0xRRGGBBAA`): enough to read as a box,
2066/// little enough that the clip under it is still legible. Not a colour, so both
2067/// families share it.
2068pub const GHOST_ALPHA: u32 = 0x66;
2069
2070// -- geometry the four regions are laid out on --------------------------------
2071/// Compact density: 11-13 px text, 28 px controls, 8 px gutters. The floor the
2072/// whole window is measured at is 640x360, and airy spacing loses a region.
2073pub const INSPECTOR_MIN_W: f32 = 208.;
2074pub const INSPECTOR_MAX_W: f32 = 320.;
2075pub const INSPECTOR_FRAC: f32 = 0.24;
2076
2077/// The colour a comment marker is drawn in. The palette is the marker's own, fixed
2078/// (red, orange, yellow, green, blue, purple), and is not one of the window's themes:
2079/// a marker's colour is data saved with the project, so it reads the same under every
2080/// theme.
2081pub fn marker_rgb(color: engine::project::MarkerColor) -> u32 {
2082 use engine::project::MarkerColor;
2083 match color {
2084 MarkerColor::Red => 0xe5484d,
2085 MarkerColor::Orange => 0xf76b15,
2086 MarkerColor::Yellow => 0xf5d90a,
2087 MarkerColor::Green => 0x46a758,
2088 MarkerColor::Blue => 0x3e8fe0,
2089 MarkerColor::Purple => 0x8e4ec6,
2090 }
2091}
2092
2093/// The inspector's width at this window width, on the library's own rule: a
2094/// share of the window, clamped so the picture keeps the middle at every size.
2095pub fn inspector_w(window_w: f32) -> f32 {
2096 (window_w * INSPECTOR_FRAC).clamp(INSPECTOR_MIN_W, INSPECTOR_MAX_W)
2097}
2098
2099#[cfg(test)]
2100mod tests {
2101 use super::darkroom as d;
2102
2103 /// WCAG 2.x relative luminance of an `0xRRGGBB`.
2104 fn luminance(hex: u32) -> f64 {
2105 let lin = |shift: u32| {
2106 let c = f64::from((hex >> shift) & 0xff) / 255.;
2107 if c <= 0.03928 {
2108 c / 12.92
2109 } else {
2110 ((c + 0.055) / 1.055).powf(2.4)
2111 }
2112 };
2113 0.2126 * lin(16) + 0.7152 * lin(8) + 0.0722 * lin(0)
2114 }
2115
2116 fn ratio(a: u32, b: u32) -> f64 {
2117 let (a, b) = (luminance(a), luminance(b));
2118 (a.max(b) + 0.05) / (a.min(b) + 0.05)
2119 }
2120
2121 const SURFACES: [(&str, u32); 4] = [
2122 ("canvas", d::BG_CANVAS),
2123 ("panel", d::BG_PANEL),
2124 ("raised", d::BG_RAISED),
2125 ("hover", d::BG_HOVER),
2126 ];
2127
2128 /// DESIGN §2.1 / §4.1: every (ink, floor) pair on every surface it can sit on.
2129 #[test]
2130 fn darkroom_token_pairs_meet_their_contrast_spec() {
2131 let specs: [(&str, u32, f64); 6] = [
2132 ("ink1", d::INK1, 4.5),
2133 ("ink2", d::INK2, 4.5),
2134 ("ink3", d::INK3, 4.5),
2135 ("err", d::NOTICE_DECIDE, 4.5),
2136 // Disabled: spec'd 3.6 (WCAG exempts it; below ink3 keeps it distinct).
2137 ("ink4 (disabled)", d::INK4, 3.6),
2138 // WCAG 1.4.11 control boundary.
2139 ("edge", d::DARK_EDGE, 3.0),
2140 ];
2141 for (name, fg, floor) in specs {
2142 for (surface, bg) in SURFACES {
2143 let r = ratio(fg, bg);
2144 assert!(r >= floor, "{name} on {surface}: {r:.2} < {floor}");
2145 }
2146 }
2147 // The focus ring and the playhead are ink1/lamp: they must clear 3:1 too.
2148 for (surface, bg) in SURFACES {
2149 assert!(ratio(d::STROKE_SELECTED, bg) >= 3.0, "focus ring on {surface}");
2150 assert!(ratio(d::LAMP_WHITE, bg) >= 3.0, "playhead on {surface}");
2151 }
2152 // The dividers are decorative: the hairline stays below the control edge.
2153 assert!(ratio(d::DARK_EDGE, d::BG_PANEL) > ratio(d::DARK_HAIRLINE, d::BG_PANEL));
2154 }
2155
2156 /// REDESIGN §1.3: the new token pairs. Ink on the surfaces it sits on,
2157 /// the accent as a focus ring, white on the primary fill, the status hues.
2158 #[test]
2159 fn darkroom_tokens_meet_the_redesign_spec() {
2160 let t = super::tokens_of(super::PaletteId::Darkroom);
2161 for (name, bg) in [("e0", t.e0), ("e1", t.e1), ("e2", t.e2), ("e3", t.e3), ("e4", t.e4)] {
2162 assert!(ratio(t.ink1, bg) >= 7.0, "ink1 on {name}");
2163 }
2164 for (name, bg) in [("e0", t.e0), ("e1", t.e1), ("e2", t.e2), ("e3", t.e3)] {
2165 assert!(ratio(t.ink2, bg) >= 4.5, "ink2 on {name}");
2166 }
2167 // ink3 carries keys and units on panels; it is not asked to sit on a popup plate at 4.5.
2168 for (name, bg) in [("e0", t.e0), ("e1", t.e1)] {
2169 assert!(ratio(t.ink3, bg) >= 4.5, "ink3 on {name}");
2170 }
2171 for (name, bg) in [("e0", t.e0), ("e1", t.e1), ("e2", t.e2)] {
2172 assert!(ratio(t.accent, bg) >= 3.0, "focus ring on {name}");
2173 for (c, hue) in [("err", t.err), ("warn", t.warn), ("ok", t.ok)] {
2174 assert!(ratio(hue, bg) >= 4.5, "{c} on {name}");
2175 }
2176 }
2177 assert!(ratio(t.on_accent, t.accent_fill) >= 4.5, "label on the primary fill");
2178 // Disabled stays distinct from information.
2179 assert!(ratio(t.ink4, t.e1) < ratio(t.ink3, t.e1));
2180 // The ladder rises and the well sits below every panel.
2181 let l = |c| luminance(c);
2182 assert!(l(t.matte) < l(t.well) && l(t.well) < l(t.e0) && l(t.e0) < l(t.e1));
2183 assert!(l(t.e1) < l(t.e2) && l(t.e2) < l(t.e3) && l(t.e3) < l(t.e4));
2184 // Clip strips carry white-ish labels at 4.5; waveform ink reads on its body.
2185 for kind in super::ClipKind::ALL {
2186 let c = t.clip(kind);
2187 // §1.3's audio green tops out at ~4.3:1 for a 12px/500 name; 4.0 is the floor here.
2188 assert!(ratio(c.label, c.strip) >= 4.0, "{kind:?} name on strip");
2189 assert!(ratio(c.ink, c.body) >= 4.5, "{kind:?} ink on body");
2190 }
2191 }
2192
2193 use super::{AccentId, AccentSpec};
2194
2195 fn spec(id: AccentId, vivid: u8, custom: u32) -> AccentSpec {
2196 AccentSpec { id, vivid, custom }
2197 }
2198
2199 /// The six presets as designed (Vivid 50), on every family: ring on the surfaces, label on the
2200 /// fill and on its press.
2201 #[test]
2202 fn every_preset_meets_contrast_on_every_family() {
2203 for id in super::PaletteId::ALL {
2204 for a in super::AccentId::ALL.into_iter().filter(|a| *a != AccentId::Custom) {
2205 let t = super::tokens_with(id, spec(a, 50, super::CUSTOM_DEFAULT));
2206 for bg in [t.e0, t.e1, t.e2] {
2207 assert!(ratio(t.accent, bg) >= 3.0, "{a:?} ring on {id:?}");
2208 }
2209 assert!(ratio(t.on_accent, t.accent_fill) >= 4.5, "{a:?} label on fill");
2210 assert!(ratio(t.on_accent, t.accent_press) >= 4.5, "{a:?} label on press");
2211 assert!(ratio(t.accent_hover, t.e1) >= 3.0, "{a:?} hover");
2212 }
2213 }
2214 }
2215
2216 #[test]
2217 fn oklch_round_trips_every_colour() {
2218 for r in (0..=255).step_by(15) {
2219 for g in (0..=255).step_by(15) {
2220 for b in (0..=255).step_by(15) {
2221 let rgb = (r << 16) | (g << 8) | b;
2222 let (l, c, h) = super::to_oklch(rgb);
2223 assert_eq!(super::from_oklch(l, c, h), rgb, "{rgb:06x}");
2224 }
2225 }
2226 }
2227 }
2228
2229 #[test]
2230 fn vivid_50_is_the_designed_colour_and_the_ends_move_chroma_only() {
2231 for a in AccentId::ALL {
2232 let (base, hover, _) = a.base(0x3ddc97);
2233 let t = super::tokens_with(super::PaletteId::Darkroom, spec(a, 50, 0x3ddc97));
2234 assert_eq!((t.accent, t.accent_hover), (base, hover), "{a:?}");
2235 let chroma = |v| super::to_oklch(super::vivid_adjust(base, v)).1;
2236 assert!(chroma(0) < chroma(50) && chroma(50) < chroma(100), "{a:?}");
2237 let (l0, _, h0) = super::to_oklch(base);
2238 for v in [0, 100] {
2239 let (l, c, h) = super::to_oklch(super::vivid_adjust(base, v));
2240 assert!((l - l0).abs() < 0.02, "{a:?} lightness at {v}");
2241 if c > 0.02 {
2242 assert!((h - h0).abs() < 4., "{a:?} hue at {v}");
2243 }
2244 }
2245 }
2246 }
2247
2248 /// The colour is the person's: never moved for readability. Only the label picks a side.
2249 #[test]
2250 fn a_custom_colour_is_kept_and_its_label_is_the_better_of_ink_and_white() {
2251 for hex in [0x000000, 0xffffff, 0x0000ff, 0xff4d8d, 0x3ddc97, 0x123456] {
2252 let t = super::tokens_with(super::PaletteId::Darkroom, spec(AccentId::Custom, 50, hex));
2253 assert_eq!(t.accent, hex);
2254 assert_eq!(t.accent_fill, hex);
2255 let score = |ink| ratio(ink, hex).min(ratio(ink, t.accent_press));
2256 assert!(score(t.on_accent) >= score(0xffffff), "{hex:06x}");
2257 }
2258 }
2259
2260 #[test]
2261 fn accent_files_parse_old_and_new() {
2262 use super::parse_accent as p;
2263 assert_eq!(p("rose\n"), (AccentId::Rose, 100, None));
2264 assert_eq!(p("accent=plum\nvivid=80\ncustom=#3ddc97\n"), (AccentId::Plum, 80, Some(0x3ddc97)));
2265 assert_eq!(p("accent=custom\nvivid=500\n"), (AccentId::Custom, 100, None));
2266 assert_eq!(p("garbage\nvivid=x\ncustom=#12\n=\n\0"), (AccentId::Sage, 100, None));
2267 assert_eq!(p(""), (AccentId::Sage, 100, None));
2268 assert_eq!(super::parse_hex("3DDC97"), Some(0x3ddc97));
2269 assert_eq!(super::parse_hex("#3ddc9"), None);
2270 assert_eq!(super::parse_hex("#3ddc9g"), None);
2271 }
2272
2273 #[test]
2274 fn accent_names_round_trip_and_switching_changes_tokens() {
2275 for a in super::AccentId::ALL {
2276 assert_eq!(super::AccentId::from_name(a.name()), Some(a));
2277 }
2278 assert_eq!(super::AccentId::from_name("nope"), None);
2279 assert_eq!(super::AccentId::DEFAULT, super::AccentId::Sage);
2280 let sage = super::tokens_with(super::PaletteId::Darkroom, spec(AccentId::Sage, 50, 0));
2281 let rose = super::tokens_with(super::PaletteId::Darkroom, spec(AccentId::Rose, 50, 0));
2282 assert_ne!(sage.accent, rose.accent);
2283 }
2284
2285 /// Every family's derived ladder still rises, and its ink stays legible on every step.
2286 #[test]
2287 fn every_palette_derives_a_rising_ladder_and_legible_inks() {
2288 use super::{PaletteId, tokens_of};
2289 for id in PaletteId::ALL {
2290 let t = tokens_of(id);
2291 let l = luminance;
2292 assert!(l(t.e0) < l(t.e1) && l(t.e1) < l(t.e2) && l(t.e2) < l(t.e3), "{id:?}");
2293 assert!(l(t.e3) < l(t.e4), "{id:?} pressed above hover");
2294 for bg in [t.e0, t.e1, t.e2, t.e3, t.e4] {
2295 assert!(ratio(t.ink1, bg) >= 4.5, "{id:?} ink1 on {bg:06x}");
2296 }
2297 for bg in [t.e0, t.e1, t.e2, t.e3] {
2298 assert!(ratio(t.ink2, bg) >= 4.5, "{id:?} ink2 on {bg:06x}");
2299 }
2300 }
2301 }
2302
2303 #[test]
2304 fn mix_and_alpha_helpers() {
2305 assert_eq!(super::mix(0x000000, 0xffffff, 0.5), 0x808080);
2306 assert_eq!(super::mix(0x123456, 0xffffff, 0.0), 0x123456);
2307 assert_eq!(super::with_alpha(0x3d8bff, 0x33), 0x3d8bff33);
2308 }
2309}