The timeline draws the dissolve join as an X, ctrl+x binds it
Browse files at this commit270631a14022e4b3d5cfcc240c74b898b9ddcaa9Parent: 474b80e- feat
- the timeline draws the dissolve join as an X, ctrl+x binds it
3 changed files +61 -4
- crates/app/src/keymap.rs +6 -4
- crates/app/src/ui/timeline.rs +27 -0
- crates/app/src/ui/widgets.rs +28 -0
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 own | 972 | // 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 be | 981 | // The mix card takes "f", for the faders on it: "m" would be |
| 980 | // the word but it is the monitoring mute, which is this | 982 | // the word but it is the monitoring mute, which is this |
| 981 | // machine's volume and not the project's -- two things one key | 983 | // 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 each | 1575 | // The fade handles: a small grab corner at each |
| 1549 | // *top* of an audio clip's box, sitting just | 1576 | // *top* of an audio clip's box, sitting just |
| 1550 | // inside the [`EDGE_W`] trim strip rather than on | 1577 | // 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 buys | 107 | /// 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 own | 108 | /// `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-up | 109 | /// key listener keeps working after a press, and the click lands on mouse-up |