From 2a43cb80e8f36aeb8059871a43716edddee1b44a Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Thu, 3 Jan 2013 17:20:21 +0900 Subject: [PATCH] skin: refined the code of general skin delete unnecessary filed, modified the variable name and etc. Signed-off-by: GiWoong Kim --- .../org/tizen/emulator/skin/EmulatorSkin.java | 56 +++++++++---------- .../layout/GeneralPurposeSkinComposer.java | 32 +++++------ .../emulator/skin/window/ControlPanel.java | 13 ++--- .../emulator/skin/window/SkinWindow.java | 54 +++++++++--------- 4 files changed, 76 insertions(+), 79 deletions(-) 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 a45c560ddd..7d850dec70 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 @@ -144,7 +144,7 @@ public class EmulatorSkin { private Menu contextMenu; private MenuItem panelItem; /* key window menu */ - public ControlPanel controlPanel; + public ControlPanel keyWindow; public Color colorPairTag; public Canvas pairTagCanvas; public CustomProgressBar bootingProgress; @@ -355,13 +355,13 @@ public class EmulatorSkin { screenShotDialog = null; } - /* close the control panel window */ - if (null != controlPanel) { - Shell cpShell = controlPanel.getShell(); - if (!cpShell.isDisposed()) { - cpShell.close(); + /* close the Key Window */ + if (null != keyWindow) { + Shell keyWindowShell = keyWindow.getShell(); + if (!keyWindowShell.isDisposed()) { + keyWindowShell.close(); } - controlPanel = null; + keyWindow = null; if (colorPairTag != null) { colorPairTag.dispose(); @@ -466,9 +466,9 @@ public class EmulatorSkin { logger.info("gain focus"); if (isOnTop == false && isControlPanel == true) { - if (controlPanel != null && - controlPanel.isAttach() != SWT.NONE) { - controlPanel.getShell().moveAbove(shell); + if (keyWindow != null && + keyWindow.getDockPosition() != SWT.NONE) { + keyWindow.getShell().moveAbove(shell); } } } @@ -919,11 +919,10 @@ public class EmulatorSkin { return isControlPanel; } - public void openKeyWindow(int attach) { - if (controlPanel != null) { - controlPanel.getShell().setVisible(true); - SkinUtil.setTopMost(controlPanel.getShell(), isOnTop); - controlPanel.setAttach(attach); + public void openKeyWindow(int dockValue) { + if (keyWindow != null) { + keyWindow.getShell().setVisible(true); + SkinUtil.setTopMost(keyWindow.getShell(), isOnTop); pairTagCanvas.setVisible(true); return; @@ -942,22 +941,22 @@ public class EmulatorSkin { } try { - controlPanel = new ControlPanel(this, shell, colorPairTag, + keyWindow = new ControlPanel(this, shell, colorPairTag, communicator, keyMapList); - SkinUtil.setTopMost(controlPanel.getShell(), isOnTop); + SkinUtil.setTopMost(keyWindow.getShell(), isOnTop); - //colorPairTag = controlPanel.getPairTagColor(); + //colorPairTag = keyWindow.getPairTagColor(); pairTagCanvas.setVisible(true); - controlPanel.open(); + keyWindow.open(dockValue); /* do not add at this line */ } finally { - controlPanel = null; + keyWindow = null; } } public void hideKeyWindow() { - controlPanel.getShell().setVisible(false); + keyWindow.getShell().setVisible(false); pairTagCanvas.setVisible(false); } @@ -1002,8 +1001,8 @@ public class EmulatorSkin { if (SkinUtil.setTopMost(shell, isOnTop) == false) { logger.info("failed to Always On Top"); } else { - if (controlPanel != null) { - SkinUtil.setTopMost(controlPanel.getShell(), isOnTop); + if (keyWindow != null) { + SkinUtil.setTopMost(keyWindow.getShell(), isOnTop); } } } @@ -1039,13 +1038,14 @@ public class EmulatorSkin { setIsControlPanel(isControlPanel); if (isControlPanel == true) { - openKeyWindow((controlPanel == null) ? - SWT.NONE : controlPanel.isAttach()); + openKeyWindow((keyWindow == null) ? + SWT.RIGHT | SWT.CENTER : keyWindow.getDockPosition()); } else { /* hide a key window */ - if (controlPanel != null && - controlPanel.isAttach() != SWT.NONE) { + if (keyWindow != null && + keyWindow.getDockPosition() != SWT.NONE) { + /* Close the Key Window if it is docked to Main Window */ pairTagCanvas.setVisible(false); - controlPanel.getShell().close(); + keyWindow.getShell().close(); } else { hideKeyWindow(); } 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 33070edfd0..c4bc0152fb 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 @@ -158,8 +158,8 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { @Override public void mouseDown(MouseEvent e) { if (skin.getIsControlPanel() == true) { - if (skin.controlPanel != null) { - skin.controlPanel.getShell().close(); + if (skin.keyWindow != null) { + skin.keyWindow.getShell().close(); } skin.setIsControlPanel(false); @@ -169,8 +169,8 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { skin.openKeyWindow(SWT.RIGHT | SWT.CENTER); /* move a key window to right of the emulator window */ - if (skin.controlPanel != null) { - skin.controlPanel.setShellPosition( + if (skin.keyWindow != null) { + skin.keyWindow.dock( SWT.RIGHT | SWT.CENTER, true, false); } } @@ -355,10 +355,10 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { e.gc.drawImage(currentState.getCurrentImage(), 0, 0); } - if (skin.controlPanel != null && - skin.controlPanel.isAttach() != SWT.NONE) { - skin.controlPanel.setShellPosition( - skin.controlPanel.isAttach(), false, false); + if (skin.keyWindow != null && + skin.keyWindow.getDockPosition() != SWT.NONE) { + skin.keyWindow.dock( + skin.keyWindow.getDockPosition(), false, false); } } }; @@ -376,10 +376,10 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { shell.setLocation(x, y); - if (skin.controlPanel != null && - skin.controlPanel.isAttach() != SWT.NONE) { - skin.controlPanel.setShellPosition( - skin.controlPanel.isAttach(), false, false); + if (skin.keyWindow != null && + skin.keyWindow.getDockPosition() != SWT.NONE) { + skin.keyWindow.dock( + skin.keyWindow.getDockPosition(), false, false); } } } @@ -396,10 +396,10 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { isGrabbedShell = false; grabPosition.x = grabPosition.y = 0; - if (skin.controlPanel != null && - skin.controlPanel.isAttach() != SWT.NONE) { - skin.controlPanel.setShellPosition( - skin.controlPanel.isAttach(), false, true); + if (skin.keyWindow != null && + skin.keyWindow.getDockPosition() != SWT.NONE) { + skin.keyWindow.dock( + skin.keyWindow.getDockPosition(), false, true); } } } 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 4f9f528718..f960a011f0 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 @@ -316,16 +316,13 @@ public class ControlPanel extends SkinWindow { 30, heightOneThird); if (childBounds.intersects(attachBounds1) == true) { - setShellPosition(SWT.RIGHT | SWT.CENTER, false, true); - isAttach = SWT.RIGHT | SWT.CENTER; + dock(SWT.RIGHT | SWT.CENTER, false, true); } else if (childBounds.intersects(attachBounds2) == true) { - setShellPosition(SWT.RIGHT | SWT.TOP, false, true); - isAttach = SWT.RIGHT | SWT.TOP; + dock(SWT.RIGHT | SWT.TOP, false, true); } else if (childBounds.intersects(attachBounds3) == true) { - setShellPosition(SWT.RIGHT | SWT.BOTTOM, false, true); - isAttach = SWT.RIGHT | SWT.BOTTOM; + dock(SWT.RIGHT | SWT.BOTTOM, false, true); } else { - isAttach = SWT.NONE; + dock(SWT.NONE, false, true); } } } @@ -356,7 +353,7 @@ public class ControlPanel extends SkinWindow { skin.pairTagCanvas.setVisible(false); } skin.setIsControlPanel(false); - skin.controlPanel = null; + skin.keyWindow = null; if (null != shellPaintListener) { shell.removePaintListener(shellPaintListener); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/window/SkinWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/SkinWindow.java index 5edb84bcb9..ed2c0d1c69 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/window/SkinWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/window/SkinWindow.java @@ -42,26 +42,23 @@ public class SkinWindow { protected Shell shell; protected Shell parent; - private int shellPositionType; - protected int isAttach; + private int dockPosition; - public SkinWindow(Shell parent, int shellPositionType) { + public SkinWindow(Shell parent, int dockPosition) { this.parent = parent; - this.shellPositionType = shellPositionType; - this.isAttach = SWT.NONE; + this.dockPosition = dockPosition; } public Shell getShell() { return shell; } - public void open() { + public void open(int dockValue) { if (shell.isDisposed()) { return; } - setShellPosition(shellPositionType, true, true); - isAttach = SWT.RIGHT | SWT.CENTER; + dock(dockValue, true, true); shell.open(); @@ -72,7 +69,7 @@ public class SkinWindow { } } - public void setShellPosition(int shellPositionType, + public void dock(int dockValue, boolean correction, boolean enableLogger) { int x = 0; int y = 0; @@ -87,26 +84,33 @@ public class SkinWindow { logger.info("current child shell bounds : " + childBounds); } - if (shellPositionType == (SWT.RIGHT | SWT.TOP)) { + dockPosition = dockValue; + + if (dockPosition == SWT.NONE){ + logger.info("undock"); + /* do nothing */ + + return; + } else if (dockPosition == (SWT.RIGHT | SWT.TOP)) { x = parentBounds.x + parentBounds.width; y = parentBounds.y; /* correction of location */ -// if ((x + childBounds.width) > -// (monitorBounds.x + monitorBounds.width)) { -// x = parentBounds.x - childBounds.width; -// } - } else if (shellPositionType == (SWT.RIGHT | SWT.BOTTOM)) { + /*if ((x + childBounds.width) > + (monitorBounds.x + monitorBounds.width)) { + x = parentBounds.x - childBounds.width; + }*/ + } else if (dockPosition == (SWT.RIGHT | SWT.BOTTOM)) { x = parentBounds.x + parentBounds.width; y = parentBounds.y + parentBounds.height - childBounds.height; /* correction of location */ -// int shift = (monitorBounds.x + monitorBounds.width) - -// (x + childBounds.width); -// if (shift < 0) { -// x += shift; -// parent.setLocation(parentBounds.x + shift, parentBounds.y); -// } + /*int shift = (monitorBounds.x + monitorBounds.width) - + (x + childBounds.width); + if (shift < 0) { + x += shift; + parent.setLocation(parentBounds.x + shift, parentBounds.y); + }*/ } else { /* SWT.RIGHT | SWT.CENTER */ x = parentBounds.x + parentBounds.width; y = parentBounds.y + (parentBounds.height / 2) - @@ -126,11 +130,7 @@ public class SkinWindow { shell.setLocation(x, y); } - public void setAttach(int attach) { - isAttach = attach; - } - - public int isAttach() { - return isAttach; + public int getDockPosition() { + return dockPosition; } } -- 2.34.1