Change custom slider mouse drag direction

Hi guys,

I have a custom slider class that uses a filmstrip skin. The slider can be created and used just fine, however, the mouse dragging direction is currently horizontal, how can I change this to vertical?

My custom slider class can be seen below.

Thanks! :slightly_smiling_face:

class Knob : public juce::Slider
{
public:
    Knob(juce::Image stripToShow)
        : filmStrip(stripToShow)
    {
        //Assumes square frames
        filmStripWidth  = filmStrip.getWidth();
        numFrames = filmStrip.getHeight() / filmStripWidth;
    }
    void paint(juce::Graphics &g) override
    {
        std::size_t imageNumber = static_cast<std::size_t>(0.5 + (getValue() - getMinimum()) / (getMaximum() - getMinimum()) * (numFrames - 1));
        g.drawImage(filmStrip, 0, 0, filmStripWidth, filmStripWidth, 0, imageNumber * filmStripWidth, filmStripWidth, filmStripWidth);
    }
    std::size_t getFilmStripWidth() { return filmStripWidth; }
private:
    std::size_t numFrames, filmStripWidth;
    juce::Image filmStrip;
};

Take a look at Slider::setSliderStyle.

Speaking of which, last time I checked, I found no easy way to reverse the orientation of a linear slider. Is there a way do to so with the API?

1 Like