From: Leif Åstrand Date: Thu, 12 Apr 2012 12:46:35 +0000 (+0300) Subject: Fix issues with minimum window sizes X-Git-Tag: 7.0.0.alpha2~59 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=215a2e419ddaaebe2d5d38012bfbfcde0576c7b3;p=vaadin-framework.git Fix issues with minimum window sizes Minimum width is only checked once per layout phase to avoid loops Maximum height is based on header and footer size instead of difference between inner and outer sizes --- diff --git a/src/com/vaadin/terminal/gwt/client/ui/window/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/window/VWindow.java index 2c5fadff3b..d08387fc6d 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/window/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/window/VWindow.java @@ -893,9 +893,10 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, } private int getDecorationHeight() { - LayoutManager layoutManager = layout.getLayoutManager(); - return layoutManager.getOuterHeight(getElement()) - - layoutManager.getInnerHeight(contentPanel.getElement()); + LayoutManager lm = layout.getLayoutManager(); + int headerHeight = lm.getOuterHeight(header); + int footerHeight = lm.getOuterHeight(footer); + return headerHeight + footerHeight; } public int getMinWidth() { @@ -905,7 +906,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, private int getDecorationWidth() { LayoutManager layoutManager = layout.getLayoutManager(); return layoutManager.getOuterWidth(getElement()) - - layoutManager.getInnerWidth(contentPanel.getElement()); + - contentPanel.getElement().getOffsetWidth(); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java b/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java index 99910aae8b..85f4213d3e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java @@ -46,6 +46,8 @@ public class WindowConnector extends AbstractComponentContainerConnector private WindowServerRPC rpc; + boolean minWidthChecked = false; + @Override public boolean delegateCaptionHandling() { return false; @@ -220,11 +222,16 @@ public class WindowConnector extends AbstractComponentContainerConnector ComponentConnector layout = window.layout; Element contentElement = window.contentPanel.getElement(); - boolean needsMinWidth = !isUndefinedWidth() || layout.isRelativeWidth(); - int minWidth = window.getMinWidth(); - if (needsMinWidth && lm.getInnerWidth(contentElement) < minWidth) { - // Use minimum width if less than a certain size - window.setWidth(minWidth + "px"); + if (!minWidthChecked) { + boolean needsMinWidth = !isUndefinedWidth() + || layout.isRelativeWidth(); + int minWidth = window.getMinWidth(); + if (needsMinWidth && lm.getInnerWidth(contentElement) < minWidth) { + minWidthChecked = true; + // Use minimum width if less than a certain size + window.setWidth(minWidth + "px"); + } + minWidthChecked = true; } boolean needsMinHeight = !isUndefinedHeight() @@ -274,6 +281,7 @@ public class WindowConnector extends AbstractComponentContainerConnector } public void postLayout() { + minWidthChecked = false; VWindow window = getWidget(); if (window.centered) { window.center();