aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cru/platform/GraphicsBase.h7
-rw-r--r--src/platform/CMakeLists.txt1
-rw-r--r--src/platform/GraphicsBase.cpp9
-rw-r--r--src/ui/controls/ControlHost.cpp8
-rw-r--r--src/ui/render/FlexLayoutRenderObject.cpp10
-rw-r--r--src/ui/render/RenderObject.cpp2
6 files changed, 15 insertions, 22 deletions
diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h
index 78a1c1a6..0c391b11 100644
--- a/include/cru/platform/GraphicsBase.h
+++ b/include/cru/platform/GraphicsBase.h
@@ -1,6 +1,4 @@
#pragma once
-#include "Base.h"
-
#include <cru/base/Range.h>
#include <cru/base/StringUtil.h>
@@ -42,9 +40,6 @@ constexpr Point operator-(const Point& left, const Point& right) {
}
struct Size final {
- static CRU_PLATFORM_API const Size kMax;
- static CRU_PLATFORM_API const Size kZero;
-
constexpr Size() = default;
constexpr Size(const float width, const float height)
: width(width), height(height) {}
@@ -64,7 +59,7 @@ struct Size final {
return {std::max(width, other.width), std::max(height, other.height)};
}
- constexpr Size AtLeast0() const { return Max(kZero); }
+ constexpr Size AtLeast0() const { return this->Max({}); }
std::string ToString() const {
return std::format("Size(width: {}, height: {})", width, height);
diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt
index 0412662c..8a4ddf98 100644
--- a/src/platform/CMakeLists.txt
+++ b/src/platform/CMakeLists.txt
@@ -1,7 +1,6 @@
add_library(CruPlatformBase
Base.cpp
Color.cpp
- GraphicsBase.cpp
)
target_link_libraries(CruPlatformBase PUBLIC CruBase)
target_compile_definitions(CruPlatformBase PRIVATE CRU_PLATFORM_EXPORT_API)
diff --git a/src/platform/GraphicsBase.cpp b/src/platform/GraphicsBase.cpp
deleted file mode 100644
index c9e57cfc..00000000
--- a/src/platform/GraphicsBase.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "cru/platform/GraphicsBase.h"
-
-#include <limits>
-
-namespace cru::platform {
-const Size Size::kZero(0.0f, 0.0f);
-const Size Size::kMax(std::numeric_limits<float>::max(),
- std::numeric_limits<float>::max());
-} // namespace cru::platform
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 <typename direction_tag_t,
std::is_same_v<direction_tag_t, tag_horizontal_t> ||
std::is_same_v<direction_tag_t, tag_vertical_t>>>
Size FlexLayoutMeasureContentImpl(
+ FlexLayoutRenderObject* render_object,
const MeasureRequirement& requirement, const MeasureSize& preferred_size,
const std::vector<RenderObject*>& children,
const std::vector<FlexChildLayoutData>& 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<tag_horizontal_t>(
- requirement, requirement.suggest, children, layout_data_list,
+ this, requirement, requirement.suggest, children, layout_data_list,
item_cross_align_, kLogTag);
} else {
return FlexLayoutMeasureContentImpl<tag_vertical_t>(
- 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;
}