aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-09-15 17:12:51 +0800
committercrupest <crupest@outlook.com>2021-09-15 17:12:51 +0800
commit105e4ad880a810300bf4b3a0a0752ae58924667b (patch)
treeda9fb12923160312d2d989514b0e4df243907b66 /include/cru/platform
parentd6cd1c46889e94b325244e5ba5ccea97cc856952 (diff)
downloadcru-105e4ad880a810300bf4b3a0a0752ae58924667b.tar.gz
cru-105e4ad880a810300bf4b3a0a0752ae58924667b.tar.bz2
cru-105e4ad880a810300bf4b3a0a0752ae58924667b.zip
...
Diffstat (limited to 'include/cru/platform')
-rw-r--r--include/cru/platform/Color.hpp12
-rw-r--r--include/cru/platform/GraphBase.hpp18
2 files changed, 14 insertions, 16 deletions
diff --git a/include/cru/platform/Color.hpp b/include/cru/platform/Color.hpp
index 3388de25..3a72aa65 100644
--- a/include/cru/platform/Color.hpp
+++ b/include/cru/platform/Color.hpp
@@ -1,6 +1,8 @@
#pragma once
#include "cru/platform/Base.hpp"
+#include "cru/common/String.hpp"
+
#include <boost/functional/hash.hpp>
#include <cstdint>
@@ -37,15 +39,14 @@ struct CRU_PLATFORM_API Color {
float GetFloatBlue() const { return static_cast<float>(blue) / 255.f; }
float GetFloatAlpha() const { return static_cast<float>(alpha) / 255.f; }
- std::string ToUtf8String() const;
- std::u16string ToString() const;
+ String ToString() const;
std::uint8_t red;
std::uint8_t green;
std::uint8_t blue;
std::uint8_t alpha;
- static std::optional<Color> Parse(std::u16string_view string,
+ static std::optional<Color> Parse(StringView string,
bool parse_predefined_color = true);
};
@@ -252,9 +253,8 @@ struct std::hash<cru::platform::Color> {
namespace cru::platform {
namespace details {
-extern const std::unordered_map<std::u16string_view, Color>
- predefined_name_color_map;
+extern const std::unordered_map<StringView, Color> predefined_name_color_map;
} // namespace details
-std::optional<Color> GetPredefinedColorByName(std::u16string_view name);
+std::optional<Color> GetPredefinedColorByName(StringView name);
} // namespace cru::platform
diff --git a/include/cru/platform/GraphBase.hpp b/include/cru/platform/GraphBase.hpp
index 2cfc9cc4..e7201ec0 100644
--- a/include/cru/platform/GraphBase.hpp
+++ b/include/cru/platform/GraphBase.hpp
@@ -1,8 +1,6 @@
#pragma once
#include "cru/common/Base.hpp"
-#include "Color.hpp"
-#include "cru/common/Format.hpp"
#include "cru/common/Range.hpp"
#include "cru/common/String.hpp"
@@ -20,10 +18,6 @@ struct Point final {
constexpr Point(const float x, const float y) : x(x), y(y) {}
explicit constexpr Point(const Size& size);
- String ToDebugString() const {
- return Format(u"({}, {})", ToUtf16String(x), ToUtf16String(y));
- }
-
constexpr Point& operator+=(const Point& other) {
this->x += other.x;
this->y += other.y;
@@ -50,6 +44,10 @@ constexpr bool operator!=(const Point& left, const Point& right) {
return !(left == right);
}
+inline String ToString(const Point& point) {
+ return Format(u"(x: {}, y: {})", point.x, point.y);
+}
+
struct Size final {
constexpr Size() = default;
constexpr Size(const float width, const float height)
@@ -62,10 +60,6 @@ struct Size final {
std::numeric_limits<float>::max()};
}
- String ToDebugString() const {
- return Format(u"({}, {})", ToUtf16String(width), ToUtf16String(height));
- }
-
float width = 0;
float height = 0;
};
@@ -88,6 +82,10 @@ constexpr bool operator!=(const Size& left, const Size& right) {
return !(left == right);
}
+inline String ToString(const Size& size) {
+ return Format(u"(width: {}, height: {})", size.width, size.height);
+}
+
struct Thickness final {
constexpr Thickness() : Thickness(0) {}