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/10 16:18:30 UTC

svn commit: r834495 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: effects/ skin/ skin/terra/

Author: gbrown
Date: Tue Nov 10 15:18:30 2009
New Revision: 834495

URL: http://svn.apache.org/viewvc?rev=834495&view=rev
Log:
Additional baseline updates and fixes.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.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/ScrollPaneSkin.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/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/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/TerraSpinnerSkin.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java?rev=834495&r1=834494&r2=834495&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java Tue Nov 10 15:18:30 2009
@@ -43,13 +43,22 @@
     @Override
     public void update() {
         int width = component.getWidth();
-        int baseline = component.getBaseline(width, component.getHeight());
+        int height = component.getHeight();
+        int baseline = component.getBaseline(width, height);
 
-        if (baseline != -1) {
-            graphics.setPaint(Color.RED);
-            GraphicsUtilities.drawLine(graphics, 0, baseline, width, Orientation.HORIZONTAL);
+        int y;
+        Color color;
+        if (baseline == -1) {
+            y = height / 2;
+            color = Color.BLUE;
+        } else {
+            y = baseline;
+            color = Color.RED;
         }
 
+        graphics.setPaint(color);
+        GraphicsUtilities.drawLine(graphics, 0, y, width, Orientation.HORIZONTAL);
+
         component = null;
         graphics = null;
     }

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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -159,11 +159,12 @@
                 topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
             }
 
-            width = Math.max(width - (thickness * 2) - padding.left - padding.right, 0);
-            height = Math.max(height - (topThickness + thickness) -
-                padding.top - padding.bottom, 0);
+            int clientWidth = Math.max(width - (thickness * 2)
+                - (padding.left + padding.right), 0);
+            int clientHeight = Math.max(height - (topThickness + thickness) -
+                (padding.top + padding.bottom), 0);
 
-            baseline = content.getBaseline(width, height);
+            baseline = content.getBaseline(clientWidth, clientHeight);
         }
 
         // Include top padding value and top border 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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -202,25 +202,40 @@
         BoxPane boxPane = (BoxPane)getComponent();
 
         int baseline = -1;
