aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/GraphicsBase.h
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-22 16:55:53 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-22 16:55:53 +0800
commit7ce185d5a3fcfad8c8f746f95f3d50a8829faac4 (patch)
treec1f00529a1286748836332b62ae79404b3a83f36 /include/cru/platform/GraphicsBase.h
parentd97c14a922b60e89a9892e519b95b7e793aff543 (diff)
downloadcru-7ce185d5a3fcfad8c8f746f95f3d50a8829faac4.tar.gz
cru-7ce185d5a3fcfad8c8f746f95f3d50a8829faac4.tar.bz2
cru-7ce185d5a3fcfad8c8f746f95f3d50a8829faac4.zip
Clean codes. Remove Measure1.
Diffstat (limited to 'include/cru/platform/GraphicsBase.h')
-rw-r--r--include/cru/platform/GraphicsBase.h40
1 files changed, 12 insertions, 28 deletions
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