A settings page for the project and the editor
Browse files at this commit- feat
- a settings page for the project and the editor
15 changed files +684 -11
- crates/app/src/keymap.rs +19 -2
- crates/app/src/main.rs +15 -2
- crates/app/src/oracle.rs +11 -0
- crates/app/src/player/actions.rs +1 -0
- crates/app/src/player/cards.rs +31 -1
- crates/app/src/player/library.rs +80 -0
- crates/app/src/tests/cards.rs +52 -3
- crates/app/src/tests/editing.rs +5 -1
- crates/app/src/tests/layout.rs +97 -0
- crates/app/src/tests/media.rs +41 -0
- crates/app/src/ui/mod.rs +1 -0
- crates/app/src/ui/settings_stance.rs +302 -0
- crates/app/src/ui/spine_stance.rs +6 -0
- crates/app/src/ui/stance.rs +22 -2
- crates/engine/src/playback.rs +1 -0
crates/app/src/keymap.rsmodified+19 -2
| @@ -210,6 +210,14 @@ actions! { | |||
| 210 | /// The cue plate's font and size -- a person's own preference, kept | 210 | /// The cue plate's font and size -- a person's own preference, kept |
| 211 | /// beside the theme and not the project, and opened the same way. | 211 | /// beside the theme and not the project, and opened the same way. |
| 212 | SubtitleStyle, | 212 | SubtitleStyle, |
| 213 | + /// The settings page: PROJECT rows (resolution, fps, sample-rate, HDR | ||
| 214 | + /// tonemap, the mix) beside EDITOR rows (proxies, auto-proxies, subtitle | ||
| 215 | + /// font) -- one door, two clearly-headed sections, per the split rule | ||
| 216 | + /// that "anything that changes the rendered output or lives in the | ||
| 217 | + /// project file is PROJECT; anything about this machine, this person, | ||
| 218 | + /// this window is EDITOR." Always answerable, same as `Theme`: it is | ||
| 219 | + /// about the editor and the project's own numbers, not about a clip. | ||
| 220 | + Settings, | ||
| 213 | } | 221 | } |
| 214 | 222 | ||
| 215 | impl ActionId { | 223 | impl ActionId { |
| @@ -290,6 +298,7 @@ impl ActionId { | |||
| 290 | ActionId::ShowActions => "All actions and their keys…", | 298 | ActionId::ShowActions => "All actions and their keys…", |
| 291 | ActionId::Screenshot => "Save the frame on screen as a PNG", | 299 | ActionId::Screenshot => "Save the frame on screen as a PNG", |
| 292 | ActionId::SubtitleStyle => "Subtitle style: font and size…", | 300 | ActionId::SubtitleStyle => "Subtitle style: font and size…", |
| 301 | + ActionId::Settings => "Settings: project and editor…", | ||
| 293 | } | 302 | } |
| 294 | } | 303 | } |
| 295 | 304 | ||
| @@ -368,6 +377,7 @@ impl ActionId { | |||
| 368 | ActionId::ShowActions => "show-actions", | 377 | ActionId::ShowActions => "show-actions", |
| 369 | ActionId::Screenshot => "screenshot", | 378 | ActionId::Screenshot => "screenshot", |
| 370 | ActionId::SubtitleStyle => "subtitle-style", | 379 | ActionId::SubtitleStyle => "subtitle-style", |
| 380 | + ActionId::Settings => "settings", | ||
| 371 | } | 381 | } |
| 372 | } | 382 | } |
| 373 | 383 | ||
| @@ -448,7 +458,10 @@ impl ActionId { | |||
| 448 | | ActionId::SubtitleStyle | 458 | | ActionId::SubtitleStyle |
| 449 | // ...and whether that window fills the screen: a way of looking, | 459 | // ...and whether that window fills the screen: a way of looking, |
| 450 | // same as the zoom and the theme beside it. | 460 | // same as the zoom and the theme beside it. |
| 451 | - | ActionId::Fullscreen => Category::View, | 461 | + | ActionId::Fullscreen |
| 462 | + // The settings page: it changes no clip and no lane, only the | ||
| 463 | + // project's own numbers and this window's preferences. | ||
| 464 | + | ActionId::Settings => Category::View, | ||
| 452 | ActionId::Cut | 465 | ActionId::Cut |
| 453 | | ActionId::Regroup | 466 | | ActionId::Regroup |
| 454 | | ActionId::Detach | 467 | | ActionId::Detach |
| @@ -1205,6 +1218,10 @@ impl Keymap { | |||
| 1205 | // opened as often as the theme, not a switch thrown once a | 1218 | // opened as often as the theme, not a switch thrown once a |
| 1206 | // session. | 1219 | // session. |
| 1207 | b(ActionId::SubtitleStyle, "y", false), | 1220 | b(ActionId::SubtitleStyle, "y", false), |
| 1221 | + // The consumer-editor convention (Cmd/Ctrl+,) -- free here: | ||
| 1222 | + // bare "," is WalkCutPrev, and nothing else answers to the | ||
| 1223 | + // ctrl chord. | ||
| 1224 | + b(ActionId::Settings, ",", true), | ||
| 1208 | ], | 1225 | ], |
| 1209 | } | 1226 | } |
| 1210 | } | 1227 | } |
| @@ -1483,7 +1500,7 @@ mod tests { | |||
| 1483 | #[test] | 1500 | #[test] |
| 1484 | fn every_default_stroke_reaches_its_action() { | 1501 | fn every_default_stroke_reaches_its_action() { |
| 1485 | let k = Keymap::defaults(); | 1502 | let k = Keymap::defaults(); |
| 1486 | - assert_eq!(k.entries().len(), 73); | 1503 | + assert_eq!(k.entries().len(), 74); |
| 1487 | // The cut odometer: bare walks one, `<`/`>` (what shift+,/shift+. | 1504 | // The cut odometer: bare walks one, `<`/`>` (what shift+,/shift+. |
| 1488 | // actually type) strides ten. | 1505 | // actually type) strides ten. |
| 1489 | assert_eq!(k.lookup(".", false), Some(ActionId::WalkCutNext)); | 1506 | assert_eq!(k.lookup(".", false), Some(ActionId::WalkCutNext)); |
crates/app/src/main.rsmodified+15 -2
| @@ -500,6 +500,11 @@ struct Player { | |||
| 500 | /// pointer: a stroke or a click meant for a row must not also cut the | 500 | /// pointer: a stroke or a click meant for a row must not also cut the |
| 501 | /// timeline. | 501 | /// timeline. |
| 502 | keys_open: bool, | 502 | keys_open: bool, |
| 503 | + /// The settings page is up (`?` overlay's sibling, but a latch rather | ||
| 504 | + /// than a hold -- it carries clickable rows, not a glance-and-release | ||
| 505 | + /// list). Cleared by [`Player::close_card`], the one reset list every | ||
| 506 | + /// opener routes through. | ||
| 507 | + settings_open: bool, | ||
| 503 | /// What has been typed into the card's search box, which is the card's own | 508 | /// What has been typed into the card's search box, which is the card's own |
| 504 | /// input exactly as the export card's digits are (nothing in it takes | 509 | /// input exactly as the export card's digits are (nothing in it takes |
| 505 | /// focus, so the root's key handler is the field). Emptied every time the | 510 | /// focus, so the root's key handler is the field). Emptied every time the |
| @@ -794,6 +799,13 @@ fn main() { | |||
| 794 | // The subtitle style the last session picked, same silence on a missing | 799 | // The subtitle style the last session picked, same silence on a missing |
| 795 | // or unreadable file. | 800 | // or unreadable file. |
| 796 | let (sub_family, sub_text) = load_subtitle_style(); | 801 | let (sub_family, sub_text) = load_subtitle_style(); |
| 802 | + // The auto-proxies default the last session left the switch at, before | ||
| 803 | + // any project's own line ([`engine::edith::Document::auto_proxy`]) | ||
| 804 | + // overrides it the moment one opens. | ||
| 805 | + let auto_proxies_on = player::library::load_auto_proxies_pref(); | ||
| 806 | + // The Proxies default the last session left the switch at, same | ||
| 807 | + // before-any-project-line precedence as the auto-proxies default above. | ||
| 808 | + let proxies_on = player::library::load_proxies_pref(); | ||
| 797 | // Nothing named on the command line is read here. The first file makes the | 809 | // Nothing named on the command line is read here. The first file makes the |
| 798 | // timeline -- a `.edith` restores a whole one, anything else *is* one -- | 810 | // timeline -- a `.edith` restores a whole one, anything else *is* one -- |
| 799 | // and the rest are imports like any other: rows in the library, dragged | 811 | // and the rest are imports like any other: rows in the library, dragged |
| @@ -867,8 +879,8 @@ fn main() { | |||
| 867 | volume_dragging: false, | 879 | volume_dragging: false, |
| 868 | // What a session comes up at, so the first one opened is | 880 | // What a session comes up at, so the first one opened is |
| 869 | // pushed the values it already holds. | 881 | // pushed the values it already holds. |
| 870 | - proxies_on: false, | 882 | + proxies_on, |
| 871 | - auto_proxies_on: true, | 883 | + auto_proxies_on, |
| 872 | // Only ever used with a timeline; 30 keeps the empty | 884 | // Only ever used with a timeline; 30 keeps the empty |
| 873 | // timecode reading in frames rather than in NaN. | 885 | // timecode reading in frames rather than in NaN. |
| 874 | fps: 30., | 886 | fps: 30., |
| @@ -944,6 +956,7 @@ fn main() { | |||
| 944 | autosave_armed: false, | 956 | autosave_armed: false, |
| 945 | keymap: keymap.clone(), | 957 | keymap: keymap.clone(), |
| 946 | keys_open: false, | 958 | keys_open: false, |
| 959 | + settings_open: false, | ||
| 947 | keys_search: String::new(), | 960 | keys_search: String::new(), |
| 948 | keys_scroll: ScrollHandle::new(), | 961 | keys_scroll: ScrollHandle::new(), |
| 949 | lanes_scroll: ScrollHandle::new(), | 962 | lanes_scroll: ScrollHandle::new(), |
crates/app/src/oracle.rsmodified+11 -0
| @@ -102,9 +102,20 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { | |||
| 102 | // touching no timeline, live through an export the same way. | 102 | // touching no timeline, live through an export the same way. |
| 103 | // ...and the cue plate's own font and size: a reading preference like the | 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. | 104 | // theme, never burned into an export, live the same way. |
| 105 | + // | ||
| 106 | + // Settings is not in this list, on purpose: it opens the same modal slot | ||
| 107 | + // the exporting card owns (`Player::open_settings`, one card at a time), | ||
| 108 | + // so a permission this oracle granted here would be a permission nobody | ||
| 109 | + // could ever observe. It is refused below, with every other card. | ||
| 105 | if action == ActionId::Theme || action == ActionId::Fullscreen || action == ActionId::SubtitleStyle { | 110 | if action == ActionId::Theme || action == ActionId::Fullscreen || action == ActionId::SubtitleStyle { |
| 106 | return Enable::Yes; | 111 | return Enable::Yes; |
| 107 | } | 112 | } |
| 113 | + if action == ActionId::Settings { | ||
| 114 | + return match ctx.exporting { | ||
| 115 | + true => Enable::No("an export is running"), | ||
| 116 | + false => Enable::Yes, | ||
| 117 | + }; | ||
| 118 | + } | ||
| 108 | if action == ActionId::ShowActions { | 119 | if action == ActionId::ShowActions { |
| 109 | return match ctx.exporting { | 120 | return match ctx.exporting { |
| 110 | true => Enable::No("an export is running"), | 121 | true => Enable::No("an export is running"), |
crates/app/src/player/actions.rsmodified+1 -0
| @@ -163,6 +163,7 @@ impl Player { | |||
| 163 | // the key handler is what answers this one while there is. | 163 | // the key handler is what answers this one while there is. |
| 164 | ActionId::CancelExport => {} | 164 | ActionId::CancelExport => {} |
| 165 | ActionId::ShowActions => self.show_actions(cx), | 165 | ActionId::ShowActions => self.show_actions(cx), |
| 166 | + ActionId::Settings => self.open_settings(cx), | ||
| 166 | ActionId::Screenshot => self.take_screenshot(cx), | 167 | ActionId::Screenshot => self.take_screenshot(cx), |
| 167 | // Cut machinery (DESIGN.md §6): the subject cut is the marked | 168 | // Cut machinery (DESIGN.md §6): the subject cut is the marked |
| 168 | // clip ([`Selection::anchor`]) -- the oracle already refused | 169 | // clip ([`Selection::anchor`]) -- the oracle already refused |
crates/app/src/player/cards.rsmodified+31 -1
| @@ -853,6 +853,23 @@ impl Player { | |||
| 853 | /// Nothing here is a clip's or even the project's -- it never reaches the | 853 | /// Nothing here is a clip's or even the project's -- it never reaches the |
| 854 | /// export, which never burns a cue into the picture -- so like the mix | 854 | /// export, which never burns a cue into the picture -- so like the mix |
| 855 | /// card it opens with no timeline required and nothing to refuse. | 855 | /// card it opens with no timeline required and nothing to refuse. |
| 856 | + /// Opens the settings page (PROJECT rows beside EDITOR rows, | ||
| 857 | + /// `ui::settings_stance`): the one door for "edit project and editor | ||
| 858 | + /// settings" -- refused while an export is running, same as every other | ||
| 859 | + /// card here, since the exporting card owns this same modal slot | ||
| 860 | + /// (`oracle.rs` agrees: `ActionId::Settings` is `No` there too, for the | ||
| 861 | + /// same reason). | ||
| 862 | + pub(crate) fn open_settings(&mut self, cx: &mut Context<Self>) { | ||
| 863 | + if self.exporting().is_some() { | ||
| 864 | + return; | ||
| 865 | + } | ||
| 866 | + // One card at a time -- `close_card`'s own rule. | ||
| 867 | + self.close_card(); | ||
| 868 | + self.settings_open = true; | ||
| 869 | + self.context_menu = None; | ||
| 870 | + cx.notify(); | ||
| 871 | + } | ||
| 872 | + | ||
| 856 | pub(crate) fn open_subtitle_style(&mut self, cx: &mut Context<Self>) { | 873 | pub(crate) fn open_subtitle_style(&mut self, cx: &mut Context<Self>) { |
| 857 | // One card at a time -- `close_card`'s own rule. | 874 | // One card at a time -- `close_card`'s own rule. |
| 858 | self.close_card(); | 875 | self.close_card(); |
| @@ -1240,7 +1257,20 @@ impl Player { | |||
| 1240 | } | 1257 | } |
| 1241 | 1258 | ||
| 1242 | pub(crate) fn modal(&self) -> bool { | 1259 | pub(crate) fn modal(&self) -> bool { |
| 1260 | + self.card_open() || self.exporting().is_some() | ||
| 1261 | + } | ||
| 1262 | + | ||
| 1263 | + /// Whether an actual card owns the screen -- [`Player::modal`] minus the | ||
| 1264 | + /// exporting flag, which is a *state* an action can still be refused | ||
| 1265 | + /// over (spoken by the oracle) rather than a surface sitting on top of | ||
| 1266 | + /// the keyboard the way every card here does. The darkroom's key guard | ||
| 1267 | + /// ([`ui::stance`]'s `on_key_down`) reads this one instead of `modal()` | ||
| 1268 | + /// so a bare export in progress, with no card actually open, still lets | ||
| 1269 | + /// a keystroke reach `enable()`/`act()` and be answered -- Yes, or a | ||
| 1270 | + /// spoken `No` -- instead of being swallowed before either is asked. | ||
| 1271 | + pub(crate) fn card_open(&self) -> bool { | ||
| 1243 | self.keys_open | 1272 | self.keys_open |
| 1273 | + || self.settings_open | ||
| 1244 | || self.export_open | 1274 | || self.export_open |
| 1245 | || self.eq_open.is_some() | 1275 | || self.eq_open.is_some() |
| 1246 | || self.color_open.is_some() | 1276 | || self.color_open.is_some() |
| @@ -1249,7 +1279,6 @@ impl Player { | |||
| 1249 | || self.silence_open.is_some() | 1279 | || self.silence_open.is_some() |
| 1250 | || self.mix_open | 1280 | || self.mix_open |
| 1251 | || self.subtitle_style_open | 1281 | || self.subtitle_style_open |
| 1252 | - || self.exporting().is_some() | ||
| 1253 | } | 1282 | } |
| 1254 | 1283 | ||
| 1255 | /// The pointer's way out of whatever card is up: what every scrim's press | 1284 | /// The pointer's way out of whatever card is up: what every scrim's press |
| @@ -1262,6 +1291,7 @@ impl Player { | |||
| 1262 | /// "the" card and closing all of them are the same act. | 1291 | /// "the" card and closing all of them are the same act. |
| 1263 | pub(crate) fn close_card(&mut self) { | 1292 | pub(crate) fn close_card(&mut self) { |
| 1264 | self.keys_open = false; | 1293 | self.keys_open = false; |
| 1294 | + self.settings_open = false; | ||
| 1265 | self.keys_search.clear(); | 1295 | self.keys_search.clear(); |
| 1266 | self.rebinding = None; | 1296 | self.rebinding = None; |
| 1267 | self.export_open = false; | 1297 | self.export_open = false; |
crates/app/src/player/library.rsmodified+80 -0
| @@ -9,6 +9,69 @@ const AUTOSAVE_DEBOUNCE: Duration = Duration::from_secs(5); | |||
| 9 | /// periodic half of "debounced + periodic". | 9 | /// periodic half of "debounced + periodic". |
| 10 | const AUTOSAVE_PERIOD: Duration = Duration::from_secs(60); | 10 | const AUTOSAVE_PERIOD: Duration = Duration::from_secs(60); |
| 11 | 11 | ||
| 12 | +/// Where the auto-proxies *default* survives, beside the keybindings and the | ||
| 13 | +/// theme, same corner-cut persistence as [`crate::subs::subtitle_style_path`]: | ||
| 14 | +/// a torn write costs this one preference and nothing else. | ||
| 15 | +/// | ||
| 16 | +/// This is the window's own answer, not the project's: a project that was | ||
| 17 | +/// saved with the switch set already carries its own line | ||
| 18 | +/// ([`engine::edith::Document::auto_proxy`]) and always wins once one is | ||
| 19 | +/// open ([`Player::install_project`]) -- this file is only ever read before | ||
| 20 | +/// that, which is what makes it the difference between "the switch reverts to | ||
| 21 | +/// On on every relaunch" and "the switch stayed how it was left". | ||
| 22 | +pub(crate) fn auto_proxies_pref_path() -> PathBuf { | ||
| 23 | + crate::keymap::Keymap::config_path().with_file_name("auto-proxies") | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +/// `On` unless the file says `off`; missing, unreadable or garbled all read as | ||
| 27 | +/// `On`, the same default the field has always started at -- a preference | ||
| 28 | +/// file is not the user's work, so a bad one is worth no message at startup. | ||
| 29 | +pub(crate) fn load_auto_proxies_pref() -> bool { | ||
| 30 | + match std::fs::read_to_string(auto_proxies_pref_path()) { | ||
| 31 | + Ok(text) => text.trim() != "off", | ||
| 32 | + Err(_) => true, | ||
| 33 | + } | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +/// Writes the pick whole, the way [`crate::ui::theme::save`] writes the | ||
| 37 | +/// palette. | ||
| 38 | +pub(crate) fn save_auto_proxies_pref(on: bool) -> std::io::Result<()> { | ||
| 39 | + let path = auto_proxies_pref_path(); | ||
| 40 | + if let Some(dir) = path.parent() { | ||
| 41 | + std::fs::create_dir_all(dir)?; | ||
| 42 | + } | ||
| 43 | + std::fs::write(path, if on { "on\n" } else { "off\n" }) | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +/// Where the Proxies *default* survives -- Proxies' own sibling of | ||
| 47 | +/// [`auto_proxies_pref_path`], same corner-cut persistence. | ||
| 48 | +/// | ||
| 49 | +/// This is the window's own answer, not the project's: a project saved with | ||
| 50 | +/// the switch set carries its own line and always wins once one is open | ||
| 51 | +/// ([`Player::install_project`]) -- this file is only ever read before that. | ||
| 52 | +pub(crate) fn proxies_pref_path() -> PathBuf { | ||
| 53 | + crate::keymap::Keymap::config_path().with_file_name("proxies") | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +/// `Off` unless the file says `on`; missing, unreadable or garbled all read as | ||
| 57 | +/// `Off`, the same default the field has always started at -- a preference | ||
| 58 | +/// file is not the user's work, so a bad one is worth no message at startup. | ||
| 59 | +pub(crate) fn load_proxies_pref() -> bool { | ||
| 60 | + match std::fs::read_to_string(proxies_pref_path()) { | ||
| 61 | + Ok(text) => text.trim() == "on", | ||
| 62 | + Err(_) => false, | ||
| 63 | + } | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +/// Writes the pick whole, the way [`save_auto_proxies_pref`] does. | ||
| 67 | +pub(crate) fn save_proxies_pref(on: bool) -> std::io::Result<()> { | ||
| 68 | + let path = proxies_pref_path(); | ||
| 69 | + if let Some(dir) = path.parent() { | ||
| 70 | + std::fs::create_dir_all(dir)?; | ||
| 71 | + } | ||
| 72 | + std::fs::write(path, if on { "on\n" } else { "off\n" }) | ||
| 73 | +} | ||
| 74 | + | ||
| 12 | impl Player { | 75 | impl Player { |
| 13 | /// The one way a library row reaches the timeline: the Add button and a row | 76 | /// The one way a library row reaches the timeline: the Add button and a row |
| 14 | /// dragged onto a lane both come here, so there is a single answer to what | 77 | /// dragged onto a lane both come here, so there is a single answer to what |
| @@ -738,6 +801,14 @@ impl Player { | |||
| 738 | (true, n, m) => format!("PROXIES ON — cutting on {n}, {m} still being made"), | 801 | (true, n, m) => format!("PROXIES ON — cutting on {n}, {m} still being made"), |
| 739 | }; | 802 | }; |
| 740 | eprintln!("{text}"); | 803 | eprintln!("{text}"); |
| 804 | + // Kept for the next launch, not only the next project -- the same | ||
| 805 | + // reason auto-proxies keeps one ([`save_auto_proxies_pref`]). | ||
| 806 | + if let Err(e) = save_proxies_pref(on) { | ||
| 807 | + let path = proxies_pref_path(); | ||
| 808 | + self.notify_user( | ||
| 809 | + format!("PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", path.display()).into(), | ||
| 810 | + ); | ||
| 811 | + } | ||
| 741 | self.notify_user(text.into()); | 812 | self.notify_user(text.into()); |
| 742 | // The switch reseeks the session, and the wait for that picture is what | 813 | // The switch reseeks the session, and the wait for that picture is what |
| 743 | // this clears -- with nothing open there is no open to wait for, and a | 814 | // this clears -- with nothing open there is no open to wait for, and a |
| @@ -770,6 +841,15 @@ impl Player { | |||
| 770 | false => "AUTO PROXIES OFF — no import makes one; Proxies on is what asks for them", | 841 | false => "AUTO PROXIES OFF — no import makes one; Proxies on is what asks for them", |
| 771 | }; | 842 | }; |
| 772 | eprintln!("{text}"); | 843 | eprintln!("{text}"); |
| 844 | + // Kept for the next launch, not only the next project -- a flip made | ||
| 845 | + // with nothing open, or a project never saved after it, used to | ||
| 846 | + // vanish the moment the window closed ([`load_auto_proxies_pref`]). | ||
| 847 | + if let Err(e) = save_auto_proxies_pref(on) { | ||
| 848 | + let path = auto_proxies_pref_path(); | ||
| 849 | + self.notify_user( | ||
| 850 | + format!("AUTO PROXIES DEFAULT COULD NOT BE KEPT — {} — {e}", path.display()).into(), | ||
| 851 | + ); | ||
| 852 | + } | ||
| 773 | self.notify_user(text.into()); | 853 | self.notify_user(text.into()); |
| 774 | cx.notify(); | 854 | cx.notify(); |
| 775 | } | 855 | } |
crates/app/src/tests/cards.rsmodified+52 -3
| @@ -25,7 +25,7 @@ fn no_overlaid_state_in_the_stance_goes_modal_without_painting_something() { | |||
| 25 | ); | 25 | ); |
| 26 | } | 26 | } |
| 27 | let guard_at = stance | 27 | let guard_at = stance |
| 28 | - .find("if this.rebinding.is_some() || this.overlaid() {") | 28 | + .find("if this.rebinding.is_some()\n || this.card_open()") |
| 29 | .expect("the stance's modal guard"); | 29 | .expect("the stance's modal guard"); |
| 30 | let guard = &stance[guard_at..guard_at + 1600]; | 30 | let guard = &stance[guard_at..guard_at + 1600]; |
| 31 | for field in ["this.context_menu = None", "this.library_menu = None", "this.picker = None"] { | 31 | for field in ["this.context_menu = None", "this.library_menu = None", "this.picker = None"] { |
| @@ -43,8 +43,15 @@ fn every_modal_field_has_a_mounted_surface_somewhere_in_the_darkroom() { | |||
| 43 | // rather than hand-copied -- a hand-copied list is exactly the shape | 43 | // rather than hand-copied -- a hand-copied list is exactly the shape |
| 44 | // that let three cards go modal with nothing mounted (GAP 2): the field | 44 | // that let three cards go modal with nothing mounted (GAP 2): the field |
| 45 | // was in `modal()` and nowhere in this test. | 45 | // was in `modal()` and nowhere in this test. |
| 46 | - let modal_body = fn_body("modal"); | 46 | + // `modal()` itself is now just `card_open() || exporting().is_some()` |
| 47 | - let mut fields = Vec::new(); | 47 | + // ([`Player::card_open`], split out so the darkroom's key guard can read |
| 48 | + // "a card is open" without also reading "an export is running" -- see | ||
| 49 | + // `ui::stance`'s guard and `an_export_alone_does_not_lock_the_stances_keyboard` | ||
| 50 | + // below) -- so the card fields this test pins live in `card_open()` now, | ||
| 51 | + // with `exporting` added by hand since `modal()`'s own body names it | ||
| 52 | + // directly rather than through a field this splitter would find. | ||
| 53 | + let modal_body = fn_body("card_open"); | ||
| 54 | + let mut fields = vec!["exporting".to_string()]; | ||
| 48 | for chunk in modal_body.split("self.").skip(1) { | 55 | for chunk in modal_body.split("self.").skip(1) { |
| 49 | let name: String = chunk | 56 | let name: String = chunk |
| 50 | .chars() | 57 | .chars() |
| @@ -75,6 +82,7 @@ fn every_modal_field_has_a_mounted_surface_somewhere_in_the_darkroom() { | |||
| 75 | "silence_open" => "silence_card(", | 82 | "silence_open" => "silence_card(", |
| 76 | "mix_open" => "mix_card(", | 83 | "mix_open" => "mix_card(", |
| 77 | "subtitle_style_open" => "subtitle_style_card(", | 84 | "subtitle_style_open" => "subtitle_style_card(", |
| 85 | + "settings_open" => "settings_stance::render(", | ||
| 78 | other => panic!( | 86 | other => panic!( |
| 79 | "Player::modal() now reads `self.{other}` with no entry in this test's \ | 87 | "Player::modal() now reads `self.{other}` with no entry in this test's \ |
| 80 | mount_for map -- add one naming the function that mounts its surface in \ | 88 | mount_for map -- add one naming the function that mounts its surface in \ |
| @@ -95,6 +103,47 @@ fn every_modal_field_has_a_mounted_surface_somewhere_in_the_darkroom() { | |||
| 95 | } | 103 | } |
| 96 | } | 104 | } |
| 97 | 105 | ||
| 106 | +/// D2's class: an action refused while a modal is up used to be sworn to | ||
| 107 | +/// silence, because the stance's own key guard ate the keystroke before | ||
| 108 | +/// `enable()`/`act()` ever saw it -- driven live with `ctrl+,` mid-export | ||
| 109 | +/// (no card open, only `exporting()` true): no notice plate, ledger reading | ||
| 110 | +/// `—`. `ActionId::Settings`'s own refusal string (`oracle.rs`) was sound and | ||
| 111 | +/// simply never reachable. | ||
| 112 | +/// | ||
| 113 | +/// The fix lives in the guard, not in Settings alone (the charter this test | ||
| 114 | +/// pins is explicit that a per-action patch would leave every *other* action | ||
| 115 | +/// refused during a bare export equally mute): [`Player::card_open`] is | ||
| 116 | +/// `modal()` with `exporting()` split out, and the stance's guard now reads | ||
| 117 | +/// `card_open()` -- never `overlaid()`/`modal()` directly, both of which | ||
| 118 | +/// still fold `exporting()` back in for the surfaces that are meant to keep | ||
| 119 | +/// blocking imports and edits during an export ([`Player::modal`]'s own | ||
| 120 | +/// doc comment). This is a source scan, the same kind the guard above it | ||
| 121 | +/// already is: this binary has no `TestAppContext` to actually press `ctrl+,` | ||
| 122 | +/// mid-export and read the notice plate back. | ||
| 123 | +#[test] | ||
| 124 | +fn the_stances_key_guard_does_not_swallow_a_bare_export_before_the_oracle_is_asked() { | ||
| 125 | + let stance = src_text("ui/stance.rs"); | ||
| 126 | + let guard_at = stance | ||
| 127 | + .find("if this.rebinding.is_some()\n || this.card_open()") | ||
| 128 | + .expect("the stance's modal guard moved -- update this test's search string"); | ||
| 129 | + let guard_line = &stance[guard_at..guard_at + 200]; | ||
| 130 | + assert!( | ||
| 131 | + !guard_line.contains("overlaid()") && !guard_line.contains("this.modal()"), | ||
| 132 | + "the stance's key guard reads overlaid()/modal() again, which folds `exporting()` \ | ||
| 133 | + back in and re-mutes every refusal an export-only moment should be able to speak (D2)" | ||
| 134 | + ); | ||
| 135 | + // The split itself: card_open() must never grow an exporting read of its | ||
| 136 | + // own, or the guard above -- which trusts card_open() to mean "an actual | ||
| 137 | + // card/menu/rebind owns the keyboard" -- silently regains the same mute. | ||
| 138 | + let card_open_body = fn_body("card_open"); | ||
| 139 | + assert!( | ||
| 140 | + !card_open_body.contains("exporting"), | ||
| 141 | + "Player::card_open() now reads `exporting` -- that reintroduces the swallow \ | ||
| 142 | + `the_stances_key_guard_does_not_swallow_a_bare_export_before_the_oracle_is_asked` \ | ||
| 143 | + exists to keep out; `modal()` is where `exporting()` belongs" | ||
| 144 | + ); | ||
| 145 | +} | ||
| 146 | + | ||
| 98 | #[test] | 147 | #[test] |
| 99 | fn a_bare_escape_leaves_player_fullscreen_before_anything_under_it() { | 148 | fn a_bare_escape_leaves_player_fullscreen_before_anything_under_it() { |
| 100 | // Fires while the picture-only layout is up, on the same bare escape | 149 | // Fires while the picture-only layout is up, on the same bare escape |
crates/app/src/tests/editing.rsmodified+5 -1
| @@ -899,7 +899,11 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { | |||
| 899 | // word to the user's own config file, which is why it is one of the | 899 | // word to the user's own config file, which is why it is one of the |
| 900 | // actions besides the cancel that stay live here. Fullscreen is the | 900 | // actions besides the cancel that stay live here. Fullscreen is the |
| 901 | // same kind of thing: the platform's own window toggle, touching no | 901 | // same kind of thing: the platform's own window toggle, touching no |
| 902 | - // edit list either. | 902 | + // edit list either. Settings is NOT among them, on purpose: it opens |
| 903 | + // the same modal slot the exporting card is already standing in | ||
| 904 | + // (`Player::open_settings`), so a permission granted here would be | ||
| 905 | + // one nobody could ever act on -- driven and confirmed: both the `,` | ||
| 906 | + // chord and the spine glyph leave the exporting card on screen. | ||
| 903 | let allowed = action == ActionId::CancelExport | 907 | let allowed = action == ActionId::CancelExport |
| 904 | || action == ActionId::Theme | 908 | || action == ActionId::Theme |
| 905 | || action == ActionId::Fullscreen | 909 | || action == ActionId::Fullscreen |
crates/app/src/tests/layout.rsmodified+97 -0
| @@ -2175,3 +2175,100 @@ fn every_darkroom_menu_sizes_its_list_against_the_floor_room_not_the_raw_viewpor | |||
| 2175 | assert!(sizings > 0, "{file} no longer opens any menu -- update this guard"); | 2175 | assert!(sizings > 0, "{file} no longer opens any menu -- update this guard"); |
| 2176 | } | 2176 | } |
| 2177 | } | 2177 | } |
| 2178 | + | ||
| 2179 | +/// The settings page's own organising rule: PROJECT rows open only the | ||
| 2180 | +/// doors that write into the `.edith` file ([`Player::open_picker`], | ||
| 2181 | +/// [`Player::open_mix`]), and EDITOR rows open only the doors that do not | ||
| 2182 | +/// ([`Player::toggle_proxies`], [`Player::toggle_auto_proxies`], | ||
| 2183 | +/// [`Player::open_subtitle_style`]) -- never the config-file writers | ||
| 2184 | +/// (`ui::dock_stance::config_path`/`ui::theme::config_path`/ | ||
| 2185 | +/// `keymap::Keymap::config_path`) directly, which every editor-side row | ||
| 2186 | +/// already routes around through its own opener. A row wired to the wrong | ||
| 2187 | +/// section's opener is exactly the regression a page organised around two | ||
| 2188 | +/// headings invites; this pins each half to its own doors so the two lists | ||
| 2189 | +/// cannot cross. | ||
| 2190 | +#[test] | ||
| 2191 | +fn settings_project_and_editor_sections_open_disjoint_doors() { | ||
| 2192 | + let source = src_text("ui/settings_stance.rs"); | ||
| 2193 | + let project_start = source.find("fn project_section(").expect("the project section"); | ||
| 2194 | + let editor_start = source.find("fn editor_section(").expect("the editor section"); | ||
| 2195 | + let render_start = source.find("pub(crate) fn render(").expect("the page's render fn"); | ||
| 2196 | + assert!(project_start < editor_start && editor_start < render_start, "the three fns moved; this scan is blind"); | ||
| 2197 | + let project_body = &source[project_start..editor_start]; | ||
| 2198 | + let editor_body = &source[editor_start..render_start]; | ||
| 2199 | + | ||
| 2200 | + for door in ["open_picker(", "open_mix("] { | ||
| 2201 | + assert!(project_body.contains(door), "PROJECT section no longer opens {door} -- update this guard"); | ||
| 2202 | + assert!( | ||
| 2203 | + !editor_body.contains(door), | ||
| 2204 | + "EDITOR section opens {door}, a project-file door -- that value belongs in PROJECT, not here" | ||
| 2205 | + ); | ||
| 2206 | + } | ||
| 2207 | + for door in ["toggle_proxies(", "toggle_auto_proxies(", "open_subtitle_style("] { | ||
| 2208 | + assert!(editor_body.contains(door), "EDITOR section no longer opens {door} -- update this guard"); | ||
| 2209 | + assert!( | ||
| 2210 | + !project_body.contains(door), | ||
| 2211 | + "PROJECT section opens {door}, an editor-only door -- that value belongs in EDITOR, not here" | ||
| 2212 | + ); | ||
| 2213 | + } | ||
| 2214 | + // Neither section writes a config file straight from a row: both go | ||
| 2215 | + // through an opener, which is the one place a config-file write (the | ||
| 2216 | + // subtitle style card's Save, this window's next project load) is | ||
| 2217 | + // allowed to live. | ||
| 2218 | + for path_fn in ["dock_stance::config_path", "theme::config_path", "Keymap::config_path"] { | ||
| 2219 | + assert!(!project_body.contains(path_fn), "PROJECT section touches {path_fn} directly"); | ||
| 2220 | + assert!(!editor_body.contains(path_fn), "EDITOR section touches {path_fn} directly"); | ||
| 2221 | + } | ||
| 2222 | +} | ||
| 2223 | + | ||
| 2224 | +/// D1's own class, pinned per row rather than per section: a row's hint can | ||
| 2225 | +/// claim a `~/.config/edith` default (the section header claims nothing on | ||
| 2226 | +/// its own since [`settings_project_and_editor_sections_open_disjoint_doors`]'s | ||
| 2227 | +/// commit, so a lying section head no longer slips past a reviewer -- but a | ||
| 2228 | +/// lying *row* hint did, on Proxies, because nothing scanned row text at all). | ||
| 2229 | +/// For every row whose own hint text names that file, this requires the | ||
| 2230 | +/// matching `save_*_pref`/`load_*_pref` pair to actually exist in | ||
| 2231 | +/// `player/library.rs` -- the exact gap Proxies shipped with: a hint promising | ||
| 2232 | +/// a default the row's own door never wrote. | ||
| 2233 | +#[test] | ||
| 2234 | +fn settings_row_hints_naming_config_edith_have_a_matching_pref_pair() { | ||
| 2235 | + let source = src_text("ui/settings_stance.rs"); | ||
| 2236 | + let library = src_text("player/library.rs"); | ||
| 2237 | + // (row id, the stem its pref functions are named after) | ||
| 2238 | + for (row_id, stem) in [("settings-proxies", "proxies"), ("settings-auto-proxies", "auto_proxies")] { | ||
| 2239 | + let row_start = source.find(&format!("\"{row_id}\"")).unwrap_or_else(|| panic!("{row_id} row moved or renamed -- update this guard")); | ||
| 2240 | + let row_end = source[row_start..].find(",\n ))").map_or(source.len(), |i| row_start + i); | ||
| 2241 | + let row_text = &source[row_start..row_end]; | ||
| 2242 | + if !row_text.contains("~/.config/edith") { | ||
| 2243 | + continue; | ||
| 2244 | + } | ||
| 2245 | + for prefix in ["save_", "load_"] { | ||
| 2246 | + let fn_name = format!("{prefix}{stem}_pref"); | ||
| 2247 | + assert!( | ||
| 2248 | + library.contains(&format!("fn {fn_name}(")), | ||
| 2249 | + "{row_id}'s hint claims a ~/.config/edith default but \ | ||
| 2250 | + player/library.rs has no `{fn_name}` -- the hint promises \ | ||
| 2251 | + storage the row does not have" | ||
| 2252 | + ); | ||
| 2253 | + } | ||
| 2254 | + } | ||
| 2255 | +} | ||
| 2256 | + | ||
| 2257 | +/// With no project open, a PROJECT row must not fall back to a bare noun | ||
| 2258 | +/// ("Size"/"Rate"/"HDR") standing in the value slot -- it reads as a value | ||
| 2259 | +/// while carrying none. This binary has no `TestAppContext` to actually | ||
| 2260 | +/// render the page with `player.session` empty, so this is a source scan | ||
| 2261 | +/// for the fallback strings the bug shipped as, same as the guard above it. | ||
| 2262 | +#[test] | ||
| 2263 | +fn settings_project_rows_have_no_bare_noun_placeholder() { | ||
| 2264 | + let source = src_text("ui/settings_stance.rs"); | ||
| 2265 | + let project_start = source.find("fn project_section(").expect("the project section"); | ||
| 2266 | + let editor_start = source.find("fn editor_section(").expect("the editor section"); | ||
| 2267 | + let project_body = &source[project_start..editor_start]; | ||
| 2268 | + for placeholder in ["\"Size\".to_string()", "\"Rate\".to_string()", "\"HDR\".to_string()"] { | ||
| 2269 | + assert!( | ||
| 2270 | + !project_body.contains(placeholder), | ||
| 2271 | + "a PROJECT row fell back to the bare noun {placeholder} -- it reads as a value with no project open" | ||
| 2272 | + ); | ||
| 2273 | + } | ||
| 2274 | +} | ||
crates/app/src/tests/media.rsmodified+41 -0
| @@ -5,6 +5,7 @@ use super::*; | |||
| 5 | use crate::subs::{ | 5 | use crate::subs::{ |
| 6 | load_subtitle_style, save_subtitle_style, sub_line_h_for, subtitle_style_path, SUB_SIZE_RANGE, | 6 | load_subtitle_style, save_subtitle_style, sub_line_h_for, subtitle_style_path, SUB_SIZE_RANGE, |
| 7 | }; | 7 | }; |
| 8 | +use crate::player::library::{auto_proxies_pref_path, load_auto_proxies_pref, save_auto_proxies_pref}; | ||
| 8 | use crate::ui::preview::{bgra_to_rgba, screenshot_path}; | 9 | use crate::ui::preview::{bgra_to_rgba, screenshot_path}; |
| 9 | 10 | ||
| 10 | /// The import line's own state machine, driven the way a repaint drives | 11 | /// The import line's own state machine, driven the way a repaint drives |
| @@ -951,6 +952,46 @@ fn the_subtitle_style_file_round_trips_or_falls_back_to_defaults() { | |||
| 951 | std::fs::remove_dir_all(&dir).ok(); | 952 | std::fs::remove_dir_all(&dir).ok(); |
| 952 | } | 953 | } |
| 953 | 954 | ||
| 955 | +/// The auto-proxies default, round-tripped through a scratch config | ||
| 956 | +/// directory the same way the subtitle style is above -- the door D1 wired | ||
| 957 | +/// it through, so this is what the settings page header can now honestly | ||
| 958 | +/// call the same claim it makes about Proxies: a project's own line always | ||
| 959 | +/// beats this one once one is open ([`engine::edith::Document::auto_proxy`]), | ||
| 960 | +/// but with nothing open (or nothing saved since the flip) this is what a | ||
| 961 | +/// relaunch reads instead of the field's hardcoded `true`. | ||
| 962 | +#[test] | ||
| 963 | +fn the_auto_proxies_default_round_trips_through_its_own_config_file_or_falls_back_to_on() { | ||
| 964 | + let dir = std::env::temp_dir().join(format!( | ||
| 965 | + "edith-auto-proxies-pref-test-{}-{}", | ||
| 966 | + std::process::id(), | ||
| 967 | + std::time::SystemTime::now() | ||
| 968 | + .duration_since(std::time::UNIX_EPOCH) | ||
| 969 | + .unwrap() | ||
| 970 | + .as_nanos() | ||
| 971 | + )); | ||
| 972 | + std::fs::create_dir_all(&dir).unwrap(); | ||
| 973 | + // Scoped to this test alone, the same guarantee the subtitle-style test | ||
| 974 | + // above makes for the same env var. | ||
| 975 | + unsafe { std::env::set_var("XDG_CONFIG_HOME", &dir) }; | ||
| 976 | + | ||
| 977 | + // Nothing written yet: On, the field's own long-standing default. | ||
| 978 | + assert!(load_auto_proxies_pref(), "a missing file must read as On"); | ||
| 979 | + | ||
| 980 | + save_auto_proxies_pref(false).unwrap(); | ||
| 981 | + assert!(!load_auto_proxies_pref(), "off must round-trip"); | ||
| 982 | + | ||
| 983 | + save_auto_proxies_pref(true).unwrap(); | ||
| 984 | + assert!(load_auto_proxies_pref(), "on must round-trip too, not just off"); | ||
| 985 | + | ||
| 986 | + // Garbled bytes -- a stray edit, or a future dialect -- read as On rather | ||
| 987 | + // than failing a startup on someone else's edit of the file. | ||
| 988 | + std::fs::write(auto_proxies_pref_path(), "not on or off\n").unwrap(); | ||
| 989 | + assert!(load_auto_proxies_pref(), "unreadable content must fall back to On"); | ||
| 990 | + | ||
| 991 | + unsafe { std::env::remove_var("XDG_CONFIG_HOME") }; | ||
| 992 | + std::fs::remove_dir_all(&dir).ok(); | ||
| 993 | +} | ||
| 994 | + | ||
| 954 | /// The cue's line height scales with its size, on the same ratio the defaults | 995 | /// 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 | 996 | /// draw at -- a bigger plate wants more room per line, not letters growing |
| 956 | /// inside an unchanged one. | 997 | /// inside an unchanged one. |
crates/app/src/ui/mod.rsmodified+1 -0
| @@ -10,6 +10,7 @@ pub mod inspector; | |||
| 10 | pub mod library; | 10 | pub mod library; |
| 11 | pub mod overlays; | 11 | pub mod overlays; |
| 12 | pub mod preview; | 12 | pub mod preview; |
| 13 | +pub mod settings_stance; | ||
| 13 | pub mod spine_stance; | 14 | pub mod spine_stance; |
| 14 | pub mod stance; | 15 | pub mod stance; |
| 15 | pub mod theme; | 16 | pub mod theme; |
crates/app/src/ui/settings_stance.rsadded+302 -0
| @@ -0,0 +1,302 @@ | |||
| 1 | +//! The settings page (user complaint: "we should have a settings page that | ||
| 2 | +//! we can edit project and editor settings"). Two clearly-headed sections, | ||
| 3 | +//! per the split rule a rubric pass settled: | ||
| 4 | +//! | ||
| 5 | +//! - PROJECT: anything that changes the rendered output or is stored in the | ||
| 6 | +//! `.edith` file -- resolution, fps, sample-rate, the HDR tonemap, the mix. | ||
| 7 | +//! - EDITOR: anything about this machine, this person, this window -- | ||
| 8 | +//! proxies/auto-proxies (this window's decode/import policy, mirrored into | ||
| 9 | +//! the project like the resolution row above it once one is open -- | ||
| 10 | +//! [`engine::PlaybackSession::set_proxies`] -- but with a window-level | ||
| 11 | +//! default, `false`/`true`, that answers before any project is, exactly as | ||
| 12 | +//! [`inspector.rs`]'s own legacy row already does) and the subtitle font | ||
| 13 | +//! (a reading preference, kept in `~/.config/edith` like the theme beside | ||
| 14 | +//! it, per [`crate::load_subtitle_style`], and never written into a | ||
| 15 | +//! project at all). | ||
| 16 | +//! | ||
| 17 | +//! Every row here reuses an opener or a picker this editor already has | ||
| 18 | +//! ([`Player::open_picker`], [`Player::open_mix`], [`Player::open_subtitle_style`], | ||
| 19 | +//! [`Player::toggle_proxies`], [`Player::toggle_auto_proxies`]) -- no new card | ||
| 20 | +//! body, no second source of truth for what a value is or how it is set. | ||
| 21 | +//! Values apply live through those same doors; there is no Apply button here | ||
| 22 | +//! to be inconsistent with the rest of the room. | ||
| 23 | +//! | ||
| 24 | +//! Seams left for other builders (this task's scope boundary): the HDR | ||
| 25 | +//! mastering-display target row (a monitor fact, not in `inspector.rs`'s own | ||
| 26 | +//! project section yet) has no row here either -- it plugs into | ||
| 27 | +//! `project_section` below, beside the tonemap row it is the pair of. A | ||
| 28 | +//! finer fps/sample-rate/tone picker is the same builder's to extend; this | ||
| 29 | +//! page only ever asks for [`Pick::Fps`]/[`Pick::SampleRate`]/[`Pick::Tone`] | ||
| 30 | +//! exactly as `inspector.rs`'s legacy panel already does. | ||
| 31 | + | ||
| 32 | +use crate::*; | ||
| 33 | +use crate::ui::type_scale; | ||
| 34 | + | ||
| 35 | +/// A 9px uppercase Archivo section head, `ink3` -- [`dock_stance::section_head`]'s | ||
| 36 | +/// exact shape, repeated rather than imported across a `pub(crate)` seam for | ||
| 37 | +/// one nine-line function. | ||
| 38 | +fn section_head(text: impl Into<SharedString>) -> impl IntoElement { | ||
| 39 | + let style = type_scale::head(); | ||
| 40 | + div() | ||
| 41 | + .flex_none() | ||
| 42 | + .pt(px(4.)) | ||
| 43 | + .font(style.font) | ||
| 44 | + .text_size(style.size) | ||
| 45 | + .text_color(rgb(INK3())) | ||
| 46 | + .child(text.into()) | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +/// One row: a ≤16-char label, its current value in mono (units carried, | ||
| 50 | +/// never a bare number -- the density rule this task's charter names), and | ||
| 51 | +/// a hover hint carrying the sentence a label must not. [`dock_stance::ghost_verb`]'s | ||
| 52 | +/// anatomy, with a live value where that row has a chord badge -- this room | ||
| 53 | +/// is a picker's own door, not a keystroke's. | ||
| 54 | +fn row( | ||
| 55 | + id: &'static str, | ||
| 56 | + label_text: &'static str, | ||
| 57 | + value: impl Into<SharedString>, | ||
| 58 | + hint: &'static str, | ||
| 59 | + player: &Player, | ||
| 60 | + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | ||
| 61 | +) -> impl IntoElement { | ||
| 62 | + row_ink(id, label_text, value, hint, player, on_click, INK1()) | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +/// [`row`] with the value's ink chosen by the caller -- [`INK4`] for a value | ||
| 66 | +/// that is not really a value yet (nothing to show until a project opens), | ||
| 67 | +/// so it reads as absent rather than as a fifth real setting. | ||
| 68 | +fn row_ink( | ||
| 69 | + id: &'static str, | ||
| 70 | + label_text: &'static str, | ||
| 71 | + value: impl Into<SharedString>, | ||
| 72 | + hint: &'static str, | ||
| 73 | + player: &Player, | ||
| 74 | + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | ||
| 75 | + value_ink: u32, | ||
| 76 | +) -> impl IntoElement { | ||
| 77 | + let value: SharedString = value.into(); | ||
| 78 | + let hint: SharedString = hint.into(); | ||
| 79 | + let label_style = type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM); | ||
| 80 | + let value_style = type_scale::mono(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM); | ||
| 81 | + let exporting = player.exporting().is_some(); | ||
| 82 | + div() | ||
| 83 | + .id(id) | ||
| 84 | + .flex_none() | ||
| 85 | + .flex() | ||
| 86 | + .items_center() | ||
| 87 | + .justify_between() | ||
| 88 | + .h(px(CONTROL_H)) | ||
| 89 | + .px(px(8.)) | ||
| 90 | + .rounded(px(3.)) | ||
| 91 | + .tooltip(move |_, cx| cx.new(|_| Tip(hint.clone())).into()) | ||
| 92 | + .when(exporting, |d| d.opacity(0.4).cursor_not_allowed()) | ||
| 93 | + .when(!exporting, |d| { | ||
| 94 | + d.cursor_pointer().hover(|s| s.bg(rgb(DARK_RAISED()))).on_click(on_click) | ||
| 95 | + }) | ||
| 96 | + .child( | ||
| 97 | + div() | ||
| 98 | + .font(label_style.font) | ||
| 99 | + .text_size(label_style.size) | ||
| 100 | + .text_color(rgb(INK2())) | ||
| 101 | + .child(label_text), | ||
| 102 | + ) | ||
| 103 | + .child( | ||
| 104 | + div() | ||
| 105 | + .flex_none() | ||
| 106 | + .font(value_style.font) | ||
| 107 | + .text_size(value_style.size) | ||
| 108 | + .text_color(rgb(value_ink)) | ||
| 109 | + .child(value), | ||
| 110 | + ) | ||
| 111 | +} | ||
| 112 | + | ||
| 113 | +/// PROJECT: the canvas every clip is composed onto, the rate it is cut at, | ||
| 114 | +/// the HDR rendition it is watched in, and the mix everything sums into -- | ||
| 115 | +/// [`inspector.rs`]'s own four-plus-Mix list, ported rather than | ||
| 116 | +/// reimplemented (same `Pick`/`open_mix` doors). | ||
| 117 | +fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 118 | + // corner-cut: no genuine default resolution or fps exists before either | ||
| 119 | + // a project opens or a pick is made, so the empty state is a bare dash | ||
| 120 | + // in INK4 -- quieter than a real value, never a noun that reads as one | ||
| 121 | + // (the "Size"/"Rate"/"HDR" placeholders this row used to fall back to). | ||
| 122 | + let resolution = player.session.as_ref().map(PlaybackSession::resolution); | ||
| 123 | + let (res_val, res_ink) = match resolution.or(player.pending_settings.0) { | ||
| 124 | + Some((_, h)) => (format!("{h}p"), INK1()), | ||
| 125 | + None => ("—".to_string(), INK4()), | ||
| 126 | + }; | ||
| 127 | + let (fps_val, fps_ink) = match (player.session.is_some(), player.pending_settings.1) { | ||
| 128 | + (true, _) => (format!("{} fps", fps_label(player.fps)), INK1()), | ||
| 129 | + (false, Some(fps)) => (format!("{} fps", fps_label(fps)), INK1()), | ||
| 130 | + (false, None) => ("—".to_string(), INK4()), | ||
| 131 | + }; | ||
| 132 | + // Sample rate keeps its "Source" fallback: unlike resolution/fps it | ||
| 133 | + // states a real behaviour (derives from the first audio source) rather | ||
| 134 | + // than standing in for a value with nothing behind it. | ||
| 135 | + let rate_val = match player.session.as_ref().map_or(player.pending_settings.2, |s| s.sample_rate()) { | ||
| 136 | + Some(rate) => format!("{rate} Hz"), | ||
| 137 | + None => "Source".to_string(), | ||
| 138 | + }; | ||
| 139 | + let (tone_val, tone_ink) = match &player.session { | ||
| 140 | + Some(session) => (format!("HDR {}", tone_label(session.tone())), INK1()), | ||
| 141 | + None => ("—".to_string(), INK4()), | ||
| 142 | + }; | ||
| 143 | + div() | ||
| 144 | + .flex_none() | ||
| 145 | + .flex() | ||
| 146 | + .flex_col() | ||
| 147 | + .gap(px(2.)) | ||
| 148 | + .child(section_head("PROJECT · stored in the .edith file")) | ||
| 149 | + .child(row_ink( | ||
| 150 | + "settings-resolution", | ||
| 151 | + "Resolution", | ||
| 152 | + res_val, | ||
| 153 | + "the canvas every clip is composed onto, and the size the export comes out at", | ||
| 154 | + player, | ||
| 155 | + cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Resolution, event.position(), cx)), | ||
| 156 | + res_ink, | ||
| 157 | + )) | ||
| 158 | + .child(row_ink( | ||
| 159 | + "settings-fps", | ||
| 160 | + "Frame rate", | ||
| 161 | + fps_val, | ||
| 162 | + "the rate the whole timeline is cut and written at", | ||
| 163 | + player, | ||
| 164 | + cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Fps, event.position(), cx)), | ||
| 165 | + fps_ink, | ||
| 166 | + )) | ||
| 167 | + .child(row( | ||
| 168 | + "settings-sample-rate", | ||
| 169 | + "Sample rate", | ||
| 170 | + rate_val, | ||
| 171 | + "the rate the project's own sound mix is run at; source derives it from the first audio source", | ||
| 172 | + player, | ||
| 173 | + cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::SampleRate, event.position(), cx)), | ||
| 174 | + )) | ||
| 175 | + // hook: the mastering-display target (a monitor peak-nits fact, not | ||
| 176 | + // yet in `inspector.rs`'s own project section) is this row's pair -- | ||
| 177 | + // another builder's row, plugged in right here once it exists. | ||
| 178 | + .child(row_ink( | ||
| 179 | + "settings-tonemap", | ||
| 180 | + "HDR tonemap", | ||
| 181 | + tone_val, | ||
| 182 | + "which rendition HDR media is watched in; SDR media is untouched", | ||
| 183 | + player, | ||
| 184 | + cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Tone, event.position(), cx)), | ||
| 185 | + tone_ink, | ||
| 186 | + )) | ||
| 187 | + .child(row( | ||
| 188 | + "settings-mix", | ||
| 189 | + "Mix", | ||
| 190 | + "Tracks…", | ||
| 191 | + "a fader per track and the limiter over the sum of them", | ||
| 192 | + player, | ||
| 193 | + cx.listener(|this, _: &ClickEvent, _, cx| this.open_mix(None, cx)), | ||
| 194 | + )) | ||
| 195 | +} | ||
| 196 | + | ||
| 197 | +/// EDITOR: this window's own decode/import policy and this person's own | ||
| 198 | +/// reading preference. The subtitle font never touches the `.edith` file; | ||
| 199 | +/// the proxy switches do mirror into it once a project is open (they are | ||
| 200 | +/// project state too), but default from the window rather than a project | ||
| 201 | +/// pick, which is what keeps them answerable with nothing open. | ||
| 202 | +fn editor_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 203 | + div() | ||
| 204 | + .flex_none() | ||
| 205 | + .flex() | ||
| 206 | + .flex_col() | ||
| 207 | + .gap(px(2.)) | ||
| 208 | + .child(section_head("EDITOR · this machine, this window")) | ||
| 209 | + .child(row( | ||
| 210 | + "settings-proxies", | ||
| 211 | + "Proxies", | ||
| 212 | + match player.proxies_on { | ||
| 213 | + true => format!("On{}", player.proxy_tail()), | ||
| 214 | + false => "Off".to_string(), | ||
| 215 | + }, | ||
| 216 | + "cuts on small stand-ins of the big films; the sound and every export stay the film's own -- default kept in ~/.config/edith, the pick for an open project in its own .edith", | ||
| 217 | + player, | ||
| 218 | + cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_proxies(cx)), | ||
| 219 | + )) | ||
| 220 | + .child(row( | ||
| 221 | + "settings-auto-proxies", | ||
| 222 | + "Auto proxies", | ||
| 223 | + if player.auto_proxies_on { "On" } else { "Off" }, | ||
| 224 | + "makes a stand-in for every big film as it is imported -- default kept in ~/.config/edith, the pick for an open project in its own .edith", | ||
| 225 | + player, | ||
| 226 | + cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_auto_proxies(cx)), | ||
| 227 | + )) | ||
| 228 | + .child(row( | ||
| 229 | + "settings-subtitle-style", | ||
| 230 | + "Subtitle font", | ||
| 231 | + "Font…", | ||
| 232 | + "the cue plate's own font and size -- kept in ~/.config/edith, never in a project", | ||
| 233 | + player, | ||
| 234 | + cx.listener(|this, _: &ClickEvent, _, cx| this.open_subtitle_style(cx)), | ||
| 235 | + )) | ||
| 236 | +} | ||
| 237 | + | ||
| 238 | +/// The page itself: a modal card, the same drag-scrim-and-click-away shape | ||
| 239 | +/// every other card in this room takes ([`crate::ui::cards`]'s | ||
| 240 | +/// eq/color/transform/speed cards) -- closed by a click away or `esc`, | ||
| 241 | +/// through [`Player::close_card`], exactly like them. | ||
| 242 | +pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | ||
| 243 | + drag_scrim(cx) | ||
| 244 | + .flex() | ||
| 245 | + .justify_center() | ||
| 246 | + .items_center() | ||
| 247 | + .bg(rgba(SCRIM())) | ||
| 248 | + .on_mouse_down( | ||
| 249 | + MouseButton::Left, | ||
| 250 | + cx.listener(|this, _: &MouseDownEvent, _, cx| { | ||
| 251 | + this.close_card(); | ||
| 252 | + cx.notify(); | ||
| 253 | + cx.stop_propagation(); | ||
| 254 | + }), | ||
| 255 | + ) | ||
| 256 | + .child( | ||
| 257 | + div() | ||
| 258 | + .id("settings-card") | ||
| 259 | + .w_full() | ||
| 260 | + .max_w(px(360.)) | ||
| 261 | + .max_h(relative(0.86)) | ||
| 262 | + .on_mouse_down(MouseButton::Left, swallow) | ||
| 263 | + .flex() | ||
| 264 | + .flex_col() | ||
| 265 | + .gap(px(8.)) | ||
| 266 | + .p(px(12.)) | ||
| 267 | + .rounded(px(6.)) | ||
| 268 | + .bg(rgb(DARK_PANEL())) | ||
| 269 | + .border_1() | ||
| 270 | + .border_color(rgba(DARK_SEAM())) | ||
| 271 | + .child({ | ||
| 272 | + let head = type_scale::head(); | ||
| 273 | + div() | ||
| 274 | + .flex_none() | ||
| 275 | + .flex() | ||
| 276 | + .justify_between() | ||
| 277 | + .items_baseline() | ||
| 278 | + .font(head.font) | ||
| 279 | + .text_size(head.size) | ||
| 280 | + .text_color(rgb(INK3())) | ||
| 281 | + .child("SETTINGS") | ||
| 282 | + .child( | ||
| 283 | + div() | ||
| 284 | + .font(type_scale::mono(type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM).font) | ||
| 285 | + .text_size(px(type_scale::CHORD_METADATA_MIN_PX)) | ||
| 286 | + .text_color(rgb(INK3())) | ||
| 287 | + .child(player.keymap.display(ActionId::Settings)), | ||
| 288 | + ) | ||
| 289 | + }) | ||
| 290 | + .child( | ||
| 291 | + div() | ||
| 292 | + .id("settings-rows") | ||
| 293 | + .min_h(px(0.)) | ||
| 294 | + .overflow_y_scroll() | ||
| 295 | + .flex() | ||
| 296 | + .flex_col() | ||
| 297 | + .gap(px(10.)) | ||
| 298 | + .child(project_section(player, cx)) | ||
| 299 | + .child(editor_section(player, cx)), | ||
| 300 | + ), | ||
| 301 | + ) | ||
| 302 | +} | ||
crates/app/src/ui/spine_stance.rsmodified+6 -0
| @@ -312,5 +312,11 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem | |||
| 312 | glyph("spine-fullscreen", "FS", ActionId::Fullscreen, false, true, player, cx), | 312 | glyph("spine-fullscreen", "FS", ActionId::Fullscreen, false, true, player, cx), |
| 313 | )) | 313 | )) |
| 314 | .child(glyph("spine-screenshot", "Sh", ActionId::Screenshot, false, true, player, cx)) | 314 | .child(glyph("spine-screenshot", "Sh", ActionId::Screenshot, false, true, player, cx)) |
| 315 | + // The settings page's own visible door (user complaint: "some | ||
| 316 | + // options are only reachable via keyboard shortcut") -- a chord | ||
| 317 | + // alone is a defect class this room has hit repeatedly, so this | ||
| 318 | + // glyph sits beside the other once-a-session ROOM acts even though | ||
| 319 | + // its chord (`^,`) is a preference, not a mnemonic. | ||
| 320 | + .child(glyph("spine-settings", "St", ActionId::Settings, player.settings_open, true, player, cx)) | ||
| 315 | .child(div().flex_1()) | 321 | .child(div().flex_1()) |
| 316 | } | 322 | } |
crates/app/src/ui/stance.rsmodified+22 -2
| @@ -11,6 +11,7 @@ | |||
| 11 | use crate::*; | 11 | use crate::*; |
| 12 | use crate::ui::bench_stance; | 12 | use crate::ui::bench_stance; |
| 13 | use crate::ui::dock_stance; | 13 | use crate::ui::dock_stance; |
| 14 | +use crate::ui::settings_stance; | ||
| 14 | use crate::ui::timeband_stance; | 15 | use crate::ui::timeband_stance; |
| 15 | use crate::ui::spine_stance; | 16 | use crate::ui::spine_stance; |
| 16 | use crate::ui::type_scale::{self, Typeset}; | 17 | use crate::ui::type_scale::{self, Typeset}; |
| @@ -754,14 +755,32 @@ pub(crate) fn render( | |||
| 754 | return; | 755 | return; |
| 755 | } | 756 | } |
| 756 | // Same modal guard the legacy handler's rebinding/keys_open/ | 757 | // Same modal guard the legacy handler's rebinding/keys_open/ |
| 757 | - // export_open/exporting/colour/transform/speed/EQ/silence/mix/ | 758 | + // export_open/colour/transform/speed/EQ/silence/mix/ |
| 758 | // subtitle-style/menu chain (`render.rs`) amounts to, read as | 759 | // subtitle-style/menu chain (`render.rs`) amounts to, read as |
| 759 | // one bool instead of re-copied field by field: while a card, a | 760 | // one bool instead of re-copied field by field: while a card, a |
| 760 | // rebind capture, or a menu owns the keyboard, the darkroom | 761 | // rebind capture, or a menu owns the keyboard, the darkroom |
| 761 | // stance yields to it exactly as the legacy tree does. This is | 762 | // stance yields to it exactly as the legacy tree does. This is |
| 762 | // the fix for the stance's `Home`-inside-the-Colour-card | 763 | // the fix for the stance's `Home`-inside-the-Colour-card |
| 763 | // misfire. | 764 | // misfire. |
| 764 | - if this.rebinding.is_some() || this.overlaid() { | 765 | + // |
| 766 | + // `exporting()` alone is deliberately left out of this list | ||
| 767 | + // (`Player::card_open` is `modal()` minus it): a running export | ||
| 768 | + // draws no card of its own to own the keyboard for, and a key | ||
| 769 | + // caught here never reaches `enable()`/`act()` below, so a | ||
| 770 | + // refusal the oracle would have spoken (`ActionId::Settings` | ||
| 771 | + // among them) never got said -- the room went silent instead. | ||
| 772 | + // Letting an export-only moment fall through costs nothing this | ||
| 773 | + // guard exists for: every action the oracle would still refuse | ||
| 774 | + // during an export says so through `act()`'s own `Enable::No` | ||
| 775 | + // branch, and the six it leaves live (Theme, Fullscreen, | ||
| 776 | + // SubtitleStyle, CancelExport, ...) are exactly the ones meant | ||
| 777 | + // to keep working. | ||
| 778 | + if this.rebinding.is_some() | ||
| 779 | + || this.card_open() | ||
| 780 | + || this.context_menu.is_some() | ||
| 781 | + || this.library_menu.is_some() | ||
| 782 | + || this.picker.is_some() | ||
| 783 | + { | ||
| 765 | // Escape is every card's own way out (`Player::close_card`, | 784 | // Escape is every card's own way out (`Player::close_card`, |
| 766 | // the same list `overlaid`/`modal` read) -- blocking every | 785 | // the same list `overlaid`/`modal` read) -- blocking every |
| 767 | // key while a card is open must not also lock the card open. | 786 | // key while a card is open must not also lock the card open. |
| @@ -843,6 +862,7 @@ pub(crate) fn render( | |||
| 843 | el.child(notice_plate(n, bench_h)) | 862 | el.child(notice_plate(n, bench_h)) |
| 844 | }) | 863 | }) |
| 845 | .when(player.keys_open, |el| el.child(keys_overlay(player))) | 864 | .when(player.keys_open, |el| el.child(keys_overlay(player))) |
| 865 | + .when(player.settings_open, |el| el.child(settings_stance::render(player, cx))) | ||
| 846 | // The two menus (DESIGN §9: "verbs of the thing under the | 866 | // The two menus (DESIGN §9: "verbs of the thing under the |
| 847 | // cursor", plate styling, the same scrim-and-row component | 867 | // cursor", plate styling, the same scrim-and-row component |
| 848 | // the legacy tree already uses -- `library.rs`'s own doc | 868 | // the legacy tree already uses -- `library.rs`'s own doc |
crates/engine/src/playback.rsmodified+1 -0
| @@ -4514,3 +4514,4 @@ mod tests { | |||
| 4514 | assert_eq!(next.index, first.index, "paused: same timeline position before and after"); | 4514 | assert_eq!(next.index, first.index, "paused: same timeline position before and after"); |
| 4515 | } | 4515 | } |
| 4516 | } | 4516 | } |
| 4517 | + | ||