diff options
author | crupest <crupest@outlook.com> | 2019-03-21 21:42:28 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-03-21 21:42:28 +0800 |
commit | fdbb02b2cbdd4e4069005d0535a343229f7c4d32 (patch) | |
tree | 3cc25c18b3b019f09d6478b8b9f7b4ddbaed9eb6 /src/ui/d2d_util.hpp | |
parent | 616ebd78b543876388cb3d64f108abea041d4983 (diff) | |
download | cru-fdbb02b2cbdd4e4069005d0535a343229f7c4d32.tar.gz cru-fdbb02b2cbdd4e4069005d0535a343229f7c4d32.tar.bz2 cru-fdbb02b2cbdd4e4069005d0535a343229f7c4d32.zip |
...
Diffstat (limited to 'src/ui/d2d_util.hpp')
-rw-r--r-- | src/ui/d2d_util.hpp | 158 |
1 files changed, 74 insertions, 84 deletions
diff --git a/src/ui/d2d_util.hpp b/src/ui/d2d_util.hpp index 94ef6223..96a017dc 100644 --- a/src/ui/d2d_util.hpp +++ b/src/ui/d2d_util.hpp @@ -5,88 +5,78 @@ #include "ui_base.hpp" -namespace cru::ui -{ - inline D2D1_POINT_2F Convert(const Point& point) - { - return D2D1::Point2F(point.x, point.y); - } - - inline D2D1_RECT_F Convert(const Rect& rect) - { - return D2D1::RectF(rect.left, rect.top, rect.left + rect.width, rect.top + rect.height); - } - - inline D2D1_ROUNDED_RECT Convert(const RoundedRect& rounded_rect) - { - return D2D1::RoundedRect(Convert(rounded_rect.rect), rounded_rect.radius_x, rounded_rect.radius_y); - } - - inline D2D1_ELLIPSE Convert(const Ellipse& ellipse) - { - return D2D1::Ellipse(Convert(ellipse.center), ellipse.radius_x, ellipse.radius_y); - } - - inline Point Convert(const D2D1_POINT_2F& point) - { - return Point(point.x, point.y); - } - - inline Rect Convert(const D2D1_RECT_F& rect) - { - return Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); - } - - inline RoundedRect Convert(const D2D1_ROUNDED_RECT& rounded_rect) - { - return RoundedRect(Convert(rounded_rect.rect), rounded_rect.radiusX, rounded_rect.radiusY); - } - - inline Ellipse Convert(const D2D1_ELLIPSE& ellipse) - { - return Ellipse(Convert(ellipse.point), ellipse.radiusX, ellipse.radiusY); - } - - inline bool operator==(const D2D1_POINT_2F& left, const D2D1_POINT_2F& right) - { - return left.x == right.x && left.y == right.y; - } - - inline bool operator!=(const D2D1_POINT_2F& left, const D2D1_POINT_2F& right) - { - return !(left == right); - } - - inline bool operator==(const D2D1_RECT_F& left, const D2D1_RECT_F& right) - { - return left.left == right.left && - left.top == right.top && - left.right == right.right && - left.bottom == right.bottom; - } - - inline bool operator!=(const D2D1_RECT_F& left, const D2D1_RECT_F& right) - { - return !(left == right); - } - - inline bool operator==(const D2D1_ROUNDED_RECT& left, const D2D1_ROUNDED_RECT& right) - { - return left.rect == right.rect && left.radiusX == right.radiusX && left.radiusY == right.radiusY; - } - - inline bool operator!=(const D2D1_ROUNDED_RECT& left, const D2D1_ROUNDED_RECT& right) - { - return !(left == right); - } - - inline bool operator == (const D2D1_ELLIPSE& left, const D2D1_ELLIPSE& right) - { - return left.point == right.point && left.radiusX == right.radiusX && left.radiusY == right.radiusY; - } - - inline bool operator!=(const D2D1_ELLIPSE& left, const D2D1_ELLIPSE& right) - { - return !(left == right); - } +namespace cru::ui { +inline D2D1_POINT_2F Convert(const Point& point) { + return D2D1::Point2F(point.x, point.y); } + +inline D2D1_RECT_F Convert(const Rect& rect) { + return D2D1::RectF(rect.left, rect.top, rect.left + rect.width, + rect.top + rect.height); +} + +inline D2D1_ROUNDED_RECT Convert(const RoundedRect& rounded_rect) { + return D2D1::RoundedRect(Convert(rounded_rect.rect), rounded_rect.radius_x, + rounded_rect.radius_y); +} + +inline D2D1_ELLIPSE Convert(const Ellipse& ellipse) { + return D2D1::Ellipse(Convert(ellipse.center), ellipse.radius_x, + ellipse.radius_y); +} + +inline Point Convert(const D2D1_POINT_2F& point) { + return Point(point.x, point.y); +} + +inline Rect Convert(const D2D1_RECT_F& rect) { + return Rect(rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top); +} + +inline RoundedRect Convert(const D2D1_ROUNDED_RECT& rounded_rect) { + return RoundedRect(Convert(rounded_rect.rect), rounded_rect.radiusX, + rounded_rect.radiusY); +} + +inline Ellipse Convert(const D2D1_ELLIPSE& ellipse) { + return Ellipse(Convert(ellipse.point), ellipse.radiusX, ellipse.radiusY); +} + +inline bool operator==(const D2D1_POINT_2F& left, const D2D1_POINT_2F& right) { + return left.x == right.x && left.y == right.y; +} + +inline bool operator!=(const D2D1_POINT_2F& left, const D2D1_POINT_2F& right) { + return !(left == right); +} + +inline bool operator==(const D2D1_RECT_F& left, const D2D1_RECT_F& right) { + return left.left == right.left && left.top == right.top && + left.right == right.right && left.bottom == right.bottom; +} + +inline bool operator!=(const D2D1_RECT_F& left, const D2D1_RECT_F& right) { + return !(left == right); +} + +inline bool operator==(const D2D1_ROUNDED_RECT& left, + const D2D1_ROUNDED_RECT& right) { + return left.rect == right.rect && left.radiusX == right.radiusX && + left.radiusY == right.radiusY; +} + +inline bool operator!=(const D2D1_ROUNDED_RECT& left, + const D2D1_ROUNDED_RECT& right) { + return !(left == right); +} + +inline bool operator==(const D2D1_ELLIPSE& left, const D2D1_ELLIPSE& right) { + return left.point == right.point && left.radiusX == right.radiusX && + left.radiusY == right.radiusY; +} + +inline bool operator!=(const D2D1_ELLIPSE& left, const D2D1_ELLIPSE& right) { + return !(left == right); +} +} // namespace cru::ui |