Cabbage Logo
Back to Cabbage Site

Titlebar color

I noticed that in the last Cabbage releases, the titlebar (and the contour of the window) of the running Cabbage plugin is grey, instead of the previous black.

I think the synth/fx developer should have an option to change the window/titlebar color of the Cabbage plugin. For example, in my case, for the graphics of my experimental synth interface, black was more suited.

So, I searched in the Cabbage source code and I found where you can change this:

For example, if you change the line 48 with this:

48|                     Colour(0, 0, 0),/*LookAndFeel::getDefaultLookAndFeel().findColour (ResizableWindow::backgroundColourId),*/

you’ll get back the black titlebar color.

Of course, it would be very nice if we could set this color with a ‘titlebarcolor(…)’ identifier of the form widget (and I noticed that identifier already exists in the source code but actually it’s not used).
I tried to make it work but I could not do it because I have no access to a ValueTree widgetData inside that function…

I think this can be done in another way. I’ll take a look tomorrow.

Being that I’m not a C++ expert and I don’t know how the Juce framework works, it was not so easy but I managed to make it work…

Now you can use the ‘titlebarcolour’ identifier to set the titlebar and border colors of your plugin window, independently from the ‘form’ background color (that you can always set with the ‘colour’ identifier).
I set the default color for the titlebar from the function “CabbageUtilities::getBackgroundSkin()”.

I made a PR. :wink:

Merged :wink:

Another thing that bugged me was that with the previous Cabbage you could make a void titlebar but actually you cannot do that anymore… With the caption("") there will always be an “Untitled” string in the titlebar. I tried with caption(" ") too, but it didn’t worked because in the Cabbage source code that string is trimmered to remove all the initial whitespaces (is there some specific reason you trimmed the titlebar caption string too?).

Sometimes you want just a void titlebar, because it’s more appropriated for your plugin graphics style. For example:

So, I modded the code to make it so that when you use:

form caption("") ...

or don’t use the caption identifier at all, there will be an “Untitled” title, like before. But if you use:

form caption(" ") ...

the title will be void, just like in the above example (window on the right).

If there aren’t specific reasons to make the titlebar always named, I can make a PR with the mods.

P.S.: I don’t know why Juce automatically adds that little vertical gradient to the titlebar. I would like to choice if I want it. Do you know if it can be avoided?

One has to be careful about that as the caption sets the plugin name in certain hosts, including Cabbage itself If I recall correctly. I think it might be safer to just have a way of setting the fontcolour() for the title? Then one can just do fontcolour(0,0,0,0). The fontcolour() identifier already exists, so it should be relatively simple to get this going.

When it comes to graphics, everything can be modified. You’ll need to look at the JUCE and Cabbage look and feel classes.

I didn’t thought of that… Yes, it could be safer to just set the alpha color of the titlebar font to a zero. Nice suggestion! I will try that when I have a little more time.

Following your suggestion I made some changes to use the “fontcolour” identifier in the form widget too.

I noticed that the behavior of Juce default lookandfeel of the DocumentWindow class is that the color of the font is calculated based on the background color, to make it always visible over it. With my changes, you can override this behavior by using the fontcolour identifier and set the exact color you want. So, now it’s also possible to make a transparent title without removing the plugin name.

Then I added the possibility to alter that light gradient Juce automatically generates in the titlebar of the plugin window (to make that, I added the drawDocumentWindowTitleBar method to the CabbageLookAndFeel2 class and set the PluginWindow component to use the lookandfeel facilities defined in CabbageLookAndFeel2).

To alter the gradient, I added (always to the form widget) the identifier “titlebargradientamount” that is just a value in the range from 0 to 1.

0 is for NO gradient.
1 is for MAX contrast in the generated gradient.

The value hard-coded in the default Juce lookandfeel used by the DocumentWindow class was 0.15, so I left it as a default.

Just made a PR. :wink:

Cool. Do you think you could make the identifier titlebargradient() instead of titlebatgradientamount() which seems a little long. Most identifiers specify an amount of something, alpha, rotation, etc, yet we never use amount in the identifier. If this is Ok with you just update your sources, it will automatically appear in the PR. You shouldn’t have to make a whole new PR for that. Thanks.

I know it’s long, but I added ‘amount’ because I wanted to make it clear that it’s not a colour value (like you could expect from the “gradient” word), but a float value in the range [0…1]. Anyway if you confirm it, I can remove it and leave just titlebargradient.

The current convention is that all colour identifiers have the word color in their title. Anyway, I can never bite and update that myself later. Thanks again. Oh wait, I won’t be able to meet till tomorrow, but I will. Thanks again.

Ok I will change it. :wink:

I changed the relevant files via github from web and you too should see the mods in the pull request, but now I’m in office and cannot compile to check if the mod from titlebargradientamount to titlebargradient works. I can see it later when I come back home.

Testing ok. It works! :slight_smile:

Thanks. I’ll merge tomorrow :wink:

Sorry, I made another little mod because I found that when you use the fontcolour(…) identifier to set the colour you want for the titlebar, if the plugin window was not focused, the titlebar colour didn’t change and that was visually strange… So I changed the code to make the titlebar text colour less contrasted when is out of focus when you use the fontcolour identifier too, exactly as it does with the default behavior. I pushed it on github.

1 Like