Why can't I get Slider NormalisableRange?

Hello,
there are methods:
Slider::setRange()
Slider::setNormalisableRange()
and:
Slider::getRange()

But I wonder where the hell is Slider::getNormalisableRange(). I am pretty sure there is some good reason for that, but I can’t find that reason and that’s why missing Slider::getNormalisableRange() frustrates me very hard.

For any help great thanks in advance.
Best Regards.

And there is also related question (at least in my case related). To Slider::valueFromTextFunction I can pass parameter String as a number with unit and I am interpreting that properly, and if I get String just as a number and without unit I can also interprate that but I need to update my value text box to show the lacking unit. And that is done automaticaly when Slider::setValue() is called. But only if I call it with new value. But if old value is passed to setValue() then slider will not call any listeners because there is no changes so in the value box I get not updated value (without unit).

So I need to check by myself in the valueFromTextFunction if ongoing value is actually new value and if not then I need to update my value box by myself. But to make appropriate comparison I need to have access to sliders NormalisableRange and I don’t have that access.

So maybe there is any other method to check if passed value to Slider::setValue() will cause ane changes or not?

For any help great thanks in advance.

you could just get these things from the processor parameter directly

Thenks for your help. But let’s assume I don’t link my slider to any processor parameter?

I think it is a simple oversight. As a workaround you can keep the NormalisableRange as member yourself whenever you set it. But it is not ideal of course.
It would be nice if that getter could be added.

in that case I’d agree with daniel that a getter would indeed be a nice thing to have, but keeping a member of it yourself somewhere the current workaround

Hello, thanks for all you reply. And for advices. But it is still interesting why there isn’t such NormalisableRange getter for Slider. I suppose there is some good reason, and it is interesting for me what the reason it is?

By the way I also found out it would be very handy if Slider::setValue() would return some bool which could tell if any changes was done. Of course it’s just my opinion, but I found many cases when I would love to have such info.

You can easily achieve that:

if (slider.getValue() != newValue)
{
    slider.setValue (newValue);
    // and do what you needed the bool for
}

Hello Daniel, thanks but that doesn’t work because newValue often can be value which is not snapped to legal value. So to snap it by myself I need NormalisableRage.

it sounds like you basically want to instantiate a parameter, but instead of this parameter being owned by the processor, it’s just some parameter in the GUI. is that true? in that case you could just take juce::RangedAudioParameter and use it in the GUI. might not be the most intended way of using it, but I think it would work and you can let the attachment handle all the slider stuff. don’t make it complicated and modify all these Slider-functions when you don’t have to

you can use getInterval or getSkew separately.

Then you still miss the snap function or individual mapping function that the NormalisableRange may have…
But good point

I think it is a totally valid request to getNormalisableRange(), somebody at the juce team just needs to find the time to add those 5 lines.

Thanks for reporting, seemed a nice easy one to drop in at the end of a working day.

4 Likes