Community
Participate
Working Groups
Cocoa has native support for alpha channel in color class, so the alpha channel in Color is honored (refer bug 461664). Running the same testcase for Windows/GTK2 & GTK3 fails: @Test public void testTransparentForeground() { Label label = createTestLabel(); // create display, shell and label Color transparent = Display.getDefault().getSystemColor(SWT.COLOR_TRANSPARENT); label.setForeground(transparent); int expected = transparent.getRGBA().alpha; int actual = label.getForeground().getRGBA().alpha; assertEquals(expected, actual); }
For GTK, The culprit may be in Widget: void setForegroundColor (long /*int*/ handle, GdkColor color, boolean setStateActive) Alpha is ignored if (OS.GTK3) { GdkRGBA rgba = null; if (color != null) { rgba = new GdkRGBA(); rgba.alpha = 1; >>>>>> alpha is lost here. This may be because the method can't get to SWT's 'alpha' property because it only has access to GdkColor (and not SWT's color). Fixing this might take some time as ~13 widgets might need refactoring so that alpha is passed down to them correctly. It is on my todo list. But it might take some time till I get to it. But if someone is in a rush and has time to work on this in the meantime, I'd be happy to review a patch :-).
This has been fixed on GTK3, see bug 477950.