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.7KB

  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. void init(void) {
  84. window.lglw = NULL;
  85. window.gVg = NULL;
  86. window.gFramebufferVg = NULL;
  87. window.gPixelRatio = 1.0;
  88. window.gWindowRatio = 1.0;
  89. window.gAllowCursorLock = true;
  90. window.gGuiFrame = 0;
  91. window.windowX = 0;
  92. window.windowY = 0;
  93. window.windowWidth = 0;
  94. window.windowHeight = 0;
  95. widgets.gHoveredWidget = NULL;
  96. widgets.gDraggedWidget = NULL;
  97. widgets.gDragHoveredWidget = NULL;
  98. widgets.gFocusedWidget = NULL;
  99. widgets.gTempWidget = NULL;
  100. ui.gScene = NULL;
  101. module_browser.sTagFilter = ModelTag::NO_TAG;
  102. app.gApplicationName = "VeeSeeVST Rack";
  103. app.gApplicationVersion = TOSTRING(VERSION);
  104. app.gApiHost = "https://api.vcvrack.com";
  105. // app.gApiHost = "http://localhost:8081";
  106. app.gCheckVersion = true;
  107. app.gRackWidget = NULL;
  108. app.gToolbar = NULL;
  109. app.gRackScene = NULL;
  110. app.bLoadVSTUniqueParamBaseId = true;
  111. blendish.bnd_icon_image = -1;
  112. blendish.bnd_font = -1;
  113. param_info.last_param_widget = NULL;
  114. param_info.last_param_gid = 0;
  115. param_info.last_param_value = 0.0f;
  116. param_info.value_clipboard = 0.0f;
  117. param_info.tf_id = NULL;
  118. param_info.tf_value = NULL;
  119. param_info.b_lock = false;
  120. param_info.placeholder_framecount = 0;
  121. }
  122. };
  123. } // namespace rack