summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2012-01-18 15:41:54 +0000
committerMarc Englund <marc.englund@itmill.com>2012-01-18 15:41:54 +0000
commit2cb8d5f1573454a5342ef3b131b344bc41fcd33c (patch)
treeb381fb904a35bd756e316b8d6ab7608e5b6412df
parent65bda5db110221f2a7e0cecb0dbb0b31a28281b4 (diff)
downloadvaadin-framework-2cb8d5f1573454a5342ef3b131b344bc41fcd33c.tar.gz
vaadin-framework-2cb8d5f1573454a5342ef3b131b344bc41fcd33c.zip
Merged patch from 6.7 for #5093 and #5094 (cursors for dragging/resizing subwindows)
svn changeset:22695/svn branch:6.8
-rw-r--r--WebContent/VAADIN/themes/base/window/window.css15
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java88
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());
}