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 2010/01/22 14:34:24 UTC
svn commit: r902079 - in /pivot/trunk:
tutorials/src/org/apache/pivot/tutorials/
tutorials/src/org/apache/pivot/tutorials/stocktracker/ tutorials/www/
wtk-terra/src/org/apache/pivot/wtk/skin/terra/
Author: gbrown
Date: Fri Jan 22 13:34:24 2010
New Revision: 902079
URL: http://svn.apache.org/viewvc?rev=902079&view=rev
Log:
Re-add padding style to TerraFormSkin.
Modified:
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calendars.wtkx
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists.wtkx
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/stocktracker.detail.wtkx
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx
pivot/trunk/tutorials/www/stock-tracker.ui.xml
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calendars.wtkx
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calendars.wtkx?rev=902079&r1=902078&r2=902079&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calendars.wtkx (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/calendars.wtkx Fri Jan 22 13:34:24 2010
@@ -42,7 +42,7 @@
<BoxPane orientation="vertical">
<Label text="Calendar Buttons" styles="{font:{bold:true}}"/>
- <Form styles="{showFlagIcons:false, showFlagHighlight:false}">
+ <Form styles="{showFlagIcons:false, padding:0}">
<sections>
<Form.Section>
<CalendarButton Form.label="English (US)" locale="{language:'en', country:'us'}"/>
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists.wtkx
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists.wtkx?rev=902079&r1=902078&r2=902079&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists.wtkx (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/lists.wtkx Fri Jan 22 13:34:24 2010
@@ -120,7 +120,7 @@
<BoxPane orientation="vertical" styles="{spacing:6}">
<Label text="List Buttons" styles="{font:{bold:true}}"/>
- <Form styles="{showFlagIcons:false, showFlagHighlight:false}">
+ <Form styles="{showFlagIcons:false, padding:0}">
<sections>
<Form.Section>
<ListButton Form.label="Basic" selectedIndex="0">
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/stocktracker.detail.wtkx
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/stocktracker.detail.wtkx?rev=902079&r1=902078&r2=902079&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/stocktracker.detail.wtkx (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/stocktracker.detail.wtkx Fri Jan 22 13:34:24 2010
@@ -21,7 +21,8 @@
xmlns="org.apache.pivot.wtk">
<Label textKey="companyName" styles="{font:{size:12, bold:true}}"/>
<Separator/>
- <Form styles="{fill:true, showFlagIcons:false, showFlagHighlight:false, leftAlignLabels:true}">
+ <Form styles="{padding:0, fill:true, showFlagIcons:false, showFlagHighlight:false,
+ leftAlignLabels:true}">
<sections>
<Form.Section>
<Label Form.label="%value" textKey="value"
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx?rev=902079&r1=902078&r2=902079&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/text.wtkx Fri Jan 22 13:34:24 2010
@@ -24,7 +24,7 @@
<BoxPane orientation="vertical" styles="{fill:true,
padding:{top:2, left:4, bottom:12, right:4}}">
<Label text="Text Input" styles="{font:{bold:true}}"/>
- <Form styles="{showFlagIcons:false, showFlagHighlight:false}">
+ <Form styles="{showFlagIcons:false, showFlagHighlight:false, padding:0}">
<sections>
<Form.Section>
<TextInput Form.label="Basic" text="Pivot" textSize="12"/>
Modified: pivot/trunk/tutorials/www/stock-tracker.ui.xml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/stock-tracker.ui.xml?rev=902079&r1=902078&r2=902079&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/stock-tracker.ui.xml (original)
+++ pivot/trunk/tutorials/www/stock-tracker.ui.xml Fri Jan 22 13:34:24 2010
@@ -446,7 +446,8 @@
<source type="xml">
<![CDATA[
- <Form styles="{fill:true, showFlagIcons:false, showFlagHighlight:false, leftAlignLabels:true}">
+ <Form styles="{padding:0, fill:true, showFlagIcons:false, showFlagHighlight:false,
+ leftAlignLabels:true}">
<sections>
<Form.Section>
<Label Form.name="%value" textKey="value"
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java?rev=902079&r1=902078&r2=902079&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java Fri Jan 22 13:34:24 2010
@@ -24,6 +24,7 @@
import java.awt.geom.GeneralPath;
import org.apache.pivot.collections.ArrayList;
+import org.apache.pivot.collections.Dictionary;
import org.apache.pivot.collections.Sequence;
import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.Bounds;
@@ -54,13 +55,11 @@
/**
* Terra form skin.
* <p>
- * TODO Re-introduce padding style
- * <p>
* TODO Create a section info structure
* <p>
* TODO Drop use of BoxPane for headers and move image views out into the section info structure
* <p>
- * TODO Dynamically calculate decorator size based on component size
+ * TODO Dynamically calculate field identifier decorator size based on component size (both types)
* <p>
* TODO Animate preferred size calculations when flags change (make this configurable via
* a style flag)
@@ -166,6 +165,7 @@
private Window flagMessageWindow = new Window(flagMessageLabel);
private ArrayList<ArrayList<Label>> flagMessageLabels = new ArrayList<ArrayList<Label>>();
+ private Insets padding;
private int horizontalSpacing;
private int verticalSpacing;
private int flagImageOffset;
@@ -264,6 +264,7 @@
private static final String DEFAULT_DELIMITER = ":";
public TerraFormSkin() {
+ padding = new Insets(4);
horizontalSpacing = 6;
verticalSpacing = 6;
flagImageOffset = 4;
@@ -380,11 +381,8 @@
preferredWidth += horizontalSpacing + maximumFlagMessageWidth;
}
- preferredWidth = Math.max(preferredWidth, maximumSeparatorWidth);
-
- if (showFlagHighlight) {
- preferredWidth += FLAG_HIGHLIGHT_PADDING * 2;
- }
+ preferredWidth = Math.max(preferredWidth + padding.left + padding.right,
+ maximumSeparatorWidth);
return preferredWidth;
}
@@ -465,9 +463,7 @@
}
}
- if (showFlagHighlight) {
- preferredHeight += FLAG_HIGHLIGHT_PADDING * 2;
- }
+ preferredHeight += (padding.top + padding.bottom);
return preferredHeight;
}
@@ -552,9 +548,7 @@
sectionIndex++;
}
- if (showFlagHighlight) {
- baseline += FLAG_HIGHLIGHT_PADDING;
- }
+ baseline += padding.top;
return baseline;
}
@@ -595,9 +589,7 @@
fieldWidth = Math.max(0, fieldWidth - (horizontalSpacing + maximumFlagMessageWidth));
}
- if (showFlagHighlight) {
- fieldWidth = Math.max(0, fieldWidth - FLAG_HIGHLIGHT_PADDING * 2);
- }
+ fieldWidth = Math.max(0, fieldWidth - (padding.left + padding.right));
return fieldWidth;
}
@@ -642,18 +634,11 @@
fieldWidth = Math.max(0, fieldWidth - (horizontalSpacing + maximumFlagMessageWidth));
}
- if (showFlagHighlight) {
- fieldWidth = Math.max(0, fieldWidth - FLAG_HIGHLIGHT_PADDING * 2);
- }
+ fieldWidth = Math.max(0, fieldWidth - (padding.left + padding.right));
// Lay out the components
- int rowX = 0;
- int rowY = 0;
-
- if (showFlagHighlight) {
- rowX += FLAG_HIGHLIGHT_PADDING;
- rowY += FLAG_HIGHLIGHT_PADDING;
- }
+ int rowX = padding.left;
+ int rowY = padding.top;
for (int sectionIndex = 0, sectionCount = sections.getLength();
sectionIndex < sectionCount; sectionIndex++) {
@@ -727,20 +712,12 @@
int rowHeight = maximumAscent + maximumDescent;
// Position the row header
- int rowHeaderX = 0;
- if (showFlagHighlight) {
- rowHeaderX += FLAG_HIGHLIGHT_PADDING;
- }
-
+ int rowHeaderX = padding.left;
int rowHeaderY = rowY + (baseline - rowHeaderAscent);
rowHeader.setLocation(rowHeaderX, rowHeaderY);
// Position the field
- int fieldX = maximumRowHeaderWidth + horizontalSpacing;
- if (showFlagHighlight) {
- fieldX += FLAG_HIGHLIGHT_PADDING;
- }
-
+ int fieldX = maximumRowHeaderWidth + horizontalSpacing + padding.left;
int fieldY = rowY + (baseline - fieldAscent);
field.setLocation(fieldX, fieldY);
@@ -830,6 +807,47 @@
}
}
+ public Insets getPadding() {
+ return padding;
+ }
+
+ public void setPadding(Insets padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ this.padding = padding;
+ invalidateComponent();
+ }
+
+ public final void setPadding(Dictionary<String, ?> padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ setPadding(new Insets(padding));
+ }
+
+ public final void setPadding(int padding) {
+ setPadding(new Insets(padding));
+ }
+
+ public final void setPadding(Number padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ setPadding(padding.intValue());
+ }
+
+ public final void setPadding(String padding) {
+ if (padding == null) {
+ throw new IllegalArgumentException("padding is null.");
+ }
+
+ setPadding(Insets.decode(padding));
+ }
+
public int getHorizontalSpacing() {
return horizontalSpacing;
}