hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/core/window.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2025-08-12 16:35:42 +0200
committerhachem <im@hachem.wtf>2025-08-12 16:35:42 +0200
commitdbe642e5e26cf2bd99218f727157b58c7fed286e (patch)
treeb964424747bdd0b143a4dfac894aee61fd752302 /src/core/window.h
parentd6b9f6c8fad3e46caca5dc167ce1cbf5ccfb489e (diff)
feat: application manager and EventDispatcher
Diffstat (limited to 'src/core/window.h')
-rw-r--r--src/core/window.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/core/window.h b/src/core/window.h
index 5f0e36e..8e9778e 100644
--- a/src/core/window.h
+++ b/src/core/window.h
@@ -2,23 +2,51 @@
#include <GLFW/glfw3.h>
#include <string>
+#include "event.h"
namespace Donut
{
class Window
{
public:
+ using EventCallbackFn = std::function<void(Event&)>;
+
Window(const std::string& title, int width, int height);
~Window();
bool should_close() const;
void on_update() const;
+
+ void set_event_callback(const EventCallbackFn& callback) { m_event_handler.set_event_callback(callback); }
+ EventHandler& get_event_handler() { return m_event_handler; }
+
+ unsigned int get_width() const { return m_width; }
+ unsigned int get_height() const { return m_height; }
+
+ void* get_native_window() const { return m_window; }
+
+ private:
+ void init();
+ void shutdown();
+
+ static void glfw_error_callback(int error, const char* description);
+ static void glfw_window_close_callback(GLFWwindow* window);
+ static void glfw_window_size_callback(GLFWwindow* window, int width, int height);
+ static void glfw_window_focus_callback(GLFWwindow* window, int focused);
+ static void glfw_window_pos_callback(GLFWwindow* window, int xpos, int ypos);
+ static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
+ static void glfw_char_callback(GLFWwindow* window, unsigned int keycode);
+ static void glfw_mouse_button_callback(GLFWwindow* window, int button, int action, int mods);
+ static void glfw_mouse_scroll_callback(GLFWwindow* window, double x_offset, double y_offset);
+ static void glfw_cursor_pos_callback(GLFWwindow* window, double x_pos, double y_pos);
+
private:
GLFWwindow* m_window;
+ EventHandler m_event_handler;
std::string m_title;
- int m_width;
- int m_height;
+ unsigned int m_width;
+ unsigned int m_height;
bool m_is_closed;
};
}