Browse Source

GUI cursor updates are now all done from GUIManager

Marko Pintera 11 years ago
parent
commit
ac362937eb

+ 1 - 1
BansheeEditor/Include/BsGUIDockSlider.h

@@ -19,10 +19,10 @@ namespace BansheeEditor
 	protected:
 	protected:
 		virtual bool mouseEvent(const BS::GUIMouseEvent& ev);
 		virtual bool mouseEvent(const BS::GUIMouseEvent& ev);
 
 
+		bool _hasCustomCursor(const CM::Vector2I position, BS::CursorType& type) const;
 	private:
 	private:
 		CM::Vector2I mLastDragPosition;
 		CM::Vector2I mLastDragPosition;
 		bool mHorizontal;
 		bool mHorizontal;
-		bool mIsMouseOver;
 		bool mIsCursorSet;
 		bool mIsCursorSet;
 		bool mDragInProgress;
 		bool mDragInProgress;
 
 

+ 1 - 1
BansheeEditor/Include/BsGUIFloatField.h

@@ -27,8 +27,8 @@ namespace BansheeEditor
 		BS::GUIInputBox* mInputBox;
 		BS::GUIInputBox* mInputBox;
 		CM::INT32 mLastDragPos;
 		CM::INT32 mLastDragPos;
 		bool mIsDragging;
 		bool mIsDragging;
-		bool mIsDragCursorSet;
 
 
+		bool _hasCustomCursor(const CM::Vector2I position, BS::CursorType& type) const;
 		virtual bool mouseEvent(const BS::GUIMouseEvent& ev);
 		virtual bool mouseEvent(const BS::GUIMouseEvent& ev);
 
 
 		static bool floatFilter(const CM::WString& str);
 		static bool floatFilter(const CM::WString& str);

+ 1 - 0
BansheeEditor/Include/BsGUIIntField.h

@@ -29,6 +29,7 @@ namespace BansheeEditor
 		bool mIsDragging;
 		bool mIsDragging;
 		bool mIsDragCursorSet;
 		bool mIsDragCursorSet;
 
 
+		bool _hasCustomCursor(const CM::Vector2I position, BS::CursorType& type) const;
 		virtual bool mouseEvent(const BS::GUIMouseEvent& ev);
 		virtual bool mouseEvent(const BS::GUIMouseEvent& ev);
 
 
 		static bool intFilter(const CM::WString& str);
 		static bool intFilter(const CM::WString& str);

+ 12 - 31
BansheeEditor/Source/BsGUIDockSlider.cpp

@@ -20,7 +20,7 @@ namespace BansheeEditor
 
 
 	GUIDockSlider::GUIDockSlider(BS::GUIWidget& parent, bool horizontal, const BS::GUIElementStyle* style, const BS::GUILayoutOptions& layoutOptions)
 	GUIDockSlider::GUIDockSlider(BS::GUIWidget& parent, bool horizontal, const BS::GUIElementStyle* style, const BS::GUILayoutOptions& layoutOptions)
 		:GUIButtonBase(parent, style, GUIContent(HString(L"")), layoutOptions),
 		:GUIButtonBase(parent, style, GUIContent(HString(L"")), layoutOptions),
-		mIsMouseOver(false), mDragInProgress(false), mHorizontal(horizontal), mIsCursorSet(false)
+		mDragInProgress(false), mHorizontal(horizontal), mIsCursorSet(false)
 	{
 	{
 
 
 	}
 	}
@@ -47,35 +47,22 @@ namespace BansheeEditor
 		return new (cm_alloc<GUIDockSlider, PoolAlloc>()) GUIDockSlider(parent, horizontal, style, GUILayoutOptions::create(layoutOptions, style));
 		return new (cm_alloc<GUIDockSlider, PoolAlloc>()) GUIDockSlider(parent, horizontal, style, GUILayoutOptions::create(layoutOptions, style));
 	}
 	}
 
 
