|
|
|
@@ -17,6 +17,7 @@ use serde_json::json;
|
|
|
|
|
use crate::i18n::tr;
|
|
|
|
|
use crate::icons::{self, Icon};
|
|
|
|
|
use crate::theme::Tokens;
|
|
|
|
|
use crate::dock::PanelKind;
|
|
|
|
|
use crate::{EffectcraftApp, widgets};
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
@@ -1237,6 +1238,7 @@ struct KeyDrag {
|
|
|
|
|
anchor: f64,
|
|
|
|
|
applied: i64,
|
|
|
|
|
quick: Option<usize>,
|
|
|
|
|
button: egui::PointerButton,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn key_drag_id() -> egui::Id {
|
|
|
|
@@ -1251,6 +1253,7 @@ struct QuickBar {
|
|
|
|
|
origin_x: f32,
|
|
|
|
|
layers: usize,
|
|
|
|
|
applied: i64,
|
|
|
|
|
button: egui::PointerButton,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn quick_bar_id() -> egui::Id {
|
|
|
|
@@ -1896,6 +1899,38 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
|
|
|
app.ui.timeline.scroll_y = rows.iter().take(i).map(|r| row_height(r, rh)).sum();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Middle-click drag scrolling for testing
|
|
|
|
|
let middle_pressed = ctx.input(|i| {
|
|
|
|
|
i.events.iter().any(|e| matches!(e, egui::Event::PointerButton { button: egui::PointerButton::Middle, pressed: true, .. }))
|
|
|
|
|
});
|
|
|
|
|
let middle_released = ctx.input(|i| {
|
|
|
|
|
i.events.iter().any(|e| matches!(e, egui::Event::PointerButton { button: egui::PointerButton::Middle, pressed: false, .. }))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if middle_pressed && app.ui.timeline.middle_drag_panel.is_none() && ui.rect_contains_pointer(rows_rect) {
|
|
|
|
|
// Start middle-click drag
|
|
|
|
|
app.ui.timeline.middle_drag_panel = Some(PanelKind::Timeline);
|
|
|
|
|
app.ui.timeline.middle_drag_start_scroll_y = app.ui.timeline.scroll_y;
|
|
|
|
|
app.ui.timeline.middle_drag_start_pos = ui.input(|i| i.pointer.latest_pos());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// End middle-click drag on release
|
|
|
|
|
if middle_released && app.ui.timeline.middle_drag_panel == Some(PanelKind::Timeline) {
|
|
|
|
|
app.ui.timeline.middle_drag_panel = None;
|
|
|
|
|
app.ui.timeline.middle_drag_start_pos = None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if app.ui.timeline.middle_drag_panel == Some(PanelKind::Timeline) {
|
|
|
|
|
// Handle middle-click drag scrolling
|
|
|
|
|
if let Some(start_pos) = app.ui.timeline.middle_drag_start_pos {
|
|
|
|
|
if let Some(current_pos) = ui.input(|i| i.pointer.latest_pos()) {
|
|
|
|
|
let delta = (start_pos.y - current_pos.y) as f64;
|
|
|
|
|
app.ui.timeline.scroll_y = (app.ui.timeline.middle_drag_start_scroll_y + delta as f32).clamp(0.0, max_scroll);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ui.rect_contains_pointer(rows_rect) {
|
|
|
|
|
let (dy, dx, zoom) = ui.input(|i| (i.smooth_scroll_delta.y, i.smooth_scroll_delta.x, i.modifiers.alt));
|
|
|
|
|
// Ctrl/Cmd+wheel and a trackpad pinch reach egui as a zoom factor rather than a scroll
|
|
|
|
@@ -1932,7 +1967,24 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
|
|
|
ctx.request_repaint();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// End middle-click drag on release
|
|
|
|
|
if middle_released && app.ui.timeline.middle_drag_panel == Some(PanelKind::Timeline) {
|
|
|
|
|
app.ui.timeline.middle_drag_panel = None;
|
|
|
|
|
app.ui.timeline.middle_drag_start_pos = None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.ui.timeline.scroll_y = app.ui.timeline.scroll_y.clamp(0.0, max_scroll);
|
|
|
|
|
// Force pointer state reset after MMB scroll - clear any stuck pointer state
|
|
|
|
|
if middle_released {
|
|
|
|
|
ctx.memory_mut(|m| {
|
|
|
|
|
// Clear pointer state to allow normal interactions
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// Force egui to reprocess pointer state after MMB scroll
|
|
|
|
|
if middle_released {
|
|
|
|
|
ctx.request_repaint();
|
|
|
|
|
}
|
|
|
|
|
let snap_project = app.session.project.clone();
|
|
|
|
|
let snap_expr = app.session.expr.clone();
|
|
|
|
|
let ectx = EvalCtx { project: &snap_project, comp_id: cid, comp: &comp, time, expr: snap_expr.as_deref(), footage: None };
|
|
|
|
@@ -2036,9 +2088,36 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
|
|
|
);
|
|
|
|
|
// Twirl + icon + name.
|
|
|
|
|
let tw = Rect::from_center_size(pos2(cw.name + 8.0, cy), vec2(14.0, 14.0));
|
|
|
|
|
let open = app.ui.timeline.open_layers.contains(&layer.id.0);
|
|
|
|
|
if widgets::twirl(ui, tw, open, egui::Id::new(("twirl", layer.id.0)), &t).clicked() {
|
|
|
|
|
ui_actions.push(UiAct::ToggleLayer(layer.id.0, ui.input(|i| i.modifiers.alt || i.modifiers.command)));
|
|
|
|
|
let is_open = app.ui.timeline.open_layers.contains(&layer.id.0);
|
|
|
|
|
if widgets::twirl(ui, tw, is_open, egui::Id::new(("twirl", layer.id.0)), &t).clicked() {
|
|
|
|
|
let alt_command = ui.input(|i| i.modifiers.alt || i.modifiers.command);
|
|
|
|
|
let shift = ui.input(|i| i.modifiers.shift);
|
|
|
|
|
|
|
|
|
|
// If layer is not selected, determine what selection should be
|
|
|
|
|
let mut layers_to_select: Vec<u64> = vec![];
|
|
|
|
|
|
|
|
|
|
if !selected.contains(&layer.id) {
|
|
|
|
|
if shift {
|
|
|
|
|
// SHIFT + click: keep existing selection and add this layer
|
|
|
|
|
layers_to_select = selected.iter().map(|id| id.0).collect();
|
|
|
|
|
layers_to_select.push(layer.id.0);
|
|
|
|
|
} else {
|
|
|
|
|
// Normal click: replace selection with just this layer
|
|
|
|
|
layers_to_select = vec![layer.id.0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send selection action FIRST
|
|
|
|
|
actions.push(("layer.select".into(), json!({"layers": layers_to_select, "add": shift})));
|
|
|
|
|
} else {
|
|
|
|
|
// Layer is already selected, use it as the target for toggles
|
|
|
|
|
layers_to_select = selected.iter().map(|id| id.0).collect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Now toggle properties for the NEW selection (layers_to_select)
|
|
|
|
|
let target_state = !is_open;
|
|
|
|
|
for layer_id in &layers_to_select {
|
|
|
|
|
ui_actions.push(UiAct::ToggleLayer(*layer_id, alt_command, target_state));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
app.auto.add(&format!("timeline.layer.{}.twirl", layer.id.0), tw, "twirl");
|
|
|
|
|
icons::paint(&lp, Rect::from_center_size(pos2(cw.name + 24.0, cy), vec2(13.0, 13.0)), layer_icon(layer, &app.session.project), t.text_dim);
|
|
|
|
@@ -2078,7 +2157,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
|
|
|
}
|
|
|
|
|
// Locked layers can't be selected or moved (unlock them with the lock switch).
|
|
|
|
|
let locked = layer.switches.locked;
|
|
|
|
|
if row_resp.drag_started() && !locked {
|
|
|
|
|
// Layer reordering only with primary button (not middle/right)
|
|
|
|
|
if row_resp.drag_started() && !locked && row_resp.dragged_by(egui::PointerButton::Primary) {
|
|
|
|
|
// The selected layers move together; an unselected row moves alone.
|
|
|
|
|
let moving: Vec<u64> =
|
|
|
|
|
if is_sel { comp.layers.iter().filter(|l| selected.contains(&l.id)).map(|l| l.id.0).collect() } else { vec![layer.id.0] };
|
|
|
|
@@ -2326,24 +2406,46 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
|
|
|
}
|
|
|
|
|
layer_context_menu(&body, &comp, layer, &selected, LayerMenuCaps::of(&app.session.project, layer), &mut actions);
|
|
|
|
|
let drag_key = format!("bar-{}", layer.id.0);
|
|
|
|
|
// Ctrl/Cmd+Alt dragging a selected bar: Quick Offset (#1012), chosen as the
|
|
|
|
|
// drag starts and followed below the rows until the button is released.
|
|
|
|
|
// Normal dragging (not Quick Offset) - only primary button
|
|
|
|
|
if body.drag_started() && !is_sel && ui.input(|i| i.pointer.primary_pressed()) {
|
|
|
|
|
// The selected layers move together; an unselected row moves alone.
|
|
|
|
|
let moving: Vec<u64> = vec![layer.id.0];
|
|
|
|
|
ctx.data_mut(|d| d.insert_temp(layer_drag_id(), moving));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ctrl/Cmd+Alt dragging a selected bar: Quick Offset (#1012)
|
|
|
|
|
let mods = ui.input(|i| i.modifiers);
|
|
|
|
|
if body.drag_started()
|
|
|
|
|
&& is_sel
|
|
|
|
|
&& mods.command
|
|
|
|
|
&& mods.alt
|
|
|
|
|
&& ui.input(|i| i.pointer.primary_pressed())
|
|
|
|
|
&& let Some(n) = quick_offset_layers(&comp, selected.iter().copied())
|
|
|
|
|
&& let Some(p) = ctx.input(|i| i.pointer.press_origin())
|
|
|
|
|
{
|
|
|
|
|
ctx.data_mut(|d| d.insert_temp(quick_bar_id(), QuickBar { layer: layer.id, origin_x: p.x, layers: n, applied: 0 }));
|
|
|
|
|
ctx.data_mut(|d| d.insert_temp(quick_bar_id(), QuickBar { layer: layer.id, origin_x: p.x, layers: n, applied: 0, button: egui::PointerButton::Primary }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let quick = ctx.data(|d| d.get_temp::<QuickBar>(quick_bar_id())).is_some_and(|q| q.layer == layer.id);
|
|
|
|
|
for (resp, kind) in [(&body, "move"), (&lin, "in"), (&lout, "out")] {
|
|
|
|
|
if kind == "move" && quick {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// Layer bar dragging only with primary button
|
|
|
|
|
if resp.dragged() {
|
|
|
|
|
let button = if let Some(q) = ctx.data(|d| d.get_temp::<QuickBar>(quick_bar_id())) {
|
|
|
|
|
q.button
|
|
|
|
|
} else {
|
|
|
|
|
// Normal drag without Quick Offset - check current button
|
|
|
|
|
if ui.input(|i| i.pointer.primary_pressed()) {
|
|
|
|
|
egui::PointerButton::Primary
|
|
|
|
|
} else {
|
|
|
|
|
egui::PointerButton::Secondary
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if button != egui::PointerButton::Primary {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
let acc_id = egui::Id::new(("bar-acc", layer.id.0, kind));
|
|
|
|
|
let mut acc: f32 = ctx.data(|d| d.get_temp(acc_id).unwrap_or(0.0));
|
|
|
|
|
acc += resp.drag_delta().x;
|
|
|
|
@@ -2922,6 +3024,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
|
|
|
if kresp.drag_started()
|
|
|
|
|
&& mods.alt
|
|
|
|
|
&& !mods.command
|
|
|
|
|
&& ui.input(|i| i.pointer.button_pressed(egui::PointerButton::Primary))
|
|
|
|
|
&& !ui.input(|i| i.pointer.button_pressed(egui::PointerButton::Middle))
|
|
|
|
|
&& let Some(c) = app.session.active_comp_arc()
|
|
|
|
|
{
|
|
|
|
|
super::graph_tools::alt_scale_begin(app, &ctx, &c, ct.seconds());
|
|
|
|
@@ -2932,11 +3036,13 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
|
|
|
// (From where the button went down: a drag starts a few pixels later.)
|
|
|
|
|
if kresp.drag_started()
|
|
|
|
|
&& !super::graph_tools::alt_scale_active(&ctx)
|
|
|
|
|
&& ui.input(|i| i.pointer.primary_pressed())
|
|
|
|
|
&& !ui.input(|i| i.pointer.button_pressed(egui::PointerButton::Middle))
|
|
|
|
|
&& let Some(p) = ctx.input(|i| i.pointer.press_origin())
|
|
|
|
|
{
|
|
|
|
|
// Ctrl/Cmd+Alt: Quick Offset of the selected keys' layers (#1012).
|
|
|
|
|
let quick = (mods.command && mods.alt && ks).then(|| quick_offset_layers(&comp, sel_keys.iter().map(|k| k.layer))).flatten();
|
|
|
|
|
ctx.data_mut(|d| d.insert_temp(key_drag_id(), KeyDrag { origin_x: p.x, anchor: ct.seconds(), applied: 0, quick }));
|
|
|
|
|
ctx.data_mut(|d| d.insert_temp(key_drag_id(), KeyDrag { origin_x: p.x, anchor: ct.seconds(), applied: 0, quick, button: egui::PointerButton::Primary }));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -3088,6 +3194,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
|
|
|
ctx.data_mut(|d| d.insert_temp(egui::Id::new("tl-box"), br));
|
|
|
|
|
}
|
|
|
|
|
// Layer reorder drag: a line where the layers will land; the release moves them there.
|
|
|
|
|
// Layer reorder drag: a line where the layers will land; the release moves them there.
|
|
|
|
|
if let Some(moving) = ctx.data(|d| d.get_temp::<Vec<u64>>(layer_drag_id())) {
|
|
|
|
|
let dropped = ctx.data_mut(|d| d.remove_temp::<bool>(layer_drop_id())).unwrap_or(false);
|
|
|
|
|
let layer_rows: Vec<(Rect, LayerId)> = hit_rows.iter().filter(|(_, r)| matches!(r.kind, RowKind::Layer)).map(|(rr, r)| (*rr, r.layer)).collect();
|
|
|
|
@@ -3381,13 +3488,13 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
|
|
|
|
// Apply.
|
|
|
|
|
for a in ui_actions {
|
|
|
|
|
match a {
|
|
|
|
|
UiAct::ToggleLayer(id, all) => {
|
|
|
|
|
UiAct::ToggleLayer(id, all, force_state) => {
|
|
|
|
|
let tl = &mut app.ui.timeline;
|
|
|
|
|
// Twirled by hand, the layer shows its whole tree again.
|
|
|
|
|
tl.reveal.clear();
|
|
|
|
|
tl.layer_reveal.remove(&id);
|
|
|
|
|
tl.full_groups.remove(&id);
|
|
|
|
|
let open = !tl.open_layers.contains(&id);
|
|
|
|
|
let open = force_state;
|
|
|
|
|
if open {
|
|
|
|
|
tl.open_layers.insert(id);
|
|
|
|
|
} else {
|
|
|
|
@@ -3541,7 +3648,7 @@ fn layer_cells(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum UiAct {
|
|
|
|
|
ToggleLayer(u64, bool),
|
|
|
|
|
ToggleLayer(u64, bool, bool),
|
|
|
|
|
/// Layer, group uid, and whether the whole tree under the group follows.
|
|
|
|
|
ToggleGroup(u64, u64, bool),
|
|
|
|
|
SetTime(Tick),
|
|
|
|
|