From: GiWoong Kim Date: Tue, 19 Nov 2013 07:29:12 +0000 (+0900) Subject: menu: prepare for dynamic scale factor X-Git-Tag: TizenStudio_2.0_p2.3~457^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df120b82d996b40b739513cfe9ef77034ec8fa21;p=sdk%2Femulator%2Fqemu.git menu: prepare for dynamic scale factor The range of scale factor has to depend on their emulator resolution. Factors must be dynamic. Therefore, the scale factor should be treated as a number. Change-Id: I5851bbca08e1dde67c32908e8d3d7257b1293b82 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java index faee611..87b5554 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java @@ -69,7 +69,6 @@ import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType; import org.tizen.emulator.skin.comm.ICommunicator.MouseButtonType; import org.tizen.emulator.skin.comm.ICommunicator.MouseEventType; import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo; -import org.tizen.emulator.skin.comm.ICommunicator.Scale; import org.tizen.emulator.skin.comm.ICommunicator.SendCommand; import org.tizen.emulator.skin.comm.sock.SocketCommunicator; import org.tizen.emulator.skin.comm.sock.SocketCommunicator.DataTranfer; @@ -1355,30 +1354,26 @@ public class EmulatorSkin { } /* temp : swap rotation menu names */ - if (currentState.getCurrentResolutionWidth() > currentState - .getCurrentResolutionHeight()) { + if (currentState.getCurrentResolutionWidth() > + currentState.getCurrentResolutionHeight()) { for (MenuItem m : rotationList) { short rotationId = (Short) m.getData(); if (rotationId == RotationInfo.PORTRAIT.id()) { - String landscape = SkinRotation - .getRotation(RotationInfo.LANDSCAPE.id()).getName() - .value(); + String landscape = SkinRotation.getRotation( + RotationInfo.LANDSCAPE.id()).getName().value(); m.setText(landscape); } else if (rotationId == RotationInfo.LANDSCAPE.id()) { - String portrait = SkinRotation - .getRotation(RotationInfo.PORTRAIT.id()).getName() - .value(); + String portrait = SkinRotation.getRotation( + RotationInfo.PORTRAIT.id()).getName().value(); m.setText(portrait); } else if (rotationId == RotationInfo.REVERSE_PORTRAIT.id()) { - String landscapeReverse = SkinRotation - .getRotation(RotationInfo.REVERSE_LANDSCAPE.id()) - .getName().value(); + String landscapeReverse = SkinRotation.getRotation( + RotationInfo.REVERSE_LANDSCAPE.id()).getName().value(); m.setText(landscapeReverse); } else if (rotationId == RotationInfo.REVERSE_LANDSCAPE.id()) { - String portraitReverse = SkinRotation - .getRotation(RotationInfo.REVERSE_PORTRAIT.id()) - .getName().value(); + String portraitReverse = SkinRotation.getRotation( + RotationInfo.REVERSE_PORTRAIT.id()).getName().value(); m.setText(portraitReverse); } } @@ -1387,10 +1382,11 @@ public class EmulatorSkin { SelectionAdapter selectionAdapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + logger.info("Rotate menu is selected"); + MenuItem item = (MenuItem) e.getSource(); boolean selection = item.getSelection(); - if (!selection) { return; } @@ -1445,43 +1441,20 @@ public class EmulatorSkin { return menu; } - public Menu createScaleMenuListener() { - Menu menu = new Menu(shell, SWT.DROP_DOWN); - - final List scaleList = new ArrayList(); - - final MenuItem scaleOneItem = new MenuItem(menu, SWT.RADIO); - scaleOneItem.setText("1x"); - scaleOneItem.setData(Scale.SCALE_100); - scaleList.add(scaleOneItem); - - final MenuItem scaleThreeQtrItem = new MenuItem(menu, SWT.RADIO); - scaleThreeQtrItem.setText("3/4x"); - scaleThreeQtrItem.setData(Scale.SCALE_75); - scaleList.add(scaleThreeQtrItem); - - final MenuItem scalehalfItem = new MenuItem(menu, SWT.RADIO); - scalehalfItem.setText("1/2x"); - scalehalfItem.setData(Scale.SCALE_50); - scaleList.add(scalehalfItem); - - final MenuItem scaleOneQtrItem = new MenuItem(menu, SWT.RADIO); - scaleOneQtrItem.setText("1/4x"); - scaleOneQtrItem.setData(Scale.SCALE_25); - scaleList.add(scaleOneQtrItem); - - SelectionAdapter selectionAdapter = new SelectionAdapter() { + public SelectionAdapter createScaleMenuListener() { + SelectionAdapter listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + logger.info("Scale menu is selected"); + MenuItem item = (MenuItem) e.getSource(); boolean selection = item.getSelection(); - if (!selection) { return; } - final int scale = ((Scale) item.getData()).value(); + final int scale = (Integer)item.getData(); /* percentage */ shell.getDisplay().syncExec(new Runnable() { @Override @@ -1506,35 +1479,26 @@ public class EmulatorSkin { } }; - for (MenuItem menuItem : scaleList) { - int scale = ((Scale) menuItem.getData()).value(); - if (currentState.getCurrentScale() == scale) { - menuItem.setSelection(true); - } - - menuItem.addSelectionListener(selectionAdapter); - } - - return menu; + return listener; } public SelectionAdapter createKeyWindowMenuListener() { SelectionAdapter listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + logger.info("Key Window menu is selected"); + /* control the menu */ if (getKeyWindowKeeper().isGeneralKeyWindow() == false) { MenuItem layoutSelected = (MenuItem) e.widget; if (layoutSelected.getSelection() == true) { - for (MenuItem layout : layoutSelected.getParent() - .getItems()) { + for (MenuItem layout : layoutSelected.getParent().getItems()) { if (layout != layoutSelected) { /* uncheck other menu items */ layout.setSelection(false); } else { - int layoutIndex = getKeyWindowKeeper() - .getLayoutIndex(); + int layoutIndex = getKeyWindowKeeper().getLayoutIndex(); if (getKeyWindowKeeper().determineLayout() != layoutIndex) { /* switch */ getKeyWindowKeeper().closeKeyWindow(); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java index a69445d..db75567 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/ICommunicator.java @@ -1,5 +1,5 @@ /** - * + * Communication Interface Between Qemu And Skin * * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * @@ -37,23 +37,6 @@ import org.tizen.emulator.skin.dbi.RotationNameType; * */ public interface ICommunicator extends Runnable { - public enum Scale { - SCALE_25(25), - SCALE_50(50), - SCALE_75(75), - SCALE_100(100); - - private int value; - - Scale( int value ) { - this.value = value; - } - - public int value() { - return this.value; - } - } - public enum MouseButtonType { LEFT( (short)1 ), WHEEL( (short)2 ), diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java index cd36ab6..3f20dcc 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java @@ -43,7 +43,6 @@ import java.util.logging.Logger; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo; -import org.tizen.emulator.skin.comm.ICommunicator.Scale; import org.tizen.emulator.skin.dbi.EmulatorUI; import org.tizen.emulator.skin.exception.ConfigException; import org.tizen.emulator.skin.log.SkinLogger; @@ -64,7 +63,7 @@ public class EmulatorConfig { private static Logger logger = SkinLogger.getSkinLogger(EmulatorConfig.class).getLogger(); - public static final int DEFAULT_WINDOW_SCALE = Scale.SCALE_50.value(); + public static final int DEFAULT_WINDOW_SCALE = 50; 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; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java index 4426634..ea611aa 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/PopupMenu.java @@ -273,17 +273,59 @@ public class PopupMenu { scaleItem.setText(name); scaleItem.setImage(imageRegistry.getIcon(IconName.SCALE)); - Menu scaleSubMenu = skin.createScaleMenuListener(); + SelectionAdapter scaleListener = skin.createScaleMenuListener(); + + Menu scaleSubMenu = new Menu(menu.getShell(), SWT.DROP_DOWN); + { + MenuItem scaleOneItem = new MenuItem(scaleSubMenu, SWT.RADIO); + scaleOneItem.setText("1x"); + scaleOneItem.setData(100); + if (skin.getEmulatorSkinState().getCurrentScale() + == (Integer)scaleOneItem.getData()) { + scaleOneItem.setSelection(true); + } + scaleOneItem.addSelectionListener(scaleListener); + + MenuItem scaleThreeQtrItem = new MenuItem(scaleSubMenu, SWT.RADIO); + scaleThreeQtrItem.setText("3/4x"); + scaleThreeQtrItem.setData(75); + if (skin.getEmulatorSkinState().getCurrentScale() + == (Integer) scaleThreeQtrItem.getData()) { + scaleThreeQtrItem.setSelection(true); + } + scaleThreeQtrItem.addSelectionListener(scaleListener); + + MenuItem scalehalfItem = new MenuItem(scaleSubMenu, SWT.RADIO); + scalehalfItem.setText("1/2x"); + scalehalfItem.setData(50); + if (skin.getEmulatorSkinState().getCurrentScale() + == (Integer) scalehalfItem.getData()) { + scalehalfItem.setSelection(true); + } + scalehalfItem.addSelectionListener(scaleListener); + + MenuItem scaleOneQtrItem = new MenuItem(scaleSubMenu, SWT.RADIO); + scaleOneQtrItem.setText("1/4x"); + scaleOneQtrItem.setData(25); + if (skin.getEmulatorSkinState().getCurrentScale() + == (Integer) scaleOneQtrItem.getData()) { + scaleOneQtrItem.setSelection(true); + } + scaleOneQtrItem.addSelectionListener(scaleListener); + } + scaleItem.setMenu(scaleSubMenu); } private void createKeyWindowItem(Menu menu, String name) { /* load Key Window layout */ + SelectionAdapter keyWindowListener = skin.createKeyWindowMenuListener(); + String pathLayoutRoot = skin.skinInfo.getSkinPath() + File.separator + SpecialKeyWindow.KEYWINDOW_LAYOUT_ROOT; ArrayList layouts = getKeyWindowLayoutList(pathLayoutRoot); - if (layouts != null) { + if (layouts != null && layouts.size() != 0) { keyWindowItem = new MenuItem(menu, SWT.CASCADE); keyWindowItem.setText(name); @@ -300,17 +342,17 @@ public class PopupMenu { keywindowLayoutItem.setSelection(true); } - keywindowLayoutItem.addSelectionListener( - skin.createKeyWindowMenuListener()); + keywindowLayoutItem.addSelectionListener(keyWindowListener); } } + keyWindowItem.setMenu(keywindowSubMenu); } else { /* general key window */ keyWindowItem = new MenuItem(menu, SWT.CHECK); keyWindowItem.setText(name); keyWindowItem.setSelection(skin.isKeyWindow); - keyWindowItem.addSelectionListener(skin.createKeyWindowMenuListener()); + keyWindowItem.addSelectionListener(keyWindowListener); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java index 6837b6b..28c505a 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java @@ -47,7 +47,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo; -import org.tizen.emulator.skin.comm.ICommunicator.Scale; import org.tizen.emulator.skin.config.EmulatorConfig; import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants; import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants; @@ -70,7 +69,11 @@ public class SkinUtil { 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"; private static Logger logger = @@ -311,10 +314,8 @@ public class SkinUtil { } public static boolean isValidScale(int scale) { - if (Scale.SCALE_100.value() == scale - || Scale.SCALE_75.value() == scale - || Scale.SCALE_50.value() == scale - || Scale.SCALE_25.value() == scale) { + if (scale >= MIN_SCALE_FACTOR && + scale <= MAX_SCALE_FACTOR) { /* percentage */ return true; } else { return false;