Răsfoiți Sursa

Dragging a tabbed title bar will move it after/before other title bars if needed

Marko Pintera 12 ani în urmă
părinte
comite
36ff8caa82
1 a modificat fișierele cu 29 adăugiri și 1 ștergeri
  1. 29 1
      CamelotClient/Source/BsGUITabbedTitleBar.cpp

+ 29 - 1
CamelotClient/Source/BsGUITabbedTitleBar.cpp

@@ -236,7 +236,35 @@ namespace BansheeEditor
 
 				mDragInProgress = true;
 
-				// TODO - If position overlaps another button permanently move the tab
+				for(UINT32 i = 0; i < idx; i++)
+				{
+					UINT32 width = mTabButtons[i]->_getWidth();
+					INT32 centerX = mTabButtons[i]->_getOffset().x + width / 2;
+
+					if(dragPos.x < centerX)
+					{
+						GUITabButton* temp = mTabButtons[i];
+						mTabButtons[i] = mTabButtons[idx];
+						mTabButtons[idx] = temp;
+
+						break;
+					}
+				}
+
+				for(UINT32 i = idx + 1; i < (UINT32)mTabButtons.size(); i++)
+				{
+					UINT32 width = mTabButtons[i]->_getWidth();
+					INT32 centerX = mTabButtons[i]->_getOffset().x + width / 2;
+
+					if(dragPos.x > centerX)
+					{
+						GUITabButton* temp = mTabButtons[i];
+						mTabButtons[i] = mTabButtons[idx];
+						mTabButtons[idx] = temp;
+
+						break;
+					}
+				}
 			}
 			else
 			{