Ownerdrawn slider

Hi,

I could manage to draw my own slider background and thumb using lookandfeel but there is one thing what I couldn’t find out yet and where i need your help.
When I draw my own slider thumb, then the current slider value corresponds to the left hand side of my slider thumb. That means,
the slider value is 0 if the thumb is at the very left position of my slider. That’s fine.
But if I move the slider thumb to the max slider value, the thumb moves out of the graphics context and disappear.
I could of course keep the thumb inside the clip region by using code like this within the lookandfeel drawLinearSliderThumb method:

if (sliderPos > (width - linearFaderThumb->getWidth()))

  sliderPos = (float)(width - linearFaderThumb->getWidth());

but then the slider value still changes if the thumb hits the very right end of the drawing area.
So what I would like to do is either reducing the lenght of the slider “way” to get the max value if the right hand side of the slider thumb
hits the very right end of the drawing area or
drawing the thumb exactly at the position of the bubble thumb of a “no- lookandfeel” - slider because that behaves right.

Any idea?

Thank you in advance,
Joerg

Try this
MySlider.h

[code]#ifndef MYSLIDER_H
#define MYSLIDER_H
#include “includes.h”

//==============================================================================

class MySlider : public JUCE_NAMESPACE::Slider
{
public:
/** Creates a myslider.

    When created, you'll need to set up the slider's style and range with setSliderStyle(),
    setRange(), etc.
*/
MySlider (const String& componentName): JUCE_NAMESPACE::Slider(componentName) {};

/** Destructor. */
~MySlider() {};

//==============================================================================
/** User-defined mapping of distance along the slider to its value.

    The default implementation for this performs the skewing operation that
    can be set up in the setSkewFactor() method. Override it if you need
    some kind of custom mapping instead, but make sure you also implement the
    inverse function in valueToProportionOfLength().
	This implementation just reverses that.

    @param proportion       a value 0 to 1.0, indicating a distance along the slider
    @returns                the slider value that is represented by this position
    @see valueToProportionOfLength
*/
double proportionOfLengthToValue (double proportion) {	return JUCE_NAMESPACE::Slider::proportionOfLengthToValue(1.0f-proportion);};

/** User-defined mapping of value to the position of the slider along its length.

    The default implementation for this performs the skewing operation that
    can be set up in the setSkewFactor() method. Override it if you need
    some kind of custom mapping instead, but make sure you also implement the
    inverse function in proportionOfLengthToValue().
	This implementation just reverses that.

    @param value            a valid slider value, between the range of values specified in
                            setRange()
    @returns                a value 0 to 1.0 indicating the distance along the slider that
                            represents this value
    @see proportionOfLengthToValue
*/
double valueToProportionOfLength (double value) {	return 1.0f-(JUCE_NAMESPACE::Slider::valueToProportionOfLength(value)); };

};
#endif //MYSLIDER_H
[/code]

It doesn’t really help:-( It only changes the value direction. So I have now the min value where the max value should be
and the other way arround.

Any other idea?

Thanks
Joerg

Ah, sorry. I’d misunderstood

i’ll help you without helping you :slight_smile:

if you want to know how it’s done in juce look at the source, the LookAndFeel class in juce sources has all those problems solved, just look at that (that’s what i do)

i created a class that uses a filmstrip (images of a slider stiched together) if you’d like that.

Hello,

Finally I could manage this by looking at the juce source code.
For me as a beginner in C++, it is always very complicated to understand this language,
I therefore apologize for some silly questions sometimes.

Thank you for your input,
Joerg