FIFE
|
Cursor class manages mouse cursor handling. More...
#include <cursor.h>
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... | |
Protected Member Functions | |
void | setNativeCursor (uint32_t cursor_id) |
Sets the cursor to a native type. 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 resource ID specific to the running platform. 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 |
RenderBackend * | m_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 |
TimeManager * | m_timemanager |
bool | m_invalidated |
FIFE::Cursor::Cursor | ( | RenderBackend * | renderbackend | ) |
Constructor.
Definition at line 79 of file cursor.cpp.
References m_cursor_id, m_timemanager, and set().
|
inlinevirtual |
|
virtual |
draws cursor on screen
Definition at line 195 of file cursor.cpp.
References FIFE::CURSOR_ANIMATION, FIFE::CURSOR_IMAGE, FIFE::CURSOR_NATIVE, FIFE::CURSOR_NONE, FIFE::Animation::getDuration(), FIFE::Animation::getFrameByTimestamp(), FIFE::Image::getHeight(), FIFE::TimeManager::getTime(), FIFE::Image::getWidth(), FIFE::Image::getXShift(), FIFE::Image::getYShift(), m_animtime, m_cursor_animation, m_cursor_drag_animation, m_cursor_drag_image, m_cursor_id, m_cursor_image, m_cursor_type, m_drag_animtime, m_drag_offset_x, m_drag_offset_y, m_drag_type, m_invalidated, m_mx, m_my, m_renderbackend, m_timemanager, FIFE::RenderBackend::popClipArea(), FIFE::RenderBackend::pushClipArea(), FIFE::Image::render(), FIFE::RenderBackend::renderVertexArrays(), and set().
Referenced by FIFE::Engine::pump().
|
inline |
Gets the current mouse animation.
Definition at line 149 of file cursor.h.
References m_cursor_animation.
|
inline |
Gets the current mouse drag animation.
Definition at line 161 of file cursor.h.
References m_cursor_drag_animation.
|
inline |
Gets the current mouse drag image.
Definition at line 157 of file cursor.h.
References m_cursor_drag_image.
|
inline |
Gets the current mouse cursor type.
Definition at line 153 of file cursor.h.
References m_drag_type.
|
inline |
Gets the current mouse cursor handle.
Definition at line 141 of file cursor.h.
References m_cursor_id.
|
inline |
|
protected |
To get some consistancy between platforms, this function checks if cursor_id matches any of the values in NativeCursor, and returns the resource ID specific to the running platform.
If no match is found, cursor_id is returned.
cursor_id | One of the values in NativeCursor |
Definition at line 246 of file cursor.cpp.
References FIFE::NC_APPSTARTING, FIFE::NC_ARROW, FIFE::NC_CROSS, FIFE::NC_HAND, FIFE::NC_HELP, FIFE::NC_IBEAM, FIFE::NC_NO, FIFE::NC_RESIZEALL, FIFE::NC_RESIZEE, FIFE::NC_RESIZEN, FIFE::NC_RESIZENE, FIFE::NC_RESIZENW, FIFE::NC_RESIZES, FIFE::NC_RESIZESE, FIFE::NC_RESIZESW, FIFE::NC_RESIZEW, FIFE::NC_UPARROW, and FIFE::NC_WAIT.
Referenced by setNativeCursor().
void FIFE::Cursor::getPosition | ( | int32_t * | x, |
int32_t * | y | ||
) |
Get the current mouse position.
Definition at line 179 of file cursor.cpp.
|
inline |
Gets the current mouse cursor type.
Definition at line 137 of file cursor.h.
References m_cursor_type.
|
inline |
|
inline |
void FIFE::Cursor::invalidate | ( | ) |
Definition at line 184 of file cursor.cpp.
References m_invalidated, and m_native_cursor.
Referenced by FIFE::Engine::changeScreenMode(), and ~Cursor().
void FIFE::Cursor::resetDrag | ( | ) |
Resets the cursor drag type to CURSOR_NONE.
Definition at line 162 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().
void FIFE::Cursor::set | ( | uint32_t | cursor_id = 0 | ) |
Sets the current mouse cursor.
cursor_id | For native cursors, this is the resource id to native cursor, or one of the values in NativeCursor |
Definition at line 97 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 Cursor(), and draw().
void FIFE::Cursor::set | ( | ImagePtr | image | ) |
Sets the current mouse cursor type to image.
image | ImagePtr to a image used for the cursor |
Definition at line 109 of file cursor.cpp.
References FIFE::CURSOR_IMAGE, m_cursor_animation, m_cursor_id, m_cursor_image, m_cursor_type, FIFE::NC_ARROW, and FIFE::SharedPtr< T >::reset().
void FIFE::Cursor::set | ( | AnimationPtr | anim | ) |
Sets the current mouse cursor type to animation.
anim | AnimationPtr to a loaded animation used for the cursor |
Definition at line 123 of file cursor.cpp.
References FIFE::CURSOR_ANIMATION, FIFE::TimeManager::getTime(), m_animtime, m_cursor_animation, m_cursor_id, m_cursor_image, m_cursor_type, m_timemanager, FIFE::NC_ARROW, and FIFE::SharedPtr< T >::reset().
void FIFE::Cursor::setDrag | ( | ImagePtr | image, |
int32_t | drag_offset_x = 0 , |
||
int32_t | drag_offset_y = 0 |
||
) |
Sets the current drag image cursor.
image | ImagePtr to a image used for the drag |
drag_offset_x | X Offset to display image when dragging. |
drag_offset_y | Y Offset to display image when dragging. |
Definition at line 138 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().
void FIFE::Cursor::setDrag | ( | AnimationPtr | anim, |
int32_t | drag_offset_x = 0 , |
||
int32_t | drag_offset_y = 0 |
||
) |
Sets the current drag animated cursor.
anim | AnimationPtr to a loaded animation used for the drag |
drag_offset_x | X Offset to display animation when dragging. |
drag_offset_y | Y Offset to display animation when dragging. |
Definition at line 149 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().
|
protected |
Sets the cursor to a native type.
cursor_id | Resource id to native cursor, or one of the values in NativeCursor |
Definition at line 334 of file cursor.cpp.
References FIFE::_log, FL_WARN, getNativeId(), and m_native_cursor.
Referenced by set().
void FIFE::Cursor::setPosition | ( | uint32_t | x, |
uint32_t | y | ||
) |
Set the mouse position.
x,y,: | The new position in screen coordinates |
Definition at line 173 of file cursor.cpp.
|
private |
|
private |
Definition at line 205 of file cursor.h.
Referenced by draw(), getAnimation(), and set().
|
private |
Definition at line 206 of file cursor.h.
Referenced by draw(), getDragAnimation(), resetDrag(), and setDrag().
|
private |
Definition at line 203 of file cursor.h.
Referenced by draw(), getDragImage(), resetDrag(), and setDrag().
|
private |
|
private |
Definition at line 202 of file cursor.h.
Referenced by draw(), getImage(), and set().
|
private |
|
private |
Definition at line 211 of file cursor.h.
Referenced by draw(), resetDrag(), and setDrag().
|
private |
Definition at line 213 of file cursor.h.
Referenced by draw(), resetDrag(), and setDrag().
|
private |
Definition at line 214 of file cursor.h.
Referenced by draw(), resetDrag(), and setDrag().
|
private |
Definition at line 198 of file cursor.h.
Referenced by draw(), getDragType(), resetDrag(), and setDrag().
|
private |
Definition at line 219 of file cursor.h.
Referenced by draw(), and invalidate().
|
private |
Definition at line 215 of file cursor.h.
Referenced by draw(), getPosition(), getX(), and setPosition().
|
private |
Definition at line 216 of file cursor.h.
Referenced by draw(), getPosition(), getY(), and setPosition().
|
private |
Definition at line 200 of file cursor.h.
Referenced by invalidate(), and setNativeCursor().
|
private |
|
private |