ulfl
May 21, 2024, 10:23pm
1
Hi!
I want to change the text colour on a linear bar slider. I have overrided the drawLinearSlider method and tried to set these colours in my LookAndFeel constructor:
setColour (Label::textColourId, Colours::black);
setColour (Label::textWhenEditingColourId, Colours::white);
setColour (Label::backgroundWhenEditingColourId, Colours::black);
setColour (Label::outlineWhenEditingColourId, Colours::black);
setColour (Slider::thumbColourId, Colours::white);
setColour (Slider::textBoxTextColourId, Colours::black);
setColour (Slider::textBoxBackgroundColourId, Colours::white);
setColour (Slider::trackColourId, Colours::grey);
But nothing works. The text is still white:
Any ideas?
Thanks,
ulfl
You may customize those colours by overriding drawLabel()
method.
Perhaps there is also a way to set it with those ColourIds. However, I am not familiar with them.
Just recently I also noticed similar anomalies in the text box of the linear sliders.
windows10, juce 8 branch.
new LookAndFeel settings work on the slider part, no effect on the text box.
the LookAndFeel does not update the new settings until you refresh it:
auto& laf = myGuiComponent.getLookAndFeel();
laf.setColour(Slider::ColourIds::backgroundColourId, Colours::red);
laf.setColour(Slider::trackColourId, Colours::green);
laf.setColour(Slider::thumbColourId, Colours::purple);
laf.setColour(Slider::ColourIds::textBoxOutlineColourId, Colours::white);
laf.setColour(Slider::textBoxBackgroundColourId, Colours::purple);
laf.setColour(Slider::textBoxTextColourId, Colours::black);
laf.setColour(Slider::textBoxHighlightColourId, Colours::red);
// refresh the LookAndFeel
myGuiComponent.setLookAndFeel(&laf);
same with:
auto& laf = juce::LookAndFeel::getDefaultLookAndFeel();
// ... your colors here
juce::LookAndFeel::setDefaultLookAndFeel(&laf);
ulfl
May 22, 2024, 9:15pm
4
Thanks for the help! I added this to my LookAndFeel class:
LookAndFeel() {
using namespace juce;
auto& lnf = getDefaultLookAndFeel();
lnf.setColour (Label::textColourId, Colours::black);
lnf.setColour (Label::textWhenEditingColourId, Colours::white);
lnf.setColour (Label::backgroundWhenEditingColourId, Colours::black);
lnf.setColour (Label::outlineWhenEditingColourId, Colours::black);
lnf.setColour (Slider::thumbColourId, Colours::white);
lnf.setColour (Slider::textBoxTextColourId, Colours::black);
lnf.setColour (Slider::textBoxBackgroundColourId, Colours::white);
lnf.setColour (Slider::trackColourId, Colours::grey);
}
That gives me the correct colors: