diff options
Diffstat (limited to 'include/cru/platform/native/window.hpp')
-rw-r--r-- | include/cru/platform/native/window.hpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/include/cru/platform/native/window.hpp b/include/cru/platform/native/window.hpp index bfaf170b..84193a13 100644 --- a/include/cru/platform/native/window.hpp +++ b/include/cru/platform/native/window.hpp @@ -12,22 +12,17 @@ struct IPainter; } namespace cru::platform::native { +struct INativeWindowResolver; + // Represents a native window, which exposes some low-level events and // operations. // -// Although you can always retain an instance of this class, the real window -// associated with it might be have already been destroyed by explicitly calling -// 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. +// Usually you save an INativeWindowResolver after creating a window. Because +// window may be destroyed when user do certain actions like click the close +// button. Then the INativeWindow instance is destroyed and +// INativeWindowResolver::Resolve return nullptr to indicate the fact. struct INativeWindow : 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 std::shared_ptr<INativeWindowResolver> GetResolver() = 0; virtual void Close() = 0; @@ -71,4 +66,9 @@ struct INativeWindow : virtual INativeResource { virtual IEvent<int>* KeyDownEvent() = 0; virtual IEvent<int>* KeyUpEvent() = 0; }; + +// See INativeWindow for more info. +struct INativeWindowResolver : virtual INativeResource { + virtual INativeWindow* Resolve() = 0; +}; } // namespace cru::platform::native |