forge
Explore
Log in

Don't you dare go Hollow

The stand-in switches are answerable before the first film

Browse files at this commit

2995059b9397f0ac9b84c0dfa4df77b37852b8c0Ahmet Kaan GümüşParent: 07ee3c7
  • fix
    • the stand-in switches are answerable before the first film
Show full message
🐛 fix(ui): the stand-in switches are answerable before the first film

Both proxy switches were dead with nothing open: the availability oracle
refuses everything below "no timeline open", and the state they toggled
lived in the session, so a window with no session had nowhere to keep an
answer and the buttons read a bare "Proxies" with no state at all.

That is backwards for what these two are. They are import options -- one
decides whether an arriving film gets a stand-in made for it, the other
what its picture is then decoded from -- so the moment a person can act
on them is *before* the import, and a switch that waited for a film was
a switch that came too late to stop the encode it was about.

So the pair joins the four the oracle already answers with nothing open
(the snap and the monitoring level), and the window keeps them the way
it keeps its volume: its own, pushed at every session it opens
(`apply_proxies`), and taken back from a project as it loads, since a
`.edith` carries its own two and they are what it was saved with.

The buttons now say on or off with an empty window, an import made while
Auto proxies is off starts no encode, and the keyboard and the pointer
go on answering the same question -- which is the rule that put the four
in the oracle in the first place.

