diff options
author | crupest <crupest@outlook.com> | 2018-12-06 21:09:12 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-12-06 21:09:12 +0800 |
commit | 03ef76f769a55b694905898c16a176fc6bd4b0d7 (patch) | |
tree | 41e11ed127f9a35f543473c39109487785383daa /src/ui/control.hpp | |
parent | 81fd0725d020e9f302c0d40fd5a5700d3dc871aa (diff) | |
download | cru-03ef76f769a55b694905898c16a176fc6bd4b0d7.tar.gz cru-03ef76f769a55b694905898c16a176fc6bd4b0d7.tar.bz2 cru-03ef76f769a55b694905898c16a176fc6bd4b0d7.zip |
Fix position cache bug.
Diffstat (limited to 'src/ui/control.hpp')
-rw-r--r-- | src/ui/control.hpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/ui/control.hpp b/src/ui/control.hpp index 41d1cfe9..6abcc365 100644 --- a/src/ui/control.hpp +++ b/src/ui/control.hpp @@ -18,7 +18,6 @@ namespace cru::ui { - class Control; class Window; @@ -68,6 +67,8 @@ namespace cru::ui //*************** region: tree *************** virtual StringView GetControlType() const = 0; + virtual const std::vector<Control*>& GetInternalChildren() const = 0; + Control* GetParent() const { return parent_ == nullptr ? internal_parent_ : parent_; @@ -84,9 +85,6 @@ namespace cru::ui return window_; } - - virtual const std::vector<Control*>& GetInternalChildren() const = 0; - void SetParent(Control* parent); void SetInternalParent(Control* internal_parent); @@ -100,11 +98,12 @@ namespace cru::ui //*************** region: position and size *************** //Get the lefttop relative to its parent. - virtual Point GetPositionRelative(); + virtual Point GetOffset(); //Get the actual size. virtual Size GetSize(); + // If offset changes, call RefreshDescendantPositionCache. virtual void SetRect(const Rect& rect); //Get lefttop relative to ancestor. This is only valid when @@ -118,6 +117,13 @@ namespace cru::ui //Absolute point to local point. Point WindowToControl(const Point& point) const; + void RefreshDescendantPositionCache(); + + private: + static void RefreshControlPositionCacheInternal(Control* control, const Point& parent_lefttop_absolute); + + public: + // Default implement in Control is test point in border geometry's // fill and stroke with width of border. virtual bool IsPointInside(const Point& point); |