From 77aed50851264cf89025fcf0a082e83027d90f68 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 5 Feb 2013 11:59:42 +0200 Subject: Fixed middle vertical alignments in HorizontalLayout #10852 Change-Id: I85dac7b89ec4ec670cf92e5c760090fbef5929af --- .../orderedlayout/AbstractOrderedLayoutConnector.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'client/src') diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index afe81c79a0..77def89e9e 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -196,6 +196,12 @@ public abstract class AbstractOrderedLayoutConnector extends */ private boolean hasChildrenWithRelativeHeight = false; + /** + * Keep track of whether any child is middle aligned. Used to determine if + * measurements are needed to make middle aligned children work. + */ + private boolean hasChildrenWithMiddleAlignment = false; + /** * Keeps track of whether slots should be expanded based on available space. */ @@ -340,6 +346,7 @@ public abstract class AbstractOrderedLayoutConnector extends processedResponseId = lastResponseId; hasChildrenWithRelativeHeight = false; + hasChildrenWithMiddleAlignment = false; needsExpand = getWidget().vertical ? !isUndefinedHeight() : !isUndefinedWidth(); @@ -380,6 +387,10 @@ public abstract class AbstractOrderedLayoutConnector extends getState().childData.get(child).alignmentBitmask); slot.setAlignment(alignment); + if (alignment.isVerticalCenter()) { + hasChildrenWithMiddleAlignment = true; + } + double expandRatio = onlyZeroExpands ? 1 : getState().childData .get(child).expandRatio; @@ -429,8 +440,10 @@ public abstract class AbstractOrderedLayoutConnector extends return false; } - else if (!hasChildrenWithRelativeHeight) { - // Already works if there are no relative heights + else if (!hasChildrenWithRelativeHeight + && !hasChildrenWithMiddleAlignment) { + // Already works if there are no relative heights or middle aligned + // children return false; } -- cgit v1.2.3