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. {
  23. Window* win = getParent();
  24. // background
  25. fImgBackground = Image(DistrhoArtworkPingPongPan::backgroundData, DistrhoArtworkPingPongPan::backgroundWidth, DistrhoArtworkPingPongPan::backgroundHeight, GL_BGRA);
  26. // knobs
  27. Image knobImage(DistrhoArtworkPingPongPan::knobData, DistrhoArtworkPingPongPan::knobWidth, DistrhoArtworkPingPongPan::knobHeight);
  28. // knob Low-Mid
  29. fKnobFreq = new ImageKnob(win, knobImage);
  30. fKnobFreq->setPos(136, 30);
  31. fKnobFreq->setRange(0.0f, 100.0f);
  32. fKnobFreq->setValue(50.0f);
  33. fKnobFreq->setCallback(this);
  34. // knob Mid-High
  35. fKnobWidth = new ImageKnob(win, knobImage);
  36. fKnobWidth->setPos(258, 30);
  37. fKnobWidth->setRange(0.0f, 100.0f);
  38. fKnobWidth->setValue(75.0f);
  39. fKnobWidth->setCallback(this);
  40. // about button
  41. Image aboutImageNormal(DistrhoArtworkPingPongPan::aboutButtonNormalData, DistrhoArtworkPingPongPan::aboutButtonNormalWidth, DistrhoArtworkPingPongPan::aboutButtonNormalHeight);
  42. Image aboutImageHover(DistrhoArtworkPingPongPan::aboutButtonHoverData, DistrhoArtworkPingPongPan::aboutButtonHoverWidth, DistrhoArtworkPingPongPan::aboutButtonHoverHeight);
  43. fButtonAbout = new ImageButton(win, aboutImageNormal, aboutImageHover, aboutImageHover);
  44. fButtonAbout->setPos(25, 23);
  45. fButtonAbout->setCallback(this);
  46. }
  47. DistrhoUIPingPongPan::~DistrhoUIPingPongPan()
  48. {
  49. delete fKnobFreq;
  50. delete fKnobWidth;
  51. delete fButtonAbout;
  52. }
  53. // -------------------------------------------------
  54. // DSP Callbacks
  55. void DistrhoUIPingPongPan::d_parameterChanged(uint32_t index, float value)
  56. {
  57. switch (index)
  58. {
  59. case DistrhoPluginPingPongPan::paramFreq:
  60. fKnobFreq->setValue(value);
  61. break;
  62. case DistrhoPluginPingPongPan::paramWidth:
  63. fKnobWidth->setValue(value);
  64. break;
  65. }
  66. }
  67. void DistrhoUIPingPongPan::d_programChanged(uint32_t index)
  68. {
  69. if (index != 0)
  70. return;
  71. // Default values
  72. fKnobFreq->setValue(50.0f);
  73. fKnobWidth->setValue(75.0f);
  74. }
  75. // -------------------------------------------------
  76. // Widget Callbacks
  77. void DistrhoUIPingPongPan::imageButtonClicked(ImageButton* button, int)
  78. {
  79. if (button != fButtonAbout)
  80. return;
  81. Image imageAbout(DistrhoArtworkPingPongPan::aboutData, DistrhoArtworkPingPongPan::aboutWidth, DistrhoArtworkPingPongPan::aboutHeight, GL_BGRA);
  82. ImageAboutWindow aboutWindow(getApp(), getParent(), imageAbout);
  83. aboutWindow.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