diff options
author | crupest <crupest@outlook.com> | 2020-11-09 18:28:33 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-11-09 18:28:33 +0800 |
commit | ddc6d6478f849ef10b832bc8b1d8ab7fe9454601 (patch) | |
tree | fe1fd08653d97a625d75040d5451081079f404f5 /include/cru | |
parent | 349b26d350d46fd6c48c6895ee9d8ef81add1315 (diff) | |
download | cru-ddc6d6478f849ef10b832bc8b1d8ab7fe9454601.tar.gz cru-ddc6d6478f849ef10b832bc8b1d8ab7fe9454601.tar.bz2 cru-ddc6d6478f849ef10b832bc8b1d8ab7fe9454601.zip |
...
Diffstat (limited to 'include/cru')
-rw-r--r-- | include/cru/ui/controls/Window.hpp | 8 | ||||
-rw-r--r-- | include/cru/ui/host/WindowHost.hpp | 13 |
2 files changed, 15 insertions, 6 deletions
diff --git a/include/cru/ui/controls/Window.hpp b/include/cru/ui/controls/Window.hpp index 616e2ee7..996bc75e 100644 --- a/include/cru/ui/controls/Window.hpp +++ b/include/cru/ui/controls/Window.hpp @@ -24,13 +24,13 @@ class Window final : public LayoutControl { render::RenderObject* GetRenderObject() const override; - protected: - void OnAddChild(Control* child, Index position) override; - void OnRemoveChild(Control* child, Index position) override; + // If create is false and native window is not create, it will not be created + // and shown. + void Show(bool create = true); private: std::unique_ptr<host::WindowHost> window_host_; std::unique_ptr<render::StackLayoutRenderObject> render_object_; }; -} // namespace cru::ui +} // namespace cru::ui::controls diff --git a/include/cru/ui/host/WindowHost.hpp b/include/cru/ui/host/WindowHost.hpp index 6d338df1..9fc24eb2 100644 --- a/include/cru/ui/host/WindowHost.hpp +++ b/include/cru/ui/host/WindowHost.hpp @@ -28,8 +28,7 @@ class WindowHost : public Object { CRU_DEFINE_CLASS_LOG_TAG(u"cru::ui::host::WindowHost") public: - WindowHost(controls::Control* root_control, - CreateWindowParams create_window_params = {}); + WindowHost(controls::Control* root_control); CRU_DELETE_COPY(WindowHost) CRU_DELETE_MOVE(WindowHost) @@ -39,6 +38,10 @@ class WindowHost : public Object { public: platform::gui::INativeWindow* GetNativeWindow() { return native_window_; } + // Do nothing if native window is already created. + gsl::not_null<platform::gui::INativeWindow*> CreateNativeWindow( + CreateWindowParams create_window_params = {}); + // Mark the layout as invalid, and arrange a re-layout later. // This method could be called more than one times in a message cycle. But // layout only takes place once. @@ -102,6 +105,10 @@ class WindowHost : public Object { void UpdateCursor(); + IEvent<platform::gui::INativeWindow*>* NativeWindowChangeEvent() { + return &native_window_change_event_; + } + private: //*************** region: native messages *************** void OnNativeDestroy(platform::gui::INativeWindow* window, std::nullptr_t); @@ -152,5 +159,7 @@ class WindowHost : public Object { controls::Control* mouse_captured_control_ = nullptr; bool layout_prefer_to_fill_window_ = true; + + Event<platform::gui::INativeWindow*> native_window_change_event_; }; } // namespace cru::ui::host |