menu: correction of key window position
authorgiwoong.kim <giwoong.kim@samsung.com>
Tue, 4 Dec 2012 06:27:10 +0000 (15:27 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Tue, 4 Dec 2012 06:27:10 +0000 (15:27 +0900)
The key window does not get out of resolution range
at generated time.
And attach the key window to main window when two
windows have short distance.

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java
tizen/src/skin/client/src/org/tizen/emulator/skin/window/SkinWindow.java

index 5a2dbb3..c8a9dfd 100644 (file)
@@ -269,6 +269,18 @@ public class ControlPanel extends SkinWindow {
                                if (e.button == 1) { /* left button */
                                        isGrabbedShell = false;
                                        grabPosition.x = grabPosition.y = 0;
+
+                                       Rectangle parentBounds = parent.getBounds();
+                                       Rectangle childBounds = shell.getBounds();
+
+                                       Rectangle attachBounds = new Rectangle(
+                                                       parentBounds.x + parentBounds.width - 5,
+                                                       parentBounds.y + (parentBounds.height / 2) - 2,
+                                                       30, 4);
+
+                                       if (childBounds.intersects(attachBounds) == true) {
+                                               setShellPosition(SWT.RIGHT | SWT.CENTER);
+                                       }
                                }
                        }
 
index 75c8d8d..8d07e66 100644 (file)
@@ -58,7 +58,8 @@ public class SkinWindow {
                        return;
                }
 
-               setShellPosition();
+               setShellPosition(shellPositionType);
+
                shell.open();
 
                while (!shell.isDisposed()) {
@@ -68,27 +69,38 @@ public class SkinWindow {
                }
        }
 
-       protected void setShellPosition() {
-               int x = 0, y = 0;
+       protected void setShellPosition(int shellPositionType) {
+               int x = 0;
+               int y = 0;
+
+               Rectangle monitorBounds = Display.getDefault().getBounds();
+               logger.info("host monitor display bounds : " + monitorBounds);
+               Rectangle parentBounds = parent.getBounds();
+               logger.info("current parent shell bounds : " + parentBounds);
+               Rectangle childBounds = shell.getBounds();
+               logger.info("current child shell bounds : " + childBounds);
 
                if (shellPositionType == (SWT.RIGHT | SWT.TOP)) {
-                       Rectangle monitorBound = Display.getDefault().getBounds();
-                       logger.info("host monitor display bound : " + monitorBound);
-                       Rectangle emulatorBound = parent.getBounds();
-                       logger.info("current Emulator window bound : " + emulatorBound);
-                       Rectangle panelBound = shell.getBounds();
-                       logger.info("current Panel shell bound : " + panelBound);
-
-                       /* location correction */
-                       x = emulatorBound.x + emulatorBound.width;
-                       y = emulatorBound.y;
-                       if ((x + panelBound.width) > (monitorBound.x + monitorBound.width)) {
-                               x = emulatorBound.x - panelBound.width;
+                       x = parentBounds.x + parentBounds.width;
+                       y = parentBounds.y;
+
+                       /* correction of location */
+                       if ((x + childBounds.width) >
+                                       (monitorBounds.x + monitorBounds.width)) {
+                               x = parentBounds.x - childBounds.width;
                        }
                } else { /* SWT.RIGHT | SWT.CENTER */
-                       x = parent.getBounds().x + parent.getBounds().width;
-                       y = parent.getBounds().y + (parent.getBounds().height / 2) -
-                                       (shell.getSize().y / 2);
+                       x = parentBounds.x + parentBounds.width;
+                       y = parentBounds.y + (parentBounds.height / 2) -
+                                       (childBounds.height / 2);
+
+                       /* correction of location */
+                       int shift = (monitorBounds.x + monitorBounds.width) -
+                                       (x + childBounds.width);
+                       if (shift < 0) {
+                               x += shift;
+                               parent.setLocation(parentBounds.x + shift, parentBounds.y);
+                       }
                }
 
                shell.setLocation(x, y);