forge
Explore
Log in

Don't you dare go Hollow

A dissolve key joins two video clips end to end (ctrl+d)

Browse files at this commit

474b80e215a875e972deda6d22e88c981189be1aAhmet Kaan GümüşParent: 82061a9
  • feat
    • a dissolve key joins two video clips end to end (ctrl+d)
Show full message
✨ feat(app): a dissolve key joins two video clips end to end (ctrl+d)

Mirrors the audio crossfade: PlaybackSession::set_transition_out wraps
Project::set_transition_out (Dirty::Picture), Player::dissolve_selected
picks the join the same way crossfade_selected does, and a second press
removes the dissolve it just made. Wired into the keymap, the dispatch
table, and the clip context menu.
crates/app/src/keymap.rsmodified+14 -2
@@ -134,6 +134,11 @@ actions! {
134 /// two adjacent clips picked on one lane, or a single pick faded into the134 /// two adjacent clips picked on one lane, or a single pick faded into the
135 /// clip right after it.135 /// clip right after it.
136 Crossfade,136 Crossfade,
137+ /// Dissolves the selected video clip into its neighbour
138+ /// ([`Project::set_transition_out`]): two adjacent clips picked on one
139+ /// lane, or a single pick dissolved into the clip right after it. A
140+ /// second press on a clip that already dissolves removes it instead.
141+ Dissolve,
137 Mix,142 Mix,
138 ToggleSnap,143 ToggleSnap,
139 ToggleSubtitles,144 ToggleSubtitles,
@@ -225,6 +230,7 @@ impl ActionId {
225 ActionId::Speed => "Speed (tape)…",230 ActionId::Speed => "Speed (tape)…",
226 ActionId::Silence => "Silences: cut or speed up…",231 ActionId::Silence => "Silences: cut or speed up…",
227 ActionId::Crossfade => "Crossfade into the next clip",232 ActionId::Crossfade => "Crossfade into the next clip",
233+ ActionId::Dissolve => "Dissolve into the next clip",
228 ActionId::Mix => "Mix: track volumes and the limiter…",234 ActionId::Mix => "Mix: track volumes and the limiter…",
229 ActionId::ToggleSnap => "Snap on / off (edges, the playhead, the start)",235 ActionId::ToggleSnap => "Snap on / off (edges, the playhead, the start)",
230 ActionId::ToggleSubtitles => "Subtitles on / off over the picture",236 ActionId::ToggleSubtitles => "Subtitles on / off over the picture",
@@ -292,6 +298,7 @@ impl ActionId {
292 ActionId::Speed => "speed",298 ActionId::Speed => "speed",
293 ActionId::Silence => "silence",299 ActionId::Silence => "silence",
294 ActionId::Crossfade => "crossfade",300 ActionId::Crossfade => "crossfade",
301+ ActionId::Dissolve => "dissolve",
295 ActionId::Mix => "mix",302 ActionId::Mix => "mix",
296 ActionId::ToggleSnap => "toggle-snap",303 ActionId::ToggleSnap => "toggle-snap",
297 ActionId::ToggleSubtitles => "toggle-subtitles",304 ActionId::ToggleSubtitles => "toggle-subtitles",
@@ -346,7 +353,8 @@ impl ActionId {
346 // timeline the clip is on -- it is a clip card like the three353 // timeline the clip is on -- it is a clip card like the three
347 // above it, opened on whichever half was picked.354 // above it, opened on whichever half was picked.
348 | ActionId::Silence355 | ActionId::Silence
349- | ActionId::Crossfade => Category::Clips,356+ | ActionId::Crossfade
357+ | ActionId::Dissolve => Category::Clips,
350 // The project's own picture size is not a clip's business, and not358 // The project's own picture size is not a clip's business, and not
351 // a file operation either: it is what the viewer is looking at.359 // a file operation either: it is what the viewer is looking at.
352 // Neither is how much of the timeline the panel shows: a zoom edits360 // Neither is how much of the timeline the panel shows: a zoom edits
@@ -964,6 +972,10 @@ impl Keymap {
964 // 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
965 // (below) -- the same letter, the modifier telling them apart.973 // (below) -- the same letter, the modifier telling them apart.
966 b(ActionId::Crossfade, "f", true),974 b(ActionId::Crossfade, "f", true),
975+ // Dissolve takes ctrl+d: the mnemonic letter for "dissolve",
976+ // with ctrl its own room now that plain "d" is Detach's --
977+ // the same letter, the modifier telling them apart.
978+ b(ActionId::Dissolve, "d", true),
967 // The mix card takes "f", for the faders on it: "m" would be979 // The mix card takes "f", for the faders on it: "m" would be
968 // the word but it is the monitoring mute, which is this980 // the word but it is the monitoring mute, which is this
969 // machine's volume and not the project's -- two things one key981 // machine's volume and not the project's -- two things one key
@@ -1276,7 +1288,7 @@ mod tests {
1276 #[test]1288 #[test]
1277 fn every_default_stroke_reaches_its_action() {1289 fn every_default_stroke_reaches_its_action() {
1278 let k = Keymap::defaults();1290 let k = Keymap::defaults();
1279- assert_eq!(k.entries().len(), 62);1291+ assert_eq!(k.entries().len(), 63);
1280 assert_eq!(k.lookup("f11", false), Some(ActionId::Fullscreen));1292 assert_eq!(k.lookup("f11", false), Some(ActionId::Fullscreen));
1281 assert_eq!(k.lookup("w", false), Some(ActionId::Screenshot));1293 assert_eq!(k.lookup("w", false), Some(ActionId::Screenshot));
1282 assert_eq!(k.lookup("y", false), Some(ActionId::SubtitleStyle));1294 assert_eq!(k.lookup("y", false), Some(ActionId::SubtitleStyle));
crates/app/src/menus.rsmodified+5 -1
@@ -142,7 +142,7 @@ impl RowItem {
142 /// action a stroke already reaches -- the menu is a second way *to* the actions142 /// action a stroke already reaches -- the menu is a second way *to* the actions
143 /// and never a second version of them -- so both the label and the hint come143 /// and never a second version of them -- so both the label and the hint come
144 /// out of the keymap registry and the two can never disagree.144 /// out of the keymap registry and the two can never disagree.
145-pub(crate) const MENU_ITEMS: [ActionId; 14] = [145+pub(crate) const MENU_ITEMS: [ActionId; 15] = [
146 ActionId::Cut,146 ActionId::Cut,
147 // The clipboard pair, which had no door but a chord: copy takes the clip the147 // The clipboard pair, which had no door but a chord: copy takes the clip the
148 // menu names, and paste is the timeline's rather than this clip's -- the148 // menu names, and paste is the timeline's rather than this clip's -- the
@@ -160,6 +160,10 @@ pub(crate) const MENU_ITEMS: [ActionId; 14] = [
160 // was clicked -- and a card only a stroke could open is one a pointer never160 // was clicked -- and a card only a stroke could open is one a pointer never
161 // finds.161 // finds.
162 ActionId::Silence,162 ActionId::Silence,
163+ // The dissolve is a video clip's own join, same door as the crossfade
164+ // above it would be for sound -- a stroke-only pair, opened here on
165+ // whichever half was clicked.
166+ ActionId::Dissolve,
163 ActionId::Color,167 ActionId::Color,
164 ActionId::Fit,168 ActionId::Fit,
165 ActionId::ToggleMute,169 ActionId::ToggleMute,
crates/app/src/player/actions.rsmodified+2 -0
@@ -54,6 +54,7 @@ impl Player {
54 | ActionId::RemoveSubtitleLane54 | ActionId::RemoveSubtitleLane
55 | ActionId::ImportSubtitles55 | ActionId::ImportSubtitles
56 | ActionId::Crossfade56 | ActionId::Crossfade
57+ | ActionId::Dissolve
57 ) {58 ) {
58 self.mark_dirty();59 self.mark_dirty();
59 }60 }
@@ -90,6 +91,7 @@ impl Player {
90 ActionId::Cut => self.cut(cx),91 ActionId::Cut => self.cut(cx),
91 ActionId::Regroup => self.regroup(cx),92 ActionId::Regroup => self.regroup(cx),
92 ActionId::Crossfade => self.crossfade_selected(cx),93 ActionId::Crossfade => self.crossfade_selected(cx),
94+ ActionId::Dissolve => self.dissolve_selected(cx),
93 ActionId::Detach => self.detach(cx),95 ActionId::Detach => self.detach(cx),
94 ActionId::Group => self.group(cx),96 ActionId::Group => self.group(cx),
95 ActionId::Select => self.select_under_playhead(cx),97 ActionId::Select => self.select_under_playhead(cx),
crates/app/src/player/timeline_edit.rsmodified+35 -0
@@ -1295,6 +1295,41 @@ impl Player {
1295 cx.notify();1295 cx.notify();
1296 }1296 }
1297 1297
1298+ /// Dissolves the join the selection names, into or back out of it: two
1299+ /// picks on one video lane take the pair, one pick takes it and its
1300+ /// right-hand neighbour. If the leading clip already carries a dissolve
1301+ /// this removes it (`0` frames) instead of widening it -- a toggle, same
1302+ /// key either way. The engine owns adjacency ([`Project::set_transition_out`]);
1303+ /// a refusal is worded here, in [`Player::crossfade_selected`]'s voice.
1304+ pub(crate) fn dissolve_selected(&mut self, cx: &mut Context<Self>) {
1305+ if self.exporting().is_some() {
1306+ return;
1307+ }
1308+ let Some((lane, idx)) = (match self.selected.picks() {
1309+ [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))),
1310+ _ => self.selected.anchor(),
1311+ }) else {
1312+ self.notify_user("NOTHING TO DISSOLVE — select a video clip that has a neighbour".into());
1313+ cx.notify();
1314+ return;
1315+ };
1316+ let Some(session) = &mut self.session else {
1317+ cx.notify();
1318+ return;
1319+ };
1320+ let removing = session.transition_out_of(lane, idx) > 0;
1321+ let frames = if removing { 0 } else { self.fps.round().max(1.) as u32 };
1322+ if !session.set_transition_out(lane, idx, frames) {
1323+ self.notify_user(
1324+ "NOTHING TO DISSOLVE — it takes two video clips sitting end to end on one lane"
1325+ .into(),
1326+ );
1327+ } else if removing {
1328+ self.notify_user("DISSOLVE REMOVED — the clips cut again".into());
1329+ }
1330+ cx.notify();
1331+ }
1332+
1298 /// The clip as the drag is showing it: an edge under the pointer moves its1333 /// The clip as the drag is showing it: an edge under the pointer moves its
1299 /// own box, and the boxes of everything linked to it, before anything is1334 /// own box, and the boxes of everything linked to it, before anything is
1300 /// committed. Display only -- the project is not touched until the release.1335 /// committed. Display only -- the project is not touched until the release.
crates/engine/src/playback.rsmodified+12 -0
@@ -2587,6 +2587,18 @@ impl PlaybackSession {
2587 self.edit(Dirty::Sound, |p| p.crossfade(lane, idx, frames))2587 self.edit(Dirty::Sound, |p| p.crossfade(lane, idx, frames))
2588 }2588 }
2589 2589
2590+ /// Timeline frames of dissolve at the end of the clip at `idx` of `lane`,
2591+ /// into its neighbour. `0` for an index that is not there.
2592+ pub fn transition_out_of(&self, lane: Lane, idx: usize) -> u32 {
2593+ self.project.transition_out_of(lane, idx)
2594+ }
2595+
2596+ /// Sets that clip's dissolve into its neighbour, clamped to its own
2597+ /// length. A picture edit -- same as a grade or fit policy.
2598+ pub fn set_transition_out(&mut self, lane: Lane, idx: usize, frames: u32) -> bool {
2599+ self.edit(Dirty::Picture, |p| p.set_transition_out(lane, idx, frames))
2600+ }
2601+
2590 /// The clip at `idx` -- what a caller copies. It is a pair of source frame2602 /// The clip at `idx` -- what a caller copies. It is a pair of source frame
2591 /// numbers and nothing else, so a copy stays valid after the clip it came2603 /// numbers and nothing else, so a copy stays valid after the clip it came
2592 /// from is deleted. `None` past the end.2604 /// from is deleted. `None` past the end.