skin: apply nine-patch frame
authorgiwoong.kim <giwoong.kim@samsung.com>
Wed, 28 Nov 2012 08:47:04 +0000 (17:47 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Wed, 28 Nov 2012 08:47:04 +0000 (17:47 +0900)
apply nine-patch frame to key window

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java
tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java

index cd4357a65e5540a85200127520245fe1ed9ce6b3..a9b2564ea1912662c57d2fd796ec799f08d7da01 100644 (file)
@@ -1592,9 +1592,9 @@ public class EmulatorSkin {
 
                new MenuItem(menu, SWT.SEPARATOR);
 
-               /* HW Key Window menu */
+               /* Key Window menu */
                final MenuItem panelItem = new MenuItem(menu, SWT.CHECK);
-               panelItem.setText("&HW Key Window");
+               panelItem.setText("&Key Window");
                panelItem.setSelection(isControlPanel);
 
                panelItem.addSelectionListener(new SelectionAdapter() {
@@ -1602,7 +1602,7 @@ public class EmulatorSkin {
                        public void widgetSelected(SelectionEvent e) {
                                final boolean isControlPanel = panelItem.getSelection();
 
-                               logger.info("Select HW Key Window : " + isControlPanel);
+                               logger.info("Select Key Window : " + isControlPanel);
 
                                if (isControlPanel == true) {
                                        if (controlPanel != null) {
@@ -1610,7 +1610,7 @@ public class EmulatorSkin {
                                                return;
                                        }
 
-                                       /* create a HW key window */
+                                       /* create a key window */
                                        List<KeyMapType> keyMapList =
                                                        SkinUtil.getHWKeyMapList(currentState.getCurrentRotationId());
 
index ad3a618033aa60c3d707d4e6899118d1e23e2214..cce49805cdcb07bca43c9612a0e7de8e7f2fd289 100644 (file)
@@ -56,6 +56,8 @@ 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 Logger logger = SkinLogger.getSkinLogger(
                        GeneralPurposeSkinComposer.class).getLogger();
 
@@ -65,7 +67,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
        private EmulatorSkinState currentState;
 
        private ImageRegistry imageRegistry;
-       private SkinPatches frame;
+       private SkinPatches frameMaker;
        private SocketCommunicator communicator;
 
        private PaintListener shellPaintListener;
@@ -86,7 +88,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                this.isGrabbedShell= false;
                this.grabPosition = new Point(0, 0);
 
-               this.frame = new SkinPatches("images/emul-window/");
+               this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
        }
 
        @Override
@@ -165,7 +167,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                }
 
                currentState.setCurrentImage(
-                               frame.getPatchedImage(lcdBounds.width, lcdBounds.height));
+                               frameMaker.getPatchedImage(lcdBounds.width, lcdBounds.height));
 
                if (tempImage != null) {
                        tempImage.dispose();
@@ -191,7 +193,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                        int scale, short rotationId) {
 
                Rectangle lcdBounds = new Rectangle(
-                               frame.getPatchWidth(), frame.getPatchHeight(), 0, 0);
+                               frameMaker.getPatchWidth(), frameMaker.getPatchHeight(), 0, 0);
 
                float convertedScale = SkinUtil.convertScale(scale);
                RotationInfo rotation = RotationInfo.getValue(rotationId);
@@ -227,8 +229,7 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                shellMouseMoveListener = new MouseMoveListener() {
                        @Override
                        public void mouseMove(MouseEvent e) {
-                               if (isGrabbedShell == true && e.button == 0/* left button */ &&
-                                               currentState.getCurrentPressedHWKey() == null) {
+                               if (isGrabbedShell == true && e.button == 0/* left button */) {
                                        /* move a window */
                                        Point previousLocation = shell.getLocation();
                                        int x = previousLocation.x + (e.x - grabPosition.x);
@@ -337,6 +338,6 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                        shell.removeMouseListener(shellMouseListener);
                }
 
-               frame.freePatches();
+               frameMaker.freePatches();
        }
 }
index 26ab444101f9dd7e78872302a12919db542078be..8a9608a51e53e4fa05b3d259e708490d71a438d8 100644 (file)
@@ -39,6 +39,7 @@ public class SkinPatches {
        private Logger logger =
                        SkinLogger.getSkinLogger(SkinPatches.class).getLogger();
 
+       private Display display;
        private String pathImage;
        private int patchWidth;
        private int patchHeight;
@@ -68,6 +69,7 @@ public class SkinPatches {
        private static final String filenameRB = "RB.png";
 
        public SkinPatches(String path) {
+               this.display = Display.getCurrent();
                this.pathImage = path;
 
                loadPatches(pathImage);
@@ -87,7 +89,7 @@ public class SkinPatches {
        }
 
        public Image getPatchedImage(int centerPatchWidth, int centerPatchHeight) {
-               Image patchedImage = new Image(Display.getCurrent(),
+               Image patchedImage = new Image(display,
                                (patchWidth * 2) + centerPatchWidth,
                                (patchHeight * 2) + centerPatchHeight);
 
@@ -120,24 +122,24 @@ public class SkinPatches {
        private void loadPatches(String path) {
                ClassLoader loader = this.getClass().getClassLoader();
 
-               imageLT = new Image(Display.getCurrent(),
+               imageLT = new Image(display,
                                loader.getResourceAsStream(path + filenameLT));
                logger.info("left-top image is loaded from " + path + filenameLT);
-               imageT = new Image(Display.getCurrent(),
+               imageT = new Image(display,
                                loader.getResourceAsStream(path + filenameT));
-               imageRT = new Image(Display.getCurrent(),
+               imageRT = new Image(display,
                                loader.getResourceAsStream(path + filenameRT));
 
-               imageL = new Image(Display.getCurrent(),
+               imageL = new Image(display,
                                loader.getResourceAsStream(path + filenameL));
-               imageR = new Image(Display.getCurrent(),
+               imageR = new Image(display,
                                loader.getResourceAsStream(path + filenameR));
 
-               imageLB = new Image(Display.getCurrent(),
+               imageLB = new Image(display,
                                loader.getResourceAsStream(path + filenameLB));
-               imageB = new Image(Display.getCurrent(),
+               imageB = new Image(display,
                                loader.getResourceAsStream(path + filenameB));
-               imageRB = new Image(Display.getCurrent(),
+               imageRB = new Image(display,
                                loader.getResourceAsStream(path + filenameRB));
        }
 
index 8f62d9112018c983f2f8dfae34c0a686f5f2f4ce..d8d9b4a90a38f70b83d461e6951bd09bb8e6f339 100644 (file)
@@ -35,6 +35,9 @@ import org.eclipse.swt.custom.ScrolledComposite;
 import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -47,10 +50,20 @@ 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.layout.SkinPatches;
 
 public class ControlPanel extends SkinWindow {
+       private static final String PATCH_IMAGES_PATH = "images/key-window/";
+
+       private SkinPatches frameMaker;
+       private Image imageFrame;
        private SocketCommunicator communicator;
        private List<KeyMapType> keyMapList;
+
+       private PaintListener shellPaintListener;
+       private MouseMoveListener shellMouseMoveListener;
+       private MouseListener shellMouseListener;
+
        private boolean isGrabbedShell;
        private Point grabPosition;
 
@@ -59,21 +72,25 @@ public class ControlPanel extends SkinWindow {
                super(parent);
 
                this.shell = new Shell(Display.getDefault(), SWT.NO_TRIM);
+               this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH); //TODO: freePatches
+               this.imageFrame = frameMaker.getPatchedImage(136, 140);
 
                this.keyMapList = keyMapList;
                this.communicator = communicator;
                this.grabPosition = new Point(0, 0);
 
                createContents();
-               addControlPanelListener();
+               addControlPanelListener(); //TODO: remove
 
-               shell.setSize(160, 100);
+               shell.setSize((frameMaker.getPatchWidth() * 2) + 136,
+                               (frameMaker.getPatchHeight() * 2) + 140);
        }
 
        protected void createContents() {
                GridLayout gridLayout = new GridLayout(1, true);
-               gridLayout.marginLeft = gridLayout.marginRight = 0;
-               gridLayout.marginTop = gridLayout.marginBottom = 0;
+               gridLayout.marginLeft = gridLayout.marginRight = frameMaker.getPatchWidth() + 6;
+               gridLayout.marginTop = frameMaker.getPatchHeight() + 20;
+               gridLayout.marginBottom = frameMaker.getPatchHeight() + 6;
                gridLayout.marginWidth = gridLayout.marginHeight = 0;
                gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
 
@@ -123,10 +140,21 @@ public class ControlPanel extends SkinWindow {
        }
 
        private void addControlPanelListener() {
-               MouseMoveListener shellMouseMoveListener = new MouseMoveListener() {
+               shellPaintListener = new PaintListener() {
+                       @Override
+                       public void paintControl(final PaintEvent e) {
+                               if (imageFrame != null) {
+                                       e.gc.drawImage(imageFrame, 0, 0);
+                               }
+                       }
+               };
+
+               shell.addPaintListener(shellPaintListener);
+
+               shellMouseMoveListener = new MouseMoveListener() {
                        @Override
                        public void mouseMove(MouseEvent e) {
-                               if (isGrabbedShell == true && e.button == 0) {
+                               if (isGrabbedShell == true && e.button == 0/* left button */) {
                                        /* move a window */
                                        Point previousLocation = shell.getLocation();
                                        int x = previousLocation.x + (e.x - grabPosition.x);
@@ -137,9 +165,18 @@ public class ControlPanel extends SkinWindow {
                                }
                        }
                };
+
                shell.addMouseMoveListener(shellMouseMoveListener);
 
-               MouseListener shellMouseListener = new MouseListener() {
+               shellMouseListener = new MouseListener() {
+                       @Override
+                       public void mouseUp(MouseEvent e) {
+                               if (e.button == 1) { /* left button */
+                                       isGrabbedShell = false;
+                                       grabPosition.x = grabPosition.y = 0;
+                               }
+                       }
+
                        @Override
                        public void mouseDown(MouseEvent e) {
                                if (1 == e.button) { /* left button */
@@ -149,19 +186,12 @@ public class ControlPanel extends SkinWindow {
                                }
                        }
 
-                       @Override
-                       public void mouseUp(MouseEvent e) {
-                               if (e.button == 1) { /* left button */
-                                       isGrabbedShell = false;
-                                       grabPosition.x = grabPosition.y = 0;
-                               }
-                       }
-
                        @Override
                        public void mouseDoubleClick(MouseEvent e) {
                                /* do nothing */
                        }
                };
+
                shell.addMouseListener(shellMouseListener);
        }
 }