FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
FIFE::Cursor Class Reference

Cursor class manages mouse cursor handling. More...

#include <cursor.h>

+ Collaboration diagram for FIFE::Cursor:

Public Member Functions

 Cursor (RenderBackend *renderbackend)
 Constructor. More...
 
virtual ~Cursor ()
 Destructor. More...
 
void invalidate ()
 
virtual void draw ()
 draws cursor on screen More...
 
void set (uint32_t cursor_id=0)
 Sets the current mouse cursor. More...
 
void set (ImagePtr image)
 Sets the current mouse cursor type to image. More...
 
void set (AnimationPtr anim)
 Sets the current mouse cursor type to animation. More...
 
void setDrag (ImagePtr image, int32_t drag_offset_x=0, int32_t drag_offset_y=0)
 Sets the current drag image cursor. More...
 
void setDrag (AnimationPtr anim, int32_t drag_offset_x=0, int32_t drag_offset_y=0)
 Sets the current drag animated cursor. More...
 
void resetDrag ()
 Resets the cursor drag type to CURSOR_NONE. More...
 
MouseCursorType getType () const
 Gets the current mouse cursor type. More...
 
uint32_t getId () const
 Gets the current mouse cursor handle. More...
 
ImagePtr getImage ()
 Gets the current mouse image. More...
 
AnimationPtr getAnimation ()
 Gets the current mouse animation. More...
 
MouseCursorType getDragType () const
 Gets the current mouse cursor type. More...
 
ImagePtr getDragImage ()
 Gets the current mouse drag image. More...
 
AnimationPtr getDragAnimation ()
 Gets the current mouse drag animation. More...
 
uint32_t getX () const
 Gets the current mouse x position. More...
 
uint32_t getY () const
 Gets the current mouse y position. More...
 
void setPosition (uint32_t x, uint32_t y)
 Set the mouse position. More...
 
void getPosition (int32_t *x, int32_t *y)
 Get the current mouse position. More...
 
void setNativeImageCursorEnabled (bool native_image_cursor_enabled)
 Enables or disables the native image cursor feature. More...
 
bool isNativeImageCursorEnabled () const
 Returns whether cursors set to an image or an animation are drawn natively. More...
 

Protected Member Functions

void setNativeCursor (uint32_t cursor_id)
 Sets the cursor to a native type. More...
 
bool setNativeImageCursor (ImagePtr image)
 Sets the SDL cursor to the specified image. More...
 
uint32_t getNativeId (uint32_t cursor_id)
 To get some consistancy between platforms, this function checks if cursor_id matches any of the values in NativeCursor, and returns the SDL_SystemCursor. More...
 

Private Attributes

uint32_t m_cursor_id
 
MouseCursorType m_cursor_type
 
MouseCursorType m_drag_type
 
SDL_Cursor * m_native_cursor
 
ImagePtr m_cursor_image
 
ImagePtr m_cursor_drag_image
 
AnimationPtr m_cursor_animation
 
AnimationPtr m_cursor_drag_animation
 
RenderBackendm_renderbackend
 
uint32_t m_animtime
 
uint32_t m_drag_animtime
 
int32_t m_drag_offset_x
 
int32_t m_drag_offset_y
 
int32_t m_mx
 
int32_t m_my
 
TimeManagerm_timemanager
 
bool m_invalidated
 
bool m_native_image_cursor_enabled
 
ImagePtr m_native_cursor_image
 

Detailed Description

Cursor class manages mouse cursor handling.

Definition at line 73 of file cursor.h.

Constructor & Destructor Documentation

◆ Cursor()

FIFE::Cursor::Cursor ( RenderBackend renderbackend)

Constructor.

Definition at line 47 of file cursor.cpp.

References m_cursor_id, and m_timemanager.

◆ ~Cursor()

virtual FIFE::Cursor::~Cursor ( )
inlinevirtual

Destructor.

Definition at line 81 of file cursor.h.

References draw(), invalidate(), resetDrag(), and setDrag().

Member Function Documentation

◆ draw()

◆ getAnimation()

AnimationPtr FIFE::Cursor::getAnimation ( )
inline

Gets the current mouse animation.

Definition at line 138 of file cursor.h.

References m_cursor_animation.

Referenced by fcn::ResizableWindow::saveCursor().

+ Here is the caller graph for this function:

◆ getDragAnimation()

