From 769a4db24b64a2baf20960858ae24461328e5b7a Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 10 Dec 2018 23:29:54 +0800 Subject: ... --- src/ui/d2d_util.hpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/ui/d2d_util.hpp (limited to 'src/ui/d2d_util.hpp') diff --git a/src/ui/d2d_util.hpp b/src/ui/d2d_util.hpp new file mode 100644 index 00000000..d4fff620 --- /dev/null +++ b/src/ui/d2d_util.hpp @@ -0,0 +1,64 @@ +#pragma once + +// ReSharper disable once CppUnusedIncludeDirective +#include "pre.hpp" + +#include "system_headers.hpp" + +#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 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 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); + } +} -- cgit v1.2.3