]> source.dussan.org Git - vaadin-framework.git/commitdiff
[merge from 6.7] #3401 Resizing browser window should ensure sub windows are visible
authorAutomerge <automerge@vaadin.com>
Tue, 6 Mar 2012 10:06:12 +0000 (10:06 +0000)
committerAutomerge <automerge@vaadin.com>
Tue, 6 Mar 2012 10:06:12 +0000 (10:06 +0000)
svn changeset:23185/svn branch:6.8

src/com/vaadin/terminal/gwt/client/ui/VView.java

index 07ade6a8b1479826a0d6599a732723266ab88a15..46a7df9efba725b4b25a21bb750368832a0698d6 100644 (file)
@@ -149,10 +149,46 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
             connection.runDescendentsLayout(VView.this);
             Util.runWebkitOverflowAutoFix(getElement());
 
+            ensureSubWindowsVisible();
             sendClientResized();
         }
     }
 
+    private void ensureSubWindowsVisible() {
+        for (VWindow subWindow : subWindows) {
+            int oldLeft = subWindow.getPopupLeft();
+            int oldWidth = subWindow.getOffsetWidth();
+            int oldRight = oldLeft + oldWidth;
+
+            int newLeft = oldLeft;
+
+            if (oldRight > width) {
+                newLeft = width - oldWidth;
+                if (newLeft < 0) {
+                    newLeft = 0;
+                    subWindow.setWidth(width + "px");
+                }
+            }
+
+            int oldTop = subWindow.getPopupTop();
+            int oldHeight = subWindow.getOffsetHeight();
+            int oldBottom = oldTop + oldHeight;
+
+            int newTop = oldTop;
+
+            if (oldBottom > height) {
+                newTop = height - oldHeight;
+                if (newTop < 0) {
+                    newTop = 0;
+                    subWindow.setHeight(height + "px");
+                }
+            }
+
+            subWindow.setPopupPosition(newLeft, newTop);
+        }
+
+    }
+
     public String getTheme() {
         return theme;
     }