AnimationPtr FIFE::Cursor::getDragAnimation ( )
inline

Gets the current mouse drag animation.

Definition at line 150 of file cursor.h.

References m_cursor_drag_animation.

◆ getDragImage()

ImagePtr FIFE::Cursor::getDragImage ( )
inline

Gets the current mouse drag image.

Definition at line 146 of file cursor.h.

References m_cursor_drag_image.

◆ getDragType()

MouseCursorType FIFE::Cursor::getDragType ( ) const
inline

Gets the current mouse cursor type.

Definition at line 142 of file cursor.h.

References m_drag_type.

◆ getId()

uint32_t FIFE::Cursor::getId ( ) const
inline

Gets the current mouse cursor handle.

Definition at line 130 of file cursor.h.

References m_cursor_id.

Referenced by fcn::ResizableWindow::saveCursor().

+ Here is the caller graph for this function:

◆ getImage()

ImagePtr FIFE::Cursor::getImage ( )
inline

Gets the current mouse image.

Definition at line 134 of file cursor.h.

References m_cursor_image.

Referenced by fcn::ResizableWindow::saveCursor().

+ Here is the caller graph for this function:

◆ getNativeId()

uint32_t FIFE::Cursor::getNativeId ( uint32_t  cursor_id)
protected

To get some consistancy between platforms, this function checks if cursor_id matches any of the values in NativeCursor, and returns the SDL_SystemCursor.

If no match is found, cursor_id is returned.

Parameters
cursor_idOne of the values in NativeCursor

Definition at line 242 of file cursor.cpp.

References FIFE::NC_ARROW, FIFE::NC_CROSS, FIFE::NC_HAND, FIFE::NC_IBEAM, FIFE::NC_NO, FIFE::NC_RESIZEALL, FIFE::NC_RESIZENESW, FIFE::NC_RESIZENS, FIFE::NC_RESIZENWSE, FIFE::NC_RESIZEWE, FIFE::NC_WAIT, and FIFE::NC_WAITARROW.

Referenced by getY(), and setNativeCursor().

+ Here is the caller graph for this function:

◆ getPosition()

void FIFE::Cursor::getPosition ( int32_t *  x,
int32_t *  y 
)

Get the current mouse position.

Definition at line 164 of file cursor.cpp.

References m_mx, and m_my.

Referenced by getY().

+ Here is the caller graph for this function:

◆ getType()

MouseCursorType FIFE::Cursor::getType ( ) const
inline

Gets the current mouse cursor type.

Definition at line 126 of file cursor.h.

References m_cursor_type.

Referenced by fcn::ResizableWindow::saveCursor().

+ Here is the caller graph for this function:

◆ getX()

uint32_t FIFE::Cursor::getX ( ) const
inline

Gets the current mouse x position.

Definition at line 154 of file cursor.h.

References m_mx.

◆ getY()

uint32_t FIFE::Cursor::getY ( ) const
inline

◆ invalidate()

void FIFE::Cursor::invalidate ( )

Definition at line 169 of file cursor.cpp.

References m_invalidated, m_native_cursor, m_native_cursor_image, and FIFE::SharedPtr< T >::reset().

Referenced by FIFE::Engine::changeScreenMode(), and ~Cursor().

+ Here is the caller graph for this function:

◆ isNativeImageCursorEnabled()

bool FIFE::Cursor::isNativeImageCursorEnabled ( ) const

Returns whether cursors set to an image or an animation are drawn natively.

See also
setNativeImageCursorEnabled()

Definition at line 341 of file cursor.cpp.

References m_native_image_cursor_enabled.

Referenced by getY().

+ Here is the caller graph for this function:

◆ resetDrag()

void FIFE::Cursor::resetDrag ( )

Resets the cursor drag type to CURSOR_NONE.

Definition at line 147 of file cursor.cpp.

References FIFE::CURSOR_NONE, m_cursor_drag_animation, m_cursor_drag_image, m_drag_animtime, m_drag_offset_x, m_drag_offset_y, m_drag_type, and FIFE::SharedPtr< T >::reset().

Referenced by ~Cursor().

+ Here is the caller graph for this function:

◆ set() [1/3]

void FIFE::Cursor::set ( uint32_t  cursor_id = 0)

Sets the current mouse cursor.

Parameters
cursor_idFor native cursors, this is the resource id to native cursor, or one of the values in NativeCursor

