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/08/13 13:59:49 UTC
svn commit: r803852 - in /incubator/pivot/trunk:
tools/src/org/apache/pivot/tools/net/
tutorials/src/org/apache/pivot/tutorials/
tutorials/src/org/apache/pivot/tutorials/layout/ tutorials/www/
wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/...
Author: gbrown
Date: Thu Aug 13 11:59:49 2009
New Revision: 803852
URL: http://svn.apache.org/viewvc?rev=803852&view=rev
Log:
Applied SplitPane patch; changed "topLeftComponent" and "bottomRightComponent" properties in SplitPane to simply "topLeft" and "bottomRight"; added a NONE constant to CornerRadii; changed sheet open/close duration to 300ms; changed CardPane flip transition to use standard selection change duration of 250ms.
Modified:
incubator/pivot/trunk/tools/src/org/apache/pivot/tools/net/application.wtkx
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/splitters.wtkx
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx
incubator/pivot/trunk/tutorials/www/flow_panes.template.html
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPane.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPaneListener.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java
incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/text/test/text_area_test.wtkx
Modified: incubator/pivot/trunk/tools/src/org/apache/pivot/tools/net/application.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tools/src/org/apache/pivot/tools/net/application.wtkx?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/tools/src/org/apache/pivot/tools/net/application.wtkx (original)
+++ incubator/pivot/trunk/tools/src/org/apache/pivot/tools/net/application.wtkx Thu Aug 13 11:59:49 2009
@@ -33,7 +33,7 @@
<TablePane.Row height="1*">
<Border styles="{thickness:0, padding:2}">
<content>
- <SplitPane orientation="vertical" splitLocation="400" primaryRegion="top_left">
+ <SplitPane orientation="vertical" splitRatio="0.6" primaryRegion="top_left">
<top>
<wtkx:include wtkx:id="request" src="request.wtkx" />
</top>
Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx Thu Aug 13 11:59:49 2009
@@ -20,7 +20,7 @@
xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk">
<content>
- <SplitPane splitLocation="260">
+ <SplitPane splitRatio="0.75">
<left>
<Border styles="{padding:0}">
<content>
Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/splitters.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/splitters.wtkx?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/splitters.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/splitters.wtkx Thu Aug 13 11:59:49 2009
@@ -20,10 +20,10 @@
xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk">
<content>
- <SplitPane orientation="vertical" splitLocation="175"
+ <SplitPane orientation="vertical" splitRatio="0.5"
preferredWidth="480" preferredHeight="360">
<top>
- <SplitPane orientation="horizontal" splitLocation="240">
+ <SplitPane orientation="horizontal" splitRatio="0.5">
<left>
<ImageView image="org/apache/pivot/tutorials/IMG_0735_2.jpg"
styles="{backgroundColor:'#404040'}"/>
Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx Thu Aug 13 11:59:49 2009
@@ -47,7 +47,7 @@
</content>
</Border>
- <SplitPane preferredWidth="472" preferredHeight="180" splitLocation="288">
+ <SplitPane preferredWidth="472" preferredHeight="180" splitRatio="0.6">
<left>
<Border>
<content>
Modified: incubator/pivot/trunk/tutorials/www/flow_panes.template.html
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/www/flow_panes.template.html?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/www/flow_panes.template.html (original)
+++ incubator/pivot/trunk/tutorials/www/flow_panes.template.html Thu Aug 13 11:59:49 2009
@@ -54,7 +54,7 @@
xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk">
<content>
- <SplitPane splitLocation="300">
+ <SplitPane splitRatio="0.5">
<left>
<Border styles="{padding:0}">
<content>
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/CornerRadii.java Thu Aug 13 11:59:49 2009
@@ -40,6 +40,11 @@
public static final String BOTTOM_LEFT_KEY = "bottomLeft";
public static final String BOTTOM_RIGHT_KEY = "bottomRight";
+ /**
+ * Corner radii whose top, left, bottom, and right values are all zero.
+ */
+ public static final CornerRadii NONE = new CornerRadii(0);
+
public CornerRadii(int radius) {
this(radius, radius, radius, radius);
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPane.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPane.java?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPane.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPane.java Thu Aug 13 11:59:49 2009
@@ -16,13 +16,9 @@
*/
package org.apache.pivot.wtk;
-import org.apache.pivot.collections.Dictionary;
import org.apache.pivot.collections.Sequence;
-import org.apache.pivot.serialization.JSONSerializer;
-import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.util.ListenerList;
-
/**
* A <tt>SplitPane</tt> is a container component that splits its size up into
* two regions, each of which is capable of holding one component. A split
@@ -52,15 +48,15 @@
private static class SplitPaneListenerList extends ListenerList<SplitPaneListener>
implements SplitPaneListener {
- public void topLeftComponentChanged(SplitPane splitPane, Component previousTopLeftComponent) {
+ public void topLeftChanged(SplitPane splitPane, Component previousTopLeft) {
for (SplitPaneListener listener : this) {
- listener.topLeftComponentChanged(splitPane, previousTopLeftComponent);
+ listener.topLeftChanged(splitPane, previousTopLeft);
}
}
- public void bottomRightComponentChanged(SplitPane splitPane, Component previousBottomRightComponent) {
+ public void bottomRightChanged(SplitPane splitPane, Component previousBottomRight) {
for (SplitPaneListener listener : this) {
- listener.bottomRightComponentChanged(splitPane, previousBottomRightComponent);
+ listener.bottomRightChanged(splitPane, previousBottomRight);
}
}
@@ -76,15 +72,9 @@
}
}
- public void splitLocationChanged(SplitPane splitPane, int previousSplitLocation) {
+ public void splitRatioChanged(SplitPane splitPane, float previousSplitRatio) {
for (SplitPaneListener listener : this) {
- listener.splitLocationChanged(splitPane, previousSplitLocation);
- }
- }
-
- public void splitBoundsChanged(SplitPane splitPane, Span previousSplitBounds) {
- for (SplitPaneListener listener : this) {
- listener.splitBoundsChanged(splitPane, previousSplitBounds);
+ listener.splitRatioChanged(splitPane, previousSplitRatio);
}
}
@@ -95,114 +85,118 @@
}
}
- Component topLeftComponent = null;
- Component bottomRightComponent = null;
+ Component topLeft = null;
+ Component bottomRight = null;
private Orientation orientation = null;
private Region primaryRegion = Region.TOP_LEFT;
- private int splitLocation = 0;
- private Span splitBounds = null;
+ private float splitRatio = 0.5f;
private boolean locked = false;
private SplitPaneListenerList splitPaneListeners = new SplitPaneListenerList();
- // TODO Define a constructor that takes 2 components as arguments
-
public SplitPane() {
this(Orientation.HORIZONTAL);
}
public SplitPane(Orientation orientation) {
+ this(orientation, null, null);
+ }
+
+ public SplitPane(Orientation orientation, Component topLeft, Component bottomRight) {
this.orientation = orientation;
installSkin(SplitPane.class);
+
+ setTopLeft(topLeft);
+ setBottomRight(bottomRight);
}
- public Component getTopLeftComponent() {
- return topLeftComponent;
+ public Component getTopLeft() {
+ return topLeft;
}
- public void setTopLeftComponent(Component topLeftComponent) {
- if (topLeftComponent != this.topLeftComponent) {
+ public void setTopLeft(Component topLeft) {
+ if (topLeft != this.topLeft) {
// Set the component as the new top/left component
- Component previousTopLeftComponent = this.topLeftComponent;
- this.topLeftComponent = topLeftComponent;
+ Component previousTopLeft = this.topLeft;
+ this.topLeft = topLeft;
// Remove any previous content component
- if (previousTopLeftComponent != null) {
- remove(previousTopLeftComponent);
+ if (previousTopLeft != null) {
+ remove(previousTopLeft);
}
- if (topLeftComponent != null) {
- if (topLeftComponent.getParent() != null) {
+ if (topLeft != null) {
+ if (topLeft.getParent() != null) {
throw new IllegalArgumentException("Component already has a parent.");
}
// Add the component
- add(topLeftComponent);
+ add(topLeft);
}
- splitPaneListeners.topLeftComponentChanged(this, previousTopLeftComponent);
+ splitPaneListeners.topLeftChanged(this, previousTopLeft);
}
}
- public Component getBottomRightComponent() {
- return bottomRightComponent;
+ public Component getBottomRight() {
+ return bottomRight;
}
- public void setBottomRightComponent(Component bottomRightComponent) {
- if (bottomRightComponent != this.bottomRightComponent) {
+ public void setBottomRight(Component bottomRight) {
+ if (bottomRight != this.bottomRight) {
// Set the component as the new bottom/right component
- Component previousBottomRightComponent = this.bottomRightComponent;
- this.bottomRightComponent = bottomRightComponent;
+ Component previousBottomRight = this.bottomRight;
+ this.bottomRight = bottomRight;
// Remove any previous content component
- if (previousBottomRightComponent != null) {
- remove(previousBottomRightComponent);
+ if (previousBottomRight != null) {
+ remove(previousBottomRight);
}
- if (bottomRightComponent != null) {
- if (bottomRightComponent.getParent() != null) {
+ if (bottomRight != null) {
+ if (bottomRight.getParent() != null) {
throw new IllegalArgumentException("Component already has a parent.");
}
// Add the component
- add(bottomRightComponent);
+ add(bottomRight);
}
- splitPaneListeners.bottomRightComponentChanged(this, previousBottomRightComponent);
+ splitPaneListeners.bottomRightChanged(this, previousBottomRight);
}
}
public Component getTop() {
- return (orientation == Orientation.HORIZONTAL) ? null : getTopLeftComponent();
+ return (orientation == Orientation.HORIZONTAL) ? null : getTopLeft();
}
public void setTop(Component component) {
- setTopLeftComponent(component);
+ setTopLeft(component);
}
public Component getBottom() {
- return (orientation == Orientation.HORIZONTAL) ? null : getBottomRightComponent();
+ return (orientation == Orientation.HORIZONTAL) ? null : getBottomRight();
}
public void setBottom(Component component) {
- setBottomRightComponent(component);
+ setBottomRight(component);
}
public Component getLeft() {
- return (orientation == Orientation.VERTICAL) ? null : getTopLeftComponent();
+ return (orientation == Orientation.VERTICAL) ? null : getTopLeft();
}
public void setLeft(Component component) {
- setTopLeftComponent(component);
+ setTopLeft(component);
}
public Component getRight() {
- return (orientation == Orientation.VERTICAL) ? null : getBottomRightComponent();
+ return (orientation == Orientation.VERTICAL) ? null : getBottomRight();
}
public void setRight(Component component) {
- setBottomRightComponent(component);
+ setBottomRight(component);
}
public Orientation getOrientation() {
@@ -253,59 +247,16 @@
setPrimaryRegion(Region.valueOf(primaryRegion.toUpperCase()));
}
- public int getSplitLocation() {
- return splitLocation;
+ public float getSplitRatio() {
+ return splitRatio;
}
- public void setSplitLocation(int splitLocation) {
- int previousSplitLocation = this.splitLocation;
-
- if (previousSplitLocation != splitLocation) {
- this.splitLocation = splitLocation;
- splitPaneListeners.splitLocationChanged(this, previousSplitLocation);
- }
- }
-
- public Span getSplitBounds() {
- return splitBounds;
- }
-
- public void setSplitBounds(Span splitBounds) {
- Span previousSplitBounds = this.splitBounds;
-
- if (previousSplitBounds != splitBounds) {
- this.splitBounds = new Span(splitBounds);
-
- // Reposition the splitter if necessary
- if (splitBounds != null) {
- if (splitLocation < splitBounds.start) {
- setSplitLocation(splitBounds.start);
- } else if (splitLocation > splitBounds.end) {
- setSplitLocation(splitBounds.end);
- }
- }
-
- splitPaneListeners.splitBoundsChanged(this, previousSplitBounds);
- }
- }
-
- public final void setSplitBounds(Dictionary<String, ?> splitBounds) {
- if (splitBounds == null) {
- throw new IllegalArgumentException("splitBounds is null.");
- }
-
- setSplitBounds(new Span(splitBounds));
- }
-
- public final void setSplitBounds(String splitBounds) {
- if (splitBounds == null) {
- throw new IllegalArgumentException("splitBounds is null.");
- }
+ public void setSplitRatio(float splitRatio) {
+ float previousSplitRatio = this.splitRatio;
- try {
- setSplitBounds(JSONSerializer.parseMap(splitBounds));
- } catch (SerializationException exception) {
- throw new IllegalArgumentException(exception);
+ if (previousSplitRatio != splitRatio) {
+ this.splitRatio = splitRatio;
+ splitPaneListeners.splitRatioChanged(this, previousSplitRatio);
}
}
@@ -324,8 +275,8 @@
public Sequence<Component> remove(int index, int count) {
for (int i = index, n = index + count; i < n; i++) {
Component component = get(i);
- if (component == topLeftComponent
- || component == bottomRightComponent) {
+ if (component == topLeft
+ || component == bottomRight) {
throw new UnsupportedOperationException();
}
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPaneListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPaneListener.java?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPaneListener.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SplitPaneListener.java Thu Aug 13 11:59:49 2009
@@ -26,17 +26,17 @@
* Called when a split pane's top left component has changed.
*
* @param splitPane
- * @param previousTopLeftComponent
+ * @param previousTopLeft
*/
- public void topLeftComponentChanged(SplitPane splitPane, Component previousTopLeftComponent);
+ public void topLeftChanged(SplitPane splitPane, Component previousTopLeft);
/**
* Called when a split pane's bottom right component has changed.
*
* @param splitPane
- * @param previousBottomRightComponent
+ * @param previousBottomRight
*/
- public void bottomRightComponentChanged(SplitPane splitPane, Component previousBottomRightComponent);
+ public void bottomRightChanged(SplitPane splitPane, Component previousBottomRight);
/**
* Called when a split pane's orientation has changed.
@@ -56,17 +56,9 @@
* Called when a split pane's split location has changed.
*
* @param splitPane
- * @param previousSplitLocation
+ * @param previousSplitRatio
*/
- public void splitLocationChanged(SplitPane splitPane, int previousSplitLocation);
-
- /**
- * Called when a split pane's split bounds have changed.
- *
- * @param splitPane
- * @param previousSplitBounds
- */
- public void splitBoundsChanged(SplitPane splitPane, Span previousSplitBounds);
+ public void splitRatioChanged(SplitPane splitPane, float previousSplitRatio);
/**
* Called when a split pane's locked flag has changed.
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java Thu Aug 13 11:59:49 2009
@@ -67,7 +67,7 @@
titleColor = Color.BLACK;
thickness = 1;
padding = new Insets(2);
- cornerRadii = new CornerRadii(0);
+ cornerRadii = CornerRadii.NONE;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java Thu Aug 13 11:59:49 2009
@@ -65,11 +65,7 @@
public final Component toCard;
public SelectionChangeTransition(int from, int to) {
- this(from, to, SELECTION_CHANGE_DURATION);
- }
-
- public SelectionChangeTransition(int from, int to, int duration) {
- super(duration, SELECTION_CHANGE_RATE, false);
+ super(SELECTION_CHANGE_DURATION, SELECTION_CHANGE_RATE, false);
this.from = from;
this.to = to;
@@ -196,7 +192,7 @@
private ScaleDecorator scaleDecorator = new ScaleDecorator();
public FlipTransition(Orientation orientation, int from, int to) {
- super(from, to, 350);
+ super(from, to);
this.orientation = orientation;
}
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=803852&r1=803851&r2=803852&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 Thu Aug 13 11:59:49 2009
@@ -84,7 +84,7 @@
private DropShadowDecorator dropShadowDecorator = null;
- private static final int TRANSITION_DURATION = 250;
+ private static final int TRANSITION_DURATION = 300;
private static final int TRANSITION_RATE = 30;
public TerraSheetSkin() {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSplitPaneSkin.java Thu Aug 13 11:59:49 2009
@@ -19,28 +19,24 @@
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
-
import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.Cursor;
import org.apache.pivot.wtk.Dimensions;
import org.apache.pivot.wtk.GraphicsUtilities;
import org.apache.pivot.wtk.Mouse;
import org.apache.pivot.wtk.Orientation;
-import org.apache.pivot.wtk.Span;
import org.apache.pivot.wtk.SplitPane;
import org.apache.pivot.wtk.SplitPaneListener;
import org.apache.pivot.wtk.Theme;
import org.apache.pivot.wtk.skin.ComponentSkin;
import org.apache.pivot.wtk.skin.ContainerSkin;
-
/**
* Split pane skin.
*
* @author tvolkert
*/
-public class TerraSplitPaneSkin extends ContainerSkin
- implements SplitPaneListener {
+public class TerraSplitPaneSkin extends ContainerSkin implements SplitPaneListener {
/**
* Split pane splitter component.
@@ -86,7 +82,7 @@
}
public void paint(Graphics2D graphics) {
- SplitPane splitPane = (SplitPane)TerraSplitPaneSkin.this.getComponent();
+ SplitPane splitPane = (SplitPane) TerraSplitPaneSkin.this.getComponent();
Orientation orientation = splitPane.getOrientation();
@@ -143,23 +139,23 @@
boolean consumed = super.mouseMove(component, x, y);
if (Mouse.getCapturer() == component) {
- SplitPane splitPane = (SplitPane)TerraSplitPaneSkin.this.getComponent();
+ SplitPane splitPane = (SplitPane) TerraSplitPaneSkin.this.getComponent();
Orientation orientation = splitPane.getOrientation();
// Calculate the would-be new split location
int splitLocation;
+ float splitRatio;
if (orientation == Orientation.HORIZONTAL) {
- splitLocation = component.getX() + x - dragOffset;
+ splitLocation = limitSplitLocation(component.getX() + x - dragOffset);
+ splitRatio = (float) splitLocation / splitPane.getWidth();
} else {
- splitLocation = component.getY() + y - dragOffset;
+ splitLocation = limitSplitLocation(component.getY() + y - dragOffset);
+ splitRatio = (float) splitLocation / splitPane.getHeight();
}
- // Bound the split location
- splitLocation = boundSplitLocation(splitLocation);
-
if (shadow == null) {
// Update the split location immediately
- splitPane.setSplitLocation(splitLocation);
+ splitPane.setSplitRatio(splitRatio);
} else {
// Move the shadow to the split location
if (orientation == Orientation.HORIZONTAL) {
@@ -177,10 +173,9 @@
public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
boolean consumed = super.mouseDown(component, button, x, y);
- SplitPane splitPane = (SplitPane)TerraSplitPaneSkin.this.getComponent();
+ SplitPane splitPane = (SplitPane) TerraSplitPaneSkin.this.getComponent();
- if (button == Mouse.Button.LEFT
- && !splitPane.isLocked()) {
+ if (button == Mouse.Button.LEFT && !splitPane.isLocked()) {
Orientation orientation = splitPane.getOrientation();
if (useShadow) {
@@ -209,20 +204,22 @@
public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
boolean consumed = super.mouseUp(component, button, x, y);
- if (button == Mouse.Button.LEFT
- && Mouse.getCapturer() == component) {
+ if (button == Mouse.Button.LEFT && Mouse.getCapturer() == component) {
if (shadow != null) {
- SplitPane splitPane = (SplitPane)TerraSplitPaneSkin.this.getComponent();
+ SplitPane splitPane = (SplitPane) TerraSplitPaneSkin.this.getComponent();
// Update the split location and remove the shadow
int splitLocation;
+ float splitRatio;
if (splitPane.getOrientation() == Orientation.HORIZONTAL) {
splitLocation = shadow.getX();
+ splitRatio = (float) splitLocation / splitPane.getWidth();
} else {
splitLocation = shadow.getY();
+ splitRatio = (float) splitLocation / splitPane.getHeight();
}
- splitPane.setSplitLocation(splitLocation);
+ splitPane.setSplitRatio(splitRatio);
splitPane.remove(shadow);
shadow = null;
@@ -233,32 +230,6 @@
return consumed;
}
-
- private int boundSplitLocation(int splitLocation) {
- SplitPane splitPane = (SplitPane)TerraSplitPaneSkin.this.getComponent();
-
- int lower = 0;
- int upper;
- if (splitPane.getOrientation() == Orientation.HORIZONTAL) {
- upper = splitPane.getWidth() - splitterThickness;
- } else {
- upper = splitPane.getHeight() - splitterThickness;
- }
-
- Span bounds = splitPane.getSplitBounds();
- if (bounds != null) {
- lower = Math.max(lower, bounds.start);
- upper = Math.min(upper, bounds.end);
- }
-
- if (splitLocation < lower) {
- splitLocation = lower;
- } else if (splitLocation > upper) {
- splitLocation = upper;
- }
-
- return splitLocation;
- }
}
/**
@@ -310,7 +281,7 @@
private boolean useShadow;
public TerraSplitPaneSkin() {
- TerraTheme theme = (TerraTheme)Theme.getTheme();
+ TerraTheme theme = (TerraTheme) Theme.getTheme();
splitterHandlePrimaryColor = theme.getColor(9);
splitterHandleSecondaryColor = theme.getColor(10);
splitterThickness = 6;
@@ -321,7 +292,7 @@
public void install(Component component) {
super.install(component);
- SplitPane splitPane = (SplitPane)component;
+ SplitPane splitPane = (SplitPane) component;
splitPane.getSplitPaneListeners().add(this);
splitPane.add(splitter);
@@ -330,7 +301,7 @@
@Override
public void uninstall() {
- SplitPane splitPane = (SplitPane)getComponent();
+ SplitPane splitPane = (SplitPane) getComponent();
splitPane.getSplitPaneListeners().remove(this);
splitPane.remove(splitter);
@@ -357,38 +328,41 @@
int width = getWidth();
int height = getHeight();
- SplitPane splitPane = (SplitPane)getComponent();
- int splitLocation = splitPane.getSplitLocation();
- Component leftComponent = splitPane.getTopLeftComponent();
- Component rightComponent = splitPane.getBottomRightComponent();
+ SplitPane splitPane = (SplitPane) getComponent();
- int rightStart = splitLocation + splitterThickness;
+ float splitRatio = splitPane.getSplitRatio();
+ Component topLeft = splitPane.getTopLeft();
+ Component bottomRight = splitPane.getBottomRight();
if (splitPane.getOrientation() == Orientation.HORIZONTAL) {
+ int splitLocation = limitSplitLocation((int) (splitRatio * width));
+ int rightStart = splitLocation + splitterThickness;
splitter.setLocation(splitLocation, 0);
splitter.setSize(splitterThickness, height);
- if (leftComponent != null) {
- leftComponent.setLocation(0, 0);
- leftComponent.setSize(splitLocation, height);
+ if (topLeft != null) {
+ topLeft.setLocation(0, 0);
+ topLeft.setSize(splitLocation, height);
}
- if (rightComponent != null) {
- rightComponent.setLocation(rightStart, 0);
- rightComponent.setSize(Math.max(width - rightStart, 0), height);
+ if (bottomRight != null) {
+ bottomRight.setLocation(rightStart, 0);
+ bottomRight.setSize(Math.max(width - rightStart, 0), height);
}
} else {
+ int splitLocation = limitSplitLocation((int) (splitRatio * height));
+ int bottomStart = splitLocation + splitterThickness;
splitter.setLocation(0, splitLocation);
splitter.setSize(width, splitterThickness);
- if (leftComponent != null) {
- leftComponent.setLocation(0, 0);
- leftComponent.setSize(width, splitLocation);
+ if (topLeft != null) {
+ topLeft.setLocation(0, 0);
+ topLeft.setSize(width, splitLocation);
}
- if (rightComponent != null) {
- rightComponent.setLocation(0, rightStart);
- rightComponent.setSize(width, Math.max(height - rightStart, 0));
+ if (bottomRight != null) {
+ bottomRight.setLocation(0, bottomStart);
+ bottomRight.setSize(width, Math.max(height - bottomStart, 0));
}
}
}
@@ -415,7 +389,7 @@
}
public final void setSplitterHandlePrimaryColor(int splitterHandlePrimaryColor) {
- TerraTheme theme = (TerraTheme)Theme.getTheme();
+ TerraTheme theme = (TerraTheme) Theme.getTheme();
setSplitterHandlePrimaryColor(theme.getColor(splitterHandlePrimaryColor));
}
@@ -441,7 +415,7 @@
}
public final void setSplitterHandleSecondaryColor(int splitterHandleSecondaryColor) {
- TerraTheme theme = (TerraTheme)Theme.getTheme();
+ TerraTheme theme = (TerraTheme) Theme.getTheme();
setSplitterHandleSecondaryColor(theme.getColor(splitterHandleSecondaryColor));
}
@@ -462,11 +436,11 @@
this.useShadow = useShadow;
}
- public void topLeftComponentChanged(SplitPane splitPane, Component previousTopLeftComponent) {
+ public void topLeftChanged(SplitPane splitPane, Component previousTopLeft) {
invalidateComponent();
}
- public void bottomRightComponentChanged(SplitPane splitPane, Component previousBottomRightComponent) {
+ public void bottomRightChanged(SplitPane splitPane, Component previousBottomRight) {
invalidateComponent();
}
@@ -479,11 +453,7 @@
updateSplitterCursor();
}
- public void splitLocationChanged(SplitPane splitPane, int previousSplitLocation) {
- invalidateComponent();
- }
-
- public void splitBoundsChanged(SplitPane splitPane, Span previousSplitBounds) {
+ public void splitRatioChanged(SplitPane splitPane, float previousSplitLocation) {
invalidateComponent();
}
@@ -493,34 +463,68 @@
private void updateSplitterCursor() {
Cursor cursor = Cursor.DEFAULT;
- SplitPane splitPane = (SplitPane)getComponent();
+ SplitPane splitPane = (SplitPane) getComponent();
if (!splitPane.isLocked()) {
switch (splitPane.getOrientation()) {
- case HORIZONTAL:
- switch (splitPane.getPrimaryRegion()) {
- case TOP_LEFT:
- cursor = Cursor.RESIZE_EAST;
- break;
- case BOTTOM_RIGHT:
- cursor = Cursor.RESIZE_WEST;
+ case HORIZONTAL: {
+ switch (splitPane.getPrimaryRegion()) {
+ case TOP_LEFT:
+ cursor = Cursor.RESIZE_EAST;
+ break;
+ case BOTTOM_RIGHT:
+ cursor = Cursor.RESIZE_WEST;
+ break;
+ }
+
break;
}
- break;
- case VERTICAL:
- switch (splitPane.getPrimaryRegion()) {
- case TOP_LEFT:
- cursor = Cursor.RESIZE_SOUTH;
- break;
- case BOTTOM_RIGHT:
- cursor = Cursor.RESIZE_NORTH;
+ case VERTICAL: {
+ switch (splitPane.getPrimaryRegion()) {
+ case TOP_LEFT:
+ cursor = Cursor.RESIZE_SOUTH;
+ break;
+ case BOTTOM_RIGHT:
+ cursor = Cursor.RESIZE_NORTH;
+ break;
+ }
+
break;
}
- break;
}
}
splitter.setCursor(cursor);
}
+
+ private int limitSplitLocation(int splitLocation) {
+ SplitPane splitPane = (SplitPane) getComponent();
+
+ int lower, upper;
+ if (splitPane.getOrientation() == Orientation.HORIZONTAL) {
+ int splitWidth = splitPane.getWidth();
+ lower = splitPane.getLeft().getMinPreferredWidth();
+
+ int minChildSize = splitPane.getRight().getMinPreferredWidth();
+ upper = splitWidth - splitterThickness - (minChildSize > 0 ? minChildSize : 0);
+ } else {
+ lower = splitPane.getBottom().getMinPreferredHeight();
+ int minChildSize = splitPane.getBottom().getMinPreferredHeight();
+ upper = splitPane.getHeight() - splitterThickness
+ - (minChildSize > 0 ? minChildSize : 0);
+ }
+
+ if (splitLocation < lower) {
+ splitLocation = lower;
+ } else if (splitLocation > upper) {
+ splitLocation = upper;
+ }
+
+ if (splitLocation < 0) {
+ splitLocation = 0;
+ }
+
+ return splitLocation;
+ }
}
Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/text/test/text_area_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/text/test/text_area_test.wtkx?rev=803852&r1=803851&r2=803852&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/text/test/text_area_test.wtkx (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/text/test/text_area_test.wtkx Thu Aug 13 11:59:49 2009
@@ -16,7 +16,7 @@
limitations under the License.
-->
-<SplitPane splitLocation="420"
+<SplitPane splitRatio="0.75"
xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns:test="org.apache.pivot.wtk.text.test"
xmlns="org.apache.pivot.wtk">