You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/06/19 15:22:54 UTC

svn commit: r786500 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: Component.java Form.java effects/Transition.java skin/terra/TerraSheetSkin.java

Author: gbrown
Date: Fri Jun 19 13:22:54 2009
New Revision: 786500

URL: http://svn.apache.org/viewvc?rev=786500&view=rev
Log:
Remove invalid assertion from Component; support reversing open transition in TerraSheetSkin.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Form.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java?rev=786500&r1=786499&r2=786500&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java Fri Jun 19 13:22:54 2009
@@ -2308,8 +2308,6 @@
      * @param attributes
      */
     protected void setAttributes(Attributes attributes) {
-        assert (parent != null);
-
         if (this.attributes != null) {
             this.attributes.setComponent(null);
         }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Form.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Form.java?rev=786500&r1=786499&r2=786500&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Form.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Form.java Fri Jun 19 13:22:54 2009
@@ -31,15 +31,13 @@
  * an optional text label associated with it and may be flagged as requiring
  * attention using one of several flag types and an optional flag message (for
  * use during form validation, for example).
- * <p>
- * TODO Add a label alignment attribute (vertical).
  *
  * @author gbrown
  */
 public class Form extends Container {
     /**
-     * Class representing a menu section. A section is a grouping of menu
-     * items within a menu.
+     * Class representing a form section. A section is a grouping of components
+     * within a form.
      *
      * @author gbrown
      */

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java?rev=786500&r1=786499&r2=786500&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java Fri Jun 19 13:22:54 2009
@@ -86,6 +86,22 @@
      * <tt>true</tt> if the transition should repeat; <tt>false</tt>, otherwise.
      */
     public Transition(int duration, int rate, boolean repeat) {
+        this(duration, rate, repeat, false);
+    }
+
+    /**
+     * Creates a new transition with the given duration, rate, and repeat.
+     *
+     * @param duration
+     * Transition duration, in milliseconds.
+     *
+     * @param rate
+     * Transition rate, in frames per second.
+     *
+     * @param repeat
+     * <tt>true</tt> if the transition should repeat; <tt>false</tt>, otherwise.
+     */
+    public Transition(int duration, int rate, boolean repeat, boolean reversed) {
         if (duration <= 0) {
             throw new IllegalArgumentException("duration must be positive.");
         }
@@ -93,6 +109,7 @@
         this.duration = duration;
         this.rate = rate;
         this.repeat = repeat;
+        this.reversed = reversed;
     }
 
     /**
@@ -239,9 +256,9 @@
     }
 
     /**
-     * Starts the transition. Calls {@link #update()} to establish the
-     * initial state and starts a timer that will repeatedly call
-     * {@link #update()} at the current rate.
+     * Starts the transition with no listener.
+     *
+     * @see #start(TransitionListener)
      */
     public final void start() {
         start(null);
@@ -306,14 +323,29 @@
     protected abstract void update();
 
     /**
-     * Reverses a currently running transition. Updates the start time so the
-     * reverse duration is the same as the current elapsed time.
+     * Reverses the transition with no listener.
+     *
+     * @see #reverse(TransitionListener)
      */
     public void reverse() {
-        if (transitionListener == null) {
+        reverse(null);
+    }
+
+    /**
+     * Reverses the transition. Updates the start time so the reverse duration
+     * is the same as the current elapsed time.
+     *
+     * @param transitionListener
+     * The listener to get notified when the transition completes, or
+     * <tt>null</tt> if no notification is necessary
+     */
+    public void reverse(TransitionListener transitionListener) {
+        if (this.transitionCallback == null) {
             throw new IllegalStateException("Transition is not currently running.");
         }
 
+        this.transitionListener = transitionListener;
+
         if (repeat) {
             throw new IllegalStateException("Transition is repeating.");
         }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java?rev=786500&r1=786499&r2=786500&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java Fri Jun 19 13:22:54 2009
@@ -53,10 +53,10 @@
  */
 public class TerraSheetSkin extends WindowSkin implements SheetStateListener {
     public class WindowStateTransition extends Transition {
-        private final boolean close;
+        private boolean close;
 
         public WindowStateTransition(boolean close) {
-            super(TRANSITION_DURATION, TRANSITION_RATE);
+            super(TRANSITION_DURATION, TRANSITION_RATE, false, close);
             this.close = close;
         }
 
@@ -64,6 +64,12 @@
         public void update() {
             invalidateComponent();
         }
+
+        @Override
+        public void reverse() {
+            super.reverse();
+            close = !close;
+        }
     }
 
     private Color borderColor;
@@ -214,18 +220,19 @@
         return preferredSize;
     }
 
-    private int getEasedPreferredHeight(int preferredHeight) {
+    public int getEasedPreferredHeight(int preferredHeight) {
         if (windowStateTransition != null
             && windowStateTransition.isRunning()) {
+            float scale;
             if (windowStateTransition.close) {
-                float scale = easing.easeIn(windowStateTransition.getElapsedTime(), 0, 1,
+                scale = easing.easeIn(windowStateTransition.getElapsedTime(), 0, 1,
                     windowStateTransition.getDuration());
-                preferredHeight = (int)((1.0f - scale) * preferredHeight);
             } else {
-                float scale = easing.easeOut(windowStateTransition.getElapsedTime(), 0, 1,
+                scale = easing.easeOut(windowStateTransition.getElapsedTime(), 0, 1,
                     windowStateTransition.getDuration());
-                preferredHeight = (int)(scale * preferredHeight);
             }
+
+            preferredHeight = (int)(scale * preferredHeight);
         }
 
         return preferredHeight;
@@ -393,18 +400,26 @@
         // Don't start the transition if the sheet is being closed as a result
         // of the owner closing
         Window owner = sheet.getOwner();
-        if (!owner.isClosing()
-            && windowStateTransition == null) {
-            windowStateTransition = new WindowStateTransition(true);
-            windowStateTransition.start(new TransitionListener() {
+        if (!owner.isClosing()) {
+            TransitionListener transitionListener = new TransitionListener() {
                 public void transitionCompleted(Transition transition) {
                     sheet.close(result);
                     windowStateTransition = null;
                 }
-            });
+            };
+
+            if (windowStateTransition == null) {
+                // Start the close transition
+                windowStateTransition = new WindowStateTransition(true);
+                windowStateTransition.start(transitionListener);
+            } else {
+                // Reverse the open transition
+                if (!windowStateTransition.close
+                    && windowStateTransition.isRunning()) {
+                    windowStateTransition.reverse(transitionListener);
+                }
+            }
 
-            vote = Vote.DEFER;
-        } else {
             vote = (windowStateTransition != null
                 && windowStateTransition.isRunning()) ? Vote.DEFER : Vote.APPROVE;
         }