Collection of DPF-based plugins for packaging
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.

119 lines
3.8KB

  1. /*
  2. * DISTRHO AmplitudeImposer, a DPF'ied AmplitudeImposer.
  3. * Copyright (C) 2004 Niall Moody
  4. * Copyright (C) 2015-2021 Filipe Coelho <falktx@falktx.com>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. * DEALINGS IN THE SOFTWARE.
  23. */
  24. #include "DistrhoUIAmplitudeImposer.hpp"
  25. #include "DistrhoPluginAmplitudeImposer.hpp"
  26. START_NAMESPACE_DISTRHO
  27. namespace Art = DistrhoArtworkAmplitudeImposer;
  28. // -----------------------------------------------------------------------
  29. DistrhoUIAmplitudeImposer::DistrhoUIAmplitudeImposer()
  30. : UI(Art::backWidth, Art::backHeight, true),
  31. fImgBackground(Art::backData, Art::backWidth, Art::backHeight, kImageFormatGrayscale)
  32. {
  33. // sliders
  34. Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight, kImageFormatGrayscale);
  35. fSliderDepth = new ImageSlider(this, sliderImage);
  36. fSliderDepth->setId(DistrhoPluginAmplitudeImposer::kParameterDepth);
  37. fSliderDepth->setStartPos(108, 71);
  38. fSliderDepth->setEndPos(268, 71);
  39. fSliderDepth->setRange(0.0f, 1.0f);
  40. fSliderDepth->setCallback(this);
  41. fSliderThres = new ImageSlider(this, sliderImage);
  42. fSliderThres->setId(DistrhoPluginAmplitudeImposer::kParameterThreshold);
  43. fSliderThres->setStartPos(108, 110);
  44. fSliderThres->setEndPos(268, 110);
  45. fSliderThres->setRange(0.0f, 1.0f);
  46. fSliderThres->setCallback(this);
  47. // set initial values
  48. programLoaded(0);
  49. }
  50. // -----------------------------------------------------------------------
  51. // DSP Callbacks
  52. void DistrhoUIAmplitudeImposer::parameterChanged(uint32_t index, float value)
  53. {
  54. switch (index)
  55. {
  56. case DistrhoPluginAmplitudeImposer::kParameterDepth:
  57. fSliderDepth->setValue(value);
  58. break;
  59. case DistrhoPluginAmplitudeImposer::kParameterThreshold:
  60. fSliderThres->setValue(value);
  61. break;
  62. }
  63. }
  64. void DistrhoUIAmplitudeImposer::programLoaded(uint32_t index)
  65. {
  66. if (index != 0)
  67. return;
  68. fSliderDepth->setValue(1.0f);
  69. fSliderThres->setValue(0.5f);
  70. }
  71. // -----------------------------------------------------------------------
  72. // Widget Callbacks
  73. void DistrhoUIAmplitudeImposer::imageSliderDragStarted(ImageSlider* slider)
  74. {
  75. editParameter(slider->getId(), true);
  76. }
  77. void DistrhoUIAmplitudeImposer::imageSliderDragFinished(ImageSlider* slider)
  78. {
  79. editParameter(slider->getId(), false);
  80. }
  81. void DistrhoUIAmplitudeImposer::imageSliderValueChanged(ImageSlider* slider, float value)
  82. {
  83. setParameterValue(slider->getId(), value);
  84. }
  85. void DistrhoUIAmplitudeImposer::onDisplay()
  86. {
  87. const GraphicsContext& context(getGraphicsContext());
  88. fImgBackground.draw(context);
  89. }
  90. // -----------------------------------------------------------------------
  91. UI* createUI()
  92. {
  93. return new DistrhoUIAmplitudeImposer();
  94. }
  95. // -----------------------------------------------------------------------
  96. END_NAMESPACE_DISTRHO