forge
Explore
Log in

Don't you dare go Hollow

One card at a time in the clip section

Browse files at this commit

1480a08fa9ffdde929c869dd11ad04f1d291adddAhmet Kaan GümüşParent: fbe0ef516d5a8c
  • fix
    • one card at a time in the clip section
Show full message
🐛 fix(cards): one card at a time in the clip section
crates/app/src/player/cards.rsmodified+20 -35
@@ -270,15 +270,16 @@ impl Player {
270 };270 };
271 match target {271 match target {
272 Some(clip) => {272 Some(clip) => {
273+ // One card at a time: `close_card` is the single list of
274+ // every flag that means "a card is up", so opening this one
275+ // starts by closing all of them.
276+ self.close_card();
273 self.color_open = Some(clip);277 self.color_open = Some(clip);
274 self.color_band = 0;278 self.color_band = 0;
275 self.color_dragging = false;279 self.color_dragging = false;
276 // A sample the last card held back belongs to the clip it was280 // A sample the last card held back belongs to the clip it was
277 // dragged on, and this may be another one.281 // dragged on, and this may be another one.
278 self.pending_color = None;282 self.pending_color = None;
279- // One card at a time, the rule both the others already follow.
280- self.keys_open = false;
281- self.export_open = false;
282 self.context_menu = None;283 self.context_menu = None;
283 }284 }
284 None => self.notify_user("no clip under the playhead to grade".into()),285 None => self.notify_user("no clip under the playhead to grade".into()),
@@ -415,12 +416,12 @@ impl Player {
415 };416 };
416 match target {417 match target {
417 Some(clip) => {418 Some(clip) => {
419+ // One card at a time -- `close_card`'s own rule.
420+ self.close_card();
418 self.transform_open = Some(clip);421 self.transform_open = Some(clip);
419 self.transform_band = 0;422 self.transform_band = 0;
420 self.transform_dragging = false;423 self.transform_dragging = false;
421 self.pending_transform = None;424 self.pending_transform = None;
422- self.keys_open = false;
423- self.export_open = false;
424 self.context_menu = None;425 self.context_menu = None;
425 }426 }
426 None => self.notify_user("no clip under the playhead to place".into()),427 None => self.notify_user("no clip under the playhead to place".into()),
@@ -550,16 +551,12 @@ impl Player {
550 };551 };
551 match anchor {552 match anchor {
552 Some(clip) => {553 Some(clip) => {
554+ // One card at a time -- `close_card`'s own rule.
555+ self.close_card();
553 self.speed_open = Some(clip);556 self.speed_open = Some(clip);
554 self.speed_dragging = false;557 self.speed_dragging = false;
555 // The colour card's rule: a held sample is the last clip's.558 // The colour card's rule: a held sample is the last clip's.
556 self.pending_speed = None;559 self.pending_speed = None;
557- // One card at a time, the rule the other four follow.
558- self.keys_open = false;
559- self.export_open = false;
560- self.eq_open = None;
561- self.color_open = None;
562- self.close_silence();
563 self.context_menu = None;560 self.context_menu = None;
564 }561 }
565 None => self.notify_user("no clip under the playhead to re-time".into()),562 None => self.notify_user("no clip under the playhead to re-time".into()),
@@ -735,14 +732,14 @@ impl Player {
735 cx.notify();732 cx.notify();
736 return;733 return;
737 }734 }
735+ // One card at a time -- `close_card`'s own rule. This clears
736+ // `silence_open` too when the same clip is reopened; the
737+ // marks it drops come back below from the levels cache
738+ // (`scan_plan`/`silence_cached`), which `close_card` never
739+ // touches.
740+ self.close_card();
738 self.silence_open = Some((lane, idx));741 self.silence_open = Some((lane, idx));
739 self.silence_field = 0;742 self.silence_field = 0;
740- // One card at a time, the rule the other four follow.
741- self.keys_open = false;
742- self.export_open = false;
743- self.eq_open = None;
744- self.color_open = None;
745- self.speed_open = None;
746 self.context_menu = None;743 self.context_menu = None;
747 // The clip's own range, not the file's: the scan reads what this744 // The clip's own range, not the file's: the scan reads what this
748 // clip plays and nothing else, so a take cut in half costs half745 // clip plays and nothing else, so a take cut in half costs half
@@ -784,17 +781,12 @@ impl Player {
784 if self.exporting().is_some() {781 if self.exporting().is_some() {
785 return;782 return;
786 }783 }
784+ // One card at a time -- `close_card`'s own rule.
785+ self.close_card();
787 self.mix_open = true;786 self.mix_open = true;
788 self.mix_field = lane787 self.mix_field = lane
789 .and_then(|lane| self.mix_lanes().iter().position(|&l| l == lane))788 .and_then(|lane| self.mix_lanes().iter().position(|&l| l == lane))
790 .unwrap_or(0);789 .unwrap_or(0);
791- // One card at a time, the rule the other five follow.
792- self.keys_open = false;
793- self.export_open = false;
794- self.eq_open = None;
795- self.color_open = None;
796- self.speed_open = None;
797- self.close_silence();
798 self.context_menu = None;790 self.context_menu = None;
799 cx.notify();791 cx.notify();
800 }792 }
@@ -862,17 +854,11 @@ impl Player {
862 /// export, which never burns a cue into the picture -- so like the mix854 /// export, which never burns a cue into the picture -- so like the mix
863 /// card it opens with no timeline required and nothing to refuse.855 /// card it opens with no timeline required and nothing to refuse.
864 pub(crate) fn open_subtitle_style(&mut self, cx: &mut Context<Self>) {856 pub(crate) fn open_subtitle_style(&mut self, cx: &mut Context<Self>) {
857+ // One card at a time -- `close_card`'s own rule.
858+ self.close_card();
865 self.subtitle_fonts = cx.text_system().all_font_names();859 self.subtitle_fonts = cx.text_system().all_font_names();
866 self.subtitle_style_open = true;860 self.subtitle_style_open = true;
867 self.subtitle_style_field = 0;861 self.subtitle_style_field = 0;
868- // One card at a time, the rule the other five follow.
869- self.keys_open = false;
870- self.export_open = false;
871- self.eq_open = None;
872- self.color_open = None;
873- self.speed_open = None;
874- self.mix_open = false;
875- self.close_silence();
876 self.context_menu = None;862 self.context_menu = None;
877 cx.notify();863 cx.notify();
878 }864 }
@@ -1342,12 +1328,11 @@ impl Player {
1342 .eq_of(lane, idx)1328 .eq_of(lane, idx)
1343 .cloned()1329 .cloned()
1344 .unwrap_or_else(EqParams::default_layout);1330 .unwrap_or_else(EqParams::default_layout);
1331+ // One card at a time -- `close_card`'s own rule.
1332+ self.close_card();
1345 self.eq_band = 0;1333 self.eq_band = 0;
1346 self.eq_dragging = false;1334 self.eq_dragging = false;
1347 self.eq_open = Some((lane, idx));1335 self.eq_open = Some((lane, idx));
1348- // One card at a time, the rule the other two already follow.
1349- self.keys_open = false;
1350- self.export_open = false;
1351 self.context_menu = None;1336 self.context_menu = None;
1352 cx.notify();1337 cx.notify();
1353 }1338 }
crates/app/src/tests/cards.rsmodified+41 -0
@@ -1633,3 +1633,44 @@ fn a_preset_over_a_picture_this_timeline_has_none_of_carries_the_codec_refusal()
1633 let (audio_format, _) = ExportPreset::AudioOnly.bundle().expect("a real bundle");1633 let (audio_format, _) = ExportPreset::AudioOnly.bundle().expect("a real bundle");
1634 assert_eq!(format_refusal(&session, audio_format), None);1634 assert_eq!(format_refusal(&session, audio_format), None);
1635 }1635 }
1636+
1637+/// The stacking-scrims bug: opening the speed card while the colour card was
1638+/// up left both up at once, because each `open_*` cleared a different
1639+/// hand-picked subset of the other flags rather than all of them. The fix is
1640+/// one path (`Player::close_card`, the single list of every flag that means
1641+/// "a card is up") that every opener calls before setting its own -- so this
1642+/// pins that *every* opener routes through it, found by name in the source
1643+/// rather than hand-listed, which is what let a seventh and eighth card slip
1644+/// through the ad-hoc version unnoticed.
1645+#[test]
1646+fn every_card_opener_closes_every_other_card_through_one_path() {
1647+ let cards_src = src_text("player/cards.rs");
1648+ let mut openers = Vec::new();
1649+ let mut rest = cards_src.as_str();
1650+ let mut scanned_from = 0usize;
1651+ while let Some(at) = rest.find("fn open_") {
1652+ let after = &rest[at + "fn ".len()..];
1653+ let name_end = after.find('(').expect("a fn's parens");
1654+ openers.push(after[..name_end].to_string());
1655+ scanned_from += at + "fn ".len() + name_end;
1656+ rest = &cards_src[scanned_from..];
1657+ }
1658+ // `open_picker` opens a small dropdown (a resolution/fps/fit choice
1659+ // list), not one of the seven full-window plates `close_card` lists --
1660+ // it is not part of this invariant.
1661+ openers.retain(|name| name != "open_picker");
1662+ assert!(
1663+ openers.len() >= 7,
1664+ "expected at least the seven card openers (eq/color/transform/speed/silence/mix/subtitle_style), found {openers:?}"
1665+ );
1666+ for name in &openers {
1667+ let body = fn_body(name);
1668+ assert!(
1669+ body.contains("self.close_card();"),
1670+ "{name} never calls close_card() -- it may be clearing its own \
1671+ hand-picked subset of the other cards again, which is exactly \
1672+ what let two cards stack on screen at once (open speed, then \
1673+ colour, and both stayed up)"
1674+ );
1675+ }
1676+}