Transparency on edge of Window with FL_ROUND_BOX

Skip to first unread message

Jeff Paranich

Apr 30, 2021, 2:03:49 PM4/30/21
to fltk.general
Hi all,

In an attempt to make FLTK a smidge more modern looking, I've disabled the title bar (window decorations) on my GUI and changed box to FL_ROUND_BOX; but notice it still draws a black background outside the rounded corner.  Is there a way to change this to a transparency?  Here is an image for reference...

Thank you!

Albrecht Schlosser

Apr 30, 2021, 2:12:42 PM4/30/21
You should take a look at FLTK/examples/shapedwindow.cxx to see how you
can create a shaped window.

Greg Ercolano

Apr 30, 2021, 3:47:40 PM4/30/21
    Attaching the OP's pic here in case the link goes stale in the future:


May 1, 2021, 2:52:28 AM5/1/21
to fltk.general
As already mentionned, the solution for this problem is to use the
Fl_Window::shape() member function. See :
This feature is available in FLTK 1.4 and also starting from FLTK 1.3.3 provided the library is built with
    FL_ABI_VERSION = 10303  (or more)

Giving a window the shape of an Fl_ROUND_BOX is done in FLTK 1.4 to transiently
display the new value of the scale factor (type ctrl-+ (or cmd-+ on macOS)).

The code is found in function Fl_Screen_Driver::transient_scale_display() of
file Fl_Screen_Driver.cxx :
- lines 363-373 create an Fl_RGB_Image object containing the adequate shape information
- line 388 applies this shape to the window (and also set it without titlebar)
That should be enough.


May 1, 2021, 3:01:31 AM5/1/21
to fltk.general
I can add that the size of the image used in the Fl_Window::shape() call is not essential.
You may therefore keep a single (relatively large probably) shape image and use it
for all your round-angled windows, small or large.

Reply all
Reply to author
0 new messages