Skip to content

Add pinch-to-zoom, improve zooming on trackpads and smooth scroll wheels#799

Merged
cameronwhite merged 7 commits into
PintaProject:masterfrom
PurelyAndy:master
May 16, 2024
Merged

Add pinch-to-zoom, improve zooming on trackpads and smooth scroll wheels#799
cameronwhite merged 7 commits into
PintaProject:masterfrom
PurelyAndy:master

Conversation

@PurelyAndy

Copy link
Copy Markdown
Contributor

Fixes #634 and #715

@cameronwhite cameronwhite left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!
This works very well in my testing on a Macbook - I just left a few questions and style comments.

Comment thread Pinta.Gui.Widgets/Widgets/Canvas/CanvasWindow.cs Outdated
Comment thread Pinta.Gui.Widgets/Widgets/Canvas/CanvasWindow.cs Outdated
Comment thread Pinta.Gui.Widgets/Widgets/Canvas/CanvasWindow.cs
Comment thread Pinta.Gui.Widgets/Widgets/Canvas/CanvasWindow.cs Outdated
Comment thread Pinta.Gui.Widgets/Widgets/Canvas/CanvasWindow.cs Outdated
var scroll_controller = Gtk.EventControllerScroll.New (EventControllerScrollFlags.Vertical);
var scroll_controller = Gtk.EventControllerScroll.New (EventControllerScrollFlags.BothAxes);
scroll_controller.OnScroll += HandleScrollEvent;
scroll_controller.OnDecelerate += (_, _) => gesture_zoom.IsActive ();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some Dereference of a possibly null reference warnings here, maybe because gesture_zoom is initialized below?
I'm not quite clear what this event handler is doing, along with the BothAxes flag added above? Otherwise I think all the changes are looking good now 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning's fixed. BothAxes makes sure that both horizontal and vertical scrolling will be cancelled while the user is using the zoom gesture (the first check under HandleScrollEvent). The OnDecelerate handler returns true when the zoom gesture is being used to cancel the scroll deceleration as well. Together, they stop janky behavior where scrolling and zooming are detected at the same time.

@cameronwhite

Copy link
Copy Markdown
Member

Looks good, thanks!

@cameronwhite cameronwhite merged commit 60cabb8 into PintaProject:master May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Touchpad gestures / Pinch to zoom

2 participants