From 4b47a24bb1db568f21cc4865409567167fb621dc Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 4 Aug 2023 21:18:09 +0200 Subject: [PATCH] wind: Render an actual TGA mouse cursor --- base/usr/share/cursors/default.tga | Bin 0 -> 1004 bytes wind/Mouse.cpp | 10 ++++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 base/usr/share/cursors/default.tga diff --git a/base/usr/share/cursors/default.tga b/base/usr/share/cursors/default.tga new file mode 100644 index 0000000000000000000000000000000000000000..ef3bb7a0b14996e69219c755d329a7e8e230de91 GIT binary patch literal 1004 zcmZQzU}As)9tIHx1q~qYKNQ0x2+=V0AetEP|6yJ +#include + +static SharedPtr g_mouse_cursor; Mouse::Mouse(ui::Canvas& screen) { m_position.x = screen.width / 2; m_position.y = screen.height / 2; m_screen_rect = screen.rect(); + + g_mouse_cursor = ui::Image::load("/usr/share/cursors/default.tga").value_or({}); } void Mouse::draw(ui::Canvas& screen) { - auto canvas = screen.subcanvas(ui::Rect { m_position, 10, 10 }); - canvas.fill(ui::WHITE); + if (!g_mouse_cursor) return; + auto canvas = screen.subcanvas(ui::Rect { m_position, g_mouse_cursor->width(), g_mouse_cursor->height() }); + canvas.fill(g_mouse_cursor->pixels(), g_mouse_cursor->width()); } void Mouse::update(const moon::MousePacket& packet)