skin: apply XML bindings for SpecailKeyWindow 47/10647/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Mon, 7 Oct 2013 08:47:39 +0000 (17:47 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 8 Oct 2013 06:19:45 +0000 (15:19 +0900)
KeyWindowUI

Change-Id: Ibebedfe3b50656b04b2673b3f04f46260e389613
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java
tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java
tizen/src/skin/client/src/org/tizen/emulator/skin/util/SpecialKeyWindowUtil.java [deleted file]

index 2325fb001b9012ed88f940ddbc0c8a33100276dd..adbe9bb8be5c06ca5b5f07878d80462f71b10e3b 100644 (file)
@@ -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<KeyMapType> 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();
        }
 }
index 96c34afea4ff8b7a728d36614ef505f38aa200cb..d9fdf91e139f6dafee47a23e8c2a5427936e3e59 100644 (file)
@@ -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;
index f4292ddd9b215fa5bdada4f2ca0b168b6e9b1bf4..df77af4888dd7eb36a4053203222d829855fafc7 100644 (file)
@@ -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;
index f55c7920434733b49a64021257e723deb31a8173..fa68254f785a8ee7c0c32fe096e5bf14c8af258c 100644 (file)
@@ -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<String, Image> 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<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) {
-                       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<RotationType> 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));
                }
index 95c6caf6fbac917334a10dab702868b6b9c04960..94f1025fe4681e672420aeb1aec050a1f8dd5a42 100644 (file)
@@ -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;
                                        }
 
index cce151eee462374cae9e51660e2abcc5de9e6edf..9d24b218bc018d9da347c266554d18fa0aa0f6c4 100644 (file)
@@ -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<File> layouts = getKeyWindowLayoutList(pathLayoutRoot);
 
                        if (layouts != null) {
index 924d97988368073a3a7a616d9ed7ba6a8d420dde..d00ab0343083284ca35ea8d05d6385d87ad7bf41 100644 (file)
@@ -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 (file)
index 9c5bfa9..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * 
- *
- * 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.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<KeyMapType> 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<KeyMapType> 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 );
-
-       }
-}