Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

#2328: Effect Controls draws a line between the fixed and the added effects

irgendwasmitfelixca7c56238db4
diff --git a/crates/ui-egui/src/panels/effect_controls.rs b/crates/ui-egui/src/panels/effect_controls.rs
index b829a25fc..887768294 100644
--- a/crates/ui-egui/src/panels/effect_controls.rs
+++ b/crates/ui-egui/src/panels/effect_controls.rs
@@ -197,9 +197,18 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
// Premiere lists the fixed effects (Motion, Opacity, Time Remapping / Volume…) first.
let mut order: Vec<usize> = (0..it.effects.len()).collect();
order.sort_by_key(|i| !it.effects[*i].def().is_some_and(|d| d.intrinsic));
+ let mut after_fixed = false;
for idx in order {
let e = &it.effects[idx];
let Some(def) = e.def() else { continue };
+ // the first effect added from the library after the fixed ones gets a line on top
+ // (#2328); drawn on its edge, so no row moves
+ let first_added = if def.intrinsic {
+ after_fixed = true;
+ false
+ } else {
+ std::mem::take(&mut after_fixed)
+ };
let key = format!("{}:{}", clip.0, idx);
let open = !app.ui.collapsed_fx.contains(&key);
let selected = app.session.state.selected_effect.as_ref().is_some_and(|s| s.clip == clip && s.index(&it.effects) == Some(idx));
@@ -210,6 +219,12 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
bui.painter().rect_filled(crate::panels::effect_controls::row_fill(r), 0.0, t.hover);
}
row_line(bui, r, &lane, &t);
+ if first_added {
+ let line = Rect::from_min_max(pos2(r.min.x, r.min.y - 1.0), pos2(r.max.x, r.min.y + 1.0));
+ bui.painter().rect_filled(line, 0.0, t.accent.gamma_multiply(0.8));
+ let which = if *kind == TrackKind::Video { "video" } else { "audio" };
+ app.auto.add(&format!("effectControls.addedEffects.{which}"), line, "Added effects");
+ }
// only the arrow twirls the effect open or shut; the rest of the header selects it
let tw = Rect::from_center_size(pos2(r.min.x + 10.0, r.center().y), vec2(10.0, 10.0));
icons::paint(bui.painter(), tw, if open { Icon::ChevronDown } else { Icon::ChevronRight }, t.text_dim);
diff --git a/crates/ui-egui/tests/keyframes_ui.rs b/crates/ui-egui/tests/keyframes_ui.rs
index d0549a015..a4cb06c07 100644
--- a/crates/ui-egui/tests/keyframes_ui.rs
+++ b/crates/ui-egui/tests/keyframes_ui.rs
@@ -708,3 +708,22 @@ fn mask_keyframe_menus_preserve_the_effect_and_other_masks() {
assert_eq!(effect(&d), before);
}
}
+
+/// #2328: a line separates the fixed effects (Motion, Opacity, Time Remapping) from the effects
+/// added from the library; without added effects there is none.
+#[test]
+fn a_line_separates_added_effects_from_the_fixed_ones() {
+ let (mut d, clip) = Driver::demo();
+ assert!(d.find("effectControls.addedEffects.video").is_none(), "only fixed effects: no line");
+ d.exec("effects.apply", json!({"clips": [clip.id], "effect": "gaussian_blur"}));
+ d.exec("effects.apply", json!({"clips": [clip.id], "effect": "tint"}));
+ let line = d.rect("effectControls.addedEffects.video");
+ let opacity = d.rect("effectControls.effect.opacity");
+ let blur = d.rect("effectControls.effect.gaussian_blur");
+ let tint = d.rect("effectControls.effect.tint");
+ assert!(
+ opacity[1] < line[1] && (line[1] + line[3] / 2.0 - blur[1]).abs() <= 0.5,
+ "on the edge between the fixed and the added effects: {opacity:?} {line:?} {blur:?}"
+ );
+ assert!(tint[1] > blur[1], "one line, above all the added effects");
+}