From: GiWoong Kim Date: Wed, 16 Oct 2013 09:11:16 +0000 (+0900) Subject: skin: load nine-patch image throught imageRegistry X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~689 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4198fa7c735b561c81cb2db1ef799d39f131bd8;p=sdk%2Femulator%2Fqemu.git skin: load nine-patch image throught imageRegistry Change-Id: Ieaf2046efa8cd52c163a2c2d18cb7dd7d4c084fb Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index a1e4bef3bd..0af8d5deb3 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -205,6 +205,7 @@ public class EmulatorSkin { this.currentState = new EmulatorSkinState(); setColorVM(); /* generate a identity color */ + this.keyWindowKeeper = new KeyWindowKeeper(this); } @@ -231,6 +232,8 @@ public class EmulatorSkin { } public long initLayout() { + logger.info("initialize the skin layout"); + imageRegistry = ImageRegistry.getInstance(); /* set emulator states */ @@ -249,8 +252,6 @@ public class EmulatorSkin { isOnKbd = false; popupMenu = new PopupMenu(config, this); - getKeyWindowKeeper().determineLayout(); - /* build a skin layout */ if (skinInfo.isGeneralPurposeSkin() == false) { skinComposer = new ProfileSpecificSkinComposer(config, this); @@ -406,7 +407,7 @@ public class EmulatorSkin { /* close the Key Window */ if (getKeyWindowKeeper() != null) { - getKeyWindowKeeper().closeKeyWindow(); + getKeyWindowKeeper().dispose(); } /* dispose the images */ diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/GeneralKeyWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/GeneralKeyWindow.java index fb784f4ca2..baf44b9722 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/GeneralKeyWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/GeneralKeyWindow.java @@ -61,7 +61,6 @@ import org.tizen.emulator.skin.layout.SkinPatches; import org.tizen.emulator.skin.util.SwtUtil; public class GeneralKeyWindow extends SkinWindow { - private static final String PATCH_IMAGES_PATH = "images/key-window/"; private static final int SHELL_MARGIN_BOTTOM = 3; private static final int PAIRTAG_CIRCLE_SIZE = 8; private static final int PAIRTAG_MARGIN_BOTTOM = 6; @@ -95,7 +94,8 @@ public class GeneralKeyWindow extends SkinWindow { private boolean isGrabbedShell; private Point grabPosition; - public GeneralKeyWindow(EmulatorSkin skin, List keyMapList) { + public GeneralKeyWindow(EmulatorSkin skin, + GeneralKeyWindowImageRegistry imageRegstry, List keyMapList) { super(skin.getShell(), SWT.RIGHT | SWT.CENTER); this.skin = skin; @@ -103,8 +103,24 @@ public class GeneralKeyWindow extends SkinWindow { this.shell = new Shell(parent.getDisplay() /* for Mac & Always on Top */, SWT.NO_TRIM | SWT.RESIZE | SWT.TOOL | SWT.NO_FOCUS); - this.imageRegistry = new GeneralKeyWindowImageRegistry(shell.getDisplay()); - this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH); + this.imageRegistry = imageRegstry; + this.frameMaker = new SkinPatches( + imageRegistry.getKeyWindowImage( + GeneralKeyWindowImageName.KEYWINDOW_PATCH_LT), + imageRegistry.getKeyWindowImage( + GeneralKeyWindowImageName.KEYWINDOW_PATCH_T), + imageRegistry.getKeyWindowImage( + GeneralKeyWindowImageName.KEYWINDOW_PATCH_RT), + imageRegistry.getKeyWindowImage( + GeneralKeyWindowImageName.KEYWINDOW_PATCH_L), + imageRegistry.getKeyWindowImage( + GeneralKeyWindowImageName.KEYWINDOW_PATCH_R), + imageRegistry.getKeyWindowImage( + GeneralKeyWindowImageName.KEYWINDOW_PATCH_LB), + imageRegistry.getKeyWindowImage( + GeneralKeyWindowImageName.KEYWINDOW_PATCH_B), + imageRegistry.getKeyWindowImage( + GeneralKeyWindowImageName.KEYWINDOW_PATCH_RB)); this.keyMapList = keyMapList; //TODO: null this.grabPosition = new Point(0, 0); @@ -504,8 +520,5 @@ public class GeneralKeyWindow extends SkinWindow { } colorFrame.dispose(); - - frameMaker.freePatches(); - imageRegistry.dispose(); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java index d9fdf91e13..7aef8b9121 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java @@ -47,6 +47,15 @@ public class GeneralKeyWindowImageRegistry { GeneralKeyWindowImageRegistry.class).getLogger(); public enum GeneralKeyWindowImageName { + KEYWINDOW_PATCH_LT("LT.png"), + KEYWINDOW_PATCH_T("T.png"), + KEYWINDOW_PATCH_RT("RT.png"), + KEYWINDOW_PATCH_L("L.png"), + KEYWINDOW_PATCH_R("R.png"), + KEYWINDOW_PATCH_LB("LB.png"), + KEYWINDOW_PATCH_B("B.png"), + KEYWINDOW_PATCH_RB("RB.png"), + KEYBUTTON_NORMAL("keybutton_nml.png"), KEYBUTTON_HOVER("keybutton_hover.png"), KEYBUTTON_PUSHED("keybutton_pushed.png"), @@ -113,6 +122,8 @@ public class GeneralKeyWindowImageRegistry { } public void dispose() { + logger.info("dispose"); + if (null != keyWindowImageMap) { Image image = null; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java index df77af4888..158ce6ccb5 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java @@ -47,6 +47,15 @@ public class GeneralSkinImageRegistry { GeneralSkinImageRegistry.class).getLogger(); public enum GeneralSkinImageName { + SKIN_PATCH_LT("LT.png"), + SKIN_PATCH_T("T.png"), + SKIN_PATCH_RT("RT.png"), + SKIN_PATCH_L("L.png"), + SKIN_PATCH_R("R.png"), + SKIN_PATCH_LB("LB.png"), + SKIN_PATCH_B("B.png"), + SKIN_PATCH_RB("RB.png"), + TOGGLE_BUTTON_NORMAL("arrow_nml.png"), TOGGLE_BUTTON_HOVER("arrow_hover.png"), TOGGLE_BUTTON_PUSHED("arrow_pushed.png"); @@ -104,6 +113,8 @@ public class GeneralSkinImageRegistry { } public void dispose() { + logger.info("dispose"); + if (null != skinImageMap) { Image image = null; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java index 35e3e57449..84e81ac97a 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java @@ -119,6 +119,8 @@ public class ProfileSkinImageRegistry { } public void dispose() { + logger.info("dispose"); + if (null != skinImageMap) { Image image = null; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java index fa68254f78..adcf4d96a6 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java @@ -106,6 +106,8 @@ public class SpecialKeyWindowImageRegistry { } public void dispose() { + logger.info("dispose"); + if (null != keyWindowImageMap) { Image image = null; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java index 5eac5fa241..73c6e6b6fb 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java @@ -63,7 +63,6 @@ import org.tizen.emulator.skin.util.SkinUtil; import org.tizen.emulator.skin.util.SwtUtil; public class GeneralPurposeSkinComposer implements ISkinComposer { - private static final String PATCH_IMAGES_PATH = "images/emul-window/"; private static final int PAIR_TAG_POSITION_X = 26; private static final int PAIR_TAG_POSITION_Y = 13; @@ -101,7 +100,16 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { this.imageRegistry = new GeneralSkinImageRegistry(shell.getDisplay()); - this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH); + this.frameMaker = new SkinPatches( + imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_LT), + imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_T), + imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_RT), + imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_L), + imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_R), + imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_LB), + imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_B), + imageRegistry.getSkinImage(GeneralSkinImageName.SKIN_PATCH_RB)); + this.backgroundColor = new Color(shell.getDisplay(), new RGB(38, 38, 38)); } @@ -463,7 +471,6 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { backgroundColor.dispose(); } - frameMaker.freePatches(); imageRegistry.dispose(); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java index 5ca395f7da..68de9c9fe2 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java @@ -1,7 +1,7 @@ /** + * General Skin Frame Maker * - * - * 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 @@ -43,7 +43,6 @@ public class SkinPatches { SkinLogger.getSkinLogger(SkinPatches.class).getLogger(); private Display display; - private String pathImage; private int patchWidth; private int patchHeight; @@ -59,23 +58,25 @@ public class SkinPatches { private Image imageB; private Image imageRB; - // TODO: configurable - private static final String SKIN_PATCH_IMG_LT = "LT.png"; - private static final String SKIN_PATCH_IMG_T = "T.png"; - private static final String SKIN_PATCH_IMG_RT = "RT.png"; + /** + * Constructor + */ + public SkinPatches( + Image leftTop, Image middleTop, Image rightTop, + Image leftMiddle, Image rightMiddle, + Image leftBottom, Image middleBottom, Image rightBottom) { + this.display = Display.getCurrent(); - private static final String SKIN_PATCH_IMG_L = "L.png"; - private static final String SKIN_PATCH_IMG_R = "R.png"; + imageLT = leftTop; + imageT = middleTop; + imageRT = rightTop; - private static final String SKIN_PATCH_IMG_LB = "LB.png"; - private static final String SKIN_PATCH_IMG_B = "B.png"; - private static final String SKIN_PATCH_IMG_RB = "RB.png"; + imageL = leftMiddle; + imageR = rightMiddle; - public SkinPatches(String path) { - this.display = Display.getCurrent(); - this.pathImage = path; - - loadPatches(pathImage); + imageLB = leftBottom; + imageB = middleBottom; + imageRB = rightBottom; // TODO: configurable this.patchWidth = imageLT.getImageData().width; @@ -127,42 +128,4 @@ public class SkinPatches { return patchedImage; } - - private void loadPatches(String path) { - ClassLoader loader = this.getClass().getClassLoader(); - - imageLT = new Image(display, - loader.getResourceAsStream(path + SKIN_PATCH_IMG_LT)); - logger.info("left-top image is loaded from " + - path + SKIN_PATCH_IMG_LT); - imageT = new Image(display, - loader.getResourceAsStream(path + SKIN_PATCH_IMG_T)); - imageRT = new Image(display, - loader.getResourceAsStream(path + SKIN_PATCH_IMG_RT)); - - imageL = new Image(display, - loader.getResourceAsStream(path + SKIN_PATCH_IMG_L)); - imageR = new Image(display, - loader.getResourceAsStream(path + SKIN_PATCH_IMG_R)); - - imageLB = new Image(display, - loader.getResourceAsStream(path + SKIN_PATCH_IMG_LB)); - imageB = new Image(display, - loader.getResourceAsStream(path + SKIN_PATCH_IMG_B)); - imageRB = new Image(display, - loader.getResourceAsStream(path + SKIN_PATCH_IMG_RB)); - } - - public void freePatches() { - imageLT.dispose(); - imageT.dispose(); - imageRT.dispose(); - - imageL.dispose(); - imageR.dispose(); - - imageLB.dispose(); - imageB.dispose(); - imageRB.dispose(); - } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java index 5f7bfeca48..66e0e441e9 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java @@ -38,6 +38,7 @@ import org.tizen.emulator.skin.custom.GeneralKeyWindow; import org.tizen.emulator.skin.custom.SkinWindow; import org.tizen.emulator.skin.custom.SpecialKeyWindow; import org.tizen.emulator.skin.dbi.KeyMapType; +import org.tizen.emulator.skin.image.GeneralKeyWindowImageRegistry; import org.tizen.emulator.skin.log.SkinLogger; import org.tizen.emulator.skin.util.SkinUtil; @@ -50,6 +51,8 @@ public class KeyWindowKeeper { private int recentlyDocked; private int indexLayout; + private GeneralKeyWindowImageRegistry imageRegstry; + /** * Constructor */ @@ -57,6 +60,7 @@ public class KeyWindowKeeper { this.skin = skin; this.recentlyDocked = SWT.NONE; this.indexLayout = -1; + this.imageRegstry = null; } public void openKeyWindow(int dockValue, boolean recreate) { @@ -80,7 +84,14 @@ public class KeyWindowKeeper { } /* create a Key Window */ + determineLayout(); + if (isGeneralKeyWindow() == true) { + if (imageRegstry == null) { + logger.warning("GeneralKeyWindowImageRegistry is null"); + return; + } + List keyMapList = SkinUtil.getHWKeyMapList( skin.getEmulatorSkinState().getCurrentRotationId()); @@ -94,7 +105,7 @@ public class KeyWindowKeeper { return; } - keyWindow = new GeneralKeyWindow(skin, keyMapList); + keyWindow = new GeneralKeyWindow(skin, imageRegstry, keyMapList); } else { // TODO: String layoutName = @@ -171,7 +182,13 @@ public class KeyWindowKeeper { } } else { logger.info("key window has a general layout"); + indexLayout = -1; + + if (imageRegstry == null) { + imageRegstry = new GeneralKeyWindowImageRegistry( + skin.getShell().getDisplay()); + } } return indexLayout; @@ -230,4 +247,12 @@ public class KeyWindowKeeper { public void setRecentlyDocked(int dockValue) { recentlyDocked = dockValue; } + + public void dispose() { + closeKeyWindow(); + + if (imageRegstry != null) { + imageRegstry.dispose(); + } + } }