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.

61 lines
1.6KB

  1. #pragma once
  2. #include "app/common.hpp"
  3. #include "app/WireWidget.hpp"
  4. #include "app/WireContainer.hpp"
  5. namespace rack {
  6. struct RackWidget : OpaqueWidget {
  7. FramebufferWidget *rails;
  8. // Only put ModuleWidgets in here
  9. Widget *moduleContainer;
  10. // Only put WireWidgets in here
  11. WireContainer *wireContainer;
  12. std::string lastPath;
  13. Vec lastMousePos;
  14. bool lockModules = false;
  15. RackWidget();
  16. ~RackWidget();
  17. /** Completely clear the rack's modules and wires */
  18. void clear();
  19. /** Clears the rack and loads the template patch */
  20. void reset();
  21. void loadDialog();
  22. void saveDialog();
  23. void saveAsDialog();
  24. /** If `lastPath` is defined, ask the user to reload it */
  25. void revert();
  26. /** Disconnects all wires */
  27. void disconnect();
  28. void save(std::string filename);
  29. void load(std::string filename);
  30. json_t *toJson();
  31. void fromJson(json_t *rootJ);
  32. /** Creates a module and adds it to the rack */
  33. ModuleWidget *moduleFromJson(json_t *moduleJ);
  34. void pastePresetClipboard();
  35. void addModule(ModuleWidget *m);
  36. /** Removes the module and transfers ownership to the caller */
  37. void deleteModule(ModuleWidget *m);
  38. void cloneModule(ModuleWidget *m);
  39. /** Sets a module's box if non-colliding. Returns true if set */
  40. bool requestModuleBox(ModuleWidget *m, Rect box);
  41. /** Moves a module to the closest non-colliding position */
  42. bool requestModuleBoxNearest(ModuleWidget *m, Rect box);
  43. void step() override;
  44. void draw(NVGcontext *vg) override;
  45. void onHover(event::Hover &e) override;
  46. void onButton(event::Button &e) override;
  47. void onZoom(event::Zoom &e) override;
  48. };
  49. } // namespace rack