aboutsummaryrefslogtreecommitdiff
path: root/src/osx/gui/Window.mm
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-10-02 16:44:32 +0800
committercrupest <crupest@outlook.com>2021-10-02 16:44:32 +0800
commit24a636954a25e938c079d88f48ee01143d667cfb (patch)
tree5901c9a6eb41907976d38401f3617fc30de62052 /src/osx/gui/Window.mm
parentf246877698e5b9aa98e99f3fd3d2247998008695 (diff)
downloadcru-24a636954a25e938c079d88f48ee01143d667cfb.tar.gz
cru-24a636954a25e938c079d88f48ee01143d667cfb.tar.bz2
cru-24a636954a25e938c079d88f48ee01143d667cfb.zip
...
Diffstat (limited to 'src/osx/gui/Window.mm')
-rw-r--r--src/osx/gui/Window.mm14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/osx/gui/Window.mm b/src/osx/gui/Window.mm
index 52cc3934..239e175a 100644
--- a/src/osx/gui/Window.mm
+++ b/src/osx/gui/Window.mm
@@ -1,9 +1,11 @@
#include "cru/osx/gui/Window.hpp"
+#include "cru/osx/graphics/quartz/Painter.hpp"
#include "cru/osx/gui/UiApplication.hpp"
-#include "cru/platform/gui/Base.hpp"
+#include <AppKit/NSGraphicsContext.h>
#include <AppKit/NSWindow.h>
+#include <memory>
namespace cru::platform::gui::osx {
namespace details {
@@ -112,6 +114,16 @@ void OsxWindow::SetWindowRect(const Rect& rect) {
}
}
+std::unique_ptr<graphics::IPainter> OsxWindow::BeginPaint() {
+ NSGraphicsContext* ns_graphics_context =
+ [NSGraphicsContext graphicsContextWithWindow:p_->window_];
+
+ CGContextRef cg_context = [ns_graphics_context CGContext];
+
+ return std::make_unique<cru::platform::graphics::osx::quartz::QuartzCGContextPainter>(
+ GetUiApplication()->GetGraphicsFactory(), cg_context, true, GetClientSize());
+}
+
void OsxWindow::CreateWindow() {
NSRect content_rect{p_->content_rect_.left, p_->content_rect_.top, p_->content_rect_.width,
p_->content_rect_.height};