skin: added Pair Tag to key window & emul window
authorgiwoong.kim <giwoong.kim@samsung.com>
Mon, 3 Dec 2012 07:00:48 +0000 (16:00 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Mon, 3 Dec 2012 07:11:44 +0000 (16:11 +0900)
This tag represents a pair of windows.
The color of tag is random for each VM.

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/comm/sock/SocketCommunicator.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 61610fc927f3e63c82467e53367c755ccf78a726..5f03ed6d7c36392376315ffc9a8fac45684f8d2f 100644 (file)
@@ -149,6 +149,8 @@ public class EmulatorSkin {
        private boolean isOnKbd;
 
        public ControlPanel controlPanel;
+       public Color colorPairTag;
+       public Canvas pairTagCanvas;
        protected ScreenShotDialog screenShotDialog;
        private Menu contextMenu;
        private MenuItem panelItem; /* key window */
@@ -319,7 +321,7 @@ public class EmulatorSkin {
                        }
                }
 
-               return new SkinReopenPolicy( reopenSkin, isAboutToReopen );
+               return new SkinReopenPolicy(reopenSkin, isAboutToReopen);
 
        }
 
@@ -331,14 +333,14 @@ public class EmulatorSkin {
 
                shellCloseListener = new Listener() {
                        @Override
-                       public void handleEvent( Event event ) {
+                       public void handleEvent(Event event) {
 
-                               if ( isShutdownRequested ) {
+                               if (isShutdownRequested) {
 
                                        removeShellListeners();
                                        removeCanvasListeners();
 
-                                       if ( !isAboutToReopen ) {
+                                       if (!isAboutToReopen) {
                                                /* close the screen shot window */
                                                if (null != screenShotDialog) {
                                                        Shell scShell = screenShotDialog.getShell();
@@ -355,6 +357,7 @@ public class EmulatorSkin {
                                                                cpShell.close();
                                                        }
                                                        controlPanel = null;
+                                                       colorPairTag.dispose();
                                                }
 
                                                /* save config only for emulator close */
@@ -1535,6 +1538,7 @@ public class EmulatorSkin {
        public void openKeyWindow() {
                if (controlPanel != null) {
                        controlPanel.getShell().setVisible(true);
+                       pairTagCanvas.setVisible(true);
                        return;
                }
 
@@ -1552,6 +1556,9 @@ public class EmulatorSkin {
 
                try {
                        controlPanel = new ControlPanel(shell, communicator, keyMapList);
+                       colorPairTag = controlPanel.getPairTagColor();
+                       pairTagCanvas.setVisible(true);
+
                        controlPanel.open();
                } finally {
                        controlPanel = null;
@@ -1560,6 +1567,7 @@ public class EmulatorSkin {
 
        public void hideKeyWindow() {
                controlPanel.getShell().setVisible(false);
+               pairTagCanvas.setVisible(false);
        }
 
        private void addMenuItems(final Shell shell, final Menu menu) {
index 6a63f8a03e7f9ec9c3575cd36a6634a389a17305..24d3d40a35b172682d1eae9cdcf4475a8120111a 100644 (file)
@@ -48,7 +48,6 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.eclipse.swt.SWT;
 import org.tizen.emulator.skin.EmulatorSkin;
 import org.tizen.emulator.skin.comm.ICommunicator;
 import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
index 70867d177c7f8c542fa8cb69816f9a3f9d06cb7d..7eb35307a9068a5c1b33a57b82e2ed2f8ae9646c 100644 (file)
@@ -48,7 +48,6 @@ import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.EmulatorSkin;
 import org.tizen.emulator.skin.EmulatorSkinState;
 import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
-import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
@@ -183,6 +182,23 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                        }
                });
 
+               /* make a pair tag circle */
+               skin.pairTagCanvas = new Canvas(shell, SWT.NONE);
+               skin.pairTagCanvas.setBackground(
+                               new Color(shell.getDisplay(), new RGB(38, 38, 38)));
+
+               skin.pairTagCanvas.addPaintListener(new PaintListener() {
+                       @Override
+                       public void paintControl(PaintEvent e) {
+                               if (skin.colorPairTag != null) {
+                                       e.gc.setBackground(skin.colorPairTag);
+                                       e.gc.setAntialias(SWT.ON);
+                                       e.gc.fillOval(0, 0, 8, 8);
+                               }
+                       }
+               });
+               skin.pairTagCanvas.setVisible(false);
+
                arrangeSkin(scale, rotationId);
        }
 
@@ -228,6 +244,9 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                lcdBounds.y + (lcdBounds.height / 2) - (toggleButton.getImageSize().y / 2),
                                toggleButton.getImageSize().x, toggleButton.getImageSize().y);
 
+               /* arrange the pair tag */
+               skin.pairTagCanvas.setBounds(26, 13, 8, 8);
+
                /* custom window shape */
                trimPatchedShell(shell, currentState.getCurrentImage());
 
@@ -417,6 +436,14 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                        shell.removeMouseListener(shellMouseListener);
                }
 
+               if (toggleButton != null) {
+                       toggleButton.dispose();
+               }
+
+               if (skin.pairTagCanvas != null) {
+                       skin.pairTagCanvas.dispose();
+               }
+
                frameMaker.freePatches();
        }
 }
index 9916e2aef05f537d1a7794c6a7334cf35e6cf96b..e13f3874a4637b0538098e042e2716da0138c96a 100644 (file)
@@ -31,8 +31,10 @@ package org.tizen.emulator.skin.layout;
 import java.util.logging.Logger;
 
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.widgets.Display;
 import org.tizen.emulator.skin.log.SkinLogger;
 
@@ -110,7 +112,7 @@ public class SkinPatches {
                /* middle side */
                gc.drawImage(imageL, 0, 0, imageL.getImageData().width, imageL.getImageData().height,
                                0, patchHeight, patchWidth, centerPatchHeight);
-               gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+               gc.setBackground(new Color(display, new RGB(38, 38, 38)));
                gc.fillRectangle(patchWidth, patchHeight, centerPatchWidth, centerPatchHeight); /* center */
                gc.drawImage(imageR, 0, 0, imageR.getImageData().width, imageR.getImageData().height,
                                patchWidth + centerPatchWidth, patchHeight, patchWidth, centerPatchHeight);
index 6251e77338aec3d6e4578abef7f83d528b511f9d..7aa082542cb5a6e730a9570055fcc5c2bf1ddbcd 100644 (file)
@@ -46,6 +46,7 @@ import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.graphics.Region;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Event;
@@ -60,6 +61,11 @@ import org.tizen.emulator.skin.layout.SkinPatches;
 
 public class ControlPanel 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;
+       private static final int BUTTON_DEFAULT_CNT = 4;
+       private static final int BUTTON_VERTICAL_SPACING = 7;
 
        private SkinPatches frameMaker;
        private Image imageNormal; /* ImageButton image */
@@ -67,6 +73,7 @@ public class ControlPanel extends SkinWindow {
        private Image imagePushed; /* pushed ImageButton image */
        private Image imageFrame; /* nine-patch image */
        private Color colorFrame;
+       private Color colorPairTag;
        private SocketCommunicator communicator;
        private List<KeyMapType> keyMapList;
 
@@ -85,6 +92,10 @@ public class ControlPanel extends SkinWindow {
                this.shell = new Shell(Display.getDefault(), SWT.NO_TRIM | SWT.RESIZE);
                this.frameMaker = new SkinPatches(PATCH_IMAGES_PATH);
 
+               this.keyMapList = keyMapList;
+               this.communicator = communicator;
+               this.grabPosition = new Point(0, 0);
+
                /* load image for HW key button */
                ClassLoader loader = this.getClass().getClassLoader();
                imageNormal = new Image(Display.getDefault(),
@@ -96,15 +107,20 @@ public class ControlPanel extends SkinWindow {
 
                /* calculate the key window size */
                int width = imageNormal.getImageData().width;
-               int height = (imageNormal.getImageData().height * 4) + (4 * 3);
+               int height = (imageNormal.getImageData().height * BUTTON_DEFAULT_CNT) +
+                               (BUTTON_VERTICAL_SPACING * (BUTTON_DEFAULT_CNT - 1)) +
+                               (PAIRTAG_CIRCLE_SIZE + PAIRTAG_MARGIN_BOTTOM) +
+                               SHELL_MARGIN_BOTTOM;
 
                /* make a frame image */
                this.imageFrame = frameMaker.getPatchedImage(width, height);
                this.colorFrame = new Color(shell.getDisplay(), new RGB(38, 38, 38));
 
-               this.keyMapList = keyMapList;
-               this.communicator = communicator;
-               this.grabPosition = new Point(0, 0);
+               /* generate a pair tag color of key window */
+               int red = (int) (Math.random() * 256);
+               int green = (int) (Math.random() * 256);
+               int blue = (int) (Math.random() * 256);
+               this.colorPairTag = new Color(shell.getDisplay(), new RGB(red, green, blue));
 
                createContents();
                trimPatchedShell(shell, imageFrame);
@@ -116,7 +132,7 @@ public class ControlPanel extends SkinWindow {
        }
 
        protected void createContents() {
-               GridLayout shellGridLayout = new GridLayout(1, true);
+               GridLayout shellGridLayout = new GridLayout(1, false);
                shellGridLayout.marginLeft = shellGridLayout.marginRight = frameMaker.getPatchWidth();
                shellGridLayout.marginTop = shellGridLayout.marginBottom = frameMaker.getPatchHeight();
                shellGridLayout.marginWidth = shellGridLayout.marginHeight = 0;
@@ -124,17 +140,34 @@ public class ControlPanel extends SkinWindow {
 
                shell.setLayout(shellGridLayout);
 
+               /* make a pair tag circle */
+               Canvas pairTagCanvas = new Canvas(shell, SWT.NONE);
+               pairTagCanvas.setBackground(colorFrame);
+               pairTagCanvas.setLayoutData(new GridData(PAIRTAG_CIRCLE_SIZE,
+                               PAIRTAG_CIRCLE_SIZE + PAIRTAG_MARGIN_BOTTOM));
+
+               pairTagCanvas.addPaintListener(new PaintListener() {
+                       @Override
+                       public void paintControl(PaintEvent e) {
+                               e.gc.setBackground(colorPairTag);
+                               e.gc.setAntialias(SWT.ON);
+                               e.gc.fillOval(0, 0, PAIRTAG_CIRCLE_SIZE, PAIRTAG_CIRCLE_SIZE);
+                       }
+               });
+
+               /* */
                ScrolledComposite compositeScroll = new ScrolledComposite(shell, SWT.V_SCROLL);
                compositeScroll.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));
+
                Composite compositeBase = new Composite(compositeScroll, SWT.NONE);
-               //compositeBase.setBackground(colorFrame);
+               compositeBase.setBackground(colorFrame);
 
                GridLayout compositeGridLayout = new GridLayout(1, false);
                compositeGridLayout.marginLeft = compositeGridLayout.marginRight = 0;
                compositeGridLayout.marginTop = compositeGridLayout.marginBottom = 0;
                compositeGridLayout.marginWidth = compositeGridLayout.marginHeight = 0;
                compositeGridLayout.horizontalSpacing = 0;
-               compositeGridLayout.verticalSpacing = 4;
+               compositeGridLayout.verticalSpacing = BUTTON_VERTICAL_SPACING;
                compositeBase.setLayout(compositeGridLayout);
 
                if (keyMapList != null && keyMapList.isEmpty() == false) {
@@ -277,6 +310,7 @@ public class ControlPanel extends SkinWindow {
                                imageHover.dispose();
                                imagePushed.dispose();
                                colorFrame.dispose();
+                               colorPairTag.dispose();
 
                                frameMaker.freePatches();
                        }
@@ -284,4 +318,8 @@ public class ControlPanel extends SkinWindow {
 
                shell.addListener(SWT.Close, shellCloseListener);
        }
+
+       public Color getPairTagColor() {
+               return colorPairTag;
+       }
 }