skin: added skin mode arg
authorgiwoong.kim <giwoong.kim@samsung.com>
Mon, 8 Oct 2012 12:45:42 +0000 (21:45 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Fri, 12 Oct 2012 03:27:41 +0000 (12:27 +0900)
added skin.mode argument to startup option of skin

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java
tizen/src/skin/client/src/org/tizen/emulator/skin/mode/SkinMode.java [new file with mode: 0644]

index 2d987b81299588639bed397686b3b1f74cfe2372..edefcd79db01517b3452a5bbe82660df763971a1 100644 (file)
 package org.tizen.emulator.skin;
 
 import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.mode.SkinMode;
 
 public class EmulatorSdlSkin extends EmulatorSkin {
        /**
         *  Constructor
         */
-       public EmulatorSdlSkin(EmulatorConfig config, boolean isOnTop) {
-               super(config, isOnTop);
+       public EmulatorSdlSkin(EmulatorConfig config, SkinMode mode, boolean isOnTop) {
+               super(config, mode, isOnTop);
        }
 
 }
index 484fa248822ff4448d99e2d764d83a7db43853f5..abbb8f0a631df8513e1f70fa4f98b53c339cdf59 100644 (file)
@@ -36,6 +36,7 @@ import org.eclipse.swt.graphics.PaletteData;
 import org.eclipse.swt.graphics.Transform;
 import org.eclipse.swt.widgets.Display;
 import org.tizen.emulator.skin.config.EmulatorConfig;
+import org.tizen.emulator.skin.mode.SkinMode;
 
 public class EmulatorShmSkin extends EmulatorSkin {
        public static final int RED_MASK = 0x00FF0000;
@@ -113,8 +114,8 @@ public class EmulatorShmSkin extends EmulatorSkin {
        /**
         *  Constructor
         */
-       public EmulatorShmSkin(EmulatorConfig config, boolean isOnTop) {
-               super(config, isOnTop);
+       public EmulatorShmSkin(EmulatorConfig config, SkinMode mode, boolean isOnTop) {
+               super(config, mode, isOnTop);
 
                this.paletteData = new PaletteData(RED_MASK, GREEN_MASK, BLUE_MASK);
        }
index cab80896ea30cc3482e8e796229bf435b9e052cc..b707498ba228b78775dbbf9aa8b291da5f91d08b 100644 (file)
@@ -97,6 +97,7 @@ import org.tizen.emulator.skin.image.ImageRegistry;
 import org.tizen.emulator.skin.image.ImageRegistry.IconName;
 import org.tizen.emulator.skin.image.ImageRegistry.ImageType;
 import org.tizen.emulator.skin.log.SkinLogger;
+import org.tizen.emulator.skin.mode.SkinMode;
 import org.tizen.emulator.skin.screenshot.ScreenShotDialog;
 import org.tizen.emulator.skin.util.SkinRegion;
 import org.tizen.emulator.skin.util.SkinRotation;
@@ -139,6 +140,7 @@ public class EmulatorSkin {
        private Shell shell;
        private ImageRegistry imageRegistry;
        protected Canvas lcdCanvas;
+       private SkinMode skinMode;
        private Image currentImage;
        private Image currentKeyPressedImage;
        private Color hoverColor;
@@ -192,8 +194,9 @@ public class EmulatorSkin {
         * @param config : configuration of emulator skin
         * @param isOnTop : always on top flag
        */
-       protected EmulatorSkin( EmulatorConfig config, boolean isOnTop ) {
+       protected EmulatorSkin(EmulatorConfig config, SkinMode mode, boolean isOnTop) {
                this.config = config;
+               this.skinMode = mode;
                this.isDefaultHoverColor = true;
                this.isOnTop = isOnTop;
                this.pressedKeyEventList = new LinkedList<KeyEventData>();
@@ -455,8 +458,11 @@ public class EmulatorSkin {
                        tempKeyPressedImage.dispose();
                }
 
-               SkinUtil.trimShell( shell, currentImage );
-               SkinUtil.adjustLcdGeometry( lcdCanvas, scale, rotationId );
+               /* custom window shape */
+               SkinUtil.trimShell(shell, currentImage);
+
+               /* not using a layout */
+               SkinUtil.adjustLcdGeometry(lcdCanvas, scale, rotationId);
 
                if( null != currentImage ) {
                        ImageData imageData = currentImage.getImageData();
index b937e8563b266361004bf41aefecd0ae1a8e83a9..839472a4badb3437386c0e45c534ff1591e24295 100644 (file)
@@ -53,6 +53,7 @@ import org.tizen.emulator.skin.exception.JaxbException;
 import org.tizen.emulator.skin.image.ImageRegistry;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.log.SkinLogger.SkinLogLevel;
+import org.tizen.emulator.skin.mode.SkinMode;
 import org.tizen.emulator.skin.util.IOUtil;
 import org.tizen.emulator.skin.util.JaxbUtil;
 import org.tizen.emulator.skin.util.StringUtil;
@@ -94,9 +95,9 @@ public class EmulatorSkinMain {
 
                        System.exit(-1);
                }
-               
+
                SocketCommunicator communicator = null;
-               
+
                try {
 
                        String vmPath = getVmPath( args );
@@ -108,9 +109,11 @@ public class EmulatorSkinMain {
 
                        logger = SkinLogger.getSkinLogger( EmulatorSkinMain.class ).getLogger();
                        logger.info( "!!! Start Emualtor Skin !!!" );
-                       
+
+                       /* startup arguments parsing */
                        Map<String, String> argsMap = parsArgs( args );
-                       
+
+                       /* set emulator window skin property */
                        String skinPropFilePath = vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME;
                        Properties skinProperties = loadProperties( skinPropFilePath, true );
                        if ( null == skinProperties ) {
@@ -118,6 +121,7 @@ public class EmulatorSkinMain {
                                System.exit( -1 );
                        }
 
+                       /* set emulator window config property */
                        String configPropFilePath = vmPath + File.separator + CONFIG_PROPERTIES_FILE_NAME;
                        Properties configProperties = loadProperties( configPropFilePath, false );
 
@@ -127,7 +131,7 @@ public class EmulatorSkinMain {
                        EmulatorConfig.validateArgs( argsMap );
                        EmulatorConfig.validateSkinProperties( skinProperties );
                        EmulatorConfig.validateSkinConfigProperties( configProperties );
-                       
+
                        int lcdWidth = Integer.parseInt( argsMap.get( ArgsConstants.RESOLUTION_WIDTH ) );
                        int lcdHeight = Integer.parseInt( argsMap.get( ArgsConstants.RESOLUTION_HEIGHT ) );
                        String argSkinPath = (String) argsMap.get( ArgsConstants.SKIN_PATH );
@@ -151,17 +155,23 @@ public class EmulatorSkinMain {
                        EmulatorConfig config = new EmulatorConfig( argsMap, dbiContents, skinProperties, skinPropFilePath,
                                        configProperties );
 
-                       ImageRegistry.getInstance().initialize( config );
-                       
-                       String onTopVal = config.getSkinProperty( SkinPropertiesConstants.WINDOW_ONTOP, Boolean.FALSE.toString() );
-                       boolean isOnTop = Boolean.parseBoolean( onTopVal );
+                       /* load image resource */
+                       ImageRegistry.getInstance().initialize(config);
+
+                       String onTopVal = config.getSkinProperty(
+                                       SkinPropertiesConstants.WINDOW_ONTOP, Boolean.FALSE.toString());
+                       boolean isOnTop = Boolean.parseBoolean(onTopVal);
+
+                       /* determine skin mode */
+                       SkinMode skinMode = SkinMode.getValue(argsMap.get(ArgsConstants.SKIN_MODE));
+                       logger.info("skin mode is " + skinMode);
 
                        /* create skin */
                        EmulatorSkin skin;
                        if (SwtUtil.isMacPlatform()) {
-                               skin = new EmulatorShmSkin(config, isOnTop);
+                               skin = new EmulatorShmSkin(config, skinMode, isOnTop);
                        } else { // linux & windows
-                               skin = new EmulatorSdlSkin(config, isOnTop);
+                               skin = new EmulatorSdlSkin(config, skinMode, isOnTop);
                        }
 
                        long windowHandleId = skin.compose();
index 0c46b1b8bccc6b5c18a6ee4b1341bde2bcff66ed..dab1dd087047b92a1537e29d5fdf3f302dc1160e 100644 (file)
@@ -73,6 +73,7 @@ public class EmulatorConfig {
                public static final String LOG_LEVEL = "log.level";
                public static final String NET_BASE_PORT = "net.baseport";
                public static final String SKIN_PATH = "skin.path";
+               public static final String SKIN_MODE = "skin.mode";
        }
 
        public interface SkinPropertiesConstants {
@@ -106,60 +107,59 @@ public class EmulatorConfig {
                }
        }
 
-       public static void validateArgs( Map<String, String> args ) throws ConfigException {
-               if ( null == args ) {
+       public static void validateArgs(Map<String, String> args) throws ConfigException {
+               if (null == args) {
                        return;
                }
 
-               if( args.containsKey( ArgsConstants.UID ) ) {
-                       String uid = args.get( ArgsConstants.UID );
+               if (args.containsKey(ArgsConstants.UID)) {
+                       String uid = args.get(ArgsConstants.UID);
                        try {
-                               Integer.parseInt( uid );
-                       } catch ( NumberFormatException e ) {
+                               Integer.parseInt(uid);
+                       } catch (NumberFormatException e) {
                                String msg = ArgsConstants.UID + " argument is not numeric. : " + uid;
-                               throw new ConfigException( msg );
+                               throw new ConfigException(msg);
                        }
                }
 
-               if( args.containsKey( ArgsConstants.SERVER_PORT ) ) {
-                       String serverPort = args.get( ArgsConstants.SERVER_PORT );
+               if (args.containsKey(ArgsConstants.SERVER_PORT)) {
+                       String serverPort = args.get(ArgsConstants.SERVER_PORT);
                        try {
-                               Integer.parseInt( serverPort );
-                       } catch ( NumberFormatException e ) {
+                               Integer.parseInt(serverPort);
+                       } catch (NumberFormatException e) {
                                String msg = ArgsConstants.SERVER_PORT + " argument is not numeric. : " + serverPort;
-                               throw new ConfigException( msg );
+                               throw new ConfigException(msg);
                        }
-               }else {
+               } else {
                        String msg = ArgsConstants.SERVER_PORT + " is required argument.";
-                       throw new ConfigException( msg );
+                       throw new ConfigException(msg);
                }
 
-               if( args.containsKey( ArgsConstants.RESOLUTION_WIDTH ) ) {
-                       String width = args.get( ArgsConstants.RESOLUTION_WIDTH );
+               if (args.containsKey(ArgsConstants.RESOLUTION_WIDTH)) {
+                       String width = args.get(ArgsConstants.RESOLUTION_WIDTH);
                        try {
-                               Integer.parseInt( width );
-                       } catch ( NumberFormatException e ) {
+                               Integer.parseInt(width);
+                       } catch (NumberFormatException e) {
                                String msg = ArgsConstants.RESOLUTION_WIDTH + " argument is not numeric. : " + width;
-                               throw new ConfigException( msg );
+                               throw new ConfigException(msg);
                        }
-               }else {
+               } else {
                        String msg = ArgsConstants.RESOLUTION_WIDTH + " is required argument.";
-                       throw new ConfigException( msg );
+                       throw new ConfigException(msg);
                }
 
-               if( args.containsKey( ArgsConstants.RESOLUTION_HEIGHT ) ) {
-                       String height = args.get( ArgsConstants.RESOLUTION_HEIGHT );
+               if (args.containsKey(ArgsConstants.RESOLUTION_HEIGHT)) {
+                       String height = args.get(ArgsConstants.RESOLUTION_HEIGHT);
                        try {
-                               Integer.parseInt( height );
-                       } catch ( NumberFormatException e ) {
+                               Integer.parseInt(height);
+                       } catch (NumberFormatException e) {
                                String msg = ArgsConstants.RESOLUTION_HEIGHT + " argument is not numeric. : " + height;
-                               throw new ConfigException( msg );
+                               throw new ConfigException(msg);
                        }
-               }else {
+               } else {
                        String msg = ArgsConstants.RESOLUTION_HEIGHT + " is required argument.";
-                       throw new ConfigException( msg );
+                       throw new ConfigException(msg);
                }
-
        }
 
        public static void validateSkinProperties( Properties skinProperties ) throws ConfigException {
diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/mode/SkinMode.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/mode/SkinMode.java
new file mode 100644 (file)
index 0000000..e8f4486
--- /dev/null
@@ -0,0 +1,61 @@
+/**
+ * 
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * GiWoong Kim <giwoong.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.skin.mode;
+
+/**
+ *
+ */
+public enum SkinMode {
+       NONE("none"),
+       FULLSCREEN("fullscreen"),
+       DEFAULT("default"),
+       CUSTOM("custom");
+
+       private String value;
+
+       SkinMode(String value) {
+               this.value = value;
+       }
+
+       public String value() {
+               return this.value;
+       }
+       
+       public static SkinMode getValue(String val) {
+               SkinMode[] values = SkinMode.values();
+               for (int i = 0; i < values.length; i++) {
+                       if (values[i].value.equalsIgnoreCase(val) == true) {
+                               return values[i];
+                       }
+               }
+
+               return SkinMode.DEFAULT;
+       }
+}
+