From e6b335dea86f82de4be54a2bcbfce421f3e9108a Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Mon, 7 Oct 2013 17:47:39 +0900 Subject: [PATCH] skin: apply XML bindings for SpecailKeyWindow KeyWindowUI Change-Id: Ibebedfe3b50656b04b2673b3f04f46260e389613 Signed-off-by: GiWoong Kim --- .../skin/custom/SpecialKeyWindow.java | 195 +++++++++++------- .../image/GeneralKeyWindowImageRegistry.java | 1 - .../skin/image/GeneralSkinImageRegistry.java | 1 - .../image/SpecialKeyWindowImageRegistry.java | 76 ++----- .../layout/ProfileSpecificSkinComposer.java | 13 +- .../tizen/emulator/skin/menu/PopupMenu.java | 5 +- .../tizen/emulator/skin/util/SkinUtil.java | 3 +- .../skin/util/SpecialKeyWindowUtil.java | 161 --------------- 8 files changed, 151 insertions(+), 304 deletions(-) delete mode 100644 tizen/src/skin/client/src/org/tizen/emulator/skin/util/SpecialKeyWindowUtil.java diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java index 2325fb001b..adbe9bb8be 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java @@ -32,6 +32,7 @@ package org.tizen.emulator.skin.custom; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.util.List; import java.util.logging.Level; import org.eclipse.swt.SWT; @@ -42,11 +43,9 @@ import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.events.ShellListener; -import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Shell; import org.tizen.emulator.skin.EmulatorSkin; import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType; @@ -57,98 +56,96 @@ import org.tizen.emulator.skin.comm.sock.SocketCommunicator; import org.tizen.emulator.skin.comm.sock.data.KeyEventData; import org.tizen.emulator.skin.comm.sock.data.MouseEventData; import org.tizen.emulator.skin.config.EmulatorConfig; -import org.tizen.emulator.skin.dbi.EmulatorUI; import org.tizen.emulator.skin.exception.JaxbException; import org.tizen.emulator.skin.image.SpecialKeyWindowImageRegistry; import org.tizen.emulator.skin.image.SpecialKeyWindowImageRegistry.SpecailKeyWindowImageType; +import org.tizen.emulator.skin.keywindow.dbi.EventInfoType; +import org.tizen.emulator.skin.keywindow.dbi.KeyMapType; +import org.tizen.emulator.skin.keywindow.dbi.KeyWindowUI; +import org.tizen.emulator.skin.keywindow.dbi.RegionType; import org.tizen.emulator.skin.layout.HWKey; import org.tizen.emulator.skin.util.IOUtil; import org.tizen.emulator.skin.util.JaxbUtil; -import org.tizen.emulator.skin.util.SpecialKeyWindowUtil; +import org.tizen.emulator.skin.util.SkinRegion; +import org.tizen.emulator.skin.util.SkinUtil; import org.tizen.emulator.skin.util.SwtUtil; public class SpecialKeyWindow extends SkinWindow { - private static final String KEYWINDOW_LAYOUT = "keywindow-layout"; - private static final String DBI_FILE_NAME = "default.dbi"; + public static final String KEYWINDOW_LAYOUT_ROOT = "keywindow-layout"; + public static final String DBI_FILE_NAME = "default.dbi"; private EmulatorSkin skin; - - private HWKey currentPressedHWKey; - - private int widthBase; - private int heightBase; + private SpecialKeyWindowImageRegistry imageRegistry; + private SocketCommunicator communicator; + private KeyWindowUI dbiContents; private Image keyWindowImage; private Image keyWindowPressedImage; - private Color colorFrame; - private SpecialKeyWindowImageRegistry imageRegistry; - private SocketCommunicator communicator; - private ShellListener shellListener; private PaintListener shellPaintListener; private MouseMoveListener shellMouseMoveListener; private MouseListener shellMouseListener; - - private boolean isTouch; + private boolean isGrabbedShell; private Point grabPosition; + private HWKey currentPressedHWKey; + private boolean isTouch; public SpecialKeyWindow(EmulatorSkin skin, String layoutName) { 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); - } else { - this.shell = new Shell(parent.getDisplay(), - SWT.NO_TRIM | SWT.RESIZE | SWT.TOOL); - } - + this.shell = new Shell(parent.getDisplay() /* for Mac & Always on Top */, + SWT.NO_TRIM | SWT.RESIZE | SWT.TOOL | SWT.NO_FOCUS); this.communicator = skin.communicator; + + this.isGrabbedShell= false; this.grabPosition = new Point(0, 0); shell.setText(parent.getText()); + shell.setBackground(parent.getBackground()); shell.setImage(parent.getImage()); /* load dbi file */ String skinPath = skin.skinInfo.getSkinPath(); - String specialKeyWindowPath = skinPath + File.separator + KEYWINDOW_LAYOUT + File.separator + layoutName; + String specialKeyWindowPath = skinPath + File.separator + + KEYWINDOW_LAYOUT_ROOT + File.separator + layoutName; logger.info("special key window path : " + specialKeyWindowPath); - EmulatorUI dbiContents = loadXMLForKeyWindow(specialKeyWindowPath); - /* image init */ - this.imageRegistry = new SpecialKeyWindowImageRegistry(shell.getDisplay(), dbiContents, specialKeyWindowPath); - - /* get keywindow image */ - keyWindowImage = imageRegistry.getKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL); - keyWindowPressedImage = imageRegistry.getKeyWindowImage(EmulatorConfig.DEFAULT_WINDOW_ROTATION, SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED); - - SpecialKeyWindowUtil.trimShell(shell, keyWindowImage); - SpecialKeyWindowUtil.trimShell(shell, keyWindowPressedImage); - - /* calculate the key window size */ - widthBase = keyWindowImage.getImageData().width; - heightBase = keyWindowImage.getImageData().height; + this.dbiContents = loadXMLForKeyWindow(specialKeyWindowPath); - /* make a frame image */ - this.colorFrame = new Color(shell.getDisplay(), new RGB(38, 38, 38)); + /* image init */ + this.imageRegistry = new SpecialKeyWindowImageRegistry( + shell.getDisplay(), dbiContents, specialKeyWindowPath); - shell.setBackground(colorFrame); + /* get keywindow image */ + //TODO: null + keyWindowImage = imageRegistry.getKeyWindowImage( + EmulatorConfig.DEFAULT_WINDOW_ROTATION, + SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL); + keyWindowPressedImage = imageRegistry.getKeyWindowImage( + EmulatorConfig.DEFAULT_WINDOW_ROTATION, + SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED); + + /* set window size */ + shell.setSize( + keyWindowImage.getImageData().width, + keyWindowImage.getImageData().height); + + /* custom window shape */ + SkinUtil.trimShell(shell, keyWindowImage); addKeyWindowListener(); - - shell.setSize(widthBase, heightBase); } - private EmulatorUI loadXMLForKeyWindow(String skinPath) { + private KeyWindowUI loadXMLForKeyWindow(String skinPath) { String dbiPath = skinPath + File.separator + DBI_FILE_NAME; logger.info("load dbi file from " + dbiPath); FileInputStream fis = null; - EmulatorUI emulatorUI = null; + KeyWindowUI keyWindowUI = null; try { fis = new FileInputStream(dbiPath); @@ -157,7 +154,7 @@ public class SpecialKeyWindow extends SkinWindow { logger.info(new String(bytes, "UTF-8")); logger.info("======================================="); - emulatorUI = JaxbUtil.unmarshal(bytes, EmulatorUI.class); + keyWindowUI = JaxbUtil.unmarshal(bytes, KeyWindowUI.class); } catch (IOException e) { logger.log(Level.SEVERE, e.getMessage(), e); } catch (JaxbException e) { @@ -166,7 +163,38 @@ public class SpecialKeyWindow extends SkinWindow { IOUtil.close(fis); } - return emulatorUI; + return keyWindowUI; + } + + private HWKey getHWKey(int currentX, int currentY) { + List keyMapList = dbiContents.getKeyMapList().getKeyMap(); + if (keyMapList == null) { + return null; + } + + for (KeyMapType keyEntry : keyMapList) { + RegionType region = keyEntry.getRegion(); + + int scaledX = (int) region.getLeft(); + int scaledY = (int) region.getTop(); + int scaledWidth = (int) region.getWidth(); + int scaledHeight = (int) region.getHeight(); + + if (SkinUtil.isInGeometry(currentX, currentY, + scaledX, scaledY, scaledWidth, scaledHeight)) { + EventInfoType eventInfo = keyEntry.getEventInfo(); + + HWKey hwKey = new HWKey( + eventInfo.getKeyName(), + eventInfo.getKeyCode(), + new SkinRegion(scaledX, scaledY, scaledWidth, scaledHeight), + keyEntry.getTooltip()); + + return hwKey; + } + } + + return null; } private void addKeyWindowListener() { @@ -238,7 +266,8 @@ public class SpecialKeyWindow extends SkinWindow { @Override public void mouseMove(MouseEvent e) { if (isTouch == true) { - logger.info("MouseMove in SpecialKeyWindow : " + e.x + ", " + e.y); + logger.info("mouseMove in KeyWindow : " + e.x + ", " + e.y); + HWKey pressedHWKey = currentPressedHWKey; int x = pressedHWKey.getRegion().x; int y = pressedHWKey.getRegion().y; @@ -246,7 +275,7 @@ public class SpecialKeyWindow extends SkinWindow { int height = pressedHWKey.getRegion().height; int eventType; - if (SpecialKeyWindowUtil.isInGeometry(e.x, e.y, x, y, width, height)) { + if (SkinUtil.isInGeometry(e.x, e.y, x, y, width, height)) { eventType = MouseEventType.DRAG.value(); } else { isTouch = false; @@ -256,8 +285,10 @@ public class SpecialKeyWindow extends SkinWindow { } MouseEventData mouseEventData = new MouseEventData( - MouseButtonType.LEFT.value(), MouseEventType.DRAG.value(), e.x, e.y, e.x, e.y, 0); - communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT, mouseEventData, false); + MouseButtonType.LEFT.value(), MouseEventType.DRAG.value(), + e.x, e.y, e.x, e.y, 0); + communicator.sendToQEMU( + SendCommand.SEND_MOUSE_EVENT, mouseEventData, false); } else if (isGrabbedShell == true && e.button == 0/* left button */) { if (getDockPosition() != SWT.NONE) { dock(SWT.NONE, false, false); @@ -281,21 +312,32 @@ public class SpecialKeyWindow extends SkinWindow { @Override public void mouseUp(MouseEvent e) { if (e.button == 1) { /* left button */ - logger.info("MouseUp in SpecialKeyWindow : " + e.x + ", " + e.y); isGrabbedShell = false; grabPosition.x = grabPosition.y = 0; + + /* HW key handling */ HWKey pressedHWKey = currentPressedHWKey; + if (pressedHWKey == null) { + logger.info("mouseUp in KeyWindow : " + e.x + ", " + e.y); + return; + } + + if (pressedHWKey.getKeyCode() != SkinUtil.UNKNOWN_KEYCODE) { + logger.info(pressedHWKey.getName() + " key is released"); - if (pressedHWKey != null && pressedHWKey.getKeyCode() != SpecialKeyWindowUtil.UNKNOWN_KEYCODE) { /* send event */ if (isTouch) { isTouch = false; MouseEventData mouseEventData = new MouseEventData( - MouseButtonType.LEFT.value(), MouseEventType.RELEASE.value(), e.x, e.y, e.x, e.y, 0); - communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT, mouseEventData, false); + MouseButtonType.LEFT.value(), MouseEventType.RELEASE.value(), + e.x, e.y, e.x, e.y, 0); + communicator.sendToQEMU( + SendCommand.SEND_MOUSE_EVENT, mouseEventData, false); } else { - KeyEventData keyEventData = new KeyEventData(KeyEventType.RELEASED.value(), pressedHWKey.getKeyCode(), 0, 0); - communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false); + KeyEventData keyEventData = new KeyEventData( + KeyEventType.RELEASED.value(), pressedHWKey.getKeyCode(), 0, 0); + communicator.sendToQEMU( + SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false); } currentPressedHWKey = null; @@ -310,40 +352,48 @@ public class SpecialKeyWindow extends SkinWindow { @Override public void mouseDown(MouseEvent e) { if (1 == e.button) { /* left button */ - logger.info("MouseDown in SpecialKeyWindow : " + e.x + ", " + e.y); - /* HW key handling */ - final HWKey hwKey = SpecialKeyWindowUtil.getHWKey(e.x, e.y, EmulatorConfig.DEFAULT_WINDOW_ROTATION); - if (hwKey == null) { + final HWKey hwKey = getHWKey(e.x, e.y); + if (hwKey == null) { + logger.info("mouseDown in KeyWindow : " + e.x + ", " + e.y); + isGrabbedShell = true; grabPosition.x = e.x; grabPosition.y = e.y; + return; } - if (hwKey.getKeyCode() != SpecialKeyWindowUtil.UNKNOWN_KEYCODE) { + if (hwKey.getKeyCode() != SkinUtil.UNKNOWN_KEYCODE) { + logger.info(hwKey.getName() + " key is pressed"); + + /* send event */ if (hwKey.getTooltip().equalsIgnoreCase("touch")) { isTouch = true; MouseEventData mouseEventData = new MouseEventData( - MouseButtonType.LEFT.value(), MouseEventType.PRESS.value(), e.x, e.y, e.x, e.y, 0); - communicator.sendToQEMU(SendCommand.SEND_MOUSE_EVENT, mouseEventData, false); + MouseButtonType.LEFT.value(), MouseEventType.PRESS.value(), + e.x, e.y, e.x, e.y, 0); + communicator.sendToQEMU( + SendCommand.SEND_MOUSE_EVENT, mouseEventData, false); } else { - /* send event */ - KeyEventData keyEventData = new KeyEventData(KeyEventType.PRESSED.value(), hwKey.getKeyCode(), 0, 0); - communicator.sendToQEMU(SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false); + KeyEventData keyEventData = new KeyEventData( + KeyEventType.PRESSED.value(), hwKey.getKeyCode(), 0, 0); + communicator.sendToQEMU( + SendCommand.SEND_HARD_KEY_EVENT, keyEventData, false); } currentPressedHWKey = hwKey; + shell.setToolTipText(null); /* draw the HW key region as the cropped keyPressed image area */ - if(hwKey.getRegion() != null && + if (hwKey.getRegion() != null && hwKey.getRegion().width != 0 && hwKey.getRegion().height != 0) { shell.getDisplay().syncExec(new Runnable() { public void run() { - if(keyWindowPressedImage != null) { + if (keyWindowPressedImage != null) { GC gc = new GC(shell); - if(gc != null) { + if (gc != null) { gc.drawImage(keyWindowPressedImage, hwKey.getRegion().x, hwKey.getRegion().y, hwKey.getRegion().width, hwKey.getRegion().height, @@ -389,7 +439,6 @@ public class SpecialKeyWindow extends SkinWindow { shell.removeMouseListener(shellMouseListener); } - colorFrame.dispose(); 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 96c34afea4..d9fdf91e13 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 @@ -28,7 +28,6 @@ package org.tizen.emulator.skin.image; -import java.io.File; import java.io.InputStream; import java.util.Collection; import java.util.HashMap; 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 f4292ddd9b..df77af4888 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 @@ -28,7 +28,6 @@ package org.tizen.emulator.skin.image; -import java.io.File; import java.io.InputStream; import java.util.Collection; import java.util.HashMap; 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 f55c792043..fa68254f78 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 @@ -32,19 +32,14 @@ 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.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.keywindow.dbi.ImageListType; +import org.tizen.emulator.skin.keywindow.dbi.KeyWindowUI; import org.tizen.emulator.skin.log.SkinLogger; -import org.tizen.emulator.skin.util.KeyWindowRotation; -import org.tizen.emulator.skin.util.SkinRotation; /** @@ -61,36 +56,19 @@ public class SpecialKeyWindowImageRegistry { } private Display display; - private String skinPath; - private EmulatorUI dbiContents; + private String imagePath; + private KeyWindowUI dbiContents; private Map keyWindowImageMap; /** * Constructor */ public SpecialKeyWindowImageRegistry( - Display display, EmulatorUI dbiContents, String skinPath) { + Display display, KeyWindowUI dbiContents, String imagePath) { this.display = display; - this.skinPath = skinPath; + this.imagePath = imagePath; this.dbiContents = dbiContents; this.keyWindowImageMap = new HashMap(); - - 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 rotationList = rotations.getRotation(); - - for (RotationType rotation : rotationList) { - KeyWindowRotation.put(rotation); - } } private String makeKey(Short id, SpecailKeyWindowImageType imageType) { @@ -101,41 +79,25 @@ public class SpecialKeyWindowImageRegistry { Image image = keyWindowImageMap.get(makeKey(id, imageType)); if (image == null) { - RotationsType rotations = dbiContents.getRotations(); - - if (null == rotations) { - logger.severe("Fail to loading rotations element from XML"); + ImageListType imageList = dbiContents.getImageList(); + if (imageList == null) { return null; } - logger.info("get skin image from " + skinPath); - - RotationType targetRotation = SkinRotation.getRotation(id); - List rotationList = rotations.getRotation(); + logger.info("get Key Window image from " + imagePath); - for (RotationType rotation : rotationList) { - ImageListType imageList = rotation.getImageList(); - if (imageList == null) { - continue; - } + String mainImage = imageList.getMainImage(); + String keyPressedImage = imageList.getKeyPressedImage(); - String mainImage = imageList.getMainImage(); - String keyPressedImage = imageList.getKeyPressedImage(); + String mainKey = makeKey(id, + SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL); + keyWindowImageMap.put(mainKey, + new Image(display, imagePath + File.separator + mainImage)); - if (targetRotation.getName().value().equals(rotation.getName().value())) { - String mainKey = makeKey(id, - SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_NORMAL); - keyWindowImageMap.put(mainKey, - new Image(display, skinPath + File.separator + mainImage)); - - String pressedKey = makeKey(id, - SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED); - keyWindowImageMap.put(pressedKey, - new Image(display, skinPath + File.separator + keyPressedImage)); - - break; - } - } + String pressedKey = makeKey(id, + SpecailKeyWindowImageType.SPECIAL_IMAGE_TYPE_PRESSED); + keyWindowImageMap.put(pressedKey, + new Image(display, imagePath + File.separator + keyPressedImage)); image = keyWindowImageMap.get(makeKey(id, imageType)); } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java index 95c6caf6fb..94f1025fe4 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java @@ -426,7 +426,7 @@ public class ProfileSpecificSkinComposer implements ISkinComposer { /* HW key handling */ HWKey pressedHWKey = currentState.getCurrentPressedHWKey(); if (pressedHWKey == null) { - logger.info("mouseUp in Skin"); + logger.info("mouseUp in Skin : " + e.x + ", " + e.y); return; } @@ -457,15 +457,16 @@ public class ProfileSpecificSkinComposer implements ISkinComposer { @Override public void mouseDown(MouseEvent e) { if (1 == e.button) { /* left button */ - isGrabbedShell = true; - grabPosition.x = e.x; - grabPosition.y = e.y; - /* HW key handling */ final HWKey hwKey = SkinUtil.getHWKey(e.x, e.y, currentState.getCurrentRotationId(), currentState.getCurrentScale()); if (hwKey == null) { - logger.info("mouseDown in Skin"); + logger.info("mouseDown in Skin : " + e.x + ", " + e.y); + + isGrabbedShell = true; + grabPosition.x = e.x; + grabPosition.y = e.y; + return; } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java index cce151eee4..9d24b218bc 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java @@ -40,6 +40,7 @@ import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.tizen.emulator.skin.EmulatorSkin; import org.tizen.emulator.skin.config.EmulatorConfig; +import org.tizen.emulator.skin.custom.SpecialKeyWindow; import org.tizen.emulator.skin.dbi.MenuItemType; import org.tizen.emulator.skin.dbi.PopupMenuType; import org.tizen.emulator.skin.image.ImageRegistry; @@ -64,8 +65,6 @@ public class PopupMenu { public static final String SDBSHELL_MENUITEM_NAME = "S&hell"; public static final String CLOSE_MENUITEM_NAME = "&Close"; - public static final String KEYWINDOW_LAYOUT_ROOT = "keywindow-layout"; - private static Logger logger = SkinLogger.getSkinLogger(PopupMenu.class).getLogger(); @@ -200,7 +199,7 @@ public class PopupMenu { (keywindowMenuType != null && keywindowMenuType.isVisible() == true)) { /* load Key Window layout */ String pathLayoutRoot = skin.skinInfo.getSkinPath() + - File.separator + KEYWINDOW_LAYOUT_ROOT; + File.separator + SpecialKeyWindow.KEYWINDOW_LAYOUT_ROOT; ArrayList layouts = getKeyWindowLayoutList(pathLayoutRoot); if (layouts != null) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java index 924d979883..d00ab03430 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java @@ -176,7 +176,7 @@ public class SkinUtil { EventInfoType eventInfo = keyEntry.getEventInfo(); HWKey hwKey = new HWKey( - keyEntry.getEventInfo().getKeyName(), + eventInfo.getKeyName(), eventInfo.getKeyCode(), new SkinRegion(scaledX, scaledY, scaledWidth, scaledHeight), keyEntry.getTooltip()); @@ -190,7 +190,6 @@ public class SkinUtil { public static boolean isInGeometry(int currentX, int currentY, int targetX, int targetY, int targetWidth, int targetHeight) { - if ((currentX >= targetX) && (currentY >= targetY)) { if ((currentX <= (targetX + targetWidth)) && (currentY <= (targetY + targetHeight))) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SpecialKeyWindowUtil.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SpecialKeyWindowUtil.java deleted file mode 100644 index 9c5bfa9d13..0000000000 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SpecialKeyWindowUtil.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * - * - * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * GiWoong Kim - * YeongKyoon Lee - * HyunJun Son - * Hyunjin Lee - * - * 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.List; -import java.util.logging.Logger; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.graphics.Region; -import org.eclipse.swt.widgets.Shell; -import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo; -import org.tizen.emulator.skin.dbi.EventInfoType; -import org.tizen.emulator.skin.dbi.KeyMapListType; -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.layout.HWKey; -import org.tizen.emulator.skin.log.SkinLogger; - - -/** - * - * - */ -public class SpecialKeyWindowUtil { - public static final int UNKNOWN_KEYCODE = -1; - public static final int TOUCH_KEYCODE = -2; - - private static Logger logger = - SkinLogger.getSkinLogger(SkinUtil.class).getLogger(); - - private SpecialKeyWindowUtil() { - /* do nothing */ - } - - public static List getHWKeyMapList(short rotationId) { - RotationType rotation = KeyWindowRotation.getRotation(rotationId); - if (rotation == null) { - return null; - } - - KeyMapListType list = rotation.getKeyMapList(); - if (list == null) { - /* try to using a KeyMapList of portrait */ - rotation = KeyWindowRotation.getRotation(RotationInfo.PORTRAIT.id()); - if (rotation == null) { - return null; - } - - list = rotation.getKeyMapList(); - if (list == null) { - return null; - } - } - - return list.getKeyMap(); - } - - public static HWKey getHWKey( - int currentX, int currentY, short rotationId) { - - List keyMapList = getHWKeyMapList(rotationId); - if (keyMapList == null) { - return null; - } - - for (KeyMapType keyMap : keyMapList) { - RegionType region = keyMap.getRegion(); - - int scaledX = (int) region.getLeft(); - int scaledY = (int) region.getTop(); - int scaledWidth = (int) region.getWidth(); - int scaledHeight = (int) region.getHeight(); - - if (isInGeometry(currentX, currentY, scaledX, scaledY, scaledWidth, scaledHeight)) { - EventInfoType eventInfo = keyMap.getEventInfo(); - - HWKey hwKey = new HWKey(); - hwKey.setKeyCode(eventInfo.getKeyCode()); - hwKey.setRegion(new SkinRegion(scaledX, scaledY, scaledWidth, scaledHeight)); - hwKey.setTooltip(keyMap.getTooltip()); - - return hwKey; - } - } - - return null; - } - - public static boolean isInGeometry(int currentX, int currentY, - int targetX, int targetY, int targetWidth, int targetHeight) { - - if ((currentX >= targetX) && (currentY >= targetY)) { - if ((currentX <= (targetX + targetWidth)) && - (currentY <= (targetY + targetHeight))) { - return true; - } - } - - return false; - } - - public static void trimShell( Shell shell, Image image ) { - - // trim transparent pixels in image. especially, corner round areas. - - if ( null == image ) { - return; - } - - ImageData imageData = image.getImageData(); - - int width = imageData.width; - int height = imageData.height; - - Region region = new Region(); - region.add( new Rectangle( 0, 0, width, height ) ); - - for ( int i = 0; i < width; i++ ) { - for ( int j = 0; j < height; j++ ) { - int alpha = imageData.getAlpha( i, j ); - if ( 0 == alpha ) { - region.subtract( i, j, 1, 1 ); - } - } - } - - shell.setRegion( region ); - - } -} -- 2.34.1