diff options
author | Silenio Quarti <silenio> | 2005-07-08 17:37:55 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2005-07-08 17:37:55 +0000 |
commit | b1dbb178b5008dcde16cb7cda2cdc928e2b7e39d (patch) | |
tree | 83b47989c3773061897a3b836c8a3634e4f33b4f | |
parent | a8f114be734cf55461b8999b4ca14407d0f10da3 (diff) | |
download | eclipse.platform.swt-b1dbb178b5008dcde16cb7cda2cdc928e2b7e39d.tar.gz eclipse.platform.swt-b1dbb178b5008dcde16cb7cda2cdc928e2b7e39d.tar.xz eclipse.platform.swt-b1dbb178b5008dcde16cb7cda2cdc928e2b7e39d.zip |
103187
4 files changed, 28 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java index 8cfe85f307..d26fb67169 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java @@ -94,6 +94,9 @@ public Pattern(Device device, Image image) { * @see #dispose() */ public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, Color color2) { + this(device, x1, y1, x2, y2, color1, 0xFF, color2, 0xFF); +} +public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); @@ -104,9 +107,8 @@ public Pattern(Device device, float x1, float y1, float x2, float y2, Color colo device.checkCairo(); handle = Cairo.cairo_pattern_create_linear(x1, y1, x2, y2); if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); - //TODO - how about alpha? - GC.setCairoPatternColor(handle, 0, color1); - GC.setCairoPatternColor(handle, 1, color2); + GC.setCairoPatternColor(handle, 0, color1, alpha1); + GC.setCairoPatternColor(handle, 1, color2, alpha2); Cairo.cairo_pattern_set_extend(handle, Cairo.CAIRO_EXTEND_REPEAT); if (device.tracking) device.new_Object(this); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Pattern.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Pattern.java index 72e1bb9860..9c2cea7ad6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Pattern.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Pattern.java @@ -28,6 +28,7 @@ public class Pattern extends Resource { int jniRef; Image image; Color color1, color2; + int alpha1, alpha2; float x1, y1, x2, y2; int shading; @@ -86,6 +87,9 @@ public Pattern(Device device, Image image) { * @see #dispose() */ public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, Color color2) { + this(device, x1, y1, x2, y2, color1, 0xFF, color2, 0xFF); +} +public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) { if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); @@ -99,6 +103,8 @@ public Pattern(Device device, float x1, float y1, float x2, float y2, Color colo this.y2 = y2; this.color1 = color1; this.color2 = color2; + this.alpha1 = alpha1; + this.alpha2 = alpha2; device.createPatternCallbacks(); jniRef = OS.NewGlobalRef(this); if (jniRef == 0) SWT.error(SWT.ERROR_NO_HANDLES); @@ -124,11 +130,12 @@ int axialShadingProc (int ref, int in, int out) { float factor2 = buffer[0], factor1 = 1 - factor2; float[] c1 = color1.handle; float[] c2 = color2.handle; + float a1 = ((alpha1 & 0xFF) / (float)0xFF); + float a2 = ((alpha2 & 0xFF) / (float)0xFF); buffer[0] = (c2[0] * factor2) + (c1[0] * factor1); buffer[1] = (c2[1] * factor2) + (c1[1] * factor1); buffer[2] = (c2[2] * factor2) + (c1[2] * factor1); - //TODO - how about alpha? - buffer[3] = 1; + buffer[3] = (a2 * factor2) + (a1 * factor1); OS.memcpy(out, buffer, buffer.length * 4); return 0; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java index c43ec160b5..a89d0bfa14 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java @@ -2565,9 +2565,13 @@ static void setCairoClip(int /*long*/ cairo, int /*long*/ clipRgn) { if (rects[0] != 0) OS.g_free(rects[0]); } -static void setCairoPatternColor(int /*long*/ pattern, int offset, Color c) { +static void setCairoPatternColor(int /*long*/ pattern, int offset, Color c, int alpha) { GdkColor color = c.handle; - Cairo.cairo_pattern_add_color_stop(pattern, offset, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, 1); + double aa = (alpha & 0xFF) / (double)0xFF; + double red = ((color.red & 0xFFFF) / (double)0xFFFF); + double green = ((color.green & 0xFFFF) / (double)0xFFFF); + double blue = ((color.blue & 0xFFFF) / (double)0xFFFF); + Cairo.cairo_pattern_add_color_stop(pattern, offset, red, green, blue, aa); } void setClipping(int /*long*/ clipRgn) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java index 4845ab82d9..587573ad77 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java @@ -1093,7 +1093,7 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt float naw2 = naw / 2f; float nah2 = nah / 2f; float fw = nw / naw2; - float fh = nh / nah2; +// float fh = nh / nah2; Cairo.cairo_new_path(cairo); Cairo.cairo_save(cairo); float offset = data.lineWidth == 0 || (data.lineWidth % 2) == 1 ? 0.5f : 0f; @@ -1205,7 +1205,6 @@ public void drawString (String string, int x, int y, boolean isTransparent) { } } void createRenderTable() { - int xDisplay = data.display; int fontList = data.font.handle; /* Get the width of the tabs */ byte[] buffer = {(byte)' ', 0}; @@ -1816,7 +1815,7 @@ public void fillRoundRectangle (int x, int y, int width, int height, int arcWidt float naw2 = naw / 2f; float nah2 = nah / 2f; float fw = nw / naw2; - float fh = nh / nah2; +// float fh = nh / nah2; XColor color = new XColor(); color.pixel = values.background; OS.XQueryColor(xDisplay, data.colormap, color); @@ -3234,9 +3233,13 @@ static void setCairoClip(int /*long*/ cairo, int /*long*/ clipRgn) { Cairo.cairo_clip(cairo); Cairo.cairo_new_path(cairo); } -static void setCairoPatternColor(int /*long*/ pattern, int offset, Color c) { +static void setCairoPatternColor(int /*long*/ pattern, int offset, Color c, int alpha) { XColor color = c.handle; - Cairo.cairo_pattern_add_color_stop(pattern, offset, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, 1); + double aa = (alpha & 0xFF) / (double)0xFF; + double red = ((color.red & 0xFFFF) / (double)0xFFFF); + double green = ((color.green & 0xFFFF) / (double)0xFFFF); + double blue = ((color.blue & 0xFFFF) / (double)0xFFFF); + Cairo.cairo_pattern_add_color_stop(pattern, offset, red, green, blue, aa); } void setClipping(int clipRgn) { if (clipRgn == 0) { |