]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged fix for #3647 - "GridLayout with rowspan updates the cell heights incorrectly...
authorArtur Signell <artur.signell@itmill.com>
Fri, 13 Nov 2009 08:25:32 +0000 (08:25 +0000)
committerArtur Signell <artur.signell@itmill.com>
Fri, 13 Nov 2009 08:25:32 +0000 (08:25 +0000)
svn changeset:9772/svn branch:6.2

src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
tests/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java [new file with mode: 0644]

index 7e9cf96d7210829b77c661ecdb5a9c761018458a..e2f217267a50877350306075f4700b96b8784e91 100644 (file)
@@ -272,15 +272,31 @@ public class VGridLayout extends SimplePanel implements Paintable, Container {
                                 c.cc.updateWidgetSize();
                                 int newHeight = c.getHeight();
                                 if (columnWidths[i] < oldWidths[i]
-                                        && newHeight > minRowHeights[j]) {
+                                        && newHeight > minRowHeights[j]
+                                        && c.rowspan == 1) {
+                                    /*
+                                     * The width of this column was reduced and
+                                     * this affected the height. The height is
+                                     * now greater than the previously
+                                     * calculated minHeight for the row.
+                                     */
                                     minRowHeights[j] = newHeight;
                                     if (newHeight > rowHeights[j]) {
+                                        /*
+                                         * The new height is greater than the
+                                         * previously calculated rowHeight -> we
+                                         * need to recalculate heights later on
+                                         */
                                         rowHeights[j] = newHeight;
                                         heightChanged = true;
                                     }
                                 } else if (newHeight < minRowHeights[j]) {
-                                    // need to recalculate new minimum height
-                                    // for this row
+                                    /*
+                                     * The new height of the component is less
+                                     * than the previously calculated min row
+                                     * height. The min row height may be
+                                     * affected and must thus be recalculated
+                                     */
                                     if (dirtyRows == null) {
                                         dirtyRows = new HashSet<Integer>();
                                     }
diff --git a/tests/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java b/tests/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java
new file mode 100644 (file)
index 0000000..1592c3a
--- /dev/null
@@ -0,0 +1,64 @@
+package com.vaadin.tests.layouts;\r
+\r
+import com.vaadin.tests.components.TestBase;\r
+import com.vaadin.ui.Button;\r
+import com.vaadin.ui.CustomComponent;\r
+import com.vaadin.ui.GridLayout;\r
+import com.vaadin.ui.NativeButton;\r
+import com.vaadin.ui.TextField;\r
+import com.vaadin.ui.VerticalLayout;\r
+import com.vaadin.ui.Button.ClickEvent;\r
+\r
+public class GridLayoutWidthChange extends TestBase {\r
+\r
+    private GridLayout generateLayout() {\r
+        VerticalLayout fields1 = new VerticalLayout();\r
+\r
+        NativeButton nb = new NativeButton("A button");\r
+        nb.setHeight("300px");\r
+        fields1.addComponent(nb);\r
+\r
+        VerticalLayout fields3 = new VerticalLayout();\r
+        fields3.addComponent(new TextField("field14"));\r
+\r
+        NativeButton b = new NativeButton("A big button");\r
+        b.setWidth("200px");\r
+        b.setHeight("200px");\r
+\r
+        GridLayout layout = new GridLayout(3, 2);\r
+        layout.setWidth("100%");\r
+        layout.addComponent(fields1, 0, 0, 0, 1);\r
+        layout.addComponent(b, 2, 1);\r
+\r
+        return layout;\r
+    }\r
+\r
+    @Override\r
+    protected void setup() {\r
+        final GridLayout layout1 = generateLayout();\r
+        final CustomComponent cc = new CustomComponent(layout1);\r
+        cc.setWidth("500px");\r
+        addComponent(cc);\r
+\r
+        Button testButton = new Button("Reduce GridLayout parent width",\r
+                new Button.ClickListener() {\r
+\r
+                    public void buttonClick(ClickEvent event) {\r
+                        cc.setWidth((cc.getWidth() - 10) + "px");\r
+                    }\r
+\r
+                });\r
+        addComponent(testButton);\r
+    }\r
+\r
+    @Override\r
+    protected String getDescription() {\r
+        return "A 100% wide GridLayout is wrapped inside a CustomComponent. When the width of the CustomComponent is reduced, the size of the GridLayout should be reduced accordingly. The Buttons should stay in place vertically and just move closer to each other horizontally.";\r
+    }\r
+\r
+    @Override\r
+    protected Integer getTicketNumber() {\r
+        // TODO Auto-generated method stub\r
+        return null;\r
+    }\r
+}\r