diff options
Diffstat (limited to 'include/cru/platform')
-rw-r--r-- | include/cru/platform/graphic_base.hpp | 12 | ||||
-rw-r--r-- | include/cru/platform/native/native_window.hpp | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/include/cru/platform/graphic_base.hpp b/include/cru/platform/graphic_base.hpp index 2aa4e2cb..fd479e56 100644 --- a/include/cru/platform/graphic_base.hpp +++ b/include/cru/platform/graphic_base.hpp @@ -239,8 +239,14 @@ struct Color { : 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)); + const std::uint32_t mask = 0b11111111; + return Color((hex >> 16) & mask, (hex >> 8) & mask, hex & mask, 255); + } + + constexpr static Color FromHexAlpha(std::uint32_t hex) { + const std::uint32_t mask = 0b11111111; + return Color((hex >> 16) & mask, (hex >> 8) & mask, hex & mask, + (hex >> 24) & mask); } std::uint8_t red; @@ -254,4 +260,4 @@ constexpr Color black{0, 0, 0}; constexpr Color white{255, 255, 255}; constexpr Color skyblue = Color::FromHex(0x87ceeb); } // namespace colors -} // namespace cru::ui +} // namespace cru::platform diff --git a/include/cru/platform/native/native_window.hpp b/include/cru/platform/native/native_window.hpp index b557a0dd..d4e608b4 100644 --- a/include/cru/platform/native/native_window.hpp +++ b/include/cru/platform/native/native_window.hpp @@ -62,6 +62,7 @@ class NativeWindow : public NativeResource { virtual bool CaptureMouse() = 0; virtual bool ReleaseMouse() = 0; + virtual void Repaint() = 0; virtual graph::Painter* BeginPaint() = 0; virtual IEvent<std::nullptr_t>* DestroyEvent() = 0; |