]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix issues with minimum window sizes
authorLeif Åstrand <leif@vaadin.com>
Thu, 12 Apr 2012 12:46:35 +0000 (15:46 +0300)
committerLeif Åstrand <leif@vaadin.com>
Thu, 12 Apr 2012 12:46:50 +0000 (15:46 +0300)
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

src/com/vaadin/terminal/gwt/client/ui/window/VWindow.java
src/com/vaadin/terminal/gwt/client/ui/window/WindowConnector.java

index 2c5fadff3ba9a5d75512153aebeb2ab12156509c..d08387fc6d269e228898d20ebd566f424a01959b 100644 (file)
@@ -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();
     }
 
 }
index 99910aae8bb33bcec7fb4bb91528c840e0333b8e..85f4213d3e4601ad867f4393eb4baec89d676fd7 100644 (file)
@@ -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();