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:58:03 UTC

svn commit: r834518 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra: TerraAccordionSkin.java TerraTabPaneSkin.java

Author: gbrown
Date: Tue Nov 10 15:58:03 2009
New Revision: 834518

URL: http://svn.apache.org/viewvc?rev=834518&view=rev
Log:
Add baseline support to Accordion and TabPane.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java?rev=834518&r1=834517&r2=834518&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java Tue Nov 10 15:58:03 2009
@@ -138,6 +138,25 @@
         }
 
         @Override
+        public int getBaseline(int width, int height) {
+            PanelHeader panelHeader = (PanelHeader)getComponent();
+
+            Button.DataRenderer dataRenderer = panelHeader.getDataRenderer();
+            dataRenderer.render(panelHeader.getButtonData(), panelHeader, false);
+
+            int clientWidth = Math.max(width - (buttonPadding.left + buttonPadding.right + 2), 0);
+            int clientHeight = Math.max(height - (buttonPadding.top + buttonPadding.bottom + 2), 0);
+
+            int baseline = dataRenderer.getBaseline(clientWidth, clientHeight);
+
+            if (baseline != -1) {
+                baseline += buttonPadding.top + 1;
+            }
+
+            return baseline;
+        }
+
+        @Override
         public void paint(Graphics2D graphics) {
             PanelHeader panelHeader = (PanelHeader)getComponent();
 
@@ -420,6 +439,18 @@
     }
 
     @Override
+    public int getBaseline(int width, int height) {
+        int baseline = -1;
+
+        if (panelHeaders.getLength() > 0) {
+            PanelHeader firstPanelHeader = panelHeaders.get(0);
+            baseline = firstPanelHeader.getBaseline(width, firstPanelHeader.getPreferredHeight(width));
+        }
+
+        return baseline;
+    }
+
+    @Override
     public void layout() {
         Accordion accordion = (Accordion)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=834518&r1=834517&r2=834518&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 Tue Nov 10 15:58:03 2009
@@ -152,6 +152,25 @@
         }
 
         @Override
+        public int getBaseline(int width, int height) {
+            TabButton tabButton = (TabButton)getComponent();
+
+            Button.DataRenderer dataRenderer = tabButton.getDataRenderer();
+            dataRenderer.render(tabButton.getButtonData(), tabButton, false);
+
+            int clientWidth = Math.max(width - (buttonPadding.left + buttonPadding.right + 2), 0);
+            int clientHeight = Math.max(height - (buttonPadding.top + buttonPadding.bottom + 2), 0);
+
+            int baseline = dataRenderer.getBaseline(clientWidth, clientHeight);
+
+            if (baseline != -1) {
+                baseline += buttonPadding.top + 1;
+            }
+
+            return baseline;
+        }
+
+        @Override
         public void paint(Graphics2D graphics) {
             TabButton tabButton = (TabButton)getComponent();
 
@@ -665,6 +684,22 @@
         return new Dimensions(preferredWidth, preferredHeight);
     }
 
+    @Override
+    public int getBaseline(int width, int height) {
+        int baseline = -1;
+
+        if (tabOrientation == Orientation.HORIZONTAL
+            && buttonBoxPane.getLength() > 0) {
+            TabButton firstTabButton = (TabButton)buttonBoxPane.get(0);
+
+            int buttonHeight = buttonBoxPane.getPreferredHeight();
+            baseline = firstTabButton.getBaseline(firstTabButton.getPreferredWidth(buttonHeight),
+                buttonHeight);
+        }
+
+        return baseline;
+    }
+
     private int getPreferredTabWidth(int height) {
         int preferredTabWidth = 0;
 
@@ -720,7 +755,6 @@
             case HORIZONTAL: {
                 int buttonPanoramaWidth = Math.min(width, buttonPanoramaSize.width);
                 int buttonPanoramaHeight = buttonPanoramaSize.height;
-                int buttonPanoramaX = 0;
                 int buttonPanoramaY = 0;
 
                 if (corner != null) {
@@ -735,7 +769,7 @@
                     corner.setSize(cornerWidth, cornerHeight);
                 }
 
-                buttonPanorama.setLocation(buttonPanoramaX, buttonPanoramaY);
+                buttonPanorama.setLocation(0, buttonPanoramaY);
                 buttonPanorama.setSize(buttonPanoramaWidth, buttonPanoramaHeight);
 
                 tabX = padding.left + 1;
@@ -753,7 +787,6 @@
                 int buttonPanoramaHeight = Math.min(height,
                     buttonPanoramaSize.height);
                 int buttonPanoramaX = 0;
-                int buttonPanoramaY = 0;
 
                 if (corner != null) {
                     int cornerWidth = corner.getPreferredWidth(-1);
@@ -767,7 +800,7 @@
                     corner.setSize(cornerWidth, cornerHeight);
                 }
 
-                buttonPanorama.setLocation(buttonPanoramaX, buttonPanoramaY);
+                buttonPanorama.setLocation(buttonPanoramaX, 0);
                 buttonPanorama.setSize(buttonPanoramaWidth, buttonPanoramaHeight);
 
                 tabX = padding.left + buttonPanoramaX + buttonPanoramaWidth;