]> source.dussan.org Git - vaadin-framework.git/commitdiff
Limit sub window minimum size (#11510)
authorLeif Åstrand <leif@vaadin.com>
Wed, 29 May 2013 12:59:06 +0000 (15:59 +0300)
committerVaadin Code Review <review@vaadin.com>
Thu, 30 May 2013 13:30:43 +0000 (13:30 +0000)
Change-Id: I8ad89e74b058246939d77165f2d4b5abc3417886

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

index 38dfdba1b81457ee6d5ff1eb77dae9acaa9aa520..1331eb106a4c4ff44ad8dea7c9436f9e05ee6642 100644 (file)
@@ -38,7 +38,6 @@ import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.client.ApplicationConnection;
 import com.vaadin.client.BrowserInfo;
@@ -793,6 +792,9 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
         int w = Util.getTouchOrMouseClientX(event) - startX + origW;
         int h = Util.getTouchOrMouseClientY(event) - startY + origH;
 
+        w = Math.max(w, getMinWidth());
+        h = Math.max(h, getMinHeight());
+
         setWidth(w + "px");
         setHeight(h + "px");
 
@@ -811,6 +813,22 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
         }
     }
 
+    private int getMinHeight() {
+        return getPixelValue(getElement().getStyle().getProperty("minHeight"));
+    }
+
+    private int getMinWidth() {
+        return getPixelValue(getElement().getStyle().getProperty("minWidth"));
+    }
+
+    private static int getPixelValue(String size) {
+        if (size == null || !size.endsWith("px")) {
+            return -1;
+        } else {
+            return Integer.parseInt(size.substring(0, size.length() - 2));
+        }
+    }
+
     public void updateContentsSize() {
         LayoutManager layoutManager = getLayoutManager();
         layoutManager.setNeedsMeasure(ConnectorMap.get(client).getConnector(
index 90311e30ad881fc823054133ce3d6d3957bb507c..beaf549dcfbe29e6602c9543b8e57164f63a6d8f 100644 (file)
@@ -207,6 +207,14 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector
         contentStyle.setPaddingBottom(footerHeight, Unit.PX);
         contentStyle.setMarginBottom(-footerHeight, Unit.PX);
 
+        int minWidth = lm.getOuterWidth(window.header)
+                - lm.getInnerWidth(window.header);
+        int minHeight = footerHeight + headerHeight;
+
+        getWidget().getElement().getStyle().setPropertyPx("minWidth", minWidth);
+        getWidget().getElement().getStyle()
+                .setPropertyPx("minHeight", minHeight);
+
         /*
          * Must set absolute position if the child has relative height and
          * there's a chance of horizontal scrolling as some browsers will