|
| CursorBase (const Uint8 *data, const Uint8 *mask, int w, int h, int hot_x, int hot_y) |
| Create a cursor using the specified bitmap data and mask (in MSB format).
|
|
| CursorBase (SurfaceBase &surface, int hot_x, int hot_y) |
| Create a color cursor.
|
|
| CursorBase (SystemCursor id) |
| Create a system cursor.
|
|
constexpr | Resource (T resource={}) |
| Constructs the underlying resource.
|
|
constexpr | Resource (std::nullptr_t) |
| Equivalent to default ctor.
|
|
constexpr | Resource (std::nullopt_t) |
| Equivalent to default ctor.
|
|
| Resource (const Resource &other)=delete |
|
| Resource (Resource &&other)=delete |
|
constexpr | Resource (SDL_Cursor * resource={}) |
| Constructs the underlying resource.
|
|
constexpr | Resource (std::nullptr_t) |
| Equivalent to default ctor.
|
|
constexpr | Resource (std::nullopt_t) |
| Equivalent to default ctor.
|
|
| Resource (const Resource &other)=delete |
|
| Resource (Resource &&other)=delete |
|
Resource & | operator= (const Resource &other)=delete |
|
Resource & | operator= (Resource &&other)=delete |
|
constexpr | operator bool () const |
| True if contains a valid resource.
|
|
constexpr bool | operator== (const Resource &other) const=default |
| Comparison.
|
|
constexpr bool | operator== (std::nullopt_t) const |
| Comparison.
|
|
constexpr bool | operator== (std::nullptr_t) const |
| Comparison.
|
|
constexpr SDL_Cursor * | get () const |
| Return contained resource;.
|
|
constexpr SDL_Cursor * | release (SDL_Cursor * newResource={}) |
| Return contained resource and empties or replace value.
|
|
constexpr const SDL_Cursor * | operator-> () const |
| Access to fields.
|
|
constexpr SDL_Cursor * | operator-> () |
| Access to fields.
|
|
SDL::CursorBase::CursorBase |
( |
const Uint8 * |
data, |
|
|
const Uint8 * |
mask, |
|
|
int |
w, |
|
|
int |
h, |
|
|
int |
hot_x, |
|
|
int |
hot_y |
|
) |
| |
|
inline |
mask
has to be in MSB (Most Significant Bit) format.
The cursor width (w
) must be a multiple of 8 bits.
The cursor is created in black and white according to the following:
- data=0, mask=1: white
- data=1, mask=1: black
- data=0, mask=0: transparent
- data=1, mask=0: inverted color if possible, black if not.
Cursors created with this function must be freed with CursorRef.reset().
If you want to have a color cursor, or create your cursor from an SurfaceBase, you should use CursorBase.CursorBase(). Alternately, you can hide the cursor and draw your own as part of your game's rendering, but it will be bound to the framerate.
Also, CursorBase.CursorBase() is available, which provides several readily-available system cursors to pick from.
- Parameters
-
data | the color value for each pixel of the cursor. |
mask | the mask value for each pixel of the cursor. |
w | the width of the cursor. |
h | the height of the cursor. |
hot_x | the x-axis offset from the left of the cursor image to the mouse x position, in the range of 0 to w - 1. |
hot_y | the y-axis offset from the top of the cursor image to the mouse y position, in the range of 0 to h - 1. |
- Postcondition
- a new cursor with the specified parameters on success.
- Exceptions
-
- Thread safety:
- This function should only be called on the main thread.
- Since
- This function is available since SDL 3.2.0.
- See also
- CursorBase.CursorBase
-
CursorBase.CursorBase
-
CursorRef.reset
-
SetCursor
SDL::CursorBase::CursorBase |
( |
SurfaceBase & |
surface, |
|
|
int |
hot_x, |
|
|
int |
hot_y |
|
) |
| |
|
inline |
If this function is passed a surface with alternate representations, the surface will be interpreted as the content to be used for 100% display scale, and the alternate representations will be used for high DPI situations. For example, if the original surface is 32x32, then on a 2x macOS display or 200% display scale on Windows, a 64x64 version of the image will be used, if available. If a matching version of the image isn't available, the closest larger size image will be downscaled to the appropriate size and be used instead, if available. Otherwise, the closest smaller image will be upscaled and be used instead.
- Parameters
-
surface | an SurfaceBase structure representing the cursor image. |
hot_x | the x position of the cursor hot spot. |
hot_y | the y position of the cursor hot spot. |
- Postcondition
- the new cursor on success.
- Exceptions
-
- Thread safety:
- This function should only be called on the main thread.
- Since
- This function is available since SDL 3.2.0.
- See also
- CursorBase.CursorBase
-
CursorBase.CursorBase
-
CursorRef.reset
-
SetCursor