wxMSW: first angle is huge in wxEVT_GESTURE_ROTATE handler. (Issue #24596)

11 views
Skip to first unread message

dsa-t

unread,
Jun 8, 2024, 2:05:41 PM6/8/24
to wx-...@googlegroups.com, Subscribed

Description

The first (starting) rotation angle sent to wxEVT_GESTURE_ROTATE event handler is too big on wxMSW:

Rotate gesture started
Rotate gesture performed with rotation center at (893, 742) and cumulative rotation angle = 42623.000000
Rotate gesture performed with rotation center at (894, 742) and cumulative rotation angle = 6.220387
Rotate gesture performed with rotation center at (895, 741) and cumulative rotation angle = 6.218470
Rotate gesture performed with rotation center at (896, 741) and cumulative rotation angle = 6.216552
Rotate gesture performed with rotation center at (819, 529) and cumulative rotation angle = 6.170915

It is missing the GID_ROTATE_ANGLE_FROM_ARGUMENT conversion here:

https://github.com/wxWidgets/wxWidgets/blob/79ddb0d67ce6fd6a28f0ee9a8050182f5fdb6288/src/msw/window.cpp#L6236

Everything works as expected with the following change (the first angle specifies the absolute angle relative to the rotation center):

diff --git a/src/msw/window.cpp b/src/msw/window.cpp
index 68d1ac3e10..dbfbd9157c 100644
--- a/src/msw/window.cpp
+++ b/src/msw/window.cpp
@@ -6231,30 +6231,25 @@ bool wxWindowMSW::HandleRotateGesture(const wxPoint& pt,
     // wxEVT_GESTURE_ROTATE
     wxRotateGestureEvent event(GetId());
 
-    if ( InitGestureEvent(event, pt, flags) )
-    {
-        event.SetRotationAngle(angleArgument);
-    }
-    else // Not the first event.
-    {
-        // Use angleArgument to obtain the cumulative angle since the gesture
-        // was first started. This angle is in radians and MSW returns negative
-        // angle for clockwise rotation and positive otherwise, so, multiply
-        // angle by -1 for positive angle for clockwise and negative in case of
-        // counterclockwise.
-        double angle = -GID_ROTATE_ANGLE_FROM_ARGUMENT(angleArgument);
+    InitGestureEvent(event, pt, flags);
 
-        // If the rotation is anti-clockwise convert the angle to its
-        // corresponding positive value in a clockwise sense.
-        if ( angle < 0 )
-        {
-            angle += 2 * M_PI;
-        }
+    // Use angleArgument to obtain the cumulative angle since the gesture
+    // was first started. This angle is in radians and MSW returns negative
+    // angle for clockwise rotation and positive otherwise, so, multiply
+    // angle by -1 for positive angle for clockwise and negative in case of
+    // counterclockwise.
+    double angle = -GID_ROTATE_ANGLE_FROM_ARGUMENT(angleArgument);
 
-        // Set the angle
-        event.SetRotationAngle(angle);
+    // If the rotation is anti-clockwise convert the angle to its
+    // corresponding positive value in a clockwise sense.
+    if (angle < 0)
+    {
+        angle += 2 * M_PI;
     }
 
+    // Set the angle
+    event.SetRotationAngle(angle);
+
     return HandleWindowEvent(event);
 }
 

Platform and version information

  • wxWidgets version you use: 3.2 / master
  • wxWidgets port you use: wxMSW
  • OS and its version: Windows 11


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24596@github.com>

VZ

unread,
Jun 8, 2024, 5:48:50 PM6/8/24
to wx-...@googlegroups.com, Subscribed

Thanks for reporting/debugging/fixing this! I don't have the hardware for gestures testing, so I'd be glad to just apply the PR with these changes.

Of course, if anybody else who can test this change could do it, it would be great, TIA!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/24596/2156198750@github.com>

Reply all
Reply to author
Forward
0 new messages