commit
e40630ec6d
|
|
@ -55,7 +55,7 @@ DebugActor::DebugActor()
|
|||
comma_locale_ = std::locale(std::locale(), new comma_numpunct);
|
||||
|
||||
background_brush_ = memory::New<Brush>();
|
||||
background_brush_->SetColor(Color(0.0f, 0.0f, 0.0f, 0.7f));
|
||||
background_brush_->SetColor(Color::Rgba(0x000000, 0.7f));
|
||||
|
||||
BrushPtr fill_brush = memory::New<Brush>();
|
||||
fill_brush->SetColor(Color::White);
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ enum class CursorType
|
|||
*/
|
||||
struct Resolution
|
||||
{
|
||||
uint32_t width; ///< 分辨率宽度
|
||||
uint32_t height; ///< 分辨率高度
|
||||
uint32_t refresh_rate; ///< 刷新率
|
||||
uint32_t width = 0; ///< 分辨率宽度
|
||||
uint32_t height = 0; ///< 分辨率高度
|
||||
uint32_t refresh_rate = 0; ///< 刷新率
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -249,28 +249,27 @@ void WindowWin32Impl::Init(const WindowConfig& config)
|
|||
HMONITOR monitor = ::MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
|
||||
|
||||
// Get the target monitor info
|
||||
MONITORINFOEXA monitor_info_ex;
|
||||
memset(&monitor_info_ex, 0, sizeof(MONITORINFOEXA));
|
||||
monitor_info_ex.cbSize = sizeof(MONITORINFOEXA);
|
||||
::GetMonitorInfoA(monitor, &monitor_info_ex);
|
||||
MONITORINFOEXA monitor_info;
|
||||
memset(&monitor_info, 0, sizeof(MONITORINFOEXA));
|
||||
monitor_info.cbSize = sizeof(MONITORINFOEXA);
|
||||
::GetMonitorInfoA(monitor, &monitor_info);
|
||||
|
||||
// Save the device name
|
||||
device_name_ = monitor_info_ex.szDevice;
|
||||
device_name_ = monitor_info.szDevice;
|
||||
|
||||
uint32_t screenw = monitor_info_ex.rcWork.right - monitor_info_ex.rcWork.left;
|
||||
uint32_t screenh = monitor_info_ex.rcWork.bottom - monitor_info_ex.rcWork.top;
|
||||
uint32_t screenw = monitor_info.rcWork.right - monitor_info.rcWork.left;
|
||||
uint32_t screenh = monitor_info.rcWork.bottom - monitor_info.rcWork.top;
|
||||
|
||||
uint32_t win_width, win_height;
|
||||
AdjustWindow(config.width, config.height, GetStyle(), &win_width, &win_height);
|
||||
|
||||
int left = monitor_info_ex.rcWork.left + (screenw - win_width) / 2;
|
||||
int top = monitor_info_ex.rcWork.top + (screenh - win_height) / 2;
|
||||
int left = monitor_info.rcWork.left + (screenw - win_width) / 2;
|
||||
int top = monitor_info.rcWork.top + (screenh - win_height) / 2;
|
||||
|
||||
width_ = win_width;
|
||||
height_ = win_height;
|
||||
resizable_ = config.resizable;
|
||||
is_fullscreen_ = config.fullscreen;
|
||||
resolution_ = Resolution{ width_, height_, 0 };
|
||||
|
||||
handle_ = ::CreateWindowExA(0, "KiwanoAppWnd", config.title.c_str(), GetStyle(), left, top, width_, height_,
|
||||
nullptr, nullptr, hinst, nullptr);
|
||||
|
|
@ -293,6 +292,7 @@ void WindowWin32Impl::Init(const WindowConfig& config)
|
|||
if (is_fullscreen_)
|
||||
{
|
||||
MONITORINFOEXA info = GetMoniterInfoEx(handle_);
|
||||
|
||||
int x = (int)info.rcMonitor.left;
|
||||
int y = (int)info.rcMonitor.top;
|
||||
int cx = (int)(info.rcMonitor.right - info.rcMonitor.left);
|
||||
|
|
@ -301,6 +301,16 @@ void WindowWin32Impl::Init(const WindowConfig& config)
|
|||
// Top the window
|
||||
::SetWindowPos(handle_, HWND_TOPMOST, x, y, cx, cy, SWP_NOACTIVATE);
|
||||
::ShowWindow(handle_, SW_SHOWNORMAL);
|
||||
|
||||
resolution_.width = config.width;
|
||||
resolution_.height = config.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
RECT client_area;
|
||||
::GetClientRect(handle_, &client_area);
|
||||
resolution_.width = uint32_t(client_area.right - client_area.left);
|
||||
resolution_.height = uint32_t(client_area.bottom - client_area.top);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ const uint32_t GREEN_MASK = 0xff << GREEN_SHIFT;
|
|||
const uint32_t BLUE_MASK = 0xff << BLUE_SHIFT;
|
||||
} // namespace
|
||||
|
||||
const Color Color::Transparent = Color(0.f, 0.f, 0.f, 0.f);
|
||||
const Color Color::Transparent = Color(0, 0, 0, 0.f);
|
||||
|
||||
Color::Color()
|
||||
: r(0)
|
||||
|
|
@ -43,30 +43,14 @@ Color::Color()
|
|||
{
|
||||
}
|
||||
|
||||
Color::Color(float r, float g, float b)
|
||||
: r(r)
|
||||
, g(g)
|
||||
, b(b)
|
||||
, a(1.f)
|
||||
{
|
||||
}
|
||||
|
||||
Color::Color(float r, float g, float b, float alpha)
|
||||
: r(r)
|
||||
, g(g)
|
||||
, b(b)
|
||||
Color::Color(uint32_t r, uint32_t g, uint32_t b, float alpha)
|
||||
: r(r / 255.0f)
|
||||
, g(g / 255.0f)
|
||||
, b(b / 255.0f)
|
||||
, a(alpha)
|
||||
{
|
||||
}
|
||||
|
||||
Color::Color(uint32_t rgb)
|
||||
: r(((rgb & RED_MASK) >> RED_SHIFT) / 255.f)
|
||||
, g(((rgb & GREEN_MASK) >> GREEN_SHIFT) / 255.f)
|
||||
, b(((rgb & BLUE_MASK) >> BLUE_SHIFT) / 255.f)
|
||||
, a(1.f)
|
||||
{
|
||||
}
|
||||
|
||||
Color::Color(uint32_t rgb, float alpha)
|
||||
: r(((rgb & RED_MASK) >> RED_SHIFT) / 255.f)
|
||||
, g(((rgb & GREEN_MASK) >> GREEN_SHIFT) / 255.f)
|
||||
|
|
@ -75,7 +59,7 @@ Color::Color(uint32_t rgb, float alpha)
|
|||
{
|
||||
}
|
||||
|
||||
Color Color::Rgb(float r, float g, float b)
|
||||
Color Color::Rgb(uint32_t r, uint32_t g, uint32_t b)
|
||||
{
|
||||
return Color::Rgba(r, g, b, 1.0f);
|
||||
}
|
||||
|
|
@ -85,7 +69,7 @@ Color Color::Rgb(uint32_t rgb)
|
|||
return Color::Rgba(rgb, 1.0f);
|
||||
}
|
||||
|
||||
Color Color::Rgba(float r, float g, float b, float alpha)
|
||||
Color Color::Rgba(uint32_t r, uint32_t g, uint32_t b, float alpha)
|
||||
{
|
||||
return Color(r, g, b, alpha);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,8 @@ namespace kiwano
|
|||
* @brief 颜色
|
||||
* @details
|
||||
* 使用枚举表示颜色: @code Color blue = Color::Blue; @endcode
|
||||
* 使用 RGB 表示一个颜色: @code Color red = Color(1.0f, 0.0f, 0.0f); @endcode
|
||||
* 使用 RGBA 表示一个带透明度的颜色: @code Color not_white = Color(1.0f, 1.0f,
|
||||
* 1.0f, 0.5f); @endcode
|
||||
* 使用 RGB 表示一个颜色: @code Color red = Color(255, 0, 0); @endcode
|
||||
* 使用 RGBA 表示一个带透明度的颜色: @code Color not_white = Color(255, 255, 255, 0.5f); @endcode
|
||||
* 使用一个16进制整型值表示 RGB 颜色: @code Color black(0x000000); @endcode
|
||||
*/
|
||||
class KGE_API Color
|
||||
|
|
@ -44,41 +43,29 @@ class KGE_API Color
|
|||
public:
|
||||
/// \~chinese
|
||||
/// @brief 构造颜色
|
||||
/// @details 默认颜色为 R: 0.0, G: 0.0, B: 0.0, A: 1.0
|
||||
/// @details 默认颜色为 R: 0, G: 0, B: 0, A: 1.0
|
||||
Color();
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGB 颜色
|
||||
/// @param r 红色值,范围 0.0 - 1.0
|
||||
/// @param g 绿色值,范围 0.0 - 1.0
|
||||
/// @param b 蓝色值,范围 0.0 - 1.0
|
||||
Color(float r, float g, float b);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGBA 颜色
|
||||
/// @param r 红色值,范围 0.0 - 1.0
|
||||
/// @param g 绿色值,范围 0.0 - 1.0
|
||||
/// @param b 蓝色值,范围 0.0 - 1.0
|
||||
/// @param r 红色值,范围 0 - 255
|
||||
/// @param g 绿色值,范围 0 - 255
|
||||
/// @param b 蓝色值,范围 0 - 255
|
||||
/// @param alpha Alpha值,范围 0.0 - 1.0
|
||||
Color(float r, float g, float b, float alpha);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGB 颜色
|
||||
/// @param rgb 使用16进制整形值表示 RGB颜色
|
||||
Color(uint32_t rgb);
|
||||
Color(uint32_t r, uint32_t g, uint32_t b, float alpha = 1.0f);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGBA 颜色
|
||||
/// @param rgb 使用16进制整形值表示 RGB 颜色
|
||||
/// @param alpha Alpha值,范围 0.0 - 1.0
|
||||
Color(uint32_t rgb, float alpha);
|
||||
Color(uint32_t rgb, float alpha = 1.0f);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGB 颜色
|
||||
/// @param r 红色值,范围 0.0 - 1.0
|
||||
/// @param g 绿色值,范围 0.0 - 1.0
|
||||
/// @param b 蓝色值,范围 0.0 - 1.0
|
||||
static Color Rgb(float r, float g, float b);
|
||||
/// @param r 红色值,范围 0 - 255
|
||||
/// @param g 绿色值,范围 0 - 255
|
||||
/// @param b 蓝色值,范围 0 - 255
|
||||
static Color Rgb(uint32_t r, uint32_t g, uint32_t b);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGB 颜色
|
||||
|
|
@ -87,11 +74,11 @@ public:
|
|||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGBA 颜色
|
||||
/// @param r 红色值,范围 0.0 - 1.0
|
||||
/// @param g 绿色值,范围 0.0 - 1.0
|
||||
/// @param b 蓝色值,范围 0.0 - 1.0
|
||||
/// @param r 红色值,范围 0 - 255
|
||||
/// @param g 绿色值,范围 0 - 255
|
||||
/// @param b 蓝色值,范围 0 - 255
|
||||
/// @param alpha Alpha值,范围 0.0 - 1.0
|
||||
static Color Rgba(float r, float g, float b, float alpha);
|
||||
static Color Rgba(uint32_t r, uint32_t g, uint32_t b, float alpha);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构造 RGBA 颜色
|
||||
|
|
|
|||
Loading…
Reference in New Issue