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.

139 lines
4.1KB

  1. /*
  2. * DISTRHO PingPongPan Plugin, based on PingPongPan by Michael Gruhn
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * For a full copy of the license see the LGPL.txt file
  15. */
  16. #include "DistrhoUIPingPongPan.hpp"
  17. START_NAMESPACE_DISTRHO
  18. // -------------------------------------------------
  19. DistrhoUIPingPongPan::DistrhoUIPingPongPan()
  20. : OpenGLExtUI()
  21. {
  22. // background
  23. Image bgImage(DistrhoArtworkPingPongPan::backgroundData, DistrhoArtworkPingPongPan::backgroundWidth, DistrhoArtworkPingPongPan::backgroundHeight, GL_BGRA);
  24. setBackgroundImage(bgImage);
  25. // knobs
  26. Image knobImage(DistrhoArtworkPingPongPan::knobData, DistrhoArtworkPingPongPan::knobWidth, DistrhoArtworkPingPongPan::knobHeight);
  27. Point knobPos(136, 30);
  28. // knob Low-Mid
  29. knobFreq = new ImageKnob(knobImage, knobPos);
  30. knobFreq->setRange(0.0f, 100.0f);
  31. knobFreq->setValue(50.0f);
  32. addImageKnob(knobFreq);
  33. // knob Mid-High
  34. knobPos.setX(258);
  35. knobWidth = new ImageKnob(knobImage, knobPos);
  36. knobWidth->setRange(0.0f, 100.0f);
  37. knobWidth->setValue(75.0f);
  38. addImageKnob(knobWidth);
  39. // about button
  40. Image aboutImageNormal(DistrhoArtworkPingPongPan::aboutButtonNormalData, DistrhoArtworkPingPongPan::aboutButtonNormalWidth, DistrhoArtworkPingPongPan::aboutButtonNormalHeight);
  41. Image aboutImageHover(DistrhoArtworkPingPongPan::aboutButtonHoverData, DistrhoArtworkPingPongPan::aboutButtonHoverWidth, DistrhoArtworkPingPongPan::aboutButtonHoverHeight);
  42. Point aboutPos(25, 23);
  43. buttonAbout = new ImageButton(aboutImageNormal, aboutImageHover, aboutImageHover, aboutPos);
  44. addImageButton(buttonAbout);
  45. }
  46. DistrhoUIPingPongPan::~DistrhoUIPingPongPan()
  47. {
  48. delete knobFreq;
  49. delete knobWidth;
  50. delete buttonAbout;
  51. }
  52. // -------------------------------------------------
  53. // DSP Callbacks
  54. void DistrhoUIPingPongPan::d_parameterChanged(uint32_t index, float value)
  55. {
  56. switch (index)
  57. {
  58. case DistrhoPluginPingPongPan::paramFreq:
  59. knobFreq->setValue(value);
  60. break;
  61. case DistrhoPluginPingPongPan::paramWidth:
  62. knobWidth->setValue(value);
  63. break;
  64. }
  65. d_uiRepaint();
  66. }
  67. void DistrhoUIPingPongPan::d_programChanged(uint32_t index)
  68. {
  69. if (index != 0)
  70. return;
  71. // Default values
  72. knobFreq->setValue(50.0f);
  73. knobWidth->setValue(75.0f);
  74. d_uiRepaint();
  75. }
  76. // -------------------------------------------------
  77. // Extended Callbacks
  78. void DistrhoUIPingPongPan::imageButtonClicked(ImageButton* button)
  79. {
  80. if (button != buttonAbout)
  81. return;
  82. Image imageAbout(DistrhoArtworkPingPongPan::aboutData, DistrhoArtworkPingPongPan::aboutWidth, DistrhoArtworkPingPongPan::aboutHeight, GL_BGRA);
  83. showImageModalDialog(imageAbout, "About");
  84. }
  85. void DistrhoUIPingPongPan::imageKnobDragStarted(ImageKnob* knob)
  86. {
  87. if (knob == knobFreq)
  88. d_uiEditParameter(DistrhoPluginPingPongPan::paramFreq, true);
  89. else if (knob == knobWidth)
  90. d_uiEditParameter(DistrhoPluginPingPongPan::paramWidth, true);
  91. }
  92. void DistrhoUIPingPongPan::imageKnobDragFinished(ImageKnob* knob)
  93. {
  94. if (knob == knobFreq)
  95. d_uiEditParameter(DistrhoPluginPingPongPan::paramFreq, false);
  96. else if (knob == knobWidth)
  97. d_uiEditParameter(DistrhoPluginPingPongPan::paramWidth, false);
  98. }
  99. void DistrhoUIPingPongPan::imageKnobValueChanged(ImageKnob* knob, float value)
  100. {
  101. if (knob == knobFreq)
  102. d_setParameterValue(DistrhoPluginPingPongPan::paramFreq, value);
  103. else if (knob == knobWidth)
  104. d_setParameterValue(DistrhoPluginPingPongPan::paramWidth, value);
  105. }
  106. // -------------------------------------------------
  107. UI* createUI()
  108. {
  109. return new DistrhoUIPingPongPan;
  110. }
  111. // -------------------------------------------------
  112. END_NAMESPACE_DISTRHO