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.

156 lines
4.2KB

  1. /*
  2. * Vector Juice Plugin
  3. * Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef GROOVEJUICEUI_HPP_INCLUDED
  18. #define GROOVEJUICEUI_HPP_INCLUDED
  19. #include "DistrhoUI.hpp"
  20. #include "Geometry.hpp"
  21. #include "ImageAboutWindow.hpp"
  22. #include "ImageButton.hpp"
  23. #include "ImageKnob.hpp"
  24. #include "ImageSlider.hpp"
  25. #include "GrooveJuiceArtwork.hpp"
  26. #include "GrooveJuicePlugin.hpp"
  27. using DGL::Image;
  28. using DGL::ImageAboutWindow;
  29. using DGL::ImageButton;
  30. using DGL::ImageKnob;
  31. using DGL::ImageSlider;
  32. using DGL::Rectangle;
  33. START_NAMESPACE_DISTRHO
  34. // -----------------------------------------------------------------------
  35. class GrooveJuiceUI : public UI,
  36. public ImageButton::Callback,
  37. public ImageKnob::Callback,
  38. public ImageSlider::Callback
  39. {
  40. public:
  41. GrooveJuiceUI();
  42. protected:
  43. // -------------------------------------------------------------------
  44. // Information
  45. uint d_getWidth() const noexcept override
  46. {
  47. return GrooveJuiceArtwork::backgroundWidth;
  48. }
  49. uint d_getHeight() const noexcept override
  50. {
  51. return GrooveJuiceArtwork::backgroundHeight;
  52. }
  53. // -------------------------------------------------------------------
  54. // DSP Callbacks
  55. void d_parameterChanged(uint32_t index, float value) override;
  56. void d_programChanged(uint32_t index) override;
  57. // -------------------------------------------------------------------
  58. // Widget Callbacks
  59. void imageButtonClicked(ImageButton* button, int) override;
  60. void imageKnobDragStarted(ImageKnob* knob) override;
  61. void imageKnobDragFinished(ImageKnob* knob) override;
  62. void imageKnobValueChanged(ImageKnob* knob, float value) override;
  63. void imageSliderDragStarted(ImageSlider* slider) override;
  64. void imageSliderDragFinished(ImageSlider* slider) override;
  65. void imageSliderValueChanged(ImageSlider* slider, float value) override;
  66. void onDisplay() override;
  67. bool onMouse(const MouseEvent&) override;
  68. bool onMotion(const MotionEvent&) override;
  69. private:
  70. float paramX, paramY;
  71. Image fImgBackground;
  72. Image fImgRoundlet;
  73. Image fImgOrbit;
  74. Image fImgSubOrbit;
  75. ImageAboutWindow fAboutWindow;
  76. //knobs
  77. ScopedPointer<ImageKnob> fKnobOrbitSpeedX, fKnobOrbitSpeedY;
  78. ScopedPointer<ImageKnob> fKnobOrbitSizeX, fKnobOrbitSizeY;
  79. ScopedPointer<ImageKnob> fKnobSubOrbitSpeed, fKnobSubOrbitSize, fKnobSubOrbitSmooth;
  80. ScopedPointer<ImageKnob> fKnobsSynth[8];
  81. int page;
  82. struct square {
  83. float timer;
  84. float maxTimer;
  85. int x;
  86. int y;
  87. int size;
  88. } squares[8][8];
  89. //sliders
  90. ScopedPointer<ImageSlider> fSliderOrbitWaveX, fSliderOrbitWaveY;
  91. ScopedPointer<ImageSlider> fSliderOrbitPhaseX, fSliderOrbitPhaseY;
  92. ScopedPointer<ImageButton> fButtonAbout;
  93. ScopedPointer<ImageButton> fButtonRandomize;
  94. ScopedPointer<ImageButton> fButtonsPage[8];
  95. int tabOX;
  96. int tabOY;
  97. int tabW;
  98. int tabH;
  99. float tabPosX;
  100. float tabTargetPosX;
  101. int tabMarginX;
  102. float getRandom() {
  103. return static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  104. }
  105. // needed for XY canvas handling
  106. bool fDragging;
  107. bool fDragValid;
  108. int fLastX;
  109. int fLastY;
  110. Rectangle<int> fCanvasArea;
  111. float orbitX, orbitY, subOrbitX, subOrbitY;
  112. float synthData[8][8]; //as per gui, [param][page]
  113. float synthSound[8];
  114. bool isWithinSquare(float x, float y, float sX, float sY) {
  115. if (x>=sX && x<sX+0.125)
  116. if (y>=sY && y<sY+0.125)
  117. return true;
  118. return false;
  119. };
  120. };
  121. // -----------------------------------------------------------------------
  122. END_NAMESPACE_DISTRHO
  123. #endif // GROOVEJUICEUI_HPP_INCLUDED