From 0e448396d2ecf571fadbf94a580ff096da7f2c18 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 13 Nov 2009 08:25:32 +0000 Subject: [PATCH] Merged fix for #3647 - "GridLayout with rowspan updates the cell heights incorrectly when width shrinks" from 6.1 svn changeset:9772/svn branch:6.2 --- .../terminal/gwt/client/ui/VGridLayout.java | 22 ++++++- .../tests/layouts/GridLayoutWidthChange.java | 64 +++++++++++++++++++ 2 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 tests/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java diff --git a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java index 7e9cf96d72..e2f217267a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java @@ -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(); } diff --git a/tests/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java b/tests/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java new file mode 100644 index 0000000000..1592c3adcf --- /dev/null +++ b/tests/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java @@ -0,0 +1,64 @@ +package com.vaadin.tests.layouts; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Button.ClickEvent; + +public class GridLayoutWidthChange extends TestBase { + + private GridLayout generateLayout() { + VerticalLayout fields1 = new VerticalLayout(); + + NativeButton nb = new NativeButton("A button"); + nb.setHeight("300px"); + fields1.addComponent(nb); + + VerticalLayout fields3 = new VerticalLayout(); + fields3.addComponent(new TextField("field14")); + + NativeButton b = new NativeButton("A big button"); + b.setWidth("200px"); + b.setHeight("200px"); + + GridLayout layout = new GridLayout(3, 2); + layout.setWidth("100%"); + layout.addComponent(fields1, 0, 0, 0, 1); + layout.addComponent(b, 2, 1); + + return layout; + } + + @Override + protected void setup() { + final GridLayout layout1 = generateLayout(); + final CustomComponent cc = new CustomComponent(layout1); + cc.setWidth("500px"); + addComponent(cc); + + Button testButton = new Button("Reduce GridLayout parent width", + new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + cc.setWidth((cc.getWidth() - 10) + "px"); + } + + }); + addComponent(testButton); + } + + @Override + protected String getDescription() { + 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."; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } +} -- 2.39.5