config: modified emulator skin properties 92/13092/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Thu, 28 Nov 2013 04:50:22 +0000 (13:50 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Thu, 28 Nov 2013 05:01:44 +0000 (14:01 +0900)
1. extended skin properties for interpolation
(save the most recently used interpolation value)
2. enhanced skin properties file loading

Change-Id: I3f603a58ec5868ebbf4de7b541616e20c9839b32
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/maru_sdl.c
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/comm/sock/SocketCommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java

index a6ce7e1..5b37ebf 100644 (file)
@@ -839,7 +839,7 @@ void maruskin_sdl_init(uint64 swt_handle,
 
     set_emul_resolution(display_width, display_height);
     set_emul_sdl_bpp(SDL_BPP);
-    maruskin_sdl_interpolation(true);
+    maruskin_sdl_interpolation(false);
     init_multi_touch_state();
 
     if (blank_guide_enable == true) {
index edce0fb..f8babf4 100755 (executable)
@@ -190,7 +190,7 @@ public class EmulatorSkin {
                this.pressedKeyEventList = new LinkedList<KeyEventData>();
 
                this.isOnTop = isOnTop;
-               this.isOnInterpolation = true;
+               this.isOnInterpolation = false;
                this.isOnKbd = false;
                this.isKeyWindow = false;
 
@@ -425,6 +425,9 @@ public class EmulatorSkin {
                                        config.setSkinProperty(
                                                        SkinPropertiesConstants.WINDOW_ONTOP,
                                                        Boolean.toString(isOnTop));
+                                       config.setSkinProperty(
+                                                       SkinPropertiesConstants.WINDOW_INTERPOLATION,
+                                                       Boolean.toString(isOnInterpolation));
 
                                        int dockValue = 0;
                                        SkinWindow keyWindow = getKeyWindowKeeper().getKeyWindow();
index 2edc547..78d5ddc 100644 (file)
@@ -131,6 +131,7 @@ public class EmulatorSkinMain {
 
                        /* startup arguments parsing */
                        Map<String, String> argsMap = parseArgs(args);
+                       EmulatorConfig.validateArgs(argsMap);
 
                        /* get skin path from startup argument */
                        String argSkinPath = (String) argsMap.get(ArgsConstants.SKIN_PATH);
@@ -192,14 +193,13 @@ public class EmulatorSkinMain {
                        String configPropFilePath =
                                        vmPath + File.separator + CONFIG_PROPERTIES_FILE_NAME;
                        Properties configProperties = loadProperties(configPropFilePath, false);
+                       EmulatorConfig.validateSkinConfigProperties(configProperties);
 
                        /* able to use log file after loading properties */
                        initLog(argsMap, configProperties);
 
                        /* validation check */
-                       EmulatorConfig.validateArgs(argsMap);
                        EmulatorConfig.validateSkinProperties(skinProperties);
-                       EmulatorConfig.validateSkinConfigProperties(configProperties);
 
                        /* determine the layout */
                        boolean isGeneralSkin = false;
index c11a892..3564c62 100755 (executable)
@@ -46,13 +46,16 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.MenuItem;
 import org.tizen.emulator.skin.EmulatorSkin;
 import org.tizen.emulator.skin.comm.ICommunicator;
 import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
+import org.tizen.emulator.skin.comm.sock.data.BooleanData;
 import org.tizen.emulator.skin.comm.sock.data.ISendData;
 import org.tizen.emulator.skin.comm.sock.data.StartData;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
+import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
 import org.tizen.emulator.skin.image.ImageRegistry.ResourceImageName;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.util.IOUtil;
@@ -175,6 +178,31 @@ public class SocketCommunicator implements ICommunicator {
        private void sendInitialData() {
                logger.info("send startData");
                sendToQEMU(SendCommand.SEND_SKIN_OPENED, startData, false);
+
+               /* default interpolation */
+               skin.getShell().getDisplay().asyncExec(new Runnable() {
+                       @Override
+                       public void run() {
+                               skin.isOnInterpolation = Boolean.parseBoolean(config.getSkinProperty(
+                                               SkinPropertiesConstants.WINDOW_INTERPOLATION,
+                                               Boolean.TRUE.toString()));
+
+                               MenuItem item = skin.getPopupMenu().interpolationHighItem;
+                               if (item != null) {
+                                       item.setSelection(skin.isOnInterpolation);
+                               }
+
+                               item = skin.getPopupMenu().interpolationLowItem;
+                               if (item != null) {
+                                       item.setSelection(!skin.isOnInterpolation);
+                               }
+
+                               BooleanData dataInterpolation = new BooleanData(
+                                               skin.isOnInterpolation,
+                                               SendCommand.SEND_INTERPOLATION_STATE.toString());
+                               sendToQEMU(SendCommand.SEND_INTERPOLATION_STATE, dataInterpolation, false);
+                       }
+               });
        }
 
        @Override
index 640159d..cc762a0 100644 (file)
@@ -94,6 +94,7 @@ public class EmulatorConfig {
                public static final String WINDOW_ROTATION = "window.rotate";
                public static final String WINDOW_SCALE = "window.scale";
                public static final String WINDOW_ONTOP = "window.ontop"; /* always on top */
+               public static final String WINDOW_INTERPOLATION = "window.interpolation";
                public static final String KEYWINDOW_POSITION = "window.keywindow.position";
        }
 
@@ -170,7 +171,8 @@ public class EmulatorConfig {
 
        public static void validateArgs(Map<String, String> args) throws ConfigException {
                if (null == args) {
-                       return;
+                       String msg = INVALID_OPTION_MESSAGE;
+                       throw new ConfigException(msg);
                }
 
                if (args.containsKey(ArgsConstants.UID)) {
@@ -240,69 +242,34 @@ public class EmulatorConfig {
                        return;
                }
 
-               Rectangle monitorBound = Display.getDefault().getBounds();
-               logger.info("current display size : " + monitorBound);
-
                if (skinProperties.containsKey(
                                SkinPropertiesConstants.WINDOW_X) == true) {
                        String window_x = skinProperties.getProperty(SkinPropertiesConstants.WINDOW_X);
-                       int xx = 0;
 
                        try {
-                               xx = Integer.parseInt(window_x);
+                               Integer.parseInt(window_x);
                        } catch (NumberFormatException e) {
                                String msg = SkinPropertiesConstants.WINDOW_X +
                                                " in .skin.properties is not numeric : " + window_x;
                                logger.warning(msg);
 
-                               xx = DEFAULT_WINDOW_X;
+                               skinProperties.remove(SkinPropertiesConstants.WINDOW_X);
                        }
-
-                       /* location correction */
-                       if (xx < monitorBound.x) {
-                               int correction = monitorBound.x;
-                               logger.info("WINDOW_X = " + xx + ", set to " + correction);
-                               xx = correction;
-                       } else if (xx > monitorBound.x + monitorBound.width - 30) {
-                               int correction = monitorBound.x + monitorBound.width - 100;
-                               logger.info("WINDOW_X = " + xx + ", set to " + correction);
-                               xx = correction;
-                       } else {
-                               logger.info("WINDOW_X = " + xx);
-                       }
-
-                       skinProperties.setProperty(SkinPropertiesConstants.WINDOW_X, "" + xx);
                }
 
                if (skinProperties.containsKey(
                                SkinPropertiesConstants.WINDOW_Y) == true) {
                        String window_y = skinProperties.getProperty(SkinPropertiesConstants.WINDOW_Y);
-                       int yy = 0;
 
                        try {
-                               yy = Integer.parseInt(window_y);
+                               Integer.parseInt(window_y);
                        } catch (NumberFormatException e) {
                                String msg = SkinPropertiesConstants.WINDOW_Y +
                                                " in .skin.properties is not numeric. : " + window_y;
                                logger.warning(msg);
 
-                               yy = DEFAULT_WINDOW_Y;
-                       }
-
-                       /* location correction */
-                       if (yy < monitorBound.y) {
-                               int correction = monitorBound.y;
-                               logger.info("WINDOW_Y = " + yy + ", set to " + correction);
-                               yy = correction;
-                       } else if (yy > monitorBound.y + monitorBound.height - 30) {
-                               int correction = monitorBound.y + monitorBound.height - 100;
-                               logger.info("WINDOW_Y = " + yy + ", set to " + correction);
-                               yy = correction;
-                       } else {
-                               logger.info("WINDOW_Y = " + yy);
+                               skinProperties.remove(SkinPropertiesConstants.WINDOW_Y);
                        }
-
-                       skinProperties.setProperty(SkinPropertiesConstants.WINDOW_Y, "" + yy);
                }
 
                if (skinProperties.containsKey(
@@ -316,29 +283,39 @@ public class EmulatorConfig {
                                                " in .skin.properties is not numeric. : " + rotation;
                                logger.warning(msg);
 
-                               // TODO:
+                               skinProperties.remove(SkinPropertiesConstants.WINDOW_ROTATION);
                        }
                }
 
                if (skinProperties.containsKey(
                                SkinPropertiesConstants.WINDOW_SCALE) == true) {
                        String scale = skinProperties.getProperty(SkinPropertiesConstants.WINDOW_SCALE);
-                       int percent = 0;
 
                        try {
-                               percent = Integer.parseInt(scale);
+                               Integer.parseInt(scale);
                        } catch (NumberFormatException e) {
                                String msg = SkinPropertiesConstants.WINDOW_SCALE +
                                                " in .skin.properties is not numeric. : " + scale;
                                logger.warning(msg);
 
-                               percent = DEFAULT_WINDOW_SCALE;
+                               skinProperties.remove(SkinPropertiesConstants.WINDOW_SCALE);
                        }
-
-                       skinProperties.setProperty(SkinPropertiesConstants.WINDOW_SCALE, "" + percent);
                }
 
-               // TODO: WINDOW_ONTOP, KEYWINDOW_POSITION
+               if (skinProperties.containsKey(
+                               SkinPropertiesConstants.KEYWINDOW_POSITION) == true) {
+                       String position = skinProperties.getProperty(SkinPropertiesConstants.KEYWINDOW_POSITION);
+
+                       try {
+                               Integer.parseInt(position);
+                       } catch (NumberFormatException e) {
+                               String msg = SkinPropertiesConstants.KEYWINDOW_POSITION +
+                                               " in .skin.properties is not numeric. : " + position;
+                               logger.warning(msg);
+
+                               skinProperties.remove(SkinPropertiesConstants.KEYWINDOW_POSITION);
+                       }
+               }
        }
 
        public static void validateSkinConfigProperties(
@@ -525,6 +502,54 @@ public class EmulatorConfig {
                setProperty(skinProperties, key, value);
        }
 
+       public int getValidWindowX() {
+               int vmIndex = getArgInt(ArgsConstants.VM_BASE_PORT) % 100;
+               final int storedValue = getSkinPropertyInt(SkinPropertiesConstants.WINDOW_X,
+                               EmulatorConfig.DEFAULT_WINDOW_X + vmIndex);
+
+               Rectangle monitorBound = Display.getDefault().getBounds();
+               logger.info("current display size : " + monitorBound);
+
+               /* location correction */
+               int xx = 0;
+               if (storedValue < monitorBound.x) {
+                       xx = monitorBound.x;
+                       logger.info("WINDOW_X = " + storedValue + " -> " + xx);
+               } else if (storedValue > monitorBound.x + monitorBound.width - 30) {
+                       xx = monitorBound.x + monitorBound.width - 100;
+                       logger.info("WINDOW_X = " + storedValue + " -> " + xx);
+               } else {
+                       xx = storedValue;
+                       logger.info("WINDOW_X = " + xx);
+               }
+
+               return xx;
+       }
+
+       public int getValidWindowY() {
+               int vmIndex = getArgInt(ArgsConstants.VM_BASE_PORT) % 100;
+               final int storedValue = getSkinPropertyInt(SkinPropertiesConstants.WINDOW_Y,
+                               EmulatorConfig.DEFAULT_WINDOW_Y + vmIndex);
+
+               Rectangle monitorBound = Display.getDefault().getBounds();
+               logger.info("current display size : " + monitorBound);
+
+               /* location correction */
+               int yy = 0;
+               if (storedValue < monitorBound.y) {
+                       yy = monitorBound.y;
+                       logger.info("WINDOW_Y = " + storedValue + " -> " + yy);
+               } else if (storedValue > monitorBound.y + monitorBound.height - 30) {
+                       yy = monitorBound.y + monitorBound.height - 100;
+                       logger.info("WINDOW_Y = " + storedValue + " -> " + yy);
+               } else {
+                       yy = storedValue;
+                       logger.info("WINDOW_Y = " + yy);
+               }
+
+               return yy;
+       }
+
        public int getValidScale() {
                final int storedScale = getSkinPropertyInt(
                                SkinPropertiesConstants.WINDOW_SCALE, DEFAULT_WINDOW_SCALE);
index 3f130e9..4581ec9 100644 (file)
@@ -50,7 +50,6 @@ import org.tizen.emulator.skin.EmulatorSkin;
 import org.tizen.emulator.skin.EmulatorSkinMain;
 import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.config.EmulatorConfig;
-import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
 import org.tizen.emulator.skin.custom.ColorTag;
 import org.tizen.emulator.skin.custom.CustomButton;
@@ -118,13 +117,8 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
 
                displayCanvas = new Canvas(shell, style);
 
-               int vmIndex =
-                               config.getArgInt(ArgsConstants.VM_BASE_PORT) % 100;
-               int x = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_X,
-                               EmulatorConfig.DEFAULT_WINDOW_X + vmIndex);
-               int y = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_Y,
-                               EmulatorConfig.DEFAULT_WINDOW_Y + vmIndex);
-
+               int x = config.getValidWindowX();
+               int y = config.getValidWindowY();
                int scale = currentState.getCurrentScale();
                short rotationId = currentState.getCurrentRotationId();
 
index 16b86c1..b71aad6 100644 (file)
@@ -55,7 +55,6 @@ import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
 import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
 import org.tizen.emulator.skin.comm.sock.data.KeyEventData;
 import org.tizen.emulator.skin.config.EmulatorConfig;
-import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
 import org.tizen.emulator.skin.custom.CustomProgressBar;
 import org.tizen.emulator.skin.dbi.DisplayType;
@@ -111,13 +110,8 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
        public Canvas compose(int style) {
                lcdCanvas = new Canvas(shell, style);
 
-               int vmIndex =
-                               config.getArgInt(ArgsConstants.VM_BASE_PORT) % 100;
-               int x = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_X,
-                               EmulatorConfig.DEFAULT_WINDOW_X + vmIndex);
-               int y = config.getSkinPropertyInt(SkinPropertiesConstants.WINDOW_Y,
-                               EmulatorConfig.DEFAULT_WINDOW_Y + vmIndex);
-
+               int x = config.getValidWindowX();
+               int y = config.getValidWindowY();
                int scale = currentState.getCurrentScale();
                short rotationId = currentState.getCurrentRotationId();