diff options
author | crupest <crupest@outlook.com> | 2020-10-18 21:40:23 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-10-18 21:40:23 +0800 |
commit | f90650efb7175957892d18097954ffd3aa59dc95 (patch) | |
tree | 136bde01edf8c4f2c36f2aa0c7b8aecfc6577483 /src/ui/UiHost.cpp | |
parent | c072432e68d7a3d7659add0994b2f8caf387ddf2 (diff) | |
download | cru-f90650efb7175957892d18097954ffd3aa59dc95.tar.gz cru-f90650efb7175957892d18097954ffd3aa59dc95.tar.bz2 cru-f90650efb7175957892d18097954ffd3aa59dc95.zip |
...
Diffstat (limited to 'src/ui/UiHost.cpp')
-rw-r--r-- | src/ui/UiHost.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ui/UiHost.cpp b/src/ui/UiHost.cpp index 48a4e06e..cd09907f 100644 --- a/src/ui/UiHost.cpp +++ b/src/ui/UiHost.cpp @@ -7,6 +7,7 @@ #include "cru/platform/native/UiApplication.hpp" #include "cru/platform/native/Window.hpp" #include "cru/ui/Window.hpp" +#include "cru/ui/render/MeasureRequirement.hpp" #include "cru/ui/render/WindowRenderObject.hpp" namespace cru::ui { @@ -168,14 +169,27 @@ void UiHost::InvalidateLayout() { } } +bool UiHost::IsLayoutPreferToFillWindow() const { + return layout_prefer_to_fill_window_; +} + +void UiHost::SetLayoutPreferToFillWindow(bool value) { + if (value == layout_prefer_to_fill_window_) return; + layout_prefer_to_fill_window_ = value; + InvalidateLayout(); +} + void UiHost::Relayout() { const auto native_window = native_window_resolver_->Resolve(); const auto client_size = native_window ? native_window->GetClientSize() : Size{100, 100}; // a reasonable assumed size + root_render_object_->Measure( render::MeasureRequirement{client_size, - render::MeasureSize::NotSpecified()}, + IsLayoutPreferToFillWindow() + ? render::MeasureSize(client_size) + : render::MeasureSize::NotSpecified()}, render::MeasureSize::NotSpecified()); root_render_object_->Layout(Point{}); after_layout_event_.Raise(AfterLayoutEventArgs{}); |