From 46819c2490b6d8d0da2918530c24e5026ce6f255 Mon Sep 17 00:00:00 2001 From: "minkee.lee" Date: Wed, 13 May 2015 18:41:14 +0900 Subject: [PATCH] VMButton: Changed VMButton - Added custom VMButton. - Added skin shape factor for VMButton. Change-Id: Ibb3e36865590ce22ff2d88300bf661ccccece2ae Signed-off-by: minkee.lee --- .../manager/plugin/PluginImageResources.java | 13 +++++++- .../emulator/manager/ui/list/VMButtonFactory.java | 5 +-- .../manager/ui/widgets/IVMButtonPainter.java | 38 ++++++++++++++++++++++ .../emulator/manager/ui/widgets/VMButton.java | 35 +++++++++++++++----- .../manager/ui/widgets/VMCreateButton.java | 2 +- 5 files changed, 81 insertions(+), 12 deletions(-) create mode 100644 common-project/src/org/tizen/emulator/manager/ui/widgets/IVMButtonPainter.java diff --git a/common-project/src/org/tizen/emulator/manager/plugin/PluginImageResources.java b/common-project/src/org/tizen/emulator/manager/plugin/PluginImageResources.java index 1c391ac..ae81d15 100644 --- a/common-project/src/org/tizen/emulator/manager/plugin/PluginImageResources.java +++ b/common-project/src/org/tizen/emulator/manager/plugin/PluginImageResources.java @@ -56,7 +56,10 @@ public enum PluginImageResources { BUTTON_LAUNCH_DISABLE("button_launch_dis"), BUTTON_LAUNCH_NOMAL("button_launch_nml"), BUTTON_LAUNCH_HOVER("button_launch_hover"), - BUTTON_LAUNCH_PUSH("button_launch_pushed"); + BUTTON_LAUNCH_PUSH("button_launch_pushed"), + + VM_IMAGE_CUSTOM_HOVER("emulator_list_custom_image_hover"), + VM_IMAGE_CUSTOM_NORMAL("emulator_list_custom_image_nml"); String name; Map image; @@ -74,6 +77,14 @@ public enum PluginImageResources { this.frames = new HashMap(); } + public Image getImage(String platformName, String shape) { + String group = platformName; + if (shape != null && !shape.isEmpty()) { + group += "-" + shape; + } + return getImage(group); + } + // TODO public Image getImage(String platformName) { Image i = image.get(platformName); diff --git a/common-project/src/org/tizen/emulator/manager/ui/list/VMButtonFactory.java b/common-project/src/org/tizen/emulator/manager/ui/list/VMButtonFactory.java index 0736e4a..bdde3a7 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/list/VMButtonFactory.java +++ b/common-project/src/org/tizen/emulator/manager/ui/list/VMButtonFactory.java @@ -40,13 +40,14 @@ import org.eclipse.swt.widgets.Composite; import org.tizen.emulator.manager.platform.BaseImage; import org.tizen.emulator.manager.ui.widgets.VMButton; import org.tizen.emulator.manager.ui.widgets.VMCreateButton; +import org.tizen.emulator.manager.vms.VMProperty; public class VMButtonFactory { private static ArrayList buttons = new ArrayList (); private static int selectedIndex = 0; - public static VMButton getButton(Composite parent, BaseImage base) { - VMButton b = new VMButton(parent, SWT.NONE, base); + public static VMButton getButton(Composite parent, BaseImage base, VMProperty property) { + VMButton b = new VMButton(parent, SWT.NONE, base, property); b.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { diff --git a/common-project/src/org/tizen/emulator/manager/ui/widgets/IVMButtonPainter.java b/common-project/src/org/tizen/emulator/manager/ui/widgets/IVMButtonPainter.java new file mode 100644 index 0000000..1903260 --- /dev/null +++ b/common-project/src/org/tizen/emulator/manager/ui/widgets/IVMButtonPainter.java @@ -0,0 +1,38 @@ +/* Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Minkee Lee + * JiHye Kim + * SeokYeon Hwang + * Sangho Park + * + * 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.manager.ui.widgets; + +public interface IVMButtonPainter { + + // Offset in VMButton. + public int getLaunchButtonBottomOffset(); + public int getLaunchButtonLeftOffset(); +} diff --git a/common-project/src/org/tizen/emulator/manager/ui/widgets/VMButton.java b/common-project/src/org/tizen/emulator/manager/ui/widgets/VMButton.java index 1ed8f04..8d28be8 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/widgets/VMButton.java +++ b/common-project/src/org/tizen/emulator/manager/ui/widgets/VMButton.java @@ -51,6 +51,7 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.platform.BaseImage; +import org.tizen.emulator.manager.platform.Skin; import org.tizen.emulator.manager.plugin.ExtensionItem; import org.tizen.emulator.manager.plugin.PluginImageResources; import org.tizen.emulator.manager.plugin.PluginStringResources; @@ -59,6 +60,7 @@ import org.tizen.emulator.manager.resources.FontResources; import org.tizen.emulator.manager.ui.MainDialog; import org.tizen.emulator.manager.ui.VMsMainView; import org.tizen.emulator.manager.ui.list.VMButtonFactory; +import org.tizen.emulator.manager.vms.SKIN_SHAPE; import org.tizen.emulator.manager.vms.VMProperty; import org.tizen.emulator.manager.vms.helper.CheckingRunningEmulator; import org.tizen.emulator.manager.vms.helper.HelperClass; @@ -75,9 +77,13 @@ public class VMButton extends ImageButton { private int LAUNCH_BUTTON_WIDTH = 40; private int LAUNCH_BUTTON_HEIGHT =14; - public VMButton(Composite parent, int style, BaseImage base) { + private int launchButtonLeftOffset; + private int launchButtonBottomOffset; + + public VMButton(Composite parent, int style, BaseImage base, VMProperty property) { super(parent, style); this.baseImage = base; + this.property = property; button = this; this.setLayout(new FormLayout()); @@ -87,10 +93,15 @@ public class VMButton extends ImageButton { item = base.getPlatform().getPlugin() .getExtensionItem(PluginStringResources.VMButtonPainter); } + if (item != null) { this.setPainListener((PaintListener)item.createClass()); + launchButtonLeftOffset = ((IVMButtonPainter)item.createClass()).getLaunchButtonLeftOffset(); + launchButtonBottomOffset = ((IVMButtonPainter)item.createClass()).getLaunchButtonBottomOffset(); } else { this.setPainListener(VMButtonPaintListener); + launchButtonLeftOffset = 13; + launchButtonBottomOffset = 13; } settingImage(); @@ -100,15 +111,23 @@ public class VMButton extends ImageButton { } private void settingImage() { + String shape=""; + if (button.getProperty() != null) { + Skin skin = button.getProperty().getPropertyValue().skin; + if (skin != null && skin.getSkinShape() == SKIN_SHAPE.CIRCLE) { + shape = skin.getSkinShape().toString(); + } + } + for (WSTATE s : WSTATE.values()) { - images.add(s.getId(), PluginImageResources.VM_IMAGE_NOMAL.getImage(baseImage.getPlatform().getPluginPlatformName())); + images.add(s.getId(), PluginImageResources.VM_IMAGE_NOMAL.getImage(baseImage.getPlatform().getPluginPlatformName(), shape)); } BUTTON_WIDTH = images.get(0).getImageData().width; BUTTON_HEIGHT = images.get(0).getImageData().height; - images.set(WSTATE.HOVER.getId(), PluginImageResources.VM_IMAGE_HOVER.getImage(baseImage.getPlatform().getPluginPlatformName())); - images.set(WSTATE.SELECTED_HOVER.getId(), PluginImageResources.VM_IMAGE_HOVER.getImage(baseImage.getPlatform().getPluginPlatformName())); + images.set(WSTATE.HOVER.getId(), PluginImageResources.VM_IMAGE_HOVER.getImage(baseImage.getPlatform().getPluginPlatformName(), shape)); + images.set(WSTATE.SELECTED_HOVER.getId(), PluginImageResources.VM_IMAGE_HOVER.getImage(baseImage.getPlatform().getPluginPlatformName(), shape)); } @Override @@ -146,8 +165,8 @@ public class VMButton extends ImageButton { FormData data = new FormData(); //data.top = new FormAttachment(0, 119 + H_OFFSET); - data.bottom = new FormAttachment(100, -10 - 3); - data.left = new FormAttachment(0, 10 + 3); + data.bottom = new FormAttachment(100, - launchButtonBottomOffset); + data.left = new FormAttachment(0, + launchButtonLeftOffset); data.width = LAUNCH_BUTTON_WIDTH; data.height = LAUNCH_BUTTON_HEIGHT; @@ -200,12 +219,12 @@ public class VMButton extends ImageButton { } } - public void setProperty(VMProperty property) { - this.property = property; + public void setProperty() { this.setToolTipText(property.getName()); settingTitleWidth(); } + public VMProperty getProperty() { return property; } diff --git a/common-project/src/org/tizen/emulator/manager/ui/widgets/VMCreateButton.java b/common-project/src/org/tizen/emulator/manager/ui/widgets/VMCreateButton.java index c5a0962..50428d7 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/widgets/VMCreateButton.java +++ b/common-project/src/org/tizen/emulator/manager/ui/widgets/VMCreateButton.java @@ -19,7 +19,7 @@ public class VMCreateButton extends VMButton { private VMCreateButton button; public VMCreateButton(Composite parent, int style, BaseImage base) { - super(parent, style, base); + super(parent, style, base, null); // delete launchButton launchButton.dispose(); launchButton = null; -- 2.7.4