How do I change the colour of the Titlebar? I tried using paint function in the DocumentWindow class but it didn’tdo anything.
juce::LookAndFeel_V4 uses the widgetBackground colour from juce::LookAndFeel_V4::ColourScheme for the titlebar colour:
If you already have a custom LookAndFeel class, then you can override the drawDocumentWindowTitleBar() method, or you could simply edit the colour scheme of the default LookAndFeel:
if (auto laf4 = dynamic_cast<juce::LookAndFeel_V4*> (&myComponent.getLookAndFeel()))
{
auto& colourScheme = laf4->getCurrentColourScheme();
colourScheme.setUIColour (juce::LookAndFeel_V4::ColourScheme::widgetBackground,
juce::Colours::pink);
}
Thank you. Is there a way to replace the titlebar buttons with custom imagebuttons?
Take a look at the docs for DocumentWindow::LookAndFeelMethods:
https://docs.juce.com/master/structDocumentWindow_1_1LookAndFeelMethods.html
This shows you everything you can override in a custom LookAndFeel class, for the buttons you can override juce::Button* createDocumentWindowButton (int buttonType) where the buttonType param is (I assume) values from the DocumentWindow::TitleBarButtons enum.
I did it like this but they tell me ‘Exception thrown: read access violation. e was nullptr.’ It seems to be caused by the ‘buttonType == DocumentWindow::closeButton’ but if I remove that line, it just replaces every titlebar button with the same imagebutton. Any ideas how to fix the error?
Button* createDocumentWindowButton(int buttonType)
{
if (buttonType == DocumentWindow::closeButton)
{
ImageButton* btn = new ImageButton();
Image normal = ImageCache::getFromMemory(BinaryData::icon_png, BinaryData::icon_pngSize);
Image over = ImageCache::getFromMemory(BinaryData::iconOver_png, BinaryData::iconOver_pngSize);
btn->setImages(true, true, true, normal, 1.0f, {}, over, 1.0f, {}, normal, 1.0f, {});
return btn;
}
}
Ok I found I can edit directly within the LookAndFeel class itself and it works perfectly now.
