How to create a window with custom title bar?

Is there a way to create my own custom title bar for a window? I want my window to look “light weight”, so that it doesn’t have OS’s own title bar, but something simpler created by myself.

The first thing that came to my mind was to just use juce::TopLevelWindow and turn off it’s title bar with setUsingNativeTitleBar(false). This obviously doesn’t let the user drag the window anymore. So to make the window draggable again, I read the mouse up/down/drag and set its own bounds so it can be dragged. This unfortunately created noticeable lag in dragging which isn’t present in regular windows, so it’s a no-go.

Is there some other obvious option I’ve missed which lets me design my own drag bar and get proper low lag for window dragging around the screen?

I was going to suggest the solution you tried, but obviously it isn’t working for you. I can’t think of anything inherint to the process that would cause it, so I wonder if there is someting (a sort of event feedback loop?) that is slowing things down? like two pieces of code competing to set window position. maybe you could do some measuring to see where the time seems to be going?

I think it will work if you use a DocumentWindow and set Native Title Bar to false. Then you will get the Juce Title Bar, and you can customize it with the LookAndFeel methods.

This is interesting:
When I use the native title bar, there’s no lag.
But when I don’t use the native title bar, there is lag by default in JUCE’s own implementation.

I found a fix:

The lag appears when you have the following settings in effect:

  • The window has been added to the desktop instead of having a parent Component.
  • The window uses JUCE’s own title bar instead of native title bar.

So when I set “bool addToDesktop = false” in the window’s constructor and use parentComponent->addAndMakeVisible(windowComponent), the lag disappears.