forge
Explore
Log in

Don't you dare go Hollow

The subtitle cue dresses to the user's taste

Browse files at this commit

0bee605205e8c9a32a36f8830c90e81c528e632bAhmet Kaan GümüşParent: 79d189bdd4bbea
  • feat
    • the subtitle cue dresses to the user's taste
Show full message
✨ feat(app): the subtitle cue dresses to the user's taste
crates/app/src/keymap.rsmodified+14 -1
@@ -146,6 +146,9 @@ actions! {
146146 /// own picture or a library preview's, since both write through the one
147147 /// `self.image` the atlas already holds.
148148 Screenshot,
149+ /// The cue plate's font and size -- a person's own preference, kept
150+ /// beside the theme and not the project, and opened the same way.
151+ SubtitleStyle,
149152 }
150153
151154 impl ActionId {
@@ -208,6 +211,7 @@ impl ActionId {
208211 ActionId::CancelExport => "Cancel export",
209212 ActionId::ShowActions => "All actions and their keys…",
210213 ActionId::Screenshot => "Save the frame on screen as a PNG",
214+ ActionId::SubtitleStyle => "Subtitle style: font and size…",
211215 }
212216 }
213217
@@ -268,6 +272,7 @@ impl ActionId {
268272 ActionId::CancelExport => "cancel-export",
269273 ActionId::ShowActions => "show-actions",
270274 ActionId::Screenshot => "screenshot",
275+ ActionId::SubtitleStyle => "subtitle-style",
271276 }
272277 }
273278
@@ -329,6 +334,9 @@ impl ActionId {
329334 // ...and what the whole window is painted in: it edits nothing at
330335 // all, it is what one is looking *with*.
331336 | ActionId::Theme
337+ // ...and what the cue plate is drawn in: a person's own reading
338+ // preference, same as the theme beside it.
339+ | ActionId::SubtitleStyle
332340 // ...and whether that window fills the screen: a way of looking,
333341 // same as the zoom and the theme beside it.
334342 | ActionId::Fullscreen => Category::View,
@@ -944,6 +952,10 @@ impl Keymap {
944952 // "w" is free entirely, bare and ctrl both -- nothing else in
945953 // this table answers to it.
946954 b(ActionId::Screenshot, "w", false),
955+ // Bare "y" is free entirely, and unshifted: a preference
956+ // opened as often as the theme, not a switch thrown once a
957+ // session.
958+ b(ActionId::SubtitleStyle, "y", false),
947959 ],
948960 }
949961 }
@@ -1207,9 +1219,10 @@ mod tests {
12071219 #[test]
12081220 fn every_default_stroke_reaches_its_action() {
12091221 let k = Keymap::defaults();
1210- assert_eq!(k.entries().len(), 55);
1222+ assert_eq!(k.entries().len(), 56);
12111223 assert_eq!(k.lookup("f11", false), Some(ActionId::Fullscreen));
12121224 assert_eq!(k.lookup("w", false), Some(ActionId::Screenshot));
1225+ assert_eq!(k.lookup("y", false), Some(ActionId::SubtitleStyle));
12131226 assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies));
12141227 assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies));
12151228 assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions));
crates/app/src/main.rsmodified+29 -0
@@ -519,6 +519,27 @@ struct Player {
519519 /// or its switch. The card's own focus, since nothing in it takes gpui's
520520 /// (ledger:182).
521521 mix_field: usize,
522+ /// The cue plate's own size, in force this session and kept in
523+ /// `~/.config/edith/subtitle-style` beside the keybindings -- an
524+ /// app-global preference like the theme, since export never burns
525+ /// subtitles into the picture. [`SUB_TEXT`] is the default it opens at,
526+ /// never the value read at paint; [`sub_line_h`](Player::sub_line_h) is
527+ /// what preview.rs reads for the line height, derived from this.
528+ sub_text: f32,
529+ /// Which family the cue plate draws in, or the platform default with
530+ /// nothing picked -- `None` calls no [`gpui::Styled::font_family`] at
531+ /// all, which is what leaves the window's own choice in force.
532+ sub_family: Option<String>,
533+ /// The subtitle style card is up.
534+ subtitle_style_open: bool,
535+ /// Which of its rows the arrow keys move: 0 is the size stepper, every
536+ /// row after it a family in [`Self::subtitle_fonts`]. The card's own
537+ /// focus, since nothing in it takes gpui's (ledger:182).
538+ subtitle_style_field: usize,
539+ /// Every family the platform can draw, asked for once when the card
540+ /// opens and kept for as long as it is up: [`gpui::TextSystem::all_font_names`]
541+ /// walks the whole font registry, which is not a repaint's business.
542+ subtitle_fonts: Vec<String>,
522543 /// The silence card is up on this clip -- the lane it is on and its index
523544 /// there, exactly as the speed card's handle is.
524545 silence_open: Option<(Lane, usize)>,
@@ -637,6 +658,9 @@ fn main() {
637658 // itself. Silent on a missing or unreadable file -- the default is a whole
638659 // answer, and nothing of the user's is lost by it.
639660 ui::theme::load();
661+ // The subtitle style the last session picked, same silence on a missing
662+ // or unreadable file.
663+ let (sub_family, sub_text) = load_subtitle_style();
640664 // Nothing named on the command line is read here. The first file makes the
641665 // timeline -- a `.edith` restores a whole one, anything else *is* one --
642666 // and the rest are imports like any other: rows in the library, dragged
@@ -788,6 +812,11 @@ fn main() {
788812 pending_speed: None,
789813 mix_open: false,
790814 mix_field: 0,
815+ sub_text,
816+ sub_family,
817+ subtitle_style_open: false,
818+ subtitle_style_field: 0,
819+ subtitle_fonts: Vec::new(),
791820 silence_open: None,
792821 // The conservative defaults the engine documents: a first
793822 // scan that leaves a little too much is one nobody undoes.
crates/app/src/oracle.rsmodified+3 -1
@@ -100,7 +100,9 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
100100 // reading one, which is the only state that dims the list above.
101101 // ...and whether that window fills the screen: also always there, also
102102 // touching no timeline, live through an export the same way.
103- if action == ActionId::Theme || action == ActionId::Fullscreen {
103+ // ...and the cue plate's own font and size: a reading preference like the
104+ // theme, never burned into an export, live the same way.
105+ if action == ActionId::Theme || action == ActionId::Fullscreen || action == ActionId::SubtitleStyle {
104106 return Enable::Yes;
105107 }
106108 if action == ActionId::ShowActions {
crates/app/src/player/actions.rsmodified+1 -0
@@ -89,6 +89,7 @@ impl Player {
8989 ActionId::Speed => self.open_speed(cx),
9090 ActionId::Silence => self.open_silence(cx),
9191 ActionId::Mix => self.open_mix(None, cx),
92+ ActionId::SubtitleStyle => self.open_subtitle_style(cx),
9293 ActionId::ToggleSnap => self.toggle_snap(cx),
9394 ActionId::ToggleSubtitles => self.toggle_subtitles(cx),
9495 ActionId::ToggleProxies => self.toggle_proxies(cx),
crates/app/src/player/cards.rsmodified+53 -0
@@ -691,6 +691,57 @@ impl Player {
691691 cx.notify();
692692 }
693693
694+ /// Opens the subtitle style card: the platform's font list, asked for
695+ /// once and kept while the card is up, and the size stepper beside it.
696+ /// Nothing here is a clip's or even the project's -- it never reaches the
697+ /// export, which never burns a cue into the picture -- so like the mix
698+ /// card it opens with no timeline required and nothing to refuse.
699+ pub(crate) fn open_subtitle_style(&mut self, cx: &mut Context<Self>) {
700+ self.subtitle_fonts = cx.text_system().all_font_names();
701+ self.subtitle_style_open = true;
702+ self.subtitle_style_field = 0;
703+ // One card at a time, the rule the other five follow.
704+ self.keys_open = false;
705+ self.export_open = false;
706+ self.eq_open = None;
707+ self.color_open = None;
708+ self.speed_open = None;
709+ self.mix_open = false;
710+ self.close_silence();
711+ self.context_menu = None;
712+ cx.notify();
713+ }
714+
715+ /// Picks a family outright -- a click on a row, the card's rule for a
716+ /// list rather than a stepper. `None` is the top row, the platform's own
717+ /// choice, which is what a family nobody can spell as a fallback would
718+ /// leave silently wrong instead.
719+ pub(crate) fn set_sub_family(&mut self, family: Option<String>, cx: &mut Context<Self>) {
720+ self.sub_family = family;
721+ self.keep_subtitle_style(cx);
722+ }
723+
724+ /// One [`SUB_SIZE_STEP`] per keystroke or stepper press, clamped to
725+ /// [`SUB_SIZE_RANGE`].
726+ pub(crate) fn nudge_sub_size(&mut self, steps: i32, cx: &mut Context<Self>) {
727+ self.sub_text = (self.sub_text + steps as f32 * SUB_SIZE_STEP)
728+ .clamp(SUB_SIZE_RANGE.0, SUB_SIZE_RANGE.1);
729+ self.keep_subtitle_style(cx);
730+ }
731+
732+ /// Writes the style to disk and repaints: every change to either field
733+ /// goes through here, so the file on disk and the plate on screen never
734+ /// disagree about which session's edit is in force.
735+ fn keep_subtitle_style(&mut self, cx: &mut Context<Self>) {
736+ if let Err(e) = save_subtitle_style(self.sub_family.as_deref(), self.sub_text) {
737+ let path = subtitle_style_path();
738+ self.notify_user(
739+ format!("SUBTITLE STYLE COULD NOT BE KEPT — {} — {e}", path.display()).into(),
740+ );
741+ }
742+ cx.notify();
743+ }
744+
694745 /// Closes it and drops the preview with it: marks left on the lane after
695746 /// the card is gone would name frames the next edit has already moved.
696747 pub(crate) fn close_silence(&mut self) {
@@ -1045,6 +1096,7 @@ impl Player {
10451096 || self.speed_open.is_some()
10461097 || self.silence_open.is_some()
10471098 || self.mix_open
1099+ || self.subtitle_style_open
10481100 || self.exporting().is_some()
10491101 }
10501102
@@ -1075,6 +1127,7 @@ impl Player {
10751127 self.close_silence();
10761128 }
10771129 self.mix_open = false;
1130+ self.subtitle_style_open = false;
10781131 }
10791132
10801133 /// Opens the equalizer on the selected clip. Audio only, and it says so
crates/app/src/render.rsmodified+30 -0
@@ -434,6 +434,36 @@ impl Render for Player {
434434 cx.notify();
435435 return;
436436 }
437+ // The subtitle style card, the same way again: row 0 is the
438+ // size stepper (←→ moves it, held or pressed, the mix card's
439+ // rule) and every row after it a family in
440+ // `subtitle_fonts` -- ↑↓ walk the whole list and `enter`
441+ // picks the one the arrows are on, since a hand with no
442+ // mouse still has to be able to leave the platform default.
443+ if this.subtitle_style_open {
444+ // Row 0 is the size stepper, row 1 the platform default,
445+ // and every row after it a family in `subtitle_fonts`.
446+ let rows = 2 + this.subtitle_fonts.len();
447+ if key == ESCAPE {
448+ this.subtitle_style_open = false;
449+ } else if key == "down" {
450+ this.subtitle_style_field = (this.subtitle_style_field + 1) % rows;
451+ } else if key == "up" {
452+ this.subtitle_style_field =
453+ (this.subtitle_style_field + rows - 1) % rows;
454+ } else if key == "right" {
455+ this.nudge_sub_size(1, cx);
456+ } else if key == "left" {
457+ this.nudge_sub_size(-1, cx);
458+ } else if key == "enter" && this.subtitle_style_field == 1 {
459+ this.set_sub_family(None, cx);
460+ } else if key == "enter" && this.subtitle_style_field > 1 {
461+ let family = this.subtitle_fonts[this.subtitle_style_field - 2].clone();
462+ this.set_sub_family(Some(family), cx);
463+ }
464+ cx.notify();
465+ return;
466+ }
437467 // A clip menu names an index, and every edit below moves
438468 // indices -- so a stroke closes it before it acts. Escape means
439469 // that and nothing else, which is the `esc` the keys menu
crates/app/src/subs.rsmodified+51 -0
@@ -2,6 +2,57 @@
22
33 use crate::*;
44
5+/// One press of the size stepper, and how far it may be pushed: below
6+/// [`SUB_SIZE_RANGE`].0 a plate is unreadable, above its top it eats the
7+/// smallest picture the layout floor promises ([`the_subtitle_plate_and_lanes_fit_the_smallest_window`]).
8+pub(crate) const SUB_SIZE_STEP: f32 = 1.;
9+pub(crate) const SUB_SIZE_RANGE: (f32, f32) = (10., 28.);
10+
11+/// The cue's line height at `size`, on the ratio the defaults draw at
12+/// ([`SUB_LINE_H`] over [`SUB_TEXT`]): a bigger cue wants a taller line, not
13+/// just bigger letters on the old one.
14+pub(crate) fn sub_line_h_for(size: f32) -> f32 {
15+ size * SUB_LINE_H / SUB_TEXT
16+}
17+
18+/// Where the subtitle style survives: beside the keybindings and the theme,
19+/// same corner-cut persistence -- a torn write costs the style and nothing
20+/// else, and [`load_subtitle_style`] falls back to the defaults on one.
21+pub(crate) fn subtitle_style_path() -> PathBuf {
22+ crate::keymap::Keymap::config_path().with_file_name("subtitle-style")
23+}
24+
25+/// Two lines: the family (empty for the system default) and the size.
26+/// Anything unreadable, missing or out of range leaves the defaults in
27+/// force -- a subtitle style file is not the user's work, so a bad one is
28+/// worth no message at startup, exactly as [`ui::theme::load`].
29+pub(crate) fn load_subtitle_style() -> (Option<String>, f32) {
30+ let Ok(text) = std::fs::read_to_string(subtitle_style_path()) else {
31+ return (None, SUB_TEXT);
32+ };
33+ let mut lines = text.lines();
34+ let family = lines.next().filter(|l| !l.is_empty()).map(str::to_string);
35+ // A size this format could not have written means the file is not this
36+ // format at all -- the family line is then noise too, not a font.
37+ let Some(size) = lines
38+ .next()
39+ .and_then(|l| l.trim().parse::<f32>().ok())
40+ .filter(|s| (SUB_SIZE_RANGE.0..=SUB_SIZE_RANGE.1).contains(s))
41+ else {
42+ return (None, SUB_TEXT);
43+ };
44+ (family, size)
45+}
46+
47+/// Writes the style whole, the way [`ui::theme::save`] writes the palette.
48+pub(crate) fn save_subtitle_style(family: Option<&str>, size: f32) -> std::io::Result<()> {
49+ let path = subtitle_style_path();
50+ if let Some(dir) = path.parent() {
51+ std::fs::create_dir_all(dir)?;
52+ }
53+ std::fs::write(path, format!("{}\n{size}\n", family.unwrap_or("")))
54+}
55+
556 /// Whether a dropped or named path is a subtitle file rather than media: the
657 /// formats `engine::subtitle` parses, lowercased, for [`engine::is_audio`]'s
758 /// reason -- the import door has to know which of the engine's two doors a file
crates/app/src/tests/editing.rsmodified+3 -1
@@ -890,7 +890,8 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
890890 // edit list either.
891891 let allowed = action == ActionId::CancelExport
892892 || action == ActionId::Theme
893- || action == ActionId::Fullscreen;
893+ || action == ActionId::Fullscreen
894+ || action == ActionId::SubtitleStyle;
894895 assert_eq!(
895896 whole(action, busy).yes(),
896897 allowed,
@@ -1206,6 +1207,7 @@ fn every_card_closes_without_the_keyboard() {
12061207 "speed_card",
12071208 "mix_card",
12081209 "silence_card",
1210+ "subtitle_style_card",
12091211 ] {
12101212 let src = fn_body(card);
12111213 assert!(
crates/app/src/tests/layout.rsmodified+1 -1
@@ -175,7 +175,7 @@ fn an_inspector_section_occludes_no_timeline() {
175175 // leave this rule reading a file the render is no longer in.
176176 let render = source_from("impl Render for Player");
177177 for card in [
178- "eq_card", "color_card", "speed_card", "silence_card", "mix_card",
178+ "eq_card", "color_card", "speed_card", "silence_card", "mix_card", "subtitle_style_card",
179179 ] {
180180 assert!(
181181 inspector.contains(&format!("self.{card}(")),
crates/app/src/tests/media.rsmodified+65 -0
@@ -2,6 +2,9 @@
22 //! command line, the scans, the codecs offered, and the subtitles found.
33
44 use super::*;
5+use crate::subs::{
6+ load_subtitle_style, save_subtitle_style, sub_line_h_for, subtitle_style_path, SUB_SIZE_RANGE,
7+};
58 use crate::ui::preview::{bgra_to_rgba, screenshot_path};
69
710 /// 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() {
901904 assert!(SUB_HEAD_H >= HIT_MIN);
902905 }
903906
907+/// The subtitle style file, round-tripped through a scratch config directory
908+/// -- the same corner-cut persistence as the theme and the keybindings, kept
909+/// to the same test the load/save pair earns: a save followed by a load reads
910+/// back what was written, a file that never existed leaves the defaults in
911+/// force, and a file that exists but says nothing readable does too rather
912+/// than crashing a startup on someone else's edit of the file.
913+#[test]
914+fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() {
915+ let dir = std::env::temp_dir().join(format!(
916+ "edith-subtitle-style-test-{}-{}",
917+ std::process::id(),
918+ std::time::SystemTime::now()
919+ .duration_since(std::time::UNIX_EPOCH)
920+ .unwrap()
921+ .as_nanos()
922+ ));
923+ std::fs::create_dir_all(&dir).unwrap();
924+ // Scoped to this test alone: no other test reads XDG_CONFIG_HOME or the
925+ // subtitle-style file it names, so this narrow, restored mutation of the
926+ // process environment cannot race another test's own file.
927+ unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) };
928+
929+ // Nothing written yet: the defaults, not a crash on a missing file.
930+ assert_eq!(load_subtitle_style(), (None, SUB_TEXT));
931+
932+ // A save, read back whole: family and size both.
933+ save_subtitle_style(Some("Iosevka"), 22.).unwrap();
934+ assert_eq!(
935+ load_subtitle_style(),
936+ (Some("Iosevka".to_string()), 22.)
937+ );
938+
939+ // The platform default (`None`) round-trips too, and is not a family
940+ // called "".
941+ save_subtitle_style(None, 14.).unwrap();
942+ assert_eq!(load_subtitle_style(), (None, 14.));
943+
944+ // A file present but unreadable as this format -- a stray edit, or bytes
945+ // from a future version -- leaves the defaults in force rather than
946+ // failing the window that opens over it.
947+ std::fs::write(subtitle_style_path(), "not a number\n9999\n").unwrap();
948+ assert_eq!(load_subtitle_style(), (None, SUB_TEXT));
949+
950+ unsafe { std::env::remove_var("XDG_CONFIG_HOME") };
951+ std::fs::remove_dir_all(&dir).ok();
952+}
953+
954+/// The cue's line height scales with its size, on the same ratio the defaults
955+/// draw at -- a bigger plate wants more room per line, not letters growing
956+/// inside an unchanged one.
957+#[test]
958+fn the_cue_line_height_scales_with_its_size() {
959+ assert_eq!(sub_line_h_for(SUB_TEXT), SUB_LINE_H);
960+ // Twice the size is twice the line height, on the same ratio.
961+ assert_eq!(sub_line_h_for(SUB_TEXT * 2.), SUB_LINE_H * 2.);
962+ // Always at least the text itself, across the whole size range: a line
963+ // shorter than its own text would clip it.
964+ for size in [SUB_SIZE_RANGE.0, SUB_TEXT, SUB_SIZE_RANGE.1] {
965+ assert!(sub_line_h_for(size) >= size);
966+ }
967+}
968+
904969 /// What the rows of both lists do with a name too long for the column: two
905970 /// episodes off one release differ in their last two characters, and a name
906971 /// cut from the right is the same row twice.
crates/app/src/ui/cards.rsmodified+153 -0
@@ -1818,6 +1818,159 @@ impl Player {
18181818 )
18191819 }
18201820
1821+ /// The subtitle style card: the size stepper on top, the platform's own
1822+ /// font list scrolling under it -- a picker's rows and not a cycle, so a
1823+ /// hundred-odd families are each one click and not a hundred presses of
1824+ /// the same key. Nothing here is a clip's or the project's, the mix
1825+ /// card's shape for the same reason: app-global, kept in a file beside
1826+ /// the theme, and drawn straight off `self.sub_text` / `self.sub_family`
1827+ /// so a change is on the cue underneath before the card is closed.
1828+ pub(crate) fn subtitle_style_card(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
1829+ if !self.subtitle_style_open {
1830+ return None;
1831+ }
1832+ let size_row = div()
1833+ .id("subtitle-size-row")
1834+ .flex()
1835+ .flex_none()
1836+ .min_h(px(KEYS_ROW_H))
1837+ .items_center()
1838+ .justify_between()
1839+ .px(px(6.))
1840+ .rounded(px(3.))
1841+ .bg(rgb(match self.subtitle_style_field == 0 {
1842+ true => BG_SELECTED(),
1843+ false => BG_PANEL(),
1844+ }))
1845+ .child(div().text_color(rgb(FG_SECONDARY())).child("Size"))
1846+ .child(
1847+ div()
1848+ .flex()
1849+ .items_center()
1850+ .gap(px(4.))
1851+ .child(format!("{:.0}px", self.sub_text))
1852+ .children([-1, 1].map(|steps: i32| {
1853+ div()
1854+ .id(("subtitle-size-step", usize::from(steps > 0)))
1855+ .flex_none()
1856+ .w(px(HIT_MIN))
1857+ .h(px(KEYS_ROW_H))
1858+ .flex()
1859+ .items_center()
1860+ .justify_center()
1861+ .rounded(px(3.))
1862+ .bg(rgb(BG_PANEL()))
1863+ .cursor_pointer()
1864+ .hover(|s| s.bg(rgb(BG_HOVER())))
1865+ .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
1866+ this.subtitle_style_field = 0;
1867+ this.nudge_sub_size(steps, cx);
1868+ }))
1869+ .child(match steps > 0 {
1870+ true => "+",
1871+ false => "−",
1872+ })
1873+ })),
1874+ );
1875+ let default_row = div()
1876+ .id("subtitle-family-row-default")
1877+ .flex()
1878+ .flex_none()
1879+ .min_h(px(KEYS_ROW_H))
1880+ .items_center()
1881+ .px(px(6.))
1882+ .rounded(px(3.))
1883+ .bg(rgb(match self.subtitle_style_field == 1 {
1884+ true => BG_SELECTED(),
1885+ false => BG_PANEL(),
1886+ }))
1887+ .cursor_pointer()
1888+ .hover(|s| s.bg(rgb(BG_HOVER())))
1889+ .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
1890+ this.set_sub_family(None, cx);
1891+ }))
1892+ .child("System default");
1893+ let family_rows = self.subtitle_fonts.iter().enumerate().map(|(n, name)| {
1894+ div()
1895+ .id(("subtitle-family-row", n))
1896+ .flex()
1897+ .flex_none()
1898+ .min_h(px(KEYS_ROW_H))
1899+ .items_center()
1900+ .px(px(6.))
1901+ .rounded(px(3.))
1902+ .bg(rgb(
1903+ match (self.subtitle_style_field == n + 2, self.sub_family.as_deref() == Some(name.as_str())) {
1904+ (true, _) | (false, true) => BG_SELECTED(),
1905+ _ => BG_PANEL(),
1906+ },
1907+ ))
1908+ .cursor_pointer()
1909+ .hover(|s| s.bg(rgb(BG_HOVER())))
1910+ .on_click(cx.listener({
1911+ let name = name.clone();
1912+ move |this, _: &ClickEvent, _, cx| {
1913+ this.set_sub_family(Some(name.clone()), cx);
1914+ }
1915+ }))
1916+ .child(name.clone())
1917+ });
1918+ Some(
1919+ scrim()
1920+ .flex()
1921+ .justify_center()
1922+ .items_center()
1923+ .bg(rgba(SCRIM()))
1924+ .on_mouse_down(
1925+ MouseButton::Left,
1926+ cx.listener(|this, _: &MouseDownEvent, _, cx| {
1927+ this.close_card();
1928+ cx.notify();
1929+ cx.stop_propagation();
1930+ }),
1931+ )
1932+ .child(
1933+ div()
1934+ .w_full()
1935+ .max_w(px(COLOR_W))
1936+ .on_mouse_down(MouseButton::Left, swallow)
1937+ .max_h(px(360. - 24.))
1938+ .flex()
1939+ .flex_col()
1940+ .gap(px(6.))
1941+ .p(px(12.))
1942+ .rounded(px(6.))
1943+ .bg(rgb(BG_RAISED()))
1944+ .child(
1945+ div()
1946+ .flex_none()
1947+ .px(px(6.))
1948+ .child("Subtitle style — font and size of the cue plate"),
1949+ )
1950+ .child(
1951+ div()
1952+ .flex_none()
1953+ .px(px(6.))
1954+ .text_size(px(11.))
1955+ .text_color(rgb(FG_SECONDARY()))
1956+ .child(
1957+ "− 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",
1958+ ),
1959+ )
1960+ .child(size_row)
1961+ .child(
1962+ div()
1963+ .id("subtitle-family-rows")
1964+ .flex()
1965+ .flex_col()
1966+ .overflow_y_scroll()
1967+ .child(default_row)
1968+ .children(family_rows),
1969+ ),
1970+ ),
1971+ )
1972+ }
1973+
18211974 /// The silence card: what the scan is looking for, what it found, and the
18221975 /// two things that can be done about it.
18231976 ///
crates/app/src/ui/inspector.rsmodified+11 -0
@@ -84,6 +84,7 @@ impl Player {
8484 .children(self.speed_card(cx))
8585 .children(self.silence_card(cx))
8686 .children(self.mix_card(cx))
87+ .children(self.subtitle_style_card(cx))
8788 }
8889
8990 /// What is marked, and the settings that belong to *it*. A dump of every
@@ -371,6 +372,16 @@ impl Player {
371372 "a fader per track and the limiter over the sum of them",
372373 ActionId::Mix,
373374 cx.listener(|this, _: &ClickEvent, _, cx| this.open_mix(None, cx)),
375+ ))
376+ .child(self.action_control(
377+ "inspect-subtitle-style",
378+ 0.,
379+ BG_RAISED(),
380+ None,
381+ "Font",
382+ "the cue plate's own font and size",
383+ ActionId::SubtitleStyle,
384+ cx.listener(|this, _: &ClickEvent, _, cx| this.open_subtitle_style(cx)),
374385 )),
375386 )
376387 }
crates/app/src/ui/preview.rsmodified+7 -6
@@ -190,18 +190,19 @@ impl Player {
190190 .px(px(6.))
191191 .rounded(px(3.))
192192 .bg(rgba(SUB_SHADE()))
193- .text_size(px(SUB_TEXT))
193+ .text_size(px(self.sub_text))
194194 .text_color(rgb(SUB_FG()))
195195 .text_align(TextAlign::Center)
196+ .when_some(self.sub_family.clone(), |el, fam| el.font_family(fam))
196197 // A line of the cue is a line on screen: the break the
197198 // parser kept is not whitespace to be re-flowed. What a
198199 // *long* line does is wrap inside its own div, which is
199200 // what the width cap above is for.
200- .children(
201- cue.text
202- .split('\n')
203- .map(|line| div().min_h(px(SUB_LINE_H)).child(line.to_string())),
204- )
201+ .children(cue.text.split('\n').map(|line| {
202+ div()
203+ .min_h(px(sub_line_h_for(self.sub_text)))
204+ .child(line.to_string())
205+ }))
205206 })),
206207 )
207208 }