changeset 10317:17fa5ea51ecb

8173852: FXCanvas needs to invert rotation angle when forwarding a gesture event Summary: Ensured FXCanvas inverts the rotation angle when forwarding SWT GestureEvents to the embedded scene. Reviewed-by: azvegint, kcr
author anyssen
date Fri, 03 Feb 2017 16:02:18 -0800
parents 020fbca40bf9
children 01023e38dcec
files modules/javafx.swt/src/main/java/javafx/embed/swt/FXCanvas.java tests/manual/swt/FXCanvasGestureEventsTest.java
diffstat 2 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.swt/src/main/java/javafx/embed/swt/FXCanvas.java	Thu Feb 02 12:46:31 2017 -0800
+++ b/modules/javafx.swt/src/main/java/javafx/embed/swt/FXCanvas.java	Fri Feb 03 16:02:18 2017 -0800
@@ -923,7 +923,9 @@
     private void sendRotateEventToFX(int type, GestureEvent gestureEvent) {
         Point los = toDisplay(gestureEvent.x, gestureEvent.y);
 
-        double totalAngle = gestureEvent.rotation;
+        // SWT uses negative angle values to indicate clockwise rotation, while JavaFX uses positive ones.
+        // We thus have to invert the values here
+        double totalAngle = -gestureEvent.rotation;
         if (type == AbstractEvents.ROTATEEVENT_STARTED) {
             totalAngle = lastTotalAngle = 0.0;
         } else if (type == AbstractEvents.ROTATEEVENT_FINISHED) {
--- a/tests/manual/swt/FXCanvasGestureEventsTest.java	Thu Feb 02 12:46:31 2017 -0800
+++ b/tests/manual/swt/FXCanvasGestureEventsTest.java	Fri Feb 03 16:02:18 2017 -0800
@@ -39,7 +39,7 @@
                     "It passes if proper event sequences for ZOOM (Mac, Windows), ROTATE (Mac, Windows), SCROLL (Mac, Windows)" +
                     "are printed to the console (SWT does not support any gestures on Linux yet, and SWIPE does not seem to be supported any more):\n\n " +
                     " 1) Perform a simple ZOOM gesture and observe that a 'ZoomStarted (Zoom)+ ZoomFinished' event sequence is printed out. The finish event should provide a zoom of '1.0' and a totalZoom that corresponds to the product of the zoom values of all preceding events.\n\n" +
-                    " 2) Perform a simple ROTATE gesture and observe that a 'RotationStarted (Rotate)+ RotationFinished' event sequence is printed out. The finish event should provide an angle of '0.0' and a totalAngle that corresponds to the sum of the angle values of all preceding events. Note that with SWT < 3.8, rotate values will all be zero on MacOS 64-bit due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=349812.\n\n" +
+                    " 2) Perform a simple ROTATE gesture and observe that a 'RotationStarted (Rotate)+ RotationFinished' event sequence is printed out. The finish event should provide an angle of '0.0' and a totalAngle that corresponds to the sum of the angle values of all preceding events. The rotation angle values should be positive when rotating clockwise and negative when rotating counter-clockwise. Note that with SWT < 3.8, rotate values will all be zero on MacOS 64-bit due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=349812.\n\n" +
                     " 3) Perform a complex ROTATE-ZOOM gesture (start with ROTATE then continue with ZOOM) and observe that a 'RotationStarted (Rotate)+ ZoomStarted (Zoom | Rotate)+ ZoomFinished (Rotate)* RotationFinished' event sequence is printed out.\n\n" +
                     " 4) Perform a complex ZOOM-ROTATE gesture (start with ZOOM then continue with ROTATE) and observe that a 'ZoomStarted (Zoom)+ RotationStarted (Zoom | Rotate)+ RotationFinished (Zoom)* ZoomFinished' event sequence is printed out.\n\n" +
                     " 5) Perform a simple vertical SCROLL gesture and observe that a 'ScrollStarted (Scroll)+ ScrollFinished (Scroll)*' event sequence is printed out. The finish event should provide a scrollY value of 0 and a totalScrollY value that corresponds to the sum of the scrollY events of all preceding events. The scroll events that occur after the finish event should have inertia set to true, while all others should have set inertia to false.\n\n" +