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.

93 lines
2.5KB

  1. #pragma once
  2. // Include headers that plugins will likely use, for convenience
  3. #include "util/common.hpp"
  4. #include "asset.hpp"
  5. #include "plugin.hpp"
  6. #include "engine.hpp"
  7. #include "widgets.hpp"
  8. #include "app.hpp"
  9. #include "ui.hpp"
  10. #include "componentlibrary.hpp"
  11. namespace rack {
  12. ////////////////////
  13. // helpers
  14. ////////////////////
  15. /** Deprecated, use Model::create<TModule, TModuleWidget>(...) instead */
  16. template <class TModuleWidget, typename... Tags>
  17. DEPRECATED Model *createModel(std::string author, std::string slug, std::string name, Tags... tags) {
  18. struct TModel : Model {
  19. ModuleWidget *createModuleWidget() override {
  20. ModuleWidget *moduleWidget = new TModuleWidget();
  21. moduleWidget->model = this;
  22. return moduleWidget;
  23. }
  24. };
  25. Model *model = new TModel();
  26. model->author = author;
  27. model->slug = slug;
  28. model->name = name;
  29. model->tags = {tags...};
  30. return model;
  31. }
  32. /** Deprecated, use Widget::create<TScrew>() instead */
  33. template <class TScrew>
  34. DEPRECATED TScrew *createScrew(Vec pos) {
  35. TScrew *screw = new TScrew();
  36. screw->box.pos = pos;
  37. return screw;
  38. }
  39. /** Deprecated, use ParamWidget::create<TParamWidget>() instead */
  40. template <class TParamWidget>
  41. DEPRECATED TParamWidget *createParam(Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) {
  42. TParamWidget *param = new TParamWidget();
  43. param->box.pos = pos;
  44. param->module = module;
  45. param->paramId = paramId;
  46. param->setLimits(minValue, maxValue);
  47. param->setDefaultValue(defaultValue);
  48. return param;
  49. }
  50. /** Deprecated, use Port::create<TPort>(..., Port::INPUT, ...) instead */
  51. template <class TPort>
  52. DEPRECATED TPort *createInput(Vec pos, Module *module, int inputId) {
  53. TPort *port = new TPort();
  54. port->box.pos = pos;
  55. port->module = module;
  56. port->type = Port::INPUT;
  57. port->portId = inputId;
  58. return port;
  59. }
  60. /** Deprecated, use Port::create<TPort>(..., Port::OUTPUT, ...) instead */
  61. template <class TPort>
  62. DEPRECATED TPort *createOutput(Vec pos, Module *module, int outputId) {
  63. TPort *port = new TPort();
  64. port->box.pos = pos;
  65. port->module = module;
  66. port->type = Port::OUTPUT;
  67. port->portId = outputId;
  68. return port;
  69. }
  70. /** Deprecated, use ModuleLightWidget::create<TModuleLightWidget>() instead */
  71. template<class TModuleLightWidget>
  72. DEPRECATED TModuleLightWidget *createLight(Vec pos, Module *module, int firstLightId) {
  73. TModuleLightWidget *light = new TModuleLightWidget();
  74. light->box.pos = pos;
  75. light->module = module;
  76. light->firstLightId = firstLightId;
  77. return light;
  78. }
  79. } // namespace rack