From 04367ead7027e9f0359d24681f5cc0dd916b934d Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Mon, 12 Aug 2019 01:03:02 +0800 Subject: ... --- include/cru/platform/graphic_base.hpp | 12 +++++++++--- include/cru/platform/native/native_window.hpp | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'include/cru/platform') 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* DestroyEvent() = 0; -- cgit v1.2.3