Every edit door arms the flag only when it wrote
Browse files at this commitf7e750cdfb13af3cfb530bfc4d11187b28b2c604Parent: e063ed4- fix
- every edit door arms the flag only when it wrote
3 changed files +295 -44
- crates/app/src/player/actions.rs +43 -12
- crates/app/src/player/timeline_edit.rs +101 -8
- crates/app/src/tests/cards.rs +151 -24
crates/app/src/player/actions.rsmodified+43 -12
| @@ -36,6 +36,12 @@ impl Player { | ||
| 36 | 36 | // costs nothing a real edit would not have earned anyway, and one list |
| 37 | 37 | // here is the whole answer instead of fifteen scattered calls. |
| 38 | 38 | // |
| 39 | + // The two exceptions are the history pair, whose doors answer "there was | |
| 40 | + // a step to take" and are gated in their own arms below: `^z` with | |
| 41 | + // nothing to undo is not a stroke that earned an autosave, and the | |
| 42 | + // save-on-close question over a project nobody has touched is exactly | |
| 43 | + // what the card doors' own gate exists to prevent. | |
| 44 | + // | |
| 39 | 45 | // This list is the *action* doors only, and that is the class to mind |
| 40 | 46 | // when adding an edit: a control that reaches the session from a |
| 41 | 47 | // *click* -- the Clip tab's look chips and wheel, the settings rows, |
| @@ -54,8 +60,6 @@ impl Player { | ||
| 54 | 60 | | ActionId::Group |
| 55 | 61 | | ActionId::Delete |
| 56 | 62 | | ActionId::Lift |
| 57 | - | ActionId::Undo | |
| 58 | - | ActionId::Redo | |
| 59 | 63 | | ActionId::AddVideoLane |
| 60 | 64 | | ActionId::RemoveVideoLane |
| 61 | 65 | | ActionId::AddAudioLane |
| @@ -130,8 +134,16 @@ impl Player { | ||
| 130 | 134 | ActionId::ZoomIn => self.zoom(ZOOM_STEP, None, cx), |
| 131 | 135 | ActionId::ZoomOut => self.zoom(1. / ZOOM_STEP, None, cx), |
| 132 | 136 | ActionId::ZoomFit => self.zoom_fit(cx), |
| 133 | - ActionId::Undo => self.undo(cx), | |
| 134 | - ActionId::Redo => self.redo(cx), | |
| 137 | + ActionId::Undo => { | |
| 138 | + if self.undo(cx) { | |
| 139 | + self.mark_dirty(); | |
| 140 | + } | |
| 141 | + } | |
| 142 | + ActionId::Redo => { | |
| 143 | + if self.redo(cx) { | |
| 144 | + self.mark_dirty(); | |
| 145 | + } | |
| 146 | + } | |
| 135 | 147 | ActionId::AddVideoLane => self.add_lane(LaneKind::Video, cx), |
| 136 | 148 | ActionId::AddAudioLane => self.add_lane(LaneKind::Audio, cx), |
| 137 | 149 | // The last track of that kind: the one the add key put there, so the |
| @@ -611,12 +623,17 @@ impl Player { | ||
| 611 | 623 | return; |
| 612 | 624 | }; |
| 613 | 625 | let to = nudge_edge(current, dir, lo, hi); |
| 614 | - self.mark_dirty(); | |
| 615 | 626 | let trimmed = self |
| 616 | 627 | .session |
| 617 | 628 | .as_mut() |
| 618 | 629 | .is_some_and(|s| s.trim_clip(lane, idx, edge, to)); |
| 619 | 630 | if trimmed { |
| 631 | + // The arm rides the door's own answer: `trim_clip` is `false` for an | |
| 632 | + // edge already where it was asked to go -- the `[`/`]` pressed | |
| 633 | + // against the wall the edge is already on -- so the flag, the | |
| 634 | + // autosave sidecar and the save-on-close question stay off a | |
| 635 | + // project nobody has changed. | |
| 636 | + self.mark_dirty(); | |
| 620 | 637 | self.reset_after_reseek(); |
| 621 | 638 | // Loop-trim follows the edge it is trimming: the whole point of |
| 622 | 639 | // the mode is hearing the cut as it moves. |
| @@ -643,12 +660,15 @@ impl Player { | ||
| 643 | 660 | return; |
| 644 | 661 | }; |
| 645 | 662 | let to = frame_at(session.now(), self.fps); |
| 646 | - self.mark_dirty(); | |
| 647 | 663 | let trimmed = self |
| 648 | 664 | .session |
| 649 | 665 | .as_mut() |
| 650 | 666 | .is_some_and(|s| s.trim_clip(lane, idx, edge, to)); |
| 651 | 667 | if trimmed { |
| 668 | + // The door's own answer again: an edge the playhead is already on is | |
| 669 | + // `false`, no undo step, and nothing for the unsaved ghost to be | |
| 670 | + // about. | |
| 671 | + self.mark_dirty(); | |
| 652 | 672 | self.reset_after_reseek(); |
| 653 | 673 | // Loop-trim follows the edge it is trimming, same as the nudge |
| 654 | 674 | // pair above. |
| @@ -684,20 +704,31 @@ impl Player { | ||
| 684 | 704 | cx.notify(); |
| 685 | 705 | } |
| 686 | 706 | |
| 687 | - pub(crate) fn undo(&mut self, cx: &mut Context<Self>) { | |
| 688 | - if self.session.as_mut().is_some_and(PlaybackSession::undo) { | |
| 707 | + /// Whether there was a step to take, for the reason the action table arms | |
| 708 | + /// nothing on its own: a `^z` with an empty history is not an edit, and it | |
| 709 | + /// may not raise the save-on-close question over a project nobody has | |
| 710 | + /// touched. The selection goes with the step for the same reason it used to | |
| 711 | + /// go every time: a step back puts the indices on different clips, while a | |
| 712 | + /// refused one leaves them naming exactly what they named. | |
| 713 | + pub(crate) fn undo(&mut self, cx: &mut Context<Self>) -> bool { | |
| 714 | + let stepped = self.session.as_mut().is_some_and(PlaybackSession::undo); | |
| 715 | + if stepped { | |
| 689 | 716 | self.reset_after_reseek(); |
| 717 | + self.selected.clear(); | |
| 690 | 718 | } |
| 691 | - self.selected.clear(); | |
| 692 | 719 | cx.notify(); |
| 720 | + stepped | |
| 693 | 721 | } |
| 694 | 722 | |
| 695 | - pub(crate) fn redo(&mut self, cx: &mut Context<Self>) { | |
| 696 | - if self.session.as_mut().is_some_and(PlaybackSession::redo) { | |
| 723 | + /// [`Player::undo`]'s twin, the same answer and the same gate. | |
| 724 | + pub(crate) fn redo(&mut self, cx: &mut Context<Self>) -> bool { | |
| 725 | + let stepped = self.session.as_mut().is_some_and(PlaybackSession::redo); | |
| 726 | + if stepped { | |
| 697 | 727 | self.reset_after_reseek(); |
| 728 | + self.selected.clear(); | |
| 698 | 729 | } |
| 699 | - self.selected.clear(); | |
| 700 | 730 | cx.notify(); |
| 731 | + stepped | |
| 701 | 732 | } |
| 702 | 733 | } |
| 703 | 734 |
crates/app/src/player/timeline_edit.rsmodified+101 -8
| @@ -350,7 +350,6 @@ impl Player { | ||
| 350 | 350 | if self.exporting().is_some() { |
| 351 | 351 | return; |
| 352 | 352 | } |
| 353 | - self.mark_dirty(); | |
| 354 | 353 | let (Some((start, _)), Some(was)) = ( |
| 355 | 354 | self.drop_frame(from, idx, x), |
| 356 | 355 | self.session |
| @@ -385,6 +384,14 @@ impl Player { | ||
| 385 | 384 | }; |
| 386 | 385 | match moved { |
| 387 | 386 | true => { |
| 387 | + // The arm rides the door's own answer: `move_clip_to` / | |
| 388 | + // `move_selection_to` answer `false` for a clip let go where it | |
| 389 | + // was picked up (`Project::move_selection` refuses before its | |
| 390 | + // snapshot) and for a lane of the wrong kind, and the arms below | |
| 391 | + // say both in words. Armed before the call it dirtied a project | |
| 392 | + // nobody had touched -- the ledger's `unsaved` ghost and the | |
| 393 | + // save-on-close question over an unchanged file. | |
| 394 | + self.mark_dirty(); | |
| 388 | 395 | // Every pick named a `(lane, ...)` by index into that lane's |
| 389 | 396 | // clips, sorted by start -- exactly what an insert or a lane |
| 390 | 397 | // change reorders. Re-read by the frame each pick's clip now |
| @@ -512,7 +519,6 @@ impl Player { | ||
| 512 | 519 | if self.exporting().is_some() { |
| 513 | 520 | return; |
| 514 | 521 | } |
| 515 | - self.mark_dirty(); | |
| 516 | 522 | self.snap_cue = None; |
| 517 | 523 | self.ghost.clear(); |
| 518 | 524 | let at = self.place_frame(x).0; |
| @@ -533,6 +539,15 @@ impl Player { | ||
| 533 | 539 | (None, Some(_)) => Some("NOT PLACED — that subtitle track has no cues".to_string()), |
| 534 | 540 | (_, None) => Some("NOT PLACED — no file open".to_string()), |
| 535 | 541 | }; |
| 542 | + // The arm rides the door's own answer: `text` is `None` exactly when | |
| 543 | + // `Project::place_sub` took the track, and every refusal -- an overlap, | |
| 544 | + // a lane that is not a subtitle lane, "no file open", "no cues" -- | |
| 545 | + // leaves the project byte-for-byte what it was. Armed ahead of the | |
| 546 | + // answer it wrote an autosave sidecar, the ledger's `unsaved` ghost and | |
| 547 | + // the save-on-close question over a project nobody had changed. | |
| 548 | + if text.is_none() { | |
| 549 | + self.mark_dirty(); | |
| 550 | + } | |
| 536 | 551 | match (text, marked) { |
| 537 | 552 | (Some(text), _) => self.notify_user(text.into()), |
| 538 | 553 | // It went down, and a lane holds its captions in start order |
| @@ -597,12 +612,19 @@ impl Player { | ||
| 597 | 612 | if self.exporting().is_some() { |
| 598 | 613 | return; |
| 599 | 614 | } |
| 600 | - self.mark_dirty(); | |
| 601 | 615 | self.snap_cue = None; |
| 602 | 616 | self.ghost.clear(); |
| 603 | 617 | let Some(idx) = self.dragged_sub(drag) else { |
| 604 | 618 | return; |
| 605 | 619 | }; |
| 620 | + // Where the caption stands *now*, so the arm below can tell a move from | |
| 621 | + // a drag let go where it began: `Project::move_sub` answers `Ok` for a | |
| 622 | + // pick-up-put-back too ("`Ok`, and no undo step, because nothing | |
| 623 | + // changed"), so its own answer is not a change report. | |
| 624 | + let was = self | |
| 625 | + .session | |
| 626 | + .as_ref() | |
| 627 | + .and_then(|session| session.sub_lane(drag.lane).get(idx).map(|sub| sub.start)); | |
| 606 | 628 | // Asked before the edit, on the indices the press captured: the |
| 607 | 629 | // engine's own grouped-with-clips answer, which is exactly when its |
| 608 | 630 | // move reseeks -- a caption grouped only with other captions moves no |
| @@ -640,6 +662,20 @@ impl Player { | ||
| 640 | 662 | .as_ref() |
| 641 | 663 | .and_then(|session| sub_mark(session.sub_lane(to), start)) |
| 642 | 664 | .map(|i| (to, i)); |
| 665 | + // The arm rides the caption's own place having moved -- the | |
| 666 | + // engine's `Ok` covers the put-back that takes no undo step at | |
| 667 | + // all (`Project::move_sub`), and a project nobody has touched | |
| 668 | + // must not light the `unsaved` ghost. | |
| 669 | + let landed = mark.and_then(|(lane, i)| { | |
| 670 | + self.session | |
| 671 | + .as_ref()? | |
| 672 | + .sub_lane(lane) | |
| 673 | + .get(i) | |
| 674 | + .map(|sub| (lane, sub.start)) | |
| 675 | + }); | |
| 676 | + if landed != was.map(|start| (drag.lane, start)) { | |
| 677 | + self.mark_dirty(); | |
| 678 | + } | |
| 643 | 679 | self.selected = match mark { |
| 644 | 680 | Some(mark) => { |
| 645 | 681 | let mut sel = Selection::new(); |
| @@ -670,7 +706,6 @@ impl Player { | ||
| 670 | 706 | if self.exporting().is_some() { |
| 671 | 707 | return; |
| 672 | 708 | } |
| 673 | - self.mark_dirty(); | |
| 674 | 709 | let lifted = self |
| 675 | 710 | .session |
| 676 | 711 | .as_mut() |
| @@ -683,6 +718,11 @@ impl Player { | ||
| 683 | 718 | false => "NOTHING LIFTED — that caption is not there any more".to_string(), |
| 684 | 719 | }; |
| 685 | 720 | if lifted { |
| 721 | + // The arm rides the door's own answer: `false` is "NOTHING LIFTED — | |
| 722 | + // that caption is not there any more", and the project is exactly | |
| 723 | + // what it was, so the flag, the autosave sidecar and the | |
| 724 | + // save-on-close question must stay off it. | |
| 725 | + self.mark_dirty(); | |
| 686 | 726 | // Everything after it on that lane slid down one ([`Vec::remove`]), |
| 687 | 727 | // so a mark or an open menu left at or past it names a *different* |
| 688 | 728 | // caption now -- and the next Delete would take that one. Both go |
| @@ -1537,7 +1577,11 @@ impl Player { | ||
| 1537 | 1577 | let Some(trim) = self.trim.take() else { |
| 1538 | 1578 | return; |
| 1539 | 1579 | }; |
| 1540 | - self.mark_dirty(); | |
| 1580 | + // The arm rides each door's own answer or the caption's own edges -- | |
| 1581 | + // never the call: a trim released where the edge already stood is | |
| 1582 | + // `Ok`/`true` with no undo step, and it must not leave the project | |
| 1583 | + // looking edited to autosave, the `unsaved` ghost or the close | |
| 1584 | + // question. | |
| 1541 | 1585 | // A caption's edge reaches the engine through its own door, at this |
| 1542 | 1586 | // timeline's rate. An `Ok` is *not* "something changed" -- an edge that |
| 1543 | 1587 | // stopped at a wall it already stood against is `Ok` with no undo step |
| @@ -1552,14 +1596,33 @@ impl Player { | ||
| 1552 | 1596 | .session |
| 1553 | 1597 | .as_ref() |
| 1554 | 1598 | .is_some_and(|session| session.caption_grouped_with_clips(trim.lane, trim.idx)); |
| 1599 | + // The caption's own window, before and after: the only reading that | |
| 1600 | + // can tell a trim from an edge released against the wall it already | |
| 1601 | + // stood on. | |
| 1602 | + let edges = |player: &Self| { | |
| 1603 | + player.session.as_ref().and_then(|session| { | |
| 1604 | + session | |
| 1605 | + .sub_lane(trim.lane) | |
| 1606 | + .get(trim.idx) | |
| 1607 | + .map(|sub| (sub.start, sub.frames, sub.in_us, sub.out_us)) | |
| 1608 | + }) | |
| 1609 | + }; | |
| 1610 | + let before = edges(self); | |
| 1555 | 1611 | let trimmed = self |
| 1556 | 1612 | .session |
| 1557 | 1613 | .as_mut() |
| 1558 | 1614 | .map(|session| session.trim_sub(trim.lane, trim.idx, trim.edge, trim.to)); |
| 1559 | 1615 | match trimmed { |
| 1560 | 1616 | Some(Err(e)) => self.notify_user(format!("NOT TRIMMED — {e}").into()), |
| 1561 | - Some(Ok(())) if grouped => self.reset_after_reseek(), | |
| 1562 | - _ => {} | |
| 1617 | + Some(Ok(())) => { | |
| 1618 | + if edges(self) != before { | |
| 1619 | + self.mark_dirty(); | |
| 1620 | + } | |
| 1621 | + if grouped { | |
| 1622 | + self.reset_after_reseek(); | |
| 1623 | + } | |
| 1624 | + } | |
| 1625 | + None => {} | |
| 1563 | 1626 | } |
| 1564 | 1627 | cx.notify(); |
| 1565 | 1628 | return; |
| @@ -1569,6 +1632,10 @@ impl Player { | ||
| 1569 | 1632 | .as_mut() |
| 1570 | 1633 | .is_some_and(|session| session.trim_clip(trim.lane, trim.idx, trim.edge, trim.to)); |
| 1571 | 1634 | if trimmed { |
| 1635 | + // The arm rides the door's own answer: `trim_clip` is `false` for an | |
| 1636 | + // edge already where it was asked to go, which is no undo step and | |
| 1637 | + // no edit. | |
| 1638 | + self.mark_dirty(); | |
| 1572 | 1639 | self.reset_after_reseek(); |
| 1573 | 1640 | } |
| 1574 | 1641 | cx.notify(); |
| @@ -1643,7 +1710,20 @@ impl Player { | ||
| 1643 | 1710 | let Some(fade) = self.fade_drag.take() else { |
| 1644 | 1711 | return; |
| 1645 | 1712 | }; |
| 1646 | - self.mark_dirty(); | |
| 1713 | + // The ramp the clip is carrying *now*, so the arm below can tell a drag | |
| 1714 | + // from a press-and-release that left the handle where it was: `set_fade_in` | |
| 1715 | + // / `set_fade_out` answer `true` for any index that exists and take an | |
| 1716 | + // undo step either way, so their own answer is not a change report. | |
| 1717 | + let was = match fade.is_in { | |
| 1718 | + true => self | |
| 1719 | + .session | |
| 1720 | + .as_ref() | |
| 1721 | + .map(|session| session.fade_in_of(fade.lane, fade.idx)), | |
| 1722 | + false => self | |
| 1723 | + .session | |
| 1724 | + .as_ref() | |
| 1725 | + .map(|session| session.fade_out_of(fade.lane, fade.idx)), | |
| 1726 | + }; | |
| 1647 | 1727 | let set = self |
| 1648 | 1728 | .session |
| 1649 | 1729 | .as_mut() |
| @@ -1652,6 +1732,19 @@ impl Player { | ||
| 1652 | 1732 | false => session.set_fade_out(fade.lane, fade.idx, fade.to), |
| 1653 | 1733 | }); |
| 1654 | 1734 | if set { |
| 1735 | + let now = match fade.is_in { | |
| 1736 | + true => self | |
| 1737 | + .session | |
| 1738 | + .as_ref() | |
| 1739 | + .map(|session| session.fade_in_of(fade.lane, fade.idx)), | |
| 1740 | + false => self | |
| 1741 | + .session | |
| 1742 | + .as_ref() | |
| 1743 | + .map(|session| session.fade_out_of(fade.lane, fade.idx)), | |
| 1744 | + }; | |
| 1745 | + if now != was { | |
| 1746 | + self.mark_dirty(); | |
| 1747 | + } | |
| 1655 | 1748 | cx.notify(); |
| 1656 | 1749 | } |
| 1657 | 1750 | } |
crates/app/src/tests/cards.rsmodified+151 -24
| @@ -914,7 +914,10 @@ fn the_budget_is_the_one_number_the_engine_gets() { | ||
| 914 | 914 | // put on screen. |
| 915 | 915 | assert_eq!(auto_bps(1920, 1080, 30.), 6_220_800); |
| 916 | 916 | assert_eq!(auto_bps(160, 120, 15.), BPS_MIN, "a tiny picture floors"); |
| 917 | - assert!(auto_bps(7680, 4320, 60.) <= 20_000_000, "and a huge one caps"); | |
| 917 | + assert!( | |
| 918 | + auto_bps(7680, 4320, 60.) <= 20_000_000, | |
| 919 | + "and a huge one caps" | |
| 920 | + ); | |
| 918 | 921 | for bps in [auto_bps(1920, 1080, 30.), auto_bps(320, 240, 24.)] { |
| 919 | 922 | assert!((BPS_MIN..=BPS_MAX).contains(&bps)); |
| 920 | 923 | } |
| @@ -1067,11 +1070,25 @@ fn a_chord_the_export_moment_answers_never_reaches_the_room() { | ||
| 1067 | 1070 | let (typing, closed) = rest |
| 1068 | 1071 | .split_once("return true;") |
| 1069 | 1072 | .expect("the typing branch returns before the chords below it"); |
| 1070 | - assert!(typing.contains("self.budget_edit = None"), "esc leaves the field"); | |
| 1071 | - assert!(closed.contains("self.close_card()"), "then esc closes the moment"); | |
| 1073 | + assert!( | |
| 1074 | + typing.contains("self.budget_edit = None"), | |
| 1075 | + "esc leaves the field" | |
| 1076 | + ); | |
| 1077 | + assert!( | |
| 1078 | + closed.contains("self.close_card()"), | |
| 1079 | + "then esc closes the moment" | |
| 1080 | + ); | |
| 1072 | 1081 | // Its chords, all of them consumed here rather than by the keymap. |
| 1073 | 1082 | for chord in [ |
| 1074 | - "\"d\"", "\"n\"", "\"e\"", "\"enter\"", "\"up\"", "\"down\"", "\"c\"", "\"b\"", "\"g\"", | |
| 1083 | + "\"d\"", | |
| 1084 | + "\"n\"", | |
| 1085 | + "\"e\"", | |
| 1086 | + "\"enter\"", | |
| 1087 | + "\"up\"", | |
| 1088 | + "\"down\"", | |
| 1089 | + "\"c\"", | |
| 1090 | + "\"b\"", | |
| 1091 | + "\"g\"", | |
| 1075 | 1092 | "\",\"", |
| 1076 | 1093 | ] { |
| 1077 | 1094 | assert!(closed.contains(chord), "{chord} is not the moment's own"); |
| @@ -1086,7 +1103,11 @@ fn a_chord_the_export_moment_answers_never_reaches_the_room() { | ||
| 1086 | 1103 | fn row_three_wears_the_encode_options_and_the_door_to_the_rest() { |
| 1087 | 1104 | let cards = src_text("ui/cards.rs"); |
| 1088 | 1105 | let start = cards.find("fn export_card(").expect("the moment"); |
| 1089 | - let body = &cards[start..start + cards[start..].find("\n /// ").unwrap_or(cards.len() - start)]; | |
| 1106 | + let body = &cards[start | |
| 1107 | + ..start | |
| 1108 | + + cards[start..] | |
| 1109 | + .find("\n /// ") | |
| 1110 | + .unwrap_or(cards.len() - start)]; | |
| 1090 | 1111 | // A segment is the setter it names, not a readout of it. |
| 1091 | 1112 | for (id, chord, setter) in [ |
| 1092 | 1113 | ("moment-picture", "\"c\"", "cycle_export_picture"), |
| @@ -1098,7 +1119,10 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() { | ||
| 1098 | 1119 | assert!(body.contains(setter), "the {id} segment changes nothing"); |
| 1099 | 1120 | } |
| 1100 | 1121 | // The door, wearing the room's own chord rather than a hand-typed one. |
| 1101 | - assert!(body.contains("moment-settings"), "row 3 has no settings door"); | |
| 1122 | + assert!( | |
| 1123 | + body.contains("moment-settings"), | |
| 1124 | + "row 3 has no settings door" | |
| 1125 | + ); | |
| 1102 | 1126 | assert!( |
| 1103 | 1127 | body.contains("self.keymap.chord(ActionId::Settings)"), |
| 1104 | 1128 | "the door's chord is not read from the keymap" |
| @@ -1113,7 +1137,10 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() { | ||
| 1113 | 1137 | .map(|at| &cards[at..at + 1900]) |
| 1114 | 1138 | .expect("the segment atom"); |
| 1115 | 1139 | assert!(seg.contains("INK3()") && seg.contains("INK4()")); |
| 1116 | - assert!(seg.contains("DARK_RAISED()"), "a segment does not answer hover"); | |
| 1140 | + assert!( | |
| 1141 | + seg.contains("DARK_RAISED()"), | |
| 1142 | + "a segment does not answer hover" | |
| 1143 | + ); | |
| 1117 | 1144 | // The readouts worth seeing: the project's picture size and rate, and |
| 1118 | 1145 | // a sound rate that is on the line whether or not it is pressable. |
| 1119 | 1146 | assert!( |
| @@ -1126,13 +1153,18 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() { | ||
| 1126 | 1153 | ); |
| 1127 | 1154 | // The picture segment is a child, not a `has_video` maybe: hidden on the |
| 1128 | 1155 | // sound-only formats it left `c` pressing nothing and no way back. |
| 1129 | - let at = body.find("\"moment-picture\"").expect("the picture segment"); | |
| 1156 | + let at = body | |
| 1157 | + .find("\"moment-picture\"") | |
| 1158 | + .expect("the picture segment"); | |
| 1130 | 1159 | assert!( |
| 1131 | 1160 | !body[at - 240..at].contains("has_video"), |
| 1132 | 1161 | "the picture segment is gated on has_video again -- the dead end" |
| 1133 | 1162 | ); |
| 1134 | 1163 | // Wrapped, never cut: the readouts made row 3 longer than 1280 wide. |
| 1135 | - assert!(body.contains(".flex_wrap()"), "row 3 truncates instead of wrapping"); | |
| 1164 | + assert!( | |
| 1165 | + body.contains(".flex_wrap()"), | |
| 1166 | + "row 3 truncates instead of wrapping" | |
| 1167 | + ); | |
| 1136 | 1168 | } |
| 1137 | 1169 | |
| 1138 | 1170 | /// The dead end the user hit: the cycle walked into the sound-only formats |
| @@ -1140,15 +1172,22 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() { | ||
| 1140 | 1172 | /// and can't turn it back to video"). One cycle, and it wraps. |
| 1141 | 1173 | #[test] |
| 1142 | 1174 | fn the_picture_cycle_wraps_out_of_the_sound_only_formats() { |
| 1143 | - use crate::ui::settings_stance::{PICTURE_CYCLE, next_picture}; | |
| 1175 | + use crate::ui::settings_stance::{next_picture, PICTURE_CYCLE}; | |
| 1144 | 1176 | // Nothing refused: every stop is the next one, and the last wraps to the |
| 1145 | 1177 | // first -- OGG, the tail of the list, back to MP4. |
| 1146 | 1178 | let mut at = PICTURE_CYCLE[0]; |
| 1147 | - for &want in PICTURE_CYCLE.iter().skip(1).chain(std::iter::once(&PICTURE_CYCLE[0])) { | |
| 1179 | + for &want in PICTURE_CYCLE | |
| 1180 | + .iter() | |
| 1181 | + .skip(1) | |
| 1182 | + .chain(std::iter::once(&PICTURE_CYCLE[0])) | |
| 1183 | + { | |
| 1148 | 1184 | at = next_picture(at, |_| false); |
| 1149 | 1185 | assert_eq!(at, want, "the cycle stopped walking"); |
| 1150 | 1186 | } |
| 1151 | - assert_eq!(at, PICTURE_CYCLE[0], "a full walk is a wrap, not a dead end"); | |
| 1187 | + assert_eq!( | |
| 1188 | + at, PICTURE_CYCLE[0], | |
| 1189 | + "a full walk is a wrap, not a dead end" | |
| 1190 | + ); | |
| 1152 | 1191 | assert_eq!(next_picture(Format::Ogg, |_| false), Format::Mp4); |
| 1153 | 1192 | // A timeline with no picture refuses every video format, and the cycle |
| 1154 | 1193 | // still moves: the sound-only stops are what is left of it. |
| @@ -1278,12 +1317,18 @@ fn the_moment_and_the_settings_room_wear_the_same_export_chords() { | ||
| 1278 | 1317 | assert!(settings.contains(chord), "the EXPORT rows lost {chord}"); |
| 1279 | 1318 | assert!(moment.contains(chord), "row 3 lost {chord}"); |
| 1280 | 1319 | assert!(handler.contains(chord), "the moment answers no {chord}"); |
| 1281 | - assert!(player.contains(chord), "the settings page answers no {chord}"); | |
| 1320 | + assert!( | |
| 1321 | + player.contains(chord), | |
| 1322 | + "the settings page answers no {chord}" | |
| 1323 | + ); | |
| 1282 | 1324 | } |
| 1283 | 1325 | // `e` stays the Export press: the encoder seat took `g` rather than a |
| 1284 | 1326 | // shifted letter, which no ghost wears. |
| 1285 | 1327 | assert!(handler.contains("\"e\" | \"enter\" => self.start_export")); |
| 1286 | - assert!(!settings.contains("\n \"e\","), "the Encoder row took `e` back"); | |
| 1328 | + assert!( | |
| 1329 | + !settings.contains("\n \"e\","), | |
| 1330 | + "the Encoder row took `e` back" | |
| 1331 | + ); | |
| 1287 | 1332 | } |
| 1288 | 1333 | |
| 1289 | 1334 | /// The Sound row: what it offers, and that the pick travels to the engine |
| @@ -1401,9 +1446,15 @@ fn a_typed_colour_is_read_in_every_spelling_and_anything_else_is_refused() { | ||
| 1401 | 1446 | edit.typed('z'); |
| 1402 | 1447 | assert_eq!(edit.commit(), None); |
| 1403 | 1448 | let why = edit.refusal.clone().expect("a refusal, not a silence"); |
| 1404 | - assert!(why.contains("#RRGGBB"), "the refusal says what a colour is: {why}"); | |
| 1449 | + assert!( | |
| 1450 | + why.contains("#RRGGBB"), | |
| 1451 | + "the refusal says what a colour is: {why}" | |
| 1452 | + ); | |
| 1405 | 1453 | assert_eq!(edit.text, "zz", "the refusal keeps the text it refused"); |
| 1406 | - assert!(edit.detail().contains("zz▏"), "the caret stays in the buffer"); | |
| 1454 | + assert!( | |
| 1455 | + edit.detail().contains("zz▏"), | |
| 1456 | + "the caret stays in the buffer" | |
| 1457 | + ); | |
| 1407 | 1458 | // ...and the next stroke clears it: that reason described the text that is |
| 1408 | 1459 | // no longer there. |
| 1409 | 1460 | edit.typed('0'); |
| @@ -1562,6 +1613,81 @@ fn every_click_door_that_writes_the_project_arms_autosave() { | ||
| 1562 | 1613 | "{name} arms outside its gate, so a no-op pick would dirty the project" |
| 1563 | 1614 | ); |
| 1564 | 1615 | } |
| 1616 | + // The drag-and-drop family on the timeline: the same class, and the same | |
| 1617 | + // rule. Every one of these doors can answer "nothing happened" -- a clip let | |
| 1618 | + // go where it was picked up, a caption dragged back to the frame it started | |
| 1619 | + // on, a trim, a fade or a `[`/`]` nudge released against the wall the edge | |
| 1620 | + // already stood on, a subtitle row dropped on an overlap ("NOT PLACED") or a | |
| 1621 | + // caption that is not there any more ("NOTHING LIFTED") -- and each one used | |
| 1622 | + // to arm the flag *before* the door was asked, so the ledger's `unsaved` | |
| 1623 | + // ghost, the autosave sidecar and the save-on-close question described a | |
| 1624 | + // project whose content was byte-for-byte what it was. | |
| 1625 | + // | |
| 1626 | + // Each arm now rides its own door's answer, or the one reading the door's | |
| 1627 | + // answer cannot give: a caption's own window before and after the trim | |
| 1628 | + // (`Project::trim_sub` answers `Ok` for an edge released at a wall it already | |
| 1629 | + // stood against) and the ramp's own value before and after the fade | |
| 1630 | + // (`set_fade_*` answer `true` for any index that exists). | |
| 1631 | + for (name, gate) in [ | |
| 1632 | + ("move_clip", "match moved {"), | |
| 1633 | + ( | |
| 1634 | + "place_sub", | |
| 1635 | + "let text = match (self.sub_of_track(track), &mut self.session) {", | |
| 1636 | + ), | |
| 1637 | + ("move_sub", "Some(Ok(())) => {"), | |
| 1638 | + ("lift_sub", "if lifted {"), | |
| 1639 | + ("commit_trim", "if trim.lane.kind == LaneKind::Subtitle {"), | |
| 1640 | + ("commit_fade", "if set {"), | |
| 1641 | + ("nudge_cut", "let to = nudge_edge(current, dir, lo, hi);"), | |
| 1642 | + ( | |
| 1643 | + "trim_cut_to_playhead", | |
| 1644 | + "let to = frame_at(session.now(), self.fps);", | |
| 1645 | + ), | |
| 1646 | + ] { | |
| 1647 | + let body = fn_body(name); | |
| 1648 | + let (before, after) = body | |
| 1649 | + .split_once(gate) | |
| 1650 | + .unwrap_or_else(|| panic!("{name} lost the gate its arm rides")); | |
| 1651 | + assert!( | |
| 1652 | + after.contains("mark_dirty()"), | |
| 1653 | + "{name} arms outside its gate, so a stroke that changed nothing \ | |
| 1654 | + would dirty the project" | |
| 1655 | + ); | |
| 1656 | + assert!( | |
| 1657 | + !before.contains("mark_dirty()"), | |
| 1658 | + "{name} still arms ahead of its gate, so a refusal -- or a drag let \ | |
| 1659 | + go where it started -- leaves the project looking edited" | |
| 1660 | + ); | |
| 1661 | + } | |
| 1662 | + // The history pair is the one place the action table does not arm early: | |
| 1663 | + // the door's own answer ("there was a step to take") is the gate, so `^z` | |
| 1664 | + // with an empty history leaves the flag -- and the close question -- clear. | |
| 1665 | + let act = fn_body("act"); | |
| 1666 | + for gate in ["if self.undo(cx) {", "if self.redo(cx) {"] { | |
| 1667 | + let after = act | |
| 1668 | + .split_once(gate) | |
| 1669 | + .unwrap_or_else(|| panic!("{gate} is gone from the action table")) | |
| 1670 | + .1; | |
| 1671 | + assert!( | |
| 1672 | + after.contains("mark_dirty()"), | |
| 1673 | + "the arm behind `{gate}` arms nothing, so a real step back is \ | |
| 1674 | + invisible to autosave, the unsaved ghost and the close question" | |
| 1675 | + ); | |
| 1676 | + } | |
| 1677 | + // ...and the answer the arm reads is the door's own: the session's bool, not | |
| 1678 | + // a bare call that would arm for an undo with nothing to undo. | |
| 1679 | + for name in ["undo", "redo"] { | |
| 1680 | + let body = fn_body(name); | |
| 1681 | + assert!( | |
| 1682 | + body.contains("PlaybackSession::") && body.contains("stepped"), | |
| 1683 | + "Player::{name} no longer answers whether there was a step to take" | |
| 1684 | + ); | |
| 1685 | + assert!( | |
| 1686 | + !body.contains("mark_dirty"), | |
| 1687 | + "Player::{name} arms its own flag, so the arm in `act` is a second \ | |
| 1688 | + one for the same step" | |
| 1689 | + ); | |
| 1690 | + } | |
| 1565 | 1691 | } |
| 1566 | 1692 | |
| 1567 | 1693 | /// [`crate::ui::dock_stance::transition_of`]: the dock's duration row |
| @@ -1780,11 +1906,9 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() { | ||
| 1780 | 1906 | assert!(native_detail.ends_with(" source"), "{native_detail}"); |
| 1781 | 1907 | // A project at a size nobody listed still gets the whole list, with |
| 1782 | 1908 | // nothing marked rather than a wrong row marked. |
| 1783 | - assert!( | |
| 1784 | - resolution_choices((1000, 1000), native) | |
| 1785 | - .iter() | |
| 1786 | - .all(|(.., picked)| !picked) | |
| 1787 | - ); | |
| 1909 | + assert!(resolution_choices((1000, 1000), native) | |
| 1910 | + .iter() | |
| 1911 | + .all(|(.., picked)| !picked)); | |
| 1788 | 1912 | // Picking a row means that row, and stepping means the next one: the |
| 1789 | 1913 | // list and the stroke read the same ladder. |
| 1790 | 1914 | assert_eq!(next_resolution(ladder[1], native), ladder[2]); |
| @@ -1883,7 +2007,10 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() { | ||
| 1883 | 2007 | assert!(tall <= 360., "the list is taller than the floor"); |
| 1884 | 2008 | assert_eq!( |
| 1885 | 2009 | menu_at(point(px(600.), px(340.)), size(px(640.), px(360.)), tall), |
| 1886 | - (640. - crate::layout::MENU_EDGE - MENU_W, 360. - crate::layout::MENU_EDGE - tall), | |
| 2010 | + ( | |
| 2011 | + 640. - crate::layout::MENU_EDGE - MENU_W, | |
| 2012 | + 360. - crate::layout::MENU_EDGE - tall | |
| 2013 | + ), | |
| 1887 | 2014 | "the list would hang off the smallest window" |
| 1888 | 2015 | ); |
| 1889 | 2016 | } |
| @@ -2238,8 +2365,8 @@ fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() { | ||
| 2238 | 2365 | /// inside the dock, or hands it the dock's width again, fails this. |
| 2239 | 2366 | #[test] |
| 2240 | 2367 | fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() { |
| 2368 | + use crate::layout::{split_size, Split}; | |
| 2241 | 2369 | use crate::SPLIT_W; |
| 2242 | - use crate::layout::{Split, split_size}; | |
| 2243 | 2370 | |
| 2244 | 2371 | // `layout::SPLIT_W` is the one divider between `stance-centre` and the |
| 2245 | 2372 | // dock; the 56px rail that used to eat the centre's left edge is gone |
| @@ -2286,7 +2413,7 @@ fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() { | ||
| 2286 | 2413 | /// assumption. |
| 2287 | 2414 | #[test] |
| 2288 | 2415 | fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height() { |
| 2289 | - use crate::ui::stance::{LEDGER_H, TIME_BAND_H, below_picture_floor}; | |
| 2416 | + use crate::ui::stance::{below_picture_floor, LEDGER_H, TIME_BAND_H}; | |
| 2290 | 2417 | let viewport_h = 1080.; |
| 2291 | 2418 | for bench_h in [140., 200., 400.] { |
| 2292 | 2419 | assert_eq!( |