Bug 462433 - [Win/GTK] Control.getForeground() does not honor alpha channel of color
Summary: [Win/GTK] Control.getForeground() does not honor alpha channel of color
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-18 03:43 EDT by Niraj Modi CLA
Modified: 2018-07-10 14:14 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Niraj Modi CLA 2015-03-18 03:43:39 EDT
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);
}
Comment 1 Leo Ufimtsev CLA 2015-03-18 17:29:16 EDT
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 :-).
Comment 2 Eric Williams CLA 2017-07-04 17:04:23 EDT
This has been fixed on GTK3, see bug 477950.