aboutsummaryrefslogtreecommitdiff
path: root/CruUI/ui/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CruUI/ui/window.cpp')
-rw-r--r--CruUI/ui/window.cpp66
1 files changed, 1 insertions, 65 deletions
diff --git a/CruUI/ui/window.cpp b/CruUI/ui/window.cpp
index e09b150e..3f9d9f6c 100644
--- a/CruUI/ui/window.cpp
+++ b/CruUI/ui/window.cpp
@@ -77,70 +77,6 @@ namespace cru
return find_result->second;
}
- void WindowLayoutManager::InvalidateControlPositionCache(Control * control)
- {
- if (cache_invalid_controls_.count(control) == 1)
- return;
-
- // find descendant then erase it; find ancestor then just return.
- for (auto i = cache_invalid_controls_.cbegin(); i != cache_invalid_controls_.cend(); ++i)
- {
- const auto result = IsAncestorOrDescendant(*i, control);
- if (result == control)
- cache_invalid_controls_.erase(i);
- else if (result != nullptr)
- return; // find a ancestor of "control", just return
- }
-
- cache_invalid_controls_.insert(control);
-
- 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_) // traverse all descendants of position-invalid controls and notify position change event
- i->TraverseDescendants([](Control* control)
- {
- control->CheckAndNotifyPositionChanged();
- });
- cache_invalid_controls_.clear(); // after update and notify, clear the set.
-
- });
- }
- }
-
- void WindowLayoutManager::RefreshInvalidControlPositionCache()
- {
- for (const auto i : cache_invalid_controls_)
- RefreshControlPositionCache(i);
- }
-
- void WindowLayoutManager::RefreshControlPositionCache(Control * control)
- {
- auto point = Point::zero;
- auto parent = control;
- while ((parent = parent->GetParent())) {
- const auto p = parent->GetPositionRelative();
- point.x += p.x;
- point.y += p.y;
- }
- RefreshControlPositionCacheInternal(control, point);
- }
-
- void WindowLayoutManager::RefreshControlPositionCacheInternal(Control * control, const Point & parent_lefttop_absolute)
- {
- const auto position = control->GetPositionRelative();
- Point lefttop(
- parent_lefttop_absolute.x + position.x,
- parent_lefttop_absolute.y + position.y
- );
- control->position_cache_.lefttop_position_absolute = lefttop;
- control->ForeachChild([lefttop](Control* c) {
- RefreshControlPositionCacheInternal(c, lefttop);
- });
- }
-
inline Point PiToDip(const POINT& pi_point)
{
return Point(
@@ -149,7 +85,7 @@ namespace cru
);
}
- Window::Window() : Control(WindowConstructorTag{}, this), layout_manager_(new WindowLayoutManager()), control_list_({ this }) {
+ Window::Window() : Control(WindowConstructorTag{}, this), control_list_({ this }) {
const auto app = Application::GetInstance();
hwnd_ = CreateWindowEx(0,
app->GetWindowManager()->GetGeneralWindowClass()->GetName(),