aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render/StackLayoutRenderObject.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-09 22:29:17 +0800
committercrupest <crupest@outlook.com>2022-02-09 22:29:17 +0800
commite18c4fb46d7913f337cc25b9a6e3a25359c3f10a (patch)
treeca0d2ba0477af904c2b3ccc0f1b4ea5d3c101dc0 /src/ui/render/StackLayoutRenderObject.cpp
parent1cbbad7166ca3dad08f947aeea5d7efc197bd2f3 (diff)
downloadcru-e18c4fb46d7913f337cc25b9a6e3a25359c3f10a.tar.gz
cru-e18c4fb46d7913f337cc25b9a6e3a25359c3f10a.tar.bz2
cru-e18c4fb46d7913f337cc25b9a6e3a25359c3f10a.zip
...
Diffstat (limited to 'src/ui/render/StackLayoutRenderObject.cpp')
-rw-r--r--src/ui/render/StackLayoutRenderObject.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/ui/render/StackLayoutRenderObject.cpp b/src/ui/render/StackLayoutRenderObject.cpp
index ea65fe02..6c79716f 100644
--- a/src/ui/render/StackLayoutRenderObject.cpp
+++ b/src/ui/render/StackLayoutRenderObject.cpp
@@ -21,11 +21,12 @@ void StackLayoutRenderObject::SetDefaultVertialAlignment(Alignment alignment) {
Size StackLayoutRenderObject::OnMeasureContent(
const MeasureRequirement& requirement, const MeasureSize& preferred_size) {
Size child_max_size;
- for (const auto child : GetChildren()) {
+ for (int i = 0; i < GetChildCount(); i++) {
+ auto child = GetChildAt(i);
child->Measure(
MeasureRequirement(requirement.max, MeasureSize::NotSpecified()),
MeasureSize::NotSpecified());
- const auto size = child->GetSize();
+ const auto size = child->GetDesiredSize();
child_max_size.width = std::max(child_max_size.width, size.width);
child_max_size.height = std::max(child_max_size.height, size.height);
}
@@ -33,7 +34,7 @@ Size StackLayoutRenderObject::OnMeasureContent(
child_max_size = Max(preferred_size.GetSizeOr0(), child_max_size);
child_max_size = Max(requirement.min.GetSizeOr0(), child_max_size);
- for (Index i = 0; i < GetChildren().size(); ++i) {
+ for (Index i = 0; i < GetChildCount(); ++i) {
auto child_layout_data = GetChildLayoutData(i);
auto horizontal_stretch =
child_layout_data.horizontal.value_or(default_horizontal_alignment_) ==
@@ -42,8 +43,8 @@ Size StackLayoutRenderObject::OnMeasureContent(
child_layout_data.vertical.value_or(default_vertical_alignment_) ==
Alignment::Stretch;
if (horizontal_stretch || vertical_stretch) {
- auto child = GetChildren()[i];
- auto child_size = child->GetSize();
+ auto child = GetChildAt(i);
+ auto child_size = child->GetDesiredSize();
MeasureRequirement child_requirement(child_size, child_size);
if (horizontal_stretch) {
child_requirement.min.width = child_requirement.max.width =
@@ -63,12 +64,11 @@ Size StackLayoutRenderObject::OnMeasureContent(
void StackLayoutRenderObject::OnLayoutContent(const Rect& content_rect) {
const auto count = GetChildCount();
- const auto& children = GetChildren();
for (int i = 0; i < count; i++) {
- const auto child = children[i];
+ const auto child = GetChildAt(i);
const auto& layout_data = GetChildLayoutData(i);
- const auto& size = child->GetSize();
+ const auto& size = child->GetDesiredSize();
child->Layout(Point{
CalculateAnchorByAlignment(
layout_data.horizontal.value_or(default_horizontal_alignment_),