]> source.dussan.org Git - vaadin-framework.git/commitdiff
Update VWindow.setWidth/Height to set outer sizes (#8313)
authorLeif Åstrand <leif@vaadin.com>
Thu, 8 Mar 2012 12:00:39 +0000 (14:00 +0200)
committerLeif Åstrand <leif@vaadin.com>
Thu, 8 Mar 2012 12:00:39 +0000 (14:00 +0200)
Also fix some small issues related to when the min size is used

WebContent/VAADIN/themes/base/window/window.css
WebContent/VAADIN/themes/chameleon/components/window/window.css
WebContent/VAADIN/themes/reindeer/window/window.css
WebContent/VAADIN/themes/runo/window/window.css
src/com/vaadin/terminal/gwt/client/ui/VWindow.java
src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java

index 701140333ac289667f31614410f1c8df977ef7a5..bd36c1271507befab4b2e68cd2d9c9191e40c8a6 100644 (file)
@@ -1,21 +1,39 @@
 .v-window {
        background: #fff;
 }
+.v-window-contents {
+       padding: 1.6em 0 10px;
+       margin: -1.6em 0 -10px;
+       box-sizing: border-box;
+       -moz-box-sizing: border-box;
+}
+
+.v-window.v-has-width > div.popupContent,
+.v-window.v-has-width .v-window-wrap,
+.v-window.v-has-width .v-window-contents,
+.v-window.v-has-width .v-window-contents > div {
+       width: 100%;
+}
+
+.v-window.v-has-height > div.popupContent,
+.v-window.v-has-height .v-window-wrap,
+.v-window.v-has-height .v-window-contents,
+.v-window.v-has-height .v-window-contents > div {
+       height: 100%;
+}
+
 .v-window-outerheader {
-       padding: 0.3em 0;
-       height: 1em;
+       padding: 0.3em 1em;
+       height: 1.6em;
        position: relative;
+       box-sizing: border-box;
+       -moz-box-sizing: border-box;
 }
 
 .v-window-outerheader,
 .v-window-draggingCurtain {
        cursor: move;   
 }
-.v-window-header.v-not-spanning {
-       position: absolute;
-       left: 0;
-       right: 0;
-}
 .v-window-header {
        font-weight: bold;
 }
@@ -25,7 +43,7 @@ div.v-window-header {
        text-overflow: ellipsis;
        -ms-text-overflow: ellipsis;
        overflow: hidden;
-       padding: 0 1em;
+       padding: 0;
 }
 .v-window-header .v-icon {
        vertical-align: middle; /* This has to be 'middle', not 'bottom', to allow larger icons than 16px */
index b5cc0170ac7ba04ea13aae940d8d81b42abb743e..00e6760d4bc0d9d268835c5ff33afc892a0887f6 100644 (file)
        background-image: url(../../img/grad-light-top.png);
        background-repeat: repeat-x;
        }
-
+.v-window-contents {
+       padding: 2.1em 0 0;
+       margin: -2.1em 0 0;
+}
 .v-window-outerheader {
        padding: .2em 1.7em .5em 1.2em;
-       height: auto;
+       height: 2.1em;
        text-align: center;
        }
 
index e24b00e4ea5ecbfbad0e58fbb3e345bdf3d04d45..348d1cb2c578a643bba2eece97ef4dfdca65f267 100644 (file)
@@ -3,18 +3,24 @@
 }
 .v-window-wrap {
        border: 1px solid #808386;
+       box-sizing: border-box;
+       -moz-box-sizing: border-box;
 }
 .v-sa .v-window-wrap,
 .v-op .v-window-wrap {
        border-color: rgba(0,0,0,.2);
 }
 .v-window-outerheader {
-       padding: 12px 0 0;
-       height: 25px;
+       padding: 12px 32px 0 14px;
+       height: 37px;
        background: black repeat-x;
        background-image: url(img/header-bg.png); /** sprite-ref: verticals; sprite-alignment: repeat */
 }
