From: giwoong.kim Date: Tue, 4 Dec 2012 06:27:10 +0000 (+0900) Subject: menu: correction of key window position X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1313^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35db70f7c7a4c025299a680417445ac0edeb55b8;p=sdk%2Femulator%2Fqemu.git menu: correction of key window position The key window does not get out of resolution range at generated time. And attach the key window to main window when two windows have short distance. Signed-off-by: GiWoong Kim --- 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 5a2dbb313c..c8a9dfd118 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 @@ -269,6 +269,18 @@ public class ControlPanel extends SkinWindow { if (e.button == 1) { /* left button */ isGrabbedShell = false; grabPosition.x = grabPosition.y = 0; + + 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); + } } } 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 75c8d8da31..8d07e66798 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 @@ -58,7 +58,8 @@ public class SkinWindow { return; } - setShellPosition(); + setShellPosition(shellPositionType); + shell.open(); while (!shell.isDisposed()) { @@ -68,27 +69,38 @@ public class SkinWindow { } } - protected void setShellPosition() { - int x = 0, y = 0; + protected void setShellPosition(int shellPositionType) { + int x = 0; + int y = 0; + + Rectangle monitorBounds = Display.getDefault().getBounds(); + logger.info("host monitor display bounds : " + monitorBounds); + Rectangle parentBounds = parent.getBounds(); + logger.info("current parent shell bounds : " + parentBounds); + Rectangle childBounds = shell.getBounds(); + logger.info("current child shell bounds : " + childBounds); if (shellPositionType == (SWT.RIGHT | SWT.TOP)) { - Rectangle monitorBound = Display.getDefault().getBounds(); - logger.info("host monitor display bound : " + monitorBound); - Rectangle emulatorBound = parent.getBounds(); - logger.info("current Emulator window bound : " + emulatorBound); - Rectangle panelBound = shell.getBounds(); - logger.info("current Panel shell bound : " + panelBound); - - /* location correction */ - x = emulatorBound.x + emulatorBound.width; - y = emulatorBound.y; - if ((x + panelBound.width) > (monitorBound.x + monitorBound.width)) { - x = emulatorBound.x - panelBound.width; + 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 { /* SWT.RIGHT | SWT.CENTER */ - x = parent.getBounds().x + parent.getBounds().width; - y = parent.getBounds().y + (parent.getBounds().height / 2) - - (shell.getSize().y / 2); + x = parentBounds.x + parentBounds.width; + y = parentBounds.y + (parentBounds.height / 2) - + (childBounds.height / 2); + + /* correction of location */ + int shift = (monitorBounds.x + monitorBounds.width) - + (x + childBounds.width); + if (shift < 0) { + x += shift; + parent.setLocation(parentBounds.x + shift, parentBounds.y); + } } shell.setLocation(x, y);