imageRegistry = ImageRegistry.getInstance();
/* set emulator states */
- currentState.setCurrentResolutionWidth(
- config.getArgInt(ArgsConstants.RESOLUTION_WIDTH));
- currentState.setCurrentResolutionHeight(
- config.getArgInt(ArgsConstants.RESOLUTION_HEIGHT));
+ currentState.setCurrentResolutionWidth(config.getValidResolutionWidth());
+ currentState.setCurrentResolutionHeight(config.getValidResolutionHeight());
- int scale = SkinUtil.getValidScale(config);
- currentState.setCurrentScale(scale);
+ currentState.setCurrentScale(config.getValidScale());
short rotationId = EmulatorConfig.DEFAULT_WINDOW_ROTATION;
currentState.setCurrentRotationId(rotationId);
public static final String INVALID_OPTION_MESSAGE =
"An invalid option have caused the error.\n";
- private static Logger logger =
- SkinLogger.getSkinLogger(EmulatorConfig.class).getLogger();
-
public static final int DEFAULT_WINDOW_SCALE = 50;
+ public static final int MIN_SCALE_FACTOR = 25;
+ public static final int MAX_SCALE_FACTOR = 200;
public static final short DEFAULT_WINDOW_ROTATION = RotationInfo.PORTRAIT.id();
public static final int DEFAULT_WINDOW_X = 50;
public static final int DEFAULT_WINDOW_Y = 50;
public static final SkinLogLevel DEFAULT_LOG_LEVEL = SkinLogLevel.DEBUG;
+ private static Logger logger =
+ SkinLogger.getSkinLogger(EmulatorConfig.class).getLogger();
+
public interface ArgsConstants {
public static final String SIMPLE_MESSAGE = "simple.msg";
public static final String UID = "uid";
if (skinProperties.containsKey(
SkinPropertiesConstants.WINDOW_X) == true) {
- String x = skinProperties.getProperty(SkinPropertiesConstants.WINDOW_X);
+ String window_x = skinProperties.getProperty(SkinPropertiesConstants.WINDOW_X);
int xx = 0;
try {
- xx = Integer.parseInt(x);
+ xx = Integer.parseInt(window_x);
} catch (NumberFormatException e) {
String msg = SkinPropertiesConstants.WINDOW_X +
- " in .skin.properties is not numeric : " + x;
+ " in .skin.properties is not numeric : " + window_x;
logger.warning(msg);
xx = DEFAULT_WINDOW_X;
if (skinProperties.containsKey(
SkinPropertiesConstants.WINDOW_Y) == true) {
- String y = skinProperties.getProperty(SkinPropertiesConstants.WINDOW_Y);
+ String window_y = skinProperties.getProperty(SkinPropertiesConstants.WINDOW_Y);
int yy = 0;
try {
- yy = Integer.parseInt(y);
+ yy = Integer.parseInt(window_y);
} catch (NumberFormatException e) {
String msg = SkinPropertiesConstants.WINDOW_Y +
- " in .skin.properties is not numeric. : " + y;
+ " in .skin.properties is not numeric. : " + window_y;
logger.warning(msg);
yy = DEFAULT_WINDOW_Y;
skinProperties.setProperty(SkinPropertiesConstants.WINDOW_SCALE, "" + percent);
}
+
+ // TODO: WINDOW_ONTOP, KEYWINDOW_POSITION
}
public static void validateSkinConfigProperties(
return;
}
- // TODO:
+ // TODO: HEART_BEAT_IGNORE, LOG_LEVEL
}
public void saveSkinProperties() {
return Boolean.parseBoolean(arg);
}
+ public int getValidResolutionWidth() {
+ return getArgInt(ArgsConstants.RESOLUTION_WIDTH);
+ }
+
+ public int getValidResolutionHeight() {
+ return getArgInt(ArgsConstants.RESOLUTION_HEIGHT);
+ }
+
/* java properties */
private void setProperty(Properties properties, String key, String value) {
properties.put(key, value);
setProperty(skinProperties, key, value);
}
+ public int getValidScale() {
+ int storedScale = getSkinPropertyInt(
+ SkinPropertiesConstants.WINDOW_SCALE, DEFAULT_WINDOW_SCALE);
+
+ if (storedScale >= MIN_SCALE_FACTOR &&
+ storedScale <= MAX_SCALE_FACTOR) { /* percentage */
+ return storedScale;
+ } else {
+ return DEFAULT_WINDOW_SCALE;
+ }
+ }
+
/* config properties */
public String getConfigProperty(String key) {
return getProperty(configProperties, key);
scaleItem.setText(name);
scaleItem.setImage(imageRegistry.getIcon(IconName.SCALE));
- SelectionAdapter scaleListener = skin.createScaleMenuListener();
+ if (factors == null) {
+ /* use default factor array */
+ ScaleItemType.FactorItem actual = new ScaleItemType.FactorItem();
+ actual.setItemName("1x");
+ actual.setValue(100);
- Menu scaleSubMenu = new Menu(menu.getShell(), SWT.DROP_DOWN);
- {
- if (factors == null) {
- /* use default factor array */
- ScaleItemType.FactorItem actual = new ScaleItemType.FactorItem();
- actual.setItemName("1x");
- actual.setValue(100);
+ ScaleItemType.FactorItem threeQuater = new ScaleItemType.FactorItem();
+ threeQuater.setItemName("3/4x");
+ threeQuater.setValue(75);
- ScaleItemType.FactorItem threeQuater = new ScaleItemType.FactorItem();
- threeQuater.setItemName("3/4x");
- threeQuater.setValue(75);
+ ScaleItemType.FactorItem half = new ScaleItemType.FactorItem();
+ half.setItemName("1/2x");
+ half.setValue(50);
- ScaleItemType.FactorItem half = new ScaleItemType.FactorItem();
- half.setItemName("1/2x");
- half.setValue(50);
+ ScaleItemType.FactorItem quater = new ScaleItemType.FactorItem();
+ quater.setItemName("1/4x");
+ quater.setValue(25);
- ScaleItemType.FactorItem quater = new ScaleItemType.FactorItem();
- quater.setItemName("1/4x");
- quater.setValue(25);
+ factors = Arrays.asList(actual, threeQuater, half, quater);
+ }
- factors = Arrays.asList(actual, threeQuater, half, quater);
- }
+ SelectionAdapter scaleListener = skin.createScaleMenuListener();
+
+ Menu scaleSubMenu = new Menu(menu.getShell(), SWT.DROP_DOWN);
+ {
+ MenuItem matchedItem = null;
for (ScaleItemType.FactorItem factor : factors) {
final MenuItem menuItem = new MenuItem(scaleSubMenu, SWT.RADIO);
if (skin.getEmulatorSkinState().getCurrentScale()
== (Integer) menuItem.getData()) {
- menuItem.setSelection(true);
+ matchedItem = menuItem;
}
menuItem.addSelectionListener(scaleListener);
}
+
+ if (matchedItem == null) {
+ matchedItem = scaleSubMenu.getItem(0);
+ skin.getEmulatorSkinState().setCurrentScale(
+ (Integer) matchedItem.getData());
+ }
+
+ matchedItem.setSelection(true);
}
scaleItem.setMenu(scaleSubMenu);
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.dbi.EventInfoType;
import org.tizen.emulator.skin.dbi.KeyMapListType;
import org.tizen.emulator.skin.dbi.KeyMapType;
public static final String COCOA_OS_CLASS = "org.eclipse.swt.internal.cocoa.OS";
public static final int UNKNOWN_KEYCODE = -1;
-
- public static final int MIN_SCALE_FACTOR = 25;
- public static final int MAX_SCALE_FACTOR = 200;
public static final int SCALE_CONVERTER = 100;
public static final String EMULATOR_PREFIX = "Emulator";
return (float) scale / SCALE_CONVERTER;
}
- public static int getValidScale(EmulatorConfig config) {
- int storedScale = config.getSkinPropertyInt(
- SkinPropertiesConstants.WINDOW_SCALE, EmulatorConfig.DEFAULT_WINDOW_SCALE);
-
- if (!SkinUtil.isValidScale(storedScale)) {
- return EmulatorConfig.DEFAULT_WINDOW_SCALE;
- } else {
- return storedScale;
- }
- }
-
- public static boolean isValidScale(int scale) {
- if (scale >= MIN_SCALE_FACTOR &&
- scale <= MAX_SCALE_FACTOR) { /* percentage */
- return true;
- } else {
- return false;
- }
- }
-
public static <T> int openMessage(Shell shell,
String title, String message, int style, EmulatorConfig config) {
MessageBox messageBox = new MessageBox(shell, style);