Hello,
I have some problem that seems to be very easy to solve, but I can’t find the answer anywhere, probably my searching skills are not good
My slider textBox displays values like that fo example: 1.076553234. Can’t I round it any way? To show instead 1.08, or even 1.1, or just 1.
How to do that? Could any one help with that? In std library there is something like cout precision. But here I can’t find anything like that. For any help thanks in advance.
Great thanks I will check getValueToText()
But also other question I have and can’t find the answer. Can I set Slider to be step slider? I found in API Classes something like ThreeValueVertical. But what If I want 10 values? For example I have range from 0 to 100 and I want to slider jump every 10.
Thanks for your help I need to experiment. But actually I know AudioProcessorValueTreeState but as I can’t remember if there was any precision or step function setup
Use the Slider::setRange() method – lets you control max, min, and the interval that defines the granularity of the slider, so you could create this with code like
The display precision is controlled by the interval value passed to setRange() – check the source code (in the version I have installed here, it’s around line 117 in modules/juce_gui_basics/widgets/juce_Slider.cpp). It should automatically truncate at the correct precision.
Hah, great thanks for your support.
I already know that you can set: slider.setRange(0.0f, 100.0f, 10.0f)
But unfortunately it’s not what I am looking for. I would like the slider move and also slider.getValue() fluently, but I just want displayed value to be truncate at correct precision. Do you know what I mean?
Just in case the search sends somebody here, I would avoid setNumDecimalPlacesToDisplay() if you are connecting to a AudioParameterFloat, since you want the display consistent in host views and your sliders textbox. The configuration how to normalise and display is propagated from the parameter to the slider via the SliderAttachment.
If you don’t use an AudioParameter (because it’s not a plugin) or you don’t use the SliderAttachment, then setNumDecimalPlacesToDisplay is fine though.