1 /*
2   ==============================================================================
3 
4    This file is part of the JUCE library.
5    Copyright (c) 2020 - Raw Material Software Limited
6 
7    JUCE is an open source library subject to commercial or open-source
8    licensing.
9 
10    By using JUCE, you agree to the terms of both the JUCE 6 End-User License
11    Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
12 
13    End User License Agreement: www.juce.com/juce-6-licence
14    Privacy Policy: www.juce.com/juce-privacy-policy
15 
16    Or: You may also use this code under the terms of the GPL v3 (see
17    www.gnu.org/licenses).
18 
19    JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20    EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21    DISCLAIMED.
22 
23   ==============================================================================
24 */
25 
26 namespace juce
27 {
28 
29 //==============================================================================
30 /**
31     A PropertyComponent that shows its value as a slider.
32 
33     @see PropertyComponent, Slider
34 
35     @tags{GUI}
36 */
37 class JUCE_API  SliderPropertyComponent   : public PropertyComponent
38 {
39 protected:
40     //==============================================================================
41     /** Creates the property component.
42 
43         The ranges, interval and skew factor are passed to the Slider component.
44 
45         If you need to customise the slider in other ways, your constructor can
46         access the slider member variable and change it directly.
47     */
48     SliderPropertyComponent (const String& propertyName,
49                              double rangeMin,
50                              double rangeMax,
51                              double interval,
52                              double skewFactor = 1.0,
53                              bool symmetricSkew = false);
54 
55 public:
56     //==============================================================================
57     /** Creates the property component.
58 
59         The ranges, interval and skew factor are passed to the Slider component.
60 
61         If you need to customise the slider in other ways, your constructor can
62         access the slider member variable and change it directly.
63 
64         Note that if you call this constructor then you must use the Value to interact with
65         the value, and you can't override the class with your own setValue or getValue methods.
66         If you want to use those methods, call the other constructor instead.
67     */
68     SliderPropertyComponent (const Value& valueToControl,
69                              const String& propertyName,
70                              double rangeMin,
71                              double rangeMax,
72                              double interval,
73                              double skewFactor = 1.0,
74                              bool symmetricSkew = false);
75 
76     /** Destructor. */
77     ~SliderPropertyComponent() override;
78 
79 
80     //==============================================================================
81     /** Called when the user moves the slider to change its value.
82 
83         Your subclass must use this method to update whatever item this property
84         represents.
85     */
86     virtual void setValue (double newValue);
87 
88     /** Returns the value that the slider should show. */
89     virtual double getValue() const;
90 
91 
92     //==============================================================================
93     /** @internal */
94     void refresh() override;
95 
96 protected:
97     /** The slider component being used in this component.
98         Your subclass has access to this in case it needs to customise it in some way.
99     */
100     Slider slider;
101 
102 private:
103     //==============================================================================
104     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SliderPropertyComponent)
105 };
106 
107 } // namespace juce
108