sandbox
Loading...
Searching...
No Matches
window.hpp
1#ifndef LIBSBX_DEVICES_WINDOW_HPP_
2#define LIBSBX_DEVICES_WINDOW_HPP_
3
4#include <GLFW/glfw3.h>
5
6#include <stdexcept>
7#include <functional>
8#include <filesystem>
9#include <unordered_set>
10#include <cmath>
11
12#include <libsbx/utility/target.hpp>
13
14#include <libsbx/core/concepts.hpp>
16#include <libsbx/core/version.hpp>
17
18#include <libsbx/math/vector2.hpp>
19
20#include <libsbx/signals/signal.hpp>
21
22#include <libsbx/devices/events.hpp>
23#include <libsbx/devices/input.hpp>
24
25namespace sbx::devices {
26
28 std::string title{};
29 std::uint32_t width{};
30 std::uint32_t height{};
31}; // struct window_create_info
32
33class window {
34
35public:
36
37 window(const window_create_info& create_info);
38
39 ~window();
40
41 auto handle() -> GLFWwindow*;
42
43 operator GLFWwindow*();
44
45 auto title() const -> const std::string&;
46
47 auto set_title(const std::string& title) -> void;
48
49 auto width() const -> std::uint32_t;
50
51 auto height() const -> std::uint32_t;
52
53 auto aspect_ratio() const -> std::float_t;
54
59 auto should_close() -> bool;
60
64 auto show() -> void;
65
69 auto hide() -> void;
70
71 auto is_iconified() const noexcept -> bool;
72
73 auto is_focused() const noexcept -> bool;
74
75 auto is_visible() const noexcept -> bool;
76
77 auto on_window_closed_signal() -> signals::signal<const window_closed_event&>&;
78
79 auto on_window_moved_signal() -> signals::signal<const window_moved_event&>&;
80
81 auto on_window_resized_signal() -> signals::signal<const window_resized_event&>&;
82
83 auto on_framebuffer_resized() -> signals::signal<const framebuffer_resized_event&>&;
84
85 auto on_key_pressed() -> signals::signal<const key_pressed_event&>&;
86
87 auto on_key_released() -> signals::signal<const key_released_event&>&;
88
89 auto on_mouse_moved() -> signals::signal<const mouse_moved_event&>&;
90
91private:
92
93 auto _set_callbacks() -> void;
94
95 std::string _title{};
96 std::uint32_t _width{};
97 std::uint32_t _height{};
98
99 GLFWwindow* _handle{};
100
101 math::vector2 _last_mouse_position;
102
103 signals::signal<const window_closed_event&> _on_window_closed_signal;
104 signals::signal<const window_moved_event&> _on_window_moved_signal;
105 signals::signal<const window_resized_event&> _on_window_resized_signal;
113
114}; // class window
115
116} // namespace sbx::devices
117
118#endif // LIBSBX_DEVICES_WINDOW_HPP_
Definition: window.hpp:33
auto show() -> void
Makes the window visible.
Definition: window.cpp:101
auto should_close() -> bool
Determins if the window should be closed.
Definition: window.cpp:97
auto hide() -> void
Hides the window.
Definition: window.cpp:105
A vector in two-dimensional space.
Definition: vector2.hpp:27
Definition: signal.hpp:16
Definition: window.hpp:27