skin: non-skin type of emulator window
authorgiwoong.kim <giwoong.kim@samsung.com>
Wed, 10 Oct 2012 04:49:42 +0000 (13:49 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Fri, 12 Oct 2012 03:27:41 +0000 (12:27 +0900)
I added non-skin type for window style.
This simple type of emulator window is filled with lcd region only.

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/mode/SkinMode.java
tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java

index b707498..6eaaa75 100644 (file)
@@ -202,8 +202,11 @@ public class EmulatorSkin {
                this.pressedKeyEventList = new LinkedList<KeyEventData>();
                
                int style = SWT.NO_TRIM;
-               this.shell = new Shell( Display.getDefault(), style );
+               if (skinMode == SkinMode.NONE) {
+                       style = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.BORDER;
+               }
 
+               this.shell = new Shell(Display.getDefault(), style);
        }
 
        public void setCommunicator( SocketCommunicator communicator ) {
@@ -254,20 +257,19 @@ public class EmulatorSkin {
                        shell.setImage( imageRegistry.getIcon( IconName.EMULATOR_TITLE ) );
                }
 
-               arrangeSkin( lcdWidth, lcdHeight, scale, rotationId );
+               arrangeSkin(lcdWidth, lcdHeight, scale, rotationId);
 
-               this.isOnUsbKbd = isOnUsbKbd;
-               
-               if ( null == currentImage ) {
-                       logger.severe( "Fail to load initial skin image file. Kill this skin process!!!" );
-                       SkinUtil.openMessage( shell, null, "Fail to load Skin image file.", SWT.ICON_ERROR, config );
-                       System.exit( -1 );
+               if (skinMode != SkinMode.NONE && null == currentImage) {
+                       logger.severe("Failed to load initial skin image file. Kill this skin process.");
+                       SkinUtil.openMessage(shell, null,
+                                       "Failed to load Skin image file.", SWT.ICON_ERROR, config);
+                       System.exit(-1);
                }
 
                seteHoverColor();
 
+               this.isOnUsbKbd = isOnUsbKbd;
                setMenu();
-
        }
 
        private void setMenu() {
@@ -430,46 +432,51 @@ public class EmulatorSkin {
 
        private void arrangeSkin( int lcdWidth, int lcdHeight, int scale, short rotationId ) {
 
-               Image tempImage = null;
-               Image tempKeyPressedImage = null;
                this.currentLcdWidth = lcdWidth;
                this.currentLcdHeight = lcdHeight;
                this.currentScale = scale;
                this.currentRotationId = rotationId;
                this.currentAngle = SkinRotation.getAngle( rotationId );
 
-               if ( null != currentImage ) {
-                       tempImage = currentImage;
-               }
-               if ( null != currentKeyPressedImage ) {
-                       tempKeyPressedImage = currentKeyPressedImage;
-               }
+               if (skinMode != SkinMode.NONE) {
+                       Image tempImage = null;
+                       Image tempKeyPressedImage = null;
 
-               shell.redraw();
+                       if (null != currentImage) {
+                               tempImage = currentImage;
+                       }
+                       if (null != currentKeyPressedImage) {
+                               tempKeyPressedImage = currentKeyPressedImage;
+                       }
 
-               currentImage = SkinUtil.createScaledImage( imageRegistry, shell, rotationId, scale, ImageType.IMG_TYPE_MAIN );
-               currentKeyPressedImage = SkinUtil.createScaledImage( imageRegistry, shell, rotationId, scale,
-                               ImageType.IMG_TYPE_PRESSED );
+                       currentImage = SkinUtil.createScaledImage(
+                                       imageRegistry, shell, rotationId, scale, ImageType.IMG_TYPE_MAIN);
+                       currentKeyPressedImage = SkinUtil.createScaledImage(
+                                       imageRegistry, shell, rotationId, scale, ImageType.IMG_TYPE_PRESSED);
 
-               if (tempImage != null) {
-                       tempImage.dispose();
-               }
-               if (tempKeyPressedImage != null) {
-                       tempKeyPressedImage.dispose();
-               }
+                       if (tempImage != null) {
+                               tempImage.dispose();
+                       }
+                       if (tempKeyPressedImage != null) {
+                               tempKeyPressedImage.dispose();
+                       }
 
-               /* custom window shape */
-               SkinUtil.trimShell(shell, currentImage);
+                       /* custom window shape */
+                       SkinUtil.trimShell(shell, currentImage);
+               }
 
                /* not using a layout */
-               SkinUtil.adjustLcdGeometry(lcdCanvas, scale, rotationId);
+               SkinUtil.adjustLcdGeometry(lcdCanvas, scale, rotationId, skinMode);
 
-               if( null != currentImage ) {
+               /* set window size */
+               if (null != currentImage) {
                        ImageData imageData = currentImage.getImageData();
-                       shell.setMinimumSize( imageData.width, imageData.height );
-                       shell.setSize( imageData.width, imageData.height );
+                       shell.setMinimumSize(imageData.width, imageData.height);
+                       shell.setSize(imageData.width, imageData.height);
                }
 
+               shell.redraw();
+               shell.pack();
        }
 
        private void addShellListener( final Shell shell ) {
@@ -541,7 +548,9 @@ public class EmulatorSkin {
                        }
                };
 
-               shell.addPaintListener( shellPaintListener );
+               if (skinMode != SkinMode.NONE) {
+                       shell.addPaintListener(shellPaintListener);
+               }
 
                FocusListener shellFocusListener = new FocusListener() {
                        @Override
@@ -593,7 +602,9 @@ public class EmulatorSkin {
 
                };
 
-               shell.addMouseTrackListener( shellMouseTrackListener );
+               if (skinMode != SkinMode.NONE) {
+                       shell.addMouseTrackListener(shellMouseTrackListener);
+               }
 
                shellMouseMoveListener = new MouseMoveListener() {
                        @Override
@@ -657,7 +668,9 @@ public class EmulatorSkin {
                        } //end of mouseMove
                };
 
-               shell.addMouseMoveListener( shellMouseMoveListener );
+               if (skinMode != SkinMode.NONE) {
+                       shell.addMouseMoveListener(shellMouseMoveListener);
+               }
 
                shellMouseListener = new MouseListener() {
                        @Override
@@ -760,7 +773,9 @@ public class EmulatorSkin {
                        }
                };
 
-               shell.addMouseListener( shellMouseListener );
+               if (skinMode != SkinMode.NONE) {
+                       shell.addMouseListener(shellMouseListener);
+               }
 
                shellMenuDetectListener = new MenuDetectListener() {
                        @Override
index e8f4486..36a6519 100644 (file)
@@ -33,9 +33,9 @@ package org.tizen.emulator.skin.mode;
  */
 public enum SkinMode {
        NONE("none"),
-       FULLSCREEN("fullscreen"),
+       FULLSCREEN("fullscreen"), /* not used yet */
        DEFAULT("default"),
-       CUSTOM("custom");
+       CUSTOM("custom"); /* not used yet */
 
        private String value;
 
index 859b0b1..5cfe94a 100644 (file)
@@ -32,7 +32,6 @@ package org.tizen.emulator.skin.util;
 import java.io.File;
 import java.util.List;
 
-import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.Rectangle;
@@ -52,6 +51,7 @@ import org.tizen.emulator.skin.dbi.RegionType;
 import org.tizen.emulator.skin.dbi.RotationType;
 import org.tizen.emulator.skin.image.ImageRegistry;
 import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
+import org.tizen.emulator.skin.mode.SkinMode;
 
 
 /**
@@ -109,27 +109,27 @@ public class SkinUtil {
                return sdbPath;
        }
 
-       public static void adjustLcdGeometry( Canvas lcdCanvas, int scale, short rotationId ) {
+       public static void adjustLcdGeometry(
+                       Canvas lcdCanvas, int scale, short rotationId, SkinMode mode) {
 
-               RotationType rotation = SkinRotation.getRotation( rotationId );
+               RotationType rotation = SkinRotation.getRotation(rotationId);
 
                LcdType lcd = rotation.getLcd();
                RegionType region = lcd.getRegion();
 
-               Integer left = region.getLeft();
-               Integer top = region.getTop();
+               Integer left = (mode != SkinMode.NONE) ? region.getLeft() : 0;
+               Integer top = (mode != SkinMode.NONE) ? region.getTop() : 0;
                Integer width = region.getWidth();
                Integer height = region.getHeight();
 
-               float convertedScale = convertScale( scale );
-
-               int l = (int) ( left * convertedScale );
-               int t = (int) ( top * convertedScale );
-               int w = (int) ( width * convertedScale );
-               int h = (int) ( height * convertedScale );
+               float convertedScale = convertScale(scale);
 
-               lcdCanvas.setBounds( l, t, w, h );
+               int l = (int) (left * convertedScale);
+               int t = (int) (top * convertedScale);
+               int w = (int) (width * convertedScale);
+               int h = (int) (height * convertedScale);
 
+               lcdCanvas.setBounds(l, t, w, h);
        }
 
        public static SkinRegion getHardKeyArea( int currentX, int currentY, short rotationId, int scale ) {