From 2cb8d5f1573454a5342ef3b131b344bc41fcd33c Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Wed, 18 Jan 2012 15:41:54 +0000 Subject: [PATCH] Merged patch from 6.7 for #5093 and #5094 (cursors for dragging/resizing subwindows) svn changeset:22695/svn branch:6.8 --- .../VAADIN/themes/base/window/window.css | 15 +++- .../terminal/gwt/client/ui/VWindow.java | 88 ++++++++++++++----- 2 files changed, 79 insertions(+), 24 deletions(-) diff --git a/WebContent/VAADIN/themes/base/window/window.css b/WebContent/VAADIN/themes/base/window/window.css index d4c03bd82e..398238426e 100644 --- a/WebContent/VAADIN/themes/base/window/window.css +++ b/WebContent/VAADIN/themes/base/window/window.css @@ -2,10 +2,15 @@ background: #fff; } .v-window-outerheader { - cursor: move; padding: 0.3em 1em; height: 1em; } + +.v-window-outerheader, +.v-window-draggingCurtain { + cursor: move; +} + .v-window-header { font-weight: bold; } @@ -40,16 +45,22 @@ div.v-window-header { zoom: 1; height: 10px; position: relative; + cursor: move; } .v-window-resizebox { width: 10px; height: 10px; - cursor: se-resize; background: #ddd; overflow: hidden; position: absolute; right: 0; } + +.v-window-resizebox, +.v-window-resizingCurtain { + cursor: se-resize; +} + .v-window div.v-window-footer-noresize { height: 0; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java index 54a151c7e7..7b9ece24c9 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@ -141,6 +141,7 @@ public class VWindow extends VOverlay implements Container, private Element modalityCurtain; private Element draggingCurtain; + private Element resizingCurtain; private Element headerText; @@ -575,12 +576,17 @@ public class VWindow extends VOverlay implements Container, this.draggable = draggable; + setCursorProperties(); + } + + private void setCursorProperties() { if (!this.draggable) { header.getStyle().setProperty("cursor", "default"); + footer.getStyle().setProperty("cursor", "default"); } else { header.getStyle().setProperty("cursor", ""); + footer.getStyle().setProperty("cursor", ""); } - } private void setNaturalWidth() { @@ -771,32 +777,70 @@ public class VWindow extends VOverlay implements Container, } /* - * Shows (or hides) an empty div on top of all other content; used when - * resizing or moving, so that iframes (etc) do not steal event. + * Shows an empty div on top of all other content; used when moving, so that + * iframes (etc) do not steal event. */ - private void showDraggingCurtain(boolean show) { - if (show && draggingCurtain == null) { + private void showDraggingCurtain() { + setFF2CaretFixEnabled(false); // makes FF2 slow - setFF2CaretFixEnabled(false); // makes FF2 slow + DOM.appendChild(RootPanel.getBodyElement(), getDraggingCurtain()); + } - draggingCurtain = DOM.createDiv(); - DOM.setStyleAttribute(draggingCurtain, "position", "absolute"); - DOM.setStyleAttribute(draggingCurtain, "top", "0px"); - DOM.setStyleAttribute(draggingCurtain, "left", "0px"); - DOM.setStyleAttribute(draggingCurtain, "width", "100%"); - DOM.setStyleAttribute(draggingCurtain, "height", "100%"); - DOM.setStyleAttribute(draggingCurtain, "zIndex", "" - + VOverlay.Z_INDEX); + private void hideDraggingCurtain() { + if (draggingCurtain != null) { + setFF2CaretFixEnabled(true); // makes FF2 slow - DOM.appendChild(RootPanel.getBodyElement(), draggingCurtain); - } else if (!show && draggingCurtain != null) { + DOM.removeChild(RootPanel.getBodyElement(), draggingCurtain); + } + } + + /* + * Shows an empty div on top of all other content; used when resizing, so + * that iframes (etc) do not steal event. + */ + private void showResizingCurtain() { + setFF2CaretFixEnabled(false); // makes FF2 slow + + DOM.appendChild(RootPanel.getBodyElement(), getResizingCurtain()); + } + private void hideResizingCurtain() { + if (resizingCurtain != null) { setFF2CaretFixEnabled(true); // makes FF2 slow - DOM.removeChild(RootPanel.getBodyElement(), draggingCurtain); - draggingCurtain = null; + DOM.removeChild(RootPanel.getBodyElement(), resizingCurtain); + } + } + + private Element getDraggingCurtain() { + if (draggingCurtain == null) { + draggingCurtain = createCurtain(); + draggingCurtain.setClassName(CLASSNAME + "-draggingCurtain"); + } + + return draggingCurtain; + } + + private Element getResizingCurtain() { + if (resizingCurtain == null) { + resizingCurtain = createCurtain(); + resizingCurtain.setClassName(CLASSNAME + "-resizingCurtain"); } + return resizingCurtain; + } + + private Element createCurtain() { + Element curtain = DOM.createDiv(); + + DOM.setStyleAttribute(curtain, "position", "absolute"); + DOM.setStyleAttribute(curtain, "top", "0px"); + DOM.setStyleAttribute(curtain, "left", "0px"); + DOM.setStyleAttribute(curtain, "width", "100%"); + DOM.setStyleAttribute(curtain, "height", "100%"); + DOM.setStyleAttribute(curtain, "zIndex", "" + VOverlay.Z_INDEX); + + return curtain; } private void setResizable(boolean resizability) { @@ -916,7 +960,7 @@ public class VWindow extends VOverlay implements Container, if (!isActive()) { bringToFront(); } - showDraggingCurtain(true); + showResizingCurtain(); if (BrowserInfo.get().isIE()) { DOM.setStyleAttribute(resizeBox, "visibility", "hidden"); } @@ -934,7 +978,7 @@ public class VWindow extends VOverlay implements Container, case Event.ONTOUCHCANCEL: DOM.releaseCapture(getElement()); case Event.ONLOSECAPTURE: - showDraggingCurtain(false); + hideResizingCurtain(); if (BrowserInfo.get().isIE()) { DOM.setStyleAttribute(resizeBox, "visibility", ""); } @@ -1180,7 +1224,7 @@ public class VWindow extends VOverlay implements Container, private void beginMovingWindow(Event event) { if (draggable) { - showDraggingCurtain(true); + showDraggingCurtain(); dragging = true; startX = Util.getTouchOrMouseClientX(event); startY = Util.getTouchOrMouseClientY(event); @@ -1193,7 +1237,7 @@ public class VWindow extends VOverlay implements Container, private void stopMovingWindow() { dragging = false; - showDraggingCurtain(false); + hideDraggingCurtain(); DOM.releaseCapture(getElement()); } -- 2.39.5