skin: align the folding button in general skin
authorgiwoong.kim <giwoong.kim@samsung.com>
Thu, 1 Nov 2012 12:35:26 +0000 (21:35 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Thu, 1 Nov 2012 12:35:26 +0000 (21:35 +0900)
I aligned a folding button at middle of lcd height.

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/util/SkinUtil.java

index 437a252bba70d3426d9c49750ae14e04f5132dc4..c618d81f849131387df4095cd4459bc4c85c0c4c 100644 (file)
@@ -66,6 +66,7 @@ import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
@@ -395,7 +396,12 @@ public class EmulatorSkin {
                this.currentLcdHeight = resolutionH;
                this.currentScale = scale;
                this.currentRotationId = rotationId;
-               this.currentAngle = SkinRotation.getAngle( rotationId );
+               this.currentAngle = SkinRotation.getAngle(rotationId);
+
+               /* arrange the lcd */
+               Rectangle lcdBounds = SkinUtil.adjustLcdGeometry(
+                               lcdCanvas, currentLcdWidth, currentLcdHeight, scale, rotationId,
+                               skinInfo.isPhoneShape());
 
                if (skinInfo.isPhoneShape() == false) {
                        /* folding button */
@@ -403,11 +409,6 @@ public class EmulatorSkin {
                                foldingButton = new Button(shell, SWT.PUSH);
                                foldingButton.setText(">");
 
-                               FormData dataFoldingButton = new FormData();
-                               dataFoldingButton.left = new FormAttachment(lcdCanvas, 0);
-                               dataFoldingButton.top = new FormAttachment(0, 0);
-                               foldingButton.setLayoutData(dataFoldingButton);
-
                                foldingButton.addMouseListener(new MouseListener() {
                                        @Override
                                        public void mouseDown(MouseEvent e) {
@@ -418,11 +419,9 @@ public class EmulatorSkin {
                                        public void mouseUp(MouseEvent e) {
                                                if (skinInfo.getSkinOption() == 0) {
                                                        skinInfo.setSkinOption(1);
-
                                                        foldingButton.setText("<");
                                                } else {
                                                        skinInfo.setSkinOption(0);
-
                                                        foldingButton.setText(">");
                                                }
 
@@ -438,8 +437,16 @@ public class EmulatorSkin {
                                                /* do nothing */
                                        }
                                });
+
+                               shell.pack();
                        }
 
+                       FormData dataFoldingButton = new FormData();
+                       dataFoldingButton.left = new FormAttachment(lcdCanvas, 0);
+                       dataFoldingButton.top = new FormAttachment(
+                                       0, (lcdBounds.height / 2) - (foldingButton.getSize().y / 2));
+                       foldingButton.setLayoutData(dataFoldingButton);
+
                        if (skinInfo.getSkinOption() == 0) {
                                /* HW keys region */
                                if (decoration == null) {
@@ -521,10 +528,6 @@ public class EmulatorSkin {
                        SkinUtil.trimShell(shell, currentImage);
                }
 
-               /* arrange the lcd */
-               SkinUtil.adjustLcdGeometry(lcdCanvas, currentLcdWidth, currentLcdHeight,
-                               scale, rotationId, skinInfo.isPhoneShape());
-
                /* set window size */
                if (null != currentImage) {
                        ImageData imageData = currentImage.getImageData();
index 169ecc1ae400181b6a11d3dc360e2979d736fb40..c5cd5630c07f51a09e48576dfcc3b6cecf00385c 100644 (file)
@@ -110,12 +110,12 @@ public class SkinUtil {
                return sdbPath;
        }
 
-       public static void adjustLcdGeometry(
+       public static Rectangle adjustLcdGeometry(
                        Canvas lcdCanvas, int resolutionW, int resolutionH,
                        int scale, short rotationId, boolean isPhoneShape) {
 
                float convertedScale = convertScale(scale);
-               int l = 0, t = 0, w = 0, h = 0;
+               Rectangle lcdBounds = new Rectangle(0, 0, 0, 0);
 
                if (isPhoneShape == false) {
                        RotationInfo rotation = RotationInfo.getValue(rotationId);
@@ -123,11 +123,11 @@ public class SkinUtil {
                        /* resoultion, that is lcd size in general skin mode */
                        if (RotationInfo.LANDSCAPE == rotation ||
                                        RotationInfo.REVERSE_LANDSCAPE == rotation) {
-                               w = (int)(resolutionH * convertedScale);
-                               h = (int)(resolutionW * convertedScale);
+                               lcdBounds.width = (int)(resolutionH * convertedScale);
+                               lcdBounds.height = (int)(resolutionW * convertedScale);
                        } else {
-                               w = (int)(resolutionW * convertedScale);
-                               h = (int)(resolutionH * convertedScale);
+                               lcdBounds.width = (int)(resolutionW * convertedScale);
+                               lcdBounds.height = (int)(resolutionH * convertedScale);
                        }
                } else {
                        RotationType rotation = SkinRotation.getRotation(rotationId);
@@ -140,18 +140,20 @@ public class SkinUtil {
                        Integer width = region.getWidth();
                        Integer height = region.getHeight();
 
-                       l = (int) (left * convertedScale);
-                       t = (int) (top * convertedScale);
-                       w = (int) (width * convertedScale);
-                       h = (int) (height * convertedScale);
+                       lcdBounds.x = (int) (left * convertedScale);
+                       lcdBounds.y = (int) (top * convertedScale);
+                       lcdBounds.width = (int) (width * convertedScale);
+                       lcdBounds.height = (int) (height * convertedScale);
                }
 
                FormData data = new FormData();
-               data.left = new FormAttachment(0, l);
-               data.top = new FormAttachment(0, t);
-               data.width = w;
-               data.height = h;
+               data.left = new FormAttachment(0, lcdBounds.x);
+               data.top = new FormAttachment(0, lcdBounds.y);
+               data.width = lcdBounds.width;
+               data.height = lcdBounds.height;
                lcdCanvas.setLayoutData(data);
+
+               return lcdBounds;
        }
 
        public static SkinRegion getHardKeyArea( int currentX, int currentY, short rotationId, int scale ) {