From: jihye Date: Tue, 4 Jun 2013 11:50:44 +0000 (+0900) Subject: [Title] emulator-manager : add custom radio button X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dbfc4cb9003da7307fbf7a26f8a802bbb1671744;p=sdk%2Femulator%2Femulator-manager.git [Title] emulator-manager : add custom radio button [Desc.] add custom radio button and resize scrollbar's width [Issue] N/A Change-Id: I96b7309f8cf017e997fed0cadbd3a597c1ad2b32 Signed-off-by: jihye --- diff --git a/resource/res/radio_off.png b/resource/res/radio_off.png new file mode 100644 index 0000000..16e45c1 Binary files /dev/null and b/resource/res/radio_off.png differ diff --git a/resource/res/radio_on.png b/resource/res/radio_on.png new file mode 100644 index 0000000..946ced5 Binary files /dev/null and b/resource/res/radio_on.png differ diff --git a/src/org/tizen/emulator/manager/resources/ImageResources.java b/src/org/tizen/emulator/manager/resources/ImageResources.java index 82563a0..ffef529 100644 --- a/src/org/tizen/emulator/manager/resources/ImageResources.java +++ b/src/org/tizen/emulator/manager/resources/ImageResources.java @@ -65,7 +65,9 @@ public enum ImageResources { COMBO_DISABLE("dropdown_disable", ImageType.PNG), COMBO_DROPDOWN_UP("dropdown_up", ImageType.PNG), COMBO_DROPDOWN_DOWN("dropdown_down", ImageType.PNG), - + RADIO_OFF("radio_off", ImageType.PNG), + RADIO_ON("radio_on", ImageType.PNG), + // GIF TYPE TAB_SELECTED_LEFT("tab_selected_left"), TAB_SELECTED_MIDDLE("tab_selected_middle"), diff --git a/src/org/tizen/emulator/manager/ui/VMsListView.java b/src/org/tizen/emulator/manager/ui/VMsListView.java index b11dce9..33e204f 100644 --- a/src/org/tizen/emulator/manager/ui/VMsListView.java +++ b/src/org/tizen/emulator/manager/ui/VMsListView.java @@ -37,7 +37,6 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.tizen.emulator.manager.platform.BaseImage; import org.tizen.emulator.manager.platform.Platform; @@ -48,6 +47,7 @@ import org.tizen.emulator.manager.ui.list.AbstractListView; import org.tizen.emulator.manager.ui.list.ExtendTreeListView; import org.tizen.emulator.manager.ui.list.ItemListVew; import org.tizen.emulator.manager.ui.list.TreeListView; +import org.tizen.emulator.manager.ui.widgets.ImageButton; import org.tizen.emulator.manager.ui.widgets.ImageCombo; public class VMsListView { @@ -92,8 +92,8 @@ public class VMsListView { } private ImageCombo imageCombo = null; - private Button itemButton = null; - private Button treeButton = null; + private ImageButton itemButton = null; + private ImageButton treeButton = null; public void init(int width, int height) { mainView = new Composite(parent, SWT.NONE); @@ -118,13 +118,13 @@ public class VMsListView { imageCombo.setLayoutData(data); data = new FormData(); - data.top = new FormAttachment(0, 10); - data.right = new FormAttachment(100, -10); + data.top = new FormAttachment(0, 14); + data.right = new FormAttachment(100, -8); treeButton.setLayoutData(data); data = new FormData(); - data.top = new FormAttachment(0, 10); - data.right = new FormAttachment(treeButton, -10); + data.top = new FormAttachment(0, 14); + data.right = new FormAttachment(treeButton, -8); itemButton.setLayoutData(data); data = new FormData(); @@ -146,8 +146,7 @@ public class VMsListView { boolean isTreeViewSelect = false; private void makeRadioButton() { - itemButton = new Button(mainView, SWT.RADIO); - // TODO + itemButton = new ImageButton(mainView, SWT.RADIO); itemButton.setText("item"); itemButton.setBackground(ColorResources.TAB_CONTENTS_BG_COLOR.getColor()); itemButton.setFont(FontResources.RADIO_BUTTON_FONT.getFont()); @@ -155,7 +154,7 @@ public class VMsListView { @Override public void widgetSelected(SelectionEvent e) { - if (itemButton.getSelection() && isTreeViewSelect) { + if (itemButton.isSelection() && isTreeViewSelect) { selectRadioButton(false); VMsMainView.getInstance().drawVMList(VMsMainView.getInstance().getCurrentImage()); } @@ -166,7 +165,7 @@ public class VMsListView { } }); - treeButton = new Button(mainView, SWT.RADIO); + treeButton = new ImageButton(mainView, SWT.RADIO); treeButton.setText("tree"); treeButton.setBackground(ColorResources.TAB_CONTENTS_BG_COLOR.getColor()); treeButton.setFont(FontResources.RADIO_BUTTON_FONT.getFont()); @@ -174,7 +173,7 @@ public class VMsListView { @Override public void widgetSelected(SelectionEvent e) { - if (treeButton.getSelection() && !isTreeViewSelect) { + if (treeButton.isSelection() && !isTreeViewSelect) { selectRadioButton(true); VMsMainView.getInstance().drawVMList(VMsMainView.getInstance().getCurrentImage()); } @@ -234,16 +233,16 @@ public class VMsListView { public void drawPlatform(Platform platform, int imageIndex, boolean isRefresh) { if (platform instanceof TotalPlatform) { if (!isRefresh) { - selectRadioButton(true); itemButton.setEnabled(false); + selectRadioButton(true); } imageCombo.removeAll(); imageCombo.setEnabled(false); imageCombo.layout(); } else { if (!isRefresh) { - selectRadioButton(false); itemButton.setEnabled(true); + selectRadioButton(false); } if (!platform.getImageList().isEmpty()) { @@ -289,6 +288,8 @@ public class VMsListView { } public void close() { + itemButton.dispose(); + treeButton.dispose(); imageCombo.dispose(); imageListView.close(); treeListView.close(); diff --git a/src/org/tizen/emulator/manager/ui/VMsMainView.java b/src/org/tizen/emulator/manager/ui/VMsMainView.java index 72ee088..b9b867d 100644 --- a/src/org/tizen/emulator/manager/ui/VMsMainView.java +++ b/src/org/tizen/emulator/manager/ui/VMsMainView.java @@ -217,8 +217,8 @@ public class VMsMainView { } public void drawEmptyVMList() { - listView.drawEmptyVMList(); detailView.drawEmptyVM(); + listView.drawEmptyVMList(); } public void drawEmptyDetailVM() { @@ -297,8 +297,8 @@ public class VMsMainView { isCreateMode = false; if (currentImage.getVmsList().isEmpty()) { - listView.cancelModify(-1); drawEmptyVMList(); + listView.cancelModify(-1); } else { if (currentProperty != null) { int i = currentImage.getVmsList().indexOf(currentProperty); diff --git a/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java b/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java index 4d9d84d..fbb3243 100644 --- a/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java +++ b/src/org/tizen/emulator/manager/ui/detail/DetailViewItem.java @@ -277,14 +277,14 @@ public abstract class DetailViewItem { data.right = new FormAttachment(100, 0); data.height =ImageResources.DETAIL_LIST_ITEM.getImage().getImageData().height; compList.get(0).setLayoutData(data); - compList.get(0).getParent().layout(true, true); + compList.get(0).getParent().layout(true, false); */ isMinMode = true; for (int i = 1; i < count; i++) { FormData data = new FormData(); data.height = 0; compList.get(i).setLayoutData(data); - compList.get(i).getParent().layout(true, true); + compList.get(i).getParent().layout(true, false); } if (downItem != null) { @@ -300,7 +300,7 @@ public abstract class DetailViewItem { data.right = new FormAttachment(100, 0); data.height =ImageResources.DETAIL_LIST_ITEM.getImage().getImageData().height * count; compList.get(0).setLayoutData(data); - compList.get(0).getParent().layout(true, true); + compList.get(0).getParent().layout(true, false); */ isMinMode = false; for (int i = 1; i < count; i++) { @@ -311,7 +311,7 @@ public abstract class DetailViewItem { data.width = ITEM_WIDTH; data.height = ITEM_HEIGHT; compList.get(i).setLayoutData(data); - compList.get(i).getParent().layout(true, true); + compList.get(i).getParent().layout(true, false); } if (downItem != null) { downItem.changeUpComposite(compList.get(count-1)); diff --git a/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java b/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java index 960c10e..75554f3 100644 --- a/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java +++ b/src/org/tizen/emulator/manager/ui/detail/DetailViewPage.java @@ -186,6 +186,8 @@ public abstract class DetailViewPage { scrolledList.setSize(data.width, data.height); scrolledList.setLayoutData(data); itemList.setSize(image3.getImageData().width, image3.getImageData().height); + + itemListBack.layout(true, false); } public void resize(int height) { diff --git a/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java b/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java index 9c0b8f7..17938f5 100644 --- a/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java +++ b/src/org/tizen/emulator/manager/ui/detail/PEmptyViewPage.java @@ -56,7 +56,6 @@ public class PEmptyViewPage extends DetailViewPage { int h = (int)FontResources.DETAIL_LABEL_FONT.getFont().getFontData()[0].getHeight(); FormData data = new FormData(); - // TODO data.left = new FormAttachment(50, -(5 * NO_ITEM.length() / 2)); data.top = new FormAttachment(50, -((h * 2) / 2)); title.setLayoutData(data); diff --git a/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java b/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java index 269c15c..ecd6708 100644 --- a/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java +++ b/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java @@ -82,7 +82,7 @@ public class PInfoViewPage extends DetailViewPage { private ArrayList list; private void makeDetailView() { - list =DetailItemList.getItemList(); + list = DetailItemList.getItemList(); DetailViewItem item = null; DetailViewItem up = null; for (int i = 0; i < list.size(); i++) { diff --git a/src/org/tizen/emulator/manager/ui/list/ExtendTreeListView.java b/src/org/tizen/emulator/manager/ui/list/ExtendTreeListView.java index 67f8134..12750d2 100644 --- a/src/org/tizen/emulator/manager/ui/list/ExtendTreeListView.java +++ b/src/org/tizen/emulator/manager/ui/list/ExtendTreeListView.java @@ -72,7 +72,6 @@ public class ExtendTreeListView extends AbstractListView { vmsTree.setLinesVisible(true); vmsTree.setBackground(ColorResources.WHITE.getColor()); - // TODO vmsTree.setFont(FontResources.TREE_HEADER_FONT.getFont()); for(ColumnContentHelper helper : ColumnContentHelper.getContentHelpers()) { @@ -101,7 +100,7 @@ public class ExtendTreeListView extends AbstractListView { if(!(data instanceof RowItem)) { return; } - + // TODO : select template using platform if (data instanceof CreateMarker) { VMsMainView.getInstance().drawCreateVM( @@ -340,10 +339,14 @@ public class ExtendTreeListView extends AbstractListView { public void setSelectProperty() { vmsTree.forceFocus(); - if (currentItem != null) { - vmsTree.setSelection(currentItem); - } else { - vmsTree.setSelection(vmsTree.getItem(0)); + if (currentItem == null) { + currentItem = vmsTree.getItem(0); + } + vmsTree.setSelection(currentItem); + + if(currentItem.getData() instanceof TreeMarker) { + VMsMainView.getInstance().drawEmptyDetailVM(); + VMsMainView.getInstance().setCurrentProperty(null); } } } diff --git a/src/org/tizen/emulator/manager/ui/list/TreeListView.java b/src/org/tizen/emulator/manager/ui/list/TreeListView.java index 69f0864..0b4c410 100644 --- a/src/org/tizen/emulator/manager/ui/list/TreeListView.java +++ b/src/org/tizen/emulator/manager/ui/list/TreeListView.java @@ -30,8 +30,6 @@ package org.tizen.emulator.manager.ui.list; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.SelectionEvent; @@ -65,7 +63,6 @@ public class TreeListView extends AbstractListView { vmsTree.setLinesVisible(true); vmsTree.setBackground(ColorResources.WHITE.getColor()); - // TODO vmsTree.setFont(FontResources.TREE_HEADER_FONT.getFont()); for(ColumnContentHelper helper : ColumnContentHelper.getContentHelpers()) { @@ -83,6 +80,7 @@ public class TreeListView extends AbstractListView { protected PropertyContent currentProp = null; private void settingListener() { + /* vmsTree.addFocusListener(new FocusListener() { @Override @@ -97,6 +95,7 @@ public class TreeListView extends AbstractListView { } }); + */ vmsTree.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { diff --git a/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java index c33f01b..d949510 100644 --- a/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java +++ b/src/org/tizen/emulator/manager/ui/tabfolder/PlatformTabFolder.java @@ -209,7 +209,7 @@ public class PlatformTabFolder { b.redraw(); // draw main view using selected platform items.get(i).draw(); - contentsComposite.layout(true, true); + contentsComposite.layout(true, false); } else { b.setSelection(false); b.redraw(); diff --git a/src/org/tizen/emulator/manager/ui/widgets/CustomScrollBar.java b/src/org/tizen/emulator/manager/ui/widgets/CustomScrollBar.java index d940410..3ba1e87 100644 --- a/src/org/tizen/emulator/manager/ui/widgets/CustomScrollBar.java +++ b/src/org/tizen/emulator/manager/ui/widgets/CustomScrollBar.java @@ -78,7 +78,7 @@ public class CustomScrollBar extends Canvas implements PaintListener, MouseWheel private Color thumbColor; private Color thumbClickedColor; - public final static int SCROLLBAR_WIDTH = 5; + public final static int SCROLLBAR_WIDTH = 4; public CustomScrollBar(CustomScrolledComposite parent) { super(parent, SWT.DOUBLE_BUFFERED); @@ -428,7 +428,7 @@ public class CustomScrollBar extends Canvas implements PaintListener, MouseWheel //thumb.height = screenThumb; g.setBackground(thumbColor); g.setFillRule(SWT.FILL_WINDING); - g.fillRoundRectangle(thumb.x, thumb.y, thumb.width, thumb.height, 6, 6); + g.fillRoundRectangle(thumb.x, thumb.y, thumb.width, thumb.height, 5, 5); } } } diff --git a/src/org/tizen/emulator/manager/ui/widgets/CustomScrolledComposite.java b/src/org/tizen/emulator/manager/ui/widgets/CustomScrolledComposite.java index 0b49da3..c6bd682 100644 --- a/src/org/tizen/emulator/manager/ui/widgets/CustomScrolledComposite.java +++ b/src/org/tizen/emulator/manager/ui/widgets/CustomScrolledComposite.java @@ -73,7 +73,7 @@ public class CustomScrolledComposite extends Composite { data.top = new FormAttachment(0, 2); data.bottom = new FormAttachment(100, -2); data.right = new FormAttachment(100, -2); - data.width = 7; + data.width = 6; verticalBar.setLayoutData(data); verticalBar.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor()); @@ -115,7 +115,6 @@ public class CustomScrolledComposite extends Composite { return; } - //layout(true, true); if (needVScroll(content.getBounds(), false)) { verticalBar.setVisible(true); verticalBar.setScrollSize(content.getBounds().height, diff --git a/src/org/tizen/emulator/manager/ui/widgets/ImageButton.java b/src/org/tizen/emulator/manager/ui/widgets/ImageButton.java index 4150d05..053a103 100644 --- a/src/org/tizen/emulator/manager/ui/widgets/ImageButton.java +++ b/src/org/tizen/emulator/manager/ui/widgets/ImageButton.java @@ -51,6 +51,7 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.TypedListener; import org.tizen.emulator.manager.resources.ColorResources; import org.tizen.emulator.manager.resources.FontResources; +import org.tizen.emulator.manager.resources.ImageResources; import org.tizen.emulator.manager.resources.PatchImageResources; public class ImageButton extends Canvas { @@ -68,7 +69,7 @@ public class ImageButton extends Canvas { private boolean selected = false; private boolean defaultPush = true; - private int RADIO_IMAGE_SIZE = 21; + private int RADIO_IMAGE_SIZE = 16; public ImageButton(Composite parent, int style) { super(parent, SWT.DOUBLE_BUFFERED | style); this.parent = parent; @@ -79,9 +80,6 @@ public class ImageButton extends Canvas { initButton(); addListeners(); - - - this.setFont(FontResources.BUTTON_FONT.getFont()); } protected void initButton() { @@ -99,6 +97,15 @@ public class ImageButton extends Canvas { fontColors.set(WSTATE.DISABLE.getId(), ColorResources.BUTTON_DISABLE_FONT_COLOR.getColor()); + + if (checkStyle(style, SWT.RADIO)) { + this.setImages(ImageResources.RADIO_OFF.getImage(), + ImageResources.RADIO_OFF.getImage(), + ImageResources.RADIO_OFF.getImage(), + ImageResources.RADIO_ON.getImage(), + ImageResources.RADIO_ON.getImage(), + ImageResources.RADIO_OFF.getImage()); + } } private void addListeners() { @@ -135,6 +142,13 @@ public class ImageButton extends Canvas { images.set(state.getId(), image); } + @Override + public void setBackground(Color color) { + for (WSTATE s : WSTATE.values()) { + colors.set(s.getId(), color); + } + } + public void setBackgroundColor(WSTATE state, Color color) { colors.set(state.getId(), color); } @@ -217,7 +231,7 @@ public class ImageButton extends Canvas { public Point computeSize(int wHint, int hHint, boolean changed) { int width = 0, height = 0; - if (checkStyle(style, SWT.RADIO) + if (checkStyle(style, SWT.RADIO) && images.get(WSTATE.NORMAL.getId()) != null) { Rectangle bounds = images.get(WSTATE.NORMAL.getId()).getBounds(); width = bounds.width + 14; @@ -297,6 +311,7 @@ public class ImageButton extends Canvas { Point extent = e.gc.stringExtent(text); x += rect.x + ((rect.width - extent.x) / 2); } + int fontHeight = e.gc.getFontMetrics().getHeight(); y = rect.y + (rect.height - fontHeight) / 2 - 1; @@ -393,7 +408,7 @@ public class ImageButton extends Canvas { return selected; } - public void selectRadio() { + private void selectRadio() { Control[] children = parent.getChildren(); for (int i = 0; i < children.length; i++) { Control child = children[i]; diff --git a/src/org/tizen/emulator/manager/ui/widgets/ImageLabel.java b/src/org/tizen/emulator/manager/ui/widgets/ImageLabel.java index 4a2f8ec..334c00a 100644 --- a/src/org/tizen/emulator/manager/ui/widgets/ImageLabel.java +++ b/src/org/tizen/emulator/manager/ui/widgets/ImageLabel.java @@ -95,7 +95,7 @@ public class ImageLabel extends Canvas{ p = gc.textExtent(text, SWT.DRAW_MNEMONIC); x = (rect.width - p.x) / 2; y = (rect.height - p.y) / 2; - x = (x < 0) ? 0 : x; + x = (x < 0) ? 2 : x; offset = 0; } else { x = fontPoint.x;