From a63ae5cef86ba8809af9e17d6dab32c95e101007 Mon Sep 17 00:00:00 2001 From: "giwoong.kim" Date: Thu, 6 Dec 2012 15:31:49 +0900 Subject: [PATCH] skin: add window docking area right-top, right-bottom docking area is added Signed-off-by: GiWoong Kim --- .../src/org/tizen/emulator/skin/EmulatorSkin.java | 7 ++-- .../skin/layout/GeneralPurposeSkinComposer.java | 16 ++++----- .../tizen/emulator/skin/window/ControlPanel.java | 37 ++++++++++++++++----- .../org/tizen/emulator/skin/window/SkinWindow.java | 38 +++++++++++++++------- 4 files changed, 66 insertions(+), 32 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 ad4b4b3..714aa4f 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 @@ -900,7 +900,7 @@ public class EmulatorSkin { return isControlPanel; } - public void openKeyWindow(boolean attach) { + public void openKeyWindow(int attach) { if (controlPanel != null) { controlPanel.getShell().setVisible(true); SkinUtil.setTopMost(controlPanel.getShell(), isOnTop); @@ -1020,9 +1020,10 @@ public class EmulatorSkin { setIsControlPanel(isControlPanel); if (isControlPanel == true) { openKeyWindow((controlPanel == null) ? - true : controlPanel.isAttach()); + SWT.NONE : controlPanel.isAttach()); } else { /* hide a key window */ - if (controlPanel != null && controlPanel.isAttach()) { + if (controlPanel != null && + controlPanel.isAttach() != SWT.NONE) { pairTagCanvas.setVisible(false); controlPanel.getShell().close(); } else { 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 286332e..9f5b67b 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 @@ -162,12 +162,12 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { skin.pairTagCanvas.setVisible(false); } else { skin.setIsControlPanel(true); - skin.openKeyWindow(true); + skin.openKeyWindow(SWT.RIGHT | SWT.CENTER); /* move a key window to right of the emulator window */ if (skin.controlPanel != null) { skin.controlPanel.setShellPosition( - SWT.RIGHT | SWT.CENTER, false); + SWT.RIGHT | SWT.CENTER, true, false); } } } @@ -321,9 +321,9 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { } if (skin.controlPanel != null && - skin.controlPanel.isAttach() == true) { + skin.controlPanel.isAttach() != SWT.NONE) { skin.controlPanel.setShellPosition( - SWT.RIGHT | SWT.CENTER, false); + skin.controlPanel.isAttach(), false, false); } } }; @@ -342,9 +342,9 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { shell.setLocation(x, y); if (skin.controlPanel != null && - skin.controlPanel.isAttach() == true) { + skin.controlPanel.isAttach() != SWT.NONE) { skin.controlPanel.setShellPosition( - SWT.RIGHT | SWT.CENTER, false); + skin.controlPanel.isAttach(), false, false); } } } @@ -362,9 +362,9 @@ public class GeneralPurposeSkinComposer implements ISkinComposer { grabPosition.x = grabPosition.y = 0; if (skin.controlPanel != null && - skin.controlPanel.isAttach() == true) { + skin.controlPanel.isAttach() != SWT.NONE) { skin.controlPanel.setShellPosition( - SWT.RIGHT | SWT.CENTER, true); + skin.controlPanel.isAttach(), 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 d3f8e29..50dce12 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 @@ -274,19 +274,38 @@ public class ControlPanel extends SkinWindow { isGrabbedShell = false; grabPosition.x = grabPosition.y = 0; + /* Let me check whether the key window was landed + * on docking area. */ Rectangle parentBounds = parent.getBounds(); Rectangle childBounds = shell.getBounds(); - Rectangle attachBounds = new Rectangle( - parentBounds.x + parentBounds.width - 5, - parentBounds.y + (parentBounds.height / 2) - 2, - 30, 4); - - if (childBounds.intersects(attachBounds) == true) { - setShellPosition(SWT.RIGHT | SWT.CENTER, true); - isAttach = true; + /* right-middle */ + Rectangle attachBounds1 = new Rectangle( + (parentBounds.x + parentBounds.width) - 5, + (parentBounds.y + (parentBounds.height / 2)) - 10, + 30, 20); + /* right-top */ + Rectangle attachBounds2 = new Rectangle( + (parentBounds.x + parentBounds.width) - 5, + (parentBounds.y) - 40, + 30, 80); + /* right-bottom */ + Rectangle attachBounds3 = new Rectangle( + (parentBounds.x + parentBounds.width) - 5, + (parentBounds.y + parentBounds.height) - 40, + 30, 80); + + if (childBounds.intersects(attachBounds1) == true) { + setShellPosition(SWT.RIGHT | SWT.CENTER, false, true); + isAttach = SWT.RIGHT | SWT.CENTER; + } else if (childBounds.intersects(attachBounds2) == true) { + setShellPosition(SWT.RIGHT | SWT.TOP, false, true); + isAttach = SWT.RIGHT | SWT.TOP; + } else if (childBounds.intersects(attachBounds3) == true) { + setShellPosition(SWT.RIGHT | SWT.BOTTOM, false, true); + isAttach = SWT.RIGHT | SWT.BOTTOM; } else { - isAttach = false; + isAttach = SWT.NONE; } } } 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 a4b6e87..5edb84b 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 @@ -43,12 +43,12 @@ public class SkinWindow { protected Shell shell; protected Shell parent; private int shellPositionType; - protected boolean isAttach; + protected int isAttach; public SkinWindow(Shell parent, int shellPositionType) { this.parent = parent; this.shellPositionType = shellPositionType; - this.isAttach = false; + this.isAttach = SWT.NONE; } public Shell getShell() { @@ -60,8 +60,8 @@ public class SkinWindow { return; } - setShellPosition(shellPositionType, true); - isAttach = true; + setShellPosition(shellPositionType, true, true); + isAttach = SWT.RIGHT | SWT.CENTER; shell.open(); @@ -72,7 +72,8 @@ public class SkinWindow { } } - public void setShellPosition(int shellPositionType, boolean enableLogger) { + public void setShellPosition(int shellPositionType, + boolean correction, boolean enableLogger) { int x = 0; int y = 0; @@ -91,16 +92,29 @@ public class SkinWindow { y = parentBounds.y; /* correction of location */ - if ((x + childBounds.width) > - (monitorBounds.x + monitorBounds.width)) { - x = parentBounds.x - childBounds.width; - } +// if ((x + childBounds.width) > +// (monitorBounds.x + monitorBounds.width)) { +// x = parentBounds.x - childBounds.width; +// } + } else if (shellPositionType == (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); +// } } else { /* SWT.RIGHT | SWT.CENTER */ x = parentBounds.x + parentBounds.width; y = parentBounds.y + (parentBounds.height / 2) - (childBounds.height / 2); + } - /* correction of location */ + /* correction of location */ + if (correction == true) { int shift = (monitorBounds.x + monitorBounds.width) - (x + childBounds.width); if (shift < 0) { @@ -112,11 +126,11 @@ public class SkinWindow { shell.setLocation(x, y); } - public void setAttach(boolean attach) { + public void setAttach(int attach) { isAttach = attach; } - public boolean isAttach() { + public int isAttach() { return isAttach; } } -- 2.7.4