diff options
author | crupest <crupest@outlook.com> | 2022-01-29 22:19:36 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-01-29 22:19:36 +0800 |
commit | 43fe5dfe001f25870788742333d141f406b07364 (patch) | |
tree | aa2cf8825cca0bcab5f7e72c37801cf35de857b3 /src/ui/render | |
parent | 592f3f3f25f00232234399f4c5f51318a3fa49d2 (diff) | |
download | cru-43fe5dfe001f25870788742333d141f406b07364.tar.gz cru-43fe5dfe001f25870788742333d141f406b07364.tar.bz2 cru-43fe5dfe001f25870788742333d141f406b07364.zip |
...
Diffstat (limited to 'src/ui/render')
-rw-r--r-- | src/ui/render/FlexLayoutRenderObject.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/ui/render/FlexLayoutRenderObject.cpp b/src/ui/render/FlexLayoutRenderObject.cpp index 6d1f9c26..0e76995b 100644 --- a/src/ui/render/FlexLayoutRenderObject.cpp +++ b/src/ui/render/FlexLayoutRenderObject.cpp @@ -2,7 +2,9 @@ #include "cru/common/Logger.hpp" #include "cru/platform/graphics/util/Painter.hpp" +#include "cru/ui/Base.hpp" #include "cru/ui/render/LayoutHelper.hpp" +#include "cru/ui/render/MeasureRequirement.hpp" #include <algorithm> #include <functional> @@ -91,7 +93,8 @@ template <typename direction_tag_t, Size FlexLayoutMeasureContentImpl( const MeasureRequirement& requirement, const MeasureSize& preferred_size, const std::vector<RenderObject*>& children, - const std::vector<FlexChildLayoutData>& layout_data, StringView log_tag) { + const std::vector<FlexChildLayoutData>& layout_data, + Alignment item_cross_align, StringView log_tag) { Expects(children.size() == layout_data.size()); direction_tag_t direction_tag; @@ -311,6 +314,17 @@ Size FlexLayoutMeasureContentImpl( child_max_cross_length = std::max(min_cross_length.GetLengthOr0(), child_max_cross_length); + for (Index i = 0; i < child_count; i++) { + auto child_layout_data = layout_data[i]; + auto child = children[i]; + if (child_layout_data.cross_alignment.value_or(item_cross_align) == + Alignment::Stretch) { + auto size = child->GetSize(); + GetCross(size, direction_tag) = child_max_cross_length; + child->Measure({size, size}, MeasureSize::NotSpecified()); + } + } + return CreateTSize<Size>(total_length, child_max_cross_length, direction_tag); } } // namespace @@ -322,11 +336,11 @@ Size FlexLayoutRenderObject::OnMeasureContent( if (horizontal) { return FlexLayoutMeasureContentImpl<tag_horizontal_t>( requirement, preferred_size, GetChildren(), GetChildLayoutDataList(), - log_tag); + item_cross_align_, log_tag); } else { return FlexLayoutMeasureContentImpl<tag_vertical_t>( requirement, preferred_size, GetChildren(), GetChildLayoutDataList(), - log_tag); + item_cross_align_, log_tag); } } |