Bug in Slider colour

Hi, there is a bug in Juc e 7.0.5. When creating a LinearBarVertical or Horizontal, you can not change the background colour. The issue is in drawLinearSlider, where for slider.isBar no background is drawn.

Thomas

Hi @conTimbre, thanks for posting. It’s far from clear but I think this may have been intentional, even if it’s unintuitive. Unfortunately unless I’m mistaken changing this would likely break many others GUI code. Therefore it’s unlikely we’ll change this now. Probably the easiest thing you can do is…

  • override drawLinearSlider() in your derived LookAndFeel class
  • If the slider is a bar fill the background
  • Call drawLinearSlider() in your base LookAndFeel class

Something like this should do it…

class MyLookAndFeelClass : public LookAndFeel_V4
{
    void drawLinearSlider (Graphics& g, int x, int y, int width, int height,
                           float sliderPos, float minSliderPos, float maxSliderPos,
                           const Slider::SliderStyle style, Slider& slider) override
    {
        if (slider.isBar())
        {
            g.setColour (slider.findColour (Slider::ColourIds::backgroundColourId));
            g.fillRect (x, y, width, height);
        }

        LookAndFeel_V4::drawLinearSlider (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
    }
};
1 Like

Hi Anthony,

thank you for the comment. I forgot to mention that the problem arises in LookAndFeel_V4.
But look into LookAndFeel_V3::drawLinearSlider

It’s working in V3. It’s not working in V4.

Best Thomas