ShishGL  1.0
A simple modular cross-platform graphics library
Window.hpp
Go to the documentation of this file.
1 /*============================================================================*/
2 #ifndef SHISHGL_WINDOW_HPP
3 #define SHISHGL_WINDOW_HPP
4 /*============================================================================*/
5 #include <list>
6 
8 #include "PlatformListener.hpp"
9 #include "MouseEvent.hpp"
10 #include "EventSystem.hpp"
11 #include "Frame.hpp"
12 #include "WindowManager.hpp"
13 /*============================================================================*/
14 namespace Sh {
15 
16  class Window : public Listener {
17  public:
18 
19  Window() = delete;
20 
21  ~Window() override = default;
22 
23  /* No-Copyable */
24  /*-----------------------------------------------*/
25  Window(const Window& other) = delete;
26  Window& operator=(const Window& other) = delete;
27  /*-----------------------------------------------*/
28 
29  /*-----------------------------------------------*/
30  [[nodiscard]]
31  const Window* getParent() const;
32 
33  template <typename SomeWindow, typename... Args>
34  SomeWindow* attach(Args&&... args);
35 
36  template <typename SomeWindow>
37  SomeWindow* attach(SomeWindow* child);
38 
39  Window* detach(Window* child);
40  /*-----------------------------------------------*/
41 
42  /*-----------------------------------------------*/
43  [[nodiscard]]
44  const Frame& getFrame() const;
45 
46  [[nodiscard]]
47  const Vector2<double>& getSize() const;
48 
49  [[nodiscard]]
50  const Vector2<double>& getPos() const;
51 
52  [[nodiscard]]
53  virtual bool contains(const Vector2<double>& point) const;
54 
55  virtual void setPos(const Vector2<double>& pos);
56 
57  virtual void translate(const Vector2<double>& delta);
58  /*-----------------------------------------------*/
59 
60  const std::list<Window*>& getChildren() {
61  return children;
62  }
63 
64  protected:
65 
66  explicit Window(const Frame& frame);
67 
68  virtual void onRender();
69 
70  virtual void setParent(Window* new_parent);
71 
72  private:
73 
74  void render();
75 
76  void fitParent();
77 
78  friend class WindowManager;
79 
80  /* DATA */
81  Frame frame;
82  Frame viewport;
83  Window* parent;
84  std::list<Window*> children;
85 
86  };
87 
88 }
89 /*============================================================================*/
90 #include "Window.ipp"
91 /*============================================================================*/
92 #endif //SHISHGL_WINDOW_HPP
93 /*============================================================================*/
Sh::Window::getPos
const Vector2< double > & getPos() const
Definition: Window.cpp:31
Sh::WindowManager
Definition: WindowManager.hpp:13
Sh::Window::detach
Window * detach(Window *child)
Definition: Window.cpp:74
Sh::Window::getChildren
const std::list< Window * > & getChildren()
Definition: Window.hpp:60
Sh::Window
Definition: Window.hpp:16
Sh::Window::translate
virtual void translate(const Vector2< double > &delta)
Definition: Window.cpp:98
Sh::Window::getParent
const Window * getParent() const
Definition: Window.cpp:19
Sh::Frame
Definition: Frame.hpp:9
Sh::Window::contains
virtual bool contains(const Vector2< double > &point) const
Definition: Window.cpp:110
Sh::Vector2< double >
SubscriptionManager.hpp
Window.ipp
MouseEvent.hpp
PlatformListener.hpp
Sh::Window::setPos
virtual void setPos(const Vector2< double > &pos)
Definition: Window.cpp:84
Sh::Window::getSize
const Vector2< double > & getSize() const
Definition: Window.cpp:27
Sh::Window::setParent
virtual void setParent(Window *new_parent)
Definition: Window.cpp:37
Sh::Window::~Window
~Window() override=default
Sh::Window::Window
Window(const Window &other)=delete
Sh
Definition: CoreApplication.hpp:10
WindowManager.hpp
Frame.hpp
Sh::Window::attach
SomeWindow * attach(Args &&... args)
Definition: Window.ipp:8
Sh::Window::onRender
virtual void onRender()
Definition: Window.cpp:56
Sh::Window::operator=
Window & operator=(const Window &other)=delete
EventSystem.hpp
Sh::Listener
Definition: Listener.hpp:7
Sh::Window::Window
Window()=delete
Sh::Window::getFrame
const Frame & getFrame() const
Definition: Window.cpp:23