-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add touchpad pinch zooming support (2.1) #9117
Conversation
Designed for touchpad users, make it possible to pinch zoom 2D canvas item editor. A new button index constant is added to input event: GESTURE_MAGNIFY.
You introduced a nice pattern with using a negative value of the factor to use one case: GESTURE_MAGNIFY for magnifying in + magnifying out. BUTTON_MOUSE_WHEEL_HORIZONTAL
BUTTON_MOUSE_WHEEL_VERTICAL Thoughts? |
@@ -1035,6 +1035,29 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) { | |||
|
|||
const InputEventMouseButton &b = p_event.mouse_button; | |||
|
|||
if (b.button_index == GESTURE_MAGNIFY) { | |||
|
|||
if (zoom < MIN_ZOOM) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code form here on is really similar than:
b.button_index == BUTTON_WHEEL_DOWN
b.button_index == BUTTON_WHEEL_UP
would it be worth it to make a zoom inline function?
we could remove redundant code. and it would be easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep it's totally worth to make a zoom function and replace all the duplicated lines. And your idea about the button wheel events are great, which is also worth implement :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be documented really well though. It's not obvious that you have to use the factor property to find out if the user scrolls up or down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about renaming factor to: direction_value
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will try to add gesture and wheel events again, hope to get it done this time. And direction_value
is a good name.
Same for the PR on master #9115 |
I would still see implementations of the same feature for other platforms before I can think of merging this one - having such a feature only supported in one OS would not be very useful. |
Designed for touchpad users, make it possible to pinch zoom 2D canvas item editor.
A new button index constant is added to input event: GESTURE_MAGNIFY.