skin: add window docking area
authorgiwoong.kim <giwoong.kim@samsung.com>
Thu, 6 Dec 2012 06:31:49 +0000 (15:31 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Thu, 6 Dec 2012 06:31:49 +0000 (15:31 +0900)
right-top, right-bottom docking area is added

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
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 ad4b4b3..714aa4f 100644 (file)
@@ -900,7 +900,7 @@ public class EmulatorSkin {
                return isControlPanel;
        }
 
-       public void openKeyWindow(boolean attach) {
+       public void openKeyWindow(int attach) {
                if (controlPanel != null) {
                        controlPanel.getShell().setVisible(true);
                        SkinUtil.setTopMost(controlPanel.getShell(), isOnTop);
@@ -1020,9 +1020,10 @@ public class EmulatorSkin {
                                setIsControlPanel(isControlPanel);
                                if (isControlPanel == true) {
                                        openKeyWindow((controlPanel == null) ?
-                                                       true : controlPanel.isAttach());
+                                                       SWT.NONE : controlPanel.isAttach());
                                } else { /* hide a key window */
-                                       if (controlPanel != null && controlPanel.isAttach()) {
+                                       if (controlPanel != null &&
+                                                       controlPanel.isAttach() != SWT.NONE) {
                                                pairTagCanvas.setVisible(false);
                                                controlPanel.getShell().close();
                                        } else {
index 286332e..9f5b67b 100644 (file)
@@ -162,12 +162,12 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                        skin.pairTagCanvas.setVisible(false);
                                } else {
                                        skin.setIsControlPanel(true);
-                                       skin.openKeyWindow(true);
+                                       skin.openKeyWindow(SWT.RIGHT | SWT.CENTER);
 
                                        /* move a key window to right of the emulator window */
                                        if (skin.controlPanel != null) {
                                                skin.controlPanel.setShellPosition(
-                                                               SWT.RIGHT | SWT.CENTER, false);
+                                                               SWT.RIGHT | SWT.CENTER, true, false);
                                        }
                                }
                        }
@@ -321,9 +321,9 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                }
 
                                if (skin.controlPanel != null &&
-                                               skin.controlPanel.isAttach() == true) {
+                                               skin.controlPanel.isAttach() != SWT.NONE) {
                                        skin.controlPanel.setShellPosition(
-                                                       SWT.RIGHT | SWT.CENTER, false);
+                                                       skin.controlPanel.isAttach(), false, false);
                                }
                        }
                };
@@ -342,9 +342,9 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                        shell.setLocation(x, y);
 
                                        if (skin.controlPanel != null &&
-                                                       skin.controlPanel.isAttach() == true) {
+                                                       skin.controlPanel.isAttach() != SWT.NONE) {
                                                skin.controlPanel.setShellPosition(
-                                                               SWT.RIGHT | SWT.CENTER, false);
+                                                               skin.controlPanel.isAttach(), false, false);
                                        }
                                }
                        }
@@ -362,9 +362,9 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                        grabPosition.x = grabPosition.y = 0;
 
                                        if (skin.controlPanel != null &&
-                                                       skin.controlPanel.isAttach() == true) {
+                                                       skin.controlPanel.isAttach() != SWT.NONE) {
                                                skin.controlPanel.setShellPosition(
-                                                               SWT.RIGHT | SWT.CENTER, true);
+                                                               skin.controlPanel.isAttach(), false, true);
                                        }
                                }
                        }
index d3f8e29..50dce12 100644 (file)
@@ -274,19 +274,38 @@ public class ControlPanel extends SkinWindow {
                                        isGrabbedShell = false;
                                        grabPosition.x = grabPosition.y = 0;
 
+                                       /* Let me check whether the key window was landed
+                                        * on docking area. */
                                        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, true);
