aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/ui_base.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-04 17:12:25 +0800
committercrupest <crupest@outlook.com>2019-04-04 17:12:25 +0800
commita410e2048db6f5ef6fb50e401a59b4b98b979050 (patch)
tree500680c63b074e8c3eefd756fd6a1d0f41840c1a /include/cru/common/ui_base.hpp
parentfcaf471275a67d718887430ee63a53890915c4c7 (diff)
downloadcru-a410e2048db6f5ef6fb50e401a59b4b98b979050.tar.gz
cru-a410e2048db6f5ef6fb50e401a59b4b98b979050.tar.bz2
cru-a410e2048db6f5ef6fb50e401a59b4b98b979050.zip
...
Diffstat (limited to 'include/cru/common/ui_base.hpp')
-rw-r--r--include/cru/common/ui_base.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/cru/common/ui_base.hpp b/include/cru/common/ui_base.hpp
index 0da18f22..017e3bd1 100644
--- a/include/cru/common/ui_base.hpp
+++ b/include/cru/common/ui_base.hpp
@@ -233,9 +233,25 @@ struct TextRange final {
};
struct Color {
+ constexpr Color() : Color(0, 0, 0, 255) {}
+ constexpr Color(std::uint8_t red, std::uint8_t green, std::uint8_t blue,
+ std::uint8_t alpha = 255)
+ : red(red), green(green), blue(blue), alpha(alpha) {}
+
+ constexpr static Color FromHex(std::uint32_t hex) {
+ return Color(hex & (0b11111111 << 16), hex & (0b11111111 << 8),
+ hex & (0b11111111), hex & (0b11111111 << 24));
+ }
+
std::uint8_t red;
std::uint8_t green;
std::uint8_t blue;
std::uint8_t alpha;
};
+
+namespace colors {
+constexpr Color black{0, 0, 0};
+constexpr Color white{255, 255, 255};
+constexpr Color skyblue = Color::FromHex(0x87ceeb);
+} // namespace colors
} // namespace cru::ui