diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-05-29 15:59:06 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-05-30 13:30:43 +0000 |
commit | 1b274c40e6c3a57367e4f012a014a9b86e8ea909 (patch) | |
tree | 341f896d50496bde49d33b787edf61d26b899109 | |
parent | 5e26b0b6d9c97210d97e3e81f1af33feaa4751eb (diff) | |
download | vaadin-framework-1b274c40e6c3a57367e4f012a014a9b86e8ea909.tar.gz vaadin-framework-1b274c40e6c3a57367e4f012a014a9b86e8ea909.zip |
Limit sub window minimum size (#11510)
Change-Id: I8ad89e74b058246939d77165f2d4b5abc3417886
-rw-r--r-- | client/src/com/vaadin/client/ui/VWindow.java | 20 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/window/WindowConnector.java | 8 |
2 files changed, 27 insertions, 1 deletions
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 |