diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/ui/Base.hpp | 3 | ||||
-rw-r--r-- | include/cru/ui/Control.hpp | 10 | ||||
-rw-r--r-- | include/cru/ui/Window.hpp | 2 | ||||
-rw-r--r-- | include/cru/ui/host/WindowHost.hpp (renamed from include/cru/ui/WindowHost.hpp) | 8 | ||||
-rw-r--r-- | include/cru/ui/render/RenderObject.hpp | 12 |
5 files changed, 19 insertions, 16 deletions
diff --git a/include/cru/ui/Base.hpp b/include/cru/ui/Base.hpp index 36d0eb78..39fbb035 100644 --- a/include/cru/ui/Base.hpp +++ b/include/cru/ui/Base.hpp @@ -29,7 +29,10 @@ namespace colors = cru::platform::colors; class Window; class Control; class ClickDetector; + +namespace host { class WindowHost; +} namespace render { class RenderObject; diff --git a/include/cru/ui/Control.hpp b/include/cru/ui/Control.hpp index 5f381965..fe50624a 100644 --- a/include/cru/ui/Control.hpp +++ b/include/cru/ui/Control.hpp @@ -9,7 +9,7 @@ namespace cru::ui { class Control : public Object { - friend WindowHost; + friend host::WindowHost; protected: Control(); @@ -26,7 +26,7 @@ class Control : public Object { //*************** region: tree *************** public: - WindowHost* GetWindowHost() const; + host::WindowHost* GetWindowHost() const; Control* GetParent() const { return parent_; } @@ -131,8 +131,8 @@ class Control : public Object { virtual void OnAddChild(Control* child, Index position); virtual void OnRemoveChild(Control* child, Index position); virtual void OnParentChanged(Control* old_parent, Control* new_parent); - virtual void OnAttachToHost(WindowHost* host); - virtual void OnDetachFromHost(WindowHost* host); + virtual void OnAttachToHost(host::WindowHost* host); + virtual void OnDetachFromHost(host::WindowHost* host); protected: virtual void OnMouseHoverChange(bool newHover) { CRU_UNUSED(newHover) } @@ -141,7 +141,7 @@ class Control : public Object { Control* parent_ = nullptr; std::vector<Control*> children_; - WindowHost* window_host_ = nullptr; + host::WindowHost* window_host_ = nullptr; private: bool is_mouse_over_ = false; diff --git a/include/cru/ui/Window.hpp b/include/cru/ui/Window.hpp index 0739e3dc..70423a14 100644 --- a/include/cru/ui/Window.hpp +++ b/include/cru/ui/Window.hpp @@ -29,7 +29,7 @@ class Window final : public LayoutControl { void OnRemoveChild(Control* child, Index position) override; private: - std::unique_ptr<WindowHost> window_host_; + std::unique_ptr<host::WindowHost> window_host_; std::unique_ptr<render::StackLayoutRenderObject> render_object_; }; diff --git a/include/cru/ui/WindowHost.hpp b/include/cru/ui/host/WindowHost.hpp index 7f7d62f0..77ed937f 100644 --- a/include/cru/ui/WindowHost.hpp +++ b/include/cru/ui/host/WindowHost.hpp @@ -1,19 +1,19 @@ #pragma once -#include "Base.hpp" +#include "../Base.hpp" #include "cru/common/Event.hpp" #include "cru/platform/gui/UiApplication.hpp" #include "cru/platform/gui/Window.hpp" -#include "render/Base.hpp" +#include "../render/Base.hpp" #include <functional> -namespace cru::ui { +namespace cru::ui::host { struct AfterLayoutEventArgs {}; // The bridge between control tree and native window. class WindowHost : public Object { - CRU_DEFINE_CLASS_LOG_TAG(u"cru::ui::WindowHost") + CRU_DEFINE_CLASS_LOG_TAG(u"cru::ui::host::WindowHost") public: WindowHost(Control* root_control); diff --git a/include/cru/ui/render/RenderObject.hpp b/include/cru/ui/render/RenderObject.hpp index 436cf6b2..635a541e 100644 --- a/include/cru/ui/render/RenderObject.hpp +++ b/include/cru/ui/render/RenderObject.hpp @@ -39,7 +39,7 @@ namespace cru::ui::render { // Size OnMeasureContent(const MeasureRequirement& requirement) override; // void OnLayoutContent(const Rect& content_rect) override; class RenderObject : public Object { - friend WindowHost; + friend host::WindowHost; CRU_DEFINE_CLASS_LOG_TAG(u"cru::ui::render::RenderObject") @@ -65,7 +65,7 @@ class RenderObject : public Object { Control* GetAttachedControl() const { return control_; } void SetAttachedControl(Control* new_control) { control_ = new_control; } - WindowHost* GetWindowHost() const { return window_host_; } + host::WindowHost* GetWindowHost() const { return window_host_; } RenderObject* GetParent() const { return parent_; } @@ -135,7 +135,7 @@ class RenderObject : public Object { // Add offset before pass point to children. virtual RenderObject* HitTest(const Point& point) = 0; - IEvent<WindowHost*>* AttachToHostEvent() { return &attach_to_host_event_; } + IEvent<host::WindowHost*>* AttachToHostEvent() { return &attach_to_host_event_; } IEvent<std::nullptr_t>* DetachFromHostEvent() { return &detach_from_host_event_; } @@ -205,11 +205,11 @@ class RenderObject : public Object { private: void SetParent(RenderObject* new_parent); - void SetWindowHostRecursive(WindowHost* host); + void SetWindowHostRecursive(host::WindowHost* host); private: Control* control_ = nullptr; - WindowHost* window_host_ = nullptr; + host::WindowHost* window_host_ = nullptr; RenderObject* parent_ = nullptr; std::vector<RenderObject*> children_{}; @@ -225,7 +225,7 @@ class RenderObject : public Object { Thickness margin_{}; Thickness padding_{}; - Event<WindowHost*> attach_to_host_event_; + Event<host::WindowHost*> attach_to_host_event_; Event<std::nullptr_t> detach_from_host_event_; }; } // namespace cru::ui::render |