ScummVM API documentation
Graphics::CursorManager Class Reference
Inheritance diagram for Graphics::CursorManager:
Common::Singleton< CursorManager > Common::NonCopyable

Public Member Functions

bool isVisible ()
 
bool showMouse (bool visible)
 
void pushCursor (const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale=false, const Graphics::PixelFormat *format=NULL, const byte *mask=nullptr)
 
void pushCursor (const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale=false, const byte *mask=nullptr)
 
void popCursor ()
 
void replaceCursor (const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale=false, const Graphics::PixelFormat *format=nullptr, const byte *mask=nullptr)
 
void replaceCursor (const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale=false, const byte *mask=nullptr)
 
void replaceCursor (const Graphics::Cursor *cursor)
 
void popAllCursors ()
 
bool supportsCursorPalettes ()
 
void disableCursorPalette (bool disable)
 
void pushCursorPalette (const byte *colors, uint start, uint num)
 
void popCursorPalette ()
 
void replaceCursorPalette (const byte *colors, uint start, uint num)
 
void lock (bool locked)
 
void setDefaultArrowCursor (bool push=false)
 

Additional Inherited Members

- Static Public Member Functions inherited from Common::Singleton< CursorManager >
static bool hasInstance ()
 
static CursorManager & instance ()
 
static void destroy ()
 
- Protected Types inherited from Common::Singleton< CursorManager >
typedef CursorManager SingletonBaseType
 
- Static Protected Attributes inherited from Common::Singleton< CursorManager >
static CursorManager * _singleton
 

Member Function Documentation

◆ isVisible()

bool Graphics::CursorManager::isVisible ( )

Return whether the mouse cursor is visible.

◆ showMouse()

bool Graphics::CursorManager::showMouse ( bool  visible)

Show or hide the mouse cursor.

This function does not call OSystem::updateScreen, when visible is true. You may need to call OSystem::updateScreen after a call to showMouse(true) to ensure that the mouse cursor becomes visible.

See also
OSystem::showMouse.

◆ pushCursor() [1/2]

void Graphics::CursorManager::pushCursor ( const void *  buf,
uint  w,
uint  h,
int  hotspotX,
int  hotspotY,
uint32  keycolor,
bool  dontScale = false,
const Graphics::PixelFormat format = NULL,
const byte *  mask = nullptr 
)

Push a new cursor onto the stack, and set it in the backend.

A local copy of the cursor data will be made, so the original buffer can be safely freed afterwards.

Parameters
bufNew cursor data.
wWidth.
hHeight.
hotspotXHotspot X coordinate.
hotspotYHotspot Y coordinate.
keycolorColor value for the transparent color. This cannot exceed the maximum color value as defined by format. Does nothing if mask is set.
dontScaleWhether the cursor should never be scaled. An exception are high PPI displays, where the cursor would be too small to notice otherwise. These are allowed to scale the cursor anyway.
formatPointer to the pixel format that the cursor graphic uses. CLUT8 will be used if this is null or not specified.
maskOptional pointer to cursor mask containing values from the CursorMaskValue enum.
Note
It is acceptable for the buffer to be a null pointer. It is sometimes useful to push a "dummy" cursor and modify it later. The cursor will be added to the stack, but not to the backend.

◆ pushCursor() [2/2]

void Graphics::CursorManager::pushCursor ( const Surface surf,
int  hotspotX,
int  hotspotY,
uint32  keycolor,
bool  dontScale = false,
const byte *  mask = nullptr 
)

Push a new cursor onto the stack, and set it in the backend.

A local copy of the cursor data will be made, so the original surface can be safely freed afterwards.

Parameters
surfNew cursor surface.
hotspotXHotspot X coordinate.
hotspotYHotspot Y coordinate.
keycolorColor value for the transparent color. This cannot exceed the maximum color value as defined by format. Does nothing if mask is set.
dontScaleWhether the cursor should never be scaled. An exception are high PPI displays, where the cursor would be too small to notice otherwise. These are allowed to scale the cursor anyway.
maskOptional pointer to cursor mask containing values from the CursorMaskValue enum.
Note
It is acceptable for the surface to be empty. It is sometimes useful to push a "dummy" cursor and modify it later. The cursor will be added to the stack, but not to the backend.

◆ popCursor()

void Graphics::CursorManager::popCursor ( )

Pop a cursor from the stack, and restore the previous one to the backend.

If there is no previous cursor, the cursor is hidden.

◆ replaceCursor() [1/3]

void Graphics::CursorManager::replaceCursor ( const void *  buf,
uint  w,
uint  h,
int  hotspotX,
int  hotspotY,
uint32  keycolor,
bool  dontScale = false,
const Graphics::PixelFormat format = nullptr,
const byte *  mask = nullptr 
)

