From 1b274c40e6c3a57367e4f012a014a9b86e8ea909 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 29 May 2013 15:59:06 +0300 Subject: [PATCH] Limit sub window minimum size (#11510) Change-Id: I8ad89e74b058246939d77165f2d4b5abc3417886 --- client/src/com/vaadin/client/ui/VWindow.java | 20 ++++++++++++++++++- .../client/ui/window/WindowConnector.java | 8 ++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index 38dfdba1b8..1331eb106a 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -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( diff --git a/client/src/com/vaadin/client/ui/window/WindowConnector.java b/client/src/com/vaadin/client/ui/window/WindowConnector.java index 90311e30ad..beaf549dcf 100644 --- a/client/src/com/vaadin/client/ui/window/WindowConnector.java +++ b/client/src/com/vaadin/client/ui/window/WindowConnector.java @@ -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 -- 2.39.5