summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-03-08 14:00:39 +0200
committerLeif Åstrand <leif@vaadin.com>2012-03-08 14:00:39 +0200
commit2d7975fd8f41407bcd51bf798df70f88f7fbe67e (patch)
tree0a72bcb97b1f6db08960077a7e75e9481b0a6122 /src/com
parent8e0b20234ffcbc1dcb78723bf91f20f6159ef2b3 (diff)
downloadvaadin-framework-2d7975fd8f41407bcd51bf798df70f88f7fbe67e.tar.gz
vaadin-framework-2d7975fd8f41407bcd51bf798df70f88f7fbe67e.zip
Update VWindow.setWidth/Height to set outer sizes (#8313)
Also fix some small issues related to when the min size is used
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java65
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java16
2 files changed, 53 insertions, 28 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index c498cac807..222fa1ebd7 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -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());
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
index 4ae20af90d..a483e08e16 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java
@@ -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");
}
}