Bug 316882 - Transparent Shell but Opaque Contents wanted
Summary: Transparent Shell but Opaque Contents wanted
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-15 07:41 EDT by Daoen Pan CLA
Modified: 2020-12-13 04:22 EST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daoen Pan CLA 2010-06-15 07:41:52 EDT
Build Identifier: I20100603-1500

Currently, if a shell is set as transparent with setAlpha method, then all child controls in the shell are also transparent, also the drawing to the shell is affected.  

There should be an option to control the transparence behavior, propagate to children and drawing or not.

Reproducible: Always
Comment 1 Niraj Modi CLA 2016-06-13 04:00:47 EDT
Hi Daoen,
Try SWT.COLOR_TRANSPARENT color which can be set on individual widget/Composites using Control#setBackground(Color) API, here is a detailed snippet which show usage of SWT.COLOR_TRANSPARENT in SWT for commonly used widgets:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet365.java
Comment 2 Leo Ufimtsev CLA 2016-06-15 17:06:50 EDT
Eric is doing some work on transparency, maybe he can comment.
Comment 3 Eric Williams CLA 2016-07-04 14:30:38 EDT
The way opacity is handled in Shell.setOpacity() right now is to call gtk_window_set_opacity() which has been deprecated as of 3.8. As part of bug 477950 I will convert this method to something more sensible using CSS. This approach should only affect the shell itself and not its child controls.

That said, setting the shell's background to SWT.COLOR_TRANSPARENT is also an option.
Comment 4 Eric Williams CLA 2016-07-11 14:19:22 EDT
(In reply to Eric Williams from comment #3)
> The way opacity is handled in Shell.setOpacity() right now is to call
> gtk_window_set_opacity() which has been deprecated as of 3.8. As part of bug
> 477950 I will convert this method to something more sensible using CSS. This
> approach should only affect the shell itself and not its child controls.
> 
> That said, setting the shell's background to SWT.COLOR_TRANSPARENT is also
> an option.

I actually investigated this a bit further. Shell.setAlpha() - not setOpacity, which was a typo on my part - is actually a bit different from setting the background color to SWT.COLOR_TRANSPARENT.

Shell.setAlpha(0) will hide the entire shell, since it is transparent. This would include its child controls. It would be interesting to see how this behaves on Cocoa or Win32, however I think this behavior is correct. A shell acts as a container, having it be invisible (fully transparent) and still show buttons/child controls doesn't make a lot of sense to me. Calling Shell.setAlpha(0) also hides the header bar.

setBackground(COLOR_TRANSPARENT) is a bit of a different animal. The shell area is transparent (in theory, currently on GTK3 it's white) but the header bar is not. Also child controls can have different background colors which set them apart - see Snippet365 as an example.

It's also worth noting that gtk_widget_set_opacity() and gtk_window_set_opacity() are API that interact directly with the window manager/compositor. That is, they deal with GdkWindow/GdkScreen. They do not change RGBA colors using GTK's CSS machinery or StyleContext system.

My plans for now are to fix the deprecated function for this bug, and handle SWT.COLOR_TRANSPARENT in bug 477950.
Comment 5 Eric Williams CLA 2016-07-11 15:14:41 EDT
(In reply to Eric Williams from comment #4)
> My plans for now are to fix the deprecated function for this bug, and handle
> SWT.COLOR_TRANSPARENT in bug 477950.

I've opened a new bug for the deprecation fix. As for this bug, I'm going to test on Cocoa and see what the behavior is like. Unless it is radically different I'll close this bug.
Comment 6 Ivan Morelli CLA 2018-05-02 09:42:42 EDT
Hi guys,
Sorry if I bother you, I have also opened a bug for this feature: https://bugs.eclipse.org/bugs/show_bug.cgi?id=530152


Is there any chances to see this feature implemented in the future, or has been abandoned?

Thank you
Comment 7 Allen Jiang CLA 2020-01-11 03:25:32 EST
Hi SWT developers,

my requirement is to display a image on Shell ,to expect the shell's background is transparency and the image of png formate need to display.
but using alpha everything is affected, the shell it self and all its content.
but i only want to set the transparency for the background and not for the widgets on it.