Merge pull request #921 from pravdomil/claude/alt-click-layer-toggles-b7a7a3
Timeline: Alt-click an A/V feature switches the other layers
This commit is contained in:
@@ -1169,9 +1169,16 @@ fn layer_switch(
|
||||
id: egui::Id,
|
||||
layer: u64,
|
||||
name: &'static str,
|
||||
others: bool,
|
||||
actions: &mut Vec<(String, serde_json::Value)>,
|
||||
) {
|
||||
let resp = widgets::icon_toggle(ui, br, icon, on, t, id, Sense::click_and_drag());
|
||||
// Alt-click on an A/V feature sets the layer apart: the other layers go off (or locked),
|
||||
// and come back on the next Alt-click.
|
||||
if others && resp.is_pointer_button_down_on() && ui.input(|i| i.pointer.primary_pressed() && i.modifiers.alt) {
|
||||
actions.push(("layer.setSwitch".into(), json!({"layers": [layer], "switch": name, "others": true})));
|
||||
return;
|
||||
}
|
||||
if let Some((value, merge)) = switch_gesture(ui, &resp, row, name, on) {
|
||||
actions.push(("layer.setSwitch".into(), json!({"layers": [layer], "switch": name, "value": value, "merge": merge})));
|
||||
} else if resp.clicked() && !resp.clicked_by(egui::PointerButton::Primary) {
|
||||
@@ -1787,7 +1794,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
continue;
|
||||
}
|
||||
lp.rect_filled(br.shrink(0.5), 1.0, t.switch_well);
|
||||
layer_switch(ui, &t, r, br, icon, on, egui::Id::new(("av", layer.id.0, i)), layer.id.0, name, &mut actions);
|
||||
layer_switch(ui, &t, r, br, icon, on, egui::Id::new(("av", layer.id.0, i)), layer.id.0, name, true, &mut actions);
|
||||
app.auto.add(&format!("timeline.layer.{}.{name}", layer.id.0), br, name);
|
||||
}
|
||||
// Label swatch.
|
||||
@@ -1913,7 +1920,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
let br = Rect::from_center_size(pos2(cw.switches + SW * i as f32 + SW / 2.0, cy), vec2(16.0, 16.0));
|
||||
lp.rect_filled(br.shrink(1.0), 1.0, t.switch_well);
|
||||
layer_switch(ui, &t, r, br, icon, on, egui::Id::new(("sw", layer.id.0, i)), layer.id.0, name, &mut actions);
|
||||
layer_switch(ui, &t, r, br, icon, on, egui::Id::new(("sw", layer.id.0, i)), layer.id.0, name, false, &mut actions);
|
||||
app.auto.add(&format!("timeline.layer.{}.switch.{name}", layer.id.0), br, name);
|
||||
}
|
||||
// Modes.
|
||||
|
||||
@@ -100,6 +100,37 @@ fn dragging_over_layer_switches_sets_them_all() {
|
||||
assert_eq!(states(&h, &ids, video), [false, true, false, true], "other switches untouched");
|
||||
}
|
||||
|
||||
/// Alt-click on an A/V feature sets the layer apart (the other layers hidden / locked), and the
|
||||
/// next Alt-click brings the others back; the Switches column is not affected by Alt.
|
||||
#[test]
|
||||
fn alt_click_on_av_feature_switches_the_other_layers() {
|
||||
let (mut h, ids) = harness();
|
||||
let alt_click = |h: &mut Harness<'_, EffectcraftApp>, id: String| {
|
||||
let p = rect(h, &id).center();
|
||||
let modifiers = Modifiers::ALT;
|
||||
h.event(Event::PointerMoved(p));
|
||||
h.event(Event::ModifiersChanged(modifiers));
|
||||
h.step();
|
||||
h.event(Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed: true, modifiers });
|
||||
h.step();
|
||||
h.event(Event::PointerButton { pos: p, button: egui::PointerButton::Primary, pressed: false, modifiers });
|
||||
h.event(Event::ModifiersChanged(Modifiers::NONE));
|
||||
h.run_steps(3);
|
||||
};
|
||||
let steps = h.state().session.history.undo.len();
|
||||
alt_click(&mut h, format!("timeline.layer.{}.video", ids[1]));
|
||||
assert_eq!(states(&h, &ids, video), [false, true, false, false]);
|
||||
assert_eq!(h.state().session.history.undo.len(), steps + 1, "one undo step");
|
||||
alt_click(&mut h, format!("timeline.layer.{}.video", ids[1]));
|
||||
assert_eq!(states(&h, &ids, video), [true; 4]);
|
||||
alt_click(&mut h, format!("timeline.layer.{}.lock", ids[2]));
|
||||
assert_eq!(states(&h, &ids, |l| l.switches.locked), [true, true, false, true]);
|
||||
alt_click(&mut h, format!("timeline.layer.{}.solo", ids[0]));
|
||||
assert_eq!(states(&h, &ids, |l| l.switches.solo), [true, false, false, false]);
|
||||
alt_click(&mut h, format!("timeline.layer.{}.switch.motionBlur", ids[0]));
|
||||
assert_eq!(states(&h, &ids, motion_blur), [true, false, false, false]);
|
||||
}
|
||||
|
||||
/// #284: pressing a stopwatch and dragging over the stopwatches below gives every property the
|
||||
/// state the first one got (animated or not), in one undo step; Alt+click still adds an
|
||||
/// expression and a click toggles one property.
|
||||
|
||||
Reference in New Issue
Block a user