diff options
author | crupest <crupest@outlook.com> | 2020-10-28 17:51:41 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-10-28 17:51:41 +0800 |
commit | 4e0a5338f15a247c33df863c4c619ffdb0a98aae (patch) | |
tree | 491aac2d3612b4343143ea157fb33611d5c3d5e8 /src/ui/UiHost.cpp | |
parent | 864b031211322dc276b220ec0a6e11483503a0e9 (diff) | |
download | cru-4e0a5338f15a247c33df863c4c619ffdb0a98aae.tar.gz cru-4e0a5338f15a247c33df863c4c619ffdb0a98aae.tar.bz2 cru-4e0a5338f15a247c33df863c4c619ffdb0a98aae.zip |
...
Diffstat (limited to 'src/ui/UiHost.cpp')
-rw-r--r-- | src/ui/UiHost.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ui/UiHost.cpp b/src/ui/UiHost.cpp index d3564619..ccc5fea0 100644 --- a/src/ui/UiHost.cpp +++ b/src/ui/UiHost.cpp @@ -193,6 +193,8 @@ void UiHost::Relayout() { : render::MeasureSize::NotSpecified()}, render::MeasureSize::NotSpecified()); root_render_object_->Layout(Point{}); + for (auto& action : after_layout_stable_action_) action(); + after_layout_stable_action_.clear(); after_layout_event_.Raise(AfterLayoutEventArgs{}); log::TagDebug(log_tag, u"A relayout is finished."); } @@ -249,6 +251,14 @@ bool UiHost::CaptureMouseFor(Control* control) { Control* UiHost::GetMouseCaptureControl() { return mouse_captured_control_; } +void UiHost::RunAfterLayoutStable(std::function<void()> action) { + if (need_layout_) { + after_layout_stable_action_.push_back(std::move(action)); + } else { + action(); + } +} + void UiHost::OnNativeDestroy(INativeWindow* window, std::nullptr_t) { CRU_UNUSED(window) native_window_destroyed_ = true; |