Skip to content

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

A Filters card shows its look on the monitor before it adds it

Jareer21162805e81c
diff --git a/engine/crates/concat/locales/en.json b/engine/crates/concat/locales/en.json
index 9b44a094..efe7e14e 100644
--- a/engine/crates/concat/locales/en.json
+++ b/engine/crates/concat/locales/en.json
@@ -425,6 +425,7 @@
"Shifts the picture towards daylight shade.": "Shifts the picture towards daylight shade.",
"Show in folder": "Show in folder",
"Show {0}": "Show {0}",
+ "Showing the look on the clip. Double-click the card, or its plus, to add it": "Showing the look on the clip. Double-click the card, or its plus, to add it",
"Silent": "Silent",
"Similarity": "Similarity",
"Size": "Size",
diff --git a/engine/crates/concat/src/lib.rs b/engine/crates/concat/src/lib.rs
index ea785fa2..b6c720ea 100644
--- a/engine/crates/concat/src/lib.rs
+++ b/engine/crates/concat/src/lib.rs
@@ -232,7 +232,11 @@ pub fn run() -> Result<(), slint::PlatformError> {
let mut $state = shell.studio.borrow_mut();
$body
}
- shell.studio.borrow_mut().refresh_art();
+ {
+ let mut studio = shell.studio.borrow_mut();
+ studio.settle_audition();
+ studio.refresh_art();
+ }
shell.studio.borrow().$publish(&app, &shell.models);
});
}
@@ -433,6 +437,9 @@ pub fn run() -> Result<(), slint::PlatformError> {
state.apply_catalogue(id.as_str(), true);
}
));
+ editor.on_library_audition_filter(on_window!(|state, id: SharedString| {
+ state.audition_catalogue(id.as_str());
+ }));
editor.on_library_apply_effect(on_window!(|state, id: SharedString| {
state.apply_catalogue(id.as_str(), true);
}));
diff --git a/engine/crates/concat/src/studio.rs b/engine/crates/concat/src/studio.rs
index b6bba355..117ef38c 100644
--- a/engine/crates/concat/src/studio.rs
+++ b/engine/crates/concat/src/studio.rs
@@ -693,6 +693,12 @@ pub struct Studio {
/// Where the inspector should go, and a count that changes every time
/// something is applied from the library; see `Editor.inspector-jump-token`.
pub inspector_jump: (i32, &'static str, &'static str),
+ /// A look being shown before it is added: the clip it is shown on and
+ /// the filter's id. It is drawn into the frames the monitor asks for
+ /// and nowhere else - the document does not have it until the card is
+ /// double-clicked or its plus pressed - and it is dropped when the
+ /// selection leaves the clip; see `settle_audition`.
+ audition: Option<(String, String)>,
/// The last inspector commit: what it changed and when. A control that
/// is dragged commits on every move, and each of those would be an undo
/// step of its own; a commit that changes the same thing as the last
@@ -1142,6 +1148,7 @@ impl Studio {
gesture: Gesture::None,
stage_guides: Vec::new(),
inspector_jump: (0, "", ""),
+ audition: None,
last_commit: None,
title_blocks: HashMap::new(),
drop: None,
@@ -1528,6 +1535,23 @@ impl Studio {
};
let width = ((f64::from(width) * scale).round() as u32).max(2) & !1;
let height = ((f64::from(height) * scale).round() as u32).max(2) & !1;
+ // The look being shown before it is added goes into this frame
+ // only: the clip in the document is as it was.
+ if let Some(filter_id) = self.audition_of().map(str::to_owned)
+ && let Some(clip_id) = self.sole_selection()
+ && let Some(clip) = self.clip(&clip_id)
+ && let Some(media) = self.project().media_by_id(&clip.media_id)
+ && let Some(flat) = clips.iter_mut().find(|flat| {
+ flat.path == media.path && (flat.start - clip.start).abs() < 1e-6
+ })
+ {
+ flat.effects.push(AppliedFilter {
+ id: filter_id,
+ params: std::collections::BTreeMap::new(),
+ enabled: true,
+ });
+ flat.video_filter_chain = concat_export::chains::video_effect_chain(&flat.effects);
+ }
// While the brushes are out, the clip being painted is drawn with
// its cutout tinted over the whole picture rather than cut, so a
// stroke shows what it grabbed against what it left.
@@ -2089,6 +2113,53 @@ impl Studio {
(self.selection.len() == 1).then(|| self.selection[0].clone())
}
+ /// The look being shown on the selected clip, by id, while the
+ /// selection is still the clip it was shown on.
+ pub fn audition_of(&self) -> Option<&str> {
+ let (clip_id, filter_id) = self.audition.as_ref()?;
+ (self.sole_selection().as_deref() == Some(clip_id.as_str()))
+ .then_some(filter_id.as_str())
+ }
+
+ /// Shows a look on the selected clip without adding it: what a single
+ /// click on a Filters card does. The same card clicked again takes it
+ /// off; a double-click or the card's plus adds it for real.
+ pub fn audition_catalogue(&mut self, id: &str) {
+ let Some(clip_id) = self.sole_selection() else {
+ self.notify(&t("Select a clip on the timeline first"), true);
+ return;
+ };
+ if !self.clip(&clip_id).is_some_and(|clip| clip.kind.is_visual()) {
+ self.notify(
+ &t("Select a video or image clip on the timeline first"),
+ true,
+ );
+ return;
+ }
+ let same = self
+ .audition
+ .as_ref()
+ .is_some_and(|(clip, filter)| *clip == clip_id && filter == id);
+ if !same && self.audition.is_none() {
+ self.notify(
+ &t("Showing the look on the clip. Double-click the card, or its plus, to add it"),
+ false,
+ );
+ }
+ self.audition = (!same).then(|| (clip_id, id.to_owned()));
+ self.request_preview();
+ }
+
+ /// Drops the look being shown once the selection has left its clip,
+ /// and redraws the monitor without it. Run after every handler, since
+ /// the selection moves from a dozen places.
+ pub fn settle_audition(&mut self) {
+ if self.audition.is_some() && self.audition_of().is_none() {
+ self.audition = None;
+ self.request_preview();
+ }
+ }
+
/// A catalogue filter or effect, applied to the selected clip's chain.
pub fn apply_catalogue(&mut self, id: &str, video: bool) {
let Some(clip_id) = self.sole_selection() else {
@@ -2109,6 +2180,8 @@ impl Studio {
self.notify("A still has no sound to filter", true);
return;
}
+ // Added for real now, so the showing is over.
+ self.audition = None;
let entry = AppliedFilter {
id: id.to_owned(),
params: std::collections::BTreeMap::new(),
@@ -4877,6 +4950,7 @@ impl Studio {
keys.set_available(!rows.is_empty());
keys.set_rows(slint::ModelRc::from(Rc::new(VecModel::from(rows))));
editor.set_inspector_jump_token(self.inspector_jump.0);
+ editor.set_library_audition(self.audition_of().unwrap_or("").into());
editor.set_inspector_jump_tab(self.inspector_jump.1.into());
editor.set_inspector_jump_section(self.inspector_jump.2.into());
let active = project
diff --git a/engine/crates/concat/ui/editor.slint b/engine/crates/concat/ui/editor.slint
index a130d1cc..a120d9f0 100644
--- a/engine/crates/concat/ui/editor.slint
+++ b/engine/crates/concat/ui/editor.slint
@@ -94,6 +94,13 @@ export global Editor {
callback library-apply-effect(effect-id: string);
callback library-apply-transition(transition-id: string);
callback library-apply-filter(filter-id: string, label: string);
+ /// Filters page: show the look on the selected clip without adding it,
+ /// which is what a single click on a card does. The same id again takes
+ /// it off.
+ callback library-audition-filter(filter-id: string);
+ /// The look being shown that way, by id, or empty: its card draws
+ /// itself picked while it is.
+ in-out property <string> library-audition;
callback library-apply-audio(effect-id: string);
callback library-save-template();
diff --git a/engine/crates/concat/ui/workspace/media-pane.slint b/engine/crates/concat/ui/workspace/media-pane.slint
index 1ad6fc3e..d4f33cba 100644
--- a/engine/crates/concat/ui/workspace/media-pane.slint
+++ b/engine/crates/concat/ui/workspace/media-pane.slint
@@ -735,6 +735,11 @@ struct CatalogueItemData {
// a plus on hover when it works, a "Soon" badge when it does not.
component CatalogueCard inherits Rectangle {
in property <CatalogueItemData> item;
+ /// A card that shows before it adds: a click is `auditioned`, and only
+ /// a double-click or the plus is `applied`. Otherwise a click applies.
+ in property <bool> auditions;
+ /// This card's look is the one being shown; it draws itself picked.
+ in property <bool> auditioning;
/// What this card leaves on the timeline when it is dragged there, or
/// empty for a page whose entries are applied to the selection rather than
/// placed — a DragArea with no data never starts a drag, so one property
@@ -742,6 +747,7 @@ component CatalogueCard inherits Rectangle {
in property <string> payload;
callback applied();
+ callback auditioned();
/// An entry with no artwork is a compact card: the name sits inside the
/// tile, there is no mark and no caption, and the tile is half as tall.
@@ -764,7 +770,15 @@ component CatalogueCard inherits Rectangle {
card := TouchArea {
enabled: root.item.enabled;
mouse-cursor: root.item.enabled ? pointer : default;
- clicked => { root.applied(); }
+ // On a showing card the second click of a double-click lands
+ // here first and takes the showing off; the add that follows
+ // is what the gesture meant, and Rust drops the showing anyway.
+ clicked => {
+ if (root.auditions) { root.auditioned(); } else { root.applied(); }
+ }
+ double-clicked => {
+ if (root.auditions) { root.applied(); }
+ }
tile := Rectangle {
y: 0;
@@ -772,8 +786,9 @@ component CatalogueCard inherits Rectangle {
border-radius: Theme.r;
background: root.compact && card.has-hover && root.item.enabled
? Theme.field : Theme.well;
- border-width: 1px;
- border-color: (card.has-hover && root.item.enabled)
+ border-width: root.auditioning ? 2px : 1px;
+ border-color: root.auditioning ? Theme.accent
+ : (card.has-hover && root.item.enabled)
? Theme.line-strong : Theme.line;
clip: true;
@@ -825,20 +840,31 @@ component CatalogueCard inherits Rectangle {
}
}
- if root.item.enabled && card.has-hover: Rectangle {
+ // The plus is its own touch area, so that on a showing
+ // card it adds where the tile around it only shows. Always
+ // there and shown on hover, rather than made on hover: it
+ // has to keep itself on screen while the pointer is over
+ // it, whether or not the tile still counts that as hovered.
+ Rectangle {
x: parent.width - self.width - 4px;
y: parent.height - self.height - 4px;
width: 20px;
height: 20px;
border-radius: Theme.r-xs;
- background: Theme.scrim;
+ background: plus.has-hover ? Theme.accent : Theme.scrim;
+ visible: root.item.enabled && (card.has-hover || plus.has-hover);
+
+ plus := TouchArea {
+ mouse-cursor: pointer;
+ clicked => { root.applied(); }
+ }
Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: Glyph.plus;
size: 11px;
- tint: Theme.on-scrim;
+ tint: plus.has-hover ? Theme.on-accent : Theme.on-scrim;
}
}
}
@@ -1085,6 +1111,10 @@ component ShelfGrid inherits Rectangle {
pure callback art(id: string) -> image;
callback applied(id: string, label: string);
+ /// See CatalogueCard: a shelf whose cards show before they add.
+ in property <bool> auditions;
+ in property <string> auditioning;
+ callback auditioned(id: string);
property <length> gap: 8px;
property <length> min-card: 88px;
@@ -1114,7 +1144,10 @@ component ShelfGrid inherits Rectangle {
compact: root.compact;
payload: root.payload-kind == "" ? ""
: "\{root.payload-kind}:\{entry.id}:\{entry.name}";
+ auditions: root.auditions;
+ auditioning: root.auditions && root.auditioning == entry.id;
+ auditioned => { root.auditioned(entry.id); }
applied => { root.applied(entry.id, entry.name); }
}
}
@@ -1238,6 +1271,10 @@ export component MediaPane inherits Rectangle {
callback apply-effect(effect-id: string);
callback apply-transition(transition-id: string);
callback apply-filter(filter-id: string, label: string);
+ /// Filters page: a single click shows the look on the selected clip
+ /// without adding it; `audition` is the id being shown, or empty.
+ callback audition-filter(filter-id: string);
+ in property <string> audition;
/// Audio page: add a voice or room to the selected clip's sound.
callback apply-audio(effect-id: string);
/// Templates page: open the save-as-template flow for this project.
@@ -1801,8 +1838,9 @@ export component MediaPane inherits Rectangle {
// A filter is meant to be a layer over a span of the
// timeline, dragged onto the lanes like a piece of media;
// the payload says so, for the day the lanes accept it.
- // Until then a click applies the look to the selected
- // clip, which is the other way every editor offers.
+ // Until then the cards work on the selected clip: a
+ // click shows the look on the monitor, and a double-click
+ // or the card's plus adds it.
ShelfSearch {
shelf: 0;
placeholder: I18n.t1("Search {0}s", I18n.t("filter"));
@@ -1810,7 +1848,10 @@ export component MediaPane inherits Rectangle {
ShelfGrid {
entries: root.catalogue-filters;
payload-kind: "filter";
+ auditions: true;
+ auditioning: root.audition;
art(id) => { return root.art-of(id); }
+ auditioned(id) => { root.audition-filter(id); }
applied(id, label) => { root.apply-filter(id, label); }
}
}
diff --git a/engine/crates/concat/ui/workspace/seat.slint b/engine/crates/concat/ui/workspace/seat.slint
index d09b38ea..a85d995e 100644
--- a/engine/crates/concat/ui/workspace/seat.slint
+++ b/engine/crates/concat/ui/workspace/seat.slint
@@ -126,6 +126,8 @@ export component Seat inherits Rectangle {
apply-effect(id) => { Editor.library-apply-effect(id); }
apply-transition(id) => { Editor.library-apply-transition(id); }
apply-filter(id, label) => { Editor.library-apply-filter(id, label); }
+ audition: Editor.library-audition;
+ audition-filter(id) => { Editor.library-audition-filter(id); }
apply-audio(id) => { Editor.library-apply-audio(id); }
save-template => { Editor.library-save-template(); }
}