changeset 903:3fa9344823cf 2.2-b07

Automated merge with ssh://jpgodine@jfxsrc.us.oracle.com//javafx/2.2/MASTER/jfx/rt
author jpgodine@JPGODINE-LAP.st-users.us.oracle.com
date Tue, 01 May 2012 10:04:19 -0700
parents ce65dc129c92 3ae1a875814f
children 2dd3f2b733f2 4eb3bdceece6 59e272db3bc6
files
diffstat 4 files changed, 119 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/Scene.java	Mon Apr 30 11:11:55 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/Scene.java	Tue May 01 10:04:19 2012 -0700
@@ -942,17 +942,22 @@
                 protected void invalidated() {
                     Parent _value = get();
 
-                    if (_value != null && _value.getParent() != null) {
+                    if (_value == null) {
+                        if (isBound()) forceUnbind();
+                        throw new NullPointerException("Scene's root cannot be null");
+                    }
+
+                    if (_value.getParent() != null) {
                         if (isBound()) forceUnbind();
                         throw new IllegalArgumentException(_value +
                                 "is already inside a scene-graph and cannot be set as root");
                     }
-                    if (_value != null && _value.impl_getClipParent() != null) {
+                    if (_value.impl_getClipParent() != null) {
                         if (isBound()) forceUnbind();
                         throw new IllegalArgumentException(_value +
                                 "is set as a clip on another node, so cannot be set as root");
                     }
-                    if (_value != null && _value.isSceneRoot() && _value.getScene() != Scene.this) {
+                    if (_value.isSceneRoot() && _value.getScene() != Scene.this) {
                         if (isBound()) forceUnbind();
                         throw new IllegalArgumentException(_value +
                                 "is already set as root of another scene");
@@ -963,16 +968,14 @@
                         oldRoot.setImpl_traversalEngine(null);
                     }
                     oldRoot = _value;
-                    if (_value != null) {
-                        if (_value.getImpl_traversalEngine() == null) {
-                            _value.setImpl_traversalEngine(new TraversalEngine(_value, true));
-                        }
-                        _value.getStyleClass().add(0, "root");
-                        _value.setScene(Scene.this);
-                        markDirty(DirtyBits.ROOT_DIRTY);
-                        _value.resize(getWidth(), getHeight()); // maybe no-op if root is not resizable
-                        _value.requestLayout();
+                    if (_value.getImpl_traversalEngine() == null) {
+                        _value.setImpl_traversalEngine(new TraversalEngine(_value, true));
                     }
+                    _value.getStyleClass().add(0, "root");
+                    _value.setScene(Scene.this);
+                    markDirty(DirtyBits.ROOT_DIRTY);
+                    _value.resize(getWidth(), getHeight()); // maybe no-op if root is not resizable
+                    _value.requestLayout();
                 }
 
                 @Override
@@ -1276,6 +1279,7 @@
         EventTarget target;
         Point2D sceneCoords;
         Point2D screenCoords;
+        boolean finished;
     }
 
     private final TouchGesture scrollGesture = new TouchGesture();
@@ -1332,9 +1336,10 @@
                 e.getEventType() == RotateEvent.ROTATION_STARTED ||
                 e.getEventType() == ScrollEvent.SCROLL_STARTED) {
             gesture.target = null;
-        }
-
-        if (gesture.target != null) {
+            gesture.finished = false;
+        }
+
+        if (gesture.target != null && (!gesture.finished || e.isInertia())) {
             pickedTarget = gesture.target;
         } else {
             pickedTarget = pick(e.getX(), e.getY());
@@ -1357,6 +1362,12 @@
             Event.fireEvent(pickedTarget, e);
         }
 
+        if (e.getEventType() == ZoomEvent.ZOOM_FINISHED ||
+                e.getEventType() == RotateEvent.ROTATION_FINISHED ||
+                e.getEventType() == ScrollEvent.SCROLL_FINISHED) {
+            gesture.finished = true;
+        }
+
         inMousePick = false;
     }
 
--- a/javafx-ui-common/test/unit/javafx/scene/MouseTest.java	Mon Apr 30 11:11:55 2012 -0700
+++ b/javafx-ui-common/test/unit/javafx/scene/MouseTest.java	Tue May 01 10:04:19 2012 -0700
@@ -909,7 +909,31 @@
                 MouseEvent.MOUSE_RELEASED, 266, 266));
         assertTrue(scene.smallSquareTracker.wasLastStill());        
     }
