skin: enable SpecialKeyWindow docking & etc 17/10917/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 15 Oct 2013 05:17:28 +0000 (14:17 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 15 Oct 2013 06:54:14 +0000 (15:54 +0900)
Change-Id: Ia6e8b31956a03681f49ebd856dcec3009872eef6
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/EmulatorSkinState.java
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java

index a5f4ca523cd03ccb7932972ec07d8d3047bc521a..a1e4bef3bd3f62a49a64751b2ba10251ce34c5a6 100755 (executable)
@@ -244,7 +244,6 @@ public class EmulatorSkin {
 
                short rotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
                currentState.setCurrentRotationId(rotationId);
-               currentState.setCurrentAngle(SkinRotation.getAngle(rotationId));
 
                /* create and attach a popup menu */
                isOnKbd = false;
index d9d46ac4ee7f9b12e5bdb5368068fbf407ff8d53..1011207651a7978a6112374d325cd364109a76d3 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * Emulator Skin Process
  *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Contact:
  * GiWoong Kim <giwoong.kim@samsung.com>
@@ -32,14 +32,13 @@ import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
-import org.tizen.emulator.skin.layout.HWKey;
+import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.util.SkinRotation;
 
 public class EmulatorSkinState {
        private Point currentResolution;
        private int currentScale;
        private short currentRotationId;
-       private int currentAngle;
 
        private Rectangle displayBounds;
        private boolean updateDisplayBounds;
@@ -48,14 +47,13 @@ public class EmulatorSkinState {
        private Image currentKeyPressedImage;
        private Color hoverColor;
 
-       private HWKey currentPressedHWKey;
-       private HWKey currentHoveredHWKey;
-
+       /**
+        *  Constructor
+        */
        public EmulatorSkinState() {
-               this.currentResolution = new Point(480, 800);
-               this.currentScale = 50;
-               this.currentRotationId = RotationInfo.PORTRAIT.id();
-               this.currentAngle = 0;
+               this.currentResolution = new Point(720, 1280);
+               this.currentScale = EmulatorConfig.DEFAULT_WINDOW_SCALE;
+               this.currentRotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
 
                this.displayBounds = null;
                this.updateDisplayBounds = false;
@@ -107,17 +105,12 @@ public class EmulatorSkinState {
                return currentRotationId;
        }
 
-       public synchronized void setCurrentRotationId(short rotationId) {
-               this.currentRotationId = rotationId;
-       }
-
-       /* angle */
        public synchronized int getCurrentAngle() {
-               return currentAngle;
+               return SkinRotation.getAngle(currentRotationId);
        }
 
-       public synchronized void setCurrentAngle(int angle) {
-               this.currentAngle = angle;
+       public synchronized void setCurrentRotationId(short rotationId) {
+               this.currentRotationId = rotationId;
        }
 
        /* display bounds */
@@ -166,22 +159,4 @@ public class EmulatorSkinState {
        public synchronized void setHoverColor(Color color) {
                this.hoverColor = color;
        }
-
-       /* pressed HW key */
-       public synchronized HWKey getCurrentPressedHWKey() {
-               return currentPressedHWKey;
-       }
-
-       public synchronized void setCurrentPressedHWKey(HWKey hwKey) {
-               this.currentPressedHWKey = hwKey;
-       }
-
-       /* hovered HW key */
-       public synchronized HWKey getCurrentHoveredHWKey() {
-               return currentHoveredHWKey;
-       }
-
-       public synchronized void setCurrentHoveredHWKey(HWKey hwKey) {
-               this.currentHoveredHWKey = hwKey;
-       }
 }
index adbe9bb8be5c06ca5b5f07878d80462f71b10e3b..c7c2e1e07fbfb4c77dab7afc313be68d5260868e 100644 (file)
@@ -46,6 +46,7 @@ import org.eclipse.swt.events.ShellListener;
 import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.EmulatorSkin;
 import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
@@ -289,6 +290,8 @@ public class SpecialKeyWindow extends SkinWindow {
                                                        e.x, e.y, e.x, e.y, 0);
                                        communicator.sendToQEMU(
                                                        SendCommand.SEND_MOUSE_EVENT, mouseEventData, false);
+
+                                       return;
                                } else if (isGrabbedShell == true && e.button == 0/* left button */) {
                                        if (getDockPosition() != SWT.NONE) {
                                                dock(SWT.NONE, false, false);
@@ -301,6 +304,7 @@ public class SpecialKeyWindow extends SkinWindow {
                                        int y = previousLocation.y + (e.y - grabPosition.y);
 
                                        shell.setLocation(x, y);
+
                                        return;
                                }
                        }
@@ -319,6 +323,64 @@ public class SpecialKeyWindow extends SkinWindow {
                                        HWKey pressedHWKey = currentPressedHWKey;
                                        if (pressedHWKey == null) {
                                                logger.info("mouseUp in KeyWindow : " + e.x + ", " + e.y);
+
+                                               /* Let me check whether the key window was landed
+                                                * on docking area. */
+                                               Rectangle parentBounds = parent.getBounds();
+                                               Rectangle childBounds = shell.getBounds();
+
+                                               int heightOneThird = parentBounds.height / 3;
+                                               int widthDockingArea = 30;
+                                               int widthIntersectRegion = 5;
+
+                                               /* right-middle */
+                                               Rectangle attachBoundsRC = new Rectangle(
+                                                               (parentBounds.x + parentBounds.width) - widthIntersectRegion,
+                                                               parentBounds.y + heightOneThird,
+                                                               widthDockingArea, heightOneThird);
+                                               /* right-top */
+                                               Rectangle attachBoundsRT = new Rectangle(
+                                                               (parentBounds.x + parentBounds.width) - widthIntersectRegion,
+                                                               parentBounds.y,
+                                                               widthDockingArea, heightOneThird);
+                                               /* right-bottom */
+                                               Rectangle attachBoundsRB = new Rectangle(
+                                                               (parentBounds.x + parentBounds.width) - widthIntersectRegion,
+                                                               parentBounds.y + (heightOneThird * 2),
+                                                               widthDockingArea, heightOneThird);
+
+                                               /* left-middle */
+                                               Rectangle attachBoundsLC = new Rectangle(
+                                                               parentBounds.x - (widthDockingArea - widthIntersectRegion),
+                                                               parentBounds.y + heightOneThird,
+                                                               widthDockingArea, heightOneThird);
+                                               /* left-top */
+                                               Rectangle attachBoundsLT = new Rectangle(
+                                                               parentBounds.x - (widthDockingArea - widthIntersectRegion),
+                                                               parentBounds.y,
+                                                               widthDockingArea, heightOneThird);
+                                               /* left-bottom */
+                                               Rectangle attachBoundsLB = new Rectangle(
+                                                               parentBounds.x - (widthDockingArea - widthIntersectRegion),
+                                                               parentBounds.y + (heightOneThird * 2),
+                                                               widthDockingArea, heightOneThird);
+
+                                               if (childBounds.intersects(attachBoundsRC) == true) {
+                                                       dock(SWT.RIGHT | SWT.CENTER, false, true);
+                                               } else if (childBounds.intersects(attachBoundsRT) == true) {
+                                                       dock(SWT.RIGHT | SWT.TOP, false, true);
+                                               } else if (childBounds.intersects(attachBoundsRB) == true) {
+                                                       dock(SWT.RIGHT | SWT.BOTTOM, false, true);
+                                               } else if (childBounds.intersects(attachBoundsLC) == true) {
+                                                       dock(SWT.LEFT | SWT.CENTER, false, true);
+                                               } else if (childBounds.intersects(attachBoundsLT) == true) {
+                                                       dock(SWT.LEFT | SWT.TOP, false, true);
+                                               } else if (childBounds.intersects(attachBoundsLB) == true) {
+                                                       dock(SWT.LEFT | SWT.BOTTOM, false, true);
+                                               } else {
+                                                       dock(SWT.NONE, false, true);
+                                               }
+
                                                return;
                                        }
 
@@ -405,6 +467,7 @@ public class SpecialKeyWindow extends SkinWindow {
                                                                } /* end of run */
                                                        });
                                                }
+
                                        }
                                }
                        }
index 819b3d84405e35af9dfdbdd05f3d871f1598caf8..5eac5fa24198d6f4674cf4d6b76c9a6d13152108 100644 (file)
@@ -59,7 +59,6 @@ import org.tizen.emulator.skin.image.GeneralSkinImageRegistry.GeneralSkinImageNa
 import org.tizen.emulator.skin.image.ImageRegistry.IconName;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.menu.PopupMenu;
-import org.tizen.emulator.skin.util.SkinRotation;
 import org.tizen.emulator.skin.util.SkinUtil;
 import org.tizen.emulator.skin.util.SwtUtil;
 
@@ -222,7 +221,6 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
        public void arrangeSkin(int scale, short rotationId) {
                currentState.setCurrentScale(scale);
                currentState.setCurrentRotationId(rotationId);
-               currentState.setCurrentAngle(SkinRotation.getAngle(rotationId));
 
                /* arrange the display */
                Rectangle displayBounds = adjustLcdGeometry(displayCanvas,
index 379e379a52d6a4c37df3c879a5b7a941c9268c57..74dee615ef9a1ac2702b24e37528212f85a6ab4d 100644 (file)
@@ -88,6 +88,8 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
        private ProfileSkinImageRegistry imageRegistry;
        private boolean isGrabbedShell;
        private Point grabPosition;
+       private HWKey currentPressedHWKey;
+       private HWKey currentHoveredHWKey;
 
        public ProfileSpecificSkinComposer(
                        EmulatorConfig config, EmulatorSkin skin) {
@@ -185,7 +187,6 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
        public void arrangeSkin(int scale, short rotationId) {
                currentState.setCurrentScale(scale);
                currentState.setCurrentRotationId(rotationId);
-               currentState.setCurrentAngle(SkinRotation.getAngle(rotationId));
 
                /* arrange the display */
                Rectangle lcdBounds = adjustLcdGeometry(lcdCanvas,
@@ -321,7 +322,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                        public void mouseExit(MouseEvent e) {
                                /* shell does not receive event only with MouseMoveListener
                                 * in case that : hover hardkey -> mouse move into LCD area */
-                               HWKey hoveredHWKey = currentState.getCurrentHoveredHWKey();
+                               HWKey hoveredHWKey = currentHoveredHWKey;
 
                                if (hoveredHWKey != null) {
                                        shell.redraw(hoveredHWKey.getRegion().x,
@@ -329,7 +330,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                                                        hoveredHWKey.getRegion().width,
                                                        hoveredHWKey.getRegion().height, false);
 
-                                       currentState.setCurrentHoveredHWKey(null);
+                                       currentHoveredHWKey = null;
                                        shell.setToolTipText(null);
                                }
                        }
@@ -341,7 +342,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                        @Override
                        public void mouseMove(MouseEvent e) {
                                if (isGrabbedShell == true && e.button == 0/* left button */ &&
-                                               currentState.getCurrentPressedHWKey() == null) {
+                                               currentPressedHWKey == null) {
                                        /* move a window */
                                        Point previousLocation = shell.getLocation();
                                        int x = previousLocation.x + (e.x - grabPosition.x);
@@ -356,7 +357,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
 
                                final HWKey hwKey = SkinUtil.getHWKey(e.x, e.y,
                                                currentState.getCurrentRotationId(), currentState.getCurrentScale());
-                               final HWKey hoveredHWKey = currentState.getCurrentHoveredHWKey();
+                               final HWKey hoveredHWKey = currentHoveredHWKey;
 
                                if (hwKey == null) {
                                        if (hoveredHWKey != null) {
@@ -366,7 +367,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                                                                hoveredHWKey.getRegion().width,
                                                                hoveredHWKey.getRegion().height, false);
 
-                                               currentState.setCurrentHoveredHWKey(null);
+                                               currentHoveredHWKey = null;
                                                shell.setToolTipText(null);
                                        }
 
@@ -378,7 +379,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                                                hwKey.getTooltip().isEmpty() == false) {
                                        shell.setToolTipText(hwKey.getTooltip());
 
-                                       currentState.setCurrentHoveredHWKey(hwKey);
+                                       currentHoveredHWKey = hwKey;
 
                                        /* draw hover */
                                        shell.getDisplay().syncExec(new Runnable() {
@@ -405,7 +406,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                                                                hoveredHWKey.getRegion().width,
                                                                hoveredHWKey.getRegion().height, false);
 
-                                               currentState.setCurrentHoveredHWKey(null);
+                                               currentHoveredHWKey = null;
                                                shell.setToolTipText(null);
                                        }
                                }
@@ -424,7 +425,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                                        skin.getKeyWindowKeeper().redock(false, true);
 
                                        /* HW key handling */
-                                       HWKey pressedHWKey = currentState.getCurrentPressedHWKey();
+                                       HWKey pressedHWKey = currentPressedHWKey;
                                        if (pressedHWKey == null) {
                                                logger.info("mouseUp in Skin : " + e.x + ", " + e.y);
                                                return;
@@ -439,7 +440,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                                                communicator.sendToQEMU(
                                                                SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false);
 
-                                               currentState.setCurrentPressedHWKey(null);
+                                               currentPressedHWKey = null;
 
                                                /* roll back a keyPressed image region */
                                                shell.redraw(pressedHWKey.getRegion().x, pressedHWKey.getRegion().y,
@@ -479,7 +480,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                                                communicator.sendToQEMU(
                                                                SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false);
 
-                                               currentState.setCurrentPressedHWKey(hwKey);
+                                               currentPressedHWKey = hwKey;
 
                                                shell.setToolTipText(null);