diff options
author | crupest <crupest@outlook.com> | 2019-04-01 15:51:56 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-01 15:51:56 +0800 |
commit | 9e382d2175c6706e69b734480e26032e16d0bde4 (patch) | |
tree | 2702ea4dedabd5fad4be7b0f5eea1af7b7bda121 /include/cru/platform/win | |
parent | 3e89aa733587043645f5fda72596e4ff3cd21d2a (diff) | |
download | cru-9e382d2175c6706e69b734480e26032e16d0bde4.tar.gz cru-9e382d2175c6706e69b734480e26032e16d0bde4.tar.bz2 cru-9e382d2175c6706e69b734480e26032e16d0bde4.zip |
...
Diffstat (limited to 'include/cru/platform/win')
-rw-r--r-- | include/cru/platform/win/win_brush.hpp | 10 | ||||
-rw-r--r-- | include/cru/platform/win/win_native_window.hpp | 2 | ||||
-rw-r--r-- | include/cru/platform/win/win_painter.hpp | 34 |
3 files changed, 45 insertions, 1 deletions
diff --git a/include/cru/platform/win/win_brush.hpp b/include/cru/platform/win/win_brush.hpp index 2668215d..d32f6bbc 100644 --- a/include/cru/platform/win/win_brush.hpp +++ b/include/cru/platform/win/win_brush.hpp @@ -4,7 +4,13 @@ #include "../brush.hpp" namespace cru::platform::win { -class WinSolidColorBrush : public Object, public virtual SolidColorBrush { +struct WinBrush : virtual Brush { + virtual ID2D1Brush* GetD2DBrush() = 0; +}; + +class WinSolidColorBrush : public Object, + public virtual SolidColorBrush, + public virtual WinBrush { public: explicit WinSolidColorBrush( Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> brush); @@ -17,6 +23,8 @@ class WinSolidColorBrush : public Object, public virtual SolidColorBrush { ui::Color GetColor() override; void SetColor(const ui::Color& color) override; + ID2D1Brush* GetD2DBrush() override { return brush_.Get(); } + private: Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> brush_; }; diff --git a/include/cru/platform/win/win_native_window.hpp b/include/cru/platform/win/win_native_window.hpp index 8b787485..ae19c9f3 100644 --- a/include/cru/platform/win/win_native_window.hpp +++ b/include/cru/platform/win/win_native_window.hpp @@ -44,6 +44,8 @@ class WinNativeWindow : public Object, public virtual NativeWindow { // The lefttop of the rect is relative to screen lefttop. void SetWindowRect(const ui::Rect& rect) override; + Painter* BeginPaint() override; + Event<>* DestroyEvent() override { return &destroy_event_; } Event<ui::Size>* ResizeEvent() override { return &resize_event_; } Event<>* PaintEvent() override { return &paint_event_; } diff --git a/include/cru/platform/win/win_painter.hpp b/include/cru/platform/win/win_painter.hpp new file mode 100644 index 00000000..7b71ccbd --- /dev/null +++ b/include/cru/platform/win/win_painter.hpp @@ -0,0 +1,34 @@ +#pragma once +#include "win_pre_config.hpp" + +#include "../painter.hpp" + +namespace cru::platform::win { +class WinNativeWindow; + +class WinPainter : public Object, public virtual Painter { + public: + explicit WinPainter(WinNativeWindow* window); + WinPainter(const WinPainter& other) = delete; + WinPainter(WinPainter&& other) = delete; + WinPainter& operator=(const WinPainter& other) = delete; + WinPainter& operator=(WinPainter&& other) = delete; + ~WinPainter() override; + + void StrokeGeometry(Geometry* geometry, Brush* brush, float width) override; + void FillGeometry(Geometry* geometry, Brush* brush) override; + void EndDraw() override; + bool IsDisposed() override { return is_disposed; } + + void EndDrawAndDeleteThis() { + EndDraw(); + delete this; + } + + private: + WinNativeWindow* window_; + ID2D1RenderTarget* render_target_; + + bool is_disposed = false; +}; +} // namespace cru::platform::win |