]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test case and fix for #2411 - OrderedLayout extra pixel distribution
authorArtur Signell <artur.signell@itmill.com>
Tue, 30 Dec 2008 14:44:59 +0000 (14:44 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 30 Dec 2008 14:44:59 +0000 (14:44 +0000)
svn changeset:6369/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
src/com/itmill/toolkit/tests/tickets/Ticket2411.java [new file with mode: 0644]

index a628c3f8b1bc25ab00f6ac3fdd0e7d166ec2f12c..a9282e3bc9dedaa34bd62a792d552c0f3b9de2d8 100644 (file)
@@ -241,10 +241,13 @@ public class IOrderedLayout extends CellBasedLayout {
         if (remaining > 0) {\r
             // Some left-over pixels due to rounding errors\r
 \r
-            // Add extra pixels to first container\r
-            ChildComponentContainer firstChildContainer = getFirstChildComponentContainer();\r
-            if (firstChildContainer != null) {\r
-                firstChildContainer.expandExtra(orientation, remaining);\r
+            // Add one pixel to each container until there are no pixels left\r
+\r
+            Iterator<Widget> widgetIterator = iterator();\r
+            while (widgetIterator.hasNext() && remaining-- > 0) {\r
+                ChildComponentContainer childComponentContainer = (ChildComponentContainer) widgetIterator\r
+                        .next();\r
+                childComponentContainer.expandExtra(orientation, 1);\r
             }\r
         }\r
 \r
@@ -783,7 +786,8 @@ public class IOrderedLayout extends CellBasedLayout {
              * If the height changes as a consequence of this we must inform the\r
              * parent also\r
              */\r
-            if (isDynamicHeight() && sizeBefore.getHeight() != activeLayoutSize.getHeight()) {\r
+            if (isDynamicHeight()\r
+                    && sizeBefore.getHeight() != activeLayoutSize.getHeight()) {\r
                 Util.notifyParentOfSizeChange(this, false);\r
             }\r
 \r
diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2411.java b/src/com/itmill/toolkit/tests/tickets/Ticket2411.java
new file mode 100644 (file)
index 0000000..edf4ee0
--- /dev/null
@@ -0,0 +1,28 @@
+package com.itmill.toolkit.tests.tickets;\r
+\r
+import com.itmill.toolkit.Application;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.GridLayout;\r
+import com.itmill.toolkit.ui.Window;\r
+\r
+public class Ticket2411 extends Application {\r
+\r
+    @Override\r
+    public void init() {\r
+        Window w = new Window(getClass().getSimpleName());\r
+        setMainWindow(w);\r
+        \r
+//        VerticalLayout l = new VerticalLayout();\r
+        GridLayout l = new GridLayout();\r
+        w.setLayout(l);\r
+        \r
+        l.setHeight("504px");\r
+        \r
+        for (int i=1; i <= 5; i++) {\r
+            Button b = new Button("Button "+i+" should be 100px or 101px high");\r
+            b.setHeight("100%");\r
+            l.addComponent(b);\r
+        }\r
+    }\r
+\r
+}\r