Two dead imports in the same two files go with it: the build printed
them and they are one line each.
crates/app/src/main.rsmodified+17 -2
@@ -37,9 +37,7 @@ pub(crate) use timeline_math::*;
37 pub(crate) use transport::*;37 pub(crate) use transport::*;
38 pub(crate) use viewport::*;38 pub(crate) use viewport::*;
39 39
40-use ui::inspector::section_head;
41 use ui::theme::*;40 use ui::theme::*;
42-use ui::toolbar::{EXPORT_SLOT_W, SNAP_SLOT_W, VOLUME_SLOT_W, ZOOM_SLOT_W};
43 use ui::widgets::*;41 use ui::widgets::*;
44 42
45 use keymap::{ActionId, Keymap};43 use keymap::{ActionId, Keymap};
@@ -331,6 +329,19 @@ struct Player {
331 /// arrive at the root, so the bar's own geometry has to be readable there.329 /// arrive at the root, so the bar's own geometry has to be readable there.
332 volume_bar: Rc<Cell<Bounds<Pixels>>>,330 volume_bar: Rc<Cell<Bounds<Pixels>>>,
333 volume_dragging: bool,331 volume_dragging: bool,
332+ /// The two stand-in switches ([`engine::proxy`]) as this window has them
333+ /// set: whether the picture is cut on the stand-ins, and whether an
334+ /// arriving film gets one made for it. Kept here for the volume's reason
335+ /// and one more of their own -- they are *import* options, so they have to
336+ /// be settable before there is any import to have a session about.
337+ ///
338+ /// The session's own pair is the project's (it is saved with it): these are
339+ /// pushed at every new one ([`Player::apply_proxies`]) and taken back from
340+ /// a project as it loads ([`Player::install_project`]), so the button, the
341+ /// switch and the file cannot come to disagree. Their initial values are
342+ /// the ones a fresh session comes up at.
343+ proxies_on: bool,
344+ auto_proxies_on: bool,
334 /// The keybindings overlay is up. While it is, it owns the keyboard and the345 /// The keybindings overlay is up. While it is, it owns the keyboard and the
335 /// pointer: a stroke or a click meant for a row must not also cut the346 /// pointer: a stroke or a click meant for a row must not also cut the
336 /// timeline.347 /// timeline.
@@ -614,6 +625,10 @@ fn main() {
614 volume: Volume::default(),625 volume: Volume::default(),
615 volume_bar: Rc::default(),626 volume_bar: Rc::default(),
616 volume_dragging: false,627 volume_dragging: false,
628+ // What a session comes up at, so the first one opened is
629+ // pushed the values it already holds.
630+ proxies_on: false,
631+ auto_proxies_on: true,
617 // Only ever used with a timeline; 30 keeps the empty632 // Only ever used with a timeline; 30 keeps the empty
618 // timecode reading in frames rather than in NaN.633 // timecode reading in frames rather than in NaN.
619 fps: 30.,634 fps: 30.,
crates/app/src/oracle.rsmodified+13 -2
@@ -93,12 +93,23 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable {
93 false => Enable::Yes,93 false => Enable::Yes,
94 };94 };
95 }95 }
96- // The four that are about the *editor* and its monitoring rather than96+ // The six that are about the *editor* and its monitoring rather than
97 // about the edit list: they work with nothing open, the keyboard has97 // about the edit list: they work with nothing open, the keyboard has
98 // always fired them there, and so their buttons are live there too.98 // always fired them there, and so their buttons are live there too.
99+ //
100+ // The two stand-in switches are here because they are *import* options:
101+ // what an arriving film gets made for it, and what the picture is decoded
102+ // from once it has. A person who wants no encode started decides that
103+ // before the first file, and a switch that could only be set once a film
104+ // was already in was a switch that came too late to mean anything.
99 if matches!(105 if matches!(
100 action,106 action,
101- ActionId::ToggleSnap | ActionId::ToggleMute | ActionId::VolumeUp | ActionId::VolumeDown107+ ActionId::ToggleSnap
108+ | ActionId::ToggleMute
109+ | ActionId::VolumeUp
110+ | ActionId::VolumeDown
111+ | ActionId::ToggleProxies
112+ | ActionId::ToggleAutoProxies
102 ) {113 ) {
103 return match ctx.exporting {114 return match ctx.exporting {
104 true => Enable::No("an export is running"),115 true => Enable::No("an export is running"),
crates/app/src/player/library.rsmodified+49 -11
@@ -361,6 +361,20 @@ impl Player {
361 }361 }
362 }362 }
363 363
364+ /// Pushes the window's two stand-in switches at the session, which is the
365+ /// only place they are ever written -- [`Player::apply_volume`]'s contract,
366+ /// and for a sharper reason: a fresh session comes up making stand-ins for
367+ /// every big film, so a person who turned that off before importing
368+ /// anything would watch the very import they were waiting to prevent start
369+ /// an encode.
370+ pub(crate) fn apply_proxies(&mut self) {
371+ let (on, auto) = (self.proxies_on, self.auto_proxies_on);
372+ if let Some(session) = &mut self.session {
373+ session.set_proxies(on);
374+ session.set_auto_proxies(auto);
375+ }
376+ }
377+
364 /// Whether any stand-in is still being made -- what keeps the frame loop378 /// Whether any stand-in is still being made -- what keeps the frame loop
365 /// alive while one is, so its percentage moves on screen.379 /// alive while one is, so its percentage moves on screen.
366 pub(crate) fn making_proxies(&self) -> bool {380 pub(crate) fn making_proxies(&self) -> bool {
@@ -382,12 +396,17 @@ impl Player {
382 /// Cuts on the stand-ins, or on the films themselves. The picture and only396 /// Cuts on the stand-ins, or on the films themselves. The picture and only
383 /// the picture: the sound is the film's either way, and so is every frame397 /// the picture: the sound is the film's either way, and so is every frame
384 /// an export writes.398 /// an export writes.
399+ ///
400+ /// Set on the window and pushed at the session, not the other way about:
401+ /// this is an import option and a person picks it before the first film
402+ /// arrives ([`Player::apply_proxies`]). With nothing open it is the pick
403+ /// the next session comes up with.
385 pub(crate) fn toggle_proxies(&mut self, cx: &mut Context<Self>) {404 pub(crate) fn toggle_proxies(&mut self, cx: &mut Context<Self>) {
386- let Some(session) = &mut self.session else {405+ let on = !self.proxies_on;
387- return;406+ self.proxies_on = on;
388- };407+ if let Some(session) = &mut self.session {
389- let on = !session.proxies();408+ session.set_proxies(on);
390- session.set_proxies(on);409+ }
391 // What is really under the switch, said in the same breath: a project410 // What is really under the switch, said in the same breath: a project
392 // whose films have no stand-in yet would otherwise read as a switch411 // whose films have no stand-in yet would otherwise read as a switch
393 // that does nothing.412 // that does nothing.
@@ -412,7 +431,12 @@ impl Player {
412 };431 };
413 eprintln!("{text}");432 eprintln!("{text}");
414 self.notify_user(text.into());433 self.notify_user(text.into());
415- self.reset_after_reseek();434+ // The switch reseeks the session, and the wait for that picture is what
435+ // this clears -- with nothing open there is no open to wait for, and a
436+ // clock started against one would be a seek line about nothing.
437+ if self.session.is_some() {
438+ self.reset_after_reseek();
439+ }
416 cx.notify();440 cx.notify();
417 }441 }
418 442
@@ -424,12 +448,15 @@ impl Player {
424 /// is what asks for the ones this project needs ([`Player::cache_media`]),448 /// is what asks for the ones this project needs ([`Player::cache_media`]),
425 /// which is said here because a switch whose only effect is elsewhere is a449 /// which is said here because a switch whose only effect is elsewhere is a
426 /// switch that reads as doing nothing.450 /// switch that reads as doing nothing.
451+ ///
452+ /// The window's own, like the switch above and for its reason: this one
453+ /// decides what an *import* does, so it is answerable before the import.
427 pub(crate) fn toggle_auto_proxies(&mut self, cx: &mut Context<Self>) {454 pub(crate) fn toggle_auto_proxies(&mut self, cx: &mut Context<Self>) {
428- let Some(session) = &mut self.session else {455+ let on = !self.auto_proxies_on;
429- return;456+ self.auto_proxies_on = on;
430- };457+ if let Some(session) = &mut self.session {
431- let on = !session.auto_proxies();458+ session.set_auto_proxies(on);
432- session.set_auto_proxies(on);459+ }
433 let text = match on {460 let text = match on {
434 true => "AUTO PROXIES ON — a film that wants a stand-in gets one as it arrives",461 true => "AUTO PROXIES ON — a film that wants a stand-in gets one as it arrives",
435 false => "AUTO PROXIES OFF — no import makes one; Proxies on is what asks for them",462 false => "AUTO PROXIES OFF — no import makes one; Proxies on is what asks for them",
@@ -628,6 +655,9 @@ impl Player {
628 // A fresh session comes up at full volume; the player's own655 // A fresh session comes up at full volume; the player's own
629 // setting outlives the file, so it is pushed at every new one.656 // setting outlives the file, so it is pushed at every new one.
630 self.apply_volume();657 self.apply_volume();
658+ // ...and so do the stand-in switches, which were answerable
659+ // before this file existed and decide what its own import does.
660+ self.apply_proxies();
631 // Beside the new file, but still the format the card is set to:661 // Beside the new file, but still the format the card is set to:
632 // opening another clip is not a change of mind about that.662 // opening another clip is not a change of mind about that.
633 self.export_path = retarget(&export_path(path), self.format);663 self.export_path = retarget(&export_path(path), self.format);
@@ -897,6 +927,14 @@ impl Player {
897 self.export_path = retarget(&export_path(&session.sources()[0].path), self.format);927 self.export_path = retarget(&export_path(&session.sources()[0].path), self.format);
898 self.session = Some(session);928 self.session = Some(session);
899 self.apply_volume();929 self.apply_volume();
930+ // The other way round from every other door: a project carries
931+ // its own two switches ([`engine::edith`]) and they are what it
932+ // was saved with, so the window takes *them* rather than
933+ // pushing what it had -- and the buttons say what was loaded.
934+ if let Some(session) = &self.session {
935+ self.proxies_on = session.proxies();
936+ self.auto_proxies_on = session.auto_proxies();
937+ }
900 self.project_path = path.to_path_buf();938 self.project_path = path.to_path_buf();
901 self.name = file_name(path).into();939 self.name = file_name(path).into();
902 // A copied clip names its source by index, which means a940 // A copied clip names its source by index, which means a
crates/app/src/tests/editing.rsmodified+8 -0
@@ -497,11 +497,19 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
497 // The magnet and the monitoring level are the editor's own and answer497 // The magnet and the monitoring level are the editor's own and answer
498 // with no timeline at all -- the keyboard always fired them there, and498 // with no timeline at all -- the keyboard always fired them there, and
499 // now so does the toolbar.499 // now so does the toolbar.
500+ //
501+ // ...and so do the two stand-in switches, which is not a nicety: they are
502+ // *import* options -- what an arriving film gets made for it, and what its
503+ // picture is then decoded from -- so a person answers them before the first
504+ // file, and a switch that waited for one was a switch that came too late to
505+ // stop the encode it was about.
500 for editor_wide in [506 for editor_wide in [
501 ActionId::ToggleSnap,507 ActionId::ToggleSnap,
502 ActionId::ToggleMute,508 ActionId::ToggleMute,
503 ActionId::VolumeUp,509 ActionId::VolumeUp,
504 ActionId::VolumeDown,510 ActionId::VolumeDown,
511+ ActionId::ToggleProxies,
512+ ActionId::ToggleAutoProxies,
505 ] {513 ] {
506 assert!(514 assert!(
507 whole(editor_wide, Ctx::default()).yes(),515 whole(editor_wide, Ctx::default()).yes(),
crates/app/src/ui/inspector.rsmodified+10 -9
@@ -9,7 +9,6 @@
9 9
10 use crate::*;10 use crate::*;
11 use crate::ui::toolbar::{TONE_SLOT_W, ZOOM_SLOT_W};11 use crate::ui::toolbar::{TONE_SLOT_W, ZOOM_SLOT_W};
12-use crate::ui::widgets::*;
13 12
14 impl Player {13 impl Player {
15 /// The inspector column. Two sections that are always there -- the14 /// The inspector column. Two sections that are always there -- the
@@ -292,10 +291,13 @@ impl Player {
292 TONE_SLOT_W,291 TONE_SLOT_W,
293 BG_RAISED(),292 BG_RAISED(),
294 None,293 None,
295- match self.session.as_ref().map(PlaybackSession::proxies) {294+ // The window's own switch and not the session's: it is
296- Some(true) => format!("Proxies on{}", self.proxy_tail()),295+ // answerable with nothing open, so a label that read
297- Some(false) => format!("Proxies off{}", self.proxy_tail()),296+ // "Proxies" there would be a control whose state was a
298- None => "Proxies".to_string(),297+ // secret until a file arrived.
298+ match self.proxies_on {
299+ true => format!("Proxies on{}", self.proxy_tail()),
300+ false => format!("Proxies off{}", self.proxy_tail()),
299 },301 },
300 "cuts on small stand-ins of the big films; the sound and every export \302 "cuts on small stand-ins of the big films; the sound and every export \
301 stay the film's own",303 stay the film's own",
@@ -311,10 +313,9 @@ impl Player {
311 TONE_SLOT_W,313 TONE_SLOT_W,
312 BG_RAISED(),314 BG_RAISED(),
313 None,315 None,
314- match self.session.as_ref().map(PlaybackSession::auto_proxies) {316+ match self.auto_proxies_on {
315- Some(true) => "Auto proxies on",317+ true => "Auto proxies on",
316- Some(false) => "Auto proxies off",318+ false => "Auto proxies off",
317- None => "Auto proxies",
318 },319 },
319 "makes a stand-in for every big film as it is imported; with it off, \320 "makes a stand-in for every big film as it is imported; with it off, \
320 turning Proxies on is what asks for them",321 turning Proxies on is what asks for them",