From ef744edf4a0e849932d30bd9d6870ec15f391225 Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Mon, 21 May 2012 13:27:48 +0300 Subject: [PATCH] Fixed equal expand ratio for BoxLayout (no expand ratios set for defined sized layout) --- .../gwt/client/ui/AbstractBoxLayoutConnector.java | 15 ++++++++++++++- .../components/orderedlayout/BoxLayoutTest.java | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java index 25d917b7e8..854b02018f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java @@ -216,6 +216,17 @@ public abstract class AbstractBoxLayoutConnector extends hasRelativeHeight.clear(); needsMeasure.clear(); + boolean equalExpandRatio = getWidget().vertical ? !isUndefinedHeight() + : !isUndefinedWidth(); + for (ComponentConnector child : getChildren()) { + double expandRatio = getState().getChildData().get(child) + .getExpandRatio(); + if (expandRatio > 0) { + equalExpandRatio = false; + break; + } + } + for (ComponentConnector child : getChildren()) { Slot slot = getWidget().getSlot(child); @@ -225,7 +236,9 @@ public abstract class AbstractBoxLayoutConnector extends double expandRatio = getState().getChildData().get(child) .getExpandRatio(); - if (expandRatio == 0) { + if (equalExpandRatio) { + expandRatio = 1; + } else if (expandRatio == 0) { expandRatio = -1; } slot.setExpandRatio(expandRatio); diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java index f41bc35d0e..8b96ae6f27 100644 --- a/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java @@ -53,7 +53,7 @@ public class BoxLayoutTest extends AbstractTestRoot { protected void setup(WrappedRequest request) { view = new VerticalLayout(); - view.setSizeFull(); + // view.setSizeFull(); view.setMargin(true); view.setSpacing(true); @@ -72,6 +72,7 @@ public class BoxLayoutTest extends AbstractTestRoot { private Component createHorizontalTest() { HorizontalLayout l = new HorizontalLayout(); l.setWidth("100%"); + l.setSpacing(true); Label exp; -- 2.39.5