diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 0a0b102..f8c20c7 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -37,9 +37,7 @@ pub(crate) use timeline_math::*; pub(crate) use transport::*; pub(crate) use viewport::*; -use ui::inspector::section_head; use ui::theme::*; -use ui::toolbar::{EXPORT_SLOT_W, SNAP_SLOT_W, VOLUME_SLOT_W, ZOOM_SLOT_W}; use ui::widgets::*; use keymap::{ActionId, Keymap}; @@ -331,6 +329,19 @@ struct Player { /// arrive at the root, so the bar's own geometry has to be readable there. volume_bar: Rc>>, volume_dragging: bool, + /// The two stand-in switches ([`engine::proxy`]) as this window has them + /// set: whether the picture is cut on the stand-ins, and whether an + /// arriving film gets one made for it. Kept here for the volume's reason + /// and one more of their own -- they are *import* options, so they have to + /// be settable before there is any import to have a session about. + /// + /// The session's own pair is the project's (it is saved with it): these are + /// pushed at every new one ([`Player::apply_proxies`]) and taken back from + /// a project as it loads ([`Player::install_project`]), so the button, the + /// switch and the file cannot come to disagree. Their initial values are + /// the ones a fresh session comes up at. + proxies_on: bool, + auto_proxies_on: bool, /// The keybindings overlay is up. While it is, it owns the keyboard and the /// pointer: a stroke or a click meant for a row must not also cut the /// timeline. @@ -614,6 +625,10 @@ fn main() { volume: Volume::default(), volume_bar: Rc::default(), volume_dragging: false, + // What a session comes up at, so the first one opened is + // pushed the values it already holds. + proxies_on: false, + auto_proxies_on: true, // Only ever used with a timeline; 30 keeps the empty // timecode reading in frames rather than in NaN. fps: 30., diff --git a/crates/app/src/oracle.rs b/crates/app/src/oracle.rs index 60ffc67..e598d37 100644 --- a/crates/app/src/oracle.rs +++ b/crates/app/src/oracle.rs @@ -93,12 +93,23 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { false => Enable::Yes, }; } - // The four that are about the *editor* and its monitoring rather than + // The six that are about the *editor* and its monitoring rather than // about the edit list: they work with nothing open, the keyboard has // always fired them there, and so their buttons are live there too. + // + // The two stand-in switches are here because they are *import* options: + // what an arriving film gets made for it, and what the picture is decoded + // from once it has. A person who wants no encode started decides that + // before the first file, and a switch that could only be set once a film + // was already in was a switch that came too late to mean anything. if matches!( action, - ActionId::ToggleSnap | ActionId::ToggleMute | ActionId::VolumeUp | ActionId::VolumeDown + ActionId::ToggleSnap + | ActionId::ToggleMute + | ActionId::VolumeUp + | ActionId::VolumeDown + | ActionId::ToggleProxies + | ActionId::ToggleAutoProxies ) { return match ctx.exporting { true => Enable::No("an export is running"), diff --git a/crates/app/src/player/library.rs b/crates/app/src/player/library.rs index 8e15b95..a1d8ec1 100644 --- a/crates/app/src/player/library.rs +++ b/crates/app/src/player/library.rs @@ -361,6 +361,20 @@ impl Player { } } + /// Pushes the window's two stand-in switches at the session, which is the + /// only place they are ever written -- [`Player::apply_volume`]'s contract, + /// and for a sharper reason: a fresh session comes up making stand-ins for + /// every big film, so a person who turned that off before importing + /// anything would watch the very import they were waiting to prevent start + /// an encode. + pub(crate) fn apply_proxies(&mut self) { + let (on, auto) = (self.proxies_on, self.auto_proxies_on); + if let Some(session) = &mut self.session { + session.set_proxies(on); + session.set_auto_proxies(auto); + } + } + /// Whether any stand-in is still being made -- what keeps the frame loop /// alive while one is, so its percentage moves on screen. pub(crate) fn making_proxies(&self) -> bool { @@ -382,12 +396,17 @@ impl Player { /// Cuts on the stand-ins, or on the films themselves. The picture and only /// the picture: the sound is the film's either way, and so is every frame /// an export writes. + /// + /// Set on the window and pushed at the session, not the other way about: + /// this is an import option and a person picks it before the first film + /// arrives ([`Player::apply_proxies`]). With nothing open it is the pick + /// the next session comes up with. pub(crate) fn toggle_proxies(&mut self, cx: &mut Context) { - let Some(session) = &mut self.session else { - return; - }; - let on = !session.proxies(); - session.set_proxies(on); + let on = !self.proxies_on; + self.proxies_on = on; + if let Some(session) = &mut self.session { + session.set_proxies(on); + } // What is really under the switch, said in the same breath: a project // whose films have no stand-in yet would otherwise read as a switch // that does nothing. @@ -412,7 +431,12 @@ impl Player { }; eprintln!("{text}"); self.notify_user(text.into()); - self.reset_after_reseek(); + // The switch reseeks the session, and the wait for that picture is what + // this clears -- with nothing open there is no open to wait for, and a + // clock started against one would be a seek line about nothing. + if self.session.is_some() { + self.reset_after_reseek(); + } cx.notify(); } @@ -424,12 +448,15 @@ impl Player { /// is what asks for the ones this project needs ([`Player::cache_media`]), /// which is said here because a switch whose only effect is elsewhere is a /// switch that reads as doing nothing. + /// + /// The window's own, like the switch above and for its reason: this one + /// decides what an *import* does, so it is answerable before the import. pub(crate) fn toggle_auto_proxies(&mut self, cx: &mut Context) { - let Some(session) = &mut self.session else { - return; - }; - let on = !session.auto_proxies(); - session.set_auto_proxies(on); + let on = !self.auto_proxies_on; + self.auto_proxies_on = on; + if let Some(session) = &mut self.session { + session.set_auto_proxies(on); + } let text = match on { true => "AUTO PROXIES ON — a film that wants a stand-in gets one as it arrives", false => "AUTO PROXIES OFF — no import makes one; Proxies on is what asks for them", @@ -628,6 +655,9 @@ impl Player { // A fresh session comes up at full volume; the player's own // setting outlives the file, so it is pushed at every new one. self.apply_volume(); + // ...and so do the stand-in switches, which were answerable + // before this file existed and decide what its own import does. + self.apply_proxies(); // Beside the new file, but still the format the card is set to: // opening another clip is not a change of mind about that. self.export_path = retarget(&export_path(path), self.format); @@ -897,6 +927,14 @@ impl Player { self.export_path = retarget(&export_path(&session.sources()[0].path), self.format); self.session = Some(session); self.apply_volume(); + // The other way round from every other door: a project carries + // its own two switches ([`engine::edith`]) and they are what it + // was saved with, so the window takes *them* rather than + // pushing what it had -- and the buttons say what was loaded. + if let Some(session) = &self.session { + self.proxies_on = session.proxies(); + self.auto_proxies_on = session.auto_proxies(); + } self.project_path = path.to_path_buf(); self.name = file_name(path).into(); // A copied clip names its source by index, which means a diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index e387a18..57fc930 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -497,11 +497,19 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { // The magnet and the monitoring level are the editor's own and answer // with no timeline at all -- the keyboard always fired them there, and // now so does the toolbar. + // + // ...and so do the two stand-in switches, which is not a nicety: they are + // *import* options -- what an arriving film gets made for it, and what its + // picture is then decoded from -- so a person answers them before the first + // file, and a switch that waited for one was a switch that came too late to + // stop the encode it was about. for editor_wide in [ ActionId::ToggleSnap, ActionId::ToggleMute, ActionId::VolumeUp, ActionId::VolumeDown, + ActionId::ToggleProxies, + ActionId::ToggleAutoProxies, ] { assert!( whole(editor_wide, Ctx::default()).yes(), diff --git a/crates/app/src/ui/inspector.rs b/crates/app/src/ui/inspector.rs index b024a83..6ae1613 100644 --- a/crates/app/src/ui/inspector.rs +++ b/crates/app/src/ui/inspector.rs @@ -9,7 +9,6 @@ use crate::*; use crate::ui::toolbar::{TONE_SLOT_W, ZOOM_SLOT_W}; -use crate::ui::widgets::*; impl Player { /// The inspector column. Two sections that are always there -- the @@ -292,10 +291,13 @@ impl Player { TONE_SLOT_W, BG_RAISED(), None, - match self.session.as_ref().map(PlaybackSession::proxies) { - Some(true) => format!("Proxies on{}", self.proxy_tail()), - Some(false) => format!("Proxies off{}", self.proxy_tail()), - None => "Proxies".to_string(), + // The window's own switch and not the session's: it is + // answerable with nothing open, so a label that read + // "Proxies" there would be a control whose state was a + // secret until a file arrived. + match self.proxies_on { + true => format!("Proxies on{}", self.proxy_tail()), + false => format!("Proxies off{}", self.proxy_tail()), }, "cuts on small stand-ins of the big films; the sound and every export \ stay the film's own", @@ -311,10 +313,9 @@ impl Player { TONE_SLOT_W, BG_RAISED(), None, - match self.session.as_ref().map(PlaybackSession::auto_proxies) { - Some(true) => "Auto proxies on", - Some(false) => "Auto proxies off", - None => "Auto proxies", + match self.auto_proxies_on { + true => "Auto proxies on", + false => "Auto proxies off", }, "makes a stand-in for every big film as it is imported; with it off, \ turning Proxies on is what asks for them",