I’m trying to change the outline color of a text box on a slider in an audio plugin project. When I call setColour(Slider::textBoxOutlineColourId, Colours::red);
it gives the slider text box a red outline on windows but makes it disappear on mac. Why is this happening? Here’s a minimal example:
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
constexpr auto PLUGIN_WIDTH = 400;
constexpr auto PLUGIN_HEIGHT = 200;
class MyLookAndFeel final : public LookAndFeel_V4 {
public:
MyLookAndFeel() : LookAndFeel_V4(getLightColourScheme()) {
setColour(Slider::textBoxOutlineColourId, Colours::red);
}
};
std::unique_ptr<MyLookAndFeel> laf(new MyLookAndFeel());
class MyAudioProcessorEditor final : public AudioProcessorEditor {
public:
MyAudioProcessorEditor
(AudioProcessor& p) : AudioProcessorEditor(&p), processor(p) {
setLookAndFeel(laf.get());
Component::lookAndFeelChanged();
slider1.setLookAndFeel(laf.get());
Component::lookAndFeelChanged();
addAndMakeVisible(slider1);
Component::lookAndFeelChanged();
setResizable(true, true);
setSize(PLUGIN_WIDTH, PLUGIN_HEIGHT);
}
~MyAudioProcessorEditor() = default;
void paint(Graphics& graphics) override {
graphics.fillAll(getLookAndFeel().findColour(ResizableWindow::backgroundColourId));
}
void resized() override {
auto bounds = Rectangle<int>(PLUGIN_WIDTH, PLUGIN_HEIGHT);
bounds.removeFromLeft(10);
bounds.removeFromRight(10);
bounds.removeFromTop(10);
const auto sliderRect = bounds.removeFromTop(20);
slider1.setBounds(sliderRect);
}
private:
MyLookAndFeel lookAndFeel;
AudioProcessor& processor;
Slider slider1;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MyAudioProcessorEditor)
};
class MyAudioProcessor final : public AudioProcessor {
public:
void processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiMessages) override { }
MyAudioProcessor() : AudioProcessor(
BusesProperties().withInput("Input", AudioChannelSet::stereo(), true).withOutput(
"Output", AudioChannelSet::stereo(), true)) { }
~MyAudioProcessor() = default;
void init(const double sampleRate) { };
void prepareToPlay(const double sampleRate, const int samplesPerBlock) override { init(sampleRate); }
void releaseResources() override { }
#ifndef JucePlugin_PreferredChannelConfigurations
bool isBusesLayoutSupported(const BusesLayout& layouts) const override { return true; }
#endif
AudioProcessorEditor* createEditor() override { return new MyAudioProcessorEditor(*this); }
bool hasEditor() const override { return true; }
const String getName() const override { return JucePlugin_Name; }
bool acceptsMidi() const override { return false; }
bool producesMidi() const override { return false; }
bool isMidiEffect() const override { return false; }
double getTailLengthSeconds() const override { return 0.0; }
int getNumPrograms() override { return 1; }
int getCurrentProgram() override { return 0; }
void setCurrentProgram(int index) override {}
const String getProgramName(int index) override { return {}; }
void changeProgramName(int index, const String& newName) override {}
void getStateInformation(MemoryBlock& destData) override {}
void setStateInformation(const void* data, const int sizeInBytes) override {}
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MyAudioProcessor)
};
For what it’s worth, this is also happening with many other colors pertaining to slider text boxes. You can effectively make slider text boxes disappear on mac by setting a bunch of custom colors.