FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
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... | |
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 |
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 |
bool | m_native_image_cursor_enabled |
ImagePtr | m_native_cursor_image |
FIFE::Cursor::Cursor | ( | RenderBackend * | renderbackend | ) |
|
inlinevirtual |
Destructor.
Definition at line 81 of file cursor.h.
References draw(), invalidate(), resetDrag(), and setDrag().
|
virtual |
draws cursor on screen
Definition at line 179 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_native_image_cursor_enabled, m_renderbackend, m_timemanager, FIFE::RenderBackend::popClipArea(), FIFE::RenderBackend::pushClipArea(), FIFE::Image::render(), FIFE::RenderBackend::renderVertexArrays(), and setNativeImageCursor().
Referenced by FIFE::Engine::pump(), and ~Cursor().
|
inline |
Gets the current mouse animation.
Definition at line 138 of file cursor.h.
References m_cursor_animation.
Referenced by fcn::ResizableWindow::saveCursor().
|
inline |
Gets the current mouse drag animation.
Definition at line 150 of file cursor.h.
References m_cursor_drag_animation.
|
inline |
Gets the current mouse drag image.
Definition at line 146 of file cursor.h.
References m_cursor_drag_image.
|
inline |
Gets the current mouse cursor type.
Definition at line 142 of file cursor.h.
References m_drag_type.
|
inline |
Gets the current mouse cursor handle.
Definition at line 130 of file cursor.h.
References m_cursor_id.
Referenced by fcn::ResizableWindow::saveCursor().
|
inline |
Gets the current mouse image.
Definition at line 134 of file cursor.h.
References m_cursor_image.
Referenced by fcn::ResizableWindow::saveCursor().
|
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.
cursor_id | One 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().
void FIFE::Cursor::getPosition | ( | int32_t * | x, |
int32_t * | y | ||
) |
Get the current mouse position.
Definition at line 164 of file cursor.cpp.
Referenced by getY().
|
inline |
Gets the current mouse cursor type.
Definition at line 126 of file cursor.h.
References m_cursor_type.
Referenced by fcn::ResizableWindow::saveCursor().
|
inline |
|
inline |
Gets the current mouse y position.
Definition at line 158 of file cursor.h.
References getNativeId(), getPosition(), isNativeImageCursorEnabled(), m_my, setNativeCursor(), setNativeImageCursor(), setNativeImageCursorEnabled(), and setPosition().
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().
bool FIFE::Cursor::isNativeImageCursorEnabled | ( | ) | const |
Returns whether cursors set to an image or an animation are drawn natively.
Definition at line 341 of file cursor.cpp.
References m_native_image_cursor_enabled.
Referenced by getY().
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().
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 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().
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 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().
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 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().
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 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().
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 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().
|
protected |
Sets the cursor to a native type.
cursor_id | One 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().
|
protected |
Sets the SDL cursor to the specified image.
Falls back to software cursor on failure.
Definition at line 286 of file cursor.cpp.
References FIFE::_log, FIFE::Image::copySubimage(), FIFE::ImageManager::create(), FL_WARN, FIFE::IResource::getState(), FIFE::Image::getSurface(), FIFE::Image::getXShift(), FIFE::Image::getYShift(), FIFE::DynamicSingleton< ImageManager >::instance(), FIFE::Image::isSharedImage(), FIFE::Image::load(), m_native_cursor, m_native_cursor_image, FIFE::ImageManager::remove(), FIFE::IResource::RES_NOT_LOADED, and setNativeImageCursorEnabled().
Referenced by draw(), getY(), and set().
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().
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 158 of file cursor.cpp.
References FIFE::DynamicSingleton< RenderBackend >::instance(), m_mx, and m_my.
Referenced by getY().
|
private |
|
private |
Definition at line 213 of file cursor.h.
Referenced by draw(), getAnimation(), set(), and setNativeImageCursorEnabled().
|
private |
Definition at line 214 of file cursor.h.
Referenced by draw(), getDragAnimation(), resetDrag(), and setDrag().
|
private |
Definition at line 211 of file cursor.h.
Referenced by draw(), getDragImage(), resetDrag(), and setDrag().
|
private |
|
private |
Definition at line 210 of file cursor.h.
Referenced by draw(), getImage(), set(), and setNativeImageCursorEnabled().
|
private |
|
private |
Definition at line 219 of file cursor.h.
Referenced by draw(), resetDrag(), and setDrag().
|
private |
Definition at line 221 of file cursor.h.
Referenced by draw(), resetDrag(), and setDrag().
|
private |
Definition at line 222 of file cursor.h.
Referenced by draw(), resetDrag(), and setDrag().
|
private |
Definition at line 206 of file cursor.h.
Referenced by draw(), getDragType(), resetDrag(), and setDrag().
|
private |
Definition at line 227 of file cursor.h.
Referenced by draw(), and invalidate().
|
private |
Definition at line 223 of file cursor.h.
Referenced by draw(), getPosition(), getX(), and setPosition().
|
private |
Definition at line 224 of file cursor.h.
Referenced by draw(), getPosition(), getY(), and setPosition().
|
private |
Definition at line 208 of file cursor.h.
Referenced by invalidate(), setNativeCursor(), and setNativeImageCursor().
|
private |
Definition at line 229 of file cursor.h.
Referenced by invalidate(), and setNativeImageCursor().
|
private |
Definition at line 228 of file cursor.h.
Referenced by draw(), isNativeImageCursorEnabled(), set(), and setNativeImageCursorEnabled().
|
private |
|
private |