On Tuesday, 14 June 2022 at 07:25:59 UTC+1
Håvard wrote:
I have noticed in test/cube.cxx there is a fl_button with the following color:
Fl::set_color(FL_FREE_COLOR, 255, 255, 0, 75);
That gives a transparent color and works for both fl_button and fl_group (probably many more) as long as they are children of fl_gl_window.
Are there any chance the same would work for fl_window ?
Not really - the key is that the GL render context can support alpha, whereas the stock 2D rendering APIs we use for windows do not. As a result, the button drawn in the GL scene can be translucent, but "the same" button drawn to a standard window will not.
Typically, to get translucent windows you need to have some form of compositing of the desktop as a whole, for example to deal with the background changing underneath your window, even if your window is not being redrawn, that sort of thing.
That was not available in "legacy" window manager systems, but it is fairly common now. (Though still far from universal, and not always cheap to do at runtime either!)
However, how it is used (and the runtime cost of doing so) varies a fair bit between systems, so it is not something that fltk has, at least not yet.
You can get some of that functionality if you are happy to add some platform specific code to your window.
There are tricky issues to this though - as my example shows, it is pretty easy to make a translucent window (where the window *and all its widgets* are translucent); but with the current system it is tricky to have fully-opaque widgets on an otherwise transparent window, or widgets with differing alpha, and that is not an easy thing to work around in the current schemes.