You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2014/09/03 14:27:23 UTC
svn commit: r1622238 - in /pivot/trunk:
demos/src/org/apache/pivot/demos/roweditor/ tests/src/org/apache/pivot/tests/
wtk-terra/src/org/apache/pivot/wtk/skin/terra/
wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/content/
wtk/src/org/apache/...
Author: smartini
Date: Wed Sep 3 12:27:22 2014
New Revision: 1622238
URL: http://svn.apache.org/r1622238
Log:
PIVOT-956, first changes to add the skin (optional) ability to disable Transitions.
Add a first Demo working (RowEditorDemo); for documentation purposes, set this is variants (under tests) of the skin default and dark config files.
Modified:
pivot/trunk/demos/src/org/apache/pivot/demos/roweditor/RowEditorDemo.java
pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_dark_flat.json
pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_test.json
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
Modified: pivot/trunk/demos/src/org/apache/pivot/demos/roweditor/RowEditorDemo.java
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/roweditor/RowEditorDemo.java?rev=1622238&r1=1622237&r2=1622238&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/roweditor/RowEditorDemo.java (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/roweditor/RowEditorDemo.java Wed Sep 3 12:27:22 2014
@@ -24,6 +24,7 @@ import org.apache.pivot.util.Resources;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Theme;
import org.apache.pivot.wtk.Window;
public class RowEditorDemo extends Application.Adapter {
@@ -44,9 +45,13 @@ public class RowEditorDemo extends Appli
String title = (String) resources.get("title");
System.out.println("Title from Resources file is: \"" + title + "\"");
+ // print if the theme has transitions enabled
+ System.out.println("Theme has transitions enabled: " + Theme.getTheme().isTransitionEnabled());
+
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(
RowEditorDemo.class.getResource("row_editor_demo.bxml"), resources);
+
window.open(display);
}
Modified: pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_dark_flat.json
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_dark_flat.json?rev=1622238&r1=1622237&r2=1622238&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_dark_flat.json (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_dark_flat.json Wed Sep 3 12:27:22 2014
@@ -22,6 +22,8 @@
themeIsFlat: true,
+ transitionEnabled: false,
+
colors: [
"#f5f5f5",
"#141414",
Modified: pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_test.json
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_test.json?rev=1622238&r1=1622237&r2=1622238&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_test.json (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/TerraTheme_test.json Wed Sep 3 12:27:22 2014
@@ -22,6 +22,8 @@
themeIsFlat: true,
+ transitionEnabled: false,
+
colors: [
"#0a0a0a",
"#ebebeb",
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java?rev=1622238&r1=1622237&r2=1622238&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java Wed Sep 3 12:27:22 2014
@@ -101,6 +101,7 @@ public final class TerraTheme extends Th
private static float colorMultiplier = 0.1f;
private static boolean themeIsDark = false;
private static boolean themeIsFlat = false;
+ private static boolean transitionEnabled = true;
private static Color defaultBackgroundColor;
private static Color defaultForegroundColor;
@@ -277,6 +278,11 @@ public final class TerraTheme extends Th
themeIsFlat = flat.booleanValue();
}
+ Boolean transition = (Boolean) properties.get("transitionEnabled");
+ if (transition != null) {
+ transitionEnabled = transition.booleanValue();
+ }
+
for (String colorCode : colorCodes) {
Color baseColor = Color.decode(colorCode);
colors.add(darken(baseColor));
@@ -470,6 +476,17 @@ public final class TerraTheme extends Th
}
/**
+ * Tell if the theme has transitions enabled.<br/> Usually this means that (if false) any
+ * effect/transition will not be drawn.
+ *
+ * @return true if enabled (default), false otherwise
+ */
+ @Override
+ public boolean isTransitionEnabled() {
+ return transitionEnabled;
+ }
+
+ /**
* Gets the image that this theme uses to represent messages of the
* specified type.
*
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java?rev=1622238&r1=1622237&r2=1622238&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java Wed Sep 3 12:27:22 2014
@@ -180,6 +180,14 @@ public abstract class Theme {
public abstract boolean isThemeFlat();
/**
+ * Tell if the theme has transitions enabled.<br/> Usually this means that (if false) any
+ * effect/transition will not be drawn.
+ *
+ * @return true if enabled (default), false otherwise
+ */
+ public abstract boolean isTransitionEnabled();
+
+ /**
* Returns the skin class responsible for skinning the specified component
* class.
*
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java?rev=1622238&r1=1622237&r2=1622238&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java Wed Sep 3 12:27:22 2014
@@ -139,7 +139,7 @@ public class TableViewRowEditor extends
}
});
- tablePane.getStyles().put("horizontalSpacing", 1);
+ tablePane.getStyles().put("horizontalSpacing", new Integer(1));
tablePane.getRows().add(editorRow);
}
@@ -316,7 +316,7 @@ public class TableViewRowEditor extends
* @return The effect duration in milliseconds.
*/
public int getEditEffectDuration() {
- return (Integer) cardPane.getStyles().get("selectionChangeDuration");
+ return ((Integer) cardPane.getStyles().get("selectionChangeDuration")).intValue();
}
/**
@@ -325,7 +325,7 @@ public class TableViewRowEditor extends
* @param effectDuration The effect duration in milliseconds.
*/
public void setEditEffectDuration(int effectDuration) {
- cardPane.getStyles().put("selectionChangeDuration", effectDuration);
+ cardPane.getStyles().put("selectionChangeDuration", new Integer(effectDuration));
}
/**
@@ -334,7 +334,7 @@ public class TableViewRowEditor extends
* @return The effect rate.
*/
public int getEditEffectRate() {
- return (Integer) cardPane.getStyles().get("selectionChangeRate");
+ return ((Integer) cardPane.getStyles().get("selectionChangeRate")).intValue();
}
/**
@@ -343,7 +343,7 @@ public class TableViewRowEditor extends
* @param effectRate The effect rate.
*/
public void setEditEffectRate(int effectRate) {
- cardPane.getStyles().put("selectionChangeRate", effectRate);
+ cardPane.getStyles().put("selectionChangeRate", new Integer(effectRate));
}
@Override
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java?rev=1622238&r1=1622237&r2=1622238&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Transition.java Wed Sep 3 12:27:22 2014
@@ -17,6 +17,7 @@
package org.apache.pivot.wtk.effects;
import org.apache.pivot.wtk.ApplicationContext;
+import org.apache.pivot.wtk.Theme;
/**
* Abstract base class for "transitions", which are animated application
@@ -82,6 +83,9 @@ public abstract class Transition {
/**
* Creates a new transition with the given duration, rate, and repeat.
+ *
+ * Note that if the current Theme has transitions not enabled,
+ * will be set default values instead of given arguments.
*
* @param duration Transition duration, in milliseconds.
* @param rate Transition rate, in frames per second.
@@ -91,12 +95,19 @@ public abstract class Transition {
* <tt>false</tt> otherwise.
*/
public Transition(int duration, int rate, boolean repeating, boolean reversed) {
- if (duration <= 0) {
+ if (duration < 0) {
throw new IllegalArgumentException("duration must be positive.");
}
- this.duration = duration;
- this.rate = rate;
+ if (!themeHasTransitionEnabled()) {
+ // System.out.println("transitions not enabled, overriding transition values");
+ this.duration = 0;
+ this.rate = 0;
+ } else {
+ this.duration = duration;
+ this.rate = rate;
+ }
+
this.repeating = repeating;
this.reversed = reversed;
}
@@ -161,10 +172,17 @@ public abstract class Transition {
* Returns the transition interval, the number of milliseconds between
* updates.
*
- * @return The transition interval, in milliseconds.
+ * @return The transition interval in milliseconds,
+ * or a default minimum value if transitions has been disabled.
*/
public int getInterval() {
- return (int) ((1f / rate) * 1000);
+ int interval;
+ if (rate != 0) {
+ interval = (int) ((1f / rate) * 1000);
+ } else {
+ interval = 1;
+ }
+ return interval;
}
/**
@@ -213,7 +231,12 @@ public abstract class Transition {
* percent remaining.
*/
public float getPercentComplete() {
- float percentComplete = (float) (currentTime - startTime) / (float) (duration);
+ float percentComplete;
+ if (duration != 0) {
+ percentComplete = (float) (currentTime - startTime) / (float) (duration);
+ } else {
+ percentComplete = 1.0f;
+ }
if (reversed) {
percentComplete = 1.0f - percentComplete;
@@ -333,4 +356,15 @@ public abstract class Transition {
setReversed(!isReversed());
}
+
+ /**
+ * Tell if the theme has transitions enabled.<br/> Usually this means that (if false) any
+ * effect/transition will not be drawn.
+ *
+ * @return true if enabled (default), false otherwise
+ */
+ protected boolean themeHasTransitionEnabled() {
+ return Theme.getTheme().isTransitionEnabled();
+ }
+
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java?rev=1622238&r1=1622237&r2=1622238&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java Wed Sep 3 12:27:22 2014
@@ -437,6 +437,15 @@ public abstract class ComponentSkin impl
}
/**
+ * Returns if the current Theme has transitions enabled.
+ *
+ * @return true if transitions are enabled (default), false otherwise
+ */
+ protected boolean themeHasTransitionEnabled() {
+ return currentTheme().isTransitionEnabled();
+ }
+
+ /**
* Returns the Theme default background color.
*
* @return White if the theme is not dark (default), or Black.