DISTRHO Mini-Series
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.

141 lines
4.3KB

  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. using DGL::Point;
  19. START_NAMESPACE_DISTRHO
  20. // -----------------------------------------------------------------------
  21. DistrhoUIPingPongPan::DistrhoUIPingPongPan()
  22. : UI(),
  23. fAboutWindow(this)
  24. {
  25. // background
  26. fImgBackground = Image(DistrhoArtworkPingPongPan::backgroundData, DistrhoArtworkPingPongPan::backgroundWidth, DistrhoArtworkPingPongPan::backgroundHeight, GL_BGR);
  27. Image imageAbout(DistrhoArtworkPingPongPan::aboutData, DistrhoArtworkPingPongPan::aboutWidth, DistrhoArtworkPingPongPan::aboutHeight, GL_BGR);
  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(60, 58);
  34. fKnobFreq->setRange(0.0f, 100.0f);
  35. fKnobFreq->setRotationAngle(270);
  36. fKnobFreq->setCallback(this);
  37. // knob Mid-High
  38. fKnobWidth = new ImageKnob(this, knobImage);
  39. fKnobWidth->setPos(182, 58);
  40. fKnobWidth->setRange(0.0f, 100.0f);
  41. fKnobWidth->setRotationAngle(270);
  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. // set default values
  50. d_programChanged(0);
  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. fKnobFreq->setValue(value);
  60. break;
  61. case DistrhoPluginPingPongPan::paramWidth:
  62. fKnobWidth->setValue(value);
  63. break;
  64. }
  65. }
  66. void DistrhoUIPingPongPan::d_programChanged(uint32_t index)
  67. {
  68. if (index != 0)
  69. return;
  70. // Default values
  71. fKnobFreq->setValue(50.0f);
  72. fKnobWidth->setValue(75.0f);
  73. }
  74. // -----------------------------------------------------------------------
  75. // Widget Callbacks
  76. void DistrhoUIPingPongPan::imageButtonClicked(ImageButton* button, int)
  77. {
  78. if (button != fButtonAbout)
  79. return;
  80. fAboutWindow.exec();
  81. }
  82. void DistrhoUIPingPongPan::imageKnobDragStarted(ImageKnob* knob)
  83. {
  84. if (knob == fKnobFreq)
  85. d_editParameter(DistrhoPluginPingPongPan::paramFreq, true);
  86. else if (knob == fKnobWidth)
  87. d_editParameter(DistrhoPluginPingPongPan::paramWidth, true);
  88. }
  89. void DistrhoUIPingPongPan::imageKnobDragFinished(ImageKnob* knob)
  90. {
  91. if (knob == fKnobFreq)
  92. d_editParameter(DistrhoPluginPingPongPan::paramFreq, false);
  93. else if (knob == fKnobWidth)
  94. d_editParameter(DistrhoPluginPingPongPan::paramWidth, false);
  95. }
  96. void DistrhoUIPingPongPan::imageKnobValueChanged(ImageKnob* knob, float value)
  97. {
  98. if (knob == fKnobFreq)
  99. d_setParameterValue(DistrhoPluginPingPongPan::paramFreq, value);
  100. else if (knob == fKnobWidth)
  101. d_setParameterValue(DistrhoPluginPingPongPan::paramWidth, value);
  102. }
  103. void DistrhoUIPingPongPan::onDisplay()
  104. {
  105. fImgBackground.draw();
  106. }
  107. // -----------------------------------------------------------------------
  108. UI* createUI()
  109. {
  110. return new DistrhoUIPingPongPan();
  111. }
  112. // -----------------------------------------------------------------------
  113. END_NAMESPACE_DISTRHO