DISTRHO ndc Plugs
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.7KB

  1. /*
  2. * DISTRHO CycleShifter, a DPF'ied CycleShifter.
  3. * Copyright (C) 2004 Niall Moody
  4. * Copyright (C) 2015 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 "DistrhoUICycleShifter.hpp"
  25. #include "DistrhoPluginCycleShifter.hpp"
  26. START_NAMESPACE_DISTRHO
  27. namespace Art = DistrhoArtworkCycleShifter;
  28. // -----------------------------------------------------------------------
  29. DistrhoUICycleShifter::DistrhoUICycleShifter()
  30. : UI(Art::backWidth, Art::backHeight),
  31. fImgBackground(Art::backData, Art::backWidth, Art::backHeight, GL_LUMINANCE)
  32. {
  33. // sliders
  34. Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight, GL_LUMINANCE);
  35. fSliderNewCycleVol = new ImageSlider(this, sliderImage);
  36. fSliderNewCycleVol->setId(DistrhoPluginCycleShifter::kParameterNewCycleVolume);
  37. fSliderNewCycleVol->setStartPos(6, 49);
  38. fSliderNewCycleVol->setEndPos(247, 49);
  39. fSliderNewCycleVol->setRange(0.0f, 1.0f);
  40. fSliderNewCycleVol->setCallback(this);
  41. fSliderInputVol = new ImageSlider(this, sliderImage);
  42. fSliderInputVol->setId(DistrhoPluginCycleShifter::kParameterInputVolume);
  43. fSliderInputVol->setStartPos(6, 80);
  44. fSliderInputVol->setEndPos(247, 80);
  45. fSliderInputVol->setRange(0.0f, 1.0f);
  46. fSliderInputVol->setCallback(this);
  47. // set initial values
  48. programLoaded(0);
  49. }
  50. // -----------------------------------------------------------------------
  51. // DSP Callbacks
  52. void DistrhoUICycleShifter::parameterChanged(uint32_t index, float value)
  53. {
  54. switch (index)
  55. {
  56. case DistrhoPluginCycleShifter::kParameterNewCycleVolume:
  57. fSliderNewCycleVol->setValue(value);
  58. break;
  59. case DistrhoPluginCycleShifter::kParameterInputVolume:
  60. fSliderInputVol->setValue(value);
  61. break;
  62. }
  63. }
  64. void DistrhoUICycleShifter::programLoaded(uint32_t index)
  65. {
  66. switch(index)
  67. {
  68. case 0:
  69. fSliderNewCycleVol->setValue(1.0f);
  70. fSliderInputVol->setValue(1.0f);
  71. break;
  72. }
  73. }
  74. // -----------------------------------------------------------------------
  75. // Widget Callbacks
  76. void DistrhoUICycleShifter::imageSliderDragStarted(ImageSlider* slider)
  77. {
  78. editParameter(slider->getId(), true);
  79. }
  80. void DistrhoUICycleShifter::imageSliderDragFinished(ImageSlider* slider)
  81. {
  82. editParameter(slider->getId(), false);
  83. }
  84. void DistrhoUICycleShifter::imageSliderValueChanged(ImageSlider* slider, float value)
  85. {
  86. setParameterValue(slider->getId(), value);
  87. }
  88. void DistrhoUICycleShifter::onDisplay()
  89. {
  90. fImgBackground.draw();
  91. }
  92. // -----------------------------------------------------------------------
  93. UI* createUI()
  94. {
  95. return new DistrhoUICycleShifter();
  96. }
  97. // -----------------------------------------------------------------------
  98. END_NAMESPACE_DISTRHO