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.

139 lines
2.8KB

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