You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2011/12/13 19:33:00 UTC

svn commit: r1213836 - /pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java

Author: rwhitcomb
Date: Tue Dec 13 18:33:00 2011
New Revision: 1213836

URL: http://svn.apache.org/viewvc?rev=1213836&view=rev
Log:
PIVOT-828
In FillPane.layout, make sure to ignore invisible childrent when setting
position and size.  The number of components calculation used to divide
up the area was including everything instead of only the visible ones
which actually caused a hole to the right or bottom (depending on
orientation).  Corrected the calculations to count the visible ones
and use that to divide up the area.

Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java?rev=1213836&r1=1213835&r2=1213836&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FillPaneSkin.java Tue Dec 13 18:33:00 2011
@@ -247,7 +247,16 @@ public class FillPaneSkin extends Contai
     @Override
     public void layout() {
         FillPane fillPane = (FillPane)getComponent();
-        int n = fillPane.getLength();
+        // n is the number of 'visible' components
+        // len is the total number of components
+        int n = 0;
+        int len = fillPane.getLength();
+        for (int i = 0; i < len; i++) {
+            Component component = fillPane.get(i);
+            if (component.isVisible()) {
+                n++;
+            }
+        }
 
         int width = getWidth();
         int height = getHeight();
@@ -266,12 +275,12 @@ public class FillPaneSkin extends Contai
             int leftoverWidth = totalWidth - (dividedWidth * n);
 
             // Lay out the components
-            for (int i = 0; i < n; i++) {
+            for (int i = 0, j = 0; i < len; i++) {
                 Component component = fillPane.get(i);
 
                 if (component.isVisible()) {
                     int componentWidth = dividedWidth;
-                    if (i == n - 1)
+                    if (j == n - 1)
                         componentWidth += leftoverWidth;
 
                     int componentHeight = Math.max(height - (padding.top
@@ -285,6 +294,7 @@ public class FillPaneSkin extends Contai
 
                     // Increment the x-coordinate
                     x += componentWidth + spacing;
+                    j++;
                 }
             }
         } else {
@@ -297,12 +307,12 @@ public class FillPaneSkin extends Contai
             int leftoverHeight = totalHeight - (dividedHeight * n);
 
             // Lay out the components
-            for (int i = 0; i < n; i++) {
+            for (int i = 0, j = 0; i < len; i++) {
                 Component component = fillPane.get(i);
 
                 if (component.isVisible()) {
                     int componentHeight = dividedHeight;
-                    if (i == n - 1)
+                    if (j == n - 1)
                         componentHeight += leftoverHeight;
 
                     int componentWidth = Math.max(width - (padding.left
@@ -316,6 +326,7 @@ public class FillPaneSkin extends Contai
 
                     // Increment the y-coordinate
                     y += componentHeight + spacing;
+                    j++;
                 }
             }
         }