mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-19 00:27:49 +00:00
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.
This commit is contained in:
1 parent
98c4714458
commit
79a1ea4a42
1 file changed
+11
-7
@@ -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
|
||||
|
||||
Reference in new issue
Block a user