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/05/15 14:36:56 UTC
svn commit: r775107 - in /incubator/pivot/trunk: demos/src/pivot/demos/dom/
demos/src/pivot/demos/rss/ tutorials/src/pivot/tutorials/buttons/
wtk/src/pivot/wtk/skin/ wtk/src/pivot/wtk/skin/terra/
wtk/test/pivot/wtk/test/
Author: gbrown
Date: Fri May 15 12:36:55 2009
New Revision: 775107
URL: http://svn.apache.org/viewvc?rev=775107&view=rev
Log:
Define a selectionChangeEffect style and associated enum in CardPaneSkin. When null, no transition effect is applied. This enum replaces the more limited "orientation" property.
Modified:
incubator/pivot/trunk/demos/src/pivot/demos/dom/im_client.wtkx
incubator/pivot/trunk/demos/src/pivot/demos/rss/rss_feed_demo.wtkx
incubator/pivot/trunk/tutorials/src/pivot/tutorials/buttons/link_buttons.wtkx
incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java
incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraSheetSkin.java
incubator/pivot/trunk/wtk/test/pivot/wtk/test/card_pane_test.wtkx
Modified: incubator/pivot/trunk/demos/src/pivot/demos/dom/im_client.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/pivot/demos/dom/im_client.wtkx?rev=775107&r1=775106&r2=775107&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/pivot/demos/dom/im_client.wtkx (original)
+++ incubator/pivot/trunk/demos/src/pivot/demos/dom/im_client.wtkx Fri May 15 12:36:55 2009
@@ -22,7 +22,7 @@
<content>
<Border styles="{padding:8}">
<content>
- <CardPane wtkx:id="cardPane" selectedIndex="0" styles="{orientation:'horizontal'}">
+ <CardPane wtkx:id="cardPane" selectedIndex="0" styles="{selectionChangeEffect:'horizontalSlide'}">
<Form wtkx:id="loginForm" styles="{fieldAlignment:'justify'}">
<sections>
<Form.Section>
Modified: incubator/pivot/trunk/demos/src/pivot/demos/rss/rss_feed_demo.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/pivot/demos/rss/rss_feed_demo.wtkx?rev=775107&r1=775106&r2=775107&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/pivot/demos/rss/rss_feed_demo.wtkx (original)
+++ incubator/pivot/trunk/demos/src/pivot/demos/rss/rss_feed_demo.wtkx Fri May 15 12:36:55 2009
@@ -24,7 +24,7 @@
<content>
<Border styles="{padding:0, color:10}">
<content>
- <CardPane wtkx:id="cardPane" selectedIndex="0">
+ <CardPane wtkx:id="cardPane" selectedIndex="0" styles="{selectionChangeEffect:'crossfade'}">
<Label wtkx:id="statusLabel" text="Loading..."
styles="{horizontalAlignment:'center', verticalAlignment:'center'}"/>
<ScrollPane horizontalScrollBarPolicy="fillToCapacity">
Modified: incubator/pivot/trunk/tutorials/src/pivot/tutorials/buttons/link_buttons.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/pivot/tutorials/buttons/link_buttons.wtkx?rev=775107&r1=775106&r2=775107&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/pivot/tutorials/buttons/link_buttons.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/pivot/tutorials/buttons/link_buttons.wtkx Fri May 15 12:36:55 2009
@@ -21,7 +21,7 @@
xmlns:content="pivot.wtk.content"
xmlns="pivot.wtk">
<content>
- <CardPane wtkx:id="cardPane" selectedIndex="0" styles="{orientation:'horizontal'}">
+ <CardPane wtkx:id="cardPane" selectedIndex="0" styles="{selectionChangeEffect:'horizontalSlide'}">
<FlowPane orientation="vertical" styles="{horizontalAlignment:'center', verticalAlignment:'center'}">
<ImageView image="pivot/tutorials/IMG_0735_2.jpg"/>
<LinkButton wtkx:id="nextButton">
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java?rev=775107&r1=775106&r2=775107&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/CardPaneSkin.java Fri May 15 12:36:55 2009
@@ -23,7 +23,6 @@
import pivot.wtk.Component;
import pivot.wtk.Container;
import pivot.wtk.Dimensions;
-import pivot.wtk.Orientation;
import pivot.wtk.effects.FadeDecorator;
import pivot.wtk.effects.Transition;
import pivot.wtk.effects.TransitionListener;
@@ -37,6 +36,35 @@
*/
public class CardPaneSkin extends ContainerSkin implements CardPaneListener {
/**
+ * Defines the supported selection change effects.
+ *
+ * @author gbrown
+ */
+ public enum SelectionChangeEffect {
+ CROSSFADE,
+ HORIZONTAL_SLIDE,
+ VERTICAL_SLIDE;
+
+ public static SelectionChangeEffect decode(String value) {
+ SelectionChangeEffect selectionChangeEffect;
+
+ if (value == null) {
+ selectionChangeEffect = null;
+ } else if (value.equals("crossfade")) {
+ selectionChangeEffect = CROSSFADE;
+ } else if (value.equals("horizontalSlide")) {
+ selectionChangeEffect = HORIZONTAL_SLIDE;
+ } else if (value.equals("verticalSlide")) {
+ selectionChangeEffect = VERTICAL_SLIDE;
+ } else {
+ throw new IllegalArgumentException();
+ }
+
+ return selectionChangeEffect;
+ }
+ }
+
+ /**
* Abstract base class for selection change transitions.
*
* @author gbrown
@@ -76,11 +104,11 @@
*
* @author gbrown
*/
- public class FadeTransition extends SelectionChangeTransition {
+ public class CrossfadeTransition extends SelectionChangeTransition {
private FadeDecorator fadeOutDecorator = new FadeDecorator();
private FadeDecorator fadeInDecorator = new FadeDecorator();
- public FadeTransition(int from, int to) {
+ public CrossfadeTransition(int from, int to) {
super(from, to);
}
@@ -121,22 +149,6 @@
protected void update() {
float percentComplete = getPercentComplete();
- int width = getWidth();
- int height = getHeight();
-
- // Center components
- Component fromCard = getFromCard();
- if (fromCard != null) {
- fromCard.setLocation((width - fromCard.getWidth()) / 2,
- (height - fromCard.getHeight()) / 2);
- }
-
- Component toCard = getToCard();
- if (toCard != null) {
- toCard.setLocation((width - toCard.getWidth()) / 2,
- (height - toCard.getHeight()) / 2);
- }
-
fadeOutDecorator.setOpacity(1.0f - percentComplete);
fadeInDecorator.setOpacity(percentComplete);
@@ -192,7 +204,7 @@
Component fromCard = cardPane.get(from);
Component toCard = cardPane.get(to);
- if (orientation == Orientation.HORIZONTAL) {
+ if (selectionChangeEffect == SelectionChangeEffect.HORIZONTAL_SLIDE) {
fromCard.setLocation(dx, 0);
toCard.setLocation(-width * direction + dx, 0);
} else {
@@ -203,7 +215,7 @@
}
private boolean sizeToSelection = false;
- private Orientation orientation = null;
+ private SelectionChangeEffect selectionChangeEffect = null;
private SelectionChangeTransition selectionChangeTransition = null;
@@ -345,20 +357,21 @@
this.sizeToSelection = sizeToSelection;
}
- public Orientation getOrientation() {
- return orientation;
+ public SelectionChangeEffect getSelectionChangeEffect() {
+ return selectionChangeEffect;
}
- public void setOrientation(Orientation orientation) {
- this.orientation = orientation;
+ public void setSelectionChangeEffect(SelectionChangeEffect selectionChangeEffect) {
+ // TODO Check against sizeToSelection?
+ this.selectionChangeEffect = selectionChangeEffect;
}
- public void setOrientation(String orientation) {
- if (orientation == null) {
+ public void setSelectionChangeEffect(String selectionChangeEffect) {
+ if (selectionChangeEffect == null) {
throw new IllegalArgumentException();
}
- setOrientation(Orientation.decode(orientation));
+ setSelectionChangeEffect(SelectionChangeEffect.decode(selectionChangeEffect));
}
@Override
@@ -397,18 +410,23 @@
Vote vote;
if (cardPane.isShowing()
+ && selectionChangeEffect != null
&& selectionChangeTransition == null) {
int previousSelectedIndex = cardPane.getSelectedIndex();
- if (sizeToSelection) {
- selectionChangeTransition = new FadeTransition(previousSelectedIndex, selectedIndex);
- } else {
- if (orientation != null
- && previousSelectedIndex != -1
- && selectedIndex != -1) {
- selectionChangeTransition = new SlideTransition(previousSelectedIndex, selectedIndex);
- } else {
- // TODO Use a fade in/out transition?
+ switch(selectionChangeEffect) {
+ case CROSSFADE: {
+ selectionChangeTransition = new CrossfadeTransition(previousSelectedIndex, selectedIndex);
+ break;
+ }
+
+ case HORIZONTAL_SLIDE:
+ case VERTICAL_SLIDE: {
+ if (previousSelectedIndex != -1
+ && selectedIndex != -1) {
+ selectionChangeTransition = new SlideTransition(previousSelectedIndex, selectedIndex);
+ }
+ break;
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraSheetSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraSheetSkin.java?rev=775107&r1=775106&r2=775107&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraSheetSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraSheetSkin.java Fri May 15 12:36:55 2009
@@ -335,7 +335,9 @@
// when the transition is complete
Vote vote = Vote.APPROVE;
- if (closeTransition == null) {
+ Window owner = sheet.getOwner();
+ if (!owner.isClosing()
+ && closeTransition == null) {
int duration = SLIDE_DURATION;
int beginX = 0;
int beginY = 0;
@@ -365,7 +367,8 @@
vote = Vote.DEFER;
}
} else {
- vote = (closeTransition.isRunning()) ? Vote.DEFER : Vote.APPROVE;
+ vote = (closeTransition != null
+ && closeTransition.isRunning()) ? Vote.DEFER : Vote.APPROVE;
}
return vote;
Modified: incubator/pivot/trunk/wtk/test/pivot/wtk/test/card_pane_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/pivot/wtk/test/card_pane_test.wtkx?rev=775107&r1=775106&r2=775107&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/pivot/wtk/test/card_pane_test.wtkx (original)
+++ incubator/pivot/trunk/wtk/test/pivot/wtk/test/card_pane_test.wtkx Fri May 15 12:36:55 2009
@@ -31,7 +31,7 @@
</FlowPane>
</TablePane.Row>
<TablePane.Row height="1*">
- <CardPane wtkx:id="cardPane" styles="{sizeToSelection:true, orientation:'vertical'}">
+ <CardPane wtkx:id="cardPane" styles="{sizeToSelection:true, selectionChangeEffect:'crossfade'}">
<Border title="320x240" preferredWidth="320" preferredHeight="240"/>
<Border title="640x480" preferredWidth="640" preferredHeight="480"/>
<Border title="800x600" preferredWidth="800" preferredHeight="600"/>