mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00

Use this to implement automatic switching to an I-beam cursor when hovering over a GTextEditor. :^)
34 lines
928 B
C++
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();
|
|
}
|