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.

168 lines
4.1KB

  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 NVGcontext;
  8. namespace rack {
  9. struct Font;
  10. struct Widget;
  11. struct RackWidget;
  12. struct Toolbar;
  13. struct RackScene;
  14. struct Scene;
  15. struct Model;
  16. struct ParamWidget;
  17. struct TextField;
  18. //
  19. // the structure fields reflect the original file locations
  20. // (e.g. 'window' was originally located in 'window.cpp')
  21. //
  22. struct GlobalUI {
  23. struct {
  24. void *lglw; // lglw_t
  25. NVGcontext *gVg;
  26. NVGcontext *gFramebufferVg;
  27. std::shared_ptr<Font> gGuiFont;
  28. float gPixelRatio;
  29. float gWindowRatio;
  30. bool gAllowCursorLock;
  31. int gGuiFrame;
  32. Vec gMousePos;
  33. std::string lastWindowTitle;
  34. int windowX;
  35. int windowY;
  36. int windowWidth;
  37. int windowHeight;
  38. std::map<std::string, std::weak_ptr<Font>> font_cache;
  39. std::map<std::string, std::weak_ptr<Image>> image_cache;
  40. std::map<std::string, std::weak_ptr<SVG>> svg_cache;
  41. } window;
  42. struct {
  43. Widget *gHoveredWidget;
  44. Widget *gDraggedWidget;
  45. Widget *gDragHoveredWidget;
  46. Widget *gFocusedWidget;
  47. Widget *gTempWidget;
  48. } widgets;
  49. struct {
  50. Scene *gScene;
  51. } ui;
  52. struct {
  53. std::set<Model*> sFavoriteModels;
  54. std::string sAuthorFilter;
  55. ModelTag sTagFilter;
  56. } module_browser;
  57. struct {
  58. std::string gApplicationName;
  59. std::string gApplicationVersion;
  60. std::string gApiHost;
  61. std::string gLatestVersion;
  62. bool gCheckVersion;
  63. RackWidget *gRackWidget;
  64. Toolbar *gToolbar;
  65. RackScene *gRackScene;
  66. std::mutex mtx_param;
  67. bool bLoadVSTUniqueParamBaseId; // temp. false while cloning ModuleWidget
  68. } app;
  69. struct {
  70. int bnd_icon_image;
  71. int bnd_font;
  72. } blendish;
  73. struct {
  74. const ParamWidget *last_param_widget; // never dereferenced, may have already been deleted. unset after redraw().
  75. int last_param_gid; // updated during redraw()
  76. float last_param_value; // updated in onMouseMove() and onChange(). corresponding param may not exist anymore.
  77. float value_clipboard;
  78. TextField *tf_id;
  79. TextField *tf_value;
  80. bool b_lock; // true=don't update info (e.g. when receiving VST parameter updates from host)
  81. int placeholder_framecount;
  82. } param_info;
  83. bool b_fbo; // usually true. set to false when using the VirtualBox GL driver.
  84. bool b_fbo_shared; // this may or may not work. default is false (=> don't use FBOs in dynamically loaded modules).
  85. int pending_swap_interval; // -1=none, 1=vsync on, 0=vsync off
  86. void init(void) {
  87. window.lglw = NULL;
  88. window.gVg = NULL;
  89. window.gFramebufferVg = NULL;
  90. window.gPixelRatio = 1.0;
  91. window.gWindowRatio = 1.0;
  92. window.gAllowCursorLock = true;
  93. window.gGuiFrame = 0;
  94. window.windowX = 0;
  95. window.windowY = 0;
  96. window.windowWidth = 0;
  97. window.windowHeight = 0;
  98. widgets.gHoveredWidget = NULL;
  99. widgets.gDraggedWidget = NULL;
  100. widgets.gDragHoveredWidget = NULL;
  101. widgets.gFocusedWidget = NULL;
  102. widgets.gTempWidget = NULL;
  103. ui.gScene = NULL;
  104. module_browser.sTagFilter = ModelTag::NO_TAG;
  105. app.gApplicationName = "VeeSeeVST Rack";
  106. app.gApplicationVersion = TOSTRING(VERSION);
  107. app.gApiHost = "https://api.vcvrack.com";
  108. // app.gApiHost = "http://localhost:8081";
  109. app.gCheckVersion = true;
  110. app.gRackWidget = NULL;
  111. app.gToolbar = NULL;
  112. app.gRackScene = NULL;
  113. app.bLoadVSTUniqueParamBaseId = true;
  114. blendish.bnd_icon_image = -1;
  115. blendish.bnd_font = -1;
  116. param_info.last_param_widget = NULL;
  117. param_info.last_param_gid = 0;
  118. param_info.last_param_value = 0.0f;
  119. param_info.value_clipboard = 0.0f;
  120. param_info.tf_id = NULL;
  121. param_info.tf_value = NULL;
  122. param_info.b_lock = false;
  123. param_info.placeholder_framecount = 0;
  124. b_fbo = true;
  125. b_fbo_shared = false;
  126. pending_swap_interval = -1;
  127. }
  128. };
  129. } // namespace rack