-	bool GUIDockSlider::mouseEvent(const GUIMouseEvent& ev)
-	{	
-		bool processed = GUIButtonBase::mouseEvent(ev);
-
-		if(ev.getType() == GUIMouseEventType::MouseOver)
+	bool GUIDockSlider::_hasCustomCursor(const CM::Vector2I position, CursorType& type) const
+	{
+		if(_isInBounds(position))
 		{
 		{
-			mIsMouseOver = true;
-
-			if(!mIsCursorSet)
-			{
-				Cursor::instance().setCursor(mHorizontal ? CursorType::SizeNS : CursorType::SizeWE);
-				mIsCursorSet = true;
-			}
-
+			type = mHorizontal ? CursorType::SizeNS : CursorType::SizeWE;
 			return true;
 			return true;
 		}
 		}
-		else if(ev.getType() == GUIMouseEventType::MouseOut)
-		{
-			mIsMouseOver = false;
 
 
-			if(!mDragInProgress && mIsCursorSet)
-			{
-				Cursor::instance().setCursor(CursorType::Arrow);
-				mIsCursorSet = false;
-			}
+		return false;
+	}
 
 
-			return true;
-		}
-		else if(ev.getType() == GUIMouseEventType::MouseDragStart)
+	bool GUIDockSlider::mouseEvent(const GUIMouseEvent& ev)
+	{	
+		bool processed = GUIButtonBase::mouseEvent(ev);
+
+		if(ev.getType() == GUIMouseEventType::MouseDragStart)
 		{
 		{
 			mLastDragPosition = ev.getPosition();
 			mLastDragPosition = ev.getPosition();
 			mDragInProgress = true;
 			mDragInProgress = true;
@@ -96,12 +83,6 @@ namespace BansheeEditor
 		{
 		{
 			mDragInProgress = false;
 			mDragInProgress = false;
 
 
-			if(mIsCursorSet && !mIsMouseOver)
-			{
-				Cursor::instance().setCursor(CursorType::Arrow);
-				mIsCursorSet = false;
-			}
-
 			return true;
 			return true;
 		}
 		}
 
 

+ 17 - 40
BansheeEditor/Source/BsGUIFloatField.cpp

@@ -22,7 +22,7 @@ namespace BansheeEditor
 	GUIFloatField::GUIFloatField(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, CM::UINT32 labelWidth, 
 	GUIFloatField::GUIFloatField(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, CM::UINT32 labelWidth, 
 		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
 		GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
 		:TGUIField(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mInputBox(nullptr), mIsDragging(false),
 		:TGUIField(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mInputBox(nullptr), mIsDragging(false),
-		mLastDragPos(0), mIsDragCursorSet(false)
+		mLastDragPos(0)
 	{
 	{
 		const GUIElementStyle* curInputBoxStyle = inputBoxStyle;
 		const GUIElementStyle* curInputBoxStyle = inputBoxStyle;
 		if(curInputBoxStyle == nullptr)
 		if(curInputBoxStyle == nullptr)
@@ -41,6 +41,22 @@ namespace BansheeEditor
 
 
 	}
 	}
 
 
+	bool GUIFloatField::_hasCustomCursor(const CM::Vector2I position, CursorType& type) const
+	{
+		RectI draggableArea;
+
+		if(mLabel != nullptr)
+			draggableArea = mLabel->getBounds();
+
+		if(draggableArea.contains(position))
+		{
+			type = CursorType::ArrowLeftRight;
+			return true;
+		}
+
+		return false;
+	}
+
 	bool GUIFloatField::mouseEvent(const GUIMouseEvent& event)
 	bool GUIFloatField::mouseEvent(const GUIMouseEvent& event)
 	{
 	{
 		GUIElementContainer::mouseEvent(event);
 		GUIElementContainer::mouseEvent(event);
@@ -56,9 +72,6 @@ namespace BansheeEditor
 			{
 			{
 				mLastDragPos = event.getPosition().x;
 				mLastDragPos = event.getPosition().x;
 				mIsDragging = true;
 				mIsDragging = true;
-
-				Cursor::instance().setCursor(CursorType::ArrowLeftRight);
-				mIsDragCursorSet = true;
 			}
 			}
 
 
 			return true;
 			return true;
@@ -102,44 +115,8 @@ namespace BansheeEditor
 		{
 		{
 			mIsDragging = false;
 			mIsDragging = false;
 
 
-			if(mIsDragCursorSet)
-			{
-				Cursor::instance().setCursor(CursorType::Arrow);
-				mIsDragCursorSet = false;
-			}
-
 			return true;
 			return true;
 		}
 		}
-		else if(event.getType() == GUIMouseEventType::MouseOut)
-		{
-			if(!mIsDragging)
-			{
-				if(mIsDragCursorSet)
-				{
-					Cursor::instance().setCursor(CursorType::Arrow);
-					mIsDragCursorSet = false;
-				}
-			}
-		}
-		else if(event.getType() == GUIMouseEventType::MouseMove)
-		{
-			if(draggableArea.contains(event.getPosition()))
-			{
-				Cursor::instance().setCursor(CursorType::ArrowLeftRight);
-				mIsDragCursorSet = true;
-			}
-			else
-			{
-				if(!mIsDragging)
-				{
-					if(mIsDragCursorSet)
-					{
-						Cursor::instance().setCursor(CursorType::Arrow);
-						mIsDragCursorSet = false;
-					}
-				}
-			}
-		}
 
 
 		return false;
 		return false;
 	}
 	}

+ 16 - 39
BansheeEditor/Source/BsGUIIntField.cpp

@@ -41,6 +41,22 @@ namespace BansheeEditor
 
 
 	}
 	}
 
 
+	bool GUIIntField::_hasCustomCursor(const CM::Vector2I position, CursorType& type) const
+	{
+		RectI draggableArea;
+
+		if(mLabel != nullptr)
+			draggableArea = mLabel->getBounds();
+
+		if(draggableArea.contains(position))
+		{
+			type = CursorType::ArrowLeftRight;
+			return true;
+		}
+
+		return false;
+	}
+
 	bool GUIIntField::mouseEvent(const GUIMouseEvent& event)
 	bool GUIIntField::mouseEvent(const GUIMouseEvent& event)
 	{
 	{
 		GUIElementContainer::mouseEvent(event);
 		GUIElementContainer::mouseEvent(event);
@@ -56,9 +72,6 @@ namespace BansheeEditor
 			{
 			{
 				mLastDragPos = event.getPosition().x;
 				mLastDragPos = event.getPosition().x;
 				mIsDragging = true;
 				mIsDragging = true;
-
-				Cursor::instance().setCursor(CursorType::ArrowLeftRight);
-				mIsDragCursorSet = true;
 			}
 			}
 
 
 			return true;
 			return true;
@@ -119,44 +132,8 @@ namespace BansheeEditor
 		{
 		{
 			mIsDragging = false;
 			mIsDragging = false;
 
 
-			if(mIsDragCursorSet)
-			{
-				Cursor::instance().setCursor(CursorType::Arrow);
-				mIsDragCursorSet = false;
-			}
-
 			return true;
 			return true;
 		}
 		}
-		else if(event.getType() == GUIMouseEventType::MouseOut)
-		{
-			if(!mIsDragging)
-			{
-				if(mIsDragCursorSet)
-				{
-					Cursor::instance().setCursor(CursorType::Arrow);
-					mIsDragCursorSet = false;
-				}
-			}
-		}
-		else if(event.getType() == GUIMouseEventType::MouseMove)
-		{
-			if(draggableArea.contains(event.getPosition()))
-			{
-				Cursor::instance().setCursor(CursorType::ArrowLeftRight);
-				mIsDragCursorSet = true;
-			}
-			else
-			{
-				if(!mIsDragging)
-				{
-					if(mIsDragCursorSet)
-					{
-						Cursor::instance().setCursor(CursorType::Arrow);
-						mIsDragCursorSet = false;
-					}
-				}
-			}
-		}
 
 
 		return false;
 		return false;
 	}
 	}

+ 4 - 4
BansheeEditor/Source/BsGUITreeView.cpp

@@ -378,7 +378,7 @@ namespace BansheeEditor
 
 
 	bool GUITreeView::commandEvent(const GUICommandEvent& ev)
 	bool GUITreeView::commandEvent(const GUICommandEvent& ev)
 	{
 	{
-		if(ev.getType() == GUICommandEventType::CursorMoveUp || ev.getType() == GUICommandEventType::SelectUp)
+		if(ev.getType() == GUICommandEventType::MoveUp || ev.getType() == GUICommandEventType::SelectUp)
 		{
 		{
 			TreeElement* topMostElement = getTopMostSelectedElement();
 			TreeElement* topMostElement = getTopMostSelectedElement();
 			auto topMostIter = std::find_if(mVisibleElements.begin(), mVisibleElements.end(), 
 			auto topMostIter = std::find_if(mVisibleElements.begin(), mVisibleElements.end(), 
@@ -393,7 +393,7 @@ namespace BansheeEditor
 
 
 				if(topMostIter->isTreeElement())
 				if(topMostIter->isTreeElement())
 				{
 				{
-					if(ev.getType() == GUICommandEventType::CursorMoveUp)
+					if(ev.getType() == GUICommandEventType::MoveUp)
 						unselectAll();
 						unselectAll();
 
 
 					TreeElement* treeElement = topMostIter->getTreeElement();
 					TreeElement* treeElement = topMostIter->getTreeElement();
@@ -402,7 +402,7 @@ namespace BansheeEditor
 				}
 				}
 			}
 			}
 		}
 		}
-		else if(ev.getType() == GUICommandEventType::CursorMoveDown || ev.getType() == GUICommandEventType::SelectDown)
+		else if(ev.getType() == GUICommandEventType::MoveDown || ev.getType() == GUICommandEventType::SelectDown)
 		{
 		{
 			TreeElement* bottoMostElement = getBottomMostSelectedElement();
 			TreeElement* bottoMostElement = getBottomMostSelectedElement();
 			auto bottomMostIter = std::find_if(mVisibleElements.begin(), mVisibleElements.end(), 
 			auto bottomMostIter = std::find_if(mVisibleElements.begin(), mVisibleElements.end(), 
@@ -417,7 +417,7 @@ namespace BansheeEditor
 
 
 				if(bottomMostIter != mVisibleElements.end() && bottomMostIter->isTreeElement())
 				if(bottomMostIter != mVisibleElements.end() && bottomMostIter->isTreeElement())
 				{
 				{
-					if(ev.getType() == GUICommandEventType::CursorMoveDown)
+					if(ev.getType() == GUICommandEventType::MoveDown)
 						unselectAll();
 						unselectAll();
 
 
 					TreeElement* treeElement = bottomMostIter->getTreeElement();
 					TreeElement* treeElement = bottomMostIter->getTreeElement();

+ 1 - 0
BansheeEngine/BansheeEngine.vcxproj

@@ -236,6 +236,7 @@
     <ClInclude Include="Include\BsDragAndDropManager.h" />
     <ClInclude Include="Include\BsDragAndDropManager.h" />
     <ClInclude Include="Include\BsDrawHelper2D.h" />
     <ClInclude Include="Include\BsDrawHelper2D.h" />
     <ClInclude Include="Include\BsBuiltinResources.h" />
     <ClInclude Include="Include\BsBuiltinResources.h" />
+    <ClInclude Include="Include\BsEnums.h" />
     <ClInclude Include="Include\BsGUIArea.h" />
     <ClInclude Include="Include\BsGUIArea.h" />
     <ClInclude Include="Include\BsGUIButton.h" />
     <ClInclude Include="Include\BsGUIButton.h" />
     <ClInclude Include="Include\BsGUIButtonBase.h" />
     <ClInclude Include="Include\BsGUIButtonBase.h" />

+ 3 - 0
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -270,6 +270,9 @@
     <ClInclude Include="Include\BsGUIFoldout.h">
     <ClInclude Include="Include\BsGUIFoldout.h">
       <Filter>Header Files\GUI</Filter>
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsEnums.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">
     <ClCompile Include="Source\BsGUIElement.cpp">

+ 0 - 17
BansheeEngine/Include/BsCursor.h

@@ -7,23 +7,6 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	enum class CursorType
-	{
-		Arrow,
-		ArrowDrag,
-		ArrowLeftRight,
-		Wait,
-		IBeam,
-		SizeNESW,
-		SizeNS,
-		SizeNWSE,
-		SizeWE,
-		Deny,
-
-		// Keep at the end
-		Count
-	};
-
 	/**
 	/**
 	 * @brief	Allows you to manipulate the platform cursor in various ways.
 	 * @brief	Allows you to manipulate the platform cursor in various ways.
 	 * 			
 	 * 			

+ 21 - 0
BansheeEngine/Include/BsEnums.h

@@ -0,0 +1,21 @@
+#pragma once
+
+namespace BansheeEngine
+{
+	enum class CursorType
+	{
+		Arrow,
+		ArrowDrag,
+		ArrowLeftRight,
+		Wait,
+		IBeam,
+		SizeNESW,
+		SizeNS,
+		SizeNWSE,
+		SizeWE,
+		Deny,
+
+		// Keep at the end
+		Count
+	};
+}

+ 1 - 1
BansheeEngine/Include/BsGUICommandEvent.h

@@ -6,7 +6,7 @@ namespace BansheeEngine
 {
 {
 	enum class GUICommandEventType
 	enum class GUICommandEventType
 	{
 	{
-		Redraw, FocusLost, FocusGained, CursorMoveLeft, CursorMoveRight, CursorMoveUp, CursorMoveDown, 
+		Redraw, FocusLost, FocusGained, MoveLeft, MoveRight, MoveUp, MoveDown, 
 		SelectLeft, SelectRight, SelectUp, SelectDown, Escape, Delete, Backspace, Return
 		SelectLeft, SelectRight, SelectUp, SelectDown, Escape, Delete, Backspace, Return
 	};
 	};
 
 

+ 1 - 0
BansheeEngine/Include/BsGUIElement.h

@@ -131,6 +131,7 @@ namespace BansheeEngine
 		CM::UINT32 _getDepth() const { return mDepth; }
 		CM::UINT32 _getDepth() const { return mDepth; }
 		GUIWidget& _getParentWidget() const { return *mParent; }
 		GUIWidget& _getParentWidget() const { return *mParent; }
 		virtual bool _isInBounds(const CM::Vector2I position) const;
 		virtual bool _isInBounds(const CM::Vector2I position) const;
+		virtual bool _hasCustomCursor(const CM::Vector2I position, CursorType& type) const { return false; }
 
 
 		virtual GUIContextMenu* getContextMenu() const { return nullptr; }
 		virtual GUIContextMenu* getContextMenu() const { return nullptr; }
 
 

+ 1 - 1
BansheeEngine/Include/BsGUIInputBox.h

@@ -69,6 +69,7 @@ namespace BansheeEngine
 		virtual CM::RectI _getTextInputRect() const;
 		virtual CM::RectI _getTextInputRect() const;
 
 
 		virtual CM::UINT32 _getRenderElementDepth(CM::UINT32 renderElementIdx) const;
 		virtual CM::UINT32 _getRenderElementDepth(CM::UINT32 renderElementIdx) const;
+		virtual bool _hasCustomCursor(const CM::Vector2I position, CursorType& type) const;
 
 
 		virtual GUIContextMenu* getContextMenu() const;
 		virtual GUIContextMenu* getContextMenu() const;
 	private:
 	private:
@@ -92,7 +93,6 @@ namespace BansheeEngine
 
 
 		bool mCaretShown;
 		bool mCaretShown;
 		bool mSelectionShown;
 		bool mSelectionShown;
-		bool mInputCursorSet;
 		bool mDragInProgress;
 		bool mDragInProgress;
 
 
 		Sprite* renderElemToSprite(CM::UINT32 renderElemIdx, CM::UINT32& localRenderElemIdx) const;
 		Sprite* renderElemToSprite(CM::UINT32 renderElemIdx, CM::UINT32& localRenderElemIdx) const;

+ 1 - 0
BansheeEngine/Include/BsGUIManager.h

@@ -162,6 +162,7 @@ namespace BansheeEngine
 		float mCaretBlinkInterval;
 		float mCaretBlinkInterval;
 		float mCaretLastBlinkTime;
 		float mCaretLastBlinkTime;
 		bool mIsCaretOn;
 		bool mIsCaretOn;
+		CursorType mActiveCursor;
 
 
 		HSpriteTexture mTextSelectionTexture;
 		HSpriteTexture mTextSelectionTexture;
 		CM::Color mTextSelectionColor;
 		CM::Color mTextSelectionColor;

+ 1 - 0
BansheeEngine/Include/BsPrerequisites.h

@@ -19,6 +19,7 @@
 #endif
 #endif
 
 
 #include "CmGameObject.h"
 #include "CmGameObject.h"
+#include "BsEnums.h"
 
 
 // To avoid a lot of typing
 // To avoid a lot of typing
 namespace CM = CamelotFramework;
 namespace CM = CamelotFramework;

+ 16 - 28
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -18,7 +18,6 @@
 #include "BsDragAndDropManager.h"
 #include "BsDragAndDropManager.h"
 #include "BsGUIContextMenu.h"
 #include "BsGUIContextMenu.h"
 #include "BsGUIHelper.h"
 #include "BsGUIHelper.h"
-#include "BsCursor.h"
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
 
 
@@ -36,7 +35,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	GUIInputBox::GUIInputBox(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions, bool multiline)
 	GUIInputBox::GUIInputBox(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions, bool multiline)
-		:GUIElement(parent, style, layoutOptions), mInputCursorSet(false), mDragInProgress(false),
+		:GUIElement(parent, style, layoutOptions), mDragInProgress(false),
 		mCaretShown(false), mSelectionShown(false), mIsMultiline(multiline), mHasFocus(false), mIsMouseOver(false)
 		mCaretShown(false), mSelectionShown(false), mIsMultiline(multiline), mHasFocus(false), mIsMouseOver(false)
 	{
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
@@ -379,6 +378,17 @@ namespace BansheeEngine
 			return _getDepth() - 1;
 			return _getDepth() - 1;
 	}
 	}
 
 
+	bool GUIInputBox::_hasCustomCursor(const CM::Vector2I position, CursorType& type) const
+	{
+		if(_isInBounds(position))
+		{
+			type = CursorType::IBeam;
+			return true;
+		}
+
+		return false;
+	}
+
 	void GUIInputBox::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
 	void GUIInputBox::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
 		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
 		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
 	{
 	{
@@ -400,9 +410,6 @@ namespace BansheeEngine
 				markContentAsDirty();
 				markContentAsDirty();
 			}
 			}
 
 
-			Cursor::instance().setCursor(CursorType::IBeam);
-			mInputCursorSet = true;
-
 			mIsMouseOver = true;
 			mIsMouseOver = true;
 
 
 			return true;
 			return true;
@@ -415,23 +422,10 @@ namespace BansheeEngine
 				markContentAsDirty();
 				markContentAsDirty();
 			}
 			}
 
 
-			if(!mDragInProgress && mInputCursorSet)
-			{
-				Cursor::instance().setCursor(CursorType::Arrow);
-				mInputCursorSet = false;
-			}
-
 			mIsMouseOver = false;
 			mIsMouseOver = false;
 
 
 			return true;
 			return true;
 		}
 		}
-		else if(ev.getType() == GUIMouseEventType::MouseMove)
-		{
-			Cursor::instance().setCursor(CursorType::IBeam);
-			mInputCursorSet = true;
-
-			return true;
-		}
 		else if(ev.getType() == GUIMouseEventType::MouseDoubleClick && ev.getButton() == GUIMouseButton::Left)
 		else if(ev.getType() == GUIMouseEventType::MouseDoubleClick && ev.getButton() == GUIMouseButton::Left)
 		{
 		{
 			showSelection(0);
 			showSelection(0);
@@ -496,12 +490,6 @@ namespace BansheeEngine
 			{
 			{
 				mDragInProgress = false;
 				mDragInProgress = false;
 
 
-				if(!mIsMouseOver && mInputCursorSet)
-				{
-					Cursor::instance().setCursor(CursorType::Arrow);
-					mInputCursorSet = false;
-				}
-
 				gGUIManager().getInputSelectionTool()->selectionDragEnd();
 				gGUIManager().getInputSelectionTool()->selectionDragEnd();
 
 
 				return true;
 				return true;
@@ -674,7 +662,7 @@ namespace BansheeEngine
 			return true;
 			return true;
 		}
 		}
 
 
-		if(ev.getType() == GUICommandEventType::CursorMoveLeft)
+		if(ev.getType() == GUICommandEventType::MoveLeft)
 		{
 		{
 			if(mSelectionShown)
 			if(mSelectionShown)
 			{
 			{
@@ -707,7 +695,7 @@ namespace BansheeEngine
 			return true;
 			return true;
 		}
 		}
 
 
-		if(ev.getType() == GUICommandEventType::CursorMoveRight)
+		if(ev.getType() == GUICommandEventType::MoveRight)
 		{
 		{
 			if(mSelectionShown)
 			if(mSelectionShown)
 			{
 			{
@@ -740,7 +728,7 @@ namespace BansheeEngine
 			return true;
 			return true;
 		}
 		}
 
 
-		if(ev.getType() == GUICommandEventType::CursorMoveUp)
+		if(ev.getType() == GUICommandEventType::MoveUp)
 		{
 		{
 			clearSelection();
 			clearSelection();
 
 
@@ -764,7 +752,7 @@ namespace BansheeEngine
 			return true;
 			return true;
 		}
 		}
 
 
-		if(ev.getType() == GUICommandEventType::CursorMoveDown)
+		if(ev.getType() == GUICommandEventType::MoveDown)
 		{
 		{
 			clearSelection();
 			clearSelection();
 
 

+ 51 - 10
BansheeEngine/Source/BsGUIManager.cpp

@@ -32,6 +32,7 @@
 #include "CmMeshHeap.h"
 #include "CmMeshHeap.h"
 #include "CmTransientMesh.h"
 #include "CmTransientMesh.h"
 #include "BsVirtualInput.h"
 #include "BsVirtualInput.h"
+#include "BsCursor.h"
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
 namespace BansheeEngine
 namespace BansheeEngine
@@ -65,7 +66,8 @@ namespace BansheeEngine
 	GUIManager::GUIManager()
 	GUIManager::GUIManager()
 		:mSeparateMeshesByWidget(true), mActiveMouseButton(GUIMouseButton::Left),
 		:mSeparateMeshesByWidget(true), mActiveMouseButton(GUIMouseButton::Left),
 		mCaretBlinkInterval(0.5f), mCaretLastBlinkTime(0.0f), mCaretColor(1.0f, 0.6588f, 0.0f), mIsCaretOn(false),
 		mCaretBlinkInterval(0.5f), mCaretLastBlinkTime(0.0f), mCaretColor(1.0f, 0.6588f, 0.0f), mIsCaretOn(false),
-		mTextSelectionColor(1.0f, 0.6588f, 0.0f), mInputCaret(nullptr), mInputSelection(nullptr), mDragState(DragState::NoDrag)
+		mTextSelectionColor(1.0f, 0.6588f, 0.0f), mInputCaret(nullptr), mInputSelection(nullptr), mDragState(DragState::NoDrag),
+		mActiveCursor(CursorType::Arrow)
 	{
 	{
 		mOnCursorMovedConn = gInput().onCursorMoved.connect(boost::bind(&GUIManager::onCursorMoved, this, _1));
 		mOnCursorMovedConn = gInput().onCursorMoved.connect(boost::bind(&GUIManager::onCursorMoved, this, _1));
 		mOnCursorPressedConn = gInput().onCursorPressed.connect(boost::bind(&GUIManager::onCursorPressed, this, _1));
 		mOnCursorPressedConn = gInput().onCursorPressed.connect(boost::bind(&GUIManager::onCursorPressed, this, _1));
@@ -705,17 +707,50 @@ namespace BansheeEngine
 		{
 		{
 			if(mLastCursorScreenPos != event.screenPos)
 			if(mLastCursorScreenPos != event.screenPos)
 			{
 			{
+				bool moveProcessed = false;
+				bool hasCustomCursor = false;
 				for(auto& elementInfo : mElementsUnderCursor)
 				for(auto& elementInfo : mElementsUnderCursor)
 				{
 				{
-					// Send MouseMove event
 					Vector2I localPos = getWidgetRelativePos(*elementInfo.widget, event.screenPos);
 					Vector2I localPos = getWidgetRelativePos(*elementInfo.widget, event.screenPos);
-					mMouseEvent.setMouseMoveData(localPos);
-					bool processed = sendMouseEvent(elementInfo.widget, elementInfo.element, mMouseEvent);
 
 
-					if(processed)
+					if(!moveProcessed)
 					{
 					{
-						event.markAsUsed();
+						// Send MouseMove event
+						mMouseEvent.setMouseMoveData(localPos);
+						moveProcessed = sendMouseEvent(elementInfo.widget, elementInfo.element, mMouseEvent);
+
+						if(moveProcessed)
+						{
+							event.markAsUsed();
+							break;
+						}
+					}
+
+					if(!hasCustomCursor)
+					{
+						CursorType newCursor = CursorType::Arrow;
+						if(elementInfo.element->_hasCustomCursor(localPos, newCursor))
+						{
+							if(newCursor != mActiveCursor)
+							{
+								Cursor::instance().setCursor(newCursor);
+								mActiveCursor = newCursor;
+							}
+
+							hasCustomCursor = true;
+						}
+					}
+
+					if(moveProcessed && hasCustomCursor)
 						break;
 						break;
+				}
+
+				if(!hasCustomCursor)
+				{
+					if(mActiveCursor != CursorType::Arrow)
+					{
+						Cursor::instance().setCursor(CursorType::Arrow);
+						mActiveCursor = CursorType::Arrow;
 					}
 					}
 				}
 				}
 			}
 			}
@@ -803,6 +838,12 @@ namespace BansheeEngine
 			mActiveElements.clear();
 			mActiveElements.clear();
 			mActiveMouseButton = GUIMouseButton::Left;
 			mActiveMouseButton = GUIMouseButton::Left;
 		}
 		}
+
+		if(mActiveCursor != CursorType::Arrow)
+		{
+			Cursor::instance().setCursor(CursorType::Arrow);
+			mActiveCursor = CursorType::Arrow;
+		}
 	}
 	}
 
 
 	void GUIManager::onCursorPressed(const CM::PositionalInputEvent& event)
 	void GUIManager::onCursorPressed(const CM::PositionalInputEvent& event)
@@ -964,16 +1005,16 @@ namespace BansheeEngine
 			mCommandEvent.setType(GUICommandEventType::Escape);
 			mCommandEvent.setType(GUICommandEventType::Escape);
 			break;
 			break;
 		case InputCommandType::CursorMoveLeft:
 		case InputCommandType::CursorMoveLeft:
-			mCommandEvent.setType(GUICommandEventType::CursorMoveLeft);
+			mCommandEvent.setType(GUICommandEventType::MoveLeft);
 			break;
 			break;
 		case InputCommandType::CursorMoveRight:
 		case InputCommandType::CursorMoveRight:
-			mCommandEvent.setType(GUICommandEventType::CursorMoveRight);
+			mCommandEvent.setType(GUICommandEventType::MoveRight);
 			break;
 			break;
 		case InputCommandType::CursorMoveUp:
 		case InputCommandType::CursorMoveUp:
-			mCommandEvent.setType(GUICommandEventType::CursorMoveUp);
+			mCommandEvent.setType(GUICommandEventType::MoveUp);
 			break;
 			break;
 		case InputCommandType::CursorMoveDown:
 		case InputCommandType::CursorMoveDown:
-			mCommandEvent.setType(GUICommandEventType::CursorMoveDown);
+			mCommandEvent.setType(GUICommandEventType::MoveDown);
 			break;
 			break;
 		case InputCommandType::SelectLeft:
 		case InputCommandType::SelectLeft:
 			mCommandEvent.setType(GUICommandEventType::SelectLeft);
 			mCommandEvent.setType(GUICommandEventType::SelectLeft);