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.

110 lines
2.7KB

  1. //***********************************************************************************************
  2. //Blank-Panel Info for VCV Rack by Pierre Collard and Marc Boulé
  3. //***********************************************************************************************
  4. #include "Geodesics.hpp"
  5. namespace rack_plugin_Geodesics {
  6. struct BlankInfo : Module {
  7. int panelTheme = 0;
  8. BlankInfo() : Module(0, 0, 0, 0) {
  9. onReset();
  10. }
  11. void onReset() override {
  12. }
  13. void onRandomize() override {
  14. }
  15. json_t *toJson() override {
  16. json_t *rootJ = json_object();
  17. // panelTheme
  18. json_object_set_new(rootJ, "panelTheme", json_integer(panelTheme));
  19. return rootJ;
  20. }
  21. void fromJson(json_t *rootJ) override {
  22. // panelTheme
  23. json_t *panelThemeJ = json_object_get(rootJ, "panelTheme");
  24. if (panelThemeJ)
  25. panelTheme = json_integer_value(panelThemeJ);
  26. }
  27. // Advances the module by 1 audio frame with duration 1.0 / engineGetSampleRate()
  28. void step() override {
  29. }
  30. };
  31. struct BlankInfoWidget : ModuleWidget {
  32. struct PanelThemeItem : MenuItem {
  33. BlankInfo *module;
  34. int theme;
  35. void onAction(EventAction &e) override {
  36. module->panelTheme = theme;
  37. }
  38. void step() override {
  39. rightText = (module->panelTheme == theme) ? "✔" : "";
  40. }
  41. };
  42. Menu *createContextMenu() override {
  43. Menu *menu = ModuleWidget::createContextMenu();
  44. MenuLabel *spacerLabel = new MenuLabel();
  45. menu->addChild(spacerLabel);
  46. BlankInfo *module = dynamic_cast<BlankInfo*>(this->module);
  47. assert(module);
  48. MenuLabel *themeLabel = new MenuLabel();
  49. themeLabel->text = "Panel Theme";
  50. menu->addChild(themeLabel);
  51. PanelThemeItem *lightItem = new PanelThemeItem();
  52. lightItem->text = lightPanelID;// Geodesics.hpp
  53. lightItem->module = module;
  54. lightItem->theme = 0;
  55. menu->addChild(lightItem);
  56. PanelThemeItem *darkItem = new PanelThemeItem();
  57. darkItem->text = darkPanelID;// Geodesics.hpp
  58. darkItem->module = module;
  59. darkItem->theme = 1;
  60. //menu->addChild(darkItem);
  61. return menu;
  62. }
  63. BlankInfoWidget(BlankInfo *module) : ModuleWidget(module) {
  64. // Main panel from Inkscape
  65. DynamicSVGPanel *panel = new DynamicSVGPanel();
  66. panel->addPanel(SVG::load(assetPlugin(plugin, "res/light/BlankInfo-01.svg")));
  67. //panel->addPanel(SVG::load(assetPlugin(plugin, "res/dark/BlankInfo-02.svg")));// no dark pannel for now
  68. box.size = panel->box.size;
  69. panel->mode = &module->panelTheme;
  70. addChild(panel);
  71. // Screws
  72. // part of svg panel, no code required
  73. }
  74. };
  75. } // namespace rack_plugin_Geodesics
  76. using namespace rack_plugin_Geodesics;
  77. RACK_PLUGIN_MODEL_INIT(Geodesics, BlankInfo) {
  78. Model *modelBlankInfo = Model::create<BlankInfo, BlankInfoWidget>("Geodesics", "Blank-Panel Info", "MISC - Blank-Panel Info", BLANK_TAG);
  79. return modelBlankInfo;
  80. }