Viewer: Pan Behind snaps the anchor to its own layer (#147)
The Pan Behind drag passed its layer to the snapper's exclude list, which dropped all of that layer's targets: its corners, edge midpoints and centre as well as the anchor being dragged. The layer's box doesn't move in comp space while the anchor pans (Position compensates), so those points are valid targets. The engine's per-layer snap targets are now one function, layer_targets, which can leave out the anchor point. The gesture records its layer's targets without the anchor as the drag begins and passes them to the snapper (snap_with) as extra targets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
21641d5dee
commit
83f17dda37
@@ -45,6 +45,20 @@ pub(crate) fn snap(
|
||||
exclude: &[LayerId],
|
||||
sources: &[[f64; 2]],
|
||||
mods: egui::Modifiers,
|
||||
) -> [f64; 2] {
|
||||
snap_with(app, ctx, ectx, map, exclude, sources, mods, &[])
|
||||
}
|
||||
|
||||
/// [`snap`] with `extra` layer targets (the Pan Behind layer's own box).
|
||||
pub(crate) fn snap_with(
|
||||
app: &EffectcraftApp,
|
||||
ctx: &egui::Context,
|
||||
ectx: &EvalCtx,
|
||||
map: &ViewerMap,
|
||||
exclude: &[LayerId],
|
||||
sources: &[[f64; 2]],
|
||||
mods: egui::Modifiers,
|
||||
extra: &[vw::SnapTarget],
|
||||
) -> [f64; 2] {
|
||||
let layers = snapping_on(app, mods);
|
||||
let v = &app.ui.viewer;
|
||||
@@ -55,6 +69,7 @@ pub(crate) fn snap(
|
||||
}
|
||||
let opts = vw::SnapOptions { guides, grid, grid_spacing: app.session.prefs.grids.grid_spacing };
|
||||
let mut targets = vw::targets(ectx, exclude, opts);
|
||||
targets.extend_from_slice(extra);
|
||||
if !layers {
|
||||
targets.retain(|t| matches!(t.source, SnapSource::Guide | SnapSource::Grid));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user