You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/11/16 16:08:29 UTC
svn commit: r880783 - in
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin: ./ terra/
Author: tvolkert
Date: Mon Nov 16 15:08:28 2009
New Revision: 880783
URL: http://svn.apache.org/viewvc?rev=880783&view=rev
Log:
Finished baseline calculations in TablePaneSkin, TerraTreeViewSkin, TerraRollupSkin, and TerraExpanderSkin (PIVOT-340); minor fixes to BorderSkin, BoxPaneSkin, TerraListButtonSkin, and TerraTabPaneSkin
Modified:
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/TablePaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraExpanderSkin.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/TerraRollupSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
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=880783&r1=880782&r2=880783&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 16 15:08:28 2009
@@ -369,8 +369,9 @@
if (thickness < 0) {
throw new IllegalArgumentException("thickness is negative.");
}
+
this.thickness = thickness;
- repaintComponent();
+ invalidateComponent();
}
public void setThickness(Number thickness) {
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=880783&r1=880782&r2=880783&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 16 15:08:28 2009
@@ -258,13 +258,17 @@
if (component.isVisible()) {
Dimensions size;
if (fill) {
- size = new Dimensions(clientWidth, component.getPreferredHeight(clientWidth));
+ size = new Dimensions(clientWidth,
+ component.getPreferredHeight(clientWidth));
} else {
size = component.getPreferredSize();
}
if (baseline == -1) {
- baseline = component.getBaseline(size.width, size.height) + contentHeight;
+ baseline = component.getBaseline(size.width, size.height);
+ if (baseline != -1) {
+ baseline += contentHeight;
+ }
}
contentHeight += size.height + spacing;
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=880783&r1=880782&r2=880783&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 16 15:08:28 2009
@@ -411,6 +411,7 @@
@Override
public int getBaseline(int width, int height) {
+ // TODO Should this report the baseline of the currently selected card?
return -1;
}
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=880783&r1=880782&r2=880783&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 16 15:08:28 2009
@@ -453,13 +453,57 @@
@Override
public int getBaseline(int width, int height) {
+ TablePane tablePane = (TablePane)getComponent();
+
+ TablePane.RowSequence rows = tablePane.getRows();
+ TablePane.ColumnSequence columns = tablePane.getColumns();
+
+ int rowCount = rows.getLength();
+ int columnCount = columns.getLength();
+
+ int[] columnWidths = getColumnWidths(width);
+ int[] rowHeights = getRowHeights(height, columnWidths);
+ boolean[][] occupiedCells = getOccupiedCells();
+
int baseline = -1;
- // TODO Return the first available baseline by traversing cells top left to bottom right
+ int rowY = padding.top;
- // Include top padding value
- if (baseline != -1) {
- baseline += padding.top;
+ for (int i = 0; i < rowCount && baseline == -1; i++) {
+ TablePane.Row row = rows.get(i);
+ boolean rowVisible = false;
+
+ for (int j = 0, n = row.getLength(); j < n && j < columnCount && baseline == -1; j++) {
+ Component component = row.get(j);
+
+ if (component != null
+ && component.isVisible()) {
+ int columnSpan = Math.min(TablePane.getColumnSpan(component), columnCount - j);
+ int componentWidth = (columnSpan - 1) * horizontalSpacing;
+ for (int k = 0; k < columnSpan && j + k < columnCount; k++) {
+ componentWidth += columnWidths[j + k];
+ }
+
+ int rowSpan = Math.min(TablePane.getRowSpan(component), rowCount - i);
+ int componentHeight = (rowSpan - 1) * verticalSpacing;
+ for (int k = 0; k < rowSpan && i + k < rowCount; k++) {
+ componentHeight += rowHeights[i + k];
+ }
+
+ baseline = component.getBaseline(Math.max(componentWidth, 0),
+ Math.max(componentHeight, 0));
+
+ if (baseline != -1) {
+ baseline += rowY;
+ }
+ }
+
+ rowVisible |= occupiedCells[i][j];
+ }
+
+ if (rowVisible) {
+ rowY += (rowHeights[i] + verticalSpacing);
+ }
}
return baseline;
@@ -941,11 +985,9 @@
int columnSpan = TablePane.getColumnSpan(component);
for (int k = 0; k < rowSpan && i + k < rowCount; k++) {
- occupiedCells[i + k][j] = true;
- }
-
- for (int k = 0; k < columnSpan && j + k < columnCount; k++) {
- occupiedCells[i][j + k] = true;
+ for (int l = 0; l < columnSpan && j + l < columnCount; l++) {
+ occupiedCells[i + k][j + l] = true;
+ }
}
}
}
@@ -958,9 +1000,10 @@
* Gets the preferred width of a table pane column, which is defined as the
* maximum preferred width of the column's visible components.
* <p>
- * Components that span multiple columns will not be considered in the
- * calculation (even if they live in the column directly). It is up to the
- * caller to factor such components into the column widths calculation.
+ * Because their preferred width relates to the preferred widths of other
+ * columns, components that span multiple columns will not be considered in
+ * this calculation (even if they live in the column directly). It is up to
+ * the caller to factor such components into the column widths calculation.
*
* @param columnIndex
* The index of the column whose preferred width we're calculating
@@ -1024,9 +1067,10 @@
* the width of the column that the component occupies (as specified in the
* array of column widths).
* <p>
- * Components that span multiple rows will not be considered in the
- * calculation (even if they live in the column directly). It is up to the
- * caller to factor such components into the row heights calculation.
+ * Because their preferred height relates to the preferred heights of other
+ * rows, components that span multiple rows will not be considered in
+ * this calculation (even if they live in the column directly). It is up to
+ * the caller to factor such components into the row heights calculation.
*
* @param rowIndex
* The index of the row whose preferred height we're calculating
@@ -1525,8 +1569,7 @@
}
@Override
- public void rowHeightChanged(TablePane.Row row, int previousHeight,
- boolean previousRelative) {
+ public void rowHeightChanged(TablePane.Row row, int previousHeight, boolean previousRelative) {
invalidateComponent();
}
@@ -1542,8 +1585,7 @@
}
@Override
- public void columnsRemoved(TablePane tablePane, int index,
- Sequence<TablePane.Column> columns) {
+ public void columnsRemoved(TablePane tablePane, int index, Sequence<TablePane.Column> columns) {
invalidateComponent();
}
@@ -1565,22 +1607,19 @@
}
@Override
- public void cellsRemoved(TablePane.Row row, int column,
- Sequence<Component> removed) {
+ public void cellsRemoved(TablePane.Row row, int column, Sequence<Component> removed) {
invalidateComponent();
}
@Override
- public void cellUpdated(TablePane.Row row, int column,
- Component previousComponent) {
+ public void cellUpdated(TablePane.Row row, int column, Component previousComponent) {
invalidateComponent();
}
// TablePaneAttribute events
@Override
- public void rowSpanChanged(TablePane tablePane, Component component,
- int previousRowSpan) {
+ public void rowSpanChanged(TablePane tablePane, Component component, int previousRowSpan) {
invalidateComponent();
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraExpanderSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraExpanderSkin.java?rev=880783&r1=880782&r2=880783&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraExpanderSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraExpanderSkin.java Mon Nov 16 15:08:28 2009
@@ -383,6 +383,28 @@
}
@Override
+ public int getBaseline(int width, int height) {
+ Expander expander = (Expander)getComponent();
+ Component content = expander.getContent();
+
+ int baseline = -1;
+
+ if (content != null) {
+ int titleBarWidth = Math.max(width - 2, 0);
+ int titleBarHeight = titleBarTablePane.getPreferredHeight(-1);
+
+ baseline = titleBarTablePane.getBaseline(titleBarWidth, titleBarHeight);
+
+ if (baseline != -1) {
+ // Account for top border
+ baseline += 1;
+ }
+ }
+
+ return baseline;
+ }
+
+ @Override
public void layout() {
Expander expander = (Expander)getComponent();
Component content = expander.getContent();
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=880783&r1=880782&r2=880783&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 16 15:08:28 2009
@@ -540,6 +540,7 @@
}
this.listSize = listSize;
+ listViewBorder.setPreferredHeight(-1);
}
public Object getListFont() {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java?rev=880783&r1=880782&r2=880783&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraRollupSkin.java Mon Nov 16 15:08:28 2009
@@ -279,6 +279,30 @@
}
@Override
+ public int getBaseline(int width, int height) {
+ Rollup rollup = (Rollup)getComponent();
+ Component heading = rollup.getHeading();
+
+ int baseline = -1;
+
+ if (heading != null) {
+ int headingWidth, headingHeight;
+ if (fill) {
+ headingWidth = Math.max(width - rollupButton.getPreferredWidth(-1) - buffer, 0);
+ headingHeight = heading.getPreferredHeight(headingWidth);
+ } else {
+ Dimensions headingPreferredSize = heading.getPreferredSize();
+ headingWidth = headingPreferredSize.width;
+ headingHeight = headingPreferredSize.height;
+ }
+
+ baseline = heading.getBaseline(headingWidth, headingHeight);
+ }
+
+ return baseline;
+ }
+
+ @Override
public void layout() {
Rollup rollup = (Rollup)getComponent();
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java?rev=880783&r1=880782&r2=880783&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java Mon Nov 16 15:08:28 2009
@@ -1084,6 +1084,9 @@
this.buttonPadding = buttonPadding;
invalidateComponent();
+ for (Component tabButton : buttonBoxPane) {
+ tabButton.invalidate();
+ }
}
public final void setButtonPadding(int buttonPadding) {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java?rev=880783&r1=880782&r2=880783&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java Mon Nov 16 15:08:28 2009
@@ -538,6 +538,47 @@
}
@Override
+ public int getBaseline(int width, int height) {
+ int baseline = -1;
+
+ if (visibleNodes.getLength() > 0) {
+ TreeView treeView = (TreeView)getComponent();
+ TreeView.NodeRenderer nodeRenderer = treeView.getNodeRenderer();
+
+ NodeInfo nodeInfo = visibleNodes.get(0);
+
+ int nodeWidth = width - (nodeInfo.depth - 1) * (indent + spacing);
+ int nodeHeight = getNodeHeight();
+
+ boolean expanded = false;
+ boolean selected = nodeInfo.isSelected();
+ boolean highlighted = nodeInfo.isHighlighted();
+ boolean disabled = nodeInfo.isDisabled();
+
+ if (showBranchControls) {
+ if (nodeInfo instanceof BranchInfo) {
+ BranchInfo branchInfo = (BranchInfo)nodeInfo;
+ expanded = branchInfo.isExpanded();
+ }
+
+ nodeWidth -= (indent + spacing);
+ }
+
+ TreeView.NodeCheckState checkState = TreeView.NodeCheckState.UNCHECKED;
+ if (treeView.getCheckmarksEnabled()) {
+ checkState = nodeInfo.getCheckState();
+ nodeWidth -= (Math.max(indent, CHECKBOX.getWidth()) + spacing);
+ }
+
+ nodeRenderer.render(nodeInfo.data, nodeInfo.getPath(), 0, treeView, expanded, selected,
+ checkState, highlighted, disabled);
+ baseline = nodeRenderer.getBaseline(nodeWidth, nodeHeight);
+ }
+
+ return baseline;
+ }
+
+ @Override
public void layout() {
// No-op
}