Lugdunum  0.1.0
Window.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <queue>
5 #include <string>
6 #include <unordered_map>
7 #include <lug/Math/Vector.hpp>
8 #include <lug/Window/Event.hpp>
9 #include <lug/Window/Export.hpp>
10 #include <lug/Window/Keyboard.hpp>
12 
13 namespace lug {
14 namespace Window {
15 
21 namespace priv {
22  class WindowImpl;
23 } // namespace priv
24 
32 struct VideoMode {
33  uint16_t width;
34  uint16_t height;
35  uint8_t redBits;
36  uint8_t greenBits;
37  uint8_t blueBits;
38  uint16_t refreshRate;
39 };
40 
44 enum class LUG_WINDOW_API Style : uint16_t {
45  None = 0,
46  Titlebar = 1 << 0,
47  Resize = 1 << 1,
48  Close = 1 << 2,
49  Fullscreen = 1 << 3,
50 
52 };
53 
54 #include <lug/Window/Style.inl>
55 
60 public:
61  struct InitInfo {
62  uint16_t width;
63  uint16_t height;
64  std::string title;
66  };
67 
68 public:
69  Window(const Window&) = delete;
70  Window(Window&&) = delete;
71  Window& operator=(const Window&) = delete;
72  Window& operator=(Window&&) = delete;
73  virtual ~Window();
74 
82  static std::unique_ptr<Window> create(const InitInfo& initInfo);
83 
89  bool isOpen() const;
90 
99  virtual bool pollEvent(lug::Window::Event& event);
100 
104  void close();
105 
113  void setKeyRepeat(bool state);
114 
122  bool isKeyPressed(Keyboard::Key key) const;
123 
131  bool isMousePressed(Mouse::Button button) const;
132 
138  const Math::Vec2i& getMousePos() const;
139 
145  void setMousePos(const Math::Vec2i& mousePosition);
146 
152  Math::Vec2i getWindowSize() const;
153 
159  void setMouseCursorVisible(bool visible);
160 
161  GamePadEvent _gamePadState{{0.0f, 0.0f}, {0.0f, 0.0f}};
162  TouchScreenEvent _touchScreenState{{{0, 0}, {0, 0}}, lug::Window::TouchScreenEvent::GestureState::None, false, false, false};
163 protected:
164  Window();
165  bool init(const InitInfo& initInfo);
166 
170  void initKeyState();
171 
175  void initMouseState();
176 
180  priv::WindowImpl* _impl{nullptr};
181 
185  VideoMode _mode{800, 600, 8, 8, 8, 60};
186 
190  std::unordered_map<Keyboard::Key, bool> _keyState;
191 
195  std::unordered_map<Mouse::Button, bool> _mouseState;
196 
200  Math::Vec2i _mousePosition{0, 0};
202 };
203 
204 } // namespace Window
205 } // namespace lug
Represents an event.
Definition: Event.hpp:89
::lug::Window::Style style
Definition: Window.hpp:65
std::unordered_map< Keyboard::Key, bool > _keyState
Definition: Window.hpp:190
The video mode we set for the window we wish to create.
Definition: Window.hpp:32
Class for window.
Definition: Window.hpp:59
Key
Abstraction of keyboard keys.
Definition: Keyboard.hpp:23
Button
Abstraction of Mouse buttons.
Definition: Mouse.hpp:26
uint16_t refreshRate
Definition: Window.hpp:38
#define LUG_WINDOW_API
Definition: Export.hpp:11
void close(Handle handle)
Definition: Library.inl:48
std::unordered_map< Mouse::Button, bool > _mouseState
Definition: Window.hpp:195