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.

161 lines
3.3KB

  1. #pragma once
  2. #include <set>
  3. #include <map>
  4. #include "util/math.hpp" // Vec
  5. #include "tags.hpp" // ModelTag enum
  6. #include "widgets.hpp"
  7. struct GLFWwindow;
  8. struct NVGcontext;
  9. namespace rack {
  10. struct Font;
  11. struct Widget;
  12. struct RackWidget;
  13. struct Toolbar;
  14. struct RackScene;
  15. struct Scene;
  16. struct Model;
  17. //
  18. // the structure fields reflect the original file locations
  19. // (e.g. 'window' was originally located in 'window.cpp')
  20. //
  21. struct GlobalUI {
  22. struct {
  23. GLFWwindow *gWindow;
  24. NVGcontext *gVg;
  25. NVGcontext *gFramebufferVg;
  26. std::shared_ptr<Font> gGuiFont;
  27. float gPixelRatio;
  28. float gWindowRatio;
  29. bool gAllowCursorLock;
  30. int gGuiFrame;
  31. Vec gMousePos;
  32. std::string lastWindowTitle;
  33. int windowX;
  34. int windowY;
  35. int windowWidth;
  36. int windowHeight;
  37. std::map<std::string, std::weak_ptr<Font>> font_cache;
  38. std::map<std::string, std::weak_ptr<Image>> image_cache;
  39. std::map<std::string, std::weak_ptr<SVG>> svg_cache;
  40. } window;
  41. struct {
  42. Widget *gHoveredWidget;
  43. Widget *gDraggedWidget;
  44. Widget *gDragHoveredWidget;
  45. Widget *gFocusedWidget;
  46. Widget *gTempWidget;
  47. } widgets;
  48. struct {
  49. Scene *gScene;
  50. } ui;
  51. struct {
  52. std::set<Model*> sFavoriteModels;
  53. std::string sAuthorFilter;
  54. ModelTag sTagFilter;
  55. } module_browser;
  56. struct {
  57. std::string gApplicationName;
  58. std::string gApplicationVersion;
  59. std::string gApiHost;
  60. std::string gLatestVersion;
  61. bool gCheckVersion;
  62. RackWidget *gRackWidget;
  63. Toolbar *gToolbar;
  64. RackScene *gRackScene;
  65. std::mutex mtx_param;
  66. bool bLoadVSTUniqueParamBaseId; // temp. false while cloning ModuleWidget
  67. } app;
  68. struct {
  69. int bnd_icon_image;
  70. int bnd_font;
  71. } blendish;
  72. #ifdef USE_VST2
  73. struct {
  74. volatile int b_close_window;
  75. volatile int b_hide_window;
  76. #ifdef WIN32
  77. void *parent_hwnd;
  78. bool b_queued_maximize_window;
  79. #endif // WIN32
  80. } vst2;
  81. #endif // USE_VST2
  82. void init(void) {
  83. window.gWindow = NULL;
  84. window.gVg = NULL;
  85. window.gFramebufferVg = NULL;
  86. window.gPixelRatio = 1.0;
  87. window.gWindowRatio = 1.0;
  88. // #ifdef USE_VST2
  89. // window.gAllowCursorLock = false;
  90. // #else
  91. window.gAllowCursorLock = true;
  92. // #endif // USE_VST2
  93. window.windowX = 0;
  94. window.windowY = 0;
  95. window.windowWidth = 0;
  96. window.windowHeight = 0;
  97. widgets.gHoveredWidget = NULL;
  98. widgets.gDraggedWidget = NULL;
  99. widgets.gDragHoveredWidget = NULL;
  100. widgets.gFocusedWidget = NULL;
  101. widgets.gTempWidget = NULL;
  102. ui.gScene = NULL;
  103. module_browser.sTagFilter = ModelTag::NO_TAG;
  104. app.gApplicationName = "VeeSeeVST Rack";
  105. app.gApplicationVersion = TOSTRING(VERSION);
  106. app.gApiHost = "https://api.vcvrack.com";
  107. // app.gApiHost = "http://localhost:8081";
  108. app.gCheckVersion = true;
  109. app.gRackWidget = NULL;
  110. app.gToolbar = NULL;
  111. app.gRackScene = NULL;
  112. app.bLoadVSTUniqueParamBaseId = true;
  113. blendish.bnd_icon_image = -1;
  114. blendish.bnd_font = -1;
  115. #ifdef USE_VST2
  116. vst2.b_close_window = 0;
  117. vst2.b_hide_window = 0;
  118. #ifdef WIN32
  119. vst2.parent_hwnd = 0;
  120. vst2.b_queued_maximize_window = false;
  121. #endif
  122. #endif // USE_VST2
  123. }
  124. };
  125. } // namespace rack