forge
Explore
Log in

Don't you dare go Hollow

The timeline draws the dissolve join as an X, ctrl+x binds it

Browse files at this commit

270631a14022e4b3d5cfcc240c74b898b9ddcaa9Ahmet Kaan GümüşParent: 474b80e
  • feat
    • the timeline draws the dissolve join as an X, ctrl+x binds it
Show full message
✨ feat(app): the timeline draws the dissolve join as an X, ctrl+x binds it

The keymap's own rebind test claims ctrl+d as a free chord to demo with,
so Dissolve takes ctrl+x instead -- the shape its glyph (widgets.rs,
dissolve_glyph) draws at the join. Wired into the clip context menu
(menus.rs MENU_ITEMS) and the timeline (ui/timeline.rs): an X over the
last transition_out frames of a clip whenever its neighbour still abuts it.
crates/app/src/keymap.rsmodified+6 -4
@@ -972,10 +972,12 @@ impl Keymap {
972 // ctrl its own room now that plain "f" is the mix card's own972 // ctrl its own room now that plain "f" is the mix card's own
973 // (below) -- the same letter, the modifier telling them apart.973 // (below) -- the same letter, the modifier telling them apart.
974 b(ActionId::Crossfade, "f", true),974 b(ActionId::Crossfade, "f", true),
975- // Dissolve takes ctrl+d: the mnemonic letter for "dissolve",975+ // Dissolve takes ctrl+x: the join it draws on the timeline is
976- // with ctrl its own room now that plain "d" is Detach's --976+ // an X (widgets.rs, dissolve_glyph) -- "d" itself is taken
977- // the same letter, the modifier telling them apart.977+ // both plain (Detach) and, in the keymap's own rebind test,
978- b(ActionId::Dissolve, "d", true),978+ // as the free chord it rebinds Delete onto, so this reaches
979+ // for the shape instead of the word.
980+ b(ActionId::Dissolve, "x", true),
979 // The mix card takes "f", for the faders on it: "m" would be981 // The mix card takes "f", for the faders on it: "m" would be
980 // the word but it is the monitoring mute, which is this982 // the word but it is the monitoring mute, which is this
981 // machine's volume and not the project's -- two things one key983 // machine's volume and not the project's -- two things one key
crates/app/src/ui/timeline.rsmodified+27 -0
@@ -1545,6 +1545,33 @@ impl Player {
1545 .flatten(),1545 .flatten(),
1546 )1546 )
1547 })1547 })
1548+ // The dissolve: a small X astride the join, drawn
1549+ // over the last `transition_out` frames of this
1550+ // clip's own box, whenever the next clip on the
1551+ // lane actually abuts it -- the engine already
1552+ // refuses `transition_out` on anything else
1553+ // ([`Project::set_transition_out`]), but a moved
1554+ // neighbour can leave a stale value behind, so
1555+ // this checks the join itself rather than trust
1556+ // the field alone.
1557+ .when(
1558+ lane.kind == LaneKind::Video
1559+ && clip.transition_out > 0
1560+ && clips.get(i + 1).is_some_and(|n| n.start == clip.end()),
1561+ |d| {
1562+ d.child(
1563+ div()
1564+ .absolute()
1565+ .right_0()
1566+ .top_0()
1567+ .h_full()
1568+ .w(px(scale
1569+ .width_px(f64::from(clip.transition_out) / self.fps)
1570+ .min(width)))
1571+ .child(dissolve_glyph()),
1572+ )
1573+ },
1574+ )
1548 // The fade handles: a small grab corner at each1575 // The fade handles: a small grab corner at each
1549 // *top* of an audio clip's box, sitting just1576 // *top* of an audio clip's box, sitting just
1550 // inside the [`EDGE_W`] trim strip rather than on1577 // inside the [`EDGE_W`] trim strip rather than on
crates/app/src/ui/widgets.rsmodified+28 -0
@@ -76,6 +76,34 @@ pub(crate) fn fade_wedge(is_in: bool) -> impl IntoElement {
76 .size_full()76 .size_full()
77 }77 }
78 78
79+/// A video clip's dissolve into its neighbour, drawn as a small X astride the
80+/// join -- the box it is given is the last [`Clip::transition_out`] frames of
81+/// the clip's own width, so the mark sits right at the edge it dissolves
82+/// through. Two strokes rather than [`fade_wedge`]'s fill: a dissolve is not
83+/// a ramp to or from silence, it is two clips overlapping, and an X reads as
84+/// a splice the way a wedge reads as a fade.
85+pub(crate) fn dissolve_glyph() -> impl IntoElement {
86+ canvas(
87+ |_, _, _| (),
88+ move |bounds, _, window, _| {
89+ let (o, s) = (bounds.origin, bounds.size);
90+ let (w, h) = (f32::from(s.width), f32::from(s.height));
91+ if w <= 0. || h <= 0. {
92+ return;
93+ }
94+ let mut path = PathBuilder::stroke(px(1.5));
95+ path.move_to(point(o.x, o.y));
96+ path.line_to(point(o.x + px(w), o.y + px(h)));
97+ path.move_to(point(o.x + px(w), o.y));
98+ path.line_to(point(o.x, o.y + px(h)));
99+ if let Ok(path) = path.build() {
100+ window.paint_path(path, rgba(ACCENT_WASH()));
101+ }
102+ },
103+ )
104+ .size_full()
105+}
106+
79 /// A toolbar button: its glyph, its name, and its key on hover. `id` only buys107 /// A toolbar button: its glyph, its name, and its key on hover. `id` only buys
80 /// `on_click` and the tooltip -- it is still not focusable, so the root's own108 /// `on_click` and the tooltip -- it is still not focusable, so the root's own
81 /// key listener keeps working after a press, and the click lands on mouse-up109 /// key listener keeps working after a press, and the click lands on mouse-up