-div.v-window-header {
+.v-window-contents {
+       padding: 37px 0 15px;
+       margin: -37px 0 -15px;
+}
+.v-window-header {
        font-weight: bold;
        font-size: 12px;
        line-height: normal;
@@ -24,7 +30,6 @@ div.v-window-header {
        overflow: hidden;
        text-overflow: ellipsis;
        -ms-text-overflow: ellipsis;
-       padding: 0 32px 0 14px
 }
 .v-window-error .v-window-header {
        padding-left: 13px;
index 210bccb9b93cb43d6426fb986f80239a77ce5a16..3205659341e27fad601e5020001823e23063b035 100644 (file)
@@ -9,7 +9,7 @@
        background: transparent url(img/top-left.png) no-repeat;
 }
 .v-window-outerheader {
-       height: 23px;
+       height: 49px;
        margin-left: 9px;
        padding: 15px 40px 11px 12px;
        background: transparent url(img/top-right.png) no-repeat right top;
        text-shadow: 0 1px 0 #fff;
 }
 .v-window-contents {
+       padding: 49px 0 8px;
+       margin: -49px 0 -8px;
+}
+.v-window-contents > div {
        background: #fff;
        border: 2px solid #babfc0;
        border-top: none;
        border-bottom: none;
+       box-sizing: border-box;
+       -moz-box-sizing: border-box;
 }
 .v-window div.v-window-footer {
        height: 8px;
index c498cac807671bbabe3ca974050f6f2ee27d8425..222fa1ebd7d6058fc51ff1040ee226fd738bb1bc 100644 (file)
@@ -32,6 +32,7 @@ import com.vaadin.terminal.gwt.client.ComponentConnector;
 import com.vaadin.terminal.gwt.client.Console;
 import com.vaadin.terminal.gwt.client.EventId;
 import com.vaadin.terminal.gwt.client.Focusable;
+import com.vaadin.terminal.gwt.client.LayoutManager;
 import com.vaadin.terminal.gwt.client.Util;
 import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
 
@@ -47,13 +48,13 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
      * Minimum allowed height of a window. This refers to the content area, not
      * the outer borders.
      */
-    public static final int MIN_CONTENT_AREA_HEIGHT = 100;
+    private static final int MIN_CONTENT_AREA_HEIGHT = 100;
 
     /**
      * Minimum allowed width of a window. This refers to the content area, not
      * the outer borders.
      */
-    public static final int MIN_CONTENT_AREA_WIDTH = 150;
+    private static final int MIN_CONTENT_AREA_WIDTH = 150;
 
     private static ArrayList<VWindow> windowOrder = new ArrayList<VWindow>();
 
@@ -578,8 +579,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
                 resizing = true;
                 startX = Util.getTouchOrMouseClientX(event);
                 startY = Util.getTouchOrMouseClientY(event);
-                origW = contents.getOffsetWidth();
-                origH = contents.getOffsetHeight();
+                origW = getElement().getOffsetWidth();
+                origH = getElement().getOffsetHeight();
                 DOM.setCapture(getElement());
                 event.preventDefault();
                 break;
@@ -644,13 +645,15 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
         }
 
         int w = Util.getTouchOrMouseClientX(event) - startX + origW;
-        if (w < MIN_CONTENT_AREA_WIDTH) {
-            w = MIN_CONTENT_AREA_WIDTH;
+        int minWidth = getMinWidth();
+        if (w < minWidth) {
+            w = minWidth;
         }
 
         int h = Util.getTouchOrMouseClientY(event) - startY + origH;
-        if (h < MIN_CONTENT_AREA_HEIGHT) {
-            h = MIN_CONTENT_AREA_HEIGHT;
+        int minHeight = getMinHeight();
+        if (h < minHeight) {
+            h = minHeight;
         }
 
         setWidth(w + "px");
@@ -658,10 +661,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
 
         if (updateVariables) {
             // sending width back always as pixels, no need for unit
-            client.updateVariable(id, "width", getWidget().getOffsetWidth(),
-                    false);
-            client.updateVariable(id, "height", getWidget().getOffsetHeight(),
-                    immediate);
+            client.updateVariable(id, "width", w, false);
+            client.updateVariable(id, "height", h, immediate);
         }
 
         if (updateVariables || !resizeLazy) {
@@ -686,18 +687,18 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
 
     @Override
     public void setWidth(String width) {
-        super.setWidth(width);
-        // Let the width of the heading affect the total width if the window has
-        // undefined width
-        if (width == null || width.length() == 0) {
-            headerText.removeClassName("v-not-spanning");
-        } else {
-            headerText.addClassName("v-not-spanning");
-        }
+        // Override PopupPanel which sets the width to the contents
+        getElement().getStyle().setProperty("width", width);
+        // Update v-has-width in case undefined window is resized
+        setStyleName("v-has-width", width != null && width.length() > 0);
     }
 
-    int getExtraHeight() {
-        return header.getOffsetHeight() + footer.getOffsetHeight();
+    @Override
+    public void setHeight(String height) {
+        // Override PopupPanel which sets the height to the contents
+        getElement().getStyle().setProperty("height", height);
+        // Update v-has-height in case undefined window is resized
+        setStyleName("v-has-height", height != null && height.length() > 0);
     }
 
     private void onDragEvent(Event event) {
@@ -843,4 +844,24 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
         contentPanel.focus();
     }
 
+    public int getMinHeight() {
+        return MIN_CONTENT_AREA_HEIGHT + getDecorationHeight();
+    }
+
+    private int getDecorationHeight() {
+        LayoutManager layoutManager = layout.getLayoutManager();
+        return layoutManager.getOuterHeight(getElement())
+                - layoutManager.getInnerHeight(contentPanel.getElement());
+    }
+
+    public int getMinWidth() {
+        return MIN_CONTENT_AREA_WIDTH + getDecorationWidth();
+    }
+
+    private int getDecorationWidth() {
+        LayoutManager layoutManager = layout.getLayoutManager();
+        return layoutManager.getOuterWidth(getElement())
+                - layoutManager.getInnerWidth(contentPanel.getElement());
+    }
+
 }
index 4ae20af90dfd50f131ae4ef4f27fb3ca082022a1..a483e08e1646a51bb018a650dab637852b4c75e0 100644 (file)
@@ -234,16 +234,20 @@ public class WindowConnector extends AbstractComponentContainerConnector
         LayoutManager lm = getLayoutManager();
         VWindow window = getWidget();
         Element contentElement = window.contentPanel.getElement();
-        if (!window.layout.isUndefinedWidth()
-                && lm.getOuterWidth(contentElement) < VWindow.MIN_CONTENT_AREA_WIDTH) {
+        boolean needsMinWidth = !isUndefinedWidth()
+                || window.layout.isRelativeWidth();
+        int minWidth = window.getMinWidth();
+        if (needsMinWidth && lm.getInnerWidth(contentElement) < minWidth) {
             // Use minimum width if less than a certain size
-            window.setWidth(VWindow.MIN_CONTENT_AREA_WIDTH + "px");
+            window.setWidth(minWidth + "px");
         }
 
-        if (!window.layout.isUndefinedHeight()
-                && lm.getOuterHeight(contentElement) < VWindow.MIN_CONTENT_AREA_HEIGHT) {
+        boolean needsMinHeight = !isUndefinedHeight()
+                || window.layout.isRelativeHeight();
+        int minHeight = window.getMinHeight();
+        if (needsMinHeight && lm.getInnerHeight(contentElement) < minHeight) {
             // Use minimum height if less than a certain size
-            window.setHeight(VWindow.MIN_CONTENT_AREA_HEIGHT + "px");
+            window.setHeight(minHeight + "px");
         }
 
     }