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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef WINDOW_H
  2. #define WINDOW_H
  3. #include "../../../components/ComponentBuilder.h"
  4. #include "../../../components/MultiComponent.h"
  5. //#include "../components/Component.h"
  6. #include "ShaderLoader.h"
  7. #include "../../../../parsers/markup/Node.h"
  8. #include <GL/glew.h>
  9. #include <GLFW/glfw3.h>
  10. #include <memory>
  11. #include <vector>
  12. #include <algorithm>
  13. #include "../../../../networking/HTTPResponse.h"
  14. #include "../../../../tools/URL.h"
  15. #include "opengl.h"
  16. // forward def
  17. class DocumentComponent;
  18. class OpenGLWindowHandle;
  19. extern std::unique_ptr<BaseRenderer> renderer;
  20. // we don't want to extend WindowHandle because this is an API for the system in general
  21. // so we'll embed it as a member, and we can add the calls
  22. class Window : public std::enable_shared_from_this<Window> {
  23. private:
  24. public:
  25. ~Window();
  26. bool init();
  27. bool initGLFW();
  28. void render();
  29. //void setDOM(const std::shared_ptr<Node> rootNode);
  30. //void createComponentTree(const std::shared_ptr<Node> rootNode, const std::shared_ptr<Component> &parentComponent);
  31. //void renderComponentType(std::string str, std::shared_ptr<Component> component);
  32. void onResize(int passedWidth, int passedHeight);
  33. void checkForResize();
  34. void resize();
  35. void scrollDocument(int y);
  36. //void resizeComponentTree(const std::shared_ptr<Component> &component, const int windowWidth, const int windowHeight);
  37. //std::shared_ptr<Component> searchComponentTree(const std::shared_ptr<Component> &component, const int x, const int y);
  38. //void navTo(std::string url);
  39. // properties
  40. int maxTextureSize = 0;
  41. unsigned int oglActiveShader = 0; // cache to minimize opengl state changes
  42. // just a default matrix to reset UI since it won't scroll
  43. float textureTransformMatrix[16] = {
  44. 1, 0, 0, 0,
  45. 0, 1, 0, 0,
  46. 0, 0, 1, 0,
  47. 0, 0, 0, 1
  48. };
  49. // text uses a different one, since we have a different clamp on it
  50. float transformMatrix[16] = {
  51. 1, 0, 0, 0,
  52. 0, 1, 0, 0,
  53. 0, 0, 1, 0,
  54. 0, 2, 0, 1
  55. };
  56. //bool transformMatrixDirty = true;
  57. GLFWwindow *window;
  58. OpenGLWindowHandle *openglWindow;
  59. int windowWidth;
  60. int windowHeight;
  61. //std::shared_ptr<Node> domRootNode = nullptr;
  62. //bool domDirty = false;
  63. bool renderDirty = true;
  64. //ComponentBuilder componentBuilder;
  65. //std::shared_ptr<Component> rootComponent = std::make_shared<Component>();
  66. // could break these out in some sort of cursor class
  67. // to minimize dependencies
  68. //std::shared_ptr<Component> focusedComponent = nullptr;
  69. //std::shared_ptr<Component> hoverComponent = nullptr;
  70. double cursorX = 0;
  71. double cursorY = 0;
  72. unsigned int delayResize = 0;
  73. GLFWcursor* cursorHand;
  74. GLFWcursor* cursorArrow;
  75. GLFWcursor* cursorIbeam;
  76. // why is this a pointer? I think we thought it'd make moving the UI between windows easier
  77. // open to opinions on changing this to a not-pointer
  78. std::unique_ptr<MultiComponent> ui = nullptr;
  79. ShaderLoader shaderLoader;
  80. // is there only one selection per window? (probably not)
  81. int highlightStartX = 0;
  82. int highlightStartY = 0;
  83. std::vector<std::shared_ptr<Component>> selectionList;
  84. // multiwindow support
  85. size_t id; // key for shader caches
  86. unsigned int clearColor = 0xCCCCCCCC;
  87. // I hate doing this but we currently require this
  88. // FIXME: move these out into browser somehow
  89. std::shared_ptr<DocumentComponent> getActiveDocumentComponent();
  90. std::shared_ptr<Component> tabComponent = nullptr;
  91. std::shared_ptr<Component> addressComponent = nullptr;
  92. };
  93. //bool setWindowContent(URL const& url);
  94. //void handleRequest(const HTTPResponse &response);
  95. //extern const std::unique_ptr<Window> window;
  96. #endif