diff options
| author | hachem <im@hachem.wtf> | 2025-08-12 16:35:42 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2025-08-12 16:35:42 +0200 |
| commit | 16dff443789c7f1461b46ce52966972ae14c042b (patch) | |
| tree | afbaf901703c05cbb5eb18f3333898eb498d2e54 /src/Core/Window.h | |
| parent | ed6de8793f267fb1fc5c9af2e68cd4e573ee1d25 (diff) | |
[add]: Application manager and EventDispatcher
Diffstat (limited to 'src/Core/Window.h')
| -rw-r--r-- | src/Core/Window.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/Core/Window.h b/src/Core/Window.h index 866d144..f954ed6 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 ShouldClose() const; void OnUpdate() const; + + void SetEventCallback(const EventCallbackFn& callback) { m_EventHandler.SetEventCallback(callback); } + EventHandler& GetEventHandler() { return m_EventHandler; } + + unsigned int GetWidth() const { return m_Width; } + unsigned int GetHeight() const { return m_Height; } + + void* GetNativeWindow() const { return m_Window; } + + private: + void Init(); + void Shutdown(); + + static void GLFWErrorCallback(int error, const char* description); + static void GLFWWindowCloseCallback(GLFWwindow* window); + static void GLFWWindowSizeCallback(GLFWwindow* window, int width, int height); + static void GLFWWindowFocusCallback(GLFWwindow* window, int focused); + static void GLFWWindowPosCallback(GLFWwindow* window, int xpos, int ypos); + static void GLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); + static void GLFWCharCallback(GLFWwindow* window, unsigned int keycode); + static void GLFWMouseButtonCallback(GLFWwindow* window, int button, int action, int mods); + static void GLFWMouseScrollCallback(GLFWwindow* window, double xOffset, double yOffset); + static void GLFWCursorPosCallback(GLFWwindow* window, double xPos, double yPos); + private: GLFWwindow* m_Window; + EventHandler m_EventHandler; std::string m_Title; - int m_Width; - int m_Height; + unsigned int m_Width; + unsigned int m_Height; bool m_IsClosed; }; }
\ No newline at end of file |