Replace the current cursor on the stack.

If the stack is empty, the cursor is pushed instead. This is a slightly more optimized way of popping the old cursor before pushing the new one.

Parameters
bufNew cursor data.
maskNew cursor mask data.
wWidth.
hHeight.
hotspotXHotspot X coordinate.
hotspotYHotspot Y coordinate.
keycolorColor value for the transparent color. This cannot exceed the maximum color value as defined by format. Does nothing if mask is set.
dontScaleWhether the cursor should never be scaled. An exception are high PPI displays, where the cursor would be too small to notice otherwise. These are allowed to scale the cursor anyway.
formatPointer to the pixel format that the cursor graphic uses, CLUT8 will be used if this is null or not specified.
maskOptional pointer to cursor mask containing values from the CursorMaskValue enum.

◆ replaceCursor() [2/3]

void Graphics::CursorManager::replaceCursor ( const Surface surf,
int  hotspotX,
int  hotspotY,
uint32  keycolor,
bool  dontScale = false,
const byte *  mask = nullptr 
)

Replace the current cursor on the stack.

If the stack is empty, the cursor is pushed instead. This is a slightly more optimized way of popping the old cursor before pushing the new one.

Parameters
surfNew cursor surface.
maskNew cursor mask data.
hotspotXHotspot X coordinate.
hotspotYHotspot Y coordinate.
keycolorColor value for the transparent color. This cannot exceed the maximum color value as defined by format. Does nothing if mask is set.
dontScaleWhether the cursor should never be scaled. An exception are high PPI displays, where the cursor would be too small to notice otherwise. These are allowed to scale the cursor anyway.
maskOptional pointer to cursor mask containing values from the CursorMaskValue enum.

◆ replaceCursor() [3/3]

void Graphics::CursorManager::replaceCursor ( const Graphics::Cursor cursor)

Replace the current cursor on the stack.

If the stack is empty, the cursor is pushed instead. This is a slightly more optimized way of popping the old cursor before pushing the new one.

Parameters
cursorNew cursor.

◆ popAllCursors()

void Graphics::CursorManager::popAllCursors ( )

Pop all cursors and cursor palettes from their respective stacks.

The purpose is to ensure that all unnecessary cursors are removed from the stack when returning to the launcher from an engine.

◆ supportsCursorPalettes()

bool Graphics::CursorManager::supportsCursorPalettes ( )

Test whether cursor palettes are supported.

This is just a convenience wrapper for checking whether OSystem::kFeatureCursorPalette is supported by OSystem.

See also
OSystem::kFeatureCursorPalette
OSystem::hasFeature

◆ disableCursorPalette()

void Graphics::CursorManager::disableCursorPalette ( bool  disable)

Enable or disable the current cursor palette.

Parameters
disable

◆ pushCursorPalette()

void Graphics::CursorManager::pushCursorPalette ( const byte *  colors,
uint  start,
uint  num 
)

Push a new cursor palette onto the stack, and set it in the backend.

The palette entries from start until (start+num-1) will be replaced so a full palette update is accomplished via start=0, num=256.

The palette data is specified in the same interleaved RGB format as used by all backends.

Parameters
colorsNew palette data, in interleaved RGB format.
startFirst palette entry to be updated.
numNumber of palette entries to be updated.
Note
If num is zero, the cursor palette is disabled.

◆ popCursorPalette()

void Graphics::CursorManager::popCursorPalette ( )

Pop a cursor palette from the stack, and restore the previous one to the backend.

If there is no previous palette, the cursor palette is disabled instead.

◆ replaceCursorPalette()

void Graphics::CursorManager::replaceCursorPalette ( const byte *  colors,
uint  start,
uint  num 
)

Replace the current cursor palette on the stack.

If the stack is empty, the palette is pushed instead. This is a slightly more optimized way of popping the old palette before pushing the new one.

Parameters
colorsNew palette data, in interleaved RGB format.
startFirst palette entry to be updated.
numNumber of palette entries to be updated.
Note
If num is zero, the cursor palette is disabled.

◆ lock()

void Graphics::CursorManager::lock ( bool  locked)

Lock or unlock the visibility state of the cursor.

When the cursor is locked, calling showMouse(bool) does nothing and returns false.

◆ setDefaultArrowCursor()

void Graphics::CursorManager::setDefaultArrowCursor ( bool  push = false)

Sets default arrow cursor

This is supposed to be used as a sane fallback for system cursor for games that rely on the system cursor

Parameters
pushSpecified if cursor should be pushed on replaced (defailt)

The documentation for this class was generated from the following file: