From: Artur Signell Date: Tue, 30 Dec 2008 14:44:59 +0000 (+0000) Subject: Test case and fix for #2411 - OrderedLayout extra pixel distribution X-Git-Tag: 6.7.0.beta1~3438 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aa69e979147c95481f79a5570005f619bfcb3b59;p=vaadin-framework.git Test case and fix for #2411 - OrderedLayout extra pixel distribution svn changeset:6369/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java index a628c3f8b1..a9282e3bc9 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java @@ -241,10 +241,13 @@ public class IOrderedLayout extends CellBasedLayout { if (remaining > 0) { // Some left-over pixels due to rounding errors - // Add extra pixels to first container - ChildComponentContainer firstChildContainer = getFirstChildComponentContainer(); - if (firstChildContainer != null) { - firstChildContainer.expandExtra(orientation, remaining); + // Add one pixel to each container until there are no pixels left + + Iterator widgetIterator = iterator(); + while (widgetIterator.hasNext() && remaining-- > 0) { + ChildComponentContainer childComponentContainer = (ChildComponentContainer) widgetIterator + .next(); + childComponentContainer.expandExtra(orientation, 1); } } @@ -783,7 +786,8 @@ public class IOrderedLayout extends CellBasedLayout { * If the height changes as a consequence of this we must inform the * parent also */ - if (isDynamicHeight() && sizeBefore.getHeight() != activeLayoutSize.getHeight()) { + if (isDynamicHeight() + && sizeBefore.getHeight() != activeLayoutSize.getHeight()) { Util.notifyParentOfSizeChange(this, false); } diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2411.java b/src/com/itmill/toolkit/tests/tickets/Ticket2411.java new file mode 100644 index 0000000000..edf4ee0798 --- /dev/null +++ b/src/com/itmill/toolkit/tests/tickets/Ticket2411.java @@ -0,0 +1,28 @@ +package com.itmill.toolkit.tests.tickets; + +import com.itmill.toolkit.Application; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.GridLayout; +import com.itmill.toolkit.ui.Window; + +public class Ticket2411 extends Application { + + @Override + public void init() { + Window w = new Window(getClass().getSimpleName()); + setMainWindow(w); + +// VerticalLayout l = new VerticalLayout(); + GridLayout l = new GridLayout(); + w.setLayout(l); + + l.setHeight("504px"); + + for (int i=1; i <= 5; i++) { + Button b = new Button("Button "+i+" should be 100px or 101px high"); + b.setHeight("100%"); + l.addComponent(b); + } + } + +}