Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

juce_SliderPropertyComponent.cpp 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. SliderPropertyComponent::SliderPropertyComponent (const String& name,
  16. const double rangeMin,
  17. const double rangeMax,
  18. const double interval,
  19. const double skewFactor,
  20. bool symmetricSkew)
  21. : PropertyComponent (name)
  22. {
  23. addAndMakeVisible (slider);
  24. slider.setRange (rangeMin, rangeMax, interval);
  25. slider.setSkewFactor (skewFactor, symmetricSkew);
  26. slider.setSliderStyle (Slider::LinearBar);
  27. slider.onValueChange = [this]
  28. {
  29. if (getValue() != slider.getValue())
  30. setValue (slider.getValue());
  31. };
  32. }
  33. SliderPropertyComponent::SliderPropertyComponent (const Value& valueToControl,
  34. const String& name,
  35. const double rangeMin,
  36. const double rangeMax,
  37. const double interval,
  38. const double skewFactor,
  39. bool symmetricSkew)
  40. : PropertyComponent (name)
  41. {
  42. addAndMakeVisible (slider);
  43. slider.setRange (rangeMin, rangeMax, interval);
  44. slider.setSkewFactor (skewFactor, symmetricSkew);
  45. slider.setSliderStyle (Slider::LinearBar);
  46. slider.getValueObject().referTo (valueToControl);
  47. }
  48. SliderPropertyComponent::~SliderPropertyComponent()
  49. {
  50. }
  51. void SliderPropertyComponent::setValue (const double /*newValue*/)
  52. {
  53. }
  54. double SliderPropertyComponent::getValue() const
  55. {
  56. return slider.getValue();
  57. }
  58. void SliderPropertyComponent::refresh()
  59. {
  60. slider.setValue (getValue(), dontSendNotification);
  61. }
  62. } // namespace juce