Skip to content

feat: add global Ctrl+drag zoom and resolve Hand Tool pan conflict - #1332

Open
Bugutan wants to merge 13 commits into
LinwoodDev:developfrom
Bugutan:develop
Open

Bugutan wants to merge 13 commits into
LinwoodDev:developfrom
Bugutan:develop

Conversation

@Bugutan

@Bugutan Bugutan commented Oct 29, 2026

Copy link
Copy Markdown

Description

This PR introduces a global Ctrl + Drag zoom functionality that works consistently across all tools. It also resolves a UX issue where the Hand Tool would attempt to pan the canvas simultaneously while zooming.

How to Test

  1. Select any drawing tool (e.g., Pen, Eraser).
  2. Hold Ctrl and drag the mouse/stylus. Verify that the canvas zooms smoothly without leaving ink or erasing.
  3. Switch to the Hand Tool.
  4. Hold Ctrl and drag. Verify that the canvas only zooms and does not pan or jitter.
Screencast_20261029_162008.mp4

@Bugutan

Bugutan commented Oct 29, 2026

Copy link
Copy Markdown
Author

Yesterday I submitted an issue for this feature, and today I decided to take a shot at implementing it myself. Since this is my first pull request, any feedback or suggestions would be greatly appreciated

@CodeDoctorDE

Copy link
Copy Markdown
Member

I tested the pr on my pc and I really like it.
Some things I found: When using the shape tool you still draw, this needs to be cancelled

@Bugutan

Bugutan commented Oct 31, 2026

Copy link
Copy Markdown
Author

Thanks! I overlooked that, will fix it soon.

@Bugutan

Bugutan commented Oct 31, 2026

Copy link
Copy Markdown
Author

Fixed: tools no longer draw while zooming with Ctrl + drag. A configurable keybind could be added later.

@CodeDoctorDE

Copy link
Copy Markdown
Member

Hi, will try it tomorrow again but i think there needs to be a _delayBakeUnlessSmooth after zooming + i think multiple inputs can break the implementation?

  • i remembered there are tools like the pen tool that uses isCtrlPressed?

@CodeDoctorDE

Copy link
Copy Markdown
Member

Hmm, im not the fan adding explicit handler checks in input manager. Maybe we can find a better solution? What do you think?
This functionality should be available everywhere

@CodeDoctorDE

Copy link
Copy Markdown
Member

I'm thinking if we could maybe change the current ctrl to shift or alt/something similiar for the tools to keep ctrl for the zoom?

@Bugutan

Bugutan commented Nov 3, 2026 •

Copy link
Copy Markdown
Author

Maybe instead we can change the zooming to only work with middle click plus ctrl
But I dont know how it would effect stylus input

@Bugutan

Bugutan commented Nov 3, 2026 •

Copy link
Copy Markdown
Author

I tried Ctrl + middle click and it feels better for the mouse.

For the stylus, I think zoom only makes sense on the barrel button that is mapped to the hand tool (for me the secondary button). Then moving is just that button, and zooming is that button + Ctrl.

The downside is that this button is reserved for moving and zooming, so it can't be used for something else. I think that is okay, Krita does something similar. What do you think?

Edit: just commited so feel free to try when you have time

@CodeDoctorDE

Copy link
Copy Markdown
Member

Hmm is this really better than just using shift or alt inside pen/other tools. since many mouses aren't nice using with middle click and secondary stylus buttons can be customized

@Bugutan

Bugutan commented Nov 5, 2026

Copy link
Copy Markdown
Author

You are right it is hard with middle click

I think Alt+click would be so much more suitable
Maybe Alt + Drag would be for moving around
And Alt + Ctrl + Drag would be for zooming

So the tools can use Ctrl freely
What do you think?

@CodeDoctorDE

Copy link
Copy Markdown
Member

But then we have conflicts with alt. I would just change to tools to not use ctrl

@Bugutan

Bugutan commented Nov 5, 2026

Copy link
Copy Markdown
Author

I heard Photoshop and similar apps use Space to pan around, and Space + another key to zoom. Would that make sense

It would separate navigation. But I'm not sure if it conflicts with anything

@CodeDoctorDE

Copy link
Copy Markdown
Member

We have shift and space for rotation

@Bugutan

Bugutan commented Nov 5, 2026

Copy link
Copy Markdown
Author

It might be nice rotation, panning and zooming all uses space in some sort

@Bugutan

Bugutan commented Nov 5, 2026

Copy link
Copy Markdown
Author

Zoom with Ctrl + Space + drag. For panning with Space + drag, I added it myself in the app settings (Inputs -> Hold shortcuts, Space -> hand tool), but I couldn't make it a default in settings.dart like static const InputMapping middleMouse = .new(InputMapping.handToolValue);
Should Space -> hand tool be a default?
Thanks.

@CodeDoctorDE

Copy link
Copy Markdown
Member

I tested the latest version with Ctrl + Space + drag and found two remaining issues:

  • Short stylus drags still trigger onTapUp, and pausing before dragging triggers onLongPressEnd. This can activate the current tool while zooming. Tap and long-press callbacks should also be suppressed for zoom interactions.
  • _isUiZoomInput excludes PointerDeviceKind.invertedStylus, so using the eraser end of a stylus activates its assigned tool instead of zooming.

Can you look at it?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants