- Now, the corners outside the rounded button is transparent.
Change-id: I6ee95d4c090b14917063e7e50e66cc3c667cbf38
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
import org.eclipse.swt.widgets.Display;
public enum ColorResources {
+ WHITE(255, 255, 255),
+ BLACK(0, 0, 0),
+
// nine patch button
GRAY_BTN_NORMAL(149, 159, 164),
GRAY_BTN_HOVER(149, 159, 164),
GRAY_BTN_PUSH(100, 110, 144),
GRAY_BTN_DISABLE(208, 208, 208),
- GRAY_BTN_FONT(255, 255, 255),
-
MESSAGE_BOX_TITLE_BG(111, 125, 149),
MESSAGE_BOX_TITLE_FONT(255, 255, 255),
MESSAGE_BOX_CONTENTS_BG(255, 255, 255),
MESSAGE_BOX_BUTTON_BG(149, 159, 165),
MESSAGE_BOX_BUTTON_FONT(255, 255, 255);
+ public static ColorResources GRAY_BTN_FONT = WHITE;
+
+
Color color;
int r,g,b;
package org.tizen.emulator.manager.renewal.resources;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.widgets.Display;
import org.tizen.emulator.manager.ui.renewal.widgets.NinePatchResourceInfo;
public class PatchImageResources {
- public static Image getButtonImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) {
+ public static Image getNinePatchButtonImage(int width, int height, NinePatchResourceInfo ninePatchImagesInfo) {
Image lt = ninePatchImagesInfo.getLeftTopImage().getImage();
Image t = ninePatchImagesInfo.getTopImage().getImage();
Image rt = ninePatchImagesInfo.getRightTopImage().getImage();
GC gc = new GC(image);
gc.setInterpolation(SWT.NONE);
+
+ // First, fill background to make corner transparent.
+ Color transparentColor = ninePatchImagesInfo.getTransparentColor().getColor();
+ gc.setBackground(transparentColor);
+ gc.fillRectangle(0, 0, width, height);
+
+ // draw background
gc.setBackground(ninePatchImagesInfo.getBackground().getColor());
gc.fillRectangle(l.getImageData().width, t.getImageData().height,
width - l.getImageData().width - r.getImageData().width,
b.getImageData().height);
gc.drawImage(rb, width - rb.getImageData().width, height - rb.getImageData().height);
gc.dispose();
- return image;
+
+ // Make corner transparent
+ ImageData data = image.getImageData();
+ int cornerPixel = data.palette.getPixel(transparentColor.getRGB());
+ data.transparentPixel = cornerPixel;
+ Image cornerTransparentedImage = new Image(Display.getCurrent(), data);
+
+ // dispose original image
+ image.dispose();
+
+ return cornerTransparentedImage;
}
}
private final WSTATE disableState = WSTATE.DISABLE_ON;
- public void setNormalImage(ColorResources background,
+ public void setNormalImage(ColorResources background, ColorResources transparentColor,
ImageResources lt, ImageResources t,
ImageResources rt, ImageResources r,
ImageResources rb, ImageResources b,
ImageResources lb, ImageResources l) {
- setImages(WSTATE.NORMAL, background, lt, t, rt, r, rb, b, lb, l);
+ setImages(WSTATE.NORMAL, background, transparentColor, lt, t, rt, r, rb, b, lb, l);
}
- public void setHoverImage(ColorResources background,
+ public void setHoverImage(ColorResources background, ColorResources transparentColor,
ImageResources lt, ImageResources t,
ImageResources rt, ImageResources r,
ImageResources rb, ImageResources b,
ImageResources lb, ImageResources l) {
- setImages(WSTATE.HOVER, background, lt, t, rt, r, rb, b, lb, l);
+ setImages(WSTATE.HOVER, background, transparentColor, lt, t, rt, r, rb, b, lb, l);
}
- public void setPushImage(ColorResources background,
+ public void setPushImage(ColorResources background, ColorResources transparentColor,
ImageResources lt, ImageResources t,
ImageResources rt, ImageResources r,
ImageResources rb, ImageResources b,
ImageResources lb, ImageResources l) {
- setImages(WSTATE.PUSH, background, lt, t, rt, r, rb, b, lb, l);
+ setImages(WSTATE.PUSH, background, transparentColor, lt, t, rt, r, rb, b, lb, l);
}
- public void setDisableImage(ColorResources background,
+ public void setDisableImage(ColorResources background, ColorResources transparentColor,
ImageResources lt, ImageResources t,
ImageResources rt, ImageResources r,
ImageResources rb, ImageResources b,
ImageResources lb, ImageResources l) {
- setImages(disableState, background, lt, t, rt, r, rb, b, lb, l);
+ setImages(disableState, background, transparentColor, lt, t, rt, r, rb, b, lb, l);
}
- private void setImages(WSTATE wState, ColorResources background,
+ private void setImages(WSTATE wState, ColorResources background, ColorResources transparentColor,
ImageResources lt, ImageResources t,
ImageResources rt, ImageResources r,
ImageResources rb, ImageResources b,
ImageResources lb, ImageResources l) {
- map.put(wState, new NinePatchResourceInfo(background, lt, t, rt, r, rb, b, lb, l));
+ map.put(wState, new NinePatchResourceInfo(background, transparentColor,
+ lt, t, rt, r, rb, b, lb, l));
}
private static void initButtonResourceInfo() {
buttonResourceInfo = new ButtonResourceInfo();
buttonResourceInfo.setNormalImage(ColorResources.GRAY_BTN_NORMAL,
+ ColorResources.BLACK,
ImageResources.GRAY_BTN_NORMAL_LT,
ImageResources.GRAY_BTN_NORMAL_T,
ImageResources.GRAY_BTN_NORMAL_RT,
ImageResources.GRAY_BTN_NORMAL_L);
buttonResourceInfo.setHoverImage(ColorResources.GRAY_BTN_HOVER,
+ ColorResources.BLACK,
ImageResources.GRAY_BTN_HOVER_LT,
ImageResources.GRAY_BTN_HOVER_T,
ImageResources.GRAY_BTN_HOVER_RT,
ImageResources.GRAY_BTN_HOVER_L);
buttonResourceInfo.setPushImage(ColorResources.GRAY_BTN_PUSH,
+ ColorResources.BLACK,
ImageResources.GRAY_BTN_PUSH_LT,
ImageResources.GRAY_BTN_PUSH_T,
ImageResources.GRAY_BTN_PUSH_RT,
ImageResources.GRAY_BTN_PUSH_L);
buttonResourceInfo.setDisableImage(ColorResources.GRAY_BTN_DISABLE,
+ ColorResources.BLACK,
ImageResources.GRAY_BTN_DISABLE_LT,
ImageResources.GRAY_BTN_DISABLE_T,
ImageResources.GRAY_BTN_DISABLE_RT,
fonts = new ArrayList<Font>();
for (WSTATE s : WSTATE.values()) {
- colors.add(s.getId(), ColorResources.GRAY_BTN_NORMAL.getColor());
+ colors.add(s.getId(), null);
fontColors.add(s.getId(), ColorResources.GRAY_BTN_FONT.getColor());
fonts.add(s.getId(), FontResources.BUTTON_FONT.getFont());
images.add(s.getId(), null);
switch(state) {
case HOVER:
if (hoverImage == null) {
- hoverImage = PatchImageResources.getButtonImage(width, height,
+ hoverImage = PatchImageResources.getNinePatchButtonImage(width, height,
getButtonResourceInfo().getHoverImages());
}
image = hoverImage;
break;
case PUSH:
if (pushImage == null) {
- pushImage = PatchImageResources.getButtonImage(width, height,
+ pushImage = PatchImageResources.getNinePatchButtonImage(width, height,
getButtonResourceInfo().getPushImages());
}
image = pushImage;
break;
case DISABLE_ON:
if (disableImage == null) {
- disableImage = PatchImageResources.getButtonImage(width, height,
+ disableImage = PatchImageResources.getNinePatchButtonImage(width, height,
getButtonResourceInfo().getDisableImages());
}
image = disableImage;
break;
default:
if (nomalImage == null) {
- nomalImage = PatchImageResources.getButtonImage(width, height,
+ nomalImage = PatchImageResources.getNinePatchButtonImage(width, height,
getButtonResourceInfo().getNormalImages());
}
image = nomalImage;
private final Map<String, ImageResources> map = new HashMap<String, ImageResources> ();
private final ColorResources background;
+ // This is used to make the corners of button transparent.
+ // This color should be set as which is not included in button image.
+ private final ColorResources transparentColor;
+
static final String LT = "lt";
static final String T = "t";
static final String RT = "rt";
static final String LB = "lb";
static final String L = "l";
- NinePatchResourceInfo(ColorResources background,
+ NinePatchResourceInfo(ColorResources background, ColorResources transparentColor,
ImageResources lt, ImageResources t,
ImageResources rt, ImageResources r,
ImageResources rb, ImageResources b,
ImageResources lb, ImageResources l) {
this.background = background;
+ this.transparentColor = transparentColor;
map.put(LT, lt);
map.put(T, t);
map.put(RT, rt);
public ColorResources getBackground() {
return background;
}
+
+ public ColorResources getTransparentColor() {
+ return transparentColor;
+ }
}