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.

147 lines
3.0KB

  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. } app;
  66. #ifdef USE_VST2
  67. struct {
  68. volatile int b_close_window;
  69. volatile int b_hide_window;
  70. #ifdef WIN32
  71. void *parent_hwnd;
  72. bool b_queued_maximize_window;
  73. #endif // WIN32
  74. } vst2;
  75. #endif // USE_VST2
  76. void init(void) {
  77. window.gWindow = NULL;
  78. window.gVg = NULL;
  79. window.gFramebufferVg = NULL;
  80. window.gPixelRatio = 1.0;
  81. window.gWindowRatio = 1.0;
  82. // #ifdef USE_VST2
  83. // window.gAllowCursorLock = false;
  84. // #else
  85. window.gAllowCursorLock = true;
  86. // #endif // USE_VST2
  87. window.windowX = 0;
  88. window.windowY = 0;
  89. window.windowWidth = 0;
  90. window.windowHeight = 0;
  91. widgets.gHoveredWidget = NULL;
  92. widgets.gDraggedWidget = NULL;
  93. widgets.gDragHoveredWidget = NULL;
  94. widgets.gFocusedWidget = NULL;
  95. widgets.gTempWidget = NULL;
  96. ui.gScene = NULL;
  97. module_browser.sTagFilter = ModelTag::NO_TAG;
  98. app.gApplicationName = "VeeSeeVST Rack";
  99. app.gApplicationVersion = TOSTRING(VERSION);
  100. app.gApiHost = "https://api.vcvrack.com";
  101. // app.gApiHost = "http://localhost:8081";
  102. app.gCheckVersion = true;
  103. app.gRackWidget = NULL;
  104. app.gToolbar = NULL;
  105. app.gRackScene = NULL;
  106. #ifdef USE_VST2
  107. vst2.b_close_window = 0;
  108. vst2.b_hide_window = 0;
  109. #ifdef WIN32
  110. vst2.parent_hwnd = 0;
  111. vst2.b_queued_maximize_window = false;
  112. #endif
  113. #endif // USE_VST2
  114. }
  115. };
  116. } // namespace rack