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.

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