Reverse Slider Direction


#1

Hello,

I am trying to create a slider that will increase in value as the slider handle is dragged down (or left).  There doesn't appear to be any property I can set to do this, so I'm wondering if I need to go ahead and extend the Slider class to do this behavior or if there is an easier way?

Thanks,

Jason


#2

#ifndef SLIDER_REVERSE_H
#define SLIDER_REVERSE_H
class Slider_reverse : public JUCE_NAMESPACE::Slider
{
public:
    Slider_reverse (const String& componentName): JUCE_NAMESPACE::Slider(componentName) {};
    ~Slider_reverse() {};
    double proportionOfLengthToValue (double proportion) {   return JUCE_NAMESPACE::Slider::proportionOfLengthToValue(1.0f-proportion);};
    double valueToProportionOfLength (double value) {   return 1.0f-(JUCE_NAMESPACE::Slider::valueToProportionOfLength(value)); };    
};
#endif // SLIDER_REVERSE_H



#3

what about rotating the Slider by Pi using an AffineTransform around its centre?


#4

The derived class worked perfectly.  I didn't noticed those methods when I was looking at the Slider class.

 

J


#5

Rotating will make things such as text to look different. One wouldn’t want the text rotated…


#6

You could also implement a custom lookandfeel for the Slider in which you change the way it paints. Benefit is that you don’t need to use a derived class.


#7

Do you know where and how to implement this to a slider parameter listener?

Editor vs Processor side?


#8

I ended up just throwing it in a custom slider class, works like a dream!

Thanks,