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.

144 lines
4.3KB

  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. #include "dgl/ImageAboutWindow.hpp"
  18. START_NAMESPACE_DISTRHO
  19. // -------------------------------------------------
  20. DistrhoUIPingPongPan::DistrhoUIPingPongPan()
  21. : OpenGLUI(),
  22. fAboutWindow(this)
  23. {
  24. // background
  25. fImgBackground = Image(DistrhoArtworkPingPongPan::backgroundData, DistrhoArtworkPingPongPan::backgroundWidth, DistrhoArtworkPingPongPan::backgroundHeight, GL_BGR);
  26. Image imageAbout(DistrhoArtworkPingPongPan::aboutData, DistrhoArtworkPingPongPan::aboutWidth, DistrhoArtworkPingPongPan::aboutHeight, GL_BGR);
  27. fAboutWindow.setImage(imageAbout);
  28. // knobs
  29. Image knobImage(DistrhoArtworkPingPongPan::knobData, DistrhoArtworkPingPongPan::knobWidth, DistrhoArtworkPingPongPan::knobHeight);
  30. // knob Low-Mid
  31. fKnobFreq = new ImageKnob(this, knobImage);
  32. fKnobFreq->setPos(61, 59);
  33. fKnobFreq->setRange(0.0f, 100.0f);
  34. fKnobFreq->setValue(50.0f);
  35. fKnobFreq->setCallback(this);
  36. // knob Mid-High
  37. fKnobWidth = new ImageKnob(this, knobImage);
  38. fKnobWidth->setPos(183, 59);
  39. fKnobWidth->setRange(0.0f, 100.0f);
  40. fKnobWidth->setValue(75.0f);
  41. fKnobWidth->setCallback(this);
  42. // about button
  43. Image aboutImageNormal(DistrhoArtworkPingPongPan::aboutButtonNormalData, DistrhoArtworkPingPongPan::aboutButtonNormalWidth, DistrhoArtworkPingPongPan::aboutButtonNormalHeight);
  44. Image aboutImageHover(DistrhoArtworkPingPongPan::aboutButtonHoverData, DistrhoArtworkPingPongPan::aboutButtonHoverWidth, DistrhoArtworkPingPongPan::aboutButtonHoverHeight);
  45. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  46. fButtonAbout->setPos(183, 8);
  47. fButtonAbout->setCallback(this);
  48. }
  49. DistrhoUIPingPongPan::~DistrhoUIPingPongPan()
  50. {
  51. delete fKnobFreq;
  52. delete fKnobWidth;
  53. delete fButtonAbout;
  54. }
  55. // -------------------------------------------------
  56. // DSP Callbacks
  57. void DistrhoUIPingPongPan::d_parameterChanged(uint32_t index, float value)
  58. {
  59. switch (index)
  60. {
  61. case DistrhoPluginPingPongPan::paramFreq:
  62. fKnobFreq->setValue(value);
  63. break;
  64. case DistrhoPluginPingPongPan::paramWidth:
  65. fKnobWidth->setValue(value);
  66. break;
  67. }
  68. }
  69. void DistrhoUIPingPongPan::d_programChanged(uint32_t index)
  70. {
  71. if (index != 0)
  72. return;
  73. // Default values
  74. fKnobFreq->setValue(50.0f);
  75. fKnobWidth->setValue(75.0f);
  76. }
  77. // -------------------------------------------------
  78. // Widget Callbacks
  79. void DistrhoUIPingPongPan::imageButtonClicked(ImageButton* button, int)
  80. {
  81. if (button != fButtonAbout)
  82. return;
  83. fAboutWindow.exec();
  84. }
  85. void DistrhoUIPingPongPan::imageKnobDragStarted(ImageKnob* knob)
  86. {
  87. if (knob == fKnobFreq)
  88. d_editParameter(DistrhoPluginPingPongPan::paramFreq, true);
  89. else if (knob == fKnobWidth)
  90. d_editParameter(DistrhoPluginPingPongPan::paramWidth, true);
  91. }
  92. void DistrhoUIPingPongPan::imageKnobDragFinished(ImageKnob* knob)
  93. {
  94. if (knob == fKnobFreq)
  95. d_editParameter(DistrhoPluginPingPongPan::paramFreq, false);
  96. else if (knob == fKnobWidth)
  97. d_editParameter(DistrhoPluginPingPongPan::paramWidth, false);
  98. }
  99. void DistrhoUIPingPongPan::imageKnobValueChanged(ImageKnob* knob, float value)
  100. {
  101. if (knob == fKnobFreq)
  102. d_setParameterValue(DistrhoPluginPingPongPan::paramFreq, value);
  103. else if (knob == fKnobWidth)
  104. d_setParameterValue(DistrhoPluginPingPongPan::paramWidth, value);
  105. }
  106. void DistrhoUIPingPongPan::onDisplay()
  107. {
  108. fImgBackground.draw();
  109. }
  110. // -------------------------------------------------
  111. UI* createUI()
  112. {
  113. return new DistrhoUIPingPongPan();
  114. }
  115. // -------------------------------------------------
  116. END_NAMESPACE_DISTRHO