From b84b5e9a1ae2716582bcd84e46c51a0a9974150b Mon Sep 17 00:00:00 2001 From: Jouni Koivuviita Date: Sun, 15 Apr 2012 21:24:38 +0300 Subject: [PATCH] Small optimizations to BoxLayoutConnector --- .../client/ui/AbstractBoxLayoutConnector.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java index bff4710f4a..8a0471912f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractBoxLayoutConnector.java @@ -265,7 +265,7 @@ public abstract class AbstractBoxLayoutConnector extends Slot slot = getWidget().getSlot(child.getWidget()); slot.setRelativeWidth(child.isRelativeWidth()); slot.setRelativeHeight(child.isRelativeHeight()); - if (slot.hasCaption()) { + if (slot.hasCaption() && child.isRelativeHeight()) { getWidget().updateCaptionOffset(slot.getCaptionElement()); } @@ -364,7 +364,7 @@ public abstract class AbstractBoxLayoutConnector extends public void onElementResize(ElementResizeEvent e) { resizeCount++; updateLayoutHeight(); - if (needsExpand()) { + if (needsExpand() && (isUndefinedHeight() || isUndefinedWidth())) { updateExpand(); } } @@ -376,25 +376,25 @@ public abstract class AbstractBoxLayoutConnector extends Element captionElement = (Element) e.getElement().cast(); - // TODO only apply to widgets with relative size - getWidget().updateCaptionOffset(captionElement); - // TODO take caption position into account Element widgetElement = captionElement.getParentElement() .getLastChild().cast(); if (captionElement == widgetElement) { // Caption element already detached + getLayoutManager().removeElementResizeListener(captionElement, + slotCaptionResizeListener); return; } String widgetHeight = widgetElement.getStyle().getHeight(); - // if (widgetHeight == null || !widgetHeight.endsWith("%")) { + if (widgetHeight.endsWith("%")) { + getWidget().updateCaptionOffset(captionElement); + } + int h = getLayoutManager().getOuterHeight(captionElement) - getLayoutManager().getMarginHeight(captionElement); - // System.out.println("Adding caption height: " + h); childCaptionElementHeight.put(widgetElement, h); - // } updateLayoutHeight(); @@ -420,7 +420,6 @@ public abstract class AbstractBoxLayoutConnector extends private void updateLayoutHeight() { if (needsFixedHeight() && childElementHeight.size() > 0) { int h = getMaxHeight(); - System.out.println("Max height: " + h); h += getLayoutManager().getBorderHeight(getWidget().getElement()) + getLayoutManager().getPaddingHeight( getWidget().getElement()); -- 2.39.5