wind: Render an actual TGA mouse cursor
This commit is contained in:
parent
6d78fc64f9
commit
25ad2b17aa
BIN
base/usr/share/cursors/default.tga
Normal file
BIN
base/usr/share/cursors/default.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 1004 B |
@ -1,17 +1,23 @@
|
||||
#include "Mouse.h"
|
||||
#include <os/File.h>
|
||||
#include <ui/Image.h>
|
||||
|
||||
static SharedPtr<ui::Image> 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)
|
||||
|
Loading…
Reference in New Issue
Block a user