diff options
author | crupest <crupest@outlook.com> | 2021-11-20 21:25:29 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-11-20 21:25:29 +0800 |
commit | 1a53ed0791d9793ed8030d3a44e833e5e7c4542b (patch) | |
tree | 28aedaabee675b192e414489122349ad4985a31b /src/ui/host/WindowHost.cpp | |
parent | a9da4c10459e3c45115c8a42e771b00cb1caeab7 (diff) | |
download | cru-1a53ed0791d9793ed8030d3a44e833e5e7c4542b.tar.gz cru-1a53ed0791d9793ed8030d3a44e833e5e7c4542b.tar.bz2 cru-1a53ed0791d9793ed8030d3a44e833e5e7c4542b.zip |
...
Diffstat (limited to 'src/ui/host/WindowHost.cpp')
-rw-r--r-- | src/ui/host/WindowHost.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ui/host/WindowHost.cpp b/src/ui/host/WindowHost.cpp index f60e2809..d26b43ab 100644 --- a/src/ui/host/WindowHost.cpp +++ b/src/ui/host/WindowHost.cpp @@ -180,18 +180,24 @@ void WindowHost::SetLayoutPreferToFillWindow(bool value) { void WindowHost::Relayout() { const auto available_size = - native_window_ ? native_window_->GetClientSize() - : Size{100, 100}; // a reasonable assumed size - Relayout(available_size); + native_window_ ? native_window_->GetClientSize() : Size::Infinate(); + RelayoutWithSize(available_size); } -void WindowHost::Relayout(const Size& available_size) { +void WindowHost::RelayoutWithSize(const Size& available_size, + bool set_window_size_to_fit_content) { root_render_object_->Measure( render::MeasureRequirement{available_size, IsLayoutPreferToFillWindow() ? render::MeasureSize(available_size) : render::MeasureSize::NotSpecified()}, render::MeasureSize::NotSpecified()); + + if (set_window_size_to_fit_content) { + auto rect = GetWindowRect(); + SetWindowRect({rect.GetLeftTop(), root_render_object_->GetSize()}); + } + root_render_object_->Layout(Point{}); for (auto& action : after_layout_stable_action_) action(); after_layout_event_.Raise(AfterLayoutEventArgs{}); |