diff --git a/include/eepp/base/string.hpp b/include/eepp/base/string.hpp index 5a3b8bad8..22f6f6eac 100644 --- a/include/eepp/base/string.hpp +++ b/include/eepp/base/string.hpp @@ -321,9 +321,12 @@ class EE_API String { std::wstring ToWideString() const; #endif - /** Convert the string to a Utf8 string */ + /** Convert the string to a UTF-8 string */ std::string ToUtf8() const; + /** Convert the string to a UTF-16 string */ + std::basic_string ToUtf16() const; + /** @return The hash code of the String */ Uint32 GetHash() const; diff --git a/include/eepp/ui/cuidragable.hpp b/include/eepp/ui/cuidragable.hpp index da3263d5c..54958806b 100644 --- a/include/eepp/ui/cuidragable.hpp +++ b/include/eepp/ui/cuidragable.hpp @@ -32,11 +32,15 @@ class EE_API cUIDragable : public cUIControl { eeVector2i mDragPoint; Uint32 mDragButton; - virtual Uint32 OnMouseDown( const eeVector2i& Pos, const Uint32 Flags ); + virtual Uint32 OnMouseDown( const eeVector2i& Pos, const Uint32 Flags ); - virtual Uint32 OnMouseUp( const eeVector2i& Pos, const Uint32 Flags ); + virtual Uint32 OnMouseUp( const eeVector2i& Pos, const Uint32 Flags ); - virtual Uint32 OnDrag( const eeVector2i& Pos ); + virtual Uint32 OnDrag( const eeVector2i& Pos ); + + virtual Uint32 OnDragStart( const eeVector2i& Pos ); + + virtual Uint32 OnDragEnd( const eeVector2i& Pos ); }; }} diff --git a/include/eepp/ui/cuimanager.hpp b/include/eepp/ui/cuimanager.hpp index 8f71bfad0..67966322c 100644 --- a/include/eepp/ui/cuimanager.hpp +++ b/include/eepp/ui/cuimanager.hpp @@ -5,6 +5,9 @@ #include #include #include +#include + +using namespace EE::Window::Cursor; namespace EE { namespace UI { @@ -86,13 +89,18 @@ class EE_API cUIManager { const bool& IsShootingDown() const; /** @return The position of the mouse when the event MouseDown was fired last time. - ** Useful to compare the mouse position of the MouseClick event - */ + ** Useful to compare the mouse position of the MouseClick event */ const eeVector2i& GetMouseDownPos() const; void SetControlDragging( bool dragging ); const bool& IsControlDragging() const; + + void UseGlobalCursors( const bool& use ); + + const bool& UseGlobalCursors(); + + void SetCursor( EE_CURSOR_TYPE cursor ); protected: friend class cUIControl; friend class cUIWindow; @@ -120,6 +128,7 @@ class EE_API cUIManager { bool mFirstPress; bool mShootingDown; bool mControlDragging; + bool mUseGlobalCursors; cUIManager(); diff --git a/include/eepp/ui/cuimessage.hpp b/include/eepp/ui/cuimessage.hpp index 6d9cc2064..75b26451b 100644 --- a/include/eepp/ui/cuimessage.hpp +++ b/include/eepp/ui/cuimessage.hpp @@ -22,6 +22,8 @@ class EE_API cUIMessage { MsgFocusLoss, MsgCellClicked, MsgSelected, + MsgDragStart, + MsgDragEnd, MsgUser, MsgForceDWord = eeINDEX_NOT_FOUND }; diff --git a/include/eepp/ui/cuitextinput.hpp b/include/eepp/ui/cuitextinput.hpp index f593f82f3..76c808008 100644 --- a/include/eepp/ui/cuitextinput.hpp +++ b/include/eepp/ui/cuitextinput.hpp @@ -73,6 +73,8 @@ class EE_API cUITextInput : public cUITextBox { virtual Uint32 OnMouseClick( const eeVector2i& Pos, const Uint32 Flags ); + virtual Uint32 OnMouseExit( const eeVector2i& Pos, const Uint32 Flags ); + virtual Uint32 OnFocus(); virtual Uint32 OnFocusLoss(); diff --git a/include/eepp/ui/cuiwindow.hpp b/include/eepp/ui/cuiwindow.hpp index 4c198b8c0..7fe5532c6 100644 --- a/include/eepp/ui/cuiwindow.hpp +++ b/include/eepp/ui/cuiwindow.hpp @@ -212,6 +212,8 @@ class EE_API cUIWindow : public cUIComplexControl { void EnableByModal(); void DisableByModal(); + + void ResizeCursor(); }; }} diff --git a/include/eepp/window/ccursormanager.hpp b/include/eepp/window/ccursormanager.hpp index bcc76b05a..b3d196b3d 100644 --- a/include/eepp/window/ccursormanager.hpp +++ b/include/eepp/window/ccursormanager.hpp @@ -68,13 +68,13 @@ class EE_API cCursorManager { virtual cCursor * Get( const std::string& name ); /** @return The cursor pointer by its id */ - virtual cCursor * Get( const Uint32& id ); + virtual cCursor * GetById( const Uint32& id ); /** Set the the current cursor by its name */ virtual void Set( const std::string& name ); /** Set the the current cursor by its id */ - virtual void Set( const Uint32& id ); + virtual void SetById( const Uint32& id ); /** Set the the current cursor by its cursor pointer */ virtual void Set( cCursor * cursor ) = 0; @@ -82,6 +82,18 @@ class EE_API cCursorManager { /** Set the cursor using a system cursor */ virtual void Set( EE_SYSTEM_CURSOR syscurid ) = 0; + /** Set the cursor as the global cursor used in eepp + ** @see SetGlobalCursor */ + virtual void Set( EE_CURSOR_TYPE cursor ); + + /** A Global Cursor is a cursor setted to be used in eepp. It's the system cursor of the engine. + ** The global cursor can be a cCursor ( user created cursor ) or a system cursor ( the OS cursor ). + ** The system cursor is used by default, but can be override it with this function. */ + virtual void SetGlobalCursor( EE_CURSOR_TYPE cursor, cCursor * fromCursor ); + + /** @see SetGlobalCursor */ + virtual void SetGlobalCursor( EE_CURSOR_TYPE cursor, EE_SYSTEM_CURSOR fromCursor ); + /** Force to show the cursor */ virtual void Show() = 0; @@ -107,12 +119,33 @@ class EE_API cCursorManager { bool CurrentIsSysCursor() const; protected: typedef std::set CursorsList; + class GlobalCursor + { + public: + GlobalCursor() : + SysCur( SYS_CURSOR_NONE ), + Cur( NULL ) + { + } + + GlobalCursor( EE_SYSTEM_CURSOR sysCur, cCursor * cur ) : + SysCur( sysCur ), + Cur( cur ) + { + } + + EE_SYSTEM_CURSOR SysCur; + cCursor * Cur; + }; + GlobalCursor mGlobalCursors[ EE_CURSOR_COUNT ]; cWindow * mWindow; cCursor * mCurrent; EE_SYSTEM_CURSOR mSysCursor; CursorsList mCursors; bool mCurSysCursor; bool mVisible; + + void InitGlobalCursors(); }; }} diff --git a/include/eepp/window/cursorhelper.hpp b/include/eepp/window/cursorhelper.hpp index 16a51f543..946880047 100644 --- a/include/eepp/window/cursorhelper.hpp +++ b/include/eepp/window/cursorhelper.hpp @@ -5,27 +5,36 @@ namespace EE { namespace Window { namespace Cursor { /** @enum EE_SYSTEM_CURSOR list the system cursors that can be used */ enum EE_SYSTEM_CURSOR { - SYS_CURSOR_NONE = 0, - SYS_CURSOR_DEFAULT = 1, - SYS_CURSOR_ARROW = 2, - SYS_CURSOR_BUSY = 3, - SYS_CURSOR_QUESTION = 4, - SYS_CURSOR_EDIT = 5, - SYS_CURSOR_MOVE = 6, - SYS_CURSOR_RESIZE_N = 7, - SYS_CURSOR_RESIZE_W = 8, - SYS_CURSOR_RESIZE_S = 9, - SYS_CURSOR_RESIZE_E = 10, - SYS_CURSOR_RESIZE_NW = 11, - SYS_CURSOR_RESIZE_SW = 12, - SYS_CURSOR_RESIZE_SE = 13, - SYS_CURSOR_RESIZE_NE = 14, - SYS_CURSOR_PROGRESS = 15, - SYS_CURSOR_PRECISION = 16, - SYS_CURSOR_LINK = 17, - SYS_CURSOR_ALT_SELECT = 18, - SYS_CURSOR_UNAVAILABLE = 19, - SYS_CURSOR_COUNT + SYS_CURSOR_ARROW = 0, /**< Arrow */ + SYS_CURSOR_IBEAM, /**< I-beam */ + SYS_CURSOR_WAIT, /**< Wait */ + SYS_CURSOR_CROSSHAIR, /**< Crosshair */ + SYS_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */ + SYS_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */ + SYS_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */ + SYS_CURSOR_SIZEWE, /**< Double arrow pointing west and east */ + SYS_CURSOR_SIZENS, /**< Double arrow pointing north and south */ + SYS_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */ + SYS_CURSOR_NO, /**< Slashed circle or crossbones */ + SYS_CURSOR_HAND, /**< Hand */ + SYS_CURSOR_COUNT, + SYS_CURSOR_NONE +}; + +enum EE_CURSOR_TYPE { + EE_CURSOR_ARROW = 0, /**< Arrow */ + EE_CURSOR_IBEAM, /**< I-beam */ + EE_CURSOR_WAIT, /**< Wait */ + EE_CURSOR_CROSSHAIR, /**< Crosshair */ + EE_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */ + EE_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */ + EE_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */ + EE_CURSOR_SIZEWE, /**< Double arrow pointing west and east */ + EE_CURSOR_SIZENS, /**< Double arrow pointing north and south */ + EE_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */ + EE_CURSOR_NO, /**< Slashed circle or crossbones */ + EE_CURSOR_HAND, /**< Hand */ + EE_CURSOR_COUNT }; }}} diff --git a/premake4.lua b/premake4.lua index d93eb5853..c68a227bb 100644 --- a/premake4.lua +++ b/premake4.lua @@ -269,7 +269,7 @@ function add_cross_config_links() end function build_link_configuration( package_name, use_ee_icon ) - includedirs { "include", "src" } + includedirs { "include" } local extension = ""; diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 892d85303..3fc15a7e0 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/src/eepp/base/string.cpp b/src/eepp/base/string.cpp index fbdd8e9fd..76c2eee1f 100644 --- a/src/eepp/base/string.cpp +++ b/src/eepp/base/string.cpp @@ -379,6 +379,17 @@ std::string String::ToUtf8() const { return output; } +std::basic_string String::ToUtf16() const { + // Prepare the output string + std::basic_string output; + output.reserve(mString.length()); + + // Convert + Utf32::ToUtf16(mString.begin(), mString.end(), std::back_inserter(output)); + + return output; +} + Uint32 String::GetHash() const { return String::Hash( *this ); diff --git a/src/eepp/ui/cuidragable.cpp b/src/eepp/ui/cuidragable.cpp index 3047bce1f..124d0c2c0 100644 --- a/src/eepp/ui/cuidragable.cpp +++ b/src/eepp/ui/cuidragable.cpp @@ -82,6 +82,14 @@ Uint32 cUIDragable::OnDrag( const eeVector2i& Pos ) { return 1; } +Uint32 cUIDragable::OnDragStart( const eeVector2i& Pos ) { + return 1; +} + +Uint32 cUIDragable::OnDragEnd( const eeVector2i& Pos ) { + return 1; +} + bool cUIDragable::DragEnable() const { return 0 != ( mFlags & UI_DRAG_ENABLE ); } @@ -96,6 +104,18 @@ bool cUIDragable::Dragging() const { void cUIDragable::Dragging( const bool& dragging ) { WriteCtrlFlag( UI_CTRL_FLAG_DRAGGING, true == dragging ); + + if ( dragging ) { + cUIMessage tMsg( this, cUIMessage::MsgDragStart, 0 ); + MessagePost( &tMsg ); + + OnDragStart( cUIManager::instance()->GetMousePos() ); + } else { + cUIMessage tMsg( this, cUIMessage::MsgDragEnd, 0 ); + MessagePost( &tMsg ); + + OnDragEnd( cUIManager::instance()->GetMousePos() ); + } } void cUIDragable::DragButton( const Uint32& Button ) { diff --git a/src/eepp/ui/cuimanager.cpp b/src/eepp/ui/cuimanager.cpp index 4901eb8c1..2376ddd9b 100644 --- a/src/eepp/ui/cuimanager.cpp +++ b/src/eepp/ui/cuimanager.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -22,7 +23,8 @@ cUIManager::cUIManager() : mHighlightOverColor( 195, 123, 234, 255 ), mInit( false ), mFirstPress( false ), - mShootingDown( false ) + mShootingDown( false ), + mUseGlobalCursors( true ) { } @@ -445,4 +447,18 @@ const bool& cUIManager::IsControlDragging() const { return mControlDragging; } +void cUIManager::UseGlobalCursors( const bool& use ) { + mUseGlobalCursors = use; +} + +const bool& cUIManager::UseGlobalCursors() { + return mUseGlobalCursors; +} + +void cUIManager::SetCursor( EE_CURSOR_TYPE cursor ) { + if ( mUseGlobalCursors ) { + mWindow->GetCursorManager()->Set( cursor ); + } +} + }} diff --git a/src/eepp/ui/cuitextinput.cpp b/src/eepp/ui/cuitextinput.cpp index 4575ce597..e4a091829 100644 --- a/src/eepp/ui/cuitextinput.cpp +++ b/src/eepp/ui/cuitextinput.cpp @@ -35,6 +35,10 @@ bool cUITextInput::IsType( const Uint32& type ) const { } void cUITextInput::Update() { + if ( IsMouseOverMeOrChilds() ) { + cUIManager::instance()->SetCursor( EE_CURSOR_IBEAM ); + } + cUITextBox::Update(); if ( mTextBuffer.ChangedSinceLastUpdate() ) { @@ -243,4 +247,12 @@ Uint32 cUITextInput::OnMouseClick( const eeVector2i& Pos, const Uint32 Flags ) { return cUITextBox::OnMouseClick( Pos, Flags ); } +Uint32 cUITextInput::OnMouseExit( const eeVector2i& Pos, const Uint32 Flags ) { + cUIControl::OnMouseExit( Pos, Flags ); + + cUIManager::instance()->SetCursor( EE_CURSOR_ARROW ); + + return 1; +} + }} diff --git a/src/eepp/ui/cuiwindow.cpp b/src/eepp/ui/cuiwindow.cpp index 2f395e820..0810b30b4 100644 --- a/src/eepp/ui/cuiwindow.cpp +++ b/src/eepp/ui/cuiwindow.cpp @@ -407,6 +407,23 @@ Uint32 cUIWindow::OnMessage( const cUIMessage * Msg ) { if ( IsModal() && NULL != mModalCtrl ) { mModalCtrl->Size( cUIManager::instance()->MainControl()->Size() ); } + + break; + } + case cUIMessage::MsgMouseExit: + { + cUIManager::instance()->SetCursor( EE_CURSOR_ARROW ); + break; + } + case cUIMessage::MsgDragStart: + { + cUIManager::instance()->SetCursor( EE_CURSOR_HAND ); + break; + } + case cUIMessage::MsgDragEnd: + { + cUIManager::instance()->SetCursor( EE_CURSOR_ARROW ); + break; } } @@ -668,6 +685,8 @@ void cUIWindow::Draw() { } void cUIWindow::Update() { + ResizeCursor(); + cUIComplexControl::Update(); UpdateResize(); @@ -894,4 +913,55 @@ cUIControlAnim * cUIWindow::GetModalControl() const { return mModalCtrl; } +void cUIWindow::ResizeCursor() { + cUIManager * Man = cUIManager::instance(); + + if ( !IsMouseOverMeOrChilds() || !Man->UseGlobalCursors() || ( mWinFlags & UI_WIN_NO_BORDER ) || !( mWinFlags & UI_WIN_RESIZEABLE ) ) + return; + + eeVector2i Pos = Man->GetMousePos(); + + WorldToControl( Pos ); + + const cUIControl * Control = Man->OverControl(); + + if ( Control == this ) { + if ( Pos.x <= mBorderLeft->Size().Width() ) { + Man->SetCursor( EE_CURSOR_SIZENWSE ); // RESIZE_TOPLEFT + } else if ( Pos.x >= ( mSize.Width() - mBorderRight->Size().Width() ) ) { + Man->SetCursor( EE_CURSOR_SIZENESW ); // RESIZE_TOPRIGHT + } else if ( Pos.y <= mBorderBottom->Size().Height() ) { + if ( Pos.x < mMinCornerDistance ) { + Man->SetCursor( EE_CURSOR_SIZENWSE ); // RESIZE_TOPLEFT + } else if ( Pos.x > mSize.Width() - mMinCornerDistance ) { + Man->SetCursor( EE_CURSOR_SIZENESW ); // RESIZE_TOPRIGHT + } else { + Man->SetCursor( EE_CURSOR_SIZENS ); // RESIZE_TOP + } + } else if ( !( cUIManager::instance()->PressTrigger() & EE_BUTTON_LMASK ) ) { + Man->SetCursor( EE_CURSOR_ARROW ); + } + } else if ( Control == mBorderBottom ) { + if ( Pos.x < mMinCornerDistance ) { + Man->SetCursor( EE_CURSOR_SIZENESW ); // RESIZE_LEFTBOTTOM + } else if ( Pos.x > mSize.Width() - mMinCornerDistance ) { + Man->SetCursor( EE_CURSOR_SIZENWSE ); // RESIZE_RIGHTBOTTOM + } else { + Man->SetCursor( EE_CURSOR_SIZENS ); // RESIZE_BOTTOM + } + } else if ( Control == mBorderLeft ) { + if ( Pos.y >= mSize.Height() - mMinCornerDistance ) { + Man->SetCursor( EE_CURSOR_SIZENESW ); // RESIZE_LEFTBOTTOM + } else { + Man->SetCursor( EE_CURSOR_SIZEWE ); // RESIZE_LEFT + } + } else if ( Control == mBorderRight ) { + if ( Pos.y >= mSize.Height() - mMinCornerDistance ) { + Man->SetCursor( EE_CURSOR_SIZENWSE ); // RESIZE_RIGHTBOTTOM + } else { + Man->SetCursor( EE_CURSOR_SIZEWE ); // RESIZE_RIGHT + } + } +} + }} diff --git a/src/eepp/window/backend/SDL/cwindowsdl.cpp b/src/eepp/window/backend/SDL/cwindowsdl.cpp index c754dd45b..8a9a360c4 100644 --- a/src/eepp/window/backend/SDL/cwindowsdl.cpp +++ b/src/eepp/window/backend/SDL/cwindowsdl.cpp @@ -154,7 +154,7 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { /// Init the input after the window creation reinterpret_cast ( mInput )->Init(); - mCursorManager->Set( Cursor::SYS_CURSOR_DEFAULT ); + mCursorManager->Set( Cursor::SYS_CURSOR_ARROW ); return true; } diff --git a/src/eepp/window/backend/SDL2/ccursormanagersdl2.cpp b/src/eepp/window/backend/SDL2/ccursormanagersdl2.cpp index 7a1f38477..094f0bf4e 100644 --- a/src/eepp/window/backend/SDL2/ccursormanagersdl2.cpp +++ b/src/eepp/window/backend/SDL2/ccursormanagersdl2.cpp @@ -24,19 +24,23 @@ cCursor * cCursorManagerSDL::Create( const std::string& path, const eeVector2i& } void cCursorManagerSDL::Set( cCursor * cursor ) { - SDL_SetCursor( reinterpret_cast( cursor )->GetCursor() ); + if ( NULL != cursor && cursor != mCurrent ) { + SDL_SetCursor( reinterpret_cast( cursor )->GetCursor() ); - mCurrent = cursor; - mCurSysCursor = false; - mSysCursor = Cursor::SYS_CURSOR_NONE; + mCurrent = cursor; + mCurSysCursor = false; + mSysCursor = Cursor::SYS_CURSOR_NONE; + } } void cCursorManagerSDL::Set( EE_SYSTEM_CURSOR syscurid ) { - mWindow->GetPlatform()->SetSystemMouseCursor( syscurid ); + if ( syscurid != mSysCursor ) { + mWindow->GetPlatform()->SetSystemMouseCursor( syscurid ); - mCurrent = NULL; - mCurSysCursor = true; - mSysCursor = syscurid; + mCurrent = NULL; + mCurSysCursor = true; + mSysCursor = syscurid; + } } void cCursorManagerSDL::Show() { @@ -58,7 +62,7 @@ void cCursorManagerSDL::Visible( bool visible ) { } void cCursorManagerSDL::Remove( cCursor * cursor, bool Delete ) { - cCursorManager::Remove( cursor, Delete ); + cCursorManager::Remove( cursor, Delete ); } void cCursorManagerSDL::Reload() { diff --git a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp index 3696513b2..3b40fdc90 100644 --- a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp @@ -266,7 +266,7 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { /// Init the input after the window creation reinterpret_cast ( mInput )->Init(); - mCursorManager->Set( Cursor::SYS_CURSOR_DEFAULT ); + mCursorManager->Set( Cursor::SYS_CURSOR_ARROW ); #if EE_PLATFORM == EE_PLATFORM_ANDROID std::string apkPath( SDL_AndroidGetApkPath() ); diff --git a/src/eepp/window/ccursormanager.cpp b/src/eepp/window/ccursormanager.cpp index 17633efcb..6ffca0816 100644 --- a/src/eepp/window/ccursormanager.cpp +++ b/src/eepp/window/ccursormanager.cpp @@ -10,6 +10,7 @@ cCursorManager::cCursorManager( cWindow * window ) : mCurSysCursor( SYS_CURSOR_NONE ), mVisible( true ) { + InitGlobalCursors(); } cCursorManager::~cCursorManager() { @@ -45,10 +46,10 @@ void cCursorManager::Remove( const Uint32& id, bool Delete ) { } cCursor * cCursorManager::Get( const std::string& name ) { - return Get( String::Hash( name ) ); + return GetById( String::Hash( name ) ); } -cCursor * cCursorManager::Get( const Uint32& id ) { +cCursor * cCursorManager::GetById( const Uint32& id ) { for ( CursorsList::iterator it = mCursors.begin(); it != mCursors.end(); ++it ) { if ( (*it)->Id() == id ) { return (*it); @@ -59,10 +60,10 @@ cCursor * cCursorManager::Get( const Uint32& id ) { } void cCursorManager::Set( const std::string& name ) { - Set( String::Hash( name ) ); + SetById( String::Hash( name ) ); } -void cCursorManager::Set( const Uint32& id ) { +void cCursorManager::SetById( const Uint32& id ) { for ( CursorsList::iterator it = mCursors.begin(); it != mCursors.end(); ++it ) { if ( (*it)->Id() == id ) { Set( *it ); @@ -71,6 +72,32 @@ void cCursorManager::Set( const Uint32& id ) { } } +void cCursorManager::SetGlobalCursor( EE_CURSOR_TYPE cursor, cCursor * fromCursor ) { + if ( cursor < EE_CURSOR_COUNT ) { + mGlobalCursors[ cursor ].SysCur = SYS_CURSOR_NONE; + mGlobalCursors[ cursor ].Cur = fromCursor; + } +} + +void cCursorManager::SetGlobalCursor( EE_CURSOR_TYPE cursor, EE_SYSTEM_CURSOR fromCursor ) { + if ( cursor < EE_CURSOR_COUNT ) { + mGlobalCursors[ cursor ].SysCur = fromCursor; + mGlobalCursors[ cursor ].Cur = NULL; + } +} + +void cCursorManager::Set( EE_CURSOR_TYPE cursor ) { + if ( cursor < EE_CURSOR_COUNT ) { + GlobalCursor& Cursor = mGlobalCursors[ cursor ]; + + if ( SYS_CURSOR_NONE != Cursor.SysCur ) { + Set( Cursor.SysCur ); + } else if ( NULL != Cursor.Cur ) { + Set( Cursor.Cur ); + } + } +} + bool cCursorManager::Visible() { return mVisible; } @@ -87,5 +114,11 @@ bool cCursorManager::CurrentIsSysCursor() const { return mCurSysCursor; } +void cCursorManager::InitGlobalCursors() { + for ( int i = 0; i < EE_CURSOR_COUNT; i++ ) { + mGlobalCursors[ i ].SysCur = static_cast( i ); + } +} + }} diff --git a/src/eepp/window/platform/win/cwinimpl.cpp b/src/eepp/window/platform/win/cwinimpl.cpp index 4b35ff398..bbf0909e1 100644 --- a/src/eepp/window/platform/win/cwinimpl.cpp +++ b/src/eepp/window/platform/win/cwinimpl.cpp @@ -77,15 +77,15 @@ eeVector2i cWinImpl::Position() { } void cWinImpl::ShowMouseCursor() { - mCursorHidden = false; + mCursorHidden = false; if ( !mCursorCurrent ) { - SetSystemMouseCursor( Cursor::SYS_CURSOR_DEFAULT ); + SetSystemMouseCursor( Cursor::SYS_CURSOR_ARROW ); } else { SetCursor( (HCURSOR)mCursorCurrent ); - POINT p; - GetCursorPos( &p ); - SetCursorPos( p.x, p.y ); + POINT p; + GetCursorPos( &p ); + SetCursorPos( p.x, p.y ); } } @@ -111,57 +111,48 @@ cCursor * cWinImpl::CreateMouseCursor( const std::string& path, const eeVector2i } void cWinImpl::SetMouseCursor( cCursor * cursor ) { - mCursorCurrent = reinterpret_cast ( cursor )->GetCursor(); + mCursorCurrent = reinterpret_cast ( cursor )->GetCursor(); - if ( !mCursorHidden ) { + if ( !mCursorHidden ) { SetCursor( (HCURSOR)mCursorCurrent ); - POINT p; - GetCursorPos( &p ); - SetCursorPos( p.x, p.y ); - } + POINT p; + GetCursorPos( &p ); + SetCursorPos( p.x, p.y ); + } } void cWinImpl::SetSystemMouseCursor( Cursor::EE_SYSTEM_CURSOR syscursor ) { HCURSOR mc; switch ( syscursor ) { - case SYS_CURSOR_DEFAULT: case SYS_CURSOR_ARROW: mc = LoadCursor(NULL, IDC_ARROW); break; - case SYS_CURSOR_BUSY: + case SYS_CURSOR_WAIT: mc = LoadCursor(NULL, IDC_WAIT); break; - case SYS_CURSOR_QUESTION: - mc = LoadCursor(NULL, IDC_HELP); break; - case SYS_CURSOR_EDIT: - mc = LoadCursor(NULL, IDC_IBEAM); break; - case SYS_CURSOR_MOVE: - mc = LoadCursor(NULL, IDC_SIZEALL); break; - case SYS_CURSOR_RESIZE_N: - case SYS_CURSOR_RESIZE_S: - mc = LoadCursor(NULL, IDC_SIZENS); break; - case SYS_CURSOR_RESIZE_E: - case SYS_CURSOR_RESIZE_W: - mc = LoadCursor(NULL, IDC_SIZEWE); break; - case SYS_CURSOR_RESIZE_NE: - case SYS_CURSOR_RESIZE_SW: - mc = LoadCursor(NULL, IDC_SIZENESW); break; - case SYS_CURSOR_RESIZE_NW: - case SYS_CURSOR_RESIZE_SE: - mc = LoadCursor(NULL, IDC_SIZENWSE); break; - case SYS_CURSOR_PROGRESS: - mc = LoadCursor(NULL, IDC_APPSTARTING); break; - case SYS_CURSOR_PRECISION: + case SYS_CURSOR_CROSSHAIR: mc = LoadCursor(NULL, IDC_CROSS); break; - case SYS_CURSOR_LINK: - mc = LoadCursor(NULL, IDC_HAND); break; - case SYS_CURSOR_ALT_SELECT: - mc = LoadCursor(NULL, IDC_UPARROW); break; - case SYS_CURSOR_UNAVAILABLE: + case SYS_CURSOR_IBEAM: + mc = LoadCursor(NULL, IDC_IBEAM); break; + case SYS_CURSOR_WAITARROW: + mc = LoadCursor(NULL, IDC_WAIT); break; + case SYS_CURSOR_SIZENWSE: + mc = LoadCursor(NULL, IDC_SIZENWSE); break; + case SYS_CURSOR_SIZENESW: + mc = LoadCursor(NULL, IDC_SIZENESW); break; + case SYS_CURSOR_SIZEWE: + mc = LoadCursor(NULL, IDC_SIZEWE); break; + case SYS_CURSOR_SIZENS: + mc = LoadCursor(NULL, IDC_SIZENS); break; + case SYS_CURSOR_SIZEALL: + mc = LoadCursor(NULL, IDC_SIZEALL); break; + case SYS_CURSOR_NO: mc = LoadCursor(NULL, IDC_NO); break; + case SYS_CURSOR_HAND: + mc = LoadCursor(NULL, IDC_HAND); break; default: return; - mCursorCurrent = mc; + mCursorCurrent = mc; if ( !mCursorHidden ) { SetCursor( mc ); @@ -181,7 +172,7 @@ void cWinImpl::RestoreCursor() { } eeWindowHandle cWinImpl::GetHandler() const { - return mHandler; + return mHandler; } }}} diff --git a/src/eepp/window/platform/x11/cx11impl.cpp b/src/eepp/window/platform/x11/cx11impl.cpp index d4e4bad7d..6221436fa 100644 --- a/src/eepp/window/platform/x11/cx11impl.cpp +++ b/src/eepp/window/platform/x11/cx11impl.cpp @@ -269,61 +269,19 @@ void cX11Impl::SetSystemMouseCursor( Cursor::EE_SYSTEM_CURSOR syscursor ) { unsigned int cursor_shape; switch ( syscursor ) { - case SYS_CURSOR_DEFAULT: - case SYS_CURSOR_ARROW: - case SYS_CURSOR_PROGRESS: - cursor_shape = XC_left_ptr; - break; - case SYS_CURSOR_BUSY: - cursor_shape = XC_watch; - break; - case SYS_CURSOR_QUESTION: - cursor_shape = XC_question_arrow; - break; - case SYS_CURSOR_EDIT: - cursor_shape = XC_xterm; - break; - case SYS_CURSOR_MOVE: - cursor_shape = XC_fleur; - break; - case SYS_CURSOR_RESIZE_N: - cursor_shape = XC_top_side; - break; - case SYS_CURSOR_RESIZE_S: - cursor_shape = XC_bottom_side; - break; - case SYS_CURSOR_RESIZE_E: - cursor_shape = XC_right_side; - break; - case SYS_CURSOR_RESIZE_W: - cursor_shape = XC_left_side; - break; - case SYS_CURSOR_RESIZE_NE: - cursor_shape = XC_top_right_corner; - break; - case SYS_CURSOR_RESIZE_SW: - cursor_shape = XC_bottom_left_corner; - break; - case SYS_CURSOR_RESIZE_NW: - cursor_shape = XC_top_left_corner; - break; - case SYS_CURSOR_RESIZE_SE: - cursor_shape = XC_bottom_right_corner; - break; - case SYS_CURSOR_PRECISION: - cursor_shape = XC_crosshair; - break; - case SYS_CURSOR_LINK: - cursor_shape = XC_hand2; - break; - case SYS_CURSOR_ALT_SELECT: - cursor_shape = XC_hand1; - break; - case SYS_CURSOR_UNAVAILABLE: - cursor_shape = XC_X_cursor; - break; - default: - return; + case SYS_CURSOR_ARROW: cursor_shape = XC_arrow; break; + case SYS_CURSOR_WAIT: cursor_shape = XC_watch; break; + case SYS_CURSOR_WAITARROW: cursor_shape = XC_watch; break; + case SYS_CURSOR_IBEAM: cursor_shape = XC_xterm; break; + case SYS_CURSOR_SIZEALL: cursor_shape = XC_fleur; break; + case SYS_CURSOR_SIZENWSE: cursor_shape = XC_fleur; break; + case SYS_CURSOR_SIZENESW: cursor_shape = XC_fleur; break; + case SYS_CURSOR_SIZEWE: cursor_shape = XC_sb_h_double_arrow; break; + case SYS_CURSOR_SIZENS: cursor_shape = XC_sb_v_double_arrow; break; + case SYS_CURSOR_CROSSHAIR: cursor_shape = XC_tcross; break; + case SYS_CURSOR_HAND: cursor_shape = XC_hand2; break; + case SYS_CURSOR_NO: cursor_shape = XC_pirate; break; + default: return; } if ( None != mCursorCurrent ) { diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 6ef1d0012..18aa1d305 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -922,8 +922,9 @@ void cEETest::LoadTextures() { cCursorManager * CurMan = mWindow->GetCursorManager(); CurMan->Visible( false ); CurMan->Visible( true ); - CurMan->Set( Window::Cursor::SYS_CURSOR_LINK ); - CurMan->Set( CurMan->Add( CurMan->Create( CursorP[0], eeVector2i( 1, 1 ), "cursor_special" ) ) ); + CurMan->Set( Window::Cursor::SYS_CURSOR_HAND ); + CurMan->SetGlobalCursor( EE_CURSOR_ARROW, CurMan->Add( CurMan->Create( CursorP[0], eeVector2i( 1, 1 ), "cursor_special" ) ) ); + CurMan->Set( EE_CURSOR_ARROW ); CL1.AddFrame( TN[2] ); CL1.Position( 500, 400 );