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.

67 lines
1.6KB

  1. #pragma once
  2. #include <jansson.h>
  3. #include <common.hpp>
  4. namespace rack {
  5. /** Handles the Rack patch file state */
  6. namespace patch {
  7. /** Handles the Rack patch file state. */
  8. struct Manager {
  9. struct Internal;
  10. Internal* internal;
  11. /** The currently loaded patch file path */
  12. std::string path;
  13. /** Path to autosave dir */
  14. std::string autosavePath;
  15. /** Path to user template patch */
  16. std::string templatePath;
  17. /** Path to factory template patch */
  18. std::string factoryTemplatePath;
  19. /** Append to this while loading/saving a patch to display messages to the user after success. */
  20. std::string warningLog;
  21. Manager();
  22. ~Manager();
  23. void launch(std::string pathArg);
  24. /** Clears the patch. */
  25. void clear();
  26. /** Saves the patch and nothing else. */
  27. void save(std::string path);
  28. void saveDialog();
  29. void saveAsDialog();
  30. void saveTemplateDialog();
  31. void saveAutosave();
  32. void cleanAutosave();
  33. /** Loads a patch and nothing else.
  34. Returns whether the patch was loaded successfully.
  35. */
  36. void load(std::string path);
  37. /** Loads the template patch. */
  38. void loadTemplate();
  39. void loadTemplateDialog();
  40. bool hasAutosave();
  41. void loadAutosave();
  42. /** Loads a patch, sets the current path, and updates the recent patches. */
  43. void loadAction(std::string path);
  44. void loadDialog();
  45. void loadPathDialog(std::string path);
  46. /** Asks the user to reload the current patch. */
  47. void revertDialog();
  48. void pushRecentPath(std::string path);
  49. /** Disconnects all cables. */
  50. void disconnectDialog();
  51. json_t* toJson();
  52. void fromJson(json_t* rootJ);
  53. void log(std::string msg);
  54. };
  55. } // namespace patch
  56. } // namespace rack