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.

91 lines
2.1KB

  1. #pragma once
  2. #include <common.hpp>
  3. #include <plugin/Plugin.hpp>
  4. #include <jansson.h>
  5. #include <list>
  6. namespace rack {
  7. namespace ui {
  8. struct Menu;
  9. } // namespace app
  10. namespace app {
  11. struct ModuleWidget;
  12. } // namespace app
  13. namespace engine {
  14. struct Module;
  15. } // namespace engine
  16. namespace plugin {
  17. /** Type information for a module.
  18. Factory for Module and ModuleWidget.
  19. */
  20. struct Model {
  21. Plugin* plugin = NULL;
  22. /** Must be unique. Used for saving patches. Never change this after releasing your module.
  23. The model slug must be unique within your plugin, but it doesn't need to be unique among different plugins.
  24. */
  25. std::string slug;
  26. /** Human readable name for your model, e.g. "Voltage Controlled Oscillator" */
  27. std::string name;
  28. /** List of tag IDs representing the function(s) of the module.
  29. Tag IDs are not part of the ABI and may change at any time.
  30. */
  31. std::list<int> tagIds;
  32. /** A one-line summary of the module's purpose */
  33. std::string description;
  34. /** The manual of the module. HTML, PDF, or GitHub readme/wiki are fine.
  35. */
  36. std::string manualUrl;
  37. std::string modularGridUrl;
  38. /** Hides model from the Module Browser but able to be loaded from a patch file.
  39. Useful for deprecating modules without breaking old patches.
  40. */
  41. bool hidden = false;
  42. virtual ~Model() {}
  43. /** Creates a Module. */
  44. virtual engine::Module* createModule() {
  45. return NULL;
  46. }
  47. /** Creates a ModuleWidget with a Module attached.
  48. Module may be NULL.
  49. */
  50. virtual app::ModuleWidget* createModuleWidget(engine::Module* m) {
  51. return NULL;
  52. }
  53. void fromJson(json_t* rootJ);
  54. /** Returns the branded name of the model, e.g. VCV VCO-1. */
  55. std::string getFullName();
  56. std::string getFactoryPresetDirectory();
  57. std::string getUserPresetDirectory();
  58. /** Returns the module or plugin manual URL, whichever exists. */
  59. std::string getManualUrl();
  60. /** Appends items to menu with useful Model information.
  61. Enable `inBrowser` to show Module Browser key commands.
  62. */
  63. void appendContextMenu(ui::Menu* menu, bool inBrowser = false);
  64. bool isFavorite();
  65. void setFavorite(bool favorite);
  66. };
  67. } // namespace plugin
  68. } // namespace rack