The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
fix(phone): Delete on the main picture lane closes the gap, until the magnet is set either way (#497)
Jareerc631c4592f7b
diff --git a/src/crates/concat/src/panes/settings.rs b/src/crates/concat/src/panes/settings.rsindex 4c11a01d..7d68d146 100644--- a/src/crates/concat/src/panes/settings.rs+++ b/src/crates/concat/src/panes/settings.rs@@ -332,7 +332,7 @@ impl SettingsPane {studio.notify(&t("settings.gpuNextStart"), false);}SettingsMsg::MagneticChanged(on) => {- studio.prefs.magnetic = on;+ studio.prefs.set_magnetic(on);studio.prefs.save(&studio.host.dirs);}SettingsMsg::DownloadSourceChanged(index) => {@@ -856,7 +856,7 @@ impl SettingsPane {proxies: studio.prefs.proxies,gpu: !studio.prefs.draws_in_software(),gpu_switchable: cfg!(any(windows, target_os = "linux")),- magnetic: studio.prefs.magnetic,+ magnetic: studio.prefs.magnetic(),download_source: self.download_source as i32,download_base: self.download_base.as_str().into(),server_enabled: studio.prefs.server.enabled,diff --git a/src/crates/concat/src/panes/timeline.rs b/src/crates/concat/src/panes/timeline.rsindex eff6d770..16dc4cfb 100644--- a/src/crates/concat/src/panes/timeline.rs+++ b/src/crates/concat/src/panes/timeline.rs@@ -136,11 +136,12 @@ impl TimelinePane {TimelineMsg::SnapChanged(on) => self.snap = on,TimelineMsg::SnapToggled => self.snap = !self.snap,TimelineMsg::MagneticChanged(on) => {- studio.prefs.magnetic = on;+ studio.prefs.set_magnetic(on);studio.prefs.save(&studio.host.dirs);}TimelineMsg::MagneticToggled => {- studio.prefs.magnetic = !studio.prefs.magnetic;+ let on = !studio.prefs.magnetic();+ studio.prefs.set_magnetic(on);studio.prefs.save(&studio.host.dirs);}TimelineMsg::TrimFollowChanged(on) => {diff --git a/src/crates/concat/src/prefs.rs b/src/crates/concat/src/prefs.rsindex 3bf37a0d..195740fb 100644--- a/src/crates/concat/src/prefs.rs+++ b/src/crates/concat/src/prefs.rs@@ -87,10 +87,15 @@ pub struct Preferences {/// would otherwise leave Concat on the CPU for good.pub software_after_crash: Option<String>,/// The magnetic timeline: a delete and a trim close the gap they would- /// leave, on the lane they happen on. Off by default, because a gap is- /// sometimes the point; ⇧⌫ ripples either way.+ /// leave, on the lane they happen on. Off by default on a desk, because+ /// a gap is sometimes the point; ⇧⌫ ripples either way. Read it through+ /// [`Preferences::magnetic`], which knows the phone's default./// https://github.com/jub0t/Concat/issues/106pub magnetic: bool,+ /// Whether the person has set the magnetic timeline, either way. Every+ /// phone has saved `magnetic: false` without anyone choosing it, so+ /// this is what tells a phone's chosen Off from the default it got.+ pub magnetic_chosen: 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.@@ -267,6 +272,23 @@ impl Preferences {.filter(|location| std::path::Path::new(location).is_dir())}+ /// Whether the magnet shows as on. On a phone, until the person says+ /// otherwise: the phone editors close the gap a delete leaves on the+ /// main picture's lane, a Split and Delete there left a black hole in+ /// the picture and the export (#497), and the phone shell has no magnet+ /// in sight to turn on. What that default closes is+ /// `Studio::closes_gap`'s to say; the field alone is the desk's magnet,+ /// which closes every lane.+ pub fn magnetic(&self) -> bool {+ self.magnetic || (crate::platform::phone() && !self.magnetic_chosen)+ }++ /// Sets the magnetic timeline by the person's choice.+ pub fn set_magnetic(&mut self, on: bool) {+ self.magnetic = on;+ self.magnetic_chosen = true;+ }+/// Whether this launch draws in software, by choice or after a crash.pub fn draws_in_software(&self) -> bool {self.software_gpu || self.software_after_crash.is_some()@@ -320,6 +342,23 @@ impl Preferences {mod tests {use super::*;+ /// A choice made is kept, whatever the platform's default: a phone+ /// that turned the magnet off stays off, and a desk that turned it on+ /// stays on.+ #[test]+ fn a_chosen_magnetic_timeline_outranks_the_default() {+ let mut prefs = Preferences::default();+ assert!(!prefs.magnetic_chosen);+ prefs.set_magnetic(false);+ assert!(!prefs.magnetic());+ prefs.set_magnetic(true);+ assert!(prefs.magnetic());+ // A file saved before the choice was recorded reads as unchosen.+ let old: Preferences = serde_json::from_str(r#"{"magnetic":false}"#).expect("old prefs");+ assert!(!old.magnetic_chosen);+ assert_eq!(old.magnetic(), crate::platform::phone());+ }+#[test]fn the_last_project_location_survives_loading_and_saving() {let root =diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rsindex ad0742a1..a0f38385 100644--- a/src/crates/concat/src/studio.rs+++ b/src/crates/concat/src/studio.rs@@ -7709,7 +7709,7 @@ impl Studio {&ids,at,side,- self.prefs.magnetic,+ self.closes_gap(&ids),) else {self.notify(&t("studio.parkPlayheadInsideClip"), true);return;@@ -7899,10 +7899,31 @@ impl Studio {self.remove_transition();return;}- let magnetic = self.prefs.magnetic;+ let magnetic = self.closes_gap(&self.selection);self.remove_selected(magnetic);}+ /// Whether removing these clips closes the gap they leave: always with+ /// the magnetic timeline on, and on a phone, until the person sets it,+ /// when every one of them is on the main picture's lane - CapCut's main+ /// track, where a Split and Delete is done (#497). Titles, captions and+ /// overlays keep their time there: a caption deleted must not pull the+ /// ones after it off the words they were timed to.+ fn closes_gap(&self, ids: &[String]) -> bool {+ if self.prefs.magnetic {+ return true;+ }+ if !self.prefs.magnetic() {+ return false;+ }+ let main = self.timeline().background_lane();+ !ids.is_empty()+ && ids.iter().all(|id| {+ self.clip(id)+ .is_some_and(|clip| main == Some(clip.track_id.as_str()))+ })+ }+/// Ripple delete (⇧⌫): the selection goes and each lane closes behind/// it, so a rough cut needs no dragging-left after every deletion./// https://github.com/jub0t/Concat/issues/106@@ -9348,7 +9369,7 @@ impl Studio {editor.set_frame_rate(self.frame_rate());editor.set_tool(self.lanes.tool);editor.set_snap(self.lanes.snap);- editor.set_magnetic(self.prefs.magnetic);+ editor.set_magnetic(self.prefs.magnetic());editor.set_trim_follow(self.prefs.trim_follow);editor.set_meters_shown(self.prefs.meters_shown());editor.set_preview_axis(self.prefs.preview_axis);@@ -11914,7 +11935,7 @@ impl Studio {enabled: true,danger: false,checkable: true,- checked: self.prefs.magnetic,+ checked: self.prefs.magnetic(),},],2 => vec![@@ -12325,8 +12346,15 @@ impl Studio {// A clip that is part of the selection takes the selection with// it: Delete on one of five selected clips means the five."delete" | "ripple-delete" => {- let ripple = action == "ripple-delete" || self.prefs.magnetic;- if self.selection.len() > 1 && self.selection.iter().any(|held| held == id) {+ let whole =+ self.selection.len() > 1 && self.selection.iter().any(|held| held == id);+ let ripple = action == "ripple-delete"+ || if whole {+ self.closes_gap(&self.selection)+ } else {+ self.closes_gap(&[id.to_owned()])+ };+ if whole {self.remove_selected(ripple);} else {self.apply(Command::RemoveClips {