diff options
author | crupest <crupest@outlook.com> | 2022-02-16 23:04:27 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-16 23:04:27 +0800 |
commit | 9307bd1af7c52aaf9c6d25b598bf3069a63c32a1 (patch) | |
tree | a3e485ad60a0114f42dfe3c8d4c64bee87c91ba5 /include/cru/ui/controls | |
parent | f75ab0bd662c73d15057d746347d09bf94a992a6 (diff) | |
download | cru-9307bd1af7c52aaf9c6d25b598bf3069a63c32a1.tar.gz cru-9307bd1af7c52aaf9c6d25b598bf3069a63c32a1.tar.bz2 cru-9307bd1af7c52aaf9c6d25b598bf3069a63c32a1.zip |
...
Diffstat (limited to 'include/cru/ui/controls')
-rw-r--r-- | include/cru/ui/controls/Control.h | 14 | ||||
-rw-r--r-- | include/cru/ui/controls/RootControl.h | 4 | ||||
-rw-r--r-- | include/cru/ui/controls/SingleChildControl.h | 3 |
3 files changed, 15 insertions, 6 deletions
diff --git a/include/cru/ui/controls/Control.h b/include/cru/ui/controls/Control.h index 97096e35..4dad4549 100644 --- a/include/cru/ui/controls/Control.h +++ b/include/cru/ui/controls/Control.h @@ -17,6 +17,8 @@ namespace cru::ui::controls { * former one is even not used. */ class CRU_UI_API Control : public Object { + friend class RootControl; + protected: Control(); @@ -32,7 +34,7 @@ class CRU_UI_API Control : public Object { //*************** region: tree *************** public: - virtual host::WindowHost* GetWindowHost() const; + host::WindowHost* GetWindowHost() const { return window_host_; } Control* GetParent() const { return parent_; } void SetParent(Control* parent); @@ -143,12 +145,22 @@ class CRU_UI_API Control : public Object { protected: virtual void OnParentChanged(Control* old_parent, Control* new_parent) {} + virtual void OnWindowHostChanged(host::WindowHost* old_host, + host::WindowHost* new_host) {} + protected: virtual void OnMouseHoverChange(bool newHover) { CRU_UNUSED(newHover) } private: + void OnParentChangedCore(Control* old_parent, Control* new_parent); + void OnWindowHostChangedCore(host::WindowHost* old_host, + host::WindowHost* new_host); + + private: Control* parent_ = nullptr; + host::WindowHost* window_host_ = nullptr; + private: bool is_mouse_over_ = false; diff --git a/include/cru/ui/controls/RootControl.h b/include/cru/ui/controls/RootControl.h index a1878836..851b4db0 100644 --- a/include/cru/ui/controls/RootControl.h +++ b/include/cru/ui/controls/RootControl.h @@ -18,10 +18,6 @@ class CRU_UI_API RootControl ~RootControl() override; public: - host::WindowHost* GetWindowHost() const override { - return window_host_.get(); - } - platform::gui::INativeWindow* GetNativeWindow(); protected: diff --git a/include/cru/ui/controls/SingleChildControl.h b/include/cru/ui/controls/SingleChildControl.h index 6bf150c0..e733c825 100644 --- a/include/cru/ui/controls/SingleChildControl.h +++ b/include/cru/ui/controls/SingleChildControl.h @@ -31,7 +31,8 @@ class SingleChildControl : public Control { child->SetParent(this); } - container_render_object_->SetChild(child->GetRenderObject()); + container_render_object_->SetChild( + child == nullptr ? nullptr : child->GetRenderObject()); } render::RenderObject* GetRenderObject() const override { |