From dd4bbea11c6abf972d585481bd937cbff890854b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 19 Aug 2026 21:12:05 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(app):=20subtitle=20cue=20font?= =?UTF-8?q?=20and=20size=20are=20the=20user's=20to=20choose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A subtitle-style file beside the theme holds a family and a size (10-28, default 14); the cue plate reads them live and the line height scales on the stock ratio. New card lists every system family plus the platform default, opened from the inspector's Font control or y. A file the format could not have written falls back whole to the defaults. --- crates/app/src/keymap.rs | 15 ++- crates/app/src/main.rs | 29 ++++++ crates/app/src/oracle.rs | 4 +- crates/app/src/player/actions.rs | 1 + crates/app/src/player/cards.rs | 53 +++++++++++ crates/app/src/render.rs | 30 ++++++ crates/app/src/subs.rs | 51 +++++++++++ crates/app/src/tests/editing.rs | 4 +- crates/app/src/tests/layout.rs | 2 +- crates/app/src/tests/media.rs | 65 +++++++++++++ crates/app/src/ui/cards.rs | 153 +++++++++++++++++++++++++++++++ crates/app/src/ui/inspector.rs | 11 +++ crates/app/src/ui/preview.rs | 13 +-- 13 files changed, 421 insertions(+), 10 deletions(-) diff --git a/crates/app/src/keymap.rs b/crates/app/src/keymap.rs index f8fac03..cdac516 100644 --- a/crates/app/src/keymap.rs +++ b/crates/app/src/keymap.rs @@ -146,6 +146,9 @@ actions! { /// own picture or a library preview's, since both write through the one /// `self.image` the atlas already holds. Screenshot, + /// The cue plate's font and size -- a person's own preference, kept + /// beside the theme and not the project, and opened the same way. + SubtitleStyle, } impl ActionId { @@ -208,6 +211,7 @@ impl ActionId { ActionId::CancelExport => "Cancel export", ActionId::ShowActions => "All actions and their keys…", ActionId::Screenshot => "Save the frame on screen as a PNG", + ActionId::SubtitleStyle => "Subtitle style: font and size…", } } @@ -268,6 +272,7 @@ impl ActionId { ActionId::CancelExport => "cancel-export", ActionId::ShowActions => "show-actions", ActionId::Screenshot => "screenshot", + ActionId::SubtitleStyle => "subtitle-style", } } @@ -329,6 +334,9 @@ impl ActionId { // ...and what the whole window is painted in: it edits nothing at // all, it is what one is looking *with*. | ActionId::Theme + // ...and what the cue plate is drawn in: a person's own reading + // preference, same as the theme beside it. + | ActionId::SubtitleStyle // ...and whether that window fills the screen: a way of looking, // same as the zoom and the theme beside it. | ActionId::Fullscreen => Category::View, @@ -944,6 +952,10 @@ impl Keymap { // "w" is free entirely, bare and ctrl both -- nothing else in // this table answers to it. b(ActionId::Screenshot, "w", false), + // Bare "y" is free entirely, and unshifted: a preference + // opened as often as the theme, not a switch thrown once a + // session. + b(ActionId::SubtitleStyle, "y", false), ], } } @@ -1207,9 +1219,10 @@ mod tests { #[test] fn every_default_stroke_reaches_its_action() { let k = Keymap::defaults(); - assert_eq!(k.entries().len(), 55); + assert_eq!(k.entries().len(), 56); assert_eq!(k.lookup("f11", false), Some(ActionId::Fullscreen)); assert_eq!(k.lookup("w", false), Some(ActionId::Screenshot)); + assert_eq!(k.lookup("y", false), Some(ActionId::SubtitleStyle)); assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies)); assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies)); assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions)); diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index c82d272..e81678c 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -510,6 +510,27 @@ struct Player { /// or its switch. The card's own focus, since nothing in it takes gpui's /// (ledger:182). mix_field: usize, + /// The cue plate's own size, in force this session and kept in + /// `~/.config/edith/subtitle-style` beside the keybindings -- an + /// app-global preference like the theme, since export never burns + /// subtitles into the picture. [`SUB_TEXT`] is the default it opens at, + /// never the value read at paint; [`sub_line_h`](Player::sub_line_h) is + /// what preview.rs reads for the line height, derived from this. + sub_text: f32, + /// Which family the cue plate draws in, or the platform default with + /// nothing picked -- `None` calls no [`gpui::Styled::font_family`] at + /// all, which is what leaves the window's own choice in force. + sub_family: Option, + /// The subtitle style card is up. + subtitle_style_open: bool, + /// Which of its rows the arrow keys move: 0 is the size stepper, every + /// row after it a family in [`Self::subtitle_fonts`]. The card's own + /// focus, since nothing in it takes gpui's (ledger:182). + subtitle_style_field: usize, + /// Every family the platform can draw, asked for once when the card + /// opens and kept for as long as it is up: [`gpui::TextSystem::all_font_names`] + /// walks the whole font registry, which is not a repaint's business. + subtitle_fonts: Vec, /// The silence card is up on this clip -- the lane it is on and its index /// there, exactly as the speed card's handle is. silence_open: Option<(Lane, usize)>, @@ -628,6 +649,9 @@ fn main() { // 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(); + // The subtitle style the last session picked, same silence on a missing + // or unreadable file. + let (sub_family, sub_text) = load_subtitle_style(); // 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 @@ -778,6 +802,11 @@ fn main() { pending_speed: None, mix_open: false, mix_field: 0, + sub_text, + sub_family, + subtitle_style_open: false, + subtitle_style_field: 0, + subtitle_fonts: Vec::new(), silence_open: None, // The conservative defaults the engine documents: a first // scan that leaves a little too much is one nobody undoes. diff --git a/crates/app/src/oracle.rs b/crates/app/src/oracle.rs index 9f81fe0..eeeeb9a 100644 --- a/crates/app/src/oracle.rs +++ b/crates/app/src/oracle.rs @@ -100,7 +100,9 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { // reading one, which is the only state that dims the list above. // ...and whether that window fills the screen: also always there, also // touching no timeline, live through an export the same way. - if action == ActionId::Theme || action == ActionId::Fullscreen { + // ...and the cue plate's own font and size: a reading preference like the + // theme, never burned into an export, live the same way. + if action == ActionId::Theme || action == ActionId::Fullscreen || action == ActionId::SubtitleStyle { return Enable::Yes; } if action == ActionId::ShowActions { diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index b467af0..5f8bdc6 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -89,6 +89,7 @@ impl Player { ActionId::Speed => self.open_speed(cx), ActionId::Silence => self.open_silence(cx), ActionId::Mix => self.open_mix(None, cx), + ActionId::SubtitleStyle => self.open_subtitle_style(cx), ActionId::ToggleSnap => self.toggle_snap(cx), ActionId::ToggleSubtitles => self.toggle_subtitles(cx), ActionId::ToggleProxies => self.toggle_proxies(cx), diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index 8d858d1..6b04682 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -658,6 +658,57 @@ impl Player { cx.notify(); } + /// Opens the subtitle style card: the platform's font list, asked for + /// once and kept while the card is up, and the size stepper beside it. + /// Nothing here is a clip's or even the project's -- it never reaches the + /// export, which never burns a cue into the picture -- so like the mix + /// card it opens with no timeline required and nothing to refuse. + pub(crate) fn open_subtitle_style(&mut self, cx: &mut Context) { + self.subtitle_fonts = cx.text_system().all_font_names(); + self.subtitle_style_open = true; + self.subtitle_style_field = 0; + // One card at a time, the rule the other five follow. + self.keys_open = false; + self.export_open = false; + self.eq_open = None; + self.color_open = None; + self.speed_open = None; + self.mix_open = false; + self.close_silence(); + self.context_menu = None; + cx.notify(); + } + + /// Picks a family outright -- a click on a row, the card's rule for a + /// list rather than a stepper. `None` is the top row, the platform's own + /// choice, which is what a family nobody can spell as a fallback would + /// leave silently wrong instead. + pub(crate) fn set_sub_family(&mut self, family: Option, cx: &mut Context) { + self.sub_family = family; + self.keep_subtitle_style(cx); + } + + /// One [`SUB_SIZE_STEP`] per keystroke or stepper press, clamped to + /// [`SUB_SIZE_RANGE`]. + pub(crate) fn nudge_sub_size(&mut self, steps: i32, cx: &mut Context) { + self.sub_text = (self.sub_text + steps as f32 * SUB_SIZE_STEP) + .clamp(SUB_SIZE_RANGE.0, SUB_SIZE_RANGE.1); + self.keep_subtitle_style(cx); + } + + /// Writes the style to disk and repaints: every change to either field + /// goes through here, so the file on disk and the plate on screen never + /// disagree about which session's edit is in force. + fn keep_subtitle_style(&mut self, cx: &mut Context) { + if let Err(e) = save_subtitle_style(self.sub_family.as_deref(), self.sub_text) { + let path = subtitle_style_path(); + self.notify_user( + format!("SUBTITLE STYLE COULD NOT BE KEPT — {} — {e}", path.display()).into(), + ); + } + cx.notify(); + } + /// Closes it and drops the preview with it: marks left on the lane after /// the card is gone would name frames the next edit has already moved. pub(crate) fn close_silence(&mut self) { @@ -1012,6 +1063,7 @@ impl Player { || self.speed_open.is_some() || self.silence_open.is_some() || self.mix_open + || self.subtitle_style_open || self.exporting().is_some() } @@ -1042,6 +1094,7 @@ impl Player { self.close_silence(); } self.mix_open = false; + self.subtitle_style_open = false; } /// Opens the equalizer on the selected clip. Audio only, and it says so diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index d3e1c9a..bcda1d9 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -434,6 +434,36 @@ impl Render for Player { cx.notify(); return; } + // The subtitle style card, the same way again: row 0 is the + // size stepper (←→ moves it, held or pressed, the mix card's + // rule) and every row after it a family in + // `subtitle_fonts` -- ↑↓ walk the whole list and `enter` + // picks the one the arrows are on, since a hand with no + // mouse still has to be able to leave the platform default. + if this.subtitle_style_open { + // Row 0 is the size stepper, row 1 the platform default, + // and every row after it a family in `subtitle_fonts`. + let rows = 2 + this.subtitle_fonts.len(); + if key == ESCAPE { + this.subtitle_style_open = false; + } else if key == "down" { + this.subtitle_style_field = (this.subtitle_style_field + 1) % rows; + } else if key == "up" { + this.subtitle_style_field = + (this.subtitle_style_field + rows - 1) % rows; + } else if key == "right" { + this.nudge_sub_size(1, cx); + } else if key == "left" { + this.nudge_sub_size(-1, cx); + } else if key == "enter" && this.subtitle_style_field == 1 { + this.set_sub_family(None, cx); + } else if key == "enter" && this.subtitle_style_field > 1 { + let family = this.subtitle_fonts[this.subtitle_style_field - 2].clone(); + this.set_sub_family(Some(family), cx); + } + cx.notify(); + return; + } // A clip menu names an index, and every edit below moves // indices -- so a stroke closes it before it acts. Escape means // that and nothing else, which is the `esc` the keys menu diff --git a/crates/app/src/subs.rs b/crates/app/src/subs.rs index 87e9a5c..bb09d35 100644 --- a/crates/app/src/subs.rs +++ b/crates/app/src/subs.rs @@ -2,6 +2,57 @@ use crate::*; +/// One press of the size stepper, and how far it may be pushed: below +/// [`SUB_SIZE_RANGE`].0 a plate is unreadable, above its top it eats the +/// smallest picture the layout floor promises ([`the_subtitle_plate_and_lanes_fit_the_smallest_window`]). +pub(crate) const SUB_SIZE_STEP: f32 = 1.; +pub(crate) const SUB_SIZE_RANGE: (f32, f32) = (10., 28.); + +/// The cue's line height at `size`, on the ratio the defaults draw at +/// ([`SUB_LINE_H`] over [`SUB_TEXT`]): a bigger cue wants a taller line, not +/// just bigger letters on the old one. +pub(crate) fn sub_line_h_for(size: f32) -> f32 { + size * SUB_LINE_H / SUB_TEXT +} + +/// Where the subtitle style survives: beside the keybindings and the theme, +/// same corner-cut persistence -- a torn write costs the style and nothing +/// else, and [`load_subtitle_style`] falls back to the defaults on one. +pub(crate) fn subtitle_style_path() -> PathBuf { + crate::keymap::Keymap::config_path().with_file_name("subtitle-style") +} + +/// Two lines: the family (empty for the system default) and the size. +/// Anything unreadable, missing or out of range leaves the defaults in +/// force -- a subtitle style file is not the user's work, so a bad one is +/// worth no message at startup, exactly as [`ui::theme::load`]. +pub(crate) fn load_subtitle_style() -> (Option, f32) { + let Ok(text) = std::fs::read_to_string(subtitle_style_path()) else { + return (None, SUB_TEXT); + }; + let mut lines = text.lines(); + let family = lines.next().filter(|l| !l.is_empty()).map(str::to_string); + // A size this format could not have written means the file is not this + // format at all -- the family line is then noise too, not a font. + let Some(size) = lines + .next() + .and_then(|l| l.trim().parse::().ok()) + .filter(|s| (SUB_SIZE_RANGE.0..=SUB_SIZE_RANGE.1).contains(s)) + else { + return (None, SUB_TEXT); + }; + (family, size) +} + +/// Writes the style whole, the way [`ui::theme::save`] writes the palette. +pub(crate) fn save_subtitle_style(family: Option<&str>, size: f32) -> std::io::Result<()> { + let path = subtitle_style_path(); + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir)?; + } + std::fs::write(path, format!("{}\n{size}\n", family.unwrap_or(""))) +} + /// Whether a dropped or named path is a subtitle file rather than media: the /// formats `engine::subtitle` parses, lowercased, for [`engine::is_audio`]'s /// reason -- the import door has to know which of the engine's two doors a file diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index 67fcfed..87a23cb 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -890,7 +890,8 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { // edit list either. let allowed = action == ActionId::CancelExport || action == ActionId::Theme - || action == ActionId::Fullscreen; + || action == ActionId::Fullscreen + || action == ActionId::SubtitleStyle; assert_eq!( whole(action, busy).yes(), allowed, @@ -1206,6 +1207,7 @@ fn every_card_closes_without_the_keyboard() { "speed_card", "mix_card", "silence_card", + "subtitle_style_card", ] { let src = fn_body(card); assert!( diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index 4751983..047fed1 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -175,7 +175,7 @@ fn an_inspector_section_occludes_no_timeline() { // leave this rule reading a file the render is no longer in. let render = source_from("impl Render for Player"); for card in [ - "eq_card", "color_card", "speed_card", "silence_card", "mix_card", + "eq_card", "color_card", "speed_card", "silence_card", "mix_card", "subtitle_style_card", ] { assert!( inspector.contains(&format!("self.{card}(")), diff --git a/crates/app/src/tests/media.rs b/crates/app/src/tests/media.rs index 78a9938..4dfeed3 100644 --- a/crates/app/src/tests/media.rs +++ b/crates/app/src/tests/media.rs @@ -2,6 +2,9 @@ //! command line, the scans, the codecs offered, and the subtitles found. use super::*; +use crate::subs::{ + load_subtitle_style, save_subtitle_style, sub_line_h_for, subtitle_style_path, SUB_SIZE_RANGE, +}; use crate::ui::preview::{bgra_to_rgba, screenshot_path}; /// The import line's own state machine, driven the way a repaint drives @@ -901,6 +904,68 @@ fn the_subtitle_plate_and_lanes_fit_the_smallest_window() { assert!(SUB_HEAD_H >= HIT_MIN); } +/// The subtitle style file, round-tripped through a scratch config directory +/// -- the same corner-cut persistence as the theme and the keybindings, kept +/// to the same test the load/save pair earns: a save followed by a load reads +/// back what was written, a file that never existed leaves the defaults in +/// force, and a file that exists but says nothing readable does too rather +/// than crashing a startup on someone else's edit of the file. +#[test] +fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { + let dir = std::env::temp_dir().join(format!( + "edith-subtitle-style-test-{}-{}", + std::process::id(), + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos() + )); + std::fs::create_dir_all(&dir).unwrap(); + // Scoped to this test alone: no other test reads XDG_CONFIG_HOME or the + // subtitle-style file it names, so this narrow, restored mutation of the + // process environment cannot race another test's own file. + unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; + + // Nothing written yet: the defaults, not a crash on a missing file. + assert_eq!(load_subtitle_style(), (None, SUB_TEXT)); + + // A save, read back whole: family and size both. + save_subtitle_style(Some("Iosevka"), 22.).unwrap(); + assert_eq!( + load_subtitle_style(), + (Some("Iosevka".to_string()), 22.) + ); + + // The platform default (`None`) round-trips too, and is not a family + // called "". + save_subtitle_style(None, 14.).unwrap(); + assert_eq!(load_subtitle_style(), (None, 14.)); + + // A file present but unreadable as this format -- a stray edit, or bytes + // from a future version -- leaves the defaults in force rather than + // failing the window that opens over it. + std::fs::write(subtitle_style_path(), "not a number\n9999\n").unwrap(); + assert_eq!(load_subtitle_style(), (None, SUB_TEXT)); + + unsafe { std::env::remove_var("XDG_CONFIG_HOME") }; + std::fs::remove_dir_all(&dir).ok(); +} + +/// The cue's line height scales with its size, on the same ratio the defaults +/// draw at -- a bigger plate wants more room per line, not letters growing +/// inside an unchanged one. +#[test] +fn the_cue_line_height_scales_with_its_size() { + assert_eq!(sub_line_h_for(SUB_TEXT), SUB_LINE_H); + // Twice the size is twice the line height, on the same ratio. + assert_eq!(sub_line_h_for(SUB_TEXT * 2.), SUB_LINE_H * 2.); + // Always at least the text itself, across the whole size range: a line + // shorter than its own text would clip it. + for size in [SUB_SIZE_RANGE.0, SUB_TEXT, SUB_SIZE_RANGE.1] { + assert!(sub_line_h_for(size) >= size); + } +} + /// What the rows of both lists do with a name too long for the column: two /// episodes off one release differ in their last two characters, and a name /// cut from the right is the same row twice. diff --git a/crates/app/src/ui/cards.rs b/crates/app/src/ui/cards.rs index aa8b0c9..ea1d176 100644 --- a/crates/app/src/ui/cards.rs +++ b/crates/app/src/ui/cards.rs @@ -1818,6 +1818,159 @@ impl Player { ) } + /// The subtitle style card: the size stepper on top, the platform's own + /// font list scrolling under it -- a picker's rows and not a cycle, so a + /// hundred-odd families are each one click and not a hundred presses of + /// the same key. Nothing here is a clip's or the project's, the mix + /// card's shape for the same reason: app-global, kept in a file beside + /// the theme, and drawn straight off `self.sub_text` / `self.sub_family` + /// so a change is on the cue underneath before the card is closed. + pub(crate) fn subtitle_style_card(&self, cx: &mut Context) -> Option { + if !self.subtitle_style_open { + return None; + } + let size_row = div() + .id("subtitle-size-row") + .flex() + .flex_none() + .min_h(px(KEYS_ROW_H)) + .items_center() + .justify_between() + .px(px(6.)) + .rounded(px(3.)) + .bg(rgb(match self.subtitle_style_field == 0 { + true => BG_SELECTED(), + false => BG_PANEL(), + })) + .child(div().text_color(rgb(FG_SECONDARY())).child("Size")) + .child( + div() + .flex() + .items_center() + .gap(px(4.)) + .child(format!("{:.0}px", self.sub_text)) + .children([-1, 1].map(|steps: i32| { + div() + .id(("subtitle-size-step", usize::from(steps > 0))) + .flex_none() + .w(px(HIT_MIN)) + .h(px(KEYS_ROW_H)) + .flex() + .items_center() + .justify_center() + .rounded(px(3.)) + .bg(rgb(BG_PANEL())) + .cursor_pointer() + .hover(|s| s.bg(rgb(BG_HOVER()))) + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { + this.subtitle_style_field = 0; + this.nudge_sub_size(steps, cx); + })) + .child(match steps > 0 { + true => "+", + false => "−", + }) + })), + ); + let default_row = div() + .id("subtitle-family-row-default") + .flex() + .flex_none() + .min_h(px(KEYS_ROW_H)) + .items_center() + .px(px(6.)) + .rounded(px(3.)) + .bg(rgb(match self.subtitle_style_field == 1 { + true => BG_SELECTED(), + false => BG_PANEL(), + })) + .cursor_pointer() + .hover(|s| s.bg(rgb(BG_HOVER()))) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { + this.set_sub_family(None, cx); + })) + .child("System default"); + let family_rows = self.subtitle_fonts.iter().enumerate().map(|(n, name)| { + div() + .id(("subtitle-family-row", n)) + .flex() + .flex_none() + .min_h(px(KEYS_ROW_H)) + .items_center() + .px(px(6.)) + .rounded(px(3.)) + .bg(rgb( + match (self.subtitle_style_field == n + 2, self.sub_family.as_deref() == Some(name.as_str())) { + (true, _) | (false, true) => BG_SELECTED(), + _ => BG_PANEL(), + }, + )) + .cursor_pointer() + .hover(|s| s.bg(rgb(BG_HOVER()))) + .on_click(cx.listener({ + let name = name.clone(); + move |this, _: &ClickEvent, _, cx| { + this.set_sub_family(Some(name.clone()), cx); + } + })) + .child(name.clone()) + }); + Some( + scrim() + .flex() + .justify_center() + .items_center() + .bg(rgba(SCRIM())) + .on_mouse_down( + MouseButton::Left, + cx.listener(|this, _: &MouseDownEvent, _, cx| { + this.close_card(); + cx.notify(); + cx.stop_propagation(); + }), + ) + .child( + div() + .w_full() + .max_w(px(COLOR_W)) + .on_mouse_down(MouseButton::Left, swallow) + .max_h(px(360. - 24.)) + .flex() + .flex_col() + .gap(px(6.)) + .p(px(12.)) + .rounded(px(6.)) + .bg(rgb(BG_RAISED())) + .child( + div() + .flex_none() + .px(px(6.)) + .child("Subtitle style — font and size of the cue plate"), + ) + .child( + div() + .flex_none() + .px(px(6.)) + .text_size(px(11.)) + .text_color(rgb(FG_SECONDARY())) + .child( + "− and + move the size, or ↑↓ picks a row and ←→ moves it (held or pressed); a family row picks it outright — a click away or esc closes", + ), + ) + .child(size_row) + .child( + div() + .id("subtitle-family-rows") + .flex() + .flex_col() + .overflow_y_scroll() + .child(default_row) + .children(family_rows), + ), + ), + ) + } + /// The silence card: what the scan is looking for, what it found, and the /// two things that can be done about it. /// diff --git a/crates/app/src/ui/inspector.rs b/crates/app/src/ui/inspector.rs index 2e88167..40eb055 100644 --- a/crates/app/src/ui/inspector.rs +++ b/crates/app/src/ui/inspector.rs @@ -84,6 +84,7 @@ impl Player { .children(self.speed_card(cx)) .children(self.silence_card(cx)) .children(self.mix_card(cx)) + .children(self.subtitle_style_card(cx)) } /// What is marked, and the settings that belong to *it*. A dump of every @@ -367,6 +368,16 @@ impl Player { "a fader per track and the limiter over the sum of them", ActionId::Mix, cx.listener(|this, _: &ClickEvent, _, cx| this.open_mix(None, cx)), + )) + .child(self.action_control( + "inspect-subtitle-style", + 0., + BG_RAISED(), + None, + "Font", + "the cue plate's own font and size", + ActionId::SubtitleStyle, + cx.listener(|this, _: &ClickEvent, _, cx| this.open_subtitle_style(cx)), )), ) } diff --git a/crates/app/src/ui/preview.rs b/crates/app/src/ui/preview.rs index b38daa3..fb296d2 100644 --- a/crates/app/src/ui/preview.rs +++ b/crates/app/src/ui/preview.rs @@ -190,18 +190,19 @@ impl Player { .px(px(6.)) .rounded(px(3.)) .bg(rgba(SUB_SHADE())) - .text_size(px(SUB_TEXT)) + .text_size(px(self.sub_text)) .text_color(rgb(SUB_FG())) .text_align(TextAlign::Center) + .when_some(self.sub_family.clone(), |el, fam| el.font_family(fam)) // A line of the cue is a line on screen: the break the // parser kept is not whitespace to be re-flowed. What a // *long* line does is wrap inside its own div, which is // what the width cap above is for. - .children( - cue.text - .split('\n') - .map(|line| div().min_h(px(SUB_LINE_H)).child(line.to_string())), - ) + .children(cue.text.split('\n').map(|line| { + div() + .min_h(px(sub_line_h_for(self.sub_text))) + .child(line.to_string()) + })) })), ) }