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.

DistrhoUIPingPongPan.cpp 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * DISTRHO PingPongPan Plugin, based on PingPongPan by Michael Gruhn
  3. * Copyright (C) 2012-2015 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);
  34. fKnobFreq->setId(DistrhoPluginPingPongPan::paramFreq);
  35. fKnobFreq->setAbsolutePos(60, 58);
  36. fKnobFreq->setRange(0.0f, 100.0f);
  37. fKnobFreq->setDefault(50.0f);
  38. fKnobFreq->setRotationAngle(270);
  39. fKnobFreq->setCallback(this);
  40. // knob Mid-High
  41. fKnobWidth = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  42. fKnobWidth->setId(DistrhoPluginPingPongPan::paramWidth);
  43. fKnobWidth->setAbsolutePos(182, 58);
  44. fKnobWidth->setRange(0.0f, 100.0f);
  45. fKnobWidth->setDefault(75.0f);
  46. fKnobWidth->setRotationAngle(270);
  47. fKnobWidth->setCallback(this);
  48. // about button
  49. Image aboutImageNormal(DistrhoArtworkPingPongPan::aboutButtonNormalData, DistrhoArtworkPingPongPan::aboutButtonNormalWidth, DistrhoArtworkPingPongPan::aboutButtonNormalHeight);
  50. Image aboutImageHover(DistrhoArtworkPingPongPan::aboutButtonHoverData, DistrhoArtworkPingPongPan::aboutButtonHoverWidth, DistrhoArtworkPingPongPan::aboutButtonHoverHeight);
  51. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  52. fButtonAbout->setAbsolutePos(183, 8);
  53. fButtonAbout->setCallback(this);
  54. // set default values
  55. d_programChanged(0);
  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. d_editParameter(knob->getId(), true);
  90. }
  91. void DistrhoUIPingPongPan::imageKnobDragFinished(ImageKnob* knob)
  92. {
  93. d_editParameter(knob->getId(), false);
  94. }
  95. void DistrhoUIPingPongPan::imageKnobValueChanged(ImageKnob* knob, float value)
  96. {
  97. d_setParameterValue(knob->getId(), value);
  98. }
  99. void DistrhoUIPingPongPan::onDisplay()
  100. {
  101. fImgBackground.draw();
  102. }
  103. // -----------------------------------------------------------------------
  104. UI* createUI()
  105. {
  106. return new DistrhoUIPingPongPan();
  107. }
  108. // -----------------------------------------------------------------------
  109. END_NAMESPACE_DISTRHO