diff --git a/crates/app/Cargo.toml b/crates/app/Cargo.toml index 4a08943..b849730 100644 --- a/crates/app/Cargo.toml +++ b/crates/app/Cargo.toml @@ -7,11 +7,6 @@ edition.workspace = true name = "edith" path = "src/main.rs" -[features] -# The warm palette instead of the default cool one: same role names, different -# numbers (`ui/theme.rs`). `cargo run -p edith --features warm`. -warm = [] - [dependencies] engine = { path = "../engine" } gpui = "0.2.2" diff --git a/crates/app/src/keymap.rs b/crates/app/src/keymap.rs index 6318e96..19f55c9 100644 --- a/crates/app/src/keymap.rs +++ b/crates/app/src/keymap.rs @@ -110,6 +110,11 @@ actions! { Mix, ToggleSnap, ToggleSubtitles, + /// The window's own colours, which belong to the person looking at them and + /// not to the project: a list of the palettes, opened here and from the + /// toolbar's Theme button. It was a build feature once, which made it a + /// choice only whoever compiled the binary could make. + Theme, CancelExport, /// Opens the actions card -- the list every other action is on. A door of /// its own, because a card reachable only by a button in the panel is one a @@ -168,6 +173,7 @@ impl ActionId { ActionId::Mix => "Mix: track volumes and the limiter…", ActionId::ToggleSnap => "Snap on / off (edges, the playhead, the start)", ActionId::ToggleSubtitles => "Subtitles on / off over the picture", + ActionId::Theme => "Theme: the window's colours…", ActionId::CancelExport => "Cancel export", ActionId::ShowActions => "All actions and their keys…", } @@ -221,6 +227,7 @@ impl ActionId { ActionId::Mix => "mix", ActionId::ToggleSnap => "toggle-snap", ActionId::ToggleSubtitles => "toggle-subtitles", + ActionId::Theme => "theme", ActionId::CancelExport => "cancel-export", ActionId::ShowActions => "show-actions", } @@ -271,7 +278,10 @@ impl ActionId { | ActionId::ZoomIn | ActionId::ZoomOut | ActionId::ZoomFit - | ActionId::ToggleSubtitles => Category::View, + | ActionId::ToggleSubtitles + // ...and what the whole window is painted in: it edits nothing at + // all, it is what one is looking *with*. + | ActionId::Theme => Category::View, ActionId::Cut | ActionId::Regroup | ActionId::Detach @@ -388,7 +398,7 @@ fn codec_chord() -> String { .join(" / ") } -pub static FIXED: std::sync::LazyLock<[Fixed; 28]> = std::sync::LazyLock::new(|| { +pub static FIXED: std::sync::LazyLock<[Fixed; 29]> = std::sync::LazyLock::new(|| { [ // Not a chord at all but a way of pressing one, and the only place the // editor can say so: holding a key that moves a *value* runs it, and @@ -405,6 +415,15 @@ pub static FIXED: std::sync::LazyLock<[Fixed; 28]> = std::sync::LazyLock::new(|| category: Category::View, reach: Reach::Gesture, }, + // An open choice list is driven by the keyboard as well as clicked: the + // list is the door to a setting, and a door only a pointer opens is one + // half of this editor's users cannot use. + Fixed { + chord: "↑ ↓ enter".into(), + label: "Move through an open choice list, and take the row", + category: Category::View, + reach: Reach::Click("picker-row"), + }, Fixed { chord: "n".into(), label: "Open the custom export bitrate field — ↑↓ step it", @@ -792,6 +811,11 @@ impl Keymap { // the rest of the things one *looks* at, and nowhere near the // two keys that delete. b(ActionId::ToggleSubtitles, "t", false), + // The theme takes ctrl+h -- the h of the word, since "t" is the + // subtitles and ctrl+t takes one off -- and a ctrl chord because + // it is a preference set once, not a stroke wanted under a hand + // that is editing. + b(ActionId::Theme, "h", true), b(ActionId::CancelExport, "escape", false), // The help key, where every program's list of what it can do // has always been. Free -- gpui names it "f1" @@ -1061,8 +1085,9 @@ mod tests { #[test] fn every_default_stroke_reaches_its_action() { let k = Keymap::defaults(); - assert_eq!(k.entries().len(), 48); + assert_eq!(k.entries().len(), 49); assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions)); + assert_eq!(k.lookup("h", true), Some(ActionId::Theme)); assert_eq!(k.lookup("space", false), Some(ActionId::Play)); // The seek keys: bare arrows a frame, ctrl arrows a second, and the two // ends of the timeline. diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 3e18092..227c42a 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -617,6 +617,11 @@ struct LibraryMenu { struct Picker { of: Pick, at: Point, + /// Which row the keyboard is on, from the value in force when the list + /// opened. The list answers ↑↓ and enter as well as a click: a setting whose + /// only door is a pointer is a setting half this editor's users cannot + /// reach, which is the rule `FIXED` already writes down for every card. + sel: usize, } /// Which setting an open list is offering. The fit policy names the clip it is @@ -634,6 +639,10 @@ enum Pick { /// ([`engine::tonemap::Preset`]). Opened from the panel, beside the two /// other settings that are the project's rather than the media's. Tone, + /// Which palette the window is painted in ([`ui::theme`]). The one setting + /// here that is nobody's project: it is the person's, so it outlives the + /// timeline and every file opened in it. + Theme, } /// One value a list offers, carrying everything picking it needs -- so a click @@ -649,6 +658,7 @@ enum Choice { Fit(Lane, usize, FitPolicy), AudioRate(u32), Tone(Preset), + Theme(ui::theme::PaletteId), } /// One row of an open list: the value, its name, the small print beside it, and @@ -1743,6 +1753,10 @@ impl Player { ActionId::Mix => self.open_mix(None, cx), ActionId::ToggleSnap => self.toggle_snap(cx), ActionId::ToggleSubtitles => self.toggle_subtitles(cx), + // The keyboard's door to the same list the toolbar button opens. + // At the window's corner, since a stroke names no place -- and + // [`menu_at`] keeps it on screen from there. + ActionId::Theme => self.open_picker(Pick::Theme, Point::default(), cx), // Nothing to cancel while nothing is exporting; the export guard in // the key handler is what answers this one while there is. ActionId::CancelExport => {} @@ -2135,9 +2149,16 @@ impl Player { /// thing at a time: the click that opens it is the click that closes /// whatever menu it was opened from. fn open_picker(&mut self, of: Pick, at: Point, cx: &mut Context) { + // On the row that is in force, so the first ↑ or ↓ steps off the + // current value rather than off the top of the list. + let sel = self + .choices(of) + .iter() + .position(|(.., picked)| *picked) + .unwrap_or(0); self.context_menu = None; self.library_menu = None; - self.picker = Some(Picker { of, at }); + self.picker = Some(Picker { of, at, sel }); cx.notify(); } @@ -2151,6 +2172,21 @@ impl Player { Choice::Fps(fps) => self.apply_frame_rate(fps, cx), Choice::Fit(lane, idx, fit) => self.apply_fit(lane, idx, fit, cx), Choice::Tone(preset) => self.apply_tone(preset, cx), + // In force for the next paint -- every token is read through + // [`ui::theme::palette`], so one store repaints the whole window -- + // and kept for the next launch. A file that could not be written is + // said out loud: the difference between "picked" and "picked for + // good" is the user's to know. + Choice::Theme(id) => { + ui::theme::set(id); + if let Err(e) = ui::theme::save(id) { + let path = ui::theme::config_path(); + self.notify_user( + format!("THEME COULD NOT BE KEPT — {} — {e}", path.display()).into(), + ); + } + cx.notify(); + } // The same field the row's key steps, set outright: a list picks a // value, it does not step to one. Choice::AudioRate(kbps) => { @@ -2164,6 +2200,22 @@ impl Player { /// without a timeline, which is the state where nothing here has a value to /// offer -- and where the surfaces that open the list are dimmed anyway. fn choices(&self, of: Pick) -> Vec { + // The palette is not the project's, so it is offered before the + // timeline is asked about: an empty window is painted too, and its + // Theme button is live there like the snap beside it. + if of == Pick::Theme { + return ui::theme::PaletteId::ALL + .into_iter() + .map(|id| { + ( + Choice::Theme(id), + id.label().into(), + id.detail().into(), + id == ui::theme::active(), + ) + }) + .collect(); + } let Some(session) = &self.session else { return Vec::new(); }; @@ -2177,6 +2229,8 @@ impl Player { } Pick::AudioRate => audio_rate_choices(self.audio_kbps), Pick::Tone => tone_choices(session.tone()), + // Answered above, with or without a timeline. + Pick::Theme => Vec::new(), } } @@ -3766,7 +3820,7 @@ impl Player { .map_or(0, |session| session.file_frames(path)), // A path with no source entry has no colour of its own, and the // shadow wears the lane's own instead of borrowing another file's. - tint: file_tint(self.sources(), path).unwrap_or(BG_RAISED), + tint: file_tint(self.sources(), path).unwrap_or(BG_RAISED()), refused: lane_refuses(path, to).is_some(), }; self.set_ghost(Some(ghost), cx); @@ -4809,9 +4863,10 @@ impl Player { /// would name a *different* track -- and the pick is what an export writes /// into the file. /// - /// Not an undo step: subtitles are not on the history's snapshots, so the - /// way back is importing the file again. The notice says that rather than - /// promising a ctrl+z that would do nothing. + /// Not an undo step: subtitles are not on the history's snapshots. The way + /// back is the row the removal leaves behind under the list + /// ([`Player::restore_subtitle_track`]) -- a click, not a re-import -- and + /// the notice says so rather than promising a ctrl+z that would do nothing. fn remove_subtitle_track(&mut self, track: usize, cx: &mut Context) { // The one availability oracle, for the same reason the × on a row and // the stroke are one call: an empty list is not a failure, it is an @@ -4848,7 +4903,7 @@ impl Player { // ponytail: its atlas tile is not released -- `close_session`'s // note, for its reason and with its upgrade path. self.sub_image = None; - format!("{name} REMOVED — importing the file again brings it back") + format!("{name} REMOVED — it is under the list; click it to bring it back") } Some(Err(e)) => format!("NO SUBTITLES REMOVED — {e}"), None => "NO SUBTITLES REMOVED — open a file first".to_string(), @@ -4858,6 +4913,42 @@ impl Player { cx.notify(); } + /// The removed row's own way back: the `+` under the subtitle list, and the + /// row itself. The track goes back on the timeline with the cues it was + /// removed with ([`engine::PlaybackSession::restore_subtitles`]) -- no file + /// is read again, which is the whole complaint this answers. + /// + /// The restored track becomes the pick and the overlay goes on, for the + /// reason a click on a live row does: bringing a subtitle back is asking to + /// see it, and a restore that changed nothing on screen would read as a + /// dead row. + fn restore_subtitle_track(&mut self, removed: usize, cx: &mut Context) { + let name = self + .session + .as_ref() + .and_then(|session| sub_pick_name(session.removed_subtitles(), removed)) + .unwrap_or_else(|| format!("subtitle track {removed}")); + let text = match self + .session + .as_mut() + .map(|session| session.restore_subtitles(removed)) + { + Some(Ok(track)) => { + self.sub_track = track; + self.subs_on = true; + // The drawn cue is keyed by the pick, which has just moved -- + // `remove_subtitle_track`'s note, for its reason. + self.sub_image = None; + format!("{name} IS BACK — showing over the picture") + } + Some(Err(e)) => format!("NOTHING BROUGHT BACK — {e}"), + None => "NOTHING BROUGHT BACK — open a file first".to_string(), + }; + eprintln!("{text}"); + self.notify_user(text.into()); + cx.notify(); + } + /// Swaps the whole timeline for one restored from a `.edith`, for /// [`Player::install_media`]'s reason: the open is a worker's -- a project /// naming a 24 GB film opens that film, which is the same twenty seconds @@ -5983,6 +6074,28 @@ impl Render for Player { // stroke exactly as the clip menu does. // A choice list goes the same way and for the same reason: it // names a clip index too, and escape is the way out of it. + // An open list is the innermost thing on screen, so it takes + // the keys before anything under it does: ↑↓ walk it, enter + // takes the row, and escape falls through to the close below -- + // the same three strokes every list in this editor answers. + if let Some(mut picker) = this.picker { + let rows = this.choices(picker.of); + if !rows.is_empty() && matches!(key, "up" | "down" | "enter") { + match key { + "down" => picker.sel = (picker.sel + 1) % rows.len(), + "up" => picker.sel = (picker.sel + rows.len() - 1) % rows.len(), + _ => { + let (choice, ..) = rows[picker.sel.min(rows.len() - 1)]; + this.choose(choice, cx); + cx.notify(); + return; + } + } + this.picker = Some(picker); + cx.notify(); + return; + } + } let clip_menu = this.context_menu.take().is_some(); let row_menu = this.library_menu.take().is_some(); let list = this.picker.take().is_some(); @@ -6054,8 +6167,8 @@ impl Render for Player { .size_full() .flex() .flex_col() - .bg(rgb(BG_CANVAS)) - .text_color(rgb(FG_PRIMARY)) + .bg(rgb(BG_CANVAS())) + .text_color(rgb(FG_PRIMARY())) .text_size(px(12.)) // Four regions, the arrangement every consumer editor shares: // library left, picture centre, inspector right, and the timeline @@ -6093,7 +6206,7 @@ impl Render for Player { .flex() .justify_center() .items_center() - .bg(rgb(BG_CANVAS)) + .bg(rgb(BG_CANVAS())) .children( self.image .clone() @@ -7133,6 +7246,12 @@ fn enable(action: ActionId, ctx: Ctx) -> Enable { // window has no clips and still has keys -- so this answers ahead of the // timeline question, and only an export shuts it (a waiting row would // swallow the escape the progress line promises cancels the export). + // The window's own colours: there is always a window, and repainting it + // touches no timeline -- so this one is live even while an export is + // reading one, which is the only state that dims the list above. + if action == ActionId::Theme { + return Enable::Yes; + } if action == ActionId::ShowActions { return match ctx.exporting { true => Enable::No("an export is running"), @@ -7734,7 +7853,7 @@ fn window_title(name: &str) -> String { /// palette two sources share a colour, which is a smaller lie than a fifth tint /// bright enough to leave the family. fn source_tint(source: usize) -> u32 { - SOURCE_TINTS[source % SOURCE_TINTS.len()] + SOURCE_TINTS()[source % SOURCE_TINTS().len()] } /// The tint of a *file*, which is what a library row is named by: the first @@ -9368,7 +9487,7 @@ fn hist_curves(bins: [[u32; HIST_BINS]; 3]) -> impl IntoElement { } } if let Ok(path) = path.build() { - window.paint_path(path, rgb(HIST_INK[channel])); + window.paint_path(path, rgb(HIST_INK()[channel])); } } }, @@ -9494,7 +9613,7 @@ fn eq_spectrum_curve(levels: Vec) -> impl IntoElement { path.line_to(point(o.x + s.width, o.y + s.height)); path.close(); if let Ok(path) = path.build() { - window.paint_path(path, rgba(EQ_SPECTRUM_INK)); + window.paint_path(path, rgba(EQ_SPECTRUM_INK())); } }, ) @@ -9547,7 +9666,7 @@ fn eq_curve(params: EqParams, sample_rate: u32) -> impl IntoElement { } } if let Ok(bell) = bell.build() { - window.paint_path(bell, rgba(EQ_BELL_INK)); + window.paint_path(bell, rgba(EQ_BELL_INK())); } } let points = line(¶ms); @@ -9562,7 +9681,7 @@ fn eq_curve(params: EqParams, sample_rate: u32) -> impl IntoElement { area.line_to(point(o.x + s.width, o.y + s.height / 2.)); area.close(); if let Ok(area) = area.build() { - window.paint_path(area, rgba(EQ_FILL_INK)); + window.paint_path(area, rgba(EQ_FILL_INK())); } let mut path = PathBuilder::stroke(px(2.)); for (step, at) in points.into_iter().enumerate() { @@ -9572,7 +9691,7 @@ fn eq_curve(params: EqParams, sample_rate: u32) -> impl IntoElement { } } if let Ok(path) = path.build() { - window.paint_path(path, rgb(ACCENT_PRIMARY)); + window.paint_path(path, rgb(ACCENT_PRIMARY())); } }, ) @@ -9975,7 +10094,7 @@ mod tests { // function -- what makes the panel and the lanes one association. for row in 0..rows.len() { assert_eq!(rows[row].tint, row); - assert_eq!(source_tint(row), SOURCE_TINTS[row % SOURCE_TINTS.len()]); + assert_eq!(source_tint(row), SOURCE_TINTS()[row % SOURCE_TINTS().len()]); } } @@ -10451,9 +10570,14 @@ mod tests { }; assert!(whole(ActionId::CancelExport, busy).yes()); for action in ActionId::ALL { + // Nothing may touch the edit list while an export is reading it -- + // and the palette does not: it repaints this window and writes one + // word to the user's own config file, which is why it is the one + // action besides the cancel that stays live here. + let allowed = action == ActionId::CancelExport || action == ActionId::Theme; assert_eq!( whole(action, busy).yes(), - action == ActionId::CancelExport, + allowed, "{action:?} while an export reads the edit list" ); } @@ -13466,21 +13590,27 @@ mod tests { // in its column -- is body text on `BG_RAISED` and WCAG 1.4.3 binds it. // A dimmed row is drawn in this ink rather than at an opacity, which is // what a refusal used to be readable through. - assert!( - contrast(FG_SECONDARY, BG_RAISED) >= 4.5, - "refusal ink {:.2}", - contrast(FG_SECONDARY, BG_RAISED) - ); + // Every palette, not the one in force: a family is picked at runtime + // now (`ui::theme`), so a floor met by one of them and missed by the + // other is a window somebody is looking at. + for id in crate::ui::theme::PaletteId::ALL { + let p = id.palette(); + assert!( + contrast(p.FG_SECONDARY, p.BG_RAISED) >= 4.5, + "{id:?}: refusal ink {:.2}", + contrast(p.FG_SECONDARY, p.BG_RAISED) + ); // ...and on the picked row, where the highlight is the accent at // surface brightness. Both inks clear 4.5:1 on it now -- the row still // lifts its key and detail to `FG_PRIMARY`, as emphasis rather than as // the rescue it used to be. - assert!(contrast(FG_PRIMARY, BG_SELECTED) >= 4.5); - assert!( - contrast(FG_SECONDARY, BG_SELECTED) >= 4.5, - "refusal ink on the picked row {:.2}", - contrast(FG_SECONDARY, BG_SELECTED) - ); + assert!(contrast(p.FG_PRIMARY, p.BG_SELECTED) >= 4.5, "{id:?}"); + assert!( + contrast(p.FG_SECONDARY, p.BG_SELECTED) >= 4.5, + "{id:?}: refusal ink on the picked row {:.2}", + contrast(p.FG_SECONDARY, p.BG_SELECTED) + ); + } } /// The progress line's two clocks, driven the way a repaint drives them: @@ -14347,7 +14477,9 @@ mod tests { assert!(SUB_LINE_H >= SUB_TEXT); // White on the plate, not chrome on chrome: a cue is read against the // film, and this is the one pair here that has to survive any picture. - assert!(contrast(SUB_FG, 0x000000) >= 7.); + for id in crate::ui::theme::PaletteId::ALL { + assert!(contrast(id.palette().SUB_FG, 0x000000) >= 7., "{id:?}"); + } // The strip is a picture and not a target -- nothing on it takes a // click -- which is the only reason it may be under `HIT_MIN`. assert!(SUB_LANE_H < HIT_MIN && SUB_LANE_H > 0.); @@ -14711,10 +14843,10 @@ mod tests { /// the tone cannot disagree with the sentence it labels. #[test] fn a_message_wears_the_colour_its_own_words_say() { - assert_eq!(notice_tone("SCAN FAILED: no audio"), STATUS_ERROR); - assert_eq!(notice_tone(&format!("{EXPORT_DONE}out.mp4")), STATUS_SUCCESS); - assert_eq!(notice_tone("NOTHING DETACHED — not grouped"), STATUS_WARNING); - assert_eq!(notice_tone("SNAP ON"), ACCENT_PRIMARY); + assert_eq!(notice_tone("SCAN FAILED: no audio"), STATUS_ERROR()); + assert_eq!(notice_tone(&format!("{EXPORT_DONE}out.mp4")), STATUS_SUCCESS()); + assert_eq!(notice_tone("NOTHING DETACHED — not grouped"), STATUS_WARNING()); + assert_eq!(notice_tone("SNAP ON"), ACCENT_PRIMARY()); } /// The cards are sections of the inspector, not sheets over the timeline: @@ -15115,37 +15247,36 @@ mod tests { // ([`clip_kind`]); the source tint is the border and the library // swatch, and is measured for telling itself apart rather than for // carrying text. - for (i, tint) in [ - crate::ui::theme::CLIP_VIDEO, - crate::ui::theme::CLIP_AUDIO, - crate::ui::theme::CLIP_IMAGE, - crate::ui::theme::CLIP_TEXT, - ] - .iter() - .enumerate() - { - // WCAG 1.4.3: the clip's name is body text on its tint. - assert!( - contrast(FG_PRIMARY, *tint) >= 4.5, - "source {i}: label contrast {:.2}", - contrast(FG_PRIMARY, *tint) - ); - // WCAG 1.4.11: the waveform is a non-text graphic on it. - assert!( - contrast(FG_SECONDARY, *tint) >= 3., - "source {i}: waveform contrast {:.2}", - contrast(FG_SECONDARY, *tint) - ); + // Every palette a person can pick, not merely the one in force. + for id in crate::ui::theme::PaletteId::ALL { + let p = id.palette(); + for (i, tint) in [p.CLIP_VIDEO, p.CLIP_AUDIO, p.CLIP_IMAGE, p.CLIP_TEXT] + .iter() + .enumerate() + { + // WCAG 1.4.3: the clip's name is body text on its tint. + assert!( + contrast(p.FG_PRIMARY, *tint) >= 4.5, + "{id:?} source {i}: label contrast {:.2}", + contrast(p.FG_PRIMARY, *tint) + ); + // WCAG 1.4.11: the waveform is a non-text graphic on it. + assert!( + contrast(p.FG_SECONDARY, *tint) >= 3., + "{id:?} source {i}: waveform contrast {:.2}", + contrast(p.FG_SECONDARY, *tint) + ); + } + // A selected clip's bed is the same two marks on a different colour. + assert!(contrast(p.FG_PRIMARY, p.BG_SELECTED) >= 4.5, "{id:?}"); + assert!(contrast(p.FG_SECONDARY, p.BG_SELECTED) >= 3., "{id:?}"); + // The bed a gap shows through has to read as a hole in the lane -- + // the clip is the object, the bed is the hole -- and the playhead + // has to be findable on both. + assert!(contrast(p.CLIP_VIDEO, p.BG_TIMELINE) >= 1.5, "{id:?}"); + assert!(contrast(p.ACCENT_PLAYHEAD, p.BG_TIMELINE) >= 3., "{id:?}"); + assert!(contrast(p.ACCENT_PLAYHEAD, p.CLIP_VIDEO) >= 3., "{id:?}"); } - // A selected clip's bed is the same two marks on a different colour. - assert!(contrast(FG_PRIMARY, BG_SELECTED) >= 4.5); - assert!(contrast(FG_SECONDARY, BG_SELECTED) >= 3.); - // The bed a gap shows through has to read as a hole in the lane -- the - // clip is the object, the bed is the hole -- and the playhead has to be - // findable on both. - assert!(contrast(crate::ui::theme::CLIP_VIDEO, crate::ui::theme::BG_TIMELINE) >= 1.5); - assert!(contrast(crate::ui::theme::ACCENT_PLAYHEAD, crate::ui::theme::BG_TIMELINE) >= 3.); - assert!(contrast(crate::ui::theme::ACCENT_PLAYHEAD, crate::ui::theme::CLIP_VIDEO) >= 3.); // The sanity check on the ratio itself: black on white is 21:1. assert!((contrast(0xffffff, 0x000000) - 21.).abs() < 0.01); } @@ -15155,7 +15286,7 @@ mod tests { // The bug: the first entry *was* `BG_RAISED`, so the first file imported // -- the one every session has -- wore the panel's own background and // had no visible swatch at all. - assert_ne!(source_tint(0), BG_RAISED); + assert_ne!(source_tint(0), BG_RAISED()); // Neighbouring sources must not share one, or an import is invisible. assert_ne!(source_tint(0), source_tint(1)); assert_ne!(source_tint(1), source_tint(2)); @@ -15163,7 +15294,7 @@ mod tests { // Past the palette it wraps -- never an index panic. assert_eq!(source_tint(4), source_tint(0)); assert_eq!(source_tint(9), source_tint(1)); - assert_eq!(source_tint(usize::MAX), SOURCE_TINTS[usize::MAX % 4]); + assert_eq!(source_tint(usize::MAX), SOURCE_TINTS()[usize::MAX % 4]); } /// Not "they are different numbers" -- different *enough to see*, against @@ -15182,13 +15313,13 @@ mod tests { }) .sum::() }; - for (i, &tint) in SOURCE_TINTS.iter().enumerate() { + for (i, &tint) in SOURCE_TINTS().iter().enumerate() { assert!( - apart(tint, BG_RAISED) >= 16, + apart(tint, BG_RAISED()) >= 16, "tint {i} is {} from the panel it sits on", - apart(tint, BG_RAISED) + apart(tint, BG_RAISED()) ); - for (j, &other) in SOURCE_TINTS.iter().enumerate().skip(i + 1) { + for (j, &other) in SOURCE_TINTS().iter().enumerate().skip(i + 1) { assert!( apart(tint, other) >= 16, "tints {i} and {j} are only {} apart", @@ -15198,7 +15329,7 @@ mod tests { } // The two a person sees side by side first must be further apart than // the floor: source 0 and source 1 are the first import and the second. - assert!(apart(SOURCE_TINTS[0], SOURCE_TINTS[1]) >= 32); + assert!(apart(SOURCE_TINTS()[0], SOURCE_TINTS()[1]) >= 32); } /// A `.srt` dropped on the window is nobody's stream: it has no source @@ -15396,6 +15527,31 @@ mod tests { assert_eq!(sub_pick_name(&[], 0), None); } + /// Whatever a removal took off can be put back from the panel, without the + /// file being imported again: the removed row and its `+` are things on + /// screen, which is what makes the way back an action and not a sentence in + /// a notice. The names on those rows come off the same + /// [`sub_pick_name`] the live ones do, so a removed track reads as the + /// track it was. + #[test] + fn a_removed_subtitle_row_has_its_way_back_in_the_panel() { + let source = ui_source(); + for id in ["subtitle-restore", "subtitle-restore-button"] { + assert!( + source.contains(&format!("\"{id}\"")), + "{id} is on no row: a removed subtitle would need a re-import" + ); + } + // What those rows are named by, off the removed list rather than the + // live one -- the bin's own indexes. + let gone = [ + sub("/films/a.mkv", Some(1), "eng"), + sub("/subs/late.srt", None, "late.srt"), + ]; + assert_eq!(sub_pick_name(&gone, 0).as_deref(), Some("eng — a")); + assert_eq!(sub_pick_name(&gone, 1).as_deref(), Some("late.srt")); + } + /// The one thing regrouping must not break: `sub_track` is a flat index /// into the add-order list, a click sets it and a save writes it into the /// `.edith`. Every row must still name the track it was made from -- rows @@ -15661,6 +15817,11 @@ fn main() { if let Some(text) = ¬ice { eprintln!("{text}"); } + // The palette the last session picked, before the first paint: a window that + // opened cool and turned warm a frame later would be the theme announcing + // itself. Silent on a missing or unreadable file -- the default is a whole + // answer, and nothing of the user's is lost by it. + ui::theme::load(); // Nothing named on the command line is read here. The first file makes the // timeline -- a `.edith` restores a whole one, anything else *is* one -- // and the rest are imports like any other: rows in the library, dragged diff --git a/crates/app/src/ui/cards.rs b/crates/app/src/ui/cards.rs index 4252b43..d872223 100644 --- a/crates/app/src/ui/cards.rs +++ b/crates/app/src/ui/cards.rs @@ -55,9 +55,9 @@ impl Player { // an inapplicable item in the clip menu is: it still says its piece. let live = |d: Stateful
, enabled: bool| { d.when(!enabled, |d| { - d.cursor_not_allowed().text_color(rgb(FG_SECONDARY)) + d.cursor_not_allowed().text_color(rgb(FG_SECONDARY())) }) - .when(enabled, |d| d.cursor_pointer().hover(|s| s.bg(rgb(BG_HOVER)))) + .when(enabled, |d| d.cursor_pointer().hover(|s| s.bg(rgb(BG_HOVER())))) }; // A row as this card writes them: the mark saying which one is picked, // the key that picks it, its name, and what the choice means. The mark @@ -74,11 +74,11 @@ impl Player { // dim ink is only 3.3:1 -- the row it lands on lifts it (WCAG // 1.4.3, and the fit test pins both numbers). let ink = match picked { - true => FG_PRIMARY, - false => FG_SECONDARY, + true => FG_PRIMARY(), + false => FG_SECONDARY(), }; live(row(id), enabled) - .when(picked, |d| d.bg(rgb(BG_SELECTED))) + .when(picked, |d| d.bg(rgb(BG_SELECTED()))) .child( div() .flex() @@ -116,7 +116,7 @@ impl Player { .px(px(6.)) .pt(px(4.)) .text_size(px(10.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(text) .into_any_element() }; @@ -366,7 +366,7 @@ impl Player { .px(px(6.)) .py(px(2.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(format!("cannot write: {}", refusals.join(" · "))) .into_any_element(), ); @@ -386,7 +386,7 @@ impl Player { .px(px(6.)) .py(px(2.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(text) .into_any_element() }; @@ -450,7 +450,7 @@ impl Player { .flex() .justify_center() .items_center() - .bg(rgba(SCRIM)) + .bg(rgba(SCRIM())) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -469,7 +469,7 @@ impl Player { .gap(px(2.)) .p(px(12.)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child(div().flex_none().px(px(6.)).child("Export")) // The status line, where a refusal from the save dialog // lands: the notice bar it would otherwise take is under @@ -481,7 +481,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(match (&self.mbps_edit, self.notices.front()) { // A field being typed into says so here as // well as in its row: this line is outside @@ -519,7 +519,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(tail), ) .child( @@ -532,11 +532,11 @@ impl Player { .justify_center() .rounded(px(3.)) .bg(rgb(match blocked.is_some() { - true => BG_PANEL, - false => BG_SELECTED, + true => BG_PANEL(), + false => BG_SELECTED(), })) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click( cx.listener(|this, _: &ClickEvent, _, cx| { this.start_export(cx) @@ -562,9 +562,9 @@ impl Player { .items_center() .justify_center() .rounded(px(3.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.nudge_mbps(by); cx.notify(); @@ -637,8 +637,8 @@ impl Player { .h(px(EQ_HANDLE)) .rounded(px(EQ_HANDLE / 2.)) .bg(rgb(match i == self.eq_band { - true => ACCENT_PRIMARY, - false => FG_SECONDARY, + true => ACCENT_PRIMARY(), + false => FG_SECONDARY(), })) }) .collect(); @@ -651,7 +651,7 @@ impl Player { .flex_none() .h(px(EQ_GRAPH_H)) .rounded(px(3.)) - .bg(rgb(BG_HOVER_DIM)) + .bg(rgb(BG_HOVER_DIM())) .cursor_pointer() // The press picks the band under it *and* is already the first // sample of the drag, so a plain click sets a value. A second click @@ -686,7 +686,7 @@ impl Player { .left(relative(eq_x(*freq))) .w(px(1.)) .h_full() - .bg(rgb(EQ_GRID)) + .bg(rgb(EQ_GRID())) }) .collect::>(), ) @@ -698,14 +698,14 @@ impl Player { .top(relative(eq_y(db))) .w_full() .h(px(1.)) - .bg(rgb(EQ_GRID)) + .bg(rgb(EQ_GRID())) .child( div() .absolute() .left(px(4.)) .top(px(-11.)) .text_size(px(9.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(format!("{db:+.0}")), ) })) @@ -716,7 +716,7 @@ impl Player { .top(relative(0.5)) .w_full() .h(px(1.)) - .bg(rgb(BG_HOVER)), + .bg(rgb(BG_HOVER())), ) .child(eq_curve(self.eq_params.clone(), sample_rate)) .children(handles) @@ -731,7 +731,7 @@ impl Player { .w(px(24.)) .text_align(TextAlign::Center) .text_size(px(9.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(label) })) .child( @@ -740,7 +740,7 @@ impl Player { .top(px(2.)) .left(px(4.)) .text_size(px(9.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(format!("+{EQ_GAIN_LIMIT:.0} dB")), ); // The bottom of the axis is not named: -12 dB would land in the same @@ -761,7 +761,7 @@ impl Player { .flex() .justify_center() .items_center() - .bg(rgba(SCRIM)) + .bg(rgba(SCRIM())) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -793,7 +793,7 @@ impl Player { .gap(px(2.)) .p(px(12.)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child( div() .id("eq-card-rows") @@ -818,7 +818,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(self.notices.front().cloned().unwrap_or_else(|| { "drag a handle, or a digit picks a band — ←→ moves it, ↑↓ its gain, shift+←→ its width; a adds, x removes, f flattens it, r all, s spectrum; a click away or esc closes".into() })), @@ -850,9 +850,9 @@ impl Player { .items_center() .justify_center() .rounded(px(3.)) - .bg(rgb(BG_SELECTED)) + .bg(rgb(BG_SELECTED())) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { for band in &mut this.eq_params.bands { band.gain_db = 0.; @@ -874,9 +874,9 @@ impl Player { .items_center() .justify_center() .rounded(px(3.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { this.add_band(cx) })) @@ -891,9 +891,9 @@ impl Player { .items_center() .justify_center() .rounded(px(3.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { this.remove_band(cx) })) @@ -913,11 +913,11 @@ impl Player { .justify_center() .rounded(px(3.)) .bg(rgb(match self.eq_spectrum { - true => BG_SELECTED, - false => BG_HOVER_DIM, + true => BG_SELECTED(), + false => BG_HOVER_DIM(), })) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { this.eq_spectrum = !this.eq_spectrum; cx.notify(); @@ -943,8 +943,8 @@ impl Player { .px(px(6.)) .text_size(px(10.)) .text_color(rgb(match below > 1. { - true => ACCENT_PRIMARY, - false => FG_SECONDARY, + true => ACCENT_PRIMARY(), + false => FG_SECONDARY(), })) .child(match below > 1. { true => "more below — scroll the card", @@ -988,9 +988,9 @@ impl Player { .items_center() .justify_center() .rounded(px(3.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.nudge_band(change, cx) })) @@ -1045,9 +1045,9 @@ impl Player { .px(px(8.)) .items_center() .rounded(px(3.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click( cx.listener(|this, _: &ClickEvent, _, cx| { this.nudge_band(|b| b.gain_db = 0., cx) @@ -1088,8 +1088,8 @@ impl Player { .px(px(6.)) .rounded(px(3.)) .cursor_pointer() - .when(picked, |d| d.bg(rgb(BG_SELECTED))) - .hover(|s| s.bg(rgb(BG_HOVER))) + .when(picked, |d| d.bg(rgb(BG_SELECTED()))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.color_band = i; cx.notify(); @@ -1124,13 +1124,13 @@ impl Player { .w_full() .h(px(4.)) .rounded(px(2.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .child( div() .h_full() .w(relative(frac)) .rounded(px(2.)) - .bg(rgb(ACCENT_PRIMARY)), + .bg(rgb(ACCENT_PRIMARY())), ), ), ) @@ -1138,7 +1138,7 @@ impl Player { div() .w(px(44.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(format!("{value:.2}")), ) }) @@ -1148,7 +1148,7 @@ impl Player { .flex() .justify_center() .items_center() - .bg(rgba(SCRIM)) + .bg(rgba(SCRIM())) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -1168,7 +1168,7 @@ impl Player { .gap(px(2.)) .p(px(12.)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child(div().flex_none().px(px(6.)).child(format!( "Colour — {} clip {}", lane.label(), @@ -1179,7 +1179,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child( "drag a bar, or ↑↓ picks one and ←→ moves it, r resets — a click away or esc closes", ), @@ -1193,7 +1193,7 @@ impl Player { .flex_none() .h(px(HIST_H)) .rounded(px(3.)) - .bg(rgb(BG_HOVER_DIM)) + .bg(rgb(BG_HOVER_DIM())) .relative() .child(hist_curves(self.histogram)), ) @@ -1207,9 +1207,9 @@ impl Player { .items_center() .justify_center() .rounded(px(3.)) - .bg(rgb(BG_SELECTED)) + .bg(rgb(BG_SELECTED())) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { this.set_color(ColorParams::default(), cx); })) @@ -1249,11 +1249,11 @@ impl Player { .justify_center() .rounded(px(3.)) .bg(rgb(match at == speed { - true => BG_SELECTED, - false => BG_PANEL, + true => BG_SELECTED(), + false => BG_PANEL(), })) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.set_speed(at, cx); })) @@ -1265,7 +1265,7 @@ impl Player { .flex() .justify_center() .items_center() - .bg(rgba(SCRIM)) + .bg(rgba(SCRIM())) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -1285,7 +1285,7 @@ impl Player { .gap(px(6.)) .p(px(12.)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child(div().flex_none().px(px(6.)).child(format!( "Speed (tape) — {} clip {}", lane.label(), @@ -1296,7 +1296,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child( "drag the bar or ←→ moves it, r is 1.00x — the pitch moves with the rate; a click away or esc closes", ), @@ -1326,13 +1326,13 @@ impl Player { .w_full() .h(px(4.)) .rounded(px(2.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .child( div() .h_full() .w(relative(frac)) .rounded(px(2.)) - .bg(rgb(ACCENT_PRIMARY)), + .bg(rgb(ACCENT_PRIMARY())), ), ), ) @@ -1342,7 +1342,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) // What the choice *is*, in the numbers the // timeline is measured in: the source range // never moves, the room it takes does. @@ -1414,16 +1414,16 @@ impl Player { .px(px(6.)) .rounded(px(3.)) .bg(rgb(match n == self.mix_field { - true => BG_SELECTED, - false => BG_PANEL, + true => BG_SELECTED(), + false => BG_PANEL(), })) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.mix_field = n; cx.notify(); })) - .child(div().text_color(rgb(FG_SECONDARY)).child(label)) + .child(div().text_color(rgb(FG_SECONDARY())).child(label)) .child( div() .flex() @@ -1440,9 +1440,9 @@ impl Player { .items_center() .justify_center() .rounded(px(3.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { // Picked as well as moved, the silence // card's rule: the row a press lands on @@ -1463,7 +1463,7 @@ impl Player { .flex() .justify_center() .items_center() - .bg(rgba(SCRIM)) + .bg(rgba(SCRIM())) // Click away closes it, as on every card here. .on_mouse_down( MouseButton::Left, @@ -1484,7 +1484,7 @@ impl Player { .gap(px(6.)) .p(px(12.)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child( div() .flex_none() @@ -1496,7 +1496,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child( "− and + move a setting, or ↑↓ picks one and ←→ moves it (hold to run it) — a track fader moves everything on that track; a click away or esc closes", ), @@ -1515,7 +1515,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) // What the choice *is*: the limiter's own line, // because "on" alone says nothing about what it // does to a mix that never reaches the ceiling. @@ -1601,16 +1601,16 @@ impl Player { .px(px(6.)) .rounded(px(3.)) .bg(rgb(match n == self.silence_field { - true => BG_SELECTED, - false => BG_PANEL, + true => BG_SELECTED(), + false => BG_PANEL(), })) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.silence_field = n; cx.notify(); })) - .child(div().text_color(rgb(FG_SECONDARY)).child(label)) + .child(div().text_color(rgb(FG_SECONDARY())).child(label)) // The value and the two steps that move it. Every other // card has something to drag or press; this one had the // arrow keys and nothing else, so a row was a setting a @@ -1633,9 +1633,9 @@ impl Player { .items_center() .justify_center() .rounded(px(3.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { // Picked as well as moved: the row a // press lands on is the row the arrows @@ -1664,11 +1664,11 @@ impl Player { .justify_center() .rounded(px(3.)) .bg(rgb(match found { - 0 => BG_PANEL, - _ => BG_SELECTED, + 0 => BG_PANEL(), + _ => BG_SELECTED(), })) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| act(this, cx))) .child(text) }; @@ -1680,7 +1680,7 @@ impl Player { .pt(px(HEADER_H + 8.)) // Light enough to read the lanes and the marks on them through: // the preview is the point of this card. - .bg(rgba(SCRIM_LIGHT)) + .bg(rgba(SCRIM_LIGHT())) // Click away closes it, as on every card here -- and the marks // go with it, which is what makes this one a call and not a flag. .on_mouse_down( @@ -1701,7 +1701,7 @@ impl Player { .gap(px(6.)) .p(px(12.)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child(div().flex_none().px(px(6.)).child(format!( "Silences — {} clip {}", lane.label(), @@ -1712,7 +1712,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child( "− and + move a setting, or ↑↓ picks one and ←→ moves it (hold to run it) — the marks on the lane are what would go; a click away or esc closes", ), @@ -1723,8 +1723,8 @@ impl Player { .flex_none() .px(px(6.)) .text_color(rgb(match (&self.silence_scan, found) { - (None, 1..) => ACCENT_PRIMARY, - _ => FG_SECONDARY, + (None, 1..) => ACCENT_PRIMARY(), + _ => FG_SECONDARY(), })) .child(status), ) diff --git a/crates/app/src/ui/inspector.rs b/crates/app/src/ui/inspector.rs index 16c7cfd..cb60d1b 100644 --- a/crates/app/src/ui/inspector.rs +++ b/crates/app/src/ui/inspector.rs @@ -42,9 +42,9 @@ impl Player { .relative() .flex() .flex_col() - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .border_l_1() - .border_color(rgb(STROKE_DIVIDER)) + .border_color(rgb(STROKE_DIVIDER())) .child(section_head("Inspector")) .child( div() @@ -71,8 +71,8 @@ impl Player { .px(px(8.)) .text_size(px(10.)) .text_color(rgb(match below > 1. { - true => ACCENT_PRIMARY, - false => FG_SECONDARY, + true => ACCENT_PRIMARY(), + false => FG_SECONDARY(), })) .child(match below > 1. { true => "more below — scroll the inspector", @@ -124,14 +124,14 @@ impl Player { .gap(px(6.)) .p(px(8.)) .rounded(px(4.)) - .bg(rgb(BG_HOVER_DIM)) + .bg(rgb(BG_HOVER_DIM())) .child( div() .flex_none() .truncate() .text_color(rgb(match picked.is_some() { - true => FG_PRIMARY, - false => FG_SECONDARY, + true => FG_PRIMARY(), + false => FG_SECONDARY(), })) // The kind's own colour, the same one its clip wears on the // timeline: the panel and the box are about the same thing. @@ -146,7 +146,7 @@ impl Player { div() .flex_none() .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(detail), ) .child( @@ -157,7 +157,7 @@ impl Player { .child(self.action_control( "inspect-speed", 0., - BG_RAISED, + BG_RAISED(), None, "Speed", "how fast this clip and its group play", @@ -167,7 +167,7 @@ impl Player { .child(self.action_control( "inspect-color", 0., - BG_RAISED, + BG_RAISED(), None, "Colour", "exposure, contrast, saturation and temperature", @@ -177,7 +177,7 @@ impl Player { .child(self.action_control( "inspect-eq", 0., - BG_RAISED, + BG_RAISED(), None, "Equalizer", "the bands this clip's sound is filtered through", @@ -187,7 +187,7 @@ impl Player { .child(self.action_control( "inspect-silence", 0., - BG_RAISED, + BG_RAISED(), None, "Silence", "finds the quiet stretches and cuts or speeds them", @@ -197,7 +197,7 @@ impl Player { .child(self.action_control( "inspect-fit", 0., - BG_RAISED, + BG_RAISED(), None, "Fit", "how this picture is placed on the project canvas", @@ -207,7 +207,7 @@ impl Player { .child(self.action_control( "inspect-delete", 0., - BG_RAISED, + BG_RAISED(), None, "Delete", "takes this clip off the timeline", @@ -229,12 +229,12 @@ impl Player { .gap(px(6.)) .p(px(8.)) .rounded(px(4.)) - .bg(rgb(BG_HOVER_DIM)) + .bg(rgb(BG_HOVER_DIM())) .child( div() .flex_none() .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child("PROJECT"), ) .child( @@ -245,7 +245,7 @@ impl Player { .child(self.action_control( "resolution", ZOOM_SLOT_W, - BG_RAISED, + BG_RAISED(), None, resolution.map_or_else(|| "Size".to_string(), |(_, h)| format!("{h}p")), "the canvas every clip is composed onto, and the size the export comes out at", @@ -257,7 +257,7 @@ impl Player { .child(self.action_control( "fps", ZOOM_SLOT_W, - BG_RAISED, + BG_RAISED(), None, match self.session.is_some() { true => format!("{} fps", fps_label(self.fps)), @@ -272,7 +272,7 @@ impl Player { .child(self.action_control( "tonemap", TONE_SLOT_W, - BG_RAISED, + BG_RAISED(), None, match &self.session { Some(session) => format!("HDR {}", tone_label(session.tone())), @@ -287,7 +287,7 @@ impl Player { .child(self.action_control( "inspect-mix", 0., - BG_RAISED, + BG_RAISED(), None, "Mix", "a fader per track and the limiter over the sum of them", @@ -307,10 +307,10 @@ pub(crate) fn section_head(title: &'static str) -> impl IntoElement { .flex() .items_center() .px(px(8.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .border_b_1() - .border_color(rgb(STROKE_DIVIDER)) + .border_color(rgb(STROKE_DIVIDER())) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(title) } diff --git a/crates/app/src/ui/library.rs b/crates/app/src/ui/library.rs index f3182a7..32370a2 100644 --- a/crates/app/src/ui/library.rs +++ b/crates/app/src/ui/library.rs @@ -127,10 +127,10 @@ impl Player { .rounded(px(3.)) // A row that cannot be placed takes no click and no drag, and // reads as unavailable rather than merely unlucky. - .when(!usable, |d| d.text_color(rgb(FG_SECONDARY)).opacity(0.55)) + .when(!usable, |d| d.text_color(rgb(FG_SECONDARY())).opacity(0.55)) .when(usable, |d| { d.cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.selected_asset = Some((path.clone(), stream)); cx.notify(); @@ -170,7 +170,7 @@ impl Player { cx.notify(); }), ) - .when(picked, |d| d.bg(rgb(BG_SELECTED)).border_1()) + .when(picked, |d| d.bg(rgb(BG_SELECTED())).border_1()) .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into()) // Full height and hard against the edge: the tint reads as // the lane's colour continuing into the list, not as a chip @@ -205,7 +205,7 @@ impl Player { div() .truncate() .text_size(px(10.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(under), ), ) @@ -220,7 +220,7 @@ impl Player { .flex_col() .gap(px(6.)) .p(px(8.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) // The column itself scrolls at a short window. Its five stacked // things want 140 px and the 640x360 floor gives the region 136, so // the list -- the only child that may shrink -- was being squeezed to @@ -258,19 +258,19 @@ impl Player { .rounded(px(3.)) .text_size(px(11.)) .text_color(rgb(match on { - true => FG_PRIMARY, - false => FG_SECONDARY, + true => FG_PRIMARY(), + false => FG_SECONDARY(), })) // One selection language everywhere: the // same stroke a picked clip and a picked // row wear. .when(on, |d| { - d.bg(rgb(BG_SELECTED)) + d.bg(rgb(BG_SELECTED())) .border_b_2() - .border_color(rgb(STROKE_SELECTED)) + .border_color(rgb(STROKE_SELECTED())) }) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.library_tab = tab; cx.notify(); @@ -294,8 +294,8 @@ impl Player { // the rest of the time, is dimmed until something is // imported. One live accent in the window either way. match rows.is_empty() { - true => ACCENT_PRIMARY, - false => BG_RAISED, + true => ACCENT_PRIMARY(), + false => BG_RAISED(), }, None, "Import", @@ -321,7 +321,7 @@ impl Player { d.child( div() .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(self.library_tab.empty()), ) }) @@ -336,7 +336,7 @@ impl Player { .child(control( "add-asset", 0., - BG_RAISED, + BG_RAISED(), None, "Add at playhead", match self.selected_asset { @@ -442,7 +442,7 @@ impl Player { .min_w(px(0.)) .truncate() .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(value), ) .into_any_element(), @@ -463,13 +463,13 @@ impl Player { div() .min_w(px(0.)) .truncate() - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(refusal.why().unwrap_or_else(|| item.hint())), ) .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) .when(enabled, |d| { d.cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.act_on_row(item, cx); })) @@ -512,7 +512,7 @@ impl Player { .flex_col() .p(px(MENU_PAD)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) // Painted after the scrim, so this listener runs first // and a press meant for an item never closes the menu // out from under its own click (`context_card`). diff --git a/crates/app/src/ui/overlays.rs b/crates/app/src/ui/overlays.rs index 0397c44..4a40c23 100644 --- a/crates/app/src/ui/overlays.rs +++ b/crates/app/src/ui/overlays.rs @@ -41,7 +41,7 @@ impl Player { .gap(px(4.)) .px(px(12.)) .py(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child( div() .flex() @@ -55,7 +55,7 @@ impl Player { 0., // The ordinary plane -- the accent is Export's, and // a way out of a read is not the primary action. - BG_RAISED, + BG_RAISED(), None, "Cancel", "stops this file and anything queued behind it; the read already \ @@ -70,7 +70,7 @@ impl Player { .relative() .w_full() .h(px(2.)) - .bg(rgb(BG_HOVER)) + .bg(rgb(BG_HOVER())) .child( div() .absolute() @@ -82,7 +82,7 @@ impl Player { // paint outside the track. .w(relative((at + SWEEP).min(1.) - at.max(0.))) .h(px(2.)) - .bg(rgb(ACCENT_PRIMARY)), + .bg(rgb(ACCENT_PRIMARY())), ), ), ) @@ -99,7 +99,7 @@ impl Player { .flex_none() .px(px(12.)) .py(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child(line), ) } @@ -159,14 +159,14 @@ impl Player { .gap(px(12.)) .px(px(12.)) .py(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) // The tone is a stripe down the leading edge rather than the // whole bar's colour: a full red bar at every refusal is an // alarm, and most of these are answers. .border_l(px(3.)) .border_color(rgb(tone)) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { // Another process starting: off the UI thread, and it // outlives the notice it was asked from. @@ -190,7 +190,7 @@ impl Player { div() .flex_none() .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(hint), ), ) @@ -266,7 +266,7 @@ impl Player { .px(px(6.)) .pt(px(4.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(category.label()) .into_any_element(), KeyRow::Act(action) => { @@ -276,7 +276,7 @@ impl Player { let refusal = self.enable(action, None); let out = out.clone(); row() - .when(capturing, |d| d.bg(rgb(BG_SELECTED))) + .when(capturing, |d| d.bg(rgb(BG_SELECTED()))) .child( div() .id(("do", i)) @@ -303,7 +303,7 @@ impl Player { }) .when(!refusal.yes(), |d| d.opacity(0.4).cursor_not_allowed()) .when(refusal.yes(), |d| { - d.cursor_pointer().hover(|s| s.bg(rgb(BG_HOVER))).on_click( + d.cursor_pointer().hover(|s| s.bg(rgb(BG_HOVER()))).on_click( cx.listener(move |this, _: &ClickEvent, _, cx| { // The card goes first: several of // these open a card of their own, @@ -329,14 +329,14 @@ impl Player { .min_h(px(KEYS_ROW_H)) .items_center() .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.rebinding = Some(action); cx.notify(); })) .child(if capturing { div() - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(format!("press a key — {out} cancels")) } else { div().child(self.keymap.display(action)) @@ -349,7 +349,7 @@ impl Player { row() .child(f.label) // Dim, and no hover: this one is not a row you can click. - .child(div().text_color(rgb(FG_SECONDARY)).child(f.chord.clone())) + .child(div().text_color(rgb(FG_SECONDARY())).child(f.chord.clone())) .into_any_element() } }); @@ -363,7 +363,7 @@ impl Player { // swallowed here so a button under the scrim cannot take it -- // and it closes the card on the way, which is the pointer's exit // from every card here ([`Player::close_card`]). - .bg(rgba(SCRIM)) + .bg(rgba(SCRIM())) .on_mouse_down( MouseButton::Left, cx.listener(|this, _: &MouseDownEvent, _, cx| { @@ -381,7 +381,7 @@ impl Player { .gap(px(2.)) .p(px(12.)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) // Title and instruction are two children, never one // wrapping line: a fixed-height slot whose text wrapped // painted its second line over the first row. @@ -399,7 +399,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child( self.notices .front() @@ -420,7 +420,7 @@ impl Player { .flex_none() .px(px(6.)) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(search), ) // Capped and scrolling rather than as tall as the action @@ -440,7 +440,7 @@ impl Player { // list with more above it. .mt(px(4.)) .border_t_1() - .border_color(rgb(BG_PANEL)) + .border_color(rgb(BG_PANEL())) .pt(px(4.)) .overflow_y_scroll() // The wheel's offset and the arrow keys' are @@ -523,7 +523,7 @@ impl Player { // pair is 25 characters and has to fit beside // its label inside `MENU_W`. .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(value), ) .into_any_element(), @@ -563,16 +563,16 @@ impl Player { .min_w(px(0.)) .truncate() .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(why), None => div() - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(self.keymap.display(action)), }) .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) .when(enabled, |d| { d.cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| { // Closed first: the action moves the very // indices this menu is holding. @@ -599,7 +599,7 @@ impl Player { rows.push( row(rows.len()) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { if let Some(menu) = &mut this.context_menu { menu.details = true; @@ -609,7 +609,7 @@ impl Player { .child("Properties") // No stroke reaches this one, and a blank column would read // as one that was forgotten. - .child(div().text_color(rgb(FG_SECONDARY)).child("…")) + .child(div().text_color(rgb(FG_SECONDARY())).child("…")) .into_any_element(), ); } @@ -654,7 +654,7 @@ impl Player { .flex_col() .p(px(MENU_PAD)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) // Painted after the scrim, so this listener runs first // (gpui bubbles mouse events in reverse, window.rs:3705) // and a press meant for an item never closes the menu @@ -716,12 +716,17 @@ impl Player { .px(px(6.)) .rounded(px(3.)) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) // The mark is a glyph as well as a highlight, like the // export card's rows: a background alone is gone under a // hover and invisible to anyone who cannot tell the two // greys apart (WCAG 1.4.1). - .when(picked, |d| d.bg(rgb(BG_SELECTED))) + .when(picked, |d| d.bg(rgb(BG_SELECTED()))) + // Where the keyboard is, said after the mark so the cursor + // is visible on the picked row too -- and as a background, + // not a border, because a row that grew a stroke would move + // every row under it. + .when(n == picker.sel, |d| d.bg(rgb(BG_HOVER()))) .child( div() .flex() @@ -742,8 +747,8 @@ impl Player { // On the picked row the dim ink sits on the // highlight, where it is only 3.3:1 (WCAG 1.4.3). .text_color(rgb(match picked { - true => FG_PRIMARY, - false => FG_SECONDARY, + true => FG_PRIMARY(), + false => FG_SECONDARY(), })) .child(detail), ) @@ -788,7 +793,7 @@ impl Player { .flex_col() .p(px(MENU_PAD)) .rounded(px(6.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) // Painted after the scrim, so this listener runs first // and a press meant for a row never closes the list out // from under its own click (`context_card`). diff --git a/crates/app/src/ui/preview.rs b/crates/app/src/ui/preview.rs index b775555..82eaf80 100644 --- a/crates/app/src/ui/preview.rs +++ b/crates/app/src/ui/preview.rs @@ -84,9 +84,9 @@ impl Player { .max_w(relative(0.9)) .px(px(6.)) .rounded(px(3.)) - .bg(rgba(SUB_SHADE)) + .bg(rgba(SUB_SHADE())) .text_size(px(SUB_TEXT)) - .text_color(rgb(SUB_FG)) + .text_color(rgb(SUB_FG())) .text_align(TextAlign::Center) // A line of the cue is a line on screen: the break the // parser kept is not whitespace to be re-flowed. What a diff --git a/crates/app/src/ui/theme.rs b/crates/app/src/ui/theme.rs index 5aba91d..7a7dde4 100644 --- a/crates/app/src/ui/theme.rs +++ b/crates/app/src/ui/theme.rs @@ -7,30 +7,202 @@ //! can be swapped whole without touching a single element. //! //! Which is what the two modules below are for. Both families carry the same -//! role names, so the switch between them is one `use` and no call site knows -//! it happened -- and a role missing from either is a compile error rather than -//! a region that quietly kept the old colour. +//! role names, so the switch between them is one field lookup and no call site +//! knows it happened -- and a role missing from either is a compile error +//! rather than a region that quietly kept the old colour. //! //! * `cool` (default) -- near-black ground, cool neutral chrome, one cyan accent. -//! * `warm` (`--features warm`) -- a deep neutral warmed towards brown so no -//! surface reads as office grey, with one coral accent. +//! * `warm` -- a deep neutral warmed towards brown so no surface reads as +//! office grey, with one coral accent. //! //! Both take the clip bodies from the cross-NLE kind convention (video blue, //! audio green, image teal, text purple) instead of four greys that differ by a //! hair, and both are held to the same measured floors: the contrast guards in -//! `main.rs` run against whichever one is compiled. +//! `main.rs` run against *every* palette in [`PaletteId::ALL`], so a third one +//! lands gated rather than untested. //! -//! ponytail: a compile switch, because every token is a `const` and a runtime -//! palette means a lookup at every paint. Ceiling: the day the palette has to -//! change without a restart, these two modules become two `struct Palette` -//! values and the consts become fields on the one the window holds. +//! Which family is in force is the user's, picked from the toolbar's Theme +//! button or its stroke and kept in `~/.config/edith/theme` beside the +//! keybindings -- it used to be a compile feature, which is a choice only +//! whoever built the binary could make. A token is a call now +//! ([`BG_PANEL()`]): one relaxed load and one field read off a `'static` +//! table, which is what "the palette can be swapped whole" costs at paint time. use engine::project::LaneKind; +use std::path::PathBuf; +use std::sync::atomic::{AtomicUsize, Ordering::Relaxed}; -#[cfg(not(feature = "warm"))] -pub use cool::*; -#[cfg(feature = "warm")] -pub use warm::*; +/// The whole table, once: every role, its type, and the two families' numbers +/// read out of the modules below. One list, so a role added to [`Palette`] +/// without a value in both families is a compile error and a role read at a +/// paint cannot come from anywhere but the palette in force. +macro_rules! palette { + ($($name:ident: $ty:ty),+ $(,)?) => { + /// One family's numbers, in a struct so the set can be swapped whole. + /// Field names are the role names the whole editor already paints by, + /// which is why they shout. + #[allow(non_snake_case)] + #[derive(Clone, Copy, PartialEq, Debug)] + pub struct Palette { $(pub $name: $ty,)+ } + + /// The families in [`PaletteId::ALL`]'s order, so the index the atomic + /// holds is the id itself. + static PALETTES: [Palette; 2] = [ + Palette { $($name: cool::$name,)+ }, + Palette { $($name: warm::$name,)+ }, + ]; + + $( + #[allow(non_snake_case)] + #[inline] + pub fn $name() -> $ty { palette().$name } + )+ + }; +} + +palette! { + BG_CANVAS: u32, + BG_PANEL: u32, + BG_RAISED: u32, + BG_TIMELINE: u32, + BG_HOVER: u32, + BG_HOVER_DIM: u32, + BG_SELECTED: u32, + SCRIM: u32, + SCRIM_LIGHT: u32, + STROKE_DIVIDER: u32, + STROKE_FOCUS: u32, + STROKE_SELECTED: u32, + FG_PRIMARY: u32, + FG_SECONDARY: u32, + FG_DISABLED: u32, + ACCENT_PRIMARY: u32, + ACCENT_HOVER: u32, + ACCENT_PLAYHEAD: u32, + ACCENT_WASH: u32, + CLIP_VIDEO: u32, + CLIP_AUDIO: u32, + CLIP_IMAGE: u32, + CLIP_TEXT: u32, + SOURCE_TINTS: [u32; 4], + STATUS_ERROR: u32, + STATUS_WARNING: u32, + STATUS_SUCCESS: u32, + STATUS_PROGRESS: u32, + DROP_REFUSE: u32, + SUB_FG: u32, + SUB_SHADE: u32, + EQ_GRID: u32, + EQ_SPECTRUM_INK: u32, + EQ_FILL_INK: u32, + EQ_BELL_INK: u32, + HIST_INK: [u32; 3], +} + +/// Which family a person picked. An enum and not a bool: two today, and the +/// door in the toolbar is a list rather than a toggle because the third one +/// must cost a line here and nothing anywhere else. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum PaletteId { + Cool, + Warm, +} + +impl PaletteId { + /// Display order -- the picker lists them in it, and the index into + /// [`PALETTES`] *is* the position in it. + pub const ALL: [PaletteId; 2] = [PaletteId::Cool, PaletteId::Warm]; + + /// What the button and the picker row call it. + pub fn label(self) -> &'static str { + match self { + PaletteId::Cool => "Cool", + PaletteId::Warm => "Warm", + } + } + + /// The small print beside the row: what the family actually looks like, so + /// the choice is made before the click rather than after it. + pub fn detail(self) -> &'static str { + match self { + PaletteId::Cool => "near-black ground, cyan accent", + PaletteId::Warm => "warm ground, coral accent", + } + } + + /// What the file calls it: one word, never the label, which is free to be + /// reworded ([`crate::keymap`]'s rule for the same reason). + pub fn name(self) -> &'static str { + match self { + PaletteId::Cool => "cool", + PaletteId::Warm => "warm", + } + } + + fn from_name(name: &str) -> Option { + Self::ALL.into_iter().find(|p| p.name() == name) + } + + /// The numbers themselves, for anything that has to measure a family that + /// is not the one in force -- which is what the contrast guards do. + pub fn palette(self) -> &'static Palette { + &PALETTES[self as usize] + } +} + +/// The family in force, as an index into [`PALETTES`]. An atomic because a +/// token is read from whatever thread happens to be painting and the value is +/// one `usize`; relaxed because nothing is published *with* it -- the next +/// repaint reads it, and the swap asks for that repaint itself. +static ACTIVE: AtomicUsize = AtomicUsize::new(0); + +/// The numbers every token function reads. One load, one bounds-checked index +/// into a `'static` table: no allocation, no hashing, no lock. +#[inline] +pub fn palette() -> &'static Palette { + PALETTES.get(ACTIVE.load(Relaxed)).unwrap_or(&PALETTES[0]) +} + +/// Which family is in force -- what the button says and the picker marks. +pub fn active() -> PaletteId { + PaletteId::ALL + .get(ACTIVE.load(Relaxed)) + .copied() + .unwrap_or(PaletteId::Cool) +} + +/// Puts `id` in force. Every paint after this reads the new numbers; asking for +/// the repaint is the caller's, since only it holds the window. +pub fn set(id: PaletteId) { + ACTIVE.store(id as usize, Relaxed); +} + +/// Where the pick lives: one word in a file beside the keybindings, so a +/// desktop that names an XDG directory is obeyed for both. +pub fn config_path() -> PathBuf { + crate::keymap::Keymap::config_path().with_file_name("theme") +} + +/// The pick from the last session, if there was one. Anything unreadable or +/// unknown leaves the default in force: a theme file is not the user's work, +/// so a bad one is worth no message at startup. +pub fn load() { + if let Ok(text) = std::fs::read_to_string(config_path()) + && let Some(id) = PaletteId::from_name(text.trim()) + { + set(id); + } +} + +/// Writes the pick. One word, written whole -- a torn write costs the theme and +/// nothing else, and [`load`] falls back to the default on one. +pub fn save(id: PaletteId) -> std::io::Result<()> { + let path = config_path(); + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir)?; + } + std::fs::write(path, format!("{}\n", id.name())) +} /// Family B: near-black ground, cool neutral chrome, one cyan accent. pub mod cool { @@ -195,11 +367,11 @@ pub const GHOST_ALPHA: u32 = 0x66; /// What a clip on `kind` is painted: the timeline's whole colour language in /// one call, so a lane added later cannot invent a shade of its own. -pub const fn clip_kind(kind: LaneKind, image: bool) -> u32 { +pub fn clip_kind(kind: LaneKind, image: bool) -> u32 { match kind { - LaneKind::Audio => CLIP_AUDIO, - LaneKind::Video if image => CLIP_IMAGE, - LaneKind::Video => CLIP_VIDEO, + LaneKind::Audio => CLIP_AUDIO(), + LaneKind::Video if image => CLIP_IMAGE(), + LaneKind::Video => CLIP_VIDEO(), } } @@ -215,13 +387,13 @@ pub const fn clip_kind(kind: LaneKind, image: bool) -> u32 { pub fn notice_tone(message: &str) -> u32 { let has = |word: &str| message.contains(word); if has("FAILED") || has("ERROR") || has("REFUSED") || has("CANNOT") || has("COULD NOT") { - STATUS_ERROR + STATUS_ERROR() } else if message.starts_with(crate::EXPORT_DONE) || has("SAVED") || has("DONE") { - STATUS_SUCCESS + STATUS_SUCCESS() } else if has("NOTHING") || has("NO ") || has("EMPTY") { - STATUS_WARNING + STATUS_WARNING() } else { - ACCENT_PRIMARY + ACCENT_PRIMARY() } } diff --git a/crates/app/src/ui/timeline.rs b/crates/app/src/ui/timeline.rs index 6fc07e3..2e1d44e 100644 --- a/crates/app/src/ui/timeline.rs +++ b/crates/app/src/ui/timeline.rs @@ -137,9 +137,9 @@ impl Player { .gap(px(8.)) .px(px(12.)) .py(px(8.)) - .bg(rgb(BG_TIMELINE)) + .bg(rgb(BG_TIMELINE())) .border_t_1() - .border_color(rgb(STROKE_DIVIDER)) + .border_color(rgb(STROKE_DIVIDER())) .child( div() .flex_none() @@ -169,7 +169,7 @@ impl Player { .min_w(px(0.)) .truncate() .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(hint), ), ) @@ -197,7 +197,7 @@ impl Player { .justify_center() .rounded(px(3.)) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER_DIM))) + .hover(|s| s.bg(rgb(BG_HOVER_DIM()))) // The strip carries no text, so the tooltip is the only // place it can say what it is. .tooltip(|_, cx| { @@ -238,14 +238,14 @@ impl Player { .w_full() .h(px(6.)) .rounded(px(3.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child(bounds_probe(self.ruler.clone())) .child( div() .h_full() .w(px(filled)) .rounded(px(3.)) - .bg(rgb(ACCENT_PRIMARY)), + .bg(rgb(ACCENT_PRIMARY())), ), ), ), @@ -288,8 +288,8 @@ impl Player { .justify_end() .text_size(px(10.)) .text_color(rgb(match below { - 0 => FG_SECONDARY, - _ => ACCENT_PRIMARY, + 0 => FG_SECONDARY(), + _ => ACCENT_PRIMARY(), })) .child(match below { 0 => "the last track — scroll up for the rest".to_string(), @@ -400,10 +400,10 @@ impl Player { .gap(px(6.)) .pr(px(6.)) .rounded(px(3.)) - .when(!usable, |d| d.text_color(rgb(FG_SECONDARY)).opacity(0.55)) + .when(!usable, |d| d.text_color(rgb(FG_SECONDARY())).opacity(0.55)) .when(usable, |d| { d.cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.sub_track = track; // Picking a track is asking to see it: a @@ -414,7 +414,7 @@ impl Player { cx.notify(); })) }) - .when(picked, |d| d.bg(rgb(BG_SELECTED))) + .when(picked, |d| d.bg(rgb(BG_SELECTED()))) .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into()) // The media rows' bar, same width and hard against // the same edge: one association across the panel @@ -452,7 +452,7 @@ impl Player { // still there, out of // the way. .when(headed, |d| { - d.text_color(rgb(FG_SECONDARY)) + d.text_color(rgb(FG_SECONDARY())) }) .child(format!("{prefix} · ")), ) @@ -469,7 +469,7 @@ impl Player { div() .truncate() .text_size(px(10.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(row.detail), ), ) @@ -491,7 +491,7 @@ impl Player { .justify_center() .rounded(px(3.)) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .tooltip(move |_, cx| cx.new(|_| Tip(remove_tip.clone())).into()) .on_click(cx.listener( move |this, _: &ClickEvent, _, cx| { @@ -520,7 +520,7 @@ impl Player { .items_center() .gap(px(6.)) .text_size(px(10.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .when_some(tint, |d, tint| { d.child( div() @@ -547,7 +547,7 @@ impl Player { div() .truncate() .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(match (self.subs_on, sub_pick_name(tracks, self.sub_track)) { // Which of them is on screen, named by its film: // the heading over a list of five is where the one @@ -602,7 +602,7 @@ impl Player { // whose subtitles these are before the tooltip is asked. `None` for a // standalone `.srt` -- nobody's stream, and the first film's colour // would be a lie about where it came from. - let tint = file_tint(self.sources(), &track.path).unwrap_or(BG_RAISED); + let tint = file_tint(self.sources(), &track.path).unwrap_or(BG_RAISED()); // The whole of what the row says in words, since a 40 px column can hold // three characters of it: which track of which file, how many cues, the // file itself in full -- one stem is two films when they are two cuts of @@ -657,7 +657,7 @@ impl Player { .rounded(px(3.)) .bg(rgb(tint)) .text_size(px(9.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .truncate() .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into()) .child(label), @@ -669,7 +669,7 @@ impl Player { .min_w(px(0.)) .h_full() .rounded(px(3.)) - .bg(rgb(BG_TIMELINE)) + .bg(rgb(BG_TIMELINE())) .overflow_hidden() .children(cues.into_iter().map(|(left, width)| { div() @@ -679,7 +679,7 @@ impl Player { .left(px(left)) .w(px(width)) .rounded(px(2.)) - .bg(rgb(BG_SELECTED)) + .bg(rgb(BG_SELECTED())) })) // The playhead again, last and in the lanes' own colour: // the strip is only worth anything beside them if it @@ -691,7 +691,7 @@ impl Player { .h_full() .left(px(filled)) .w(px(2.)) - .bg(rgb(ACCENT_PLAYHEAD)), + .bg(rgb(ACCENT_PLAYHEAD())), ), ), ) @@ -800,9 +800,9 @@ impl Player { .items_center() .justify_center() .rounded(px(3.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .text_size(px(11.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(match audio { // A button, not a label: the one setting a track has of // its own used to be reachable from nowhere. @@ -815,7 +815,7 @@ impl Player { .justify_center() .rounded(px(3.)) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .tooltip(move |_, cx| cx.new(|_| Tip(gain_tip.clone())).into()) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.open_mix(Some(lane), cx) @@ -848,7 +848,7 @@ impl Player { .justify_center() .rounded(px(3.)) .cursor_pointer() - .hover(|s| s.bg(rgb(BG_HOVER))) + .hover(|s| s.bg(rgb(BG_HOVER()))) .tooltip(move |_, cx| cx.new(|_| Tip(remove_tip.clone())).into()) .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { this.remove_lane(lane, cx) @@ -866,7 +866,7 @@ impl Player { .min_w(px(0.)) .h_full() .rounded(px(3.)) - .bg(rgb(BG_TIMELINE)) + .bg(rgb(BG_TIMELINE())) .overflow_hidden() // A library row let go over a lane is the same insert the // Add button makes, through the same call -- but where the @@ -882,7 +882,7 @@ impl Player { let at = this.place_frame(window.mouse_position().x).0; this.insert_source(&drag.0.clone(), drag.1, Some(lane), Some(at), cx) })) - .drag_over::(|s, _, _, _| s.bg(rgb(BG_HOVER_DIM))) + .drag_over::(|s, _, _, _| s.bg(rgb(BG_HOVER_DIM()))) // The shadow of the row in flight, drawn by the lane the // pointer is inside: `on_drag_move` fires on every painted // element while a drag of its type is live, wherever the @@ -913,7 +913,7 @@ impl Player { }; this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx) })) - .drag_over::(|s, _, _, _| s.bg(rgb(BG_HOVER_DIM))) + .drag_over::(|s, _, _, _| s.bg(rgb(BG_HOVER_DIM()))) // ...and the same shadow for the clip in the hand, seated on // this lane when the pointer is inside it. .on_drag_move(cx.listener( @@ -1018,15 +1018,15 @@ impl Player { .rounded(px(3.)) .border_1() .border_color(rgb(if on { - STROKE_SELECTED + STROKE_SELECTED() } else if grouped { tint } else { - FG_SECONDARY + FG_SECONDARY() })) - .bg(rgb(if on { BG_SELECTED } else { kind })) + .bg(rgb(if on { BG_SELECTED() } else { kind })) .cursor_pointer() - .hover(|s| s.border_color(rgb(ACCENT_PRIMARY))) + .hover(|s| s.border_color(rgb(ACCENT_PRIMARY()))) .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into()) // Dragged, it *moves*: to the frame it was let go on // and to the lane it was let go over. The click that @@ -1087,7 +1087,7 @@ impl Player { .w(px(EDGE_W)) .occlude() .cursor(CursorStyle::ResizeLeftRight) - .hover(|s| s.bg(rgb(ACCENT_PRIMARY))) + .hover(|s| s.bg(rgb(ACCENT_PRIMARY()))) .on_mouse_down( MouseButton::Left, cx.listener( @@ -1129,7 +1129,7 @@ impl Player { .h_full() .flex() .items_center() - .child(div().w_full().h(px(1.)).bg(rgb(BG_HOVER))) + .child(div().w_full().h(px(1.)).bg(rgb(BG_HOVER()))) .into_any_element(), // No audio track: nothing, never a fake. Wave::Silent => return None, @@ -1144,7 +1144,7 @@ impl Player { .justify_center() .truncate() .text_size(px(9.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child("audio unreadable") .into_any_element(), }; @@ -1184,9 +1184,9 @@ impl Player { .flex_none() .px(px(3.)) .rounded(px(3.)) - .bg(rgb(ACCENT_PRIMARY)) + .bg(rgb(ACCENT_PRIMARY())) .text_size(px(9.)) - .text_color(rgb(BG_RAISED)) + .text_color(rgb(BG_RAISED())) .child(format!("{}", clip.speed)), ), ) @@ -1232,7 +1232,7 @@ impl Player { .w(px(scale .width_px(f64::from(len) / self.fps) .max(SUB_CUE_MIN_W))) - .bg(rgba(ACCENT_WASH)) + .bg(rgba(ACCENT_WASH())) }), ) // Where the thing in the hand would come to rest, at the size @@ -1254,13 +1254,13 @@ impl Player { .max(GHOST_MIN))) .rounded(px(3.)) .border_1() - .border_color(rgb(if g.refused { DROP_REFUSE } else { FG_PRIMARY })) + .border_color(rgb(if g.refused { DROP_REFUSE() } else { FG_PRIMARY() })) // The file's own swatch at a third of its weight, so // the box beneath is still legible through it -- and // the refusal red instead, for a lane that will not // take this drop at all. .bg(rgba( - ((if g.refused { DROP_REFUSE } else { g.tint }) << 8) | GHOST_ALPHA, + ((if g.refused { DROP_REFUSE() } else { g.tint }) << 8) | GHOST_ALPHA, )) })) // What the gesture in flight is about to land on, drawn on @@ -1275,7 +1275,7 @@ impl Player { .h_full() .left(px(x)) .w(px(1.)) - .bg(rgb(FG_PRIMARY)) + .bg(rgb(FG_PRIMARY())) })) // Last, so it is over the clips: the same fraction in both // lanes, which is the playhead being one line. @@ -1286,7 +1286,7 @@ impl Player { .h_full() .left(px(filled)) .w(px(2.)) - .bg(rgb(ACCENT_PLAYHEAD)), + .bg(rgb(ACCENT_PLAYHEAD())), ), ) } diff --git a/crates/app/src/ui/toolbar.rs b/crates/app/src/ui/toolbar.rs index c84e2cb..861f902 100644 --- a/crates/app/src/ui/toolbar.rs +++ b/crates/app/src/ui/toolbar.rs @@ -58,16 +58,16 @@ impl Player { .items_center() .gap(px(8.)) .px(px(12.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .border_b_1() - .border_color(rgb(STROKE_DIVIDER)) + .border_color(rgb(STROKE_DIVIDER())) .child( div() .flex_none() .w(px(10.)) .h(px(10.)) .rounded(px(2.)) - .bg(rgb(ACCENT_PRIMARY)), + .bg(rgb(ACCENT_PRIMARY())), ) .child( div() @@ -79,7 +79,7 @@ impl Player { .child(self.action_control( "save", 0., - BG_RAISED, + BG_RAISED(), None, "Save", "writes the project file", @@ -98,7 +98,7 @@ impl Player { // The one accented button in the window: the primary // action of an editor, where every consumer editor puts // it. Cancel keeps the rect and the accent both. - ACCENT_PRIMARY, + ACCENT_PRIMARY(), None, if exporting { "Cancel" } else { "Export" }, if exporting { @@ -150,13 +150,13 @@ impl Player { .items_center() .gap(px(8.)) .px(px(12.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .border_t_1() - .border_color(rgb(STROKE_DIVIDER)) + .border_color(rgb(STROKE_DIVIDER())) .child(self.action_control( "transport", 40., - BG_RAISED, + BG_RAISED(), Some(transport_glyph(state).into_any_element()), "", "plays and pauses the timeline", @@ -171,7 +171,7 @@ impl Player { .flex_none() .w(px(clock_w)) .truncate() - .text_color(rgb(FG_PRIMARY)) + .text_color(rgb(FG_PRIMARY())) .child(format!( "{} / {}", timecode(position, self.fps), @@ -190,7 +190,7 @@ impl Player { .child(self.action_control( "volume", VOLUME_SLOT_W, - BG_RAISED, + BG_RAISED(), None, // The level is the label either way and it lives in a fixed // rect: muting adds a mark and changes the colour, where it @@ -207,8 +207,8 @@ impl Player { }), )) .text_color(rgb(match muted { - true => STATUS_WARNING, - false => FG_PRIMARY, + true => STATUS_WARNING(), + false => FG_PRIMARY(), })) .when(slider, |d| { d.child(volume_slider( @@ -237,9 +237,9 @@ impl Player { .items_center() .gap(px(8.)) .px(px(12.)) - .bg(rgb(BG_PANEL)) + .bg(rgb(BG_PANEL())) .border_t_1() - .border_color(rgb(STROKE_DIVIDER)) + .border_color(rgb(STROKE_DIVIDER())) .child( div() .id("controls") @@ -253,7 +253,7 @@ impl Player { .child(self.action_control( "cut", 0., - BG_RAISED, + BG_RAISED(), Some(cut_glyph().into_any_element()), "Split", "splits the clip under the playhead", @@ -263,7 +263,7 @@ impl Player { .child(self.action_control( "delete", 0., - BG_RAISED, + BG_RAISED(), Some(delete_glyph().into_any_element()), "Delete", "takes the marked clip off the timeline", @@ -273,7 +273,7 @@ impl Player { .child(self.action_control( "undo", 0., - BG_RAISED, + BG_RAISED(), None, "Undo", "takes the last edit back", @@ -285,7 +285,7 @@ impl Player { .child(self.action_control( "add-video-lane", 0., - BG_RAISED, + BG_RAISED(), None, "+ V", "adds a video track under the ones there", @@ -297,7 +297,7 @@ impl Player { .child(self.action_control( "add-audio-lane", 0., - BG_RAISED, + BG_RAISED(), None, "+ A", "adds an audio track under the ones there", @@ -309,7 +309,7 @@ impl Player { .child(self.action_control( "add-subtitle-track", 0., - BG_RAISED, + BG_RAISED(), None, "+ S", "adds every subtitle track in a file you pick", @@ -326,7 +326,7 @@ impl Player { .child(self.action_control( "snap", SNAP_SLOT_W, - BG_RAISED, + BG_RAISED(), None, if self.snap { "Snap on" } else { "Snap off" }, match self.snap { @@ -339,7 +339,7 @@ impl Player { .child(self.action_control( "subs", SNAP_SLOT_W, - BG_RAISED, + BG_RAISED(), None, match (self.subtitle_track().is_some(), self.subs_on) { (false, _) => "No subs", @@ -350,11 +350,23 @@ impl Player { ActionId::ToggleSubtitles, cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_subtitles(cx)), )) + .child(self.action_control( + "theme", + THEME_SLOT_W, + BG_RAISED(), + None, + format!("Theme: {}", crate::ui::theme::active().label()), + "the colours this window is painted in; kept in ~/.config/edith/theme", + ActionId::Theme, + cx.listener(|this, event: &ClickEvent, _, cx| { + this.open_picker(Pick::Theme, event.position(), cx) + }), + )) .child(separator()) .child(self.action_control( "zoom-out", CONTROL_H, - BG_RAISED, + BG_RAISED(), None, "−", "show more of the timeline; stops with all of it on the bed", @@ -366,7 +378,7 @@ impl Player { .child(self.action_control( "zoom-fit", ZOOM_SLOT_W, - BG_RAISED, + BG_RAISED(), None, span_label(self.view().span()), "fit the whole timeline on the bed", @@ -376,7 +388,7 @@ impl Player { .child(self.action_control( "zoom-in", CONTROL_H, - BG_RAISED, + BG_RAISED(), None, "+", "magnify around the playhead; ctrl+wheel on the ruler zooms at the pointer", @@ -386,7 +398,7 @@ impl Player { .child(self.action_control( "keys", 0., - BG_RAISED, + BG_RAISED(), None, "Actions", "do any action, or change the key that does it", @@ -406,7 +418,7 @@ impl Player { .child(control( "controls-more", CONTROL_H, - BG_RAISED, + BG_RAISED(), None, "⋯", format!( @@ -434,6 +446,10 @@ pub(crate) const ZOOM_SLOT_W: f32 = 76.; pub(crate) const VOLUME_SLOT_W: f32 = 76.; /// The HDR rendition's names are the longest words on any button here. pub(crate) const TONE_SLOT_W: f32 = 148.; +/// "Theme: " and the longest palette name: a fixed rect like the two toggles +/// beside it, so picking a palette repaints the button without moving the ones +/// after it. +pub(crate) const THEME_SLOT_W: f32 = 96.; /// The width the transport strip needs before the level's bar fits beside the /// clock: play + clock + the mute button + the bar, in their gaps. diff --git a/crates/app/src/ui/widgets.rs b/crates/app/src/ui/widgets.rs index a5348f8..82d2200 100644 --- a/crates/app/src/ui/widgets.rs +++ b/crates/app/src/ui/widgets.rs @@ -28,7 +28,7 @@ pub(crate) fn waveform(peaks: Arc>, from: f64, to: f64) -> impl let mut path = PathBuilder::fill(); path.add_polygon(&points, true); if let Ok(path) = path.build() { - window.paint_path(path, rgb(FG_SECONDARY)); + window.paint_path(path, rgb(FG_SECONDARY())); } }, ) @@ -72,7 +72,7 @@ pub(crate) fn control( .when(w > 0., |d| d.w(px(w)).overflow_hidden()) .rounded(px(4.)) .bg(rgb(bg)) - .when(bg == ACCENT_PRIMARY, |d| d.text_color(rgb(BG_CANVAS))) + .when(bg == ACCENT_PRIMARY(), |d| d.text_color(rgb(BG_CANVAS()))) // A glyph sits in a box of its own width, never in the width it happens // to draw: the pause bars are 12 px wide and the play triangle is 11, so // pressing Play used to slide every button in the row one pixel left. A @@ -95,9 +95,9 @@ pub(crate) fn control( // turning itself off. d.cursor_pointer() .hover(move |s| { - s.bg(rgb(match bg == ACCENT_PRIMARY { - true => ACCENT_HOVER, - false => BG_HOVER, + s.bg(rgb(match bg == ACCENT_PRIMARY() { + true => ACCENT_HOVER(), + false => BG_HOVER(), })) }) .on_click(on_click) @@ -146,13 +146,13 @@ pub(crate) fn volume_slider( .w_full() .h(px(4.)) .rounded(px(2.)) - .bg(rgb(BG_RAISED)) + .bg(rgb(BG_RAISED())) .child( div() .h_full() .w(relative(volume.along())) .rounded(px(2.)) - .bg(rgb(if volume.muted { FG_SECONDARY } else { ACCENT_PRIMARY })), + .bg(rgb(if volume.muted { FG_SECONDARY() } else { ACCENT_PRIMARY() })), ), ) } @@ -165,7 +165,7 @@ pub(crate) fn group_label(name: &'static str) -> impl IntoElement { div() .flex_none() .text_size(px(10.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child(name) } @@ -175,7 +175,7 @@ pub(crate) fn separator() -> impl IntoElement { .mx(px(4.)) .w(px(1.)) .h(px(18.)) - .bg(rgb(BG_HOVER)) + .bg(rgb(BG_HOVER())) } /// Whether a card or a menu is drawn over the window, as the hover labels see @@ -209,9 +209,9 @@ impl Render for Tip { .py(px(3.)) .rounded(px(3.)) .border_1() - .border_color(rgb(BG_RAISED)) - .bg(rgb(BG_PANEL)) - .text_color(rgb(FG_PRIMARY)) + .border_color(rgb(BG_RAISED())) + .bg(rgb(BG_PANEL())) + .text_color(rgb(FG_PRIMARY())) .text_size(px(12.)) .child(self.0.clone()) } @@ -231,7 +231,7 @@ pub(crate) fn cut_glyph() -> impl IntoElement { path.move_to(point(o.x + s.width * 0.85, o.y + s.height)); path.line_to(point(o.x + s.width * 0.1, o.y + s.height * 0.1)); if let Ok(path) = path.build() { - window.paint_path(path, rgb(FG_PRIMARY)); + window.paint_path(path, rgb(FG_PRIMARY())); } }, ) @@ -246,8 +246,8 @@ pub(crate) fn delete_glyph() -> impl IntoElement { .flex_col() .items_center() .gap(px(2.)) - .child(div().w(px(13.)).h(px(2.)).bg(rgb(FG_PRIMARY))) - .child(div().w(px(9.)).h(px(9.)).bg(rgb(FG_PRIMARY))) + .child(div().w(px(13.)).h(px(2.)).bg(rgb(FG_PRIMARY()))) + .child(div().w(px(9.)).h(px(9.)).bg(rgb(FG_PRIMARY()))) } /// What a window with no file open is waiting for. Both ways in are already @@ -259,7 +259,7 @@ pub(crate) fn empty_hint() -> impl IntoElement { .flex_col() .items_center() .gap(px(6.)) - .text_color(rgb(FG_SECONDARY)) + .text_color(rgb(FG_SECONDARY())) .child("Drop a video or an .edith project here") .child( div() @@ -279,8 +279,8 @@ pub(crate) fn transport_glyph(state: Transport) -> impl IntoElement { .items_center() .gap(px(4.)) .when(playing, |d| { - d.child(div().w(px(3.)).h(px(12.)).bg(rgb(FG_PRIMARY))) - .child(div().w(px(3.)).h(px(12.)).bg(rgb(FG_PRIMARY))) + d.child(div().w(px(3.)).h(px(12.)).bg(rgb(FG_PRIMARY()))) + .child(div().w(px(3.)).h(px(12.)).bg(rgb(FG_PRIMARY()))) }) .when(!playing, |d| { d.child( @@ -294,7 +294,7 @@ pub(crate) fn transport_glyph(state: Transport) -> impl IntoElement { path.line_to(point(o.x, o.y + s.height)); path.close(); if let Ok(path) = path.build() { - window.paint_path(path, rgb(FG_PRIMARY)); + window.paint_path(path, rgb(FG_PRIMARY())); } }, )