Definition at line 66 of file cursor.cpp.

References FIFE::CURSOR_NATIVE, m_cursor_animation, m_cursor_image, m_cursor_type, FIFE::SharedPtr< T >::reset(), and setNativeCursor().

Referenced by fcn::ResizableWindow::mouseMoved(), and fcn::ResizableWindow::restoreCursor().

+ Here is the caller graph for this function:

◆ set() [2/3]

void FIFE::Cursor::set ( ImagePtr  image)

Sets the current mouse cursor type to image.

Parameters
imageImagePtr to a image used for the cursor

Definition at line 78 of file cursor.cpp.

References FIFE::CURSOR_IMAGE, m_cursor_animation, m_cursor_id, m_cursor_image, m_cursor_type, m_native_image_cursor_enabled, FIFE::NC_ARROW, FIFE::SharedPtr< T >::reset(), and setNativeImageCursor().

◆ set() [3/3]

void FIFE::Cursor::set ( AnimationPtr  anim)

Sets the current mouse cursor type to animation.

Parameters
animAnimationPtr to a loaded animation used for the cursor

Definition at line 100 of file cursor.cpp.

References FIFE::CURSOR_ANIMATION, FIFE::Animation::getFrameByTimestamp(), FIFE::TimeManager::getTime(), m_animtime, m_cursor_animation, m_cursor_id, m_cursor_image, m_cursor_type, m_native_image_cursor_enabled, m_timemanager, FIFE::NC_ARROW, FIFE::SharedPtr< T >::reset(), and setNativeImageCursor().

◆ setDrag() [1/2]

void FIFE::Cursor::setDrag ( ImagePtr  image,
int32_t  drag_offset_x = 0,
int32_t  drag_offset_y = 0 
)

Sets the current drag image cursor.

Parameters
imageImagePtr to a image used for the drag
drag_offset_xX Offset to display image when dragging.
drag_offset_yY Offset to display image when dragging.
Note
to reset the cursors drag call cursor.setDrag(Cursor::CURSOR_NONE, 0, 0)

Definition at line 123 of file cursor.cpp.

References FIFE::CURSOR_IMAGE, m_cursor_drag_animation, m_cursor_drag_image, m_drag_offset_x, m_drag_offset_y, m_drag_type, and FIFE::SharedPtr< T >::reset().

Referenced by ~Cursor().

+ Here is the caller graph for this function:

◆ setDrag() [2/2]

void FIFE::Cursor::setDrag ( AnimationPtr  anim,
int32_t  drag_offset_x = 0,
int32_t  drag_offset_y = 0 
)

Sets the current drag animated cursor.

Parameters
animAnimationPtr to a loaded animation used for the drag
drag_offset_xX Offset to display animation when dragging.
drag_offset_yY Offset to display animation when dragging.
Note
to reset the cursors drag call cursor.setDrag(Cursor::CURSOR_NONE, 0, 0)

Definition at line 134 of file cursor.cpp.

References FIFE::CURSOR_ANIMATION, FIFE::TimeManager::getTime(), m_cursor_drag_animation, m_cursor_drag_image, m_drag_animtime, m_drag_offset_x, m_drag_offset_y, m_drag_type, m_timemanager, and FIFE::SharedPtr< T >::reset().

◆ setNativeCursor()

void FIFE::Cursor::setNativeCursor ( uint32_t  cursor_id)
protected

Sets the cursor to a native type.

Parameters
cursor_idOne of the values in NativeCursor

Definition at line 272 of file cursor.cpp.

References FIFE::_log, FL_WARN, getNativeId(), and m_native_cursor.

Referenced by getY(), and set().

+ Here is the caller graph for this function:

◆ setNativeImageCursor()

bool FIFE::Cursor::setNativeImageCursor ( ImagePtr  image)
protected

◆ setNativeImageCursorEnabled()

void FIFE::Cursor::setNativeImageCursorEnabled ( bool  native_image_cursor_enabled)

Enables or disables the native image cursor feature.

If enabled, cursors set to an image or an animation will be set using SDL and drawn by the native platform; otherwise they will be drawn by FIFE. This setting has no effect on NativeCursor types which are always native and on the drag cursor which is always drawn by FIFE.

Definition at line 329 of file cursor.cpp.

References FIFE::CURSOR_ANIMATION, FIFE::CURSOR_IMAGE, m_cursor_animation, m_cursor_image, m_cursor_type, and m_native_image_cursor_enabled.

