From ff0cd8d53e90470ed575918438222403600d7d8f Mon Sep 17 00:00:00 2001 From: "changhyun1.lee" Date: Tue, 26 Mar 2013 00:10:49 +0900 Subject: [PATCH] [Title] Fixed AppTray Icon UX [Desc.] [Issue] Redmine-8752 Change-Id: Ib1c99c34d318101b5a795b98303e605907c896df --- .../org/tizen/common/ui/dialog/NewIconDialog.java | 111 +++++++-------------- 1 file changed, 38 insertions(+), 73 deletions(-) diff --git a/org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java b/org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java index b0e5d7a..5acd9f5 100644 --- a/org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java +++ b/org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java @@ -31,7 +31,6 @@ import java.awt.AlphaComposite; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; -import java.io.IOException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -50,7 +49,6 @@ import org.eclipse.swt.graphics.ImageLoader; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -61,7 +59,6 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.SelectionStatusDialog; import org.tizen.common.CommonPlugin; import org.tizen.common.ScreenDensity; -import org.tizen.common.util.FileUtil; import org.tizen.common.util.ImageUtil; import org.tizen.common.util.log.Logger; @@ -74,19 +71,17 @@ public class NewIconDialog extends SelectionStatusDialog { public static final String[] ICON_FILTER_EXTENSIONS = { "*.png;*.gif;*.jpg" }; public static final String MASK_IMAGE_PATH = "/icons/mask.png"; public static final String EFFECT_IMAGE_PATH = "/icons/effect.png"; + public static final int ICON_SIZE = ScreenDensity.XHIGH.getIconSize(); // WebApp icon is always XHIGH(108x108) private Text fText; private Button fBrowseBtn; - private Combo fDensityCombo; private String fPath; - protected Label fPreviewImage; + private Label fPreviewImage, fPreviewLabel; + private Button fApplyEffectCheck; private IProject fProject; // need to refresh file tree - private Label lblPreview; private Label lblNewLabel; private Label lblImageFile; - private boolean fIsMenuIcon; private BufferedImage fMaskImage, fEffectImage, fIconImage; - private Button fMenuIconCheck; public NewIconDialog(Shell parentShell, IProject project) { super(parentShell); @@ -133,40 +128,18 @@ public class NewIconDialog extends SelectionStatusDialog { }); fBrowseBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblPreview = new Label(grid, SWT.NONE); - lblPreview.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); - lblPreview.setText("Preview:"); - - // second row - Label label = new Label(grid, SWT.NONE); - label.setText("Density:"); - label.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); - - fDensityCombo = new Combo(grid, SWT.READ_ONLY); - for (ScreenDensity sd : ScreenDensity.values()) { - fDensityCombo.add(sd.getName()); - } - - fDensityCombo.select(0); - GridData gd_fDensityCombo = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - gd_fDensityCombo.widthHint = 250; - fDensityCombo.setLayoutData(gd_fDensityCombo); - new Label(grid, SWT.NONE); - - fPreviewImage = new Label(grid, SWT.BORDER); - gd = new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 2); - gd.widthHint = 120; - gd.heightHint = 120; - fPreviewImage.setLayoutData(gd); + fPreviewLabel = new Label(grid, SWT.NONE); + fPreviewLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); + fPreviewLabel.setText(String.format("Preview(%1$dx%2$d)", ICON_SIZE, ICON_SIZE)); lblNewLabel = new Label(grid, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); lblNewLabel.setText("Option:"); - fMenuIconCheck = new Button(grid, SWT.CHECK); - fMenuIconCheck.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1)); - fMenuIconCheck.setText("MainMenu Icon"); - fMenuIconCheck.addSelectionListener(new SelectionAdapter() { + fApplyEffectCheck = new Button(grid, SWT.CHECK); + fApplyEffectCheck.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1)); + fApplyEffectCheck.setText("Apply shadow effect"); + fApplyEffectCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { validate(); @@ -175,6 +148,12 @@ public class NewIconDialog extends SelectionStatusDialog { }); new Label(grid, SWT.NONE); + fPreviewImage = new Label(grid, SWT.BORDER); + gd = new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 2); + gd.widthHint = 120; + gd.heightHint = 120; + fPreviewImage.setLayoutData(gd); + setHelpAvailable(false); validate(); @@ -231,20 +210,11 @@ public class NewIconDialog extends SelectionStatusDialog { } try { - if (fIsMenuIcon) { - Image image = fPreviewImage.getImage(); - ImageLoader loader = new ImageLoader(); - loader.data = new ImageData[] { image.getImageData() }; - loader.save(destFilePath, SWT.IMAGE_PNG); - } else { - if (! fPath.equals(destFilePath)) { - FileUtil.copyTo(fPath, destFilePath, false); - } - } - + Image image = fPreviewImage.getImage(); + ImageLoader loader = new ImageLoader(); + loader.data = new ImageData[] { image.getImageData() }; + loader.save(destFilePath, SWT.IMAGE_PNG); destFile.getParent().refreshLocal(1, null); - } catch (IOException e) { - Logger.log(e); } catch (CoreException e1) { Logger.log(e1); } @@ -255,37 +225,32 @@ public class NewIconDialog extends SelectionStatusDialog { @Override protected void computeResult() { fPath = fText.getText(); - fIsMenuIcon = fMenuIconCheck.getSelection(); } protected void updatePreview() { Image image = null; - if (fIsMenuIcon) { - int size = ScreenDensity.XHIGH.getIconSize(); - BufferedImage srcImage = ImageUtil.getAWTImage(fPath, false); - fIconImage = ImageUtil.getScaledImage(srcImage, size, size); + BufferedImage srcImage = ImageUtil.getAWTImage(fPath, false); + fIconImage = ImageUtil.getScaledImage(srcImage, ICON_SIZE, ICON_SIZE); - if (fMaskImage == null) { - fMaskImage = ImageUtil.getAWTImage(MASK_IMAGE_PATH, true); - } - if (fEffectImage == null) { - fEffectImage = ImageUtil.getAWTImage(EFFECT_IMAGE_PATH, true); - } + if (fMaskImage == null) { + fMaskImage = ImageUtil.getAWTImage(MASK_IMAGE_PATH, true); + } + if (fEffectImage == null) { + fEffectImage = ImageUtil.getAWTImage(EFFECT_IMAGE_PATH, true); + } - BufferedImage tempImage = new BufferedImage(fMaskImage.getWidth(), fMaskImage.getHeight(), BufferedImage.TYPE_INT_ARGB); - Graphics2D graph = tempImage.createGraphics(); - graph.drawImage(fMaskImage, 0, 0, null); - graph.setComposite(AlphaComposite.SrcAtop); - // graph.setComposite(AlphaComposite.SrcOver); - graph.drawImage(fIconImage, 0, 0, null); + BufferedImage tempImage = new BufferedImage(fMaskImage.getWidth(), fMaskImage.getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D graph = tempImage.createGraphics(); + graph.drawImage(fMaskImage, 0, 0, null); + graph.setComposite(AlphaComposite.SrcAtop); + graph.drawImage(fIconImage, 0, 0, null); + // shadow effect + if (fEffectImage != null && fApplyEffectCheck.getSelection()) { graph.drawImage(fEffectImage, 0, 0, null); - graph.dispose(); - - image = ImageUtil.convertImageToSWT(getShell().getDisplay(), tempImage); - } else { - BufferedImage bimage = ImageUtil.getAWTImage(fPath, false); - image = ImageUtil.convertImageToSWT(fPreviewImage.getDisplay(), bimage); } + graph.dispose(); + + image = ImageUtil.convertImageToSWT(getShell().getDisplay(), tempImage); fPreviewImage.setImage(image); } -- 2.7.4