diff options
author | crupest <crupest@outlook.com> | 2020-01-03 00:31:34 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-03 00:31:34 +0800 |
commit | d5ff69096a3f56052b30d8ef827845473d4aa5ea (patch) | |
tree | 8faf7466ea173b66e81da83bdc4e0be1a159e263 /include/cru/platform/native | |
parent | 26c3b5c7a509d0123719f2a6537399c332a48011 (diff) | |
download | cru-d5ff69096a3f56052b30d8ef827845473d4aa5ea.tar.gz cru-d5ff69096a3f56052b30d8ef827845473d4aa5ea.tar.bz2 cru-d5ff69096a3f56052b30d8ef827845473d4aa5ea.zip |
...
Diffstat (limited to 'include/cru/platform/native')
-rw-r--r-- | include/cru/platform/native/ui_application.hpp | 5 | ||||
-rw-r--r-- | include/cru/platform/native/window.hpp | 24 |
2 files changed, 16 insertions, 13 deletions
diff --git a/include/cru/platform/native/ui_application.hpp b/include/cru/platform/native/ui_application.hpp index b69b1f52..edbcc578 100644 --- a/include/cru/platform/native/ui_application.hpp +++ b/include/cru/platform/native/ui_application.hpp @@ -3,6 +3,7 @@ #include <chrono> #include <functional> +#include <memory> #include <vector> namespace cru::platform::graph { @@ -11,6 +12,7 @@ struct IGraphFactory; namespace cru::platform::native { struct INativeWindow; +struct INativeWindowResolver; struct ICursorManager; // The entry point of a ui application. @@ -39,7 +41,8 @@ struct IUiApplication : public virtual INativeResource { virtual void CancelTimer(unsigned long id) = 0; virtual std::vector<INativeWindow*> GetAllWindow() = 0; - virtual INativeWindow* CreateWindow(INativeWindow* parent) = 0; + virtual std::shared_ptr<INativeWindowResolver> CreateWindow( + INativeWindow* parent) = 0; virtual cru::platform::graph::IGraphFactory* GetGraphFactory() = 0; 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 |