/* build a skin layout */
if (skinInfo.isGeneralPurposeSkin() == false) {
- skinComposer = new ProfileSpecificSkinComposer(config, this, shell,
- currentState, imageRegistry, communicator);
+ skinComposer = new ProfileSpecificSkinComposer(config, this);
((ProfileSpecificSkinComposer) skinComposer)
.addProfileSpecificListener(shell);
} else { /* general purpose skin */
- skinComposer = new GeneralPurposeSkinComposer(config, this, shell,
- currentState, imageRegistry);
+ skinComposer = new GeneralPurposeSkinComposer(config, this);
((GeneralPurposeSkinComposer) skinComposer)
.addGeneralPurposeListener(shell);
import org.tizen.emulator.skin.EmulatorSkin;
import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
-import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
import org.tizen.emulator.skin.dbi.KeyMapType;
import org.tizen.emulator.skin.image.GeneralKeyWindowImageRegistry;
private Image imageFrame; /* nine-patch image */
private Color colorFrame;
- private SocketCommunicator communicator;
private GeneralKeyWindowImageRegistry imageRegistry;
private List<KeyMapType> keyMapList;
private boolean isGrabbedShell;
private Point grabPosition;
- public GeneralKeyWindow(EmulatorSkin skin, Shell parent,
- SocketCommunicator communicator, List<KeyMapType> keyMapList) {
- super(parent, SWT.RIGHT | SWT.CENTER);
+ public GeneralKeyWindow(EmulatorSkin skin, List<KeyMapType> keyMapList) {
+ super(skin.getShell(), SWT.RIGHT | SWT.CENTER);
this.skin = skin;
+ this.parent = skin.getShell();
if (SwtUtil.isMacPlatform() == false) {
this.shell = new Shell(parent,
SWT.NO_TRIM | SWT.RESIZE | SWT.TOOL);
this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
this.keyMapList = keyMapList; //TODO: null
- this.communicator = communicator;
this.grabPosition = new Point(0, 0);
shell.setText(parent.getText());
KeyEventData keyEventData = new KeyEventData(
KeyEventType.PRESSED.value(), keycode, 0, 0);
- communicator.sendToQEMU(
+ skin.communicator.sendToQEMU(
SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false);
}
KeyEventData keyEventData = new KeyEventData(
KeyEventType.RELEASED.value(), keycode, 0, 0);
- communicator.sendToQEMU(
+ skin.communicator.sendToQEMU(
SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false);
}
package org.tizen.emulator.skin.image;
-import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
import org.eclipse.swt.widgets.Display;
import org.tizen.emulator.skin.config.EmulatorConfig;
import org.tizen.emulator.skin.dbi.EmulatorUI;
-import org.tizen.emulator.skin.dbi.ImageListType;
import org.tizen.emulator.skin.dbi.RotationType;
import org.tizen.emulator.skin.dbi.RotationsType;
import org.tizen.emulator.skin.log.SkinLogger;
private static Logger logger =
SkinLogger.getSkinLogger(ImageRegistry.class).getLogger();
- public enum ImageType {
- IMG_TYPE_MAIN,
- IMG_TYPE_PRESSED
- }
-
public enum ResourceImageName {
RESOURCE_ABOUT("about_Tizen_SDK.png"),
RESOURCE_BLANK_GUIDE("blank-guide.png");
private Map<String, Image> resourceImageMap;
private Map<String, Image> iconImageMap;
- private Map<String, Image> skinImageMap;
private String skinPath;
this.resourceImageMap = new HashMap<String, Image>();
this.iconImageMap = new HashMap<String, Image>();
- this.skinImageMap = new HashMap<String, Image>();
init(this.skinPath);
}
}
}
- private String makeKey(Short id, ImageType imageType) {
- return id + ":" + imageType.ordinal();
- }
-
- public Image getSkinImage(Short id, ImageType imageType) {
- Image image = skinImageMap.get(makeKey(id, imageType));
-
- if (image == null) {
- RotationsType rotations = dbiContents.getRotations();
-
- if (null == rotations) {
- logger.severe("Fail to loading rotations element from dbi.");
- return null;
- }
-
- logger.info("get skin image from " + skinPath);
-
- RotationType targetRotation = SkinRotation.getRotation(id);
- List<RotationType> rotationList = rotations.getRotation();
-
- for (RotationType rotation : rotationList) {
- ImageListType imageList = rotation.getImageList();
- if (imageList == null) {
- continue;
- }
-
- String mainImage = imageList.getMainImage();
- String keyPressedImage = imageList.getKeyPressedImage();
-
- if (targetRotation.getName().value().equals(rotation.getName().value())) {
- String mainKey = makeKey(id, ImageType.IMG_TYPE_MAIN);
- skinImageMap.put(mainKey,
- new Image(display, skinPath + File.separator + mainImage));
-
- String pressedKey = makeKey(id, ImageType.IMG_TYPE_PRESSED);
- skinImageMap.put(pressedKey,
- new Image(display, skinPath + File.separator + keyPressedImage));
-
- break;
- }
- }
-
- image = skinImageMap.get(makeKey(id, imageType));
- }
-
- return image;
- }
-
public Image getResourceImage(ResourceImageName name) {
String imageName = name.getName();
Image image = resourceImageMap.get(imageName);
image.dispose();
}
}
-
- /* skin image */
- if (null != skinImageMap) {
- images = skinImageMap.values();
-
- imageIterator = images.iterator();
-
- while (imageIterator.hasNext()) {
- image = imageIterator.next();
- image.dispose();
- }
- }
}
}
--- /dev/null
+/**
+ * Image Resource Management For Profile-Specific Skin
+ *
+ * Copyright (C) 2013 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.image;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.dbi.EmulatorUI;
+import org.tizen.emulator.skin.dbi.ImageListType;
+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.util.SkinRotation;
+
+public class ProfileSkinImageRegistry {
+ private static Logger logger = SkinLogger.getSkinLogger(
+ ProfileSkinImageRegistry.class).getLogger();
+
+ public enum SkinImageType {
+ PROFILE_IMAGE_TYPE_NORMAL,
+ PROFILE_IMAGE_TYPE_PRESSED
+ }
+
+ private Display display;
+ private String skinPath;
+ private EmulatorUI dbiContents;
+ private Map<String, Image> skinImageMap;
+
+ /**
+ * Constructor
+ */
+ public ProfileSkinImageRegistry(EmulatorConfig config,
+ Display display, String skinPath) {
+ this.display = display;
+ this.skinPath = skinPath;
+ this.dbiContents = config.getDbiContents();
+ this.skinImageMap = new HashMap<String, Image>();
+
+ initialize(skinPath);
+ }
+
+ private void initialize(String argSkinPath) {
+ RotationsType rotations = dbiContents.getRotations();
+
+ if (null == rotations) {
+ logger.severe("Fail to loading rotations element from XML");
+ return;
+ }
+
+ List<RotationType> rotationList = rotations.getRotation();
+
+ for (RotationType rotation : rotationList) {
+ SkinRotation.put(rotation);
+ }
+ }
+
+ private String makeKey(Short id, SkinImageType imageType) {
+ return id + ":" + imageType.ordinal();
+ }
+
+ public Image getSkinImage(Short id, SkinImageType imageType) {
+ Image image = skinImageMap.get(makeKey(id, imageType));
+
+ if (image == null) {
+ RotationsType rotations = dbiContents.getRotations();
+
+ if (null == rotations) {
+ logger.severe("Fail to loading rotations element from XML");
+ return null;
+ }
+
+ logger.info("get skin image from " + skinPath);
+
+ RotationType targetRotation = SkinRotation.getRotation(id);
+ List<RotationType> rotationList = rotations.getRotation();
+
+ for (RotationType rotation : rotationList) {
+ ImageListType imageList = rotation.getImageList();
+ if (imageList == null) {
+ continue;
+ }
+
+ String mainImage = imageList.getMainImage();
+ String keyPressedImage = imageList.getKeyPressedImage();
+
+ if (targetRotation.getName().value().equals(rotation.getName().value())) {
+ String mainKey = makeKey(id, SkinImageType.PROFILE_IMAGE_TYPE_NORMAL);
+ skinImageMap.put(mainKey,
+ new Image(display, skinPath + File.separator + mainImage));
+
+ String pressedKey = makeKey(id, SkinImageType.PROFILE_IMAGE_TYPE_PRESSED);
+ skinImageMap.put(pressedKey,
+ new Image(display, skinPath + File.separator + keyPressedImage));
+
+ break;
+ }
+ }
+
+ image = skinImageMap.get(makeKey(id, imageType));
+ }
+
+ return image;
+ }
+
+ public void dispose() {
+ if (null != skinImageMap) {
+ Image image = null;
+
+ Collection<Image> images = skinImageMap.values();
+ Iterator<Image> imageIterator = images.iterator();
+
+ while (imageIterator.hasNext()) {
+ image = imageIterator.next();
+ image.dispose();
+ }
+ }
+ }
+}
import org.tizen.emulator.skin.custom.ColorTag;
import org.tizen.emulator.skin.custom.CustomButton;
import org.tizen.emulator.skin.custom.CustomProgressBar;
-import org.tizen.emulator.skin.image.ImageRegistry;
import org.tizen.emulator.skin.image.ImageRegistry.IconName;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.menu.PopupMenu;
private CustomButton toggleButton;
private EmulatorSkinState currentState;
- private ImageRegistry imageRegistry;
private SkinPatches frameMaker;
private PaintListener shellPaintListener;
private boolean isGrabbedShell;
private Point grabPosition;
- public GeneralPurposeSkinComposer(EmulatorConfig config, EmulatorSkin skin,
- Shell shell, EmulatorSkinState currentState,
- ImageRegistry imageRegistry) {
+ public GeneralPurposeSkinComposer(
+ EmulatorConfig config, EmulatorSkin skin) {
this.config = config;
this.skin = skin;
- this.shell = shell;
- this.currentState = currentState;
- this.imageRegistry = imageRegistry;
+ this.shell = skin.getShell();
+ this.currentState = skin.getEmulatorSkinState();
+
this.isGrabbedShell= false;
this.grabPosition = new Point(0, 0);
@Override
public void composeInternal(Canvas displayCanvas,
final int x, final int y, int scale, short rotationId) {
-
- //shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
shell.setLocation(x, y);
/* This string must match the definition of Emulator-Manager */
shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
if (SwtUtil.isWindowsPlatform()) {
- shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE_ICO));
+ shell.setImage(skin.getImageRegistry()
+ .getIcon(IconName.EMULATOR_TITLE_ICO));
} else {
- shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE));
+ shell.setImage(skin.getImageRegistry()
+ .getIcon(IconName.EMULATOR_TITLE));
}
/* load image for toggle button of key window */
import org.tizen.emulator.skin.dbi.DisplayType;
import org.tizen.emulator.skin.dbi.RegionType;
import org.tizen.emulator.skin.dbi.RotationType;
-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.image.ProfileSkinImageRegistry;
+import org.tizen.emulator.skin.image.ProfileSkinImageRegistry.SkinImageType;
import org.tizen.emulator.skin.log.SkinLogger;
import org.tizen.emulator.skin.menu.PopupMenu;
import org.tizen.emulator.skin.util.SkinRotation;
private Shell shell;
private Canvas lcdCanvas;
private EmulatorSkinState currentState;
- private ImageRegistry imageRegistry;
private SocketCommunicator communicator;
private PaintListener shellPaintListener;
private MouseMoveListener shellMouseMoveListener;
private MouseListener shellMouseListener;
+ private ProfileSkinImageRegistry imageRegistry;
private boolean isGrabbedShell;
private Point grabPosition;
- public ProfileSpecificSkinComposer(EmulatorConfig config, EmulatorSkin skin,
- Shell shell, EmulatorSkinState currentState,
- ImageRegistry imageRegistry, SocketCommunicator communicator) {
+ public ProfileSpecificSkinComposer(
+ EmulatorConfig config, EmulatorSkin skin) {
this.config = config;
this.skin = skin;
- this.shell = shell;
- this.currentState = currentState;
- this.imageRegistry = imageRegistry;
- this.communicator = communicator;
+ this.shell = skin.getShell();
+ this.currentState = skin.getEmulatorSkinState();
+ this.communicator = skin.communicator;
+
this.isGrabbedShell= false;
this.grabPosition = new Point(0, 0);
+
+ this.imageRegistry = new ProfileSkinImageRegistry(
+ config, shell.getDisplay(), skin.skinInfo.getSkinPath());
}
@Override
@Override
public void composeInternal(Canvas lcdCanvas,
int x, int y, int scale, short rotationId) {
-
- //shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
shell.setLocation(x, y);
/* This string must match the definition of Emulator-Manager */
String emulatorName = SkinUtil.makeEmulatorName(config);
shell.setText("Emulator - " + emulatorName);
- lcdCanvas.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ lcdCanvas.setBackground(
+ shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
if (SwtUtil.isWindowsPlatform()) {
- shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE_ICO));
+ shell.setImage(skin.getImageRegistry()
+ .getIcon(IconName.EMULATOR_TITLE_ICO));
} else {
- shell.setImage(imageRegistry.getIcon(IconName.EMULATOR_TITLE));
+ shell.setImage(skin.getImageRegistry()
+ .getIcon(IconName.EMULATOR_TITLE));
}
/* create a progress bar for booting status */
}
currentState.setCurrentImage(SkinUtil.createScaledImage(
- imageRegistry, shell, rotationId, scale, ImageType.IMG_TYPE_MAIN));
+ shell.getDisplay(), imageRegistry,
+ SkinImageType.PROFILE_IMAGE_TYPE_NORMAL,
+ rotationId, scale));
currentState.setCurrentKeyPressedImage(SkinUtil.createScaledImage(
- imageRegistry, shell, rotationId, scale, ImageType.IMG_TYPE_PRESSED));
+ shell.getDisplay(), imageRegistry,
+ SkinImageType.PROFILE_IMAGE_TYPE_PRESSED,
+ rotationId, scale));
if (tempImage != null) {
tempImage.dispose();
if (null != shellMouseListener) {
shell.removeMouseListener(shellMouseListener);
}
+
+ imageRegistry.dispose();
}
}
return;
}
- keyWindow = new GeneralKeyWindow(
- skin, skin.getShell(), skin.communicator, keyMapList);
+ keyWindow = new GeneralKeyWindow(skin, keyMapList);
} else {
// TODO:
String layoutName =
/**
- *
+ * Skin Utilities
*
- * 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.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
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.ImageRegistry;
-import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
+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 Image createScaledImage(ImageRegistry imageRegistry,
- Shell shell, short rotationId, int scale, ImageType type) {
-
+ public static Image createScaledImage(Display display,
+ ProfileSkinImageRegistry imageRegistry, SkinImageType type,
+ short rotationId, int scale) {
Image imageOrigin = imageRegistry.getSkinImage(rotationId, type);
if (imageOrigin == null) {
return null;
int height = (int) (imageDataSrc.height * convertedScale);
imageDataDst = imageDataDst.scaledTo(width, height);
- return new Image(shell.getDisplay(), imageDataDst);
+ return new Image(display, imageDataDst);
}
public static float convertScale(int scale) {