Now, Emulator can foding a HW keys region in general skin.
And I coverted SkinMode class to SkinInformation class.
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.exception.ScreenShotException;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
+import org.tizen.emulator.skin.info.SkinInformation;
import org.tizen.emulator.skin.log.SkinLogger;
-import org.tizen.emulator.skin.mode.SkinMode;
import org.tizen.emulator.skin.screenshot.SdlScreenShotWindow;
import org.tizen.emulator.skin.util.SkinUtil;
import org.tizen.emulator.skin.util.SwtUtil;
/**
* Constructor
*/
- public EmulatorSdlSkin(EmulatorConfig config, SkinMode mode, boolean isOnTop) {
- super(config, mode, isOnTop);
+ public EmulatorSdlSkin(EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop) {
+ super(config, skinInfo, isOnTop);
}
public long compose() {
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.exception.ScreenShotException;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
+import org.tizen.emulator.skin.info.SkinInformation;
import org.tizen.emulator.skin.log.SkinLogger;
-import org.tizen.emulator.skin.mode.SkinMode;
import org.tizen.emulator.skin.screenshot.ShmScreenShotWindow;
import org.tizen.emulator.skin.util.SkinUtil;
/**
* Constructor
*/
- public EmulatorShmSkin(EmulatorConfig config, SkinMode mode, boolean isOnTop) {
- super(config, mode, isOnTop);
+ public EmulatorShmSkin(EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop) {
+ super(config, skinInfo, isOnTop);
this.paletteData = new PaletteData(RED_MASK, GREEN_MASK, BLUE_MASK);
}
import org.tizen.emulator.skin.image.ImageRegistry;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
+import org.tizen.emulator.skin.info.SkinInformation;
import org.tizen.emulator.skin.log.SkinLogger;
-import org.tizen.emulator.skin.mode.SkinMode;
import org.tizen.emulator.skin.screenshot.ScreenShotDialog;
import org.tizen.emulator.skin.util.SkinRegion;
import org.tizen.emulator.skin.util.SkinRotation;
protected Shell shell;
protected ImageRegistry imageRegistry;
protected Canvas lcdCanvas;
- private SkinMode skinMode;
+ private SkinInformation skinInfo;
private Image currentImage;
private Image currentKeyPressedImage;
private Color hoverColor;
private SkinWindow controlPanel;
protected ScreenShotDialog screenShotDialog;
private Menu contextMenu;
+ private Button foldingButton; //TODO:
+ private Decorations decoration; //TODO:
protected SocketCommunicator communicator;
protected long windowHandleId;
* @param config : configuration of emulator skin
* @param isOnTop : always on top flag
*/
- protected EmulatorSkin(EmulatorConfig config, SkinMode mode, boolean isOnTop) {
+ protected EmulatorSkin(EmulatorConfig config, SkinInformation skinInfo, boolean isOnTop) {
this.config = config;
- this.skinMode = mode;
+ this.skinInfo = skinInfo;
this.isDefaultHoverColor = true;
this.isOnTop = isOnTop;
this.pressedKeyEventList = new LinkedList<KeyEventData>();
this.pressedHWKeyCode = 0;
int style = SWT.NO_TRIM;
- if (skinMode == SkinMode.GENERAL) {
+ if (skinInfo.isPhoneShape() == false) {
style = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.BORDER;
}
arrangeSkin(resolutionW, resolutionH, scale, rotationId);
- if (skinMode != SkinMode.GENERAL && null == currentImage) {
+ if (skinInfo.isPhoneShape() && null == currentImage) {
logger.severe("Failed to load initial skin image file. Kill this skin process.");
SkinUtil.openMessage(shell, null,
"Failed to load Skin image file.", SWT.ICON_ERROR, config);
}
+ private void rearrangeSkin() {
+ logger.info("rearrange the skin (" + skinInfo.getSkinOption() + ")");
+ arrangeSkin(currentLcdWidth, currentLcdHeight, currentScale, currentRotationId);
+ }
+
private void arrangeSkin(int resolutionW, int resolutionH, int scale, short rotationId) {
this.currentLcdWidth = resolutionW;
this.currentRotationId = rotationId;
this.currentAngle = SkinRotation.getAngle( rotationId );
- if (skinMode == SkinMode.GENERAL) {
+ if (skinInfo.isPhoneShape() == false) {
/* folding button */
- Button foldingButton = new Button(shell, SWT.PUSH);
- foldingButton.setText(">");
+ if (foldingButton == null) {
+ foldingButton = new Button(shell, SWT.PUSH);
+ foldingButton.setText(">");
+
+ FormData dataFoldingButton = new FormData();
+ dataFoldingButton.left = new FormAttachment(lcdCanvas, 0);
+ dataFoldingButton.top = new FormAttachment(0, 0);
+ foldingButton.setLayoutData(dataFoldingButton);
+
+ foldingButton.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ /* do nothing */
+ }
- FormData dataFoldingButton = new FormData();
- dataFoldingButton.left = new FormAttachment(lcdCanvas, 0);
- dataFoldingButton.top = new FormAttachment(0, 0);
- foldingButton.setLayoutData(dataFoldingButton);
+ @Override
+ public void mouseUp(MouseEvent e) {
+ if (skinInfo.getSkinOption() == 0) {
+ skinInfo.setSkinOption(1);
- foldingButton.addMouseListener(new MouseListener() {
- @Override
- public void mouseDown(MouseEvent e) {
- /* do nothing */
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- //TODO:
- }
+ foldingButton.setText("<");
+ } else {
+ skinInfo.setSkinOption(0);
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- /* do nothing */
- }
- });
-
- /* HW keys region */
- Decorations decoration = new Decorations(shell, SWT.BORDER);
- decoration.setLayout(new GridLayout(1, true));
-
- RotationType rotation = SkinRotation.getRotation(currentRotationId);
- List<KeyMapType> keyMapList = rotation.getKeyMapList().getKeyMap();
-
- // TODO: function
- if (keyMapList != null && keyMapList.isEmpty() == false) {
- for (KeyMapType keyEntry : keyMapList) {
- Button hardKeyButton = new Button(decoration, SWT.FLAT);
- hardKeyButton.setText(keyEntry.getEventInfo().getKeyName());
- hardKeyButton.setToolTipText(keyEntry.getTooltip());
-
- hardKeyButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- final int keycode = keyEntry.getEventInfo().getKeyCode();
- hardKeyButton.addMouseListener(new MouseListener() {
- @Override
- public void mouseDown(MouseEvent e) {
- KeyEventData keyEventData = new KeyEventData(
- KeyEventType.PRESSED.value(), keycode, 0, 0);
- communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
+ foldingButton.setText(">");
}
- @Override
- public void mouseUp(MouseEvent e) {
- KeyEventData keyEventData = new KeyEventData(
- KeyEventType.RELEASED.value(), keycode, 0, 0);
- communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT,
- keyEventData);
- }
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ rearrangeSkin();
+ }
+ });
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ /* do nothing */
+ }
+ });
+ }
+
+ if (skinInfo.getSkinOption() == 0) {
+ /* HW keys region */
+ if (decoration == null) {
+ decoration = new Decorations(shell, SWT.BORDER);
+ decoration.setLayout(new GridLayout(1, true));
+
+ RotationType rotation = SkinRotation.getRotation(currentRotationId);
+ List<KeyMapType> keyMapList = rotation.getKeyMapList().getKeyMap();
+
+ // TODO: function
+ if (keyMapList != null && keyMapList.isEmpty() == false) {
+ for (KeyMapType keyEntry : keyMapList) {
+ Button hardKeyButton = new Button(decoration, SWT.FLAT);
+ hardKeyButton.setText(keyEntry.getEventInfo().getKeyName());
+ hardKeyButton.setToolTipText(keyEntry.getTooltip());
+
+ hardKeyButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ final int keycode = keyEntry.getEventInfo().getKeyCode();
+ hardKeyButton.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ KeyEventData keyEventData = new KeyEventData(
+ KeyEventType.PRESSED.value(), keycode, 0, 0);
+ communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ KeyEventData keyEventData = new KeyEventData(
+ KeyEventType.RELEASED.value(), keycode, 0, 0);
+ communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData);
+ }
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- /* do nothing */
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ /* do nothing */
+ }
+ });
}
- });
+ }
+
+ FormData dataDecoration = new FormData();
+ dataDecoration.left = new FormAttachment(foldingButton, 0);
+ dataDecoration.top = new FormAttachment(0, 0);
+ decoration.setLayoutData(dataDecoration);
+ }
+ } else {
+ if (decoration != null) {
+ decoration.dispose();
+ decoration = null;
}
}
- FormData dataDecoration = new FormData();
- dataDecoration.left = new FormAttachment(foldingButton, 0);
- dataDecoration.top = new FormAttachment(0, 0);
- decoration.setLayoutData(dataDecoration);
} else {
Image tempImage = null;
Image tempKeyPressedImage = null;
/* arrange the lcd */
SkinUtil.adjustLcdGeometry(lcdCanvas, currentLcdWidth, currentLcdHeight,
- scale, rotationId, skinMode);
+ scale, rotationId, skinInfo.isPhoneShape());
/* set window size */
if (null != currentImage) {
}
};
- if (skinMode != SkinMode.GENERAL) {
+ if (skinInfo.isPhoneShape()) {
shell.addPaintListener(shellPaintListener);
}
};
- if (skinMode != SkinMode.GENERAL) {
+ if (skinInfo.isPhoneShape()) {
shell.addMouseTrackListener(shellMouseTrackListener);
}
} //end of mouseMove
};
- if (skinMode != SkinMode.GENERAL) {
+ if (skinInfo.isPhoneShape()) {
shell.addMouseMoveListener(shellMouseMoveListener);
}
}
};
- if (skinMode != SkinMode.GENERAL) {
+ if (skinInfo.isPhoneShape()) {
shell.addMouseListener(shellMouseListener);
}
import org.tizen.emulator.skin.dbi.EmulatorUI;
import org.tizen.emulator.skin.exception.JaxbException;
import org.tizen.emulator.skin.image.ImageRegistry;
+import org.tizen.emulator.skin.info.SkinInformation;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.log.SkinLogger.SkinLogLevel;
-import org.tizen.emulator.skin.mode.SkinMode;
import org.tizen.emulator.skin.util.IOUtil;
import org.tizen.emulator.skin.util.JaxbUtil;
import org.tizen.emulator.skin.util.StringUtil;
Map<String, String> argsMap = parsArgs(args);
/* emulator resolution */
- int resolutionW = Integer.parseInt(
+ /*int resolutionW = Integer.parseInt(
argsMap.get(ArgsConstants.RESOLUTION_WIDTH));
int resolutionH = Integer.parseInt(
- argsMap.get(ArgsConstants.RESOLUTION_HEIGHT));
+ argsMap.get(ArgsConstants.RESOLUTION_HEIGHT));*/
/* get skin path from startup argument */
String skinPath = ImageRegistry.getSkinPath(
- (String) argsMap.get(ArgsConstants.SKIN_PATH), resolutionW, resolutionH);
+ (String) argsMap.get(ArgsConstants.SKIN_PATH));
/* set skin information */
String skinInfoFilePath = skinPath + File.separator + SKIN_INFO_FILE_NAME;
- Properties skinInfo = loadProperties(skinInfoFilePath, false);
- if (null == skinInfo) {
+ Properties skinInfoProperties = loadProperties(skinInfoFilePath, false);
+ if (null == skinInfoProperties) {
logger.severe("Fail to load skin information file.");
Shell temp = new Shell(Display.getDefault());
System.exit(-1);
} else {
- logger.info("skin info:" + skinInfo);
+ logger.info("skin info:" + skinInfoProperties); //TODO:
}
- SkinMode skinMode = SkinMode.STANDARD;
- if (skinInfo.getProperty(SkinInfoConstants.RESOLUTION_WIDTH).equalsIgnoreCase("all") ||
- skinInfo.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT).equalsIgnoreCase("all")) {
- skinMode = SkinMode.GENERAL;
+ boolean skinPhoneShape = true;
+ String skinInfoResolutionW = skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_WIDTH);
+ String skinInfoResolutionH = skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT);
+ if (skinInfoResolutionW.equalsIgnoreCase("all") ||
+ skinInfoResolutionH.equalsIgnoreCase("all")) {
+ skinPhoneShape = false;
}
+ SkinInformation skinInfo = new SkinInformation(
+ skinInfoProperties.getProperty(SkinInfoConstants.SKIN_NAME), skinPhoneShape);
/* set emulator window skin property */
String skinPropFilePath = vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME;
/* create skin */
EmulatorSkin skin;
if (SwtUtil.isMacPlatform()) {
- skin = new EmulatorShmSkin(config, skinMode, isOnTop);
+ skin = new EmulatorShmSkin(config, skinInfo, isOnTop);
} else { // linux & windows
- skin = new EmulatorSdlSkin(config, skinMode, isOnTop);
+ skin = new EmulatorSdlSkin(config, skinInfo, isOnTop);
}
long windowHandleId = skin.compose();
import org.tizen.emulator.skin.dbi.RotationType;
import org.tizen.emulator.skin.dbi.RotationsType;
import org.tizen.emulator.skin.log.SkinLogger;
-import org.tizen.emulator.skin.mode.SkinMode;
import org.tizen.emulator.skin.util.IOUtil;
import org.tizen.emulator.skin.util.SkinRotation;
}
- public static String getSkinPath(String argSkinPath,
- int resolutionX, int resolutionY) {
+ public static String getSkinPath(String argSkinPath) {
/* When emulator has a invalid skin path,
emulator uses default skin path instead of it */
String defaultSkinPath = ".." + //TODO:
return null;
}
- String skinPath = getSkinPath(argSkinPath, resolutionWidth, resolutionHeight);
+ String skinPath = getSkinPath(argSkinPath);
logger.info("get image data of skin from " + skinPath);
RotationType targetRotation = SkinRotation.getRotation( id );
--- /dev/null
+/**
+ *
+ *
+ * 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.info;
+
+/*
+ *
+ */
+public class SkinInformation {
+ private String skinName;
+ private boolean skinPhoneShape;
+ private int skinOption;
+
+ public SkinInformation(String skinName, boolean skinPhoneShape) {
+ this.skinName = skinName;
+ this.skinPhoneShape = skinPhoneShape;
+ this.skinOption = 0;
+ }
+
+ public String getSkinName() {
+ return skinName;
+ }
+
+ public boolean isPhoneShape() {
+ return skinPhoneShape;
+ }
+
+ public int getSkinOption() {
+ return skinOption;
+ }
+
+ public void setSkinOption(int option) {
+ this.skinOption = option;
+ }
+}
+++ /dev/null
-/**
- *
- *
- * 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.mode;
-
-/**
- *
- */
-public enum SkinMode {
- GENERAL("general"),
- FULLSCREEN("fullscreen"), /* not used yet */
- STANDARD("standard"),
- CUSTOM("custom"); /* not used yet */
-
- private String value;
-
- SkinMode(String value) {
- this.value = value;
- }
-
- public String value() {
- return this.value;
- }
-
- public static SkinMode getValue(String val) {
- SkinMode[] values = SkinMode.values();
- for (int i = 0; i < values.length; i++) {
- if (values[i].value.equalsIgnoreCase(val) == true) {
- return values[i];
- }
- }
-
- return SkinMode.STANDARD;
- }
-}
-
import org.tizen.emulator.skin.dbi.RotationType;
import org.tizen.emulator.skin.image.ImageRegistry;
import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
-import org.tizen.emulator.skin.mode.SkinMode;
/**
public static void adjustLcdGeometry(
Canvas lcdCanvas, int resolutionW, int resolutionH,
- int scale, short rotationId, SkinMode mode) {
+ int scale, short rotationId, boolean isPhoneShape) {
float convertedScale = convertScale(scale);
int l = 0, t = 0, w = 0, h = 0;
- if (mode == SkinMode.GENERAL) {
+ if (isPhoneShape == false) {
RotationInfo rotation = RotationInfo.getValue(rotationId);
/* resoultion, that is lcd size in general skin mode */