From 79a1ea4a4293edbdc08750de812fff7852904106 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Thu, 19 Nov 2026 02:36:08 +0700 Subject: [PATCH] M8: keep the canvas input under the complexity limit with edge panning (#2104) The pan past the canvas edge moves into a helper of its own. --- crates/ui-egui/src/canvas/input.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/canvas/input.rs b/crates/ui-egui/src/canvas/input.rs index 1360697d8..6ecdb948c 100644 --- a/crates/ui-egui/src/canvas/input.rs +++ b/crates/ui-egui/src/canvas/input.rs @@ -226,13 +226,7 @@ pub(super) fn input(app: &mut FigApp, ui: &mut Ui, resp: &egui::Response) -> boo send(app, PointerKind::Up, at, &mods); } } - // A drag held past the edge pans toward it, the layer or box going with the pointer. - if super::autopan::wanted(app, &ctx) - && let Some(at) = ctx.input(|i| i.pointer.latest_pos()) - && super::autopan::pan(app, &ctx, at) - { - send(app, PointerKind::Move, at, &mods); - } + pan_past_edge(app, &ctx, &mods); // Leaving the canvas: nothing is hovered there any more. if !app.canvas.dragging && std::mem::take(&mut app.canvas.hovering) { left(app); @@ -410,6 +404,16 @@ pub(super) fn input(app: &mut FigApp, ui: &mut Ui, resp: &egui::Response) -> boo } /// Pointer event `kind` at screen point `pos`, to the tools. +/// A drag held past the edge pans toward it, the layer or box going with the pointer. +fn pan_past_edge(app: &mut FigApp, ctx: &egui::Context, mods: &egui::Modifiers) { + if super::autopan::wanted(app, ctx) + && let Some(at) = ctx.input(|i| i.pointer.latest_pos()) + && super::autopan::pan(app, ctx, at) + { + send(app, PointerKind::Move, at, mods); + } +} + fn send(app: &mut FigApp, kind: PointerKind, pos: Pos2, m: &egui::Modifiers) { let ev = pointer_event(app, kind, pos, m); // A hover where nothing changed since the last one finds what that one found (the state is