short rotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
currentState.setCurrentRotationId(rotationId);
- currentState.setCurrentAngle(SkinRotation.getAngle(rotationId));
/* create and attach a popup menu */
isOnKbd = false;
/**
* 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>
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;
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;
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 */
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;
- }
}
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;
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);
int y = previousLocation.y + (e.y - grabPosition.y);
shell.setLocation(x, y);
+
return;
}
}
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;
}
} /* end of run */
});
}
+
}
}
}
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;
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,
private ProfileSkinImageRegistry imageRegistry;
private boolean isGrabbedShell;
private Point grabPosition;
+ private HWKey currentPressedHWKey;
+ private HWKey currentHoveredHWKey;
public ProfileSpecificSkinComposer(
EmulatorConfig config, EmulatorSkin skin) {
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,
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,
hoveredHWKey.getRegion().width,
hoveredHWKey.getRegion().height, false);
- currentState.setCurrentHoveredHWKey(null);
+ currentHoveredHWKey = null;
shell.setToolTipText(null);
}
}
@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);
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) {
hoveredHWKey.getRegion().width,
hoveredHWKey.getRegion().height, false);
- currentState.setCurrentHoveredHWKey(null);
+ currentHoveredHWKey = null;
shell.setToolTipText(null);
}
hwKey.getTooltip().isEmpty() == false) {
shell.setToolTipText(hwKey.getTooltip());
- currentState.setCurrentHoveredHWKey(hwKey);
+ currentHoveredHWKey = hwKey;
/* draw hover */
shell.getDisplay().syncExec(new Runnable() {
hoveredHWKey.getRegion().width,
hoveredHWKey.getRegion().height, false);
- currentState.setCurrentHoveredHWKey(null);
+ currentHoveredHWKey = null;
shell.setToolTipText(null);
}
}
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;
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,
communicator.sendToQEMU(
SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false);
- currentState.setCurrentPressedHWKey(hwKey);
+ currentPressedHWKey = hwKey;
shell.setToolTipText(null);