Referenced by getY(), FIFE::Engine::init(), and setNativeImageCursor().

+ Here is the caller graph for this function:

◆ setPosition()

void FIFE::Cursor::setPosition ( uint32_t  x,
uint32_t  y 
)

Set the mouse position.

Parameters
x,yThe new position in screen coordinates

Definition at line 158 of file cursor.cpp.

References FIFE::DynamicSingleton< RenderBackend >::instance(), m_mx, and m_my.

Referenced by getY().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_animtime

uint32_t FIFE::Cursor::m_animtime
private

Definition at line 218 of file cursor.h.

Referenced by draw(), and set().

◆ m_cursor_animation

AnimationPtr FIFE::Cursor::m_cursor_animation
private

Definition at line 213 of file cursor.h.

Referenced by draw(), getAnimation(), set(), and setNativeImageCursorEnabled().

◆ m_cursor_drag_animation

AnimationPtr FIFE::Cursor::m_cursor_drag_animation
private

Definition at line 214 of file cursor.h.

Referenced by draw(), getDragAnimation(), resetDrag(), and setDrag().

◆ m_cursor_drag_image

ImagePtr FIFE::Cursor::m_cursor_drag_image
private

Definition at line 211 of file cursor.h.

Referenced by draw(), getDragImage(), resetDrag(), and setDrag().

◆ m_cursor_id

uint32_t FIFE::Cursor::m_cursor_id
private

Definition at line 204 of file cursor.h.

Referenced by Cursor(), draw(), getId(), and set().

◆ m_cursor_image

ImagePtr FIFE::Cursor::m_cursor_image
private

Definition at line 210 of file cursor.h.

Referenced by draw(), getImage(), set(), and setNativeImageCursorEnabled().

◆ m_cursor_type

MouseCursorType FIFE::Cursor::m_cursor_type
private

Definition at line 205 of file cursor.h.

Referenced by draw(), getType(), set(), and setNativeImageCursorEnabled().

◆ m_drag_animtime

uint32_t FIFE::Cursor::m_drag_animtime
private

Definition at line 219 of file cursor.h.

Referenced by draw(), resetDrag(), and setDrag().

◆ m_drag_offset_x

int32_t FIFE::Cursor::m_drag_offset_x
private

Definition at line 221 of file cursor.h.

Referenced by draw(), resetDrag(), and setDrag().

◆ m_drag_offset_y

int32_t FIFE::Cursor::m_drag_offset_y
private

Definition at line 222 of file cursor.h.

Referenced by draw(), resetDrag(), and setDrag().

◆ m_drag_type

MouseCursorType FIFE::Cursor::m_drag_type
private

Definition at line 206 of file cursor.h.

Referenced by draw(), getDragType(), resetDrag(), and setDrag().

◆ m_invalidated

bool FIFE::Cursor::m_invalidated
private

Definition at line 227 of file cursor.h.

Referenced by draw(), and invalidate().

◆ m_mx

int32_t FIFE::Cursor::m_mx
private

Definition at line 223 of file cursor.h.

Referenced by draw(), getPosition(), getX(), and setPosition().

◆ m_my

int32_t FIFE::Cursor::m_my
private

Definition at line 224 of file cursor.h.

Referenced by draw(), getPosition(), getY(), and setPosition().

◆ m_native_cursor

SDL_Cursor* FIFE::Cursor::m_native_cursor
private

Definition at line 208 of file cursor.h.

Referenced by invalidate(), setNativeCursor(), and setNativeImageCursor().

◆ m_native_cursor_image

ImagePtr FIFE::Cursor::m_native_cursor_image
private

Definition at line 229 of file cursor.h.

Referenced by invalidate(), and setNativeImageCursor().

◆ m_native_image_cursor_enabled

bool FIFE::Cursor::m_native_image_cursor_enabled
private

Definition at line 228 of file cursor.h.

Referenced by draw(), isNativeImageCursorEnabled(), set(), and setNativeImageCursorEnabled().

◆ m_renderbackend

RenderBackend* FIFE::Cursor::m_renderbackend
private

Definition at line 216 of file cursor.h.

Referenced by draw().

◆ m_timemanager

TimeManager* FIFE::Cursor::m_timemanager
private

Definition at line 225 of file cursor.h.

Referenced by Cursor(), draw(), set(), and setDrag().


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