diff options
Diffstat (limited to 'include/cru')
| -rw-r--r-- | include/cru/base/Range.h | 2 | ||||
| -rw-r--r-- | include/cru/platform/GraphicsBase.h | 40 | ||||
| -rw-r--r-- | include/cru/ui/render/BorderRenderObject.h | 2 | ||||
| -rw-r--r-- | include/cru/ui/render/CanvasRenderObject.h | 2 | ||||
| -rw-r--r-- | include/cru/ui/render/GeometryRenderObject.h | 2 | ||||
| -rw-r--r-- | include/cru/ui/render/RenderObject.h | 34 | ||||
| -rw-r--r-- | include/cru/ui/render/ScrollRenderObject.h | 2 | ||||
| -rw-r--r-- | include/cru/ui/render/TextRenderObject.h | 2 |
8 files changed, 23 insertions, 63 deletions
diff --git a/include/cru/base/Range.h b/include/cru/base/Range.h index 44c5aca0..a2e15cd3 100644 --- a/include/cru/base/Range.h +++ b/include/cru/base/Range.h @@ -32,6 +32,8 @@ struct Range final { return Range::FromTwoSides(coerce(GetStart()), coerce(GetEnd())); } + constexpr bool operator==(const Range& other) const = default; + Index position = 0; Index count = 0; }; diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h index 23a95865..43c36494 100644 --- a/include/cru/platform/GraphicsBase.h +++ b/include/cru/platform/GraphicsBase.h @@ -27,6 +27,8 @@ struct Point final { return std::format("Point(x: {}, y: {})", x, y); } + constexpr bool operator==(const Point& other) const = default; + float x = 0; float y = 0; }; @@ -39,10 +41,6 @@ constexpr Point operator-(const Point& left, const Point& right) { return Point(left.x - right.x, left.y - right.y); } -constexpr bool operator==(const Point& left, const Point& right) { - return left.x == right.x && left.y == right.y; -} - struct Size final { static CRU_PLATFORM_API const Size kMax; static CRU_PLATFORM_API const Size kZero; @@ -62,6 +60,8 @@ struct Size final { return std::format("Size(width: {}, height: {})", width, height); } + constexpr bool operator==(const Size& other) const = default; + float width = 0; float height = 0; }; @@ -76,10 +76,6 @@ constexpr Size operator-(const Size& left, const Size& right) { return Size(left.width - right.width, left.height - right.height); } -constexpr bool operator==(const Size& left, const Size& right) { - return left.width == right.width && left.height == right.height; -} - struct Thickness final { constexpr Thickness() : Thickness(0) {} @@ -107,6 +103,8 @@ struct Thickness final { return left >= 0.0 && top >= 0.0 && right >= 0.0 && bottom >= 0.0; } + constexpr bool operator==(const Thickness& other) const = default; + float left; float top; float right; @@ -127,11 +125,6 @@ constexpr Thickness operator+(const Thickness& left, const Thickness& right) { left.right + right.right, left.bottom + right.bottom}; } -constexpr bool operator==(const Thickness& left, const Thickness& right) { - return left.left == right.left && left.top == right.top && - left.right == right.right && left.bottom == right.bottom; -} - struct Rect final { constexpr Rect() = default; constexpr Rect(const float left, const float top, const float width, @@ -226,33 +219,27 @@ struct Rect final { top, width, height); } + constexpr bool operator==(const Rect& other) const = default; + float left = 0.0f; float top = 0.0f; float width = 0.0f; float height = 0.0f; }; -constexpr bool operator==(const Rect& left, const Rect& right) { - return left.left == right.left && left.top == right.top && - left.width == right.width && left.height == right.height; -} - struct RoundedRect final { constexpr RoundedRect() = default; constexpr RoundedRect(const Rect& rect, const float radius_x, const float radius_y) : rect(rect), radius_x(radius_x), radius_y(radius_y) {} + constexpr bool operator==(const RoundedRect& other) const = default; + Rect rect{}; float radius_x = 0.0f; float radius_y = 0.0f; }; -constexpr bool operator==(const RoundedRect& left, const RoundedRect& right) { - return left.rect == right.rect && left.radius_x == right.radius_x && - left.radius_y == right.radius_y; -} - struct Ellipse final { constexpr Ellipse() = default; constexpr Ellipse(const Point& center, const float radius_x, @@ -267,16 +254,13 @@ struct Ellipse final { return Rect::FromCenter(center, radius_x * 2.0f, radius_y * 2.0f); } + constexpr bool operator==(const Ellipse& other) const = default; + Point center{}; float radius_x = 0.0f; float radius_y = 0.0f; }; -constexpr bool operator==(const Ellipse& left, const Ellipse& right) { - return left.center == right.center && left.radius_x == right.radius_x && - left.radius_y == right.radius_y; -} - using TextRange = Range; } // namespace cru::platform diff --git a/include/cru/ui/render/BorderRenderObject.h b/include/cru/ui/render/BorderRenderObject.h index 16f04962..6060dc4c 100644 --- a/include/cru/ui/render/BorderRenderObject.h +++ b/include/cru/ui/render/BorderRenderObject.h @@ -54,8 +54,6 @@ class CRU_UI_API BorderRenderObject : public SingleChildRenderObject { const MeasureSize& preferred_size) override; void OnLayoutContent(const Rect& content_rect) override; - Size OnMeasureContent1(const BoxConstraint& constraint) override; - void OnResize(const Size& new_size) override; private: diff --git a/include/cru/ui/render/CanvasRenderObject.h b/include/cru/ui/render/CanvasRenderObject.h index 3471d75f..63da9cd9 100644 --- a/include/cru/ui/render/CanvasRenderObject.h +++ b/include/cru/ui/render/CanvasRenderObject.h @@ -44,8 +44,6 @@ class CRU_UI_API CanvasRenderObject : public RenderObject { const MeasureSize& preferred_size) override; void OnLayoutContent(const Rect& content_rect) override; - Size OnMeasureContent1(const BoxConstraint& constraint) override; - private: Size desired_size_{}; diff --git a/include/cru/ui/render/GeometryRenderObject.h b/include/cru/ui/render/GeometryRenderObject.h index 1c998ef0..2320b71b 100644 --- a/include/cru/ui/render/GeometryRenderObject.h +++ b/include/cru/ui/render/GeometryRenderObject.h @@ -39,8 +39,6 @@ class GeometryRenderObject : public RenderObject { const MeasureSize& preferred_size) override; void OnLayoutContent(const Rect& content_rect) override; - Size OnMeasureContent1(const BoxConstraint& constraint) override; - private: std::shared_ptr<platform::graphics::IGeometry> geometry_ = nullptr; Rect view_port_{}; diff --git a/include/cru/ui/render/RenderObject.h b/include/cru/ui/render/RenderObject.h index 5569c788..ce788ca6 100644 --- a/include/cru/ui/render/RenderObject.h +++ b/include/cru/ui/render/RenderObject.h @@ -103,12 +103,6 @@ class CRU_UI_API RenderObject : public Object { return custom_measure_requirement_; } - Size GetMinSize1() { return min_size_; } - void SetMinSize1(const Size& min_size); - Size GetMaxSize1() { return max_size_; } - void SetMaxSize1(const Size& max_size); - BoxConstraint CalculateMergedConstraint(const BoxConstraint& constraint); - // This method will merge requirement passed by argument and requirement of // the render object using MeasureRequirement::Merge and then call // MeasureRequirement::Normalize on it. And it will use preferred size of the @@ -121,8 +115,6 @@ class CRU_UI_API RenderObject : public Object { // This will set offset of this render object and call OnLayoutCore. void Layout(const Point& offset); - Size Measure1(const BoxConstraint& constraint); - virtual Thickness GetTotalSpaceThickness(); virtual Thickness GetInnerSpaceThickness(); @@ -156,8 +148,6 @@ class CRU_UI_API RenderObject : public Object { virtual Size OnMeasureCore(const MeasureRequirement& requirement, const MeasureSize& preferred_size); - virtual Size OnMeasureCore1(const BoxConstraint& constraint); - // Please reduce margin and padding or other custom things and pass the result // content rect to OnLayoutContent. virtual void OnLayoutCore(); @@ -169,8 +159,6 @@ class CRU_UI_API RenderObject : public Object { virtual Size OnMeasureContent(const MeasureRequirement& requirement, const MeasureSize& preferred_size) = 0; - virtual Size OnMeasureContent1(const BoxConstraint& constraint); - // Layout all content and children(Call Layout on them). // Lefttop of content_rect should be added when calculated children's offset. virtual void OnLayoutContent(const Rect& content_rect) = 0; @@ -182,22 +170,18 @@ class CRU_UI_API RenderObject : public Object { private: std::string name_; - controls::Control* control_ = nullptr; - - RenderObject* parent_ = nullptr; - - Point offset_{}; - Size size_{}; + controls::Control* control_; + RenderObject* parent_; - Size desired_size_{}; + Point offset_; + Size size_; - Thickness margin_{}; - Thickness padding_{}; + Size desired_size_; - MeasureSize preferred_size_{}; - MeasureRequirement custom_measure_requirement_{}; + Thickness margin_; + Thickness padding_; - Size min_size_ = Size::kZero; - Size max_size_ = Size::kMax; + MeasureSize preferred_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 b3d1a09f..417ebf1c 100644 --- a/include/cru/ui/render/ScrollRenderObject.h +++ b/include/cru/ui/render/ScrollRenderObject.h @@ -73,8 +73,6 @@ class CRU_UI_API ScrollRenderObject : public SingleChildRenderObject { const MeasureSize& preferred_size) override; void OnLayoutContent(const Rect& content_rect) override; - Size OnMeasureContent1(const BoxConstraint& constraint) override; - void OnAttachedControlChanged(controls::Control* old_control, controls::Control* new_control) override; diff --git a/include/cru/ui/render/TextRenderObject.h b/include/cru/ui/render/TextRenderObject.h index 19ff800a..28d674aa 100644 --- a/include/cru/ui/render/TextRenderObject.h +++ b/include/cru/ui/render/TextRenderObject.h @@ -94,8 +94,6 @@ class CRU_UI_API TextRenderObject : public RenderObject { Size OnMeasureContent(const MeasureRequirement& requirement, const MeasureSize& preferred_size) override; - Size OnMeasureContent1(const BoxConstraint& constraint) override; - void OnLayoutContent(const Rect& content_rect) override; private: |
