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.

170 lines
4.2KB

  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; // last copied value
  78. int gid_clipboard; // param GID of last copied value (-1 if none)
  79. TextField *tf_id;
  80. TextField *tf_value;
  81. bool b_lock; // true=don't update info (e.g. when receiving VST parameter updates from host)
  82. int placeholder_framecount;
  83. } param_info;
  84. bool b_fbo; // usually true. set to false when using the VirtualBox GL driver.
  85. bool b_fbo_shared; // this may or may not work. default is false (=> don't use FBOs in dynamically loaded modules).
  86. int pending_swap_interval; // -1=none, 1=vsync on, 0=vsync off
  87. void init(void) {
  88. window.lglw = NULL;
  89. window.gVg = NULL;
  90. window.gFramebufferVg = NULL;
  91. window.gPixelRatio = 1.0;
  92. window.gWindowRatio = 1.0;
  93. window.gAllowCursorLock = true;
  94. window.gGuiFrame = 0;
  95. window.windowX = 0;
  96. window.windowY = 0;
  97. window.windowWidth = 0;
  98. window.windowHeight = 0;
  99. widgets.gHoveredWidget = NULL;
  100. widgets.gDraggedWidget = NULL;
  101. widgets.gDragHoveredWidget = NULL;
  102. widgets.gFocusedWidget = NULL;
  103. widgets.gTempWidget = NULL;
  104. ui.gScene = NULL;
  105. module_browser.sTagFilter = ModelTag::NO_TAG;
  106. app.gApplicationName = "VeeSeeVST Rack";
  107. app.gApplicationVersion = TOSTRING(VERSION);
  108. app.gApiHost = "https://api.vcvrack.com";
  109. // app.gApiHost = "http://localhost:8081";
  110. app.gCheckVersion = true;
  111. app.gRackWidget = NULL;
  112. app.gToolbar = NULL;
  113. app.gRackScene = NULL;
  114. app.bLoadVSTUniqueParamBaseId = true;
  115. blendish.bnd_icon_image = -1;
  116. blendish.bnd_font = -1;
  117. param_info.last_param_widget = NULL;
  118. param_info.last_param_gid = 0;
  119. param_info.last_param_value = 0.0f;
  120. param_info.value_clipboard = 0.0f;
  121. param_info.gid_clipboard = -1;
  122. param_info.tf_id = NULL;
  123. param_info.tf_value = NULL;
  124. param_info.b_lock = false;
  125. param_info.placeholder_framecount = 0;
  126. b_fbo = true;
  127. b_fbo_shared = false;
  128. pending_swap_interval = -1;
  129. }
  130. };
  131. } // namespace rack