aboutsummaryrefslogtreecommitdiff
path: root/src/osx/gui/Window.mm
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-10-03 13:48:15 +0800
committercrupest <crupest@outlook.com>2021-10-03 13:48:15 +0800
commit08833937da98a7119195f980e82762becb563e28 (patch)
treecf83c2e21bb2e030e4bc81ce11727d566b20ddb5 /src/osx/gui/Window.mm
parent24a636954a25e938c079d88f48ee01143d667cfb (diff)
downloadcru-08833937da98a7119195f980e82762becb563e28.tar.gz
cru-08833937da98a7119195f980e82762becb563e28.tar.bz2
cru-08833937da98a7119195f980e82762becb563e28.zip
...
Diffstat (limited to 'src/osx/gui/Window.mm')
-rw-r--r--src/osx/gui/Window.mm20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/osx/gui/Window.mm b/src/osx/gui/Window.mm
index 239e175a..3ff94f68 100644
--- a/src/osx/gui/Window.mm
+++ b/src/osx/gui/Window.mm
@@ -7,6 +7,13 @@
#include <AppKit/NSWindow.h>
#include <memory>
+@interface WindowDelegate : NSObject <NSWindowDelegate>
+- (void)windowWillClose:(NSNotification*)notification;
+- (void)windowDidExpose:(NSNotification*)notification;
+- (void)windowDidUpdate:(NSNotification*)notification;
+- (void)windowDidResize:(NSNotification*)notification;
+@end
+
namespace cru::platform::gui::osx {
namespace details {
class OsxWindowPrivate {
@@ -20,6 +27,12 @@ class OsxWindowPrivate {
~OsxWindowPrivate() = default;
+ public:
+ void OnWindowWillClose();
+ void OnWindowDidExpose();
+ void OnWindowDidUpdate();
+ void OnWindowDidResize();
+
private:
OsxWindow* osx_window_;
@@ -30,6 +43,13 @@ class OsxWindowPrivate {
NSWindow* window_;
};
+
+void OsxWindowPrivate::OnWindowWillClose() { osx_window_->destroy_event_.Raise(nullptr); }
+void OsxWindowPrivate::OnWindowDidExpose() { [window_ update]; }
+void OsxWindowPrivate::OnWindowDidUpdate() { osx_window_->paint_event_.Raise(nullptr); }
+void OsxWindowPrivate::OnWindowDidResize() {
+ osx_window_->resize_event_.Raise(osx_window_->GetClientSize());
+}
}
namespace {