private Color hoverColor;
private boolean isDefaultHoverColor;
- protected int currentScale;
- protected short currentRotationId;
- protected int currentAngle;
- protected int currentResolutionWidth;
- protected int currentResolutionHeight;
+ protected EmulatorSkinState currentState;
protected SkinRegion currentHoverRegion;
protected SkinRegion currentPressedRegion;
}
this.shell = new Shell(Display.getDefault(), style);
+
+ this.currentState = new EmulatorSkinState();
}
public void setCommunicator( SocketCommunicator communicator ) {
int y = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_Y,
EmulatorConfig.DEFAULT_WINDOW_Y);
- currentResolutionWidth = config.getArgInt(ArgsConstants.RESOLUTION_WIDTH);
- currentResolutionHeight = config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT);
+ currentState.setCurrentResolutionWidth(
+ config.getArgInt(ArgsConstants.RESOLUTION_WIDTH));
+ currentState.setCurrentResolutionHeight(
+ config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT));
+
int scale = SkinUtil.getValidScale(config);
// int rotationId = config.getPropertyShort( PropertiesConstants.WINDOW_ROTATION,
// EmulatorConfig.DEFAULT_WINDOW_ROTATION );
short rotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
composeInternal(lcdCanvas, x, y, scale, rotationId, false);
- logger.info("resolution : " +
- currentResolutionWidth + "x" + currentResolutionHeight + ", scale : " + scale);
+ logger.info("resolution : " + currentState.getCurrentResolution() +
+ ", scale : " + scale);
return 0;
}
}
- private void rearrangeSkin() {
- logger.info("rearrange the skin (" + skinInfo.getSkinOption() + ")");
- arrangeSkin(currentScale, currentRotationId);
- }
+// private void rearrangeSkin() {
+// logger.info("rearrange the skin (" + skinInfo.getSkinOption() + ")");
+// arrangeSkin(currentScale, currentRotationId);
+// }
private void arrangeSkin(int scale, short rotationId) {
- this.currentScale = scale;
- this.currentRotationId = rotationId;
- this.currentAngle = SkinRotation.getAngle(rotationId);
+ currentState.setCurrentScale(scale);
+ currentState.setCurrentRotationId(rotationId);
+ currentState.setCurrentAngle(SkinRotation.getAngle(rotationId));
/* arrange the lcd */
- Rectangle lcdBounds = SkinUtil.adjustLcdGeometry(
- lcdCanvas, currentResolutionWidth, currentResolutionHeight, scale, rotationId,
+ Rectangle lcdBounds = SkinUtil.adjustLcdGeometry(lcdCanvas,
+ currentState.getCurrentResolutionWidth(),
+ currentState.getCurrentResolutionHeight(), scale, rotationId,
skinInfo.isPhoneShape());
+
if (lcdBounds == null) {
logger.severe("Failed to lcd information for phone shape skin.");
SkinUtil.openMessage(shell, null,
decoration = new Decorations(shell, SWT.BORDER);
decoration.setLayout(new GridLayout(1, true));
- RotationType rotation = SkinRotation.getRotation(currentRotationId);
+ RotationType rotation =
+ SkinRotation.getRotation(currentState.getCurrentRotationId());
List<KeyMapType> keyMapList = rotation.getKeyMapList().getKeyMap();
// TODO: function
}
// save config only for emulator close
- config.setSkinProperty( SkinPropertiesConstants.WINDOW_X, shell.getLocation().x );
- config.setSkinProperty( SkinPropertiesConstants.WINDOW_Y, shell.getLocation().y );
- config.setSkinProperty( SkinPropertiesConstants.WINDOW_SCALE, currentScale );
- config.setSkinProperty( SkinPropertiesConstants.WINDOW_ROTATION, currentRotationId );
- config.setSkinProperty( SkinPropertiesConstants.WINDOW_ONTOP, Boolean.toString( isOnTop ) );
+ config.setSkinProperty(
+ SkinPropertiesConstants.WINDOW_X, shell.getLocation().x);
+ config.setSkinProperty(
+ SkinPropertiesConstants.WINDOW_Y, shell.getLocation().y);
+ config.setSkinProperty(
+ SkinPropertiesConstants.WINDOW_SCALE, currentState.getCurrentScale());
+ config.setSkinProperty(
+ SkinPropertiesConstants.WINDOW_ROTATION, currentState.getCurrentRotationId());
+ config.setSkinProperty(
+ SkinPropertiesConstants.WINDOW_ONTOP, Boolean.toString(isOnTop));
config.saveSkinProperties();
-
}
if ( null != currentImage ) {
if ( EmulatorSkin.this.isMousePressed ) {
if (0 == e.button) { /* left button */
- SkinRegion hardkeyRegion = SkinUtil.getHardKeyArea( e.x, e.y, currentRotationId, currentScale );
+ SkinRegion hardkeyRegion = SkinUtil.getHardKeyArea(e.x, e.y,
+ currentState.getCurrentRotationId(), currentState.getCurrentScale());
if ( null == hardkeyRegion ) {
Point previouseLocation = shell.getLocation();
}
} else {
- SkinRegion region = SkinUtil.getHardKeyArea( e.x, e.y, currentRotationId, currentScale );
+ SkinRegion region = SkinUtil.getHardKeyArea(e.x, e.y,
+ currentState.getCurrentRotationId(), currentState.getCurrentScale());
if ( null == region ) {
if ( isHoverState ) {
}
} else {
if (isHoverState == false) {
- shell.setToolTipText(SkinUtil.getHardKeyToolTip(e.x, e.y, currentRotationId, currentScale));
+ shell.setToolTipText(SkinUtil.getHardKeyToolTip(e.x, e.y,
+ currentState.getCurrentRotationId(), currentState.getCurrentScale()));
}
isHoverState = true;
if (gc != null) {
gc.setLineWidth(1);
gc.setForeground(hoverColor);
- gc.drawRectangle(currentHoverRegion.x, currentHoverRegion.y, currentHoverRegion.width, currentHoverRegion.height);
+ gc.drawRectangle(currentHoverRegion.x, currentHoverRegion.y,
+ currentHoverRegion.width, currentHoverRegion.height);
gc.dispose();
}
pressedHWKeyCode = 0;
}
- int keyCode = SkinUtil.getHardKeyCode( e.x, e.y, currentRotationId, currentScale );
+ int keyCode = SkinUtil.getHardKeyCode(e.x, e.y,
+ currentState.getCurrentRotationId(), currentState.getCurrentScale());
if ( SkinUtil.UNKNOWN_KEYCODE != keyCode ) {
/* null check : prevent from mouse up without a hover
}
}
- SkinRegion region = SkinUtil.getHardKeyArea(e.x, e.y, currentRotationId, currentScale);
+ SkinRegion region = SkinUtil.getHardKeyArea(e.x, e.y,
+ currentState.getCurrentRotationId(), currentState.getCurrentScale());
if (keyCode != 101) { // TODO: not necessary for home key
SkinUtil.trimShell(shell, currentImage,
region.x, region.y, region.width, region.height);
EmulatorSkin.this.pressedMouseY = e.y;
EmulatorSkin.this.isMousePressed = true;
- final int keyCode = SkinUtil.getHardKeyCode(e.x, e.y, currentRotationId, currentScale);
+ final int keyCode = SkinUtil.getHardKeyCode(e.x, e.y,
+ currentState.getCurrentRotationId(), currentState.getCurrentScale());
if (SkinUtil.UNKNOWN_KEYCODE != keyCode) {
/* send event */
shell.setToolTipText(null);
/* draw the button region as the cropped keyPressed image area */
- currentPressedRegion = SkinUtil.getHardKeyArea(e.x, e.y, currentRotationId, currentScale);
+ currentPressedRegion = SkinUtil.getHardKeyArea(e.x, e.y,
+ currentState.getCurrentRotationId(), currentState.getCurrentScale());
+
if (currentPressedRegion != null &&
currentPressedRegion.width != 0 && currentPressedRegion.height != 0) {
shell.getDisplay().syncExec(new Runnable() {
if (currentHoverRegion.width != 0 && currentHoverRegion.height != 0) {
gc.setLineWidth(1);
gc.setForeground(hoverColor);
- gc.drawRectangle(currentHoverRegion.x, currentHoverRegion.y, currentHoverRegion.width, currentHoverRegion.height);
+ gc.drawRectangle(currentHoverRegion.x, currentHoverRegion.y,
+ currentHoverRegion.width, currentHoverRegion.height);
}
gc.dispose();
EmulatorSkin.this.isDragStartedInLCD = false;
}
- int[] geometry = SkinUtil.convertMouseGeometry(
- e.x, e.y, currentResolutionWidth, currentResolutionHeight,
- currentScale, currentAngle);
+ int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
+ currentState.getCurrentResolutionWidth(),
+ currentState.getCurrentResolutionHeight(),
+ currentState.getCurrentScale(), currentState.getCurrentAngle());
MouseEventData mouseEventData = new MouseEventData(
MouseButtonType.LEFT.value(), eventType,
public void mouseUp( MouseEvent e ) {
if ( 1 == e.button ) { // left button
- int[] geometry = SkinUtil.convertMouseGeometry(
- e.x, e.y, currentResolutionWidth, currentResolutionHeight,
- currentScale, currentAngle);
+ int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
+ currentState.getCurrentResolutionWidth(),
+ currentState.getCurrentResolutionHeight(),
+ currentState.getCurrentScale(), currentState.getCurrentAngle());
logger.info( "mouseUp in LCD" + " x:" + geometry[0] + " y:" + geometry[1] );
MouseEventData mouseEventData = new MouseEventData(
public void mouseDown( MouseEvent e ) {
if ( 1 == e.button ) { // left button
- int[] geometry = SkinUtil.convertMouseGeometry(
- e.x, e.y, currentResolutionWidth, currentResolutionHeight,
- currentScale, currentAngle);
+ int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
+ currentState.getCurrentResolutionWidth(),
+ currentState.getCurrentResolutionHeight(),
+ currentState.getCurrentScale(), currentState.getCurrentAngle());
logger.info( "mouseDown in LCD" + " x:" + geometry[0] + " y:" + geometry[1] );
MouseEventData mouseEventData = new MouseEventData(
@Override
public void mouseScrolled(MouseEvent e) {
- int[] geometry = SkinUtil.convertMouseGeometry(
- e.x, e.y, currentResolutionWidth, currentResolutionHeight,
- currentScale, currentAngle);
+ int[] geometry = SkinUtil.convertMouseGeometry(e.x, e.y,
+ currentState.getCurrentResolutionWidth(),
+ currentState.getCurrentResolutionHeight(),
+ currentState.getCurrentScale(), currentState.getCurrentAngle());
logger.info("mousewheel in LCD" +
" x:" + geometry[0] + " y:" + geometry[1] + " value:" + e.count);
menuItem.setText( section.getName().value() );
menuItem.setData( rotationId );
- if ( currentRotationId == rotationId ) {
+ if (currentState.getCurrentRotationId() == rotationId) {
menuItem.setSelection( true );
}
for ( MenuItem m : rotationList ) {
short rotationId = (Short) m.getData();
- if ( rotationId == currentRotationId ) {
+ if (currentState.getCurrentRotationId() == rotationId) {
m.setSelection( true );
break;
}
short rotationId = ( (Short) item.getData() );
- arrangeSkin(currentScale, rotationId);
- LcdStateData lcdStateData = new LcdStateData( currentScale, rotationId );
- communicator.sendToQEMU( SendCommand.CHANGE_LCD_STATE, lcdStateData );
+ arrangeSkin(currentState.getCurrentScale(), rotationId);
+ LcdStateData lcdStateData =
+ new LcdStateData(currentState.getCurrentScale(), rotationId);
+ communicator.sendToQEMU(SendCommand.CHANGE_LCD_STATE, lcdStateData);
}
};
int scale = ( (Scale) item.getData() ).value();
- arrangeSkin(scale, currentRotationId);
- LcdStateData lcdStateData = new LcdStateData( scale, currentRotationId );
- communicator.sendToQEMU( SendCommand.CHANGE_LCD_STATE, lcdStateData );
+ arrangeSkin(scale, currentState.getCurrentRotationId());
+ LcdStateData lcdStateData =
+ new LcdStateData(scale, currentState.getCurrentRotationId());
+ communicator.sendToQEMU(SendCommand.CHANGE_LCD_STATE, lcdStateData);
}
};
for ( MenuItem menuItem : scaleList ) {
int scale = ( (Scale) menuItem.getData() ).value();
- if ( scale == currentScale ) {
+ if (currentState.getCurrentScale() == scale) {
menuItem.setSelection( true );
}
}
public short getCurrentRotationId() {
- return currentRotationId;
+ return currentState.getCurrentRotationId();
}
}
--- /dev/null
+/**
+ * Emulator Skin Process
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.skin;
+
+import org.eclipse.swt.graphics.Point;
+import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
+
+public class EmulatorSkinState {
+ private Point currentResolution;
+ private int currentScale;
+ private short currentRotationId;
+ private int currentAngle;
+
+ public EmulatorSkinState() {
+ this.currentResolution = new Point(480, 800);
+ this.currentScale = 50;
+ this.currentRotationId = RotationInfo.PORTRAIT.id();
+ this.currentAngle = 0;
+ }
+
+ /* resolution */
+ public synchronized Point getCurrentResolution() {
+ return currentResolution;
+ }
+ public synchronized int getCurrentResolutionWidth() {
+ return currentResolution.x;
+ }
+ public synchronized int getCurrentResolutionHeight() {
+ return currentResolution.y;
+ }
+ public synchronized void setCurrentResolution(Point resolution) {
+ setCurrentResolutionWidth(resolution.x);
+ setCurrentResolutionHeight(resolution.y);
+ }
+ public synchronized void setCurrentResolutionWidth(int width) {
+ if (width < 0) {
+ width = 0;
+ }
+ this.currentResolution.x = width;
+ }
+ public synchronized void setCurrentResolutionHeight(int height) {
+ if (height < 0) {
+ height = 0;
+ }
+ this.currentResolution.y = height;
+ }
+
+ /* scale */
+ public synchronized int getCurrentScale() {
+ return currentScale;
+ }
+ public synchronized void setCurrentScale(int scale) {
+ this.currentScale = scale;
+ }
+
+ /* rotation */
+ public synchronized short getCurrentRotationId() {
+ return currentRotationId;
+ }
+ public synchronized void setCurrentRotationId(short rotationId) {
+ this.currentRotationId = rotationId;
+ }
+
+ /* angle */
+ public synchronized int getCurrentAngle() {
+ return currentAngle;
+ }
+ public synchronized void setCurrentAngle(int angle) {
+ this.currentAngle = angle;
+ };
+}