-    
+
+    @Test
+    public void NodeMovementsWithStillMouseShouldFireEnteredExited() {
+        SimpleTestScene scene = new SimpleTestScene();
+        MouseEventGenerator generator = new MouseEventGenerator();
+
+        scene.processEvent(generator.generateMouseEvent(
+                MouseEvent.MOUSE_ENTERED, 250, 250));
+        scene.processEvent(generator.generateMouseEvent(
+                MouseEvent.MOUSE_MOVED, 250, 250));
+        scene.smallSquareTracker.clear();
+
+        assertFalse(scene.smallSquareTracker.exitedMe);
+        ((Rectangle) scene.smallSquareTracker.node).setX(400);
+        ((StubToolkit) Toolkit.getToolkit()).firePulse();
+        assertTrue(scene.smallSquareTracker.exitedMe);
+
+        scene.smallSquareTracker.clear();
+
+        assertFalse(scene.smallSquareTracker.enteredMe);
+        ((Rectangle) scene.smallSquareTracker.node).setX(200);
+        ((StubToolkit) Toolkit.getToolkit()).firePulse();
+        assertTrue(scene.smallSquareTracker.enteredMe);
+    }
+
     private static class SimpleTestScene {
 
         MouseEventTracker sceneTracker;
--- a/javafx-ui-common/test/unit/javafx/scene/Scene_properties_Test.java	Mon Apr 30 11:11:55 2012 -0700
+++ b/javafx-ui-common/test/unit/javafx/scene/Scene_properties_Test.java	Tue May 01 10:04:19 2012 -0700
@@ -39,6 +39,7 @@
 import com.sun.javafx.test.PropertiesTestBase;
 import com.sun.javafx.test.objects.TestScene;
 import com.sun.javafx.test.objects.TestStage;
+import javafx.scene.layout.Pane;
 
 @RunWith(Parameterized.class)
 public final class Scene_properties_Test extends PropertiesTestBase {
@@ -66,7 +67,7 @@
 //            config(testScene, "height", , ),
             config(testScene, "camera", null, new ParallelCamera()),
             config(testScene, "fill", Color.WHITE, Color.BLACK),
-            config(testScene, "root", new Group(), null),
+            config(testScene, "root", new Group(), new Pane()),
             config(testScene, "cursor", Cursor.DEFAULT, Cursor.CROSSHAIR),
             config(testScene, "eventDispatcher",
                    null,
--- a/javafx-ui-common/test/unit/javafx/scene/input/ScrollEventTest.java	Mon Apr 30 11:11:55 2012 -0700
+++ b/javafx-ui-common/test/unit/javafx/scene/input/ScrollEventTest.java	Tue May 01 10:04:19 2012 -0700
@@ -374,6 +374,72 @@
                 250, 250, 250, 250, true, false, true, false, true, false);
         assertTrue(scrolled);
         assertFalse(scrolled2);
+
+        // inertia
+        scrolled = false;
+        scrolled2 = false;
+        ((StubScene) scene.impl_getPeer()).getListener().scrollEvent(
+                ScrollEvent.SCROLL, 2, 3, 4, 6, 33, 33, 0, 1, 1, 3, 3,
+                250, 250, 250, 250, true, false, true, false, true, true);
+        assertTrue(scrolled);
+        assertFalse(scrolled2);
+    }
+
+    @Test
+    public void shouldPickForMouseWheelDuringInertia() {
+        Scene scene = createScene();
+        Rectangle rect1 =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(0);
+        Rectangle rect2 =
+                (Rectangle) scene.getRoot().getChildrenUnmodifiable().get(1);
+
+        rect1.addEventHandler(ScrollEvent.ANY, new EventHandler<ScrollEvent>() {
+            @Override public void handle(ScrollEvent event) {
+                scrolled = true;
+            }
+        });
+        rect2.addEventHandler(ScrollEvent.ANY, new EventHandler<ScrollEvent>() {
+            @Override public void handle(ScrollEvent event) {
+                scrolled2 = true;
+            }
+        });
+
+        ((StubScene) scene.impl_getPeer()).getListener().scrollEvent(
+                ScrollEvent.SCROLL_STARTED, 2, 3, 4, 6, 33, 33, 0, 1, 1, 3, 3,
+                150, 150, 150, 150, true, false, true, false, true, false);
+        ((StubScene) scene.impl_getPeer()).getListener().scrollEvent(
+                ScrollEvent.SCROLL, 2, 3, 4, 6, 33, 33, 0, 1, 1, 3, 3,
+                250, 250, 250, 250, true, false, true, false, true, false);
+        ((StubScene) scene.impl_getPeer()).getListener().scrollEvent(
+                ScrollEvent.SCROLL_FINISHED, 2, 3, 4, 6, 33, 33, 0, 1, 1, 3, 3,
+                250, 250, 250, 250, true, false, true, false, true, false);
+
+        // inertia
+        scrolled = false;
+        scrolled2 = false;
+        ((StubScene) scene.impl_getPeer()).getListener().scrollEvent(
+                ScrollEvent.SCROLL, 2, 3, 4, 6, 33, 33, 0, 1, 1, 3, 3,
+                250, 250, 250, 250, true, false, true, false, true, true);
+        assertTrue(scrolled);
+        assertFalse(scrolled2);
+
+        // wheel
+        scrolled = false;
+        scrolled2 = false;
+        ((StubScene) scene.impl_getPeer()).getListener().scrollEvent(
+                ScrollEvent.SCROLL, 2, 3, 4, 6, 33, 33, 0, 1, 1, 3, 3,
+                250, 250, 250, 250, true, false, true, false, true, false);
+        assertFalse(scrolled);
+        assertTrue(scrolled2);
+
+        // inertia
+        scrolled = false;
+        scrolled2 = false;
+        ((StubScene) scene.impl_getPeer()).getListener().scrollEvent(
+                ScrollEvent.SCROLL, 2, 3, 4, 6, 33, 33, 0, 1, 1, 3, 3,
+                250, 250, 250, 250, true, false, true, false, true, true);
+        assertTrue(scrolled);
+        assertFalse(scrolled2);
     }
 
     @Test