-
-        width = Math.max(width - (padding.left + padding.right), 0);
-        height = Math.max(height - (padding.top + padding.bottom), 0);
-
         int contentHeight = 0;
 
         switch (boxPane.getOrientation()) {
             case HORIZONTAL: {
+                int clientHeight = Math.max(height - (padding.top + padding.bottom), 0);
+
                 for (Component component : boxPane) {
                     if (component.isVisible()) {
                         Dimensions size;
                         if (fill) {
-                            size = new Dimensions(component.getPreferredWidth(height), height);
+                            size = new Dimensions(component.getPreferredWidth(clientHeight), clientHeight);
                         } else {
                             size = component.getPreferredSize();
                         }
 
                         contentHeight = Math.max(contentHeight, size.height);
-                        baseline = Math.max(baseline, component.getBaseline(size.width, size.height));
+
+                        int componentBaseline = component.getBaseline(size.width, size.height);
+
+                        if (!fill) {
+                            switch (verticalAlignment) {
+                                case CENTER: {
+                                    componentBaseline += (clientHeight - size.height) / 2;
+                                    break;
+                                }
+
+                                case BOTTOM: {
+                                    componentBaseline += clientHeight - size.height;
+                                    break;
+                                }
+                            }
+                        }
+
+                        baseline = Math.max(baseline, componentBaseline);
                     }
                 }
 
@@ -228,11 +243,13 @@
             }
 
             case VERTICAL: {
+                int clientWidth = Math.max(width - (padding.left + padding.right), 0);
+
                 for (Component component : boxPane) {
                     if (component.isVisible()) {
                         Dimensions size;
                         if (fill) {
-                            size = new Dimensions(width, component.getPreferredHeight(width));
+                            size = new Dimensions(clientWidth, component.getPreferredHeight(clientWidth));
                         } else {
                             size = component.getPreferredSize();
                         }
@@ -251,8 +268,6 @@
             }
         }
 
-        height += (padding.top + padding.bottom);
-
         if (baseline != -1) {
             if (fill) {
                 baseline += padding.top;

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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -318,6 +318,7 @@
 
         // Delegate baseline calculation to the view component
         if (view != null) {
+            // TODO Offset baseline by the expected view y-coordinate given width and height
             baseline = view.getBaseline(width, height);
         }
 

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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -455,14 +455,6 @@
     public int getBaseline(int width, int height) {
         int baseline = -1;
 
-        TablePane tablePane = (TablePane)getComponent();
-
-        TablePane.RowSequence rows = tablePane.getRows();
-        TablePane.ColumnSequence columns = tablePane.getColumns();
-
-        int[] columnWidths = getColumnWidths(width);
-        int[] rowHeights = getRowHeights(height, columnWidths);
-
         // TODO Return the first available baseline by traversing cells top left to bottom right
 
         // Include top padding value

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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -194,10 +194,10 @@
         Button.DataRenderer dataRenderer = calendarButton.getDataRenderer();
         dataRenderer.render(calendarButton.getButtonData(), calendarButton, false);
 
-        width = Math.max(width - (TRIGGER_WIDTH + padding.left + padding.right + 2), 0);
-        height = Math.max(height - (padding.top + padding.bottom + 2), 0);
+        int clientWidth = Math.max(width - (TRIGGER_WIDTH + padding.left + padding.right + 2), 0);
+        int clientHeight = Math.max(height - (padding.top + padding.bottom + 2), 0);
 
-        int baseline = dataRenderer.getBaseline(width, height);
+        int baseline = dataRenderer.getBaseline(clientWidth, clientHeight);
 
         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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -142,8 +142,8 @@
         Button.DataRenderer dataRenderer = checkbox.getDataRenderer();
         dataRenderer.render(checkbox.getButtonData(), checkbox, false);
 
-        width = Math.max(width - (CHECKBOX_SIZE + spacing), 0);
-        baseline = dataRenderer.getBaseline(width, height);
+        int clientWidth = Math.max(width - (CHECKBOX_SIZE + spacing), 0);
+        baseline = dataRenderer.getBaseline(clientWidth, 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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -139,10 +139,10 @@
         Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
         dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
 
-        width = Math.max(width - (TRIGGER_WIDTH + padding.left + padding.right + 2), 0);
-        height = Math.max(height - (padding.top + padding.bottom + 2), 0);
+        int clientWidth = Math.max(width - (TRIGGER_WIDTH + padding.left + padding.right + 2), 0);
+        int clientHeight = Math.max(height - (padding.top + padding.bottom + 2), 0);
 
-        int baseline = dataRenderer.getBaseline(width, height);
+        int baseline = dataRenderer.getBaseline(clientWidth, clientHeight);
 
         if (baseline != -1) {
             baseline += padding.top + 1;

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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -221,10 +221,10 @@
         Button.DataRenderer dataRenderer = listButton.getDataRenderer();
         dataRenderer.render(listButton.getButtonData(), listButton, false);
 
-        width = Math.max(width - (TRIGGER_WIDTH + padding.left + padding.right + 2), 0);
-        height = Math.max(height - (padding.top + padding.bottom + 2), 0);
+        int clientWidth = Math.max(width - (TRIGGER_WIDTH + padding.left + padding.right + 2), 0);
+        int clientHeight = Math.max(height - (padding.top + padding.bottom + 2), 0);
 
-        int baseline = dataRenderer.getBaseline(width, height);
+        int baseline = dataRenderer.getBaseline(clientWidth, clientHeight);
 
         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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -142,14 +142,15 @@
 
         int baseline = -1;
 
+        int clientWidth = width;
         if (listView.getCheckmarksEnabled()) {
-            width = Math.max(width - (CHECKBOX.getWidth() + (checkboxPadding.left
+            clientWidth = Math.max(clientWidth - (CHECKBOX.getWidth() + (checkboxPadding.left
                 + checkboxPadding.right)), 0);
         }
 
         ListView.ItemRenderer itemRenderer = listView.getItemRenderer();
         itemRenderer.render(null, -1, listView, false, false, false, false);
-        baseline = itemRenderer.getBaseline(width, getItemHeight());
+        baseline = itemRenderer.getBaseline(clientWidth, getItemHeight());
 
         return baseline;
     }

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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -139,10 +139,10 @@
         Button.DataRenderer dataRenderer = menuButton.getDataRenderer();
         dataRenderer.render(menuButton.getButtonData(), menuButton, false);
 
-        width = Math.max(width - (TRIGGER_WIDTH + padding.left + padding.right + 2), 0);
-        height = Math.max(height - (padding.top + padding.bottom + 2), 0);
+        int clientWidth = Math.max(width - (TRIGGER_WIDTH + padding.left + padding.right + 2), 0);
+        int clientHeight = Math.max(height - (padding.top + padding.bottom + 2), 0);
 
-        int baseline = dataRenderer.getBaseline(width, height);
+        int baseline = dataRenderer.getBaseline(clientWidth, clientHeight);
 
         if (baseline != -1) {
             baseline += padding.top + 1;

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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -174,15 +174,13 @@
     public int getBaseline(int width, int height) {
         PushButton pushButton = (PushButton) getComponent();
 
-        int baseline = -1;
-
         Button.DataRenderer dataRenderer = pushButton.getDataRenderer();
         dataRenderer.render(pushButton.getButtonData(), pushButton, false);
 
-        width = Math.max(width - (padding.left + padding.right + 2), 0);
-        height = Math.max(height - (padding.top + padding.bottom + 2), 0);
+        int clientWidth = Math.max(width - (padding.left + padding.right + 2), 0);
+        int clientHeight = Math.max(height - (padding.top + padding.bottom + 2), 0);
 
-        baseline = dataRenderer.getBaseline(width, height);
+        int baseline = dataRenderer.getBaseline(clientWidth, clientHeight);
 
         if (baseline != -1) {
             baseline += padding.top + 1;

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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -128,8 +128,8 @@
         Button.DataRenderer dataRenderer = radioButton.getDataRenderer();
         dataRenderer.render(radioButton.getButtonData(), radioButton, false);
 
-        width = Math.max(width - (BUTTON_DIAMETER + spacing), 0);
-        baseline = dataRenderer.getBaseline(width, height);
+        int clientWidth = Math.max(width - (BUTTON_DIAMETER + spacing), 0);
+        baseline = dataRenderer.getBaseline(clientWidth, height);
 
         return baseline;
     }

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=834495&r1=834494&r2=834495&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 Tue Nov 10 15:18:30 2009
@@ -593,10 +593,11 @@
         int buttonWidth = Math.max(upButtonPreferredSize.width,
             downButtonPreferredSize.width);
 
-        width = Math.max(width - buttonWidth - 2, 0);
-        height = Math.max(height - 2, 0);
+        int clientWidth = Math.max(width - buttonWidth - 2, 0);
+        int clientHeight = Math.max(height - 2, 0);
+
+        int baseline = spinnerContent.getBaseline(clientWidth, clientHeight);
 
-        int baseline = spinnerContent.getBaseline(width, height);
         if (baseline != -1) {
             baseline += 1;
         }