-                                               isAttach = true;
+                                       /* right-middle */
+                                       Rectangle attachBounds1 = new Rectangle(
+                                                       (parentBounds.x + parentBounds.width) - 5,
+                                                       (parentBounds.y + (parentBounds.height / 2)) - 10,
+                                                       30, 20);
+                                       /* right-top */
+                                       Rectangle attachBounds2 = new Rectangle(
+                                                       (parentBounds.x + parentBounds.width) - 5,
+                                                       (parentBounds.y) - 40,
+                                                       30, 80);
+                                       /* right-bottom */
+                                       Rectangle attachBounds3 = new Rectangle(
+                                                       (parentBounds.x + parentBounds.width) - 5,
+                                                       (parentBounds.y + parentBounds.height) - 40,
+                                                       30, 80);
+
+                                       if (childBounds.intersects(attachBounds1) == true) {
+                                               setShellPosition(SWT.RIGHT | SWT.CENTER, false, true);
+                                               isAttach = SWT.RIGHT | SWT.CENTER;
+                                       } else if (childBounds.intersects(attachBounds2) == true) {
+                                               setShellPosition(SWT.RIGHT | SWT.TOP, false, true);
+                                               isAttach = SWT.RIGHT | SWT.TOP;
+                                       } else if (childBounds.intersects(attachBounds3) == true) {
+                                               setShellPosition(SWT.RIGHT | SWT.BOTTOM, false, true);
+                                               isAttach = SWT.RIGHT | SWT.BOTTOM;
                                        } else {
-                                               isAttach = false;
+                                               isAttach = SWT.NONE;
                                        }
                                }
                        }
index a4b6e87..5edb84b 100644 (file)
@@ -43,12 +43,12 @@ public class SkinWindow {
        protected Shell shell;
        protected Shell parent;
        private int shellPositionType;
-       protected boolean isAttach;
+       protected int isAttach;
 
        public SkinWindow(Shell parent, int shellPositionType) {
                this.parent = parent;
                this.shellPositionType = shellPositionType;
-               this.isAttach = false;
+               this.isAttach = SWT.NONE;
        }
 
        public Shell getShell() {
@@ -60,8 +60,8 @@ public class SkinWindow {
                        return;
                }
 
-               setShellPosition(shellPositionType, true);
-               isAttach = true;
+               setShellPosition(shellPositionType, true, true);
+               isAttach = SWT.RIGHT | SWT.CENTER;
 
                shell.open();
 
@@ -72,7 +72,8 @@ public class SkinWindow {
                }
        }
 
-       public void setShellPosition(int shellPositionType, boolean enableLogger) {
+       public void setShellPosition(int shellPositionType,
+                       boolean correction, boolean enableLogger) {
                int x = 0;
                int y = 0;
 
@@ -91,16 +92,29 @@ public class SkinWindow {
                        y = parentBounds.y;
 
                        /* correction of location */
-                       if ((x + childBounds.width) >
-                                       (monitorBounds.x + monitorBounds.width)) {
-                               x = parentBounds.x - childBounds.width;
-                       }
+//                     if ((x + childBounds.width) >
+//                                     (monitorBounds.x + monitorBounds.width)) {
+//                             x = parentBounds.x - childBounds.width;
+//                     }
+               } else if (shellPositionType == (SWT.RIGHT | SWT.BOTTOM)) {
+                       x = parentBounds.x + parentBounds.width;
+                       y = parentBounds.y + parentBounds.height - childBounds.height;
+
+                       /* correction of location */
+//                     int shift = (monitorBounds.x + monitorBounds.width) -
+//                                     (x + childBounds.width);
+//                     if (shift < 0) {
+//                             x += shift;
+//                             parent.setLocation(parentBounds.x + shift, parentBounds.y);
+//                     }
                } else { /* SWT.RIGHT | SWT.CENTER */
                        x = parentBounds.x + parentBounds.width;
                        y = parentBounds.y + (parentBounds.height / 2) -
                                        (childBounds.height / 2);
+               }
 
-                       /* correction of location */
+               /* correction of location */
+               if (correction == true) {
                        int shift = (monitorBounds.x + monitorBounds.width) -
                                        (x + childBounds.width);
                        if (shift < 0) {
@@ -112,11 +126,11 @@ public class SkinWindow {
                shell.setLocation(x, y);
        }
 
-       public void setAttach(boolean attach) {
+       public void setAttach(int attach) {
                isAttach = attach;
        }
 
-       public boolean isAttach() {
+       public int isAttach() {
                return isAttach;
        }
 }