Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 459481

Summary: GC.drawText does not work in RAP 3.0 M5 if "transparent" (SWT.DRAW_TRANSPARENT) is specified
Product: [RT] RAP Reporter: Thomas Hendel <hendel>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.0 M6   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Code example
none
Screenshot of first code variant
none
Screenshot of the second variant
none
Result after changing the background color none

Description Thomas Hendel CLA 2015-02-09 11:09:11 EST
After updating to RAP 3.0 M5 I noticed, that GC.drawText() does not work as expected.
I have a "Canvas" based widget that draws an image and a text. In RAP 3.0 M4 everything looked fine, but now (M5) the text is not drawn.
I use a call like "gc.drawText("myText", x, y, true);", i.e., transparent text.
If I change the last parameter of GC.drawText() from "true" to "false" so that SWT.DRAW_TRANSPARENT is *not* set, then the text appears.
As I found out, the JavaScript part (GC.js) has slightly changed from M4 to M5 while the Java implementation looks unchanged.
Comment 1 Ivan Furnadjiev CLA 2015-02-09 11:27:48 EST
We are using the same method in our Controls Demo Canvas tab and it's working as expected. Is it possible the text to be drown with the background color? Is the text appear if you make it multiline - "myText\nSecond line"?
Comment 2 Thomas Hendel CLA 2015-02-10 03:44:46 EST
Created attachment 250646 [details]
Code example

Two variants of my paint method - one sets "SWT.DRAW_TRANSPARENT", the second variant avoids this flag.
Comment 3 Thomas Hendel CLA 2015-02-10 03:45:59 EST
Created attachment 250647 [details]
Screenshot of first code variant

The text is NOT drawn.
Comment 4 Thomas Hendel CLA 2015-02-10 03:46:40 EST
Created attachment 250648 [details]
Screenshot of the second variant

The text is drawn.
Comment 5 Thomas Hendel CLA 2015-02-10 03:50:55 EST
I attached a code example and two screenshots. This code is used in a custom widget recording some mouse events (The first three text lines are reports of these events, the additional text is status information about our own browser plugin...)

I think, that the problem is the handling of the flag "SWT.DRAW_TRANSPARENT". If I call GC.drawText() in a way, so that is flag is NOT set, then the text is drawn.
Comment 6 Ivan Furnadjiev CLA 2015-02-10 03:51:37 EST
I think that the text is drawn with the gray background color. Just for the test - change the background color after gc.fillRectangle(rct); to something different than SWT.COLOR_GRAY. Is the text visible now?
Comment 7 Thomas Hendel CLA 2015-02-10 03:59:24 EST
Indeed :-)!
I included the line
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_RED));
and set "SWT.DRAW_TRANSPARENT" in the first call of GC.drawText(), while the second call does an opaque drawing operation.
The result is
1) red text on gray background and
2) blue text on red background
I'll attach another sreenshot...
Comment 8 Thomas Hendel CLA 2015-02-10 03:59:54 EST
Created attachment 250650 [details]
Result after changing the background color
Comment 9 Ivan Furnadjiev CLA 2015-02-10 04:05:27 EST
Than I think that this pending change will fix the problem - https://git.eclipse.org/r/#/c/41461/
Comment 10 Ivan Furnadjiev CLA 2015-02-11 08:18:17 EST
Fixed with change https://git.eclipse.org/r/#/c/41461/