changeset 5590:1021c3b800d1

Ensemble8: Introduced reset() method to BendingPages and SlidingPages in order to reuse SamplePage.
author Alexander Kouznetsov
date Wed, 30 Oct 2013 20:05:03 -0700
parents ee2deaadbc15
children 2f74b29d7627
files apps/samples/Ensemble8/src/app/java/ensemble/control/BendingPages.java apps/samples/Ensemble8/src/app/java/ensemble/samplepage/SlidingPages.java
diffstat 2 files changed, 28 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/apps/samples/Ensemble8/src/app/java/ensemble/control/BendingPages.java	Wed Oct 30 21:47:34 2013 -0400
+++ b/apps/samples/Ensemble8/src/app/java/ensemble/control/BendingPages.java	Wed Oct 30 20:05:03 2013 -0700
@@ -97,6 +97,16 @@
         this.backPage.set(backPage);
     }
 
+    public void reset() {
+        if (animation != null) {
+            animation.stop();
+        }
+        state = State.CLOSED;
+        setTarget();
+        update();
+        fixMouseTransparency();
+    }
+
     @Override
     protected void layoutChildren() {
         super.layoutChildren();
@@ -155,6 +165,14 @@
     public void setGripSize(double gripSize) {
         this.gripSize.set(gripSize);
     }
+
+    private void fixMouseTransparency() {
+        if (state == State.OPENED) {
+            frontPage.get().setMouseTransparent(true);
+        } else if (state == State.CLOSED) {
+            frontPage.get().setMouseTransparent(false);
+        }
+    }
     
     static enum AnimationState { NO_ANIMATION, FOLLOWING_MOVING_MOUSE, 
             FOLLOWING_DRAGGING_MOUSE, ANIMATION 
@@ -367,11 +385,7 @@
                 .build();
         animation.play();
         animState = ANIMATION;
-        if (state == State.OPENED) {
-            frontPage.get().setMouseTransparent(true);
-        } else if (state == State.CLOSED) {
-            frontPage.get().setMouseTransparent(false);
-        }
+        fixMouseTransparency();
     }
     
     /**
--- a/apps/samples/Ensemble8/src/app/java/ensemble/samplepage/SlidingPages.java	Wed Oct 30 21:47:34 2013 -0400
+++ b/apps/samples/Ensemble8/src/app/java/ensemble/samplepage/SlidingPages.java	Wed Oct 30 20:05:03 2013 -0700
@@ -63,6 +63,10 @@
         getChildren().add(actionNode);
     }
 
+    public void reset() {
+        slide.reset();
+    }
+
     @Override protected void layoutChildren() {
         super.layoutChildren();
         if (frontPage != null) {
@@ -252,6 +256,11 @@
 //                nextScreen = baseScreen;
 //            }
         }
+
+        public void reset() {
+            targetScreen.setTranslateX(fromX);
+            targetScreen.setTranslateY(fromY);
+        }
     }
     
 }