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/11/09 15:04:45 UTC
svn commit: r834071 - in
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: ./ content/ skin/
skin/terra/
Author: gbrown
Date: Mon Nov 9 14:04:01 2009
New Revision: 834071
URL: http://svn.apache.org/viewvc?rev=834071&view=rev
Log:
Add height argument to ConstrainedVisual#getBaseline().
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SliderListener.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CardPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/StackPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraLinkButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.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=834071&r1=834070&r2=834071&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 Mon Nov 9 14:04:01 2009
@@ -1452,12 +1452,13 @@
/**
* Returns the component's baseline for a given width.
*
- * @return The component's baseline relative to the origin of the parent
- * container. -1 indicates that no baseline exists.
+ * @return
+ * The baseline relative to the origin of this component, or <tt>-1</tt> if
+ * this component does not have a baseline.
*/
@Override
- public int getBaseline(int width) {
- return skin.getBaseline(width);
+ public int getBaseline(int width, int height) {
+ return skin.getBaseline(width, height);
}
/**
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ConstrainedVisual.java Mon Nov 9 14:04:01 2009
@@ -54,11 +54,14 @@
public Dimensions getPreferredSize();
/**
- * Returns the baseline for a given width.
+ * Returns the baseline for a given width and height.
+ *
+ * @param width
+ * @param height
*
* @return
* The baseline relative to the origin of this visual, or <tt>-1</tt> if
* this visual does not have a baseline.
*/
- public int getBaseline(int width);
+ public int getBaseline(int width, int height);
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Slider.java Mon Nov 9 14:04:01 2009
@@ -68,10 +68,10 @@
public Slider(Orientation orientation) {
this.orientation = orientation;
-
+
installThemeSkin(Slider.class);
}
-
+
public int getStart() {
return start;
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SliderListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SliderListener.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SliderListener.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/SliderListener.java Mon Nov 9 14:04:01 2009
@@ -28,7 +28,7 @@
* @param previousEnd
*/
public void rangeChanged(Slider slider, int previousStart, int previousEnd);
-
+
/**
* Called when a sliders's orientation has changed.
*
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java Mon Nov 9 14:04:01 2009
@@ -305,19 +305,10 @@
}
@Override
- public int getBaseline(int width) {
- // Our baseline is the maximum of all our possible renderers'
- // baseline
- int baseline = defaultRenderer.getBaseline(width);
-
- for (Class<?> key : cellRenderers) {
- TableView.CellRenderer renderer = cellRenderers.get(key);
- baseline = Math.max(baseline,
- renderer.getBaseline(width));
- }
-
- return baseline;
+ public int getBaseline(int width, int height) {
+ return -1;
}
+
@Override
public Dictionary<String, Object> getStyles() {
return STYLES;
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=834071&r1=834070&r2=834071&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 Mon Nov 9 14:04:01 2009
@@ -89,8 +89,7 @@
preferredWidth = (int)Math.ceil(headingBounds.getWidth());
LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
- topThickness = Math.max((int)Math.ceil(lm.getAscent() + lm.getDescent()
- + lm.getLeading()), topThickness);
+ topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
}
Component content = border.getContent();
@@ -119,8 +118,7 @@
if (title != null
&& title.length() > 0) {
LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
- topThickness = Math.max((int)Math.ceil(lm.getAscent() + lm.getDescent()
- + lm.getLeading()), topThickness);
+ topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
}
Component content = border.getContent();
@@ -145,7 +143,7 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
int baseline = -1;
Border border = (Border)getComponent();
@@ -158,15 +156,14 @@
if (title != null
&& title.length() > 0) {
LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
- topThickness = Math.max((int)Math.ceil(lm.getAscent() + lm.getDescent()
- + lm.getLeading()), topThickness);
+ topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
}
- if (width != -1) {
- width = Math.max(width - (thickness * 2) - padding.left - padding.right, 0);
- }
+ width = Math.max(width - (thickness * 2) - padding.left - padding.right, 0);
+ height = Math.max(height - (topThickness + thickness) -
+ padding.top - padding.bottom, 0);
- baseline = content.getBaseline(width);
+ baseline = content.getBaseline(width, height);
}
// Include top padding value and top border thickness
@@ -189,8 +186,7 @@
if (title != null
&& title.length() > 0) {
LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
- topThickness = Math.max((int)Math.ceil(lm.getAscent() + lm.getDescent()
- + lm.getLeading()), topThickness);
+ topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
}
Component content = border.getContent();
@@ -218,8 +214,7 @@
&& title.length() > 0) {
LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
titleAscent = lm.getAscent();
- topThickness = Math.max((int)Math.ceil(titleAscent
- + lm.getDescent() + lm.getLeading()), topThickness);
+ topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
}
// TODO Java2D doesn't support variable corner radii; we'll need to
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BoxPaneSkin.java Mon Nov 9 14:04:01 2009
@@ -138,36 +138,14 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
BoxPane boxPane = (BoxPane)getComponent();
int baseline = -1;
- Orientation orientation = boxPane.getOrientation();
- if (orientation == Orientation.VERTICAL) {
- // Include padding in constraint
- if (width != -1) {
- width = Math.max(width - (padding.left + padding.right), 0);
- }
-
- // find the first visible component
- for (int i = 0, n = boxPane.getLength(); i < n; i++) {
- Component component = boxPane.get(i);
- if (component.isVisible()) {
- baseline = component.getBaseline(fill ? width : -1);
- break;
- }
- }
- } else {
- // Baseline is the maximum baseline of all components
- for (int i = 0, n = boxPane.getLength(); i < n; i++) {
- Component component = boxPane.get(i);
-
- if (component.isVisible()) {
- baseline = Math.max(baseline, component.getBaseline(-1));
- }
- }
- }
+ // TODO Return the baseline of the first component that has a valid baseline
+ // NOTE For vertical box panes, be sure to constrain width appropriately when fill
+ // is set to true
// Include top and bottom padding values
if (baseline != -1) {
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=834071&r1=834070&r2=834071&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 Mon Nov 9 14:04:01 2009
@@ -410,24 +410,8 @@
}
@Override
- public int getBaseline(int width) {
- int baseline = -1;
-
- CardPane cardPane = (CardPane)getComponent();
-
- if (sizeToSelection) {
- Component selectedCard = cardPane.getSelectedCard();
-
- if (selectedCard != null) {
- baseline = selectedCard.getBaseline(width);
- }
- } else {
- for (Component card : cardPane) {
- baseline = Math.max(baseline, card.getBaseline(width));
- }
- }
-
- return baseline;
+ public int getBaseline(int width, int height) {
+ return -1;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java Mon Nov 9 14:04:01 2009
@@ -124,7 +124,7 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
return -1;
}
@@ -391,7 +391,7 @@
protected final void drawBaselineDebug(Graphics2D graphics) {
int width = getWidth();
- int baseline = getBaseline(width);
+ int baseline = getBaseline(width, getHeight());
if (baseline != -1) {
graphics.setPaint(Color.RED);
GraphicsUtilities.drawLine(graphics, 0, baseline, width, Orientation.HORIZONTAL);
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java Mon Nov 9 14:04:01 2009
@@ -67,6 +67,8 @@
@Override
public int getPreferredHeight(int width) {
+ // TODO Account for baseline in these calculations
+
FlowPane flowPane = (FlowPane)getComponent();
int preferredHeight = 0;
@@ -131,6 +133,8 @@
@Override
public Dimensions getPreferredSize() {
+ // TODO Account for baseline in these calculations
+
FlowPane flowPane = (FlowPane)getComponent();
int preferredWidth = 0;
@@ -161,7 +165,7 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
FlowPane flowPane = (FlowPane)getComponent();
int baseline = -1;
@@ -177,13 +181,15 @@
if (component.isVisible()) {
Dimensions componentSize = component.getPreferredSize();
- if (rowWidth + componentSize.width > contentWidth && rowWidth > 0) {
+ if (rowWidth + componentSize.width > contentWidth
+ && rowWidth > 0) {
// The component is too big to fit in the remaining space,
// and it is not the only component in this row; wrap
break;
}
- baseline = Math.max(baseline, component.getBaseline(componentSize.width));
+ baseline = Math.max(baseline, component.getBaseline(componentSize.width,
+ componentSize.height));
rowWidth += componentSize.width + horizontalSpacing;
}
}
@@ -256,7 +262,8 @@
for (Component component : row) {
rowWidth += component.getWidth();
rowHeight = Math.max(rowHeight, component.getHeight());
- baseline = Math.max(baseline, component.getBaseline(component.getWidth()));
+ baseline = Math.max(baseline, component.getBaseline(component.getWidth(),
+ component.getHeight()));
}
rowWidth += horizontalSpacing * (row.getLength() - 1);
@@ -281,7 +288,8 @@
int y;
if (alignToBaseline && baseline != -1) {
// Align to baseline
- y = baseline - component.getBaseline(component.getWidth());
+ y = baseline - component.getBaseline(component.getWidth(),
+ component.getHeight());
} else {
// Align to bottom
y = rowHeight - component.getHeight();
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java Mon Nov 9 14:04:01 2009
@@ -178,7 +178,8 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
+ // TODO
LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
return (int)Math.ceil(lm.getAscent() - 2);
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ScrollPaneSkin.java Mon Nov 9 14:04:01 2009
@@ -308,15 +308,17 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
int baseline = -1;
ScrollPane scrollPane = (ScrollPane)getComponent();
Component view = scrollPane.getView();
+ // TODO Look for baseline in column header, then row header, then view
+
// Delegate baseline calculation to the view component
if (view != null) {
- baseline = view.getBaseline(width);
+ baseline = view.getBaseline(width, height);
}
return baseline;
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/StackPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/StackPaneSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/StackPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/StackPaneSkin.java Mon Nov 9 14:04:01 2009
@@ -82,15 +82,8 @@
}
@Override
- public int getBaseline(int width) {
- int baseline = -1;
- StackPane stackPane = (StackPane) getComponent();
-
- for (Component component : stackPane) {
- baseline = Math.max(baseline, component.getBaseline(width));
- }
-
- return baseline;
+ public int getBaseline(int width, int height) {
+ return -1;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TablePaneSkin.java Mon Nov 9 14:04:01 2009
@@ -452,7 +452,7 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
int baseline = -1;
TablePane tablePane = (TablePane)getComponent();
@@ -460,28 +460,10 @@
TablePane.RowSequence rows = tablePane.getRows();
TablePane.ColumnSequence columns = tablePane.getColumns();
- int columnCount = columns.getLength();
-
- if (width < 0) {
- width = getPreferredWidth(-1);
- }
-
int[] columnWidths = getColumnWidths(width);
+ int[] rowHeights = getRowHeights(height, columnWidths);
- // Baseline is the maximum baseline of all components in the first row,
- // excluding non-visible components and row-spanning components.
- if (rows.getLength() > 0) {
- TablePane.Row row = rows.get(0);
-
- for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) {
- Component component = row.get(j);
-
- if (TablePane.getRowSpan(component) == 1
- && component.isVisible()) {
- baseline = Math.max(baseline, component.getBaseline(columnWidths[j]));
- }
- }
- }
+ // TODO Return the first available baseline by traversing cells top left to bottom right
// Include top padding value
if (baseline != -1) {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCalendarButtonSkin.java Mon Nov 9 14:04:01 2009
@@ -182,13 +182,15 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
CalendarButton calendarButton = (CalendarButton) getComponent();
- Button.DataRenderer dataRenderer = calendarButton.getDataRenderer();
+ // TODO Adjust width and height for padding/border/trigger
+
+ Button.DataRenderer dataRenderer = calendarButton.getDataRenderer();
dataRenderer.render(calendarButton.getButtonData(), calendarButton, false);
+ int baseline = dataRenderer.getBaseline(width, height);
- int baseline = dataRenderer.getBaseline(width);
if (baseline != -1) {
baseline += padding.top + 1;
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraCheckboxSkin.java Mon Nov 9 14:04:01 2009
@@ -134,22 +134,16 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
Checkbox checkbox = (Checkbox) getComponent();
- Button.DataRenderer dataRenderer = checkbox.getDataRenderer();
int baseline = -1;
- Object buttonData = checkbox.getButtonData();
- if (buttonData != null) {
- if (width != -1) {
- width = Math.max(width - (CHECKBOX_SIZE + spacing), 0);
- }
-
- dataRenderer.render(checkbox.getButtonData(), checkbox, false);
+ Button.DataRenderer dataRenderer = checkbox.getDataRenderer();
+ dataRenderer.render(checkbox.getButtonData(), checkbox, false);
- baseline = dataRenderer.getBaseline(width);
- }
+ width = Math.max(width - (CHECKBOX_SIZE + spacing), 0);
+ baseline = dataRenderer.getBaseline(width, height);
return baseline;
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java Mon Nov 9 14:04:01 2009
@@ -119,13 +119,14 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
- Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
- dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
+ // TODO Adjust width and height for padding/border/trigger
- int baseline = dataRenderer.getBaseline(width);
+ Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
+ dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
+ int baseline = dataRenderer.getBaseline(width, height);
if (baseline != -1) {
baseline += padding.top + 1;
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java Mon Nov 9 14:04:01 2009
@@ -169,25 +169,29 @@
if (field.isVisible()) {
Label label = labels.get(sectionIndex).get(fieldIndex);
+ Dimensions labelSize = label.getPreferredSize();
+
int preferredRowHeight;
if (alignToBaseline) {
- int labelBaseLine = label.getBaseline(-1);
- int fieldBaseLine = field.getBaseline(-1);
- if (labelBaseLine != -1 && fieldBaseLine != -1) {
- int labelPreferredHeight = label.getPreferredHeight(-1);
+ int labelBaseLine = label.getBaseline(labelSize.width, labelSize.height);
+ int fieldBaseLine = field.getBaseline(fieldWidth,
+ field.getPreferredHeight(fieldWidth));
+
+ if (labelBaseLine != -1
+ && fieldBaseLine != -1) {
int fieldPreferredHeight = field.getPreferredHeight(fieldWidth);
int baseline = Math.max(labelBaseLine, fieldBaseLine);
int belowBaseline = Math.max(fieldPreferredHeight - fieldBaseLine,
- labelPreferredHeight - labelBaseLine);
+ labelSize.height - labelBaseLine);
preferredRowHeight = baseline + belowBaseline;
} else {
// if they don't both have baselines, default to
// non-baseline behaviour
- preferredRowHeight = Math.max(label.getPreferredHeight(-1),
+ preferredRowHeight = Math.max(labelSize.height,
field.getPreferredHeight(fieldWidth));
}
} else {
- preferredRowHeight = Math.max(label.getPreferredHeight(-1),
+ preferredRowHeight = Math.max(labelSize.height,
field.getPreferredHeight(fieldWidth));
}
preferredRowHeight = Math.max(preferredRowHeight, FLAG_IMAGE_SIZE);
@@ -290,8 +294,8 @@
int labelY;
int flagImageY;
if (alignToBaseline) {
- int labelBaseLine = label.getBaseline(label.getWidth());
- int fieldBaseLine = field.getBaseline(fieldSize.width);
+ int labelBaseLine = label.getBaseline(label.getWidth(), label.getHeight());
+ int fieldBaseLine = field.getBaseline(fieldSize.width, fieldSize.height);
if (labelBaseLine != -1 && fieldBaseLine != -1) {
int baseline = Math.max(labelBaseLine, fieldBaseLine);
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraLinkButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraLinkButtonSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraLinkButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraLinkButtonSkin.java Mon Nov 9 14:04:01 2009
@@ -75,13 +75,13 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
LinkButton linkButton = (LinkButton)getComponent();
Button.DataRenderer dataRenderer = linkButton.getDataRenderer();
dataRenderer.render(linkButton.getButtonData(), linkButton, false);
- return dataRenderer.getBaseline(width);
+ return dataRenderer.getBaseline(width, height);
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListButtonSkin.java Mon Nov 9 14:04:01 2009
@@ -199,13 +199,14 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
ListButton listButton = (ListButton)getComponent();
- Button.DataRenderer dataRenderer = listButton.getDataRenderer();
- dataRenderer.render(listButton.getButtonData(), listButton, false);
+ // TODO Adjust width and height for padding/border/trigger
- int baseline = dataRenderer.getBaseline(width);
+ Button.DataRenderer dataRenderer = listButton.getDataRenderer();
+ dataRenderer.render(listButton.getButtonData(), listButton, false);
+ int baseline = dataRenderer.getBaseline(width, height);
if (baseline != -1) {
baseline += padding.top + 1;
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraListViewSkin.java Mon Nov 9 14:04:01 2009
@@ -137,10 +137,16 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
+ ListView listView = (ListView)getComponent();
+
int baseline = -1;
- baseline = getItemBaseline(width);
+ // TODO Adjust width for checkbox width and checkbox padding
+
+ ListView.ItemRenderer renderer = listView.getItemRenderer();
+ renderer.render(null, -1, listView, false, false, false, false);
+ baseline = renderer.getBaseline(width, getItemHeight());
return baseline;
}
@@ -289,20 +295,6 @@
return itemHeight;
}
- private int getItemBaseline(int width) {
- ListView listView = (ListView)getComponent();
- ListView.ItemRenderer renderer = listView.getItemRenderer();
- renderer.render(null, -1, listView, false, false, false, false);
-
- int itemBaseline = renderer.getBaseline(width);
- if (listView.getCheckmarksEnabled()) {
- itemBaseline = Math.max(CHECKBOX.getBaseline(width) + checkboxPadding.top,
- itemBaseline);
- }
-
- return itemBaseline;
- }
-
@Override
public boolean isFocusable() {
ListView listView = (ListView)getComponent();
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMenuButtonSkin.java Mon Nov 9 14:04:01 2009
@@ -41,7 +41,6 @@
import org.apache.pivot.wtk.WindowStateListener;
import org.apache.pivot.wtk.skin.MenuButtonSkin;
-
/**
* Terra menu button skin.
*/
@@ -126,6 +125,23 @@
}
@Override
+ public int getBaseline(int width, int height) {
+ MenuButton menuButton = (MenuButton) getComponent();
+
+ // TODO Adjust width and height for padding/border/trigger
+
+ Button.DataRenderer dataRenderer = menuButton.getDataRenderer();
+ dataRenderer.render(menuButton.getButtonData(), menuButton, false);
+ int baseline = dataRenderer.getBaseline(width, height);
+
+ if (baseline != -1) {
+ baseline += padding.top + 1;
+ }
+
+ return baseline;
+ }
+
+ @Override
public void layout() {
// No-op
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java Mon Nov 9 14:04:01 2009
@@ -140,14 +140,17 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
int baseline = -1;
Meter meter = (Meter)getComponent();
String text = meter.getText();
+
if (text != null
&& text.length() > 0) {
LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+
+ // TODO Adjust for height
baseline = (int)Math.ceil(lm.getAscent() - 2);
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPushButtonSkin.java Mon Nov 9 14:04:01 2009
@@ -171,31 +171,21 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
PushButton pushButton = (PushButton) getComponent();
- Button.DataRenderer dataRenderer = pushButton.getDataRenderer();
+ int baseline = -1;
+
+ Button.DataRenderer dataRenderer = pushButton.getDataRenderer();
dataRenderer.render(pushButton.getButtonData(), pushButton, false);
- // Include padding in constraint
- int contentWidth = width;
- if (contentWidth != -1) {
- contentWidth = Math.max(contentWidth - (padding.left + padding.right + 2), 0);
- }
+ width = Math.max(width - (padding.left + padding.right + 2), 0);
+ height = Math.max(height - (padding.top + padding.bottom + 2), 0);
- int preferredHeight1 = dataRenderer.getPreferredHeight(contentWidth) + padding.top
- + padding.bottom + 2;
- int baseline = dataRenderer.getBaseline(contentWidth);
+ baseline = dataRenderer.getBaseline(width, height);
if (baseline != -1) {
baseline += padding.top + 1;
-
- // Adjust for preferred aspect ratio
- if (!Float.isNaN(maximumAspectRatio)
- && (float) width / (float) preferredHeight1 > maximumAspectRatio) {
- int preferredHeight2 = (int) (width / maximumAspectRatio);
- baseline = (int) (preferredHeight1 / (float) preferredHeight2 * baseline);
- }
}
return baseline;
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRadioButtonSkin.java Mon Nov 9 14:04:01 2009
@@ -120,17 +120,16 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
RadioButton radioButton = (RadioButton)getComponent();
- Button.DataRenderer dataRenderer = radioButton.getDataRenderer();
- dataRenderer.render(radioButton.getButtonData(), radioButton, false);
+ int baseline = -1;
- if (width != -1) {
- width = Math.max(width - (BUTTON_DIAMETER + spacing), 0);
- }
+ Button.DataRenderer dataRenderer = radioButton.getDataRenderer();
+ dataRenderer.render(radioButton.getButtonData(), radioButton, false);
- int baseline = dataRenderer.getBaseline(width);
+ width = Math.max(width - (BUTTON_DIAMETER + spacing), 0);
+ baseline = dataRenderer.getBaseline(width, height);
return baseline;
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSliderSkin.java Mon Nov 9 14:04:01 2009
@@ -21,7 +21,6 @@
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
-import java.awt.geom.Rectangle2D;
import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.Dimensions;
@@ -284,22 +283,28 @@
public int getPreferredWidth(int height) {
Slider slider = (Slider) getComponent();
+ int preferredWidth;
if (slider.getOrientation() == Orientation.HORIZONTAL) {
- return DEFAULT_WIDTH;
+ preferredWidth = DEFAULT_WIDTH;
} else {
- return thumbHeight;
+ preferredWidth = thumbHeight;
}
+
+ return preferredWidth;
}
@Override
public int getPreferredHeight(int width) {
Slider slider = (Slider) getComponent();
+ int preferredHeight;
if (slider.getOrientation() == Orientation.HORIZONTAL) {
- return thumbHeight;
+ preferredHeight = thumbHeight;
} else {
- return DEFAULT_WIDTH;
+ preferredHeight = DEFAULT_WIDTH;
}
+
+ return preferredHeight;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSpinnerSkin.java Mon Nov 9 14:04:01 2009
@@ -177,14 +177,14 @@
}
@Override
- public int getBaseline(int width) {
- int baseline = 0;
-
+ public int getBaseline(int width, int height) {
Spinner spinner = (Spinner)TerraSpinnerSkin.this.getComponent();
- Spinner.ItemRenderer itemRenderer = spinner.getItemRenderer();
+ int baseline = -1;
+
+ Spinner.ItemRenderer itemRenderer = spinner.getItemRenderer();
itemRenderer.render(spinner.getSelectedItem(), spinner);
- baseline = itemRenderer.getBaseline(width);
+ baseline = itemRenderer.getBaseline(width, height);
return baseline;
}
@@ -587,20 +587,20 @@
}
@Override
- public int getBaseline(int width) {
- if (width >= 0) {
- // Subtract the button and border width from width constraint
- Dimensions upButtonPreferredSize = upButton.getPreferredSize();
- Dimensions downButtonPreferredSize = downButton.getPreferredSize();
- int buttonWidth = Math.max(upButtonPreferredSize.width,
- downButtonPreferredSize.width);
+ public int getBaseline(int width, int height) {
+ Dimensions upButtonPreferredSize = upButton.getPreferredSize();
+ Dimensions downButtonPreferredSize = downButton.getPreferredSize();
+ int buttonWidth = Math.max(upButtonPreferredSize.width,
+ downButtonPreferredSize.width);
- width = Math.max(width - buttonWidth - 2, 0);
- }
- int baseline = spinnerContent.getBaseline(width);
+ width = Math.max(width - buttonWidth - 2, 0);
+ height = Math.max(height - 2, 0);
+
+ int baseline = spinnerContent.getBaseline(width, height);
if (baseline != -1) {
baseline += 1;
}
+
return baseline;
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=834071&r1=834070&r2=834071&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Mon Nov 9 14:04:01 2009
@@ -218,9 +218,10 @@
}
@Override
- public int getBaseline(int width) {
+ public int getBaseline(int width, int height) {
+ // TODO
LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
- return (int)Math.ceil(lm.getAscent() - 2) + (padding.top + 1);
+ return (int)Math.ceil(lm.getAscent()) + (padding.top + 1) - 2;
}
@Override