From 3b6a59e7f163b2d2f8a07ae187b392f71b074cc4 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Sun, 14 Dec 2025 20:46:18 +0800 Subject: Use infinite size for 0 size window. --- src/ui/controls/ControlHost.cpp | 8 +++++++- src/ui/render/FlexLayoutRenderObject.cpp | 10 ++++++---- src/ui/render/RenderObject.cpp | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/controls/ControlHost.cpp b/src/ui/controls/ControlHost.cpp index 290602d4..178e2ca3 100644 --- a/src/ui/controls/ControlHost.cpp +++ b/src/ui/controls/ControlHost.cpp @@ -1,5 +1,6 @@ #include "cru/ui/controls/ControlHost.h" +#include "cru/base/log/Logger.h" #include "cru/platform/gui/UiApplication.h" #include "cru/platform/gui/Window.h" #include "cru/ui/Base.h" @@ -151,7 +152,11 @@ void ControlHost::Repaint() { } void ControlHost::Relayout() { - RelayoutWithSize(native_window_->GetClientSize()); + auto size = native_window_->GetClientSize(); + if (size.width == 0.f && size.height == 0.f) { + size = Size::Infinite(); + } + RelayoutWithSize(size); } void ControlHost::RelayoutWithSize(const Size& available_size, @@ -259,6 +264,7 @@ void ControlHost::OnNativePaint1( } void ControlHost::OnNativeResize([[maybe_unused]] const Size& size) { + CruLogDebug(kLogTag, "Window resize to {}.", size); ScheduleRelayout(); } diff --git a/src/ui/render/FlexLayoutRenderObject.cpp b/src/ui/render/FlexLayoutRenderObject.cpp index f4936f15..c85748b8 100644 --- a/src/ui/render/FlexLayoutRenderObject.cpp +++ b/src/ui/render/FlexLayoutRenderObject.cpp @@ -85,6 +85,7 @@ template || std::is_same_v>> Size FlexLayoutMeasureContentImpl( + FlexLayoutRenderObject* render_object, const MeasureRequirement& requirement, const MeasureSize& preferred_size, const std::vector& children, const std::vector& layout_data, @@ -300,9 +301,10 @@ Size FlexLayoutMeasureContentImpl( if (max_main_length.IsSpecified() && total_length > max_main_length.GetLengthOrUndefined()) { CruLogWarn(kLogTag, - "(Measure) Children's main axis length {} exceeds required max " + "{} Children's main axis length {} exceeds required max " "length {}.", - total_length, max_main_length.GetLengthOrUndefined()); + render_object->GetDebugPathInTree(), total_length, + max_main_length.GetLengthOrUndefined()); total_length = max_main_length.GetLengthOrUndefined(); } else if (min_main_length.IsSpecified() && total_length < min_main_length.GetLengthOrUndefined()) { @@ -344,11 +346,11 @@ Size FlexLayoutRenderObject::OnMeasureContent( if (horizontal) { return FlexLayoutMeasureContentImpl( - requirement, requirement.suggest, children, layout_data_list, + this, requirement, requirement.suggest, children, layout_data_list, item_cross_align_, kLogTag); } else { return FlexLayoutMeasureContentImpl( - requirement, requirement.suggest, children, layout_data_list, + this, requirement, requirement.suggest, children, layout_data_list, item_cross_align_, kLogTag); } } diff --git a/src/ui/render/RenderObject.cpp b/src/ui/render/RenderObject.cpp index a84bd8c1..a3a42555 100644 --- a/src/ui/render/RenderObject.cpp +++ b/src/ui/render/RenderObject.cpp @@ -211,7 +211,7 @@ std::string RenderObject::GetDebugPathInTree() { std::string result(chain.back()); for (auto iter = chain.crbegin() + 1; iter != chain.crend(); ++iter) { - result += " -> "; + result += "->"; result += *iter; } -- cgit v1.2.3