Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(timeline): the playhead can follow a trimmed edge, so the monitor shows the frame the cut lands on

Raphael Bernardo8c580f9a45fc
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index 644f9789..31fc3b4a 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -621,6 +621,7 @@
"Placement": "Platzierung",
"Plate": "Platte",
"Play": "Wiedergabe",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Playhead",
"Plays everywhere": "Läuft überall",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 7c30a71b..a8436dd4 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -621,6 +621,7 @@
"Placement": "Placement",
"Plate": "Plate",
"Play": "Play",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Playhead",
"Plays everywhere": "Plays everywhere",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index e8214613..9048c4ae 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -621,6 +621,7 @@
"Placement": "Posición",
"Plate": "Placa",
"Play": "Reproducir",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Playhead",
"Plays everywhere": "Se reproduce en todas partes",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index 0539ac5c..40dab028 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -621,6 +621,7 @@
"Placement": "جای‌گذاری",
"Plate": "پس‌زمینه نواری",
"Play": "پخش",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "نشانگر پخش",
"Plays everywhere": "همه‌جا قابل پخش است",
"Polaroid": "پولاروید",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index 9d757cd5..43fbdf55 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -621,6 +621,7 @@
"Placement": "Position",
"Plate": "Cartouche",
"Play": "Lecture",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Playhead",
"Plays everywhere": "Lisible partout",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 1298858f..c1541b39 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -621,6 +621,7 @@
"Placement": "Smještaj",
"Plate": "Ploča",
"Play": "Reprodukcija",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Playhead",
"Plays everywhere": "Radi svugdje",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index 297493d0..b832e2d4 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -621,6 +621,7 @@
"Placement": "Posizione",
"Plate": "Targa",
"Play": "Riproduci",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Playhead",
"Plays everywhere": "Si riproduce ovunque",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 8c41f6bf..c01b12fa 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -621,6 +621,7 @@
"Placement": "配置",
"Plate": "プレート",
"Play": "再生",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Playhead",
"Plays everywhere": "どこでも再生可能",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index 413ecd21..de0d7f97 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -621,6 +621,7 @@
"Placement": "배치",
"Plate": "판",
"Play": "재생",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Playhead",
"Plays everywhere": "어디서나 재생",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index 37836977..8c3617f2 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -621,6 +621,7 @@
"Placement": "Posição",
"Plate": "Placa",
"Play": "Reproduzir",
+ "Player follows the resize: the playhead rides the edge you trim": "O player acompanha o corte: a agulha segue a borda que você arrasta",
"Playhead": "Playhead",
"Plays everywhere": "Reproduz em qualquer lugar",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index ff8d621c..970565b0 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -621,6 +621,7 @@
"Placement": "Расположение",
"Plate": "Плашка",
"Play": "Воспроизвести",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Курсор",
"Plays everywhere": "Воспроизводится везде",
"Polaroid": "Полароид",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index f9c0656c..9c091a13 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -621,6 +621,7 @@
"Placement": "Yerleşim",
"Plate": "Plaka",
"Play": "Oynat",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "Playhead",
"Plays everywhere": "Her yerde oynatılır",
"Polaroid": "Polaroid",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 699c7a33..d5aa94d7 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -621,6 +621,7 @@
"Placement": "位置",
"Plate": "底板",
"Play": "播放",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "播放头",
"Plays everywhere": "随处可播",
"Polaroid": "宝丽来",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index 0a7fb36f..b7cda3e7 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -621,6 +621,7 @@
"Placement": "位置",
"Plate": "底板",
"Play": "播放",
+ "Player follows the resize: the playhead rides the edge you trim": "Player follows the resize: the playhead rides the edge you trim",
"Playhead": "播放磁頭",
"Plays everywhere": "隨處可播",
"Polaroid": "拍立得",
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index 0d1b96fa..2e26f219 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -719,6 +719,9 @@ pub fn run() -> Result<(), slint::PlatformError> {
editor.on_magnetic_changed(on_window!(|state, on: bool| {
state.handle(Msg::Timeline(TimelineMsg::MagneticChanged(on)));
}));
+ editor.on_trim_follow_changed(on_window!(|state, on: bool| {
+ state.handle(Msg::Timeline(TimelineMsg::TrimFollowChanged(on)));
+ }));
editor.on_preview_axis_changed(on_window!(|state, on: bool| {
state.handle(Msg::Timeline(TimelineMsg::PreviewAxisChanged(on)));
}));
diff --git a/src/crates/concat/src/panes/timeline.rs b/src/crates/concat/src/panes/timeline.rs
index d8fc0425..adabc123 100644
--- a/src/crates/concat/src/panes/timeline.rs
+++ b/src/crates/concat/src/panes/timeline.rs
@@ -60,6 +60,7 @@ pub enum TimelineMsg {
MagneticToggled,
/// The tray's preview axis button: the monitor follows the pointer.
/// A preference, remembered.
+ TrimFollowChanged(bool),
PreviewAxisChanged(bool),
/// The button's menu: whether the sound under the pointer plays too.
PreviewAxisAudioChanged(bool),
@@ -131,6 +132,10 @@ impl TimelinePane {
studio.prefs.magnetic = !studio.prefs.magnetic;
studio.prefs.save(&studio.host.dirs);
}
+ TimelineMsg::TrimFollowChanged(on) => {
+ studio.prefs.trim_follow = on;
+ studio.prefs.save(&studio.host.dirs);
+ }
TimelineMsg::PreviewAxisChanged(on) => {
studio.prefs.preview_axis = on;
studio.prefs.save(&studio.host.dirs);
diff --git a/src/crates/concat/src/prefs.rs b/src/crates/concat/src/prefs.rs
index a70d1075..ae1208c4 100644
--- a/src/crates/concat/src/prefs.rs
+++ b/src/crates/concat/src/prefs.rs
@@ -50,6 +50,10 @@ pub struct Preferences {
/// sometimes the point; ⇧⌫ ripples either way.
/// https://github.com/jub0t/Concat/issues/106
pub magnetic: bool,
+ /// Trim follow: while a clip's edge is dragged, the playhead rides the
+ /// edge, so the monitor shows the exact frame the cut lands on. Off by
+ /// default; the tray's button beside the hand turns it on.
+ pub trim_follow: bool,
/// The preview axis: the monitor shows the frame under the pointer as
/// it crosses the lanes, the playhead staying where it is. Off by
/// default: a monitor that jumps with the pointer startles whoever has
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 665e9e86..249ff46a 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -3348,12 +3348,24 @@ impl Studio {
clip.duration = f64::from(duration - delta);
clip.source_start = f64::from(source_start + delta * speed);
}
+ // Trim follow: the playhead on the new first frame.
+ if self.prefs.trim_follow {
+ self.seek(at);
+ }
} else {
let wanted = self.snapped(start + duration + seconds, threshold, &id);
let at = wanted.max(start + MIN_DURATION);
if let Some(clip) = self.echo_clip_mut(&id) {
clip.duration = f64::from(at - start);
}
+ // Trim follow: the playhead on the new last frame, one
+ // frame inside the edge - at the edge itself the clip
+ // has already ended and the monitor would show what
+ // comes after it.
+ if self.prefs.trim_follow {
+ let frame = 1.0 / self.frame_rate().max(1.0);
+ self.seek((at - frame).max(start));
+ }
}
}
Gesture::TransitionResize {
@@ -3426,6 +3438,7 @@ impl Studio {
Edge::End => after.duration - f64::from(duration),
};
if delta.abs() > 1e-6 {
+ let id = clip.clone();
self.apply(Command::TrimClip {
clip_id: clip,
edge: match edge {
@@ -3437,6 +3450,14 @@ impl Studio {
// https://github.com/jub0t/Concat/issues/106
ripple: self.prefs.magnetic,
});
+ // Trim follow: a magnetic head trim slides the clip back
+ // into the gap, and the playhead goes with its first
+ // frame.
+ if self.prefs.trim_follow && edge == Edge::Start {
+ if let Some(start) = self.clip(&id).map(|clip| clip.start) {
+ self.seek(start as f32);
+ }
+ }
}
}
Gesture::TransitionResize {
@@ -6046,6 +6067,7 @@ impl Studio {
editor.set_tool(self.lanes.tool);
editor.set_snap(self.lanes.snap);
editor.set_magnetic(self.prefs.magnetic);
+ editor.set_trim_follow(self.prefs.trim_follow);
editor.set_preview_axis(self.prefs.preview_axis);
editor.set_preview_axis_audio(self.prefs.preview_axis_audio);
editor.set_pan_mode(self.lanes.pan_mode);
diff --git a/src/crates/concat/ui/editor.slint b/src/crates/concat/ui/editor.slint
index 16a8a3eb..d2065943 100644
--- a/src/crates/concat/ui/editor.slint
+++ b/src/crates/concat/ui/editor.slint
@@ -250,6 +250,9 @@ export global Editor {
in-out property <bool> magnetic;
/// Hand tool: wheel and drag pan time instead of scrolling the stack.
in-out property <bool> pan-mode: false;
+ /// Trim follow: the playhead rides a clip edge while it is dragged. A
+ /// remembered preference, which Rust owns.
+ in-out property <bool> trim-follow;
/// The preview axis: the monitor shows the frame under the pointer as
/// it crosses the lanes, the playhead staying put. A remembered
/// preference, which Rust owns; `preview-axis-audio` is whether the
@@ -284,6 +287,7 @@ export global Editor {
callback snap-changed(snap: bool);
callback magnetic-changed(on: bool);
callback pan-changed(on: bool);
+ callback trim-follow-changed(on: bool);
callback preview-axis-changed(on: bool);
callback preview-axis-audio-changed(on: bool);
/// The preview axis: the pointer is over the lanes at this instant,
diff --git a/src/crates/concat/ui/icons.slint b/src/crates/concat/ui/icons.slint
index 39b6a4e1..17c9ef91 100644
--- a/src/crates/concat/ui/icons.slint
+++ b/src/crates/concat/ui/icons.slint
@@ -101,6 +101,8 @@ export enum Glyph {
fold,
/// the preview axis: a hairline with the pointer beside it
axis,
+ /// trim follow: the playhead between two arrows pulling an edge
+ trim-follow,
waveform,
filter,
eye-off,
@@ -543,6 +545,13 @@ export component Icon inherits Rectangle {
commands: "M7 3v18 M11 8l9 4.2-4 1.2-1.6 4z";
}
+ // Trim follow: the playhead with an arrow either side - the line
+ // that moves with the edge being dragged.
+ if root.glyph == Glyph.trim-follow: Stroked {
+ size: root.size; tint: root.tint; weight: root.weight;
+ commands: "M12 3v18 M9 3h6 M6 9l-3 3 3 3 M18 9l3 3-3 3 M3 12h5 M16 12h5";
+ }
+
// lucide/blend: two circles overlapping, for a filter - a look laid
// over whatever plays under it.
if root.glyph == Glyph.filter: Stroked {
diff --git a/src/crates/concat/ui/timeline/tray.slint b/src/crates/concat/ui/timeline/tray.slint
index 0a966d91..a950a646 100644
--- a/src/crates/concat/ui/timeline/tray.slint
+++ b/src/crates/concat/ui/timeline/tray.slint
@@ -61,6 +61,8 @@ export component TimelineTray inherits Rectangle {
in property <bool> snap: true;
in property <bool> magnetic: false;
in property <bool> pan-mode: false;
+ /// Trim follow: the playhead rides a clip edge while it is dragged.
+ in property <bool> trim-follow: false;
/// The preview axis: the monitor follows the pointer across the lanes.
in property <bool> preview-axis: false;
in property <int> selected-count;
@@ -79,6 +81,7 @@ export component TimelineTray inherits Rectangle {
callback snap-changed(snap: bool);
callback magnetic-changed(on: bool);
callback pan-changed(on: bool);
+ callback trim-follow-changed(on: bool);
callback preview-axis-changed(on: bool);
/// The chevron beside the preview axis: open its menu under the button
/// at this x, in the tray's coordinates. The pane hosts the menu; see
@@ -190,6 +193,15 @@ export component TimelineTray inherits Rectangle {
checked: root.pan-mode;
clicked => { root.pan-changed(!root.pan-mode); }
}
+ // Beside the hand: while an edge is dragged the playhead rides it,
+ // so the monitor shows the frame the cut lands on.
+ TrayButton {
+ glyph: Glyph.trim-follow;
+ label: I18n.t("Player follows the resize: the playhead rides the edge you trim");
+ icon-size: 16px;
+ checked: root.trim-follow;
+ clicked => { root.trim-follow-changed(!root.trim-follow); }
+ }
Divider { }
diff --git a/src/crates/concat/ui/workspace/seat.slint b/src/crates/concat/ui/workspace/seat.slint
index 29649432..9c8a24fa 100644
--- a/src/crates/concat/ui/workspace/seat.slint
+++ b/src/crates/concat/ui/workspace/seat.slint
@@ -333,6 +333,7 @@ export component Seat inherits Rectangle {
snap: Editor.snap;
magnetic: Editor.magnetic;
pan-mode: Editor.pan-mode;
+ trim-follow: Editor.trim-follow;
preview-axis: Editor.preview-axis;
preview-axis-audio: Editor.preview-axis-audio;
selected-count: Editor.selected-count;
@@ -355,6 +356,7 @@ export component Seat inherits Rectangle {
snap-changed(snap) => { Editor.snap-changed(snap); }
magnetic-changed(on) => { Editor.magnetic-changed(on); }
pan-changed(on) => { Editor.pan-changed(on); }
+ trim-follow-changed(on) => { Editor.trim-follow-changed(on); }
preview-axis-changed(on) => { Editor.preview-axis-changed(on); }
preview-axis-audio-changed(on) => { Editor.preview-axis-audio-changed(on); }
hovered(seconds) => { Editor.hovered(seconds); }
diff --git a/src/crates/concat/ui/workspace/timeline-pane.slint b/src/crates/concat/ui/workspace/timeline-pane.slint
index 262ebd3e..4e17d190 100644
--- a/src/crates/concat/ui/workspace/timeline-pane.slint
+++ b/src/crates/concat/ui/workspace/timeline-pane.slint
@@ -39,6 +39,7 @@ export component TimelinePane inherits Rectangle {
in property <bool> snap: true;
in property <bool> magnetic: false;
in property <bool> pan-mode: false;
+ in property <bool> trim-follow: false;
in property <bool> preview-axis: false;
in property <bool> preview-axis-audio;
in property <int> selected-count;
@@ -52,6 +53,7 @@ export component TimelinePane inherits Rectangle {
callback snap-changed(snap: bool);
callback magnetic-changed(on: bool);
callback pan-changed(on: bool);
+ callback trim-follow-changed(on: bool);
callback preview-axis-changed(on: bool);
callback preview-axis-audio-changed(on: bool);
/// The preview axis: the pointer over the lanes, and then not.
@@ -237,6 +239,7 @@ export component TimelinePane inherits Rectangle {
snap: root.snap;
magnetic: root.magnetic;
pan-mode: root.pan-mode;
+ trim-follow: root.trim-follow;
preview-axis: root.preview-axis;
selected-count: root.selected-count;
can-undo: root.can-undo;
@@ -249,6 +252,7 @@ export component TimelinePane inherits Rectangle {
snap-changed(snap) => { root.snap-changed(snap); }
magnetic-changed(on) => { root.magnetic-changed(on); }
pan-changed(on) => { root.pan-changed(on); }
+ trim-follow-changed(on) => { root.trim-follow-changed(on); }
preview-axis-changed(on) => { root.preview-axis-changed(on); }
axis-menu-requested(x) => {
// Under the button, in the pane's own coordinates: the tray