diff options
author | crupest <crupest@outlook.com> | 2018-12-05 15:51:05 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-12-05 15:51:05 +0800 |
commit | 01b0378ed32eb2011863393892717483004cc375 (patch) | |
tree | 5cd487e9359c4680a81cd77c304935539c10406e /src/ui/controls/scroll_control.cpp | |
parent | 1166da612f01172270114921eb6785998ef88476 (diff) | |
download | cru-01b0378ed32eb2011863393892717483004cc375.tar.gz cru-01b0378ed32eb2011863393892717483004cc375.tar.bz2 cru-01b0378ed32eb2011863393892717483004cc375.zip |
Avoid search for ancestor in measure.
Diffstat (limited to 'src/ui/controls/scroll_control.cpp')
-rw-r--r-- | src/ui/controls/scroll_control.cpp | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/src/ui/controls/scroll_control.cpp b/src/ui/controls/scroll_control.cpp index 9681924d..db8ac438 100644 --- a/src/ui/controls/scroll_control.cpp +++ b/src/ui/controls/scroll_control.cpp @@ -224,7 +224,7 @@ namespace cru::ui::controls view_height_ = length; } - Size ScrollControl::OnMeasureContent(const Size& available_size) + Size ScrollControl::OnMeasureContent(const Size& available_size, const AdditionalMeasureInfo& additional_info) { const auto layout_params = GetLayoutParams(); @@ -234,13 +234,6 @@ namespace cru::ui::controls if (layout_params->width.mode == MeasureMode::Content) debug::DebugMessage(L"ScrollControl: Width measure mode is Content and horizontal scroll is enabled. So Stretch is used instead."); - for (auto child : GetChildren()) - { - const auto child_layout_params = child->GetLayoutParams(); - if (child_layout_params->width.mode == MeasureMode::Stretch) - throw std::runtime_error(Format("ScrollControl: Horizontal scroll is enabled but a child {} 's width measure mode is Stretch which may cause infinite length.", ToUtf8String(child->GetControlType()))); - } - available_size_for_children.width = std::numeric_limits<float>::max(); } @@ -249,20 +242,13 @@ namespace cru::ui::controls if (layout_params->height.mode == MeasureMode::Content) debug::DebugMessage(L"ScrollControl: Height measure mode is Content and vertical scroll is enabled. So Stretch is used instead."); - for (auto child : GetChildren()) - { - const auto child_layout_params = child->GetLayoutParams(); - if (child_layout_params->height.mode == MeasureMode::Stretch) - throw std::runtime_error(Format("ScrollControl: Vertical scroll is enabled but a child {} 's height measure mode is Stretch which may cause infinite length.", ToUtf8String(child->GetControlType()))); - } - available_size_for_children.height = std::numeric_limits<float>::max(); } auto max_child_size = Size::Zero(); for (auto control: GetChildren()) { - control->Measure(available_size_for_children); + control->Measure(available_size_for_children, AdditionalMeasureInfo{false, false}); const auto&& size = control->GetDesiredSize(); if (max_child_size.width < size.width) max_child_size.width = size.width; @@ -270,7 +256,7 @@ namespace cru::ui::controls max_child_size.height = size.height; } - // coerce size fro stretch. + // coerce size for stretch. for (auto control: GetChildren()) { auto size = control->GetDesiredSize(); |