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.

118 lines
3.5KB

  1. //***********************************************************************************************
  2. //Geodesics: A modular collection for VCV Rack by Pierre Collard and Marc Boulé
  3. //
  4. //Based on code from Valley Rack Free by Dale Johnson
  5. //See ./LICENSE.txt for all licenses
  6. //***********************************************************************************************
  7. #ifndef IM_WIDGETS_HPP
  8. #define IM_WIDGETS_HPP
  9. #include "rack.hpp"
  10. #include "window.hpp"
  11. using namespace rack;
  12. namespace rack_plugin_Geodesics {
  13. // ******** Dynamic SVGPanel ********
  14. struct PanelBorderWidget : TransparentWidget { // from SVGPanel.cpp
  15. int** expWidth = nullptr;
  16. void draw(NVGcontext *vg) override;
  17. };
  18. struct DynamicSVGPanel : FramebufferWidget { // like SVGPanel (in app.hpp and SVGPanel.cpp) but with dynmically assignable panel
  19. int* mode;
  20. int oldMode;
  21. int* expWidth;
  22. std::vector<std::shared_ptr<SVG>> panels;
  23. SVGWidget* visiblePanel;
  24. PanelBorderWidget* border;
  25. DynamicSVGPanel();
  26. void addPanel(std::shared_ptr<SVG> svg);
  27. void step() override;
  28. };
  29. // ******** Dynamic Ports ********
  30. // General Dynamic Port creation
  31. template <class TDynamicPort>
  32. TDynamicPort* createDynamicPort(Vec pos, Port::PortType type, Module *module, int portId,
  33. int* mode) {
  34. TDynamicPort *dynPort = Port::create<TDynamicPort>(pos, type, module, portId);
  35. dynPort->mode = mode;
  36. dynPort->box.pos = dynPort->box.pos.minus(dynPort->box.size.div(2));// centering
  37. return dynPort;
  38. }
  39. // Dynamic SVGPort (see SVGPort in app.hpp and SVGPort.cpp)
  40. struct DynamicSVGPort : SVGPort {
  41. int* mode;
  42. int oldMode;
  43. std::vector<std::shared_ptr<SVG>> frames;
  44. DynamicSVGPort();
  45. void addFrame(std::shared_ptr<SVG> svg);
  46. void step() override;
  47. };
  48. // ******** Dynamic Params ********
  49. // General Dynamic Param creation
  50. template <class TDynamicParam>
  51. TDynamicParam* createDynamicParam(Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue,
  52. int* mode) {
  53. TDynamicParam *dynParam = ParamWidget::create<TDynamicParam>(pos, module, paramId, minValue, maxValue, defaultValue);
  54. dynParam->mode = mode;
  55. dynParam->box.pos = dynParam->box.pos.minus(dynParam->box.size.div(2));// centering
  56. return dynParam;
  57. }
  58. // General Dynamic Param creation version two with float* instead of one int*
  59. template <class TDynamicParam>
  60. TDynamicParam* createDynamicParam2(Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue,
  61. float* wider, float* paramReadRequest) {
  62. TDynamicParam *dynParam = ParamWidget::create<TDynamicParam>(pos, module, paramId, minValue, maxValue, defaultValue);
  63. dynParam->wider = wider;
  64. dynParam->paramReadRequest = paramReadRequest;
  65. return dynParam;
  66. }
  67. // Dynamic SVGSwitch (see SVGSwitch in app.hpp and SVGSwitch.cpp)
  68. struct DynamicSVGSwitch : SVGSwitch {
  69. int* mode;
  70. int oldMode;
  71. std::vector<std::shared_ptr<SVG>> framesAll;
  72. DynamicSVGSwitch();
  73. void addFrameAll(std::shared_ptr<SVG> svg);
  74. void step() override;
  75. };
  76. // Dynamic SVGKnob (see SVGKnob in app.hpp and SVGKnob.cpp)
  77. struct DynamicSVGKnob : SVGKnob {
  78. int* mode;
  79. int oldMode;
  80. std::vector<std::shared_ptr<SVG>> framesAll;
  81. SVGWidget* effect;
  82. float orientationAngle;
  83. DynamicSVGKnob();
  84. void addFrameAll(std::shared_ptr<SVG> svg);
  85. void addEffect(std::shared_ptr<SVG> svg);// do this last
  86. void step() override;
  87. };
  88. } // namespace rack_plugin_Geodesics
  89. using namespace rack_plugin_Geodesics;
  90. #endif