aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/cru/base/StringUtil.h1
-rw-r--r--include/cru/platform/GraphicsBase.h14
-rw-r--r--include/cru/ui/controls/Control.h8
-rw-r--r--include/cru/ui/render/BorderRenderObject.h3
-rw-r--r--include/cru/ui/render/CanvasRenderObject.h26
-rw-r--r--include/cru/ui/render/FlexLayoutRenderObject.h3
-rw-r--r--include/cru/ui/render/GeometryRenderObject.h3
-rw-r--r--include/cru/ui/render/MeasureRequirement.h273
-rw-r--r--include/cru/ui/render/RenderObject.h19
-rw-r--r--include/cru/ui/render/ScrollRenderObject.h3
-rw-r--r--include/cru/ui/render/StackLayoutRenderObject.h3
-rw-r--r--include/cru/ui/render/TextRenderObject.h4
-rw-r--r--include/cru/ui/render/TreeRenderObject.h3
-rw-r--r--include/cru/ui/style/Styler.h2
14 files changed, 201 insertions, 164 deletions
diff --git a/include/cru/base/StringUtil.h b/include/cru/base/StringUtil.h
index dbc748d7..363493a1 100644
--- a/include/cru/base/StringUtil.h
+++ b/include/cru/base/StringUtil.h
@@ -1,7 +1,6 @@
#pragma once
#include "Base.h"
#include "Bitmask.h"
-#include "cru/base/StringUtil.h"
#include <algorithm>
#include <cctype>
diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h
index 43c36494..89d3df77 100644
--- a/include/cru/platform/GraphicsBase.h
+++ b/include/cru/platform/GraphicsBase.h
@@ -56,6 +56,16 @@ struct Size final {
std::numeric_limits<float>::max()};
}
+ constexpr Size Min(const Size& other) const {
+ return {std::min(width, other.width), std::min(height, other.height)};
+ }
+
+ constexpr Size Max(const Size& other) const {
+ return {std::max(width, other.width), std::max(height, other.height)};
+ }
+
+ constexpr Size AtLeast0() const { return Max(kZero); }
+
std::string ToString() const {
return std::format("Size(width: {}, height: {})", width, height);
}
@@ -93,6 +103,10 @@ struct Thickness final {
constexpr float GetVerticalTotal() const { return top + bottom; }
+ constexpr Size GetTotalSize() const {
+ return {GetHorizontalTotal(), GetVerticalTotal()};
+ }
+
void SetLeftRight(const float value) { left = right = value; }
void SetTopBottom(const float value) { top = bottom = value; }
diff --git a/include/cru/ui/controls/Control.h b/include/cru/ui/controls/Control.h
index 544d33e6..c82956b5 100644
--- a/include/cru/ui/controls/Control.h
+++ b/include/cru/ui/controls/Control.h
@@ -71,11 +71,11 @@ class CRU_UI_API Control : public Object,
public:
virtual render::RenderObject* GetRenderObject() = 0;
- virtual render::MeasureSize GetPreferredSize() {
- return GetRenderObject()->GetPreferredSize();
+ virtual render::MeasureSize GetSuggestSize() {
+ return GetRenderObject()->GetSuggestSize();
}
- virtual void SetPreferredSize(const render::MeasureSize& size) {
- GetRenderObject()->SetPreferredSize(size);
+ virtual void SetSuggestSize(const render::MeasureSize& size) {
+ GetRenderObject()->SetSuggestSize(size);
}
virtual Thickness GetMargin() { return GetRenderObject()->GetMargin(); }
diff --git a/include/cru/ui/render/BorderRenderObject.h b/include/cru/ui/render/BorderRenderObject.h
index 6060dc4c..8b8f3816 100644
--- a/include/cru/ui/render/BorderRenderObject.h
+++ b/include/cru/ui/render/BorderRenderObject.h
@@ -50,8 +50,7 @@ class CRU_UI_API BorderRenderObject : public SingleChildRenderObject {
Rect GetContentRect() override;
protected:
- Size OnMeasureContent(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size) override;
+ Size OnMeasureContent(const MeasureRequirement& requirement) override;
void OnLayoutContent(const Rect& content_rect) override;
void OnResize(const Size& new_size) override;
diff --git a/include/cru/ui/render/CanvasRenderObject.h b/include/cru/ui/render/CanvasRenderObject.h
index 63da9cd9..2e44fcc2 100644
--- a/include/cru/ui/render/CanvasRenderObject.h
+++ b/include/cru/ui/render/CanvasRenderObject.h
@@ -9,9 +9,6 @@ class CanvasPaintEventArgs {
CanvasPaintEventArgs(platform::graphics::IPainter* painter,
const Size& paint_size)
: painter_(painter), paint_size_(paint_size) {}
- CRU_DEFAULT_COPY(CanvasPaintEventArgs)
- CRU_DEFAULT_MOVE(CanvasPaintEventArgs)
- ~CanvasPaintEventArgs() = default;
platform::graphics::IPainter* GetPainter() const { return painter_; }
Size GetPaintSize() const { return paint_size_; }
@@ -21,9 +18,12 @@ class CanvasPaintEventArgs {
Size paint_size_;
};
-// Layout logic:
-// If no preferred size is set. Then (100, 100) is used and then coerced to
-// required range.
+/**
+ * Layout logic:
+ * Preferred
+ * If no preferred size is set. Then (100, 100) is used and then coerced to
+ * required range.
+ */
class CRU_UI_API CanvasRenderObject : public RenderObject {
public:
static constexpr auto kRenderObjectName = "CanvasRenderObject";
@@ -33,20 +33,12 @@ class CRU_UI_API CanvasRenderObject : public RenderObject {
public:
RenderObject* HitTest(const Point& point) override;
- Size GetDesiredSize() { return desired_size_; }
-
- IEvent<CanvasPaintEventArgs>* PaintEvent() { return &paint_event_; }
-
void Draw(platform::graphics::IPainter* painter) override;
+ CRU_DEFINE_EVENT(Paint, const CanvasPaintEventArgs&)
+
protected:
- Size OnMeasureContent(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size) override;
+ Size OnMeasureContent(const MeasureRequirement& requirement) override;
void OnLayoutContent(const Rect& content_rect) override;
-
- private:
- Size desired_size_{};
-
- Event<CanvasPaintEventArgs> paint_event_;
};
} // namespace cru::ui::render
diff --git a/include/cru/ui/render/FlexLayoutRenderObject.h b/include/cru/ui/render/FlexLayoutRenderObject.h
index 82ac6639..9fdecd28 100644
--- a/include/cru/ui/render/FlexLayoutRenderObject.h
+++ b/include/cru/ui/render/FlexLayoutRenderObject.h
@@ -119,8 +119,7 @@ class CRU_UI_API FlexLayoutRenderObject
}
protected:
- Size OnMeasureContent(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size) override;
+ Size OnMeasureContent(const MeasureRequirement& requirement) override;
void OnLayoutContent(const Rect& content_rect) override;
private:
diff --git a/include/cru/ui/render/GeometryRenderObject.h b/include/cru/ui/render/GeometryRenderObject.h
index 2320b71b..1994daf3 100644
--- a/include/cru/ui/render/GeometryRenderObject.h
+++ b/include/cru/ui/render/GeometryRenderObject.h
@@ -35,8 +35,7 @@ class GeometryRenderObject : public RenderObject {
void SetStrokeWidth(float width);
protected:
- Size OnMeasureContent(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size) override;
+ Size OnMeasureContent(const MeasureRequirement& requirement) override;
void OnLayoutContent(const Rect& content_rect) override;
private:
diff --git a/include/cru/ui/render/MeasureRequirement.h b/include/cru/ui/render/MeasureRequirement.h
index 43bd3326..5ea22952 100644
--- a/include/cru/ui/render/MeasureRequirement.h
+++ b/include/cru/ui/render/MeasureRequirement.h
@@ -7,16 +7,6 @@
#include <string>
namespace cru::ui::render {
-constexpr Size Min(const Size& left, const Size& right) {
- return Size{std::min(left.width, right.width),
- std::min(left.height, right.height)};
-}
-
-constexpr Size Max(const Size& left, const Size& right) {
- return Size{std::max(left.width, right.width),
- std::max(left.height, right.height)};
-}
-
class MeasureLength final {
public:
struct tag_not_specify_t {};
@@ -24,32 +14,31 @@ class MeasureLength final {
constexpr MeasureLength() : MeasureLength(tag_not_specify) {}
constexpr MeasureLength(tag_not_specify_t) : length_(-1) {}
- constexpr MeasureLength(float length) : length_(length) {}
-
- MeasureLength(const MeasureLength& other) = default;
- constexpr MeasureLength& operator=(const MeasureLength& other) = default;
+ constexpr MeasureLength(float length) : length_(length) {
+ if (length < 0.0f) {
+ throw Exception("Measure length must not be positive.");
+ }
+ }
constexpr MeasureLength& operator=(float length) {
+ if (length < 0.0f) {
+ throw Exception("Measure length must not be positive.");
+ }
length_ = length;
return *this;
}
- ~MeasureLength() = default;
-
constexpr static MeasureLength NotSpecified() {
- return MeasureLength{tag_not_specify};
+ return MeasureLength(tag_not_specify);
}
constexpr bool IsSpecified() const { return length_ >= 0.0f; }
- // What not specified means depends on situation.
- constexpr bool IsNotSpecified() const { return length_ < 0.0f; }
-
constexpr float GetLengthOr(float value) const {
return length_ < 0 ? value : length_;
}
// If not specify max value of float is returned.
- constexpr float GetLengthOrMax() const {
+ constexpr float GetLengthOrMaxFloat() const {
return GetLengthOr(std::numeric_limits<float>::max());
}
@@ -59,15 +48,27 @@ class MeasureLength final {
// If not specify, return value is undefined.
constexpr float GetLengthOrUndefined() const { return length_; }
- // Not operator overload because this semantics is not very clear.
+ constexpr MeasureLength Or(MeasureLength value) const {
+ return IsSpecified() ? *this : value;
+ }
+
+ constexpr MeasureLength OverrideBy(MeasureLength value) const {
+ return value.IsSpecified() ? value : *this;
+ }
+
+ /**
+ * If specified, given length is added and negative value is coerced to 0.
+ */
constexpr MeasureLength Plus(float length) const {
if (IsSpecified())
- return length_ + length;
+ return std::max(length_ + length, 0.f);
else
return NotSpecified();
}
- // Not operator overload because this semantics is not very clear.
+ /**
+ * If specified, given length is minused and negative value is coerced to 0.
+ */
constexpr MeasureLength Minus(float length) const {
if (IsSpecified())
return std::max(length_ - length, 0.f);
@@ -75,52 +76,67 @@ class MeasureLength final {
return NotSpecified();
}
- constexpr bool operator==(MeasureLength other) const {
- return (length_ < 0 && other.length_ < 0) || length_ == other.length_;
+ /**
+ * 1. Both unspecified => unspecified.
+ * 2. One is specified and the other is not => the specified one.
+ * 3. Both specified => smaller one.
+ */
+ constexpr MeasureLength Min(MeasureLength other) const {
+ if (IsSpecified()) {
+ return other.IsSpecified() ? std::min(length_, other.length_) : *this;
+ } else {
+ return other;
+ }
}
- constexpr bool operator!=(MeasureLength other) const {
- return !operator==(other);
+ /**
+ * 1. This is unspecified => other.
+ * 2. This is specified => smaller one.
+ */
+ constexpr float Min(float other) const {
+ return IsSpecified() ? std::min(length_, other) : other;
}
- constexpr static MeasureLength Min(MeasureLength left, MeasureLength right) {
- if (left.IsNotSpecified()) {
- if (right.IsNotSpecified())
- return NotSpecified();
- else
- return right;
+ /**
+ * 1. Both unspecified => unspecified.
+ * 2. One is specified and the other is not => the specified one.
+ * 3. Both specified => bigger one.
+ */
+ constexpr MeasureLength Max(MeasureLength other) const {
+ if (IsSpecified()) {
+ return other.IsSpecified() ? std::max(length_, other.length_) : *this;
} else {
- if (right.IsNotSpecified())
- return left;
- else
- return std::min(left.length_, right.length_);
+ return other;
}
}
- constexpr static MeasureLength Max(MeasureLength left, MeasureLength right) {
- if (left.IsNotSpecified()) {
- if (right.IsNotSpecified())
- return NotSpecified();
- else
- return right;
- } else {
- if (left.IsNotSpecified())
- return left;
- else
- return std::max(left.length_, right.length_);
- }
+ /**
+ * 1. This is unspecified => other.
+ * 2. This is specified => bigger one.
+ */
+ constexpr float Max(float other) const {
+ return IsSpecified() ? std::max(length_, other) : other;
}
- std::string ToDebugString() const {
+ std::string ToString() const {
return IsSpecified() ? std::to_string(GetLengthOrUndefined())
- : "UNSPECIFIED";
+ : "unspecified";
}
+ constexpr bool operator==(const MeasureLength& other) const = default;
+
private:
// -1 for not specify
float length_;
};
+} // namespace cru::ui::render
+
+template <>
+struct std::formatter<cru::ui::render::MeasureLength, char>
+ : cru::string::ImplementFormatterByToString<
+ cru::ui::render::MeasureLength> {};
+namespace cru::ui::render {
struct MeasureSize {
MeasureLength width;
MeasureLength height;
@@ -130,120 +146,149 @@ struct MeasureSize {
: width(width), height(height) {}
constexpr MeasureSize(const Size& size)
: width(size.width), height(size.height) {}
- constexpr MeasureSize(const MeasureSize& other) = default;
- MeasureSize& operator=(const MeasureSize& other) = default;
constexpr MeasureSize& operator=(const Size& other) {
width = other.width;
height = other.height;
return *this;
}
- constexpr Size GetSizeOrMax() const {
- return Size{width.GetLengthOrMax(), height.GetLengthOrMax()};
+ constexpr static MeasureSize NotSpecified() {
+ return {MeasureLength::NotSpecified(), MeasureLength::NotSpecified()};
+ }
+
+ constexpr Size GetSizeOrMaxFloat() const {
+ return {width.GetLengthOrMaxFloat(), height.GetLengthOrMaxFloat()};
}
constexpr Size GetSizeOr0() const {
- return Size{width.GetLengthOr0(), height.GetLengthOr0()};
+ return {width.GetLengthOr0(), height.GetLengthOr0()};
+ }
+
+ constexpr Size GetSizeOr(const Size& other) const {
+ return {width.GetLengthOr(other.width), height.GetLengthOr(other.height)};
+ }
+
+ constexpr MeasureSize Or(const MeasureSize& other) const {
+ return {width.Or(other.width), height.Or(other.height)};
+ }
+
+ constexpr MeasureSize OverrideBy(const MeasureSize& other) const {
+ return {width.OverrideBy(other.width), height.OverrideBy(other.height)};
}
constexpr MeasureSize Plus(const Size& size) const {
- return MeasureSize{width.Plus(size.width), height.Plus(size.height)};
+ return {width.Plus(size.width), height.Plus(size.height)};
}
constexpr MeasureSize Minus(const Size& size) const {
- return MeasureSize{width.Minus(size.width), height.Minus(size.height)};
+ return {width.Minus(size.width), height.Minus(size.height)};
}
- constexpr MeasureSize OverrideBy(const MeasureSize& size) const {
- return MeasureSize{
- size.width.IsSpecified() ? size.width.GetLengthOrUndefined()
- : this->width,
- size.height.IsSpecified() ? size.height.GetLengthOrUndefined()
- : this->height,
- };
+ constexpr MeasureSize Min(const MeasureSize& other) const {
+ return {width.Min(other.width), height.Min(other.height)};
}
- std::string ToDebugString() const {
- return std::format("({}, {})", width.ToDebugString(),
- height.ToDebugString());
+ constexpr Size Min(const Size& other) const {
+ return {width.Min(other.width), height.Min(other.height)};
}
- constexpr static MeasureSize NotSpecified() {
- return MeasureSize{MeasureLength::NotSpecified(),
- MeasureLength::NotSpecified()};
+ constexpr MeasureSize Max(const MeasureSize& other) const {
+ return {width.Max(other.width), height.Max(other.height)};
}
- constexpr static MeasureSize Min(const MeasureSize& left,
- const MeasureSize& right) {
- return MeasureSize{MeasureLength::Min(left.width, right.width),
- MeasureLength::Min(left.height, right.height)};
+ constexpr Size Max(const Size& other) const {
+ return {width.Max(other.width), height.Max(other.height)};
}
- constexpr static MeasureSize Max(const MeasureSize& left,
- const MeasureSize& right) {
- return MeasureSize{MeasureLength::Max(left.width, right.width),
- MeasureLength::Max(left.height, right.height)};
- }
+ std::string ToString() const { return std::format("{}x{}", width, height); }
+
+ constexpr bool operator==(const MeasureSize& other) const = default;
+};
+} // namespace cru::ui::render
+
+template <>
+struct std::formatter<cru::ui::render::MeasureSize, char>
+ : cru::string::ImplementFormatterByToString<cru::ui::render::MeasureSize> {
};
+namespace cru::ui::render {
struct MeasureRequirement {
MeasureSize max;
MeasureSize min;
+ MeasureSize suggest;
constexpr MeasureRequirement() = default;
- constexpr MeasureRequirement(const MeasureSize& max, const MeasureSize& min)
- : max(max), min(min) {}
+ constexpr MeasureRequirement(const MeasureSize& max, const MeasureSize& min,
+ const MeasureSize& suggest,
+ bool allow_coerce_suggest = true)
+ : max(max), min(min), suggest(Coerce(suggest)) {
+ if (max.width.GetLengthOrMaxFloat() < min.width.GetLengthOr0()) {
+ throw Exception(
+ "Measure requirement's max width is smaller than min width.");
+ }
- constexpr bool Satisfy(const Size& size) const {
- auto normalized = Normalize();
- return normalized.max.width.GetLengthOrMax() >= size.width &&
- normalized.max.height.GetLengthOrMax() >= size.height &&
- normalized.min.width.GetLengthOr0() <= size.width &&
- normalized.min.height.GetLengthOr0() <= size.height;
- }
+ if (max.height.GetLengthOrMaxFloat() < min.height.GetLengthOr0()) {
+ throw Exception(
+ "Measure requirement's max height is smaller than min height.");
+ }
- constexpr MeasureRequirement Normalize() const {
- MeasureRequirement result = *this;
- if (result.min.width.GetLengthOr0() > result.max.width.GetLengthOrMax())
- result.min.width = result.max.width;
+ if (!allow_coerce_suggest && this->suggest != suggest) {
+ throw Exception(
+ "Measure requirement's suggest size is in invalid range.");
+ }
+ }
- if (result.min.height.GetLengthOr0() > result.max.height.GetLengthOrMax())
- result.min.height = result.max.height;
- return result;
+ constexpr bool Satisfy(const Size& size) const {
+ return max.width.GetLengthOrMaxFloat() >= size.width &&
+ max.height.GetLengthOrMaxFloat() >= size.height &&
+ min.width.GetLengthOr0() <= size.width &&
+ min.height.GetLengthOr0() <= size.height;
}
constexpr Size Coerce(const Size& size) const {
- // This order guarentees result is the same as normalized.
- return Min(Max(size, min.GetSizeOr0()), max.GetSizeOrMax());
+ return max.Min(min.Max(size));
+ }
+
+ constexpr Size ExpandToSuggestAndCoerce(const Size& size) const {
+ return max.Min(min.Max(suggest.Max(size)));
}
constexpr MeasureSize Coerce(const MeasureSize& size) const {
MeasureSize result = size;
if (result.width.IsSpecified())
- // This order guarentees result is the same as normalized.
- result.width = std::min(std::max(min.width.GetLengthOr0(),
- result.width.GetLengthOrUndefined()),
- max.width.GetLengthOrMax());
+ result.width =
+ max.width.Min(min.width.Max(result.width.GetLengthOrUndefined()));
if (result.height.IsSpecified())
- // This order guarentees result is the same as normalized.
- result.height = std::min(std::max(min.height.GetLengthOr0(),
- result.height.GetLengthOrUndefined()),
- max.height.GetLengthOrMax());
+ result.height =
+ max.height.Min(min.height.Max(result.height.GetLengthOrUndefined()));
return result;
}
- std::string ToDebugString() const {
- return std::format("{{min: {}, max: {}}}", min.ToDebugString(),
- max.ToDebugString());
+ constexpr MeasureRequirement Minus(const Size& size) const {
+ return {max.Minus(size), min.Minus(size), suggest.Minus(size)};
+ }
+
+ /**
+ * Suggest size will use the other's one if this doesn't specify one but the
+ * other does.
+ */
+ constexpr MeasureRequirement Merge(const MeasureRequirement& other) const {
+ return {max.Min(other.max), min.Max(other.min),
+ suggest.OverrideBy(other.suggest)};
}
- constexpr static MeasureRequirement Merge(const MeasureRequirement& left,
- const MeasureRequirement& right) {
- return MeasureRequirement{MeasureSize::Min(left.max, right.max),
- MeasureSize::Max(left.min, right.min)};
+ std::string ToString() const {
+ return std::format("(min: {}, max: {}, suggest: {})", min, max, suggest);
}
+
+ constexpr bool operator==(const MeasureRequirement& other) const = default;
};
} // namespace cru::ui::render
+
+template <>
+struct std::formatter<cru::ui::render::MeasureRequirement, char>
+ : cru::string::ImplementFormatterByToString<
+ cru::ui::render::MeasureRequirement> {};
diff --git a/include/cru/ui/render/RenderObject.h b/include/cru/ui/render/RenderObject.h
index ce788ca6..05fee5df 100644
--- a/include/cru/ui/render/RenderObject.h
+++ b/include/cru/ui/render/RenderObject.h
@@ -82,7 +82,7 @@ class CRU_UI_API RenderObject : public Object {
Point GetTotalOffset();
Point FromRootToContent(const Point& point);
- Size GetDesiredSize() { return desired_size_; }
+ Size GetMeasureResultSize() { return measure_result_size_; }
Thickness GetMargin() { return margin_; }
void SetMargin(const Thickness& margin);
@@ -90,8 +90,8 @@ class CRU_UI_API RenderObject : public Object {
Thickness GetPadding() { return padding_; }
void SetPadding(const Thickness& padding);
- MeasureSize GetPreferredSize() { return preferred_size_; }
- void SetPreferredSize(const MeasureSize& preferred_size);
+ MeasureSize GetSuggestSize() { return custom_measure_requirement_.suggest; }
+ void SetSuggestSize(const MeasureSize& suggest_size);
MeasureSize GetMinSize() { return custom_measure_requirement_.min; }
void SetMinSize(const MeasureSize& min_size);
@@ -110,8 +110,7 @@ class CRU_UI_API RenderObject : public Object {
// OnMeasureCore and use the return value of it to set the size of this render
// object. This can be called multiple times on children during measure to
// adjust for better size.
- void Measure(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size);
+ void Measure(const MeasureRequirement& requirement);
// This will set offset of this render object and call OnLayoutCore.
void Layout(const Point& offset);
@@ -145,8 +144,7 @@ class CRU_UI_API RenderObject : public Object {
// must obey requirement.
// Note: Implementation should coerce the preferred size into the requirement
// when pass them to OnMeasureContent.
- virtual Size OnMeasureCore(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size);
+ virtual Size OnMeasureCore(const MeasureRequirement& requirement);
// Please reduce margin and padding or other custom things and pass the result
// content rect to OnLayoutContent.
@@ -156,8 +154,7 @@ class CRU_UI_API RenderObject : public Object {
// them). Do not consider margin or padding in this method because they are
// already considered in OnMeasureCore. Returned size must obey requirement.
// Caller should guarantee preferred_size is corerced into required range.
- virtual Size OnMeasureContent(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size) = 0;
+ virtual Size OnMeasureContent(const MeasureRequirement& requirement) = 0;
// Layout all content and children(Call Layout on them).
// Lefttop of content_rect should be added when calculated children's offset.
@@ -176,12 +173,10 @@ class CRU_UI_API RenderObject : public Object {
Point offset_;
Size size_;
- Size desired_size_;
-
Thickness margin_;
Thickness padding_;
- MeasureSize preferred_size_;
+ Size measure_result_size_;
MeasureRequirement custom_measure_requirement_;
};
} // namespace cru::ui::render
diff --git a/include/cru/ui/render/ScrollRenderObject.h b/include/cru/ui/render/ScrollRenderObject.h
index 417ebf1c..ae11f361 100644
--- a/include/cru/ui/render/ScrollRenderObject.h
+++ b/include/cru/ui/render/ScrollRenderObject.h
@@ -69,8 +69,7 @@ class CRU_UI_API ScrollRenderObject : public SingleChildRenderObject {
// If available size is bigger than child's preferred size, then child's
// preferred size is taken.
// If not, all available size is taken while forming a scroll area.
- Size OnMeasureContent(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size) override;
+ Size OnMeasureContent(const MeasureRequirement& requirement) override;
void OnLayoutContent(const Rect& content_rect) override;
void OnAttachedControlChanged(controls::Control* old_control,
diff --git a/include/cru/ui/render/StackLayoutRenderObject.h b/include/cru/ui/render/StackLayoutRenderObject.h
index bd08fffc..caddf5c5 100644
--- a/include/cru/ui/render/StackLayoutRenderObject.h
+++ b/include/cru/ui/render/StackLayoutRenderObject.h
@@ -45,8 +45,7 @@ class CRU_UI_API StackLayoutRenderObject
void SetDefaultVerticalAlignment(Alignment alignment);
protected:
- Size OnMeasureContent(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size) override;
+ Size OnMeasureContent(const MeasureRequirement& requirement) override;
void OnLayoutContent(const Rect& content_rect) override;
private:
diff --git a/include/cru/ui/render/TextRenderObject.h b/include/cru/ui/render/TextRenderObject.h
index 28d674aa..e976f86d 100644
--- a/include/cru/ui/render/TextRenderObject.h
+++ b/include/cru/ui/render/TextRenderObject.h
@@ -91,9 +91,7 @@ class CRU_UI_API TextRenderObject : public RenderObject {
protected:
// See remarks of this class.
- Size OnMeasureContent(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size) override;
-
+ Size OnMeasureContent(const MeasureRequirement& requirement) override;
void OnLayoutContent(const Rect& content_rect) override;
private:
diff --git a/include/cru/ui/render/TreeRenderObject.h b/include/cru/ui/render/TreeRenderObject.h
index 90c35747..090fe545 100644
--- a/include/cru/ui/render/TreeRenderObject.h
+++ b/include/cru/ui/render/TreeRenderObject.h
@@ -64,8 +64,7 @@ class CRU_UI_API TreeRenderObject : public RenderObject {
void Draw(platform::graphics::IPainter* painter) override;
protected:
- Size OnMeasureContent(const MeasureRequirement& requirement,
- const MeasureSize& preferred_size) override;
+ Size OnMeasureContent(const MeasureRequirement& requirement) override;
void OnLayoutContent(const Rect& content_rect) override;
private:
diff --git a/include/cru/ui/style/Styler.h b/include/cru/ui/style/Styler.h
index 0e21945d..64226166 100644
--- a/include/cru/ui/style/Styler.h
+++ b/include/cru/ui/style/Styler.h
@@ -113,7 +113,7 @@ class CRU_UI_API PreferredSizeStyler : public Styler {
return new PreferredSizeStyler(size_);
}
- render::MeasureSize GetPreferredSize() const { return size_; }
+ render::MeasureSize GetSuggestSize() const { return size_; }
private:
render::MeasureSize size_;