Search code examples
fltk

Rounded Corner for FLTK-Window


Many modern applications feature rounded corners for their windows, see Photoshop, which has rounded corners in the top left and right.

enter image description here

I was wondering if there is any way to implement rounded corners in FLTK. Right now, when I set my window's frame to rounded corners, the background color of my app (black) still shows through:

enter image description here

Any work arounds for this?


Solution

  • The shape member function may help in achieving what you are searching for. The below image is the window created by the example code you can find in example/shapedwindow.cxx:

    shapedwindow.cxx without upper bar

    You see that you can get any shape you want. The drawback is that there is not the upper bar with window's name and close, iconize and enlarge buttons. These can be made visible by adding win->border(1); just before win->show(); in the code, but the result is not quite appealing.

    shapedwindow.cxx with upper bar