From: giwoong.kim Date: Mon, 3 Dec 2012 07:00:48 +0000 (+0900) Subject: skin: added Pair Tag to key window & emul window X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1313^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=492e2ac6f376bce80830662d2c4182953412327a;p=sdk%2Femulator%2Fqemu.git skin: added Pair Tag to key window & emul window This tag represents a pair of windows. The color of tag is random for each VM. Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index 61610fc927..5f03ed6d7c 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -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) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java index 6a63f8a03e..24d3d40a35 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java @@ -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; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java index 70867d177c..7eb35307a9 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java @@ -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(); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java index 9916e2aef0..e13f3874a4 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/layout/SkinPatches.java @@ -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); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java index 6251e77338..7aa082542c 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/ControlPanel.java @@ -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 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; + } }