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.

146 lines
4.4KB

  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 doc/LGPL.txt file.
  15. */
  16. #include "DistrhoUIPingPongPan.hpp"
  17. using DGL::Point;
  18. START_NAMESPACE_DISTRHO
  19. // -----------------------------------------------------------------------
  20. DistrhoUIPingPongPan::DistrhoUIPingPongPan()
  21. : UI(),
  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(60, 58);
  33. fKnobFreq->setRange(0.0f, 100.0f);
  34. fKnobFreq->setValue(50.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->setValue(75.0f);
  42. fKnobWidth->setRotationAngle(270);
  43. fKnobWidth->setCallback(this);
  44. // about button
  45. Image aboutImageNormal(DistrhoArtworkPingPongPan::aboutButtonNormalData, DistrhoArtworkPingPongPan::aboutButtonNormalWidth, DistrhoArtworkPingPongPan::aboutButtonNormalHeight);
  46. Image aboutImageHover(DistrhoArtworkPingPongPan::aboutButtonHoverData, DistrhoArtworkPingPongPan::aboutButtonHoverWidth, DistrhoArtworkPingPongPan::aboutButtonHoverHeight);
  47. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  48. fButtonAbout->setPos(183, 8);
  49. fButtonAbout->setCallback(this);
  50. }
  51. DistrhoUIPingPongPan::~DistrhoUIPingPongPan()
  52. {
  53. delete fKnobFreq;
  54. delete fKnobWidth;
  55. delete fButtonAbout;
  56. }
  57. // -----------------------------------------------------------------------
  58. // DSP Callbacks
  59. void DistrhoUIPingPongPan::d_parameterChanged(uint32_t index, float value)
  60. {
  61. switch (index)
  62. {
  63. case DistrhoPluginPingPongPan::paramFreq:
  64. fKnobFreq->setValue(value);
  65. break;
  66. case DistrhoPluginPingPongPan::paramWidth:
  67. fKnobWidth->setValue(value);
  68. break;
  69. }
  70. }
  71. void DistrhoUIPingPongPan::d_programChanged(uint32_t index)
  72. {
  73. if (index != 0)
  74. return;
  75. // Default values
  76. fKnobFreq->setValue(50.0f);
  77. fKnobWidth->setValue(75.0f);
  78. }
  79. // -----------------------------------------------------------------------
  80. // Widget Callbacks
  81. void DistrhoUIPingPongPan::imageButtonClicked(ImageButton* button, int)
  82. {
  83. if (button != fButtonAbout)
  84. return;
  85. fAboutWindow.exec();
  86. }
  87. void DistrhoUIPingPongPan::imageKnobDragStarted(ImageKnob* knob)
  88. {
  89. if (knob == fKnobFreq)
  90. d_editParameter(DistrhoPluginPingPongPan::paramFreq, true);
  91. else if (knob == fKnobWidth)
  92. d_editParameter(DistrhoPluginPingPongPan::paramWidth, true);
  93. }
  94. void DistrhoUIPingPongPan::imageKnobDragFinished(ImageKnob* knob)
  95. {
  96. if (knob == fKnobFreq)
  97. d_editParameter(DistrhoPluginPingPongPan::paramFreq, false);
  98. else if (knob == fKnobWidth)
  99. d_editParameter(DistrhoPluginPingPongPan::paramWidth, false);
  100. }
  101. void DistrhoUIPingPongPan::imageKnobValueChanged(ImageKnob* knob, float value)
  102. {
  103. if (knob == fKnobFreq)
  104. d_setParameterValue(DistrhoPluginPingPongPan::paramFreq, value);
  105. else if (knob == fKnobWidth)
  106. d_setParameterValue(DistrhoPluginPingPongPan::paramWidth, value);
  107. }
  108. void DistrhoUIPingPongPan::onDisplay()
  109. {
  110. fImgBackground.draw();
  111. }
  112. // -----------------------------------------------------------------------
  113. UI* createUI()
  114. {
  115. return new DistrhoUIPingPongPan();
  116. }
  117. // -----------------------------------------------------------------------
  118. END_NAMESPACE_DISTRHO