From c72cf7ed647b450911e10a5ff4974e8fcbd1d766 Mon Sep 17 00:00:00 2001 From: hogliux Date: Mon, 12 Feb 2018 09:21:08 +0000 Subject: [PATCH] Added Slider method to modify the number of decimal places that are displayed in a slider's text box --- modules/juce_gui_basics/widgets/juce_Slider.cpp | 6 ++++++ modules/juce_gui_basics/widgets/juce_Slider.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 50e0972274..f771671446 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -1615,6 +1615,12 @@ double Slider::snapValue (double attemptedValue, DragMode) int Slider::getNumDecimalPlacesToDisplay() const noexcept { return pimpl->numDecimalPlaces; } +void Slider::setNumDecimalPlacesToDisplay (int decimalPlacesToDisplay) +{ + pimpl->numDecimalPlaces = decimalPlacesToDisplay; + updateText(); +} + //============================================================================== int Slider::getThumbBeingDragged() const noexcept { return pimpl->sliderBeingDragged; } void Slider::startedDragging() {} diff --git a/modules/juce_gui_basics/widgets/juce_Slider.h b/modules/juce_gui_basics/widgets/juce_Slider.h index f21f9d9241..d196cb7b68 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.h +++ b/modules/juce_gui_basics/widgets/juce_Slider.h @@ -746,9 +746,18 @@ public: slider's value. It calculates the fewest decimal places needed to represent numbers with the slider's interval setting. + + @see setNumDecimalPlacesToDisplay */ int getNumDecimalPlacesToDisplay() const noexcept; + /** Modifies the best number of decimal places to use when displaying this + slider's value. + + @see getNumDecimalPlacesToDisplay + */ + void setNumDecimalPlacesToDisplay (int decimalPlacesToDisplay); + //============================================================================== /** Allows a user-defined mapping of distance along the slider to its value.