1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00
serenity/Servers/WindowServer/WSCursor.cpp
Andreas Kling dcf6726487 WindowServer: Add support for per-window override cursors.
Use this to implement automatic switching to an I-beam cursor when hovering
over a GTextEditor. :^)
2019-03-31 23:52:02 +02:00

34 lines
928 B
C++

#include <WindowServer/WSCursor.h>
WSCursor::WSCursor(Retained<GraphicsBitmap>&& bitmap, const Point& hotspot)
: m_bitmap(move(bitmap))
, m_hotspot(hotspot)
{
}
WSCursor::~WSCursor()
{
}
Retained<WSCursor> WSCursor::create(Retained<GraphicsBitmap>&& bitmap)
{
return adopt(*new WSCursor(move(bitmap), bitmap->rect().center()));
}
Retained<WSCursor> WSCursor::create(Retained<GraphicsBitmap>&& bitmap, const Point& hotspot)
{
return adopt(*new WSCursor(move(bitmap), hotspot));
}
RetainPtr<WSCursor> WSCursor::create(WSStandardCursor standard_cursor)
{
switch (standard_cursor) {
case WSStandardCursor::None:
return nullptr;
case WSStandardCursor::Arrow:
return create(*GraphicsBitmap::load_from_file("/res/cursors/arrow.png"));
case WSStandardCursor::IBeam:
return create(*GraphicsBitmap::load_from_file("/res/cursors/i-beam.png"));
}
ASSERT_NOT_REACHED();
}