Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 464842 - [Win32] Obscured widgets do not 'bleed through' with transparency on Windows
Summary: [Win32] Obscured widgets do not 'bleed through' with transparency on Windows
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Niraj Modi CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-17 01:42 EDT by Ian Bull CLA
Modified: 2020-05-13 07:11 EDT (History)
2 users (show)

See Also:


Attachments
Screenshot showing the problem (64.71 KB, image/png)
2015-04-17 01:42 EDT, Ian Bull CLA
no flags Details
Snippet showing the problem (2.00 KB, application/octet-stream)
2015-04-17 01:45 EDT, Ian Bull CLA
no flags Details
Snippet working with NO_BACKGROUND style on GlassPane Composite. (1.80 KB, application/octet-stream)
2015-04-20 08:36 EDT, Niraj Modi CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Bull CLA 2015-04-17 01:42:51 EDT
Created attachment 252477 [details]
Screenshot showing the problem

This may be related to Bug 463127.

I'm trying to create a 'Glass Pane', that is a Composite with a transparent background that sits above other composites. My expectation is that widgets that makeup the concealed composite will show through the transparent 'glass pane' composite. This works on MacOS, but not windows.

On Windows, setting the glass pane to transparent does not show the concealed widgets. The background color of the hidden composite will 'bleed through' but not the widgets. I'll attach a screenshot showing the platform differences and a code snippet that reproduces this problem.

The screenshot shows composite A behind composite B. Composite A has two buttons on it, and composite B has a single button (called hide) and a transparent background. On Mac, the Composite A can be seen behind composite B. However, on Windows, composite B is drawn with a white background.
Comment 1 Ian Bull CLA 2015-04-17 01:45:07 EDT
Created attachment 252478 [details]
Snippet showing the problem

Here is the snippet I used. I've tested this on I20150414-1400.
Comment 2 Niraj Modi CLA 2015-04-17 04:08:21 EDT
(In reply to Ian Bull from comment #0)
> Created attachment 252477 [details]
> Screenshot showing the problem
> 
> This may be related to Bug 463127.
No, that's a different problem, related to composite with Scrollbars.

Here, in attached snippet you are using absolute layout(using setBounds()) to layer one Composite on top of other composite... to achieve GlassPane kind of behavior.
Comment 3 Ian Bull CLA 2015-04-17 10:17:27 EDT
(In reply to Niraj Modi from comment #2)
> (In reply to Ian Bull from comment #0)
> > Created attachment 252477 [details]
> > Screenshot showing the problem
> > 
> > This may be related to Bug 463127.
> No, that's a different problem, related to composite with Scrollbars.
> 
> Here, in attached snippet you are using absolute layout(using setBounds())
> to layer one Composite on top of other composite... to achieve GlassPane
> kind of behavior.

Is there a better layout to use? I tried a stack layout, but that didn't work either.  All other layouts (Grid, fill, row, form) work hard not to have overlapping widgets, so  the only solution I came up with was an absolute layout.
Comment 4 Niraj Modi CLA 2015-04-20 08:36:42 EDT
Created attachment 252538 [details]
Snippet working with NO_BACKGROUND style on GlassPane Composite.

(In reply to Ian Bull from comment #3)
> (In reply to Niraj Modi from comment #2)
> > (In reply to Ian Bull from comment #0)
> > > Created attachment 252477 [details]
> > > Screenshot showing the problem
> > > 
> > > This may be related to Bug 463127.
> > No, that's a different problem, related to composite with Scrollbars.
> > 
> > Here, in attached snippet you are using absolute layout(using setBounds())
> > to layer one Composite on top of other composite... to achieve GlassPane
> > kind of behavior.
> 
> Is there a better layout to use? I tried a stack layout, but that didn't
> work either.  All other layouts (Grid, fill, row, form) work hard not to
> have overlapping widgets, so  the only solution I came up with was an
> absolute layout.

Got the GlassPane behavior working on Windows too.
On Windows, it's required to apply SWT.NO_BACKGROUND style on the Composite which you are using as GlassPane... please refer updated snippet attached.
Comment 5 Ian Bull CLA 2015-04-20 10:19:51 EDT
(In reply to Niraj Modi from comment #4)
> Created attachment 252538 [details]
> Snippet working with NO_BACKGROUND style on GlassPane Composite.

> Got the GlassPane behavior working on Windows too.
> On Windows, it's required to apply SWT.NO_BACKGROUND style on the Composite
> which you are using as GlassPane... please refer updated snippet attached.

SWT.NO_BACKGROUND is very different from transparency. 

SWT.NO_BACKGROUND does not draw the background of the widget. There is a slight difference (as it mentions in the docs for SWT.NO_BACKGROUND). The by not drawing the background, it takes the current pixels (a snapshot at that time) that makeup the area behind the composite. However, if those change (say your resize the shell, or something else changes behind the glass pane) it's not updated.

In fact, just having SWT.NO_BACKGROUND has always had this behaviour (before SWT.TRANSPARENCY was ever introduced). On Mac, with SWT.TRANSPARENCY you now have a real 'glass pane' where composite below 'bleeds through' -- not just using a snapshot in time.
Comment 6 Ian Bull CLA 2015-04-20 10:22:06 EDT
Here is what the docs say for NO_BACKGROUND:

<snip>
By default, before a widget paints, the client area is filled with the current background. When this style is specified, the background is not filled, and the application is responsible for filling every pixel of the client area. This style might be used as an alternative to "double-buffering" in order to reduce flicker. This style does not mean "transparent" - widgets that are obscured will not draw through.
</snip>
Comment 7 Eclipse Genie CLA 2020-05-13 07:11:39 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.