diff options
author | crupest <crupest@outlook.com> | 2018-09-29 11:13:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-09-29 11:13:31 +0800 |
commit | 177765d0d9d74525a9db9e756f614636828ea980 (patch) | |
tree | 50c67f028f18486dc4a7656c82eff31cac86ec71 /src/ui/layout_base.cpp | |
parent | b0b5a481c9b0460f275887b15e8edecc34e99186 (diff) | |
download | cru-177765d0d9d74525a9db9e756f614636828ea980.tar.gz cru-177765d0d9d74525a9db9e756f614636828ea980.tar.bz2 cru-177765d0d9d74525a9db9e756f614636828ea980.zip |
Fix relayout system.
Diffstat (limited to 'src/ui/layout_base.cpp')
-rw-r--r-- | src/ui/layout_base.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/ui/layout_base.cpp b/src/ui/layout_base.cpp index a26379a0..40c7a724 100644 --- a/src/ui/layout_base.cpp +++ b/src/ui/layout_base.cpp @@ -2,6 +2,7 @@ #include "application.h" #include "control.h" +#include "window.h" namespace cru::ui { @@ -33,8 +34,8 @@ namespace cru::ui if (cache_invalid_controls_.size() == 1) // when insert just now and not repeat to "InvokeLater". { InvokeLater([this] { - - RefreshInvalidControlPositionCache(); // first refresh position cache. + for (const auto i : cache_invalid_controls_) + RefreshControlPositionCache(i); for (const auto i : cache_invalid_controls_) // traverse all descendants of position-invalid controls and notify position change event i->TraverseDescendants([](Control* control) { @@ -50,6 +51,7 @@ namespace cru::ui { for (const auto i : cache_invalid_controls_) RefreshControlPositionCache(i); + cache_invalid_controls_.clear(); } void LayoutManager::RefreshControlPositionCache(Control * control) @@ -64,6 +66,24 @@ namespace cru::ui RefreshControlPositionCacheInternal(control, point); } + void LayoutManager::InvalidateWindowLayout(Window* window) + { + layout_invalid_windows_.insert(window); + + if (layout_invalid_windows_.size() == 1) + InvokeLater([this]() + { + this->RefreshInvalidWindowLayout(); + }); + } + + void LayoutManager::RefreshInvalidWindowLayout() + { + for (const auto window : layout_invalid_windows_) + window->Relayout(); + layout_invalid_windows_.clear(); + } + void LayoutManager::RefreshControlPositionCacheInternal(Control * control, const Point & parent_lefttop_absolute) { const auto position = control->GetPositionRelative(); |