From 8f8b7dfd056dfa23dd1989d3f3dfd3d5d91d0168 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Sat, 22 Nov 2025 21:24:18 +0800 Subject: Clean measure requirement codes. --- include/cru/platform/GraphicsBase.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/cru/platform/GraphicsBase.h') 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::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; } -- cgit v1.2.3