skin: refined the code of general skin
authorgiwoong.kim <giwoong.kim@samsung.com>
Thu, 3 Jan 2013 08:20:21 +0000 (17:20 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Thu, 3 Jan 2013 08:45:43 +0000 (17:45 +0900)
delete unnecessary filed, modified the variable name
and etc.

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 a45c560dddcebb6ae9569cc9c0fef61774373228..7d850dec708ca1f67a3224dc2500dc8b7bce941a 100644 (file)
@@ -144,7 +144,7 @@ public class EmulatorSkin {
 
        private Menu contextMenu;
        private MenuItem panelItem; /* key window menu */
-       public ControlPanel controlPanel;
+       public ControlPanel keyWindow;
        public Color colorPairTag;
        public Canvas pairTagCanvas;
        public CustomProgressBar bootingProgress;
@@ -355,13 +355,13 @@ public class EmulatorSkin {
                                                        screenShotDialog = null;
                                                }
 
-                                               /* close the control panel window */
-                                               if (null != controlPanel) {
-                                                       Shell cpShell = controlPanel.getShell();
-                                                       if (!cpShell.isDisposed()) {
-                                                               cpShell.close();
+                                               /* close the Key Window */
+                                               if (null != keyWindow) {
+                                                       Shell keyWindowShell = keyWindow.getShell();
+                                                       if (!keyWindowShell.isDisposed()) {
+                                                               keyWindowShell.close();
                                                        }
-                                                       controlPanel = null;
+                                                       keyWindow = null;
 
                                                        if (colorPairTag != null) {
                                                                colorPairTag.dispose();
@@ -466,9 +466,9 @@ public class EmulatorSkin {
                                logger.info("gain focus");
 
                                if (isOnTop == false && isControlPanel == true) {
-                                       if (controlPanel != null &&
-                                                       controlPanel.isAttach() != SWT.NONE) {
-                                               controlPanel.getShell().moveAbove(shell);
+                                       if (keyWindow != null &&
+                                                       keyWindow.getDockPosition() != SWT.NONE) {
+                                               keyWindow.getShell().moveAbove(shell);
                                        }
                                }
                        }
@@ -919,11 +919,10 @@ public class EmulatorSkin {
                return isControlPanel;
        }
 
-       public void openKeyWindow(int attach) {
-               if (controlPanel != null) {
-                       controlPanel.getShell().setVisible(true);
-                       SkinUtil.setTopMost(controlPanel.getShell(), isOnTop);
-                       controlPanel.setAttach(attach);
+       public void openKeyWindow(int dockValue) {
+               if (keyWindow != null) {
+                       keyWindow.getShell().setVisible(true);
+                       SkinUtil.setTopMost(keyWindow.getShell(), isOnTop);
 
                        pairTagCanvas.setVisible(true);
                        return;
@@ -942,22 +941,22 @@ public class EmulatorSkin {
                }
 
                try {
-                       controlPanel = new ControlPanel(this, shell, colorPairTag,
+                       keyWindow = new ControlPanel(this, shell, colorPairTag,
                                        communicator, keyMapList);
-                       SkinUtil.setTopMost(controlPanel.getShell(), isOnTop);
+                       SkinUtil.setTopMost(keyWindow.getShell(), isOnTop);
 
-                       //colorPairTag = controlPanel.getPairTagColor();
+                       //colorPairTag = keyWindow.getPairTagColor();
                        pairTagCanvas.setVisible(true);
 
-                       controlPanel.open();
+                       keyWindow.open(dockValue);
                        /* do not add at this line */
                } finally {
-                       controlPanel = null;
+                       keyWindow = null;
                }
        }
 
        public void hideKeyWindow() {
-               controlPanel.getShell().setVisible(false);
+               keyWindow.getShell().setVisible(false);
                pairTagCanvas.setVisible(false);
        }
 
@@ -1002,8 +1001,8 @@ public class EmulatorSkin {
                                        if (SkinUtil.setTopMost(shell, isOnTop) == false) {
                                                logger.info("failed to Always On Top");
                                        } else {
-                                               if (controlPanel != null) {
-                                                       SkinUtil.setTopMost(controlPanel.getShell(), isOnTop);
+                                               if (keyWindow != null) {
+                                                       SkinUtil.setTopMost(keyWindow.getShell(), isOnTop);
                                                }
                                        }
                                }
@@ -1039,13 +1038,14 @@ public class EmulatorSkin {
 
                                setIsControlPanel(isControlPanel);
                                if (isControlPanel == true) {
-                                       openKeyWindow((controlPanel == null) ?
-                                                       SWT.NONE : controlPanel.isAttach());
+                                       openKeyWindow((keyWindow == null) ?
+                                                       SWT.RIGHT | SWT.CENTER : keyWindow.getDockPosition());
                                } else { /* hide a key window */
-                                       if (controlPanel != null &&
-                                                       controlPanel.isAttach() != SWT.NONE) {
+                                       if (keyWindow != null &&
+                                                       keyWindow.getDockPosition() != SWT.NONE) {
+                                               /* Close the Key Window if it is docked to Main Window */
                                                pairTagCanvas.setVisible(false);
-                                               controlPanel.getShell().close();
+                                               keyWindow.getShell().close();
                                        } else {
                                                hideKeyWindow();
                                        }
index 33070edfd0eeb31fa173a68f0b67f6a089e99c60..c4bc0152fbf63639f9c17ad4b1dbc6529fe904ae 100644 (file)
@@ -158,8 +158,8 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                        @Override
                        public void mouseDown(MouseEvent e) {
                                if (skin.getIsControlPanel() == true) {
-                                       if (skin.controlPanel != null) {
-                                               skin.controlPanel.getShell().close();
+                                       if (skin.keyWindow != null) {
+                                               skin.keyWindow.getShell().close();
                                        }
 
                                        skin.setIsControlPanel(false);
@@ -169,8 +169,8 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                        skin.openKeyWindow(SWT.RIGHT | SWT.CENTER);
 
                                        /* move a key window to right of the emulator window */
-                                       if (skin.controlPanel != null) {
-                                               skin.controlPanel.setShellPosition(
+                                       if (skin.keyWindow != null) {
+                                               skin.keyWindow.dock(
                                                                SWT.RIGHT | SWT.CENTER, true, false);
                                        }
                                }
@@ -355,10 +355,10 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                        e.gc.drawImage(currentState.getCurrentImage(), 0, 0);
                                }
 
-                               if (skin.controlPanel != null &&
-                                               skin.controlPanel.isAttach() != SWT.NONE) {
-                                       skin.controlPanel.setShellPosition(
-                                                       skin.controlPanel.isAttach(), false, false);
+                               if (skin.keyWindow != null &&
+                                               skin.keyWindow.getDockPosition() != SWT.NONE) {
+                                       skin.keyWindow.dock(
+                                                       skin.keyWindow.getDockPosition(), false, false);
                                }
                        }
                };
@@ -376,10 +376,10 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
 
                                        shell.setLocation(x, y);
 
-                                       if (skin.controlPanel != null &&
-                                                       skin.controlPanel.isAttach() != SWT.NONE) {
-                                               skin.controlPanel.setShellPosition(
-                                                               skin.controlPanel.isAttach(), false, false);
+                                       if (skin.keyWindow != null &&
+                                                       skin.keyWindow.getDockPosition() != SWT.NONE) {
+                                               skin.keyWindow.dock(
+                                                               skin.keyWindow.getDockPosition(), false, false);
                                        }
                                }
                        }
@@ -396,10 +396,10 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                        isGrabbedShell = false;
                                        grabPosition.x = grabPosition.y = 0;
 
-                                       if (skin.controlPanel != null &&
-                                                       skin.controlPanel.isAttach() != SWT.NONE) {
-                                               skin.controlPanel.setShellPosition(
-                                                               skin.controlPanel.isAttach(), false, true);
+                                       if (skin.keyWindow != null &&
+                                                       skin.keyWindow.getDockPosition() != SWT.NONE) {
+                                               skin.keyWindow.dock(
+                                                               skin.keyWindow.getDockPosition(), false, true);
                                        }
                                }
                        }
index 4f9f528718dbbd63d6f93c5dbd1ae37896aee9d4..f960a011f00d8fb7cb215bab1792b6b7ea2d1d8f 100644 (file)
@@ -316,16 +316,13 @@ public class ControlPanel extends SkinWindow {
                                                        30, heightOneThird);
 
                                        if (childBounds.intersects(attachBounds1) == true) {
-                                               setShellPosition(SWT.RIGHT | SWT.CENTER, false, true);
-                                               isAttach = SWT.RIGHT | SWT.CENTER;
+                                               dock(SWT.RIGHT | SWT.CENTER, false, true);
                                        } else if (childBounds.intersects(attachBounds2) == true) {
-                                               setShellPosition(SWT.RIGHT | SWT.TOP, false, true);
-                                               isAttach = SWT.RIGHT | SWT.TOP;
+                                               dock(SWT.RIGHT | SWT.TOP, false, true);
                                        } else if (childBounds.intersects(attachBounds3) == true) {
-                                               setShellPosition(SWT.RIGHT | SWT.BOTTOM, false, true);
-                                               isAttach = SWT.RIGHT | SWT.BOTTOM;
+                                               dock(SWT.RIGHT | SWT.BOTTOM, false, true);
                                        } else {
-                                               isAttach = SWT.NONE;
+                                               dock(SWT.NONE, false, true);
                                        }
                                }
                        }
@@ -356,7 +353,7 @@ public class ControlPanel extends SkinWindow {
                                        skin.pairTagCanvas.setVisible(false);
                                }
                                skin.setIsControlPanel(false);
-                               skin.controlPanel = null;
+                               skin.keyWindow = null;
 
                                if (null != shellPaintListener) {
                                        shell.removePaintListener(shellPaintListener);
index 5edb84bcb9843c37f65236b0e5dc8f6a968a1e9b..ed2c0d1c6941289949e52f9351f7078393fd8dce 100644 (file)
@@ -42,26 +42,23 @@ public class SkinWindow {
 
        protected Shell shell;
        protected Shell parent;
-       private int shellPositionType;
-       protected int isAttach;
+       private int dockPosition;
 
-       public SkinWindow(Shell parent, int shellPositionType) {
+       public SkinWindow(Shell parent, int dockPosition) {
                this.parent = parent;
-               this.shellPositionType = shellPositionType;
-               this.isAttach = SWT.NONE;
+               this.dockPosition = dockPosition;
        }
 
        public Shell getShell() {
                return shell;
        }
 
-       public void open() {
+       public void open(int dockValue) {
                if (shell.isDisposed()) {
                        return;
                }
 
-               setShellPosition(shellPositionType, true, true);
-               isAttach = SWT.RIGHT | SWT.CENTER;
+               dock(dockValue, true, true);
 
                shell.open();
 
@@ -72,7 +69,7 @@ public class SkinWindow {
                }
        }
 
-       public void setShellPosition(int shellPositionType,
+       public void dock(int dockValue,
                        boolean correction, boolean enableLogger) {
                int x = 0;
                int y = 0;
@@ -87,26 +84,33 @@ public class SkinWindow {
                        logger.info("current child shell bounds : " + childBounds);
                }
 
-               if (shellPositionType == (SWT.RIGHT | SWT.TOP)) {
+               dockPosition = dockValue;
+
+               if (dockPosition == SWT.NONE){
+                       logger.info("undock");
+                       /* do nothing */
+
+                       return;
+               } else if (dockPosition == (SWT.RIGHT | SWT.TOP)) {
                        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 if (shellPositionType == (SWT.RIGHT | SWT.BOTTOM)) {
+                       /*if ((x + childBounds.width) >
+                                       (monitorBounds.x + monitorBounds.width)) {
+                               x = parentBounds.x - childBounds.width;
+                       }*/
+               } else if (dockPosition == (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);
-//                     }
+                       /*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) -
@@ -126,11 +130,7 @@ public class SkinWindow {
                shell.setLocation(x, y);
        }
 
-       public void setAttach(int attach) {
-               isAttach = attach;
-       }
-
-       public int isAttach() {
-               return isAttach;
+       public int getDockPosition() {
+               return dockPosition;
        }
 }