I just got it to work.
Bear with me on the explanation. My situation was that I have two sliders.
A rotary slider and an IncDec Slider. The GUI requirements are that
- We have an IncDec slider that displays values
- A Rotary Slider that does not display values.
They both refer to the same information. It’s just that we want to give the user two methods of adjusting the values (using a knob, or using an incDec button)
[Credit: to @daniel for the code provided Custom Label ]
void updateFrequency()
{
//---------------------------------------------------------------------
NormalisableRange<double> newRange(
MIN,
MAX,
// maps real value to 0..1
nullptr,
// maps 0..1 values to real world
nullptr,
// maps real world to legal real world
[](auto rangeStart, auto rangeEnd, auto valueToRemap)
{
if (valueToRemap <= SomeVal)
{
return juce::jlimit(rangeStart, rangeEnd, SomeVal);
}
else if (valueToRemap > SomeVal && valueToRemap <= BiggerVal)
{
return jlimit(rangeStart, rangeEnd, BiggerVal);
}
else
{
return jlimit(rangeStart, rangeEnd, MAX);
}
});
rotarySlider.setNormalisableRange(newRange); // Slider with no Textbox
incDecSlider.setNormalisableRange(newRange); // Slider with a visible Textbox
incDecSlider.setRange(MIN, MAX, 0.00000001); // I arbitrarily chose the step value.
incDecSlider.getValueObject().referTo(rotarySlider.getValueObject());
}