From 215a2e419ddaaebe2d5d38012bfbfcde0576c7b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Thu, 12 Apr 2012 15:46:35 +0300 Subject: [PATCH] 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 --- .../terminal/gwt/client/ui/window/VWindow.java | 9 +++++---- .../gwt/client/ui/window/WindowConnector.java | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) 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(); -- 2.39.5