/* get keywindow image */
//TODO: null
- keyWindowImage = imageRegistry.getKeyWindowImage(
+ this.keyWindowImage = imageRegistry.getKeyWindowImage(
EmulatorConfig.DEFAULT_WINDOW_ROTATION,
SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL);
- keyWindowPressedImage = imageRegistry.getKeyWindowImage(
+ this.keyWindowPressedImage = imageRegistry.getKeyWindowImage(
EmulatorConfig.DEFAULT_WINDOW_ROTATION,
SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED);
keyWindowImage.getImageData().height);
/* custom window shape */
- SkinUtil.trimShell(shell, keyWindowImage);
+ shell.setRegion(SkinUtil.getTrimmingRegion(keyWindowImage));
addKeyWindowListener();
}
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.skin.EmulatorSkin;
import org.tizen.emulator.skin.EmulatorSkinState;
/* This string must match the definition of Emulator-Manager */
String emulatorName = SkinUtil.makeEmulatorName(config);
- shell.setText("Emulator - " + emulatorName);
+ shell.setText(SkinUtil.EMULATOR_PREFIX + " - " + emulatorName);
displayCanvas.setBackground(
shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
skin.getKeyWindowKeeper().openKeyWindow(
SWT.RIGHT | SWT.CENTER, false);
} else {
- skin.getKeyWindowKeeper().openKeyWindow(
- dockValue, false);
+ skin.getKeyWindowKeeper().openKeyWindow(dockValue, false);
}
}
});
@Override
public void arrangeSkin(int scale, short rotationId) {
- currentState.setCurrentScale(scale);
- currentState.setCurrentRotationId(rotationId);
+ //TODO: eject the calculation from UI thread
- /* arrange the display */
- Rectangle displayBounds = adjustLcdGeometry(displayCanvas,
+ /* calculate display bounds */
+ Rectangle displayBounds = adjustDisplayGeometry(displayCanvas,
currentState.getCurrentResolutionWidth(),
- currentState.getCurrentResolutionHeight(), scale, rotationId);
+ currentState.getCurrentResolutionHeight(),
+ scale, rotationId);
if (displayBounds == null) {
logger.severe("Failed to read display information for skin.");
}
logger.info("display bounds : " + displayBounds);
+ /* make general skin */
+ Image generalSkin =
+ frameMaker.getPatchedImage(displayBounds.width, displayBounds.height);
+
+ /* make window region */
+ Region region = getTrimmingRegion(shell.getDisplay(), generalSkin);
+
+ /* update the skin state information */
+ currentState.setCurrentScale(scale);
+ currentState.setCurrentRotationId(rotationId);
currentState.setDisplayBounds(displayBounds);
- displayCanvas.setBounds(displayBounds);
- /* arrange the skin image */
Image tempImage = null;
-
if (currentState.getCurrentImage() != null) {
tempImage = currentState.getCurrentImage();
}
-
- currentState.setCurrentImage(
- frameMaker.getPatchedImage(displayBounds.width, displayBounds.height));
+ currentState.setCurrentImage(generalSkin);
if (tempImage != null) {
tempImage.dispose();
}
+ /* arrange the display */
+ displayCanvas.setBounds(displayBounds);
+
/* arrange the toggle button of key window */
toggleButton.setBounds(displayBounds.x + displayBounds.width + 4,
displayBounds.y + ((displayBounds.height - toggleButton.getImageSize().y) / 2),
}
/* arrange the pair tag */
- int rotationType = currentState.getCurrentRotationId();
- if (rotationType == RotationInfo.PORTRAIT.id()) {
+ if (rotationId == RotationInfo.PORTRAIT.id()) {
skin.pairTag.setBounds(
PAIR_TAG_POSITION_X, PAIR_TAG_POSITION_Y,
skin.pairTag.getWidth(), skin.pairTag.getHeight());
- } else if (rotationType == RotationInfo.LANDSCAPE.id()) {
+ } else if (rotationId == RotationInfo.LANDSCAPE.id()) {
skin.pairTag.setBounds(
PAIR_TAG_POSITION_Y,
shell.getSize().y - PAIR_TAG_POSITION_X - skin.pairTag.getHeight(),
skin.pairTag.getWidth(), skin.pairTag.getHeight());
- } else if (rotationType == RotationInfo.REVERSE_PORTRAIT.id()) {
+ } else if (rotationId == RotationInfo.REVERSE_PORTRAIT.id()) {
skin.pairTag.setBounds(
shell.getSize().x - PAIR_TAG_POSITION_X - skin.pairTag.getWidth(),
shell.getSize().y - PAIR_TAG_POSITION_Y - skin.pairTag.getHeight(),
skin.pairTag.getWidth(), skin.pairTag.getHeight());
- } else if (rotationType == RotationInfo.REVERSE_LANDSCAPE.id()) {
+ } else if (rotationId == RotationInfo.REVERSE_LANDSCAPE.id()) {
skin.pairTag.setBounds(
shell.getSize().x - PAIR_TAG_POSITION_Y - skin.pairTag.getWidth(),
PAIR_TAG_POSITION_X,
}
/* custom window shape */
- trimPatchedShell(shell, currentState.getCurrentImage());
+ if (region != null) {
+ shell.setRegion(region);
+ }
currentState.setNeedToUpdateDisplay(true);
shell.redraw();
}
@Override
- public Rectangle adjustLcdGeometry(
+ public Rectangle adjustDisplayGeometry(
Canvas displayCanvas, int resolutionW, int resolutionH,
int scale, short rotationId) {
- Rectangle lcdBounds = new Rectangle(
+ Rectangle displayBounds = new Rectangle(
frameMaker.getPatchWidth(), frameMaker.getPatchHeight(), 0, 0);
float convertedScale = SkinUtil.convertScale(scale);
RotationInfo rotation = RotationInfo.getValue(rotationId);
- /* resoultion, that is lcd size in general skin mode */
+ /* resoultion, that is display size in general skin mode */
if (RotationInfo.LANDSCAPE == rotation ||
RotationInfo.REVERSE_LANDSCAPE == rotation) {
- lcdBounds.width = (int)(resolutionH * convertedScale);
- lcdBounds.height = (int)(resolutionW * convertedScale);
+ displayBounds.width = (int)(resolutionH * convertedScale);
+ displayBounds.height = (int)(resolutionW * convertedScale);
} else {
- lcdBounds.width = (int)(resolutionW * convertedScale);
- lcdBounds.height = (int)(resolutionH * convertedScale);
+ displayBounds.width = (int)(resolutionW * convertedScale);
+ displayBounds.height = (int)(resolutionH * convertedScale);
}
- return lcdBounds;
+ return displayBounds;
}
- public static void trimPatchedShell(Shell shell, Image image) {
+ public static Region getTrimmingRegion(Display display, Image image) {
if (null == image) {
- return;
+ return null;
}
- ImageData imageData = image.getImageData();
+ ImageData imageData = image.getImageData();
int width = imageData.width;
int height = imageData.height;
Region region = new Region();
region.add(new Rectangle(0, 0, width, height));
- int r = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getRed();
- int g = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getGreen();
- int b = shell.getDisplay().getSystemColor(SWT.COLOR_MAGENTA).getBlue();
+ int r = display.getSystemColor(SWT.COLOR_MAGENTA).getRed();
+ int g = display.getSystemColor(SWT.COLOR_MAGENTA).getGreen();
+ int b = display.getSystemColor(SWT.COLOR_MAGENTA).getBlue();
int colorKey = 0;
if (SwtUtil.isWindowsPlatform()) {
colorKey = r << 16 | g << 8 | b;
}
+ int j = 0;
for (int i = 0; i < width; i++) {
- for (int j = 0; j < height; j++) {
+ for (j = 0; j < height; j++) {
int colorPixel = imageData.getPixel(i, j);
if (colorPixel == colorKey /* magenta */) {
region.subtract(i, j, 1, 1);
}
}
- shell.setRegion(region);
+ return region;
}
public void addGeneralPurposeListener(final Shell shell) {
/**
- *
+ * Skin Composer Interface
*
- * 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>
public abstract void arrangeSkin(int scale, short rotationId);
- public abstract Rectangle adjustLcdGeometry(
- Canvas lcdCanvas, int resolutionW, int resolutionH,
+ public abstract Rectangle adjustDisplayGeometry(
+ Canvas displayCanvas, int resolutionW, int resolutionH,
int scale, short rotationId);
public abstract void composerFinalize();
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.skin.EmulatorSkin;
/* This string must match the definition of Emulator-Manager */
String emulatorName = SkinUtil.makeEmulatorName(config);
- shell.setText("Emulator - " + emulatorName);
+ shell.setText(SkinUtil.EMULATOR_PREFIX + " - " + emulatorName);
lcdCanvas.setBackground(
shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
@Override
public void arrangeSkin(int scale, short rotationId) {
- currentState.setCurrentScale(scale);
- currentState.setCurrentRotationId(rotationId);
+ //TODO: eject the calculation from UI thread
- /* arrange the display */
- Rectangle lcdBounds = adjustLcdGeometry(lcdCanvas,
+ /* calculate display bounds */
+ Rectangle displayBounds = adjustDisplayGeometry(lcdCanvas,
currentState.getCurrentResolutionWidth(),
currentState.getCurrentResolutionHeight(), scale, rotationId);
- if (lcdBounds == null) {
+ if (displayBounds == null) {
logger.severe("Failed to read display information for skin.");
SkinUtil.openMessage(shell, null,
"Failed to read display information for skin.\n" +
SWT.ICON_ERROR, config);
System.exit(-1);
}
- logger.info("display bounds : " + lcdBounds);
+ logger.info("display bounds : " + displayBounds);
+
+ /* make profile skin */
+ Image originSkin = imageRegistry.getSkinImage(
+ rotationId, SkinImageType.PROFILE_IMAGE_TYPE_NORMAL);
+ Image profileSkin = SkinUtil.createScaledImage(
+ shell.getDisplay(), originSkin, rotationId, scale);
+
+ Image originSkinKeyPressed = imageRegistry.getSkinImage(
+ rotationId, SkinImageType.PROFILE_IMAGE_TYPE_PRESSED);
+ Image profileSkinKeyPressed = SkinUtil.createScaledImage(
+ shell.getDisplay(), originSkinKeyPressed, rotationId, scale);
- currentState.setDisplayBounds(lcdBounds);
+ /* make window region */
+ Region region = SkinUtil.getTrimmingRegion(profileSkin);
+
+ /* update the skin state information */
+ currentState.setCurrentScale(scale);
+ currentState.setCurrentRotationId(rotationId);
+ currentState.setDisplayBounds(displayBounds);
- /* arrange the skin image */
Image tempImage = null;
Image tempKeyPressedImage = null;
tempKeyPressedImage = currentState.getCurrentKeyPressedImage();
}
- currentState.setCurrentImage(SkinUtil.createScaledImage(
- shell.getDisplay(), imageRegistry,
- SkinImageType.PROFILE_IMAGE_TYPE_NORMAL,
- rotationId, scale));
- currentState.setCurrentKeyPressedImage(SkinUtil.createScaledImage(
- shell.getDisplay(), imageRegistry,
- SkinImageType.PROFILE_IMAGE_TYPE_PRESSED,
- rotationId, scale));
+ currentState.setCurrentImage(profileSkin);
+ currentState.setCurrentKeyPressedImage(profileSkinKeyPressed);
if (tempImage != null) {
tempImage.dispose();
tempKeyPressedImage.dispose();
}
+ /* arrange the display */
if (SwtUtil.isMacPlatform() == true) {
lcdCanvas.setBounds(currentState.getDisplayBounds());
}
/* arrange the progress bar */
if (skin.bootingProgress != null) {
- skin.bootingProgress.setBounds(lcdBounds.x,
- lcdBounds.y + lcdBounds.height + 1, lcdBounds.width, 2);
+ skin.bootingProgress.setBounds(displayBounds.x,
+ displayBounds.y + displayBounds.height + 1, displayBounds.width, 2);
}
/* set window size */
}
/* custom window shape */
- SkinUtil.trimShell(shell, currentState.getCurrentImage());
+ if (region != null) {
+ shell.setRegion(region);
+ }
currentState.setNeedToUpdateDisplay(true);
shell.redraw();
}
@Override
- public Rectangle adjustLcdGeometry(
- Canvas lcdCanvas, int resolutionW, int resolutionH,
+ public Rectangle adjustDisplayGeometry(
+ Canvas displayCanvas, int resolutionW, int resolutionH,
int scale, short rotationId) {
- Rectangle lcdBounds = new Rectangle(0, 0, 0, 0);
+ Rectangle displayBounds = new Rectangle(0, 0, 0, 0);
float convertedScale = SkinUtil.convertScale(scale);
RotationType rotation = SkinRotation.getRotation(rotationId);
- DisplayType lcd = rotation.getDisplay(); /* from dbi */
- if (lcd == null) {
+ DisplayType display = rotation.getDisplay(); /* from dbi */
+ if (display == null) {
return null;
}
- RegionType region = lcd.getRegion();
+ RegionType region = display.getRegion();
if (region == null) {
return null;
}
Integer width = region.getWidth();
Integer height = region.getHeight();
- lcdBounds.x = (int) (left * convertedScale);
- lcdBounds.y = (int) (top * convertedScale);
- lcdBounds.width = (int) (width * convertedScale);
- lcdBounds.height = (int) (height * convertedScale);
+ displayBounds.x = (int) (left * convertedScale);
+ displayBounds.y = (int) (top * convertedScale);
+ displayBounds.width = (int) (width * convertedScale);
+ displayBounds.height = (int) (height * convertedScale);
- return lcdBounds;
+ return displayBounds;
}
public void addProfileSpecificListener(final Shell shell) {
+++ /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>
- * HyunJun Son
- * Hyunjin Lee <hyunjin816.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.util;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
-import org.tizen.emulator.skin.dbi.RotationType;
-
-
-/**
- *
- *
- */
-public class KeyWindowRotation {
-
- private static Map<Short, RotationType> rotationMap;
- private static Map<Short, RotationInfo> angleMap;
-
- private KeyWindowRotation(){}
-
- static {
- rotationMap = new LinkedHashMap<Short, RotationType>();
- angleMap = new HashMap<Short, RotationInfo>();
- }
-
- public static void clear() {
- if (!rotationMap.isEmpty())
- rotationMap.clear();
- if (!angleMap.isEmpty())
- angleMap.clear();
- }
-
- public static void put(RotationType rotation ) {
-
- if ( RotationInfo.PORTRAIT.value().equalsIgnoreCase( rotation.getName().value() ) ) {
- rotationMap.put( RotationInfo.PORTRAIT.id(), rotation );
- angleMap.put( RotationInfo.PORTRAIT.id(), RotationInfo.PORTRAIT );
- } else if ( RotationInfo.LANDSCAPE.value().equalsIgnoreCase( rotation.getName().value() ) ) {
- rotationMap.put( RotationInfo.LANDSCAPE.id(), rotation );
- angleMap.put( RotationInfo.LANDSCAPE.id(), RotationInfo.LANDSCAPE );
- } else if ( RotationInfo.REVERSE_PORTRAIT.value().equalsIgnoreCase( rotation.getName().value() ) ) {
- rotationMap.put( RotationInfo.REVERSE_PORTRAIT.id(), rotation );
- angleMap.put( RotationInfo.REVERSE_PORTRAIT.id(), RotationInfo.REVERSE_PORTRAIT );
- } else if ( RotationInfo.REVERSE_LANDSCAPE.value().equalsIgnoreCase( rotation.getName().value() ) ) {
- rotationMap.put( RotationInfo.REVERSE_LANDSCAPE.id(), rotation );
- angleMap.put( RotationInfo.REVERSE_LANDSCAPE.id(), RotationInfo.REVERSE_LANDSCAPE );
- }
-
- }
-
- public static int getAngle( Short rotationId ) {
- RotationInfo rotationInfo = angleMap.get(rotationId);
- if( null != rotationInfo ) {
- return rotationInfo.angle();
- }else {
- return 0;
- }
- }
-
- public static RotationType getRotation( Short rotationId ) {
- return rotationMap.get(rotationId);
- }
-
- public static Iterator<Entry<Short, RotationType>>getRotationIterator() {
- return rotationMap.entrySet().iterator();
- }
-
-}
import org.tizen.emulator.skin.dbi.KeyMapType;
import org.tizen.emulator.skin.dbi.RegionType;
import org.tizen.emulator.skin.dbi.RotationType;
-import org.tizen.emulator.skin.image.ProfileSkinImageRegistry;
-import org.tizen.emulator.skin.image.ProfileSkinImageRegistry.SkinImageType;
import org.tizen.emulator.skin.layout.HWKey;
import org.tizen.emulator.skin.log.SkinLogger;
public static final int UNKNOWN_KEYCODE = -1;
public static final int SCALE_CONVERTER = 100;
- public static final String EMULATOR_PREFIX = "emulator";
+ public static final String EMULATOR_PREFIX = "Emulator";
private static Logger logger =
SkinLogger.getSkinLogger(SkinUtil.class).getLogger();
return false;
}
- public static void trimShell(Shell shell, Image image) {
- /* trim transparent pixels in image.
- * especially, corner round areas. */
+ public static Region getTrimmingRegion(Image image) {
if (null == image) {
- return;
+ return null;
}
ImageData imageData = image.getImageData();
-
int width = imageData.width;
int height = imageData.height;
Region region = new Region();
region.add(new Rectangle(0, 0, width, height));
+ int j = 0;
for (int i = 0; i < width; i++) {
- for (int j = 0; j < height; j++) {
- int alpha = imageData.getAlpha(i, j);
- if (0 == alpha) {
+ for (j = 0; j < height; j++) {
+ if (0 == imageData.getAlpha(i, j)) {
region.subtract(i, j, 1, 1);
}
}
}
- shell.setRegion(region);
+ return region;
}
public static void trimShell(Shell shell, Image image,
}
ImageData imageData = image.getImageData();
-
int right = left + width;
int bottom = top + height;
return;
}
+ int j = 0;
for (int i = left; i < right; i++) {
- for (int j = top; j < bottom; j++) {
- int alpha = imageData.getAlpha(i, j);
- if (0 == alpha) {
+ for (j = top; j < bottom; j++) {
+ if (0 == imageData.getAlpha(i, j)) {
region.subtract(i, j, 1, 1);
} else {
region.add(i, j, 1, 1);
}
public static Image createScaledImage(Display display,
- ProfileSkinImageRegistry imageRegistry, SkinImageType type,
- short rotationId, int scale) {
- Image imageOrigin = imageRegistry.getSkinImage(rotationId, type);
+ Image imageOrigin, short rotationId, int scale) {
if (imageOrigin == null) {
return null;
}