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.

120 lines
2.7KB

  1. /*
  2. * DISTRHO Cardinal Plugin
  3. * Copyright (C) 2021-2024 Filipe Coelho <falktx@falktx.com>
  4. * SPDX-License-Identifier: GPL-3.0-or-later
  5. */
  6. #pragma once
  7. #include "DistrhoUtils.hpp"
  8. #include <string>
  9. extern const std::string CARDINAL_VERSION;
  10. struct CardinalPluginContext;
  11. // -----------------------------------------------------------------------------------------------------------
  12. namespace rack {
  13. namespace ui {
  14. struct Menu;
  15. }
  16. namespace window {
  17. void generateScreenshot();
  18. }
  19. bool isMini();
  20. bool isStandalone();
  21. #ifdef ARCH_WIN
  22. enum SpecialPath {
  23. kSpecialPathUserProfile,
  24. kSpecialPathCommonProgramFiles,
  25. kSpecialPathProgramFiles,
  26. kSpecialPathAppData,
  27. kSpecialPathMyDocuments,
  28. };
  29. std::string getSpecialPath(SpecialPath type);
  30. #endif
  31. #ifdef DISTRHO_OS_WASM
  32. extern char* patchFromURL;
  33. extern char* patchRemoteURL;
  34. extern char* patchStorageSlug;
  35. void syncfs();
  36. #endif
  37. std::string homeDir();
  38. void switchDarkMode(bool darkMode);
  39. } // namespace rack
  40. // -----------------------------------------------------------------------------------------------------------
  41. namespace patchUtils {
  42. void loadDialog();
  43. void loadPathDialog(const std::string& path, bool asTemplate = false);
  44. void loadSelectionDialog();
  45. void loadTemplate(bool factory);
  46. void loadTemplateDialog(bool factory);
  47. void revertDialog();
  48. void saveDialog(const std::string& path);
  49. void saveAsDialog();
  50. void saveAsDialogUncompressed();
  51. void saveTemplateDialog();
  52. void appendSelectionContextMenu(rack::ui::Menu* menu);
  53. void openBrowser(const std::string& url);
  54. } // namespace patchUtils
  55. // -----------------------------------------------------------------------------------------------------------
  56. #if defined(HAVE_LIBLO) && defined(HEADLESS)
  57. # define CARDINAL_INIT_OSC_THREAD
  58. #endif
  59. #ifdef HAVE_LIBLO
  60. # include <lo/lo_types.h>
  61. #endif
  62. START_NAMESPACE_DISTRHO
  63. class CardinalBasePlugin;
  64. class CardinalBaseUI;
  65. struct Initializer
  66. {
  67. std::string templatePath;
  68. std::string factoryTemplatePath;
  69. bool shouldSaveSettings = false;
  70. Initializer(const CardinalBasePlugin* plugin, const CardinalBaseUI* ui);
  71. ~Initializer();
  72. void loadSettings(bool isRealInstance);
  73. #ifdef HAVE_LIBLO
  74. lo_server oscServer = nullptr;
  75. #ifdef CARDINAL_INIT_OSC_THREAD
  76. lo_server_thread oscServerThread = nullptr;
  77. #endif
  78. CardinalBasePlugin* remotePluginInstance = nullptr;
  79. bool startRemoteServer(const char* port);
  80. void stopRemoteServer();
  81. void stepRemoteServer();
  82. #endif
  83. };
  84. #ifndef HEADLESS
  85. void handleHostParameterDrag(const CardinalPluginContext* pcontext, uint index, bool started);
  86. #endif
  87. END_NAMESPACE_DISTRHO
  88. // -----------------------------------------------------------------------------------------------------------