From e69911a8b161b81ce3f7b209175766da2b7b3d4b Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 12 Dec 2019 19:53:17 +0800 Subject: ... --- include/cru/platform/native/native_window.hpp | 34 ++++++++++----------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'include/cru/platform/native/native_window.hpp') diff --git a/include/cru/platform/native/native_window.hpp b/include/cru/platform/native/native_window.hpp index 8a067a4c..cd2459e0 100644 --- a/include/cru/platform/native/native_window.hpp +++ b/include/cru/platform/native/native_window.hpp @@ -9,7 +9,7 @@ #include "native_event.hpp" namespace cru::platform::graph { -class Painter; +struct IPainter; } namespace cru::platform::native { @@ -21,28 +21,18 @@ namespace cru::platform::native { // Close or closed by the user, which leads to an invalid instance. You can // check the validity by IsValid. When you call perform native operations on the // invalid instance, there is no effect. -class NativeWindow : public NativeResource { - protected: - NativeWindow() = default; - - public: - NativeWindow(const NativeWindow& other) = delete; - NativeWindow& operator=(const NativeWindow& other) = delete; - - NativeWindow(NativeWindow&& other) = delete; - NativeWindow& operator=(NativeWindow&& other) = delete; - - ~NativeWindow() override = default; - - public: +struct INativeWindow : public virtual INativeResource { // Return if the window is still valid, that is, hasn't been closed or // destroyed. virtual bool IsValid() = 0; + + // Set if the instance is deleted automatically when the window is destroyed + // by other ways. Default is true. virtual void SetDeleteThisOnDestroy(bool value) = 0; virtual void Close() = 0; - virtual NativeWindow* GetParent() = 0; + virtual INativeWindow* GetParent() = 0; virtual bool IsVisible() = 0; virtual void SetVisible(bool is_visible) = 0; @@ -64,16 +54,18 @@ class NativeWindow : public NativeResource { virtual bool CaptureMouse() = 0; virtual bool ReleaseMouse() = 0; - virtual void SetCursor(std::shared_ptr cursor) = 0; + virtual void SetCursor(std::shared_ptr cursor) = 0; + + virtual void RequestRepaint() = 0; - virtual void Repaint() = 0; - virtual graph::Painter* BeginPaint() = 0; + // Remember to call EndDraw on return value and destroy it. + virtual std::unique_ptr BeginPaint() = 0; virtual IEvent* DestroyEvent() = 0; virtual IEvent* PaintEvent() = 0; virtual IEvent* ResizeEvent() = 0; - virtual IEvent* FocusEvent() = 0; - virtual IEvent* MouseEnterLeaveEvent() = 0; + virtual IEvent* FocusEvent() = 0; + virtual IEvent* MouseEnterLeaveEvent() = 0; virtual IEvent* MouseMoveEvent() = 0; virtual IEvent* MouseDownEvent() = 0; virtual IEvent* MouseUpEvent() = 0; -- cgit v1.2.3