wind: Render an actual TGA mouse cursor
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
apio 2023-08-04 21:18:09 +02:00
parent 2c1e476e4b
commit 4b47a24bb1
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 8 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1004 B

View File

@ -1,17 +1,23 @@
#include "Mouse.h" #include "Mouse.h"
#include <os/File.h> #include <os/File.h>
#include <ui/Image.h>
static SharedPtr<ui::Image> g_mouse_cursor;
Mouse::Mouse(ui::Canvas& screen) Mouse::Mouse(ui::Canvas& screen)
{ {
m_position.x = screen.width / 2; m_position.x = screen.width / 2;
m_position.y = screen.height / 2; m_position.y = screen.height / 2;
m_screen_rect = screen.rect(); m_screen_rect = screen.rect();
g_mouse_cursor = ui::Image::load("/usr/share/cursors/default.tga").value_or({});
} }
void Mouse::draw(ui::Canvas& screen) void Mouse::draw(ui::Canvas& screen)
{ {
auto canvas = screen.subcanvas(ui::Rect { m_position, 10, 10 }); if (!g_mouse_cursor) return;
canvas.fill(ui::WHITE); 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) void Mouse::update(const moon::MousePacket& packet)