summaryrefslogtreecommitdiff
path: root/window.h
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2022-01-23 17:11:38 -0700
committercflip <cflip@cflip.net>2022-01-23 17:11:38 -0700
commit98e2eb0beed4f57461956a10eeae014bf88a51c6 (patch)
treee180295cf1286f8cc4b7127e275746c0c733bc0b /window.h
parent6085e71a3274cfadc0e52a4f2355af0176310df0 (diff)
Simple tile editor
Diffstat (limited to 'window.h')
-rw-r--r--window.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/window.h b/window.h
new file mode 100644
index 0000000..bdd1e91
--- /dev/null
+++ b/window.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <functional>
+
+class Bitmap;
+
+struct SDL_Window;
+struct SDL_Renderer;
+struct SDL_Texture;
+
+class Window {
+public:
+ Window(const char* title, int width, int height, int scale);
+ ~Window();
+
+ void update();
+ void draw(Bitmap&);
+
+ bool shouldClose() { return !m_isRunning; }
+
+ void onMouseDown(std::function<void(int, int, int)> callback) { m_mouseDown = callback; }
+ void onMouseUp(std::function<void(int, int, int)> callback) { m_mouseUp = callback; }
+ void onMouseMove(std::function<void(int, int)> callback) { m_mouseMove = callback; }
+private:
+ bool m_isRunning;
+
+ int m_width, m_height, m_scale;
+
+ SDL_Window* m_window;
+ SDL_Renderer* m_renderer;
+ SDL_Texture* m_texture;
+
+ std::function<void(int, int, int)> m_mouseDown;
+ std::function<void(int, int, int)> m_mouseUp;
+ std::function<void(int, int)> m_mouseMove;
+}; \ No newline at end of file