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.

134 lines
4.2KB

  1. /*
  2. * DISTRHO PingPongPan Plugin, based on PingPongPan by Michael Gruhn
  3. * Copyright (C) 2012-2014 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 LICENSE file.
  15. */
  16. #include "DistrhoPluginPingPongPan.hpp"
  17. #include "DistrhoUIPingPongPan.hpp"
  18. START_NAMESPACE_DISTRHO
  19. // -----------------------------------------------------------------------
  20. DistrhoUIPingPongPan::DistrhoUIPingPongPan()
  21. : UI(),
  22. fAboutWindow(this)
  23. {
  24. // set UI size
  25. setSize(DistrhoArtworkPingPongPan::backgroundWidth, DistrhoArtworkPingPongPan::backgroundHeight);
  26. // background
  27. fImgBackground = Image(DistrhoArtworkPingPongPan::backgroundData, DistrhoArtworkPingPongPan::backgroundWidth, DistrhoArtworkPingPongPan::backgroundHeight, GL_BGR);
  28. Image imageAbout(DistrhoArtworkPingPongPan::aboutData, DistrhoArtworkPingPongPan::aboutWidth, DistrhoArtworkPingPongPan::aboutHeight, GL_BGR);
  29. fAboutWindow.setImage(imageAbout);
  30. // knobs
  31. Image knobImage(DistrhoArtworkPingPongPan::knobData, DistrhoArtworkPingPongPan::knobWidth, DistrhoArtworkPingPongPan::knobHeight);
  32. // knob Low-Mid
  33. fKnobFreq = new ImageKnob(this, knobImage, ImageKnob::Vertical, DistrhoPluginPingPongPan::paramFreq);
  34. fKnobFreq->setAbsolutePos(60, 58);
  35. fKnobFreq->setRange(0.0f, 100.0f);
  36. fKnobFreq->setDefault(50.0f);
  37. fKnobFreq->setRotationAngle(270);
  38. fKnobFreq->setCallback(this);
  39. // knob Mid-High
  40. fKnobWidth = new ImageKnob(this, knobImage, ImageKnob::Vertical, DistrhoPluginPingPongPan::paramWidth);
  41. fKnobWidth->setAbsolutePos(182, 58);
  42. fKnobWidth->setRange(0.0f, 100.0f);
  43. fKnobWidth->setDefault(75.0f);
  44. fKnobWidth->setRotationAngle(270);
  45. fKnobWidth->setCallback(this);
  46. // about button
  47. Image aboutImageNormal(DistrhoArtworkPingPongPan::aboutButtonNormalData, DistrhoArtworkPingPongPan::aboutButtonNormalWidth, DistrhoArtworkPingPongPan::aboutButtonNormalHeight);
  48. Image aboutImageHover(DistrhoArtworkPingPongPan::aboutButtonHoverData, DistrhoArtworkPingPongPan::aboutButtonHoverWidth, DistrhoArtworkPingPongPan::aboutButtonHoverHeight);
  49. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  50. fButtonAbout->setAbsolutePos(183, 8);
  51. fButtonAbout->setCallback(this);
  52. // set default values
  53. d_programChanged(0);
  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. d_editParameter(knob->getId(), true);
  88. }
  89. void DistrhoUIPingPongPan::imageKnobDragFinished(ImageKnob* knob)
  90. {
  91. d_editParameter(knob->getId(), false);
  92. }
  93. void DistrhoUIPingPongPan::imageKnobValueChanged(ImageKnob* knob, float value)
  94. {
  95. d_setParameterValue(knob->getId(), value);
  96. }
  97. void DistrhoUIPingPongPan::onDisplay()
  98. {
  99. fImgBackground.draw();
  100. }
  101. // -----------------------------------------------------------------------
  102. UI* createUI()
  103. {
  104. return new DistrhoUIPingPongPan();
  105. }
  106. // -----------------------------------------------------------------------
  107. END_NAMESPACE_DISTRHO