From d5dc6ce853955f42a7690c68755551a39eaccadd Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Tue, 15 Oct 2013 14:17:28 +0900 Subject: [PATCH] skin: enable SpecialKeyWindow docking & etc Change-Id: Ia6e8b31956a03681f49ebd856dcec3009872eef6 Signed-off-by: GiWoong Kim --- .../src/org/tizen/emulator/skin/EmulatorSkin.java | 1 - .../org/tizen/emulator/skin/EmulatorSkinState.java | 49 +++++------------ .../emulator/skin/custom/SpecialKeyWindow.java | 63 ++++++++++++++++++++++ .../skin/layout/GeneralPurposeSkinComposer.java | 2 - .../skin/layout/ProfileSpecificSkinComposer.java | 23 ++++---- 5 files changed, 87 insertions(+), 51 deletions(-) diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index a5f4ca5..a1e4bef 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -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; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinState.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinState.java index d9d46ac..1011207 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinState.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinState.java @@ -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 @@ -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; - } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java index adbe9bb..c7c2e1e 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java @@ -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 */ }); } + } } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java index 819b3d8..5eac5fa 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java @@ -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, diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java index 379e379..74dee61 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java @@ -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); -- 2.7.4