# HG changeset patch # User helios2000@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1265223574 0 # Node ID a8bb578847236dc02188e94b89b2df5dee66a97f # Parent 16ea97290dbc2e02627a0cb4135dfb2a5c891b87 * Added a getX/getY command to the cursor diff -r 16ea97290dbc -r a8bb57884723 engine/core/video/cursor.cpp --- a/engine/core/video/cursor.cpp Wed Feb 03 01:50:37 2010 +0000 +++ b/engine/core/video/cursor.cpp Wed Feb 03 18:59:34 2010 +0000 @@ -87,6 +87,8 @@ m_drag_animtime(0), m_drag_offset_x(0), m_drag_offset_y(0), + m_mx(0), + m_my(0), m_timemanager(TimeManager::instance()) { assert(m_timemanager); set(m_cursor_type, m_cursor_id); @@ -128,12 +130,10 @@ } void Cursor::draw() { - int mx = 0; - int my = 0; + SDL_GetMouseState(&m_mx, &m_my); if ((m_cursor_type == CURSOR_NATIVE) && (m_drag_type == CURSOR_NONE)) { return; } - SDL_GetMouseState(&mx, &my); // render possible drag image Image* img = NULL; @@ -145,7 +145,7 @@ img = anim.getFrameByTimestamp(animtime); } if (img) { - Rect area(mx + m_drag_offset_x + img->getXShift(), my + m_drag_offset_y + img->getYShift(), img->getWidth(), img->getHeight()); + Rect area(m_mx + m_drag_offset_x + img->getXShift(), m_my + m_drag_offset_y + img->getYShift(), img->getWidth(), img->getHeight()); m_renderbackend->pushClipArea(area, false); img->render(area); m_renderbackend->popClipArea(); @@ -161,7 +161,7 @@ img = anim.getFrameByTimestamp(animtime); } if (img) { - Rect area(mx + img->getXShift(), my + img->getYShift(), img->getWidth(), img->getHeight()); + Rect area(m_mx + img->getXShift(), m_my + img->getYShift(), img->getWidth(), img->getHeight()); m_renderbackend->pushClipArea(area, false); img->render(area); m_renderbackend->popClipArea(); diff -r 16ea97290dbc -r a8bb57884723 engine/core/video/cursor.h --- a/engine/core/video/cursor.h Wed Feb 03 01:50:37 2010 +0000 +++ b/engine/core/video/cursor.h Wed Feb 03 18:59:34 2010 +0000 @@ -124,6 +124,14 @@ */ unsigned int getDragId() const { return m_drag_id; } + /** Gets the current mouse x position + */ + unsigned int getX() const {return m_mx;} + + /** Gets the current mouse y position + */ + unsigned int getY() const {return m_my;} + protected: /** Sets the cursor to a native type. * @param cursor_id Resource id to native cursor, or one of the values in NativeCursor @@ -156,6 +164,8 @@ int m_drag_offset_x; int m_drag_offset_y; + int m_mx; + int m_my; TimeManager* m_timemanager; }; diff -r 16ea97290dbc -r a8bb57884723 engine/core/video/video.i --- a/engine/core/video/video.i Wed Feb 03 01:50:37 2010 +0000 +++ b/engine/core/video/video.i Wed Feb 03 18:59:34 2010 +0000 @@ -201,6 +201,8 @@ unsigned int getId() const; MouseCursorType getDragType() const; unsigned int getDragId() const; + unsigned int getX() const; + unsigned int getY() const; private: Cursor(ImagePool* imgpool, AnimationPool* animpool);