Browse Source

Tabbed title bar is now draggable again
Dock overlay only appears over content area and not entire widget container

Marko Pintera 12 years ago
parent
commit
1125f26ea8

+ 3 - 0
CamelotClient/Include/BsDockManager.h

@@ -38,6 +38,8 @@ namespace BansheeEditor
 			 */
 			DockContainer* findAtPos(const CM::Vector2I& pos);
 
+			CM::RectI getContentBounds() const;
+
 			bool mIsLeaf;
 			DockContainer* mChildren[2];
 			DockContainer* mParent;
@@ -85,6 +87,7 @@ namespace BansheeEditor
 
 		CM::HMesh mDropOverlayMesh;
 		CM::HMaterial mDropOverlayMat;
+		CM::RectI mLastOverlayBounds;
 
 		DockContainer* mMouseOverContainer;
 		DockLocation mHighlightedDropLoc;

+ 2 - 0
CamelotClient/Include/BsEditorWidgetContainer.h

@@ -21,6 +21,8 @@ namespace BansheeEditor
 		CM::UINT32 getNumWidgets() const { return (CM::UINT32)mWidgets.size(); }
 		BS::GUIWidget& getParentWidget() const { return *mParent; }
 
+		CM::RectI getContentBounds() const;
+
 		void _notifyWidgetDestroyed(EditorWidget* widget);
 		bool _isHandlingWidgetDragAndDrop() const { return mIsHandlingWidgetDragAndDrop; }
 		void _addCallbackOnDraggedWidgetDropped(std::function<void()> callback);

+ 26 - 15
CamelotClient/Source/BsDockManager.cpp

@@ -244,6 +244,14 @@ namespace BansheeEditor
 		return nullptr;
 	}
 
+	RectI DockManager::DockContainer::getContentBounds() const
+	{
+		if(!mIsLeaf)
+			return mArea;
+
+		return mWidgets->getContentBounds();
+	}
+
 	DockManager::DockManager(BS::GUIWidget* parent, CM::RenderWindow* parentWindow)
 		:mParent(parent), mParentWindow(parentWindow), mMouseOverContainer(nullptr), mHighlightedDropLoc(DockLocation::None),
 		mShowOverlay(false)
@@ -533,27 +541,28 @@ namespace BansheeEditor
 			Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
 			Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
 
-			DockContainer* mouseOverContainer = mRootContainer.findAtPos(windowPos);
-			if(mouseOverContainer == nullptr)
-				mouseOverContainer = &mRootContainer;
+			mMouseOverContainer = mRootContainer.findAtPos(windowPos);
+			if(mMouseOverContainer == nullptr)
+				mMouseOverContainer = &mRootContainer;
+
+			RectI overlayBounds;
+			
+			if(mMouseOverContainer != nullptr)
+				overlayBounds = mMouseOverContainer->getContentBounds();
 
 			// Update mesh if needed
-			if(mouseOverContainer != mMouseOverContainer)
+			if(mLastOverlayBounds != overlayBounds)
 			{
-				mMouseOverContainer = mouseOverContainer;
-
-				if(mMouseOverContainer == nullptr)
-				{
+				if(overlayBounds.width <= 0 || overlayBounds.height <= 0)
 					mDropOverlayMesh = HMesh();
-				}
 				else
-				{
-					updateDropOverlay(mMouseOverContainer->mArea.x, mMouseOverContainer->mArea.y, mMouseOverContainer->mArea.width, mMouseOverContainer->mArea.height);
-				}
+					updateDropOverlay(overlayBounds.x, overlayBounds.y, overlayBounds.width, overlayBounds.height);
+
+				mLastOverlayBounds = overlayBounds;
 			}
 
 			// Check if we need to highlight any drop locations
-			if(mouseOverContainer)
+			if(mMouseOverContainer != nullptr)
 			{
 				if(insidePolygon(mTopDropPolygon, 4, windowPosVec))
 					mHighlightedDropLoc = DockLocation::Top;
@@ -566,7 +575,7 @@ namespace BansheeEditor
 				else
 					mHighlightedDropLoc = DockLocation::None;
 
-				if(mouseOverContainer->mArea.contains(windowPos))
+				if(overlayBounds.contains(windowPos))
 					mShowOverlay = true;
 				else
 					mShowOverlay = false;
@@ -591,9 +600,11 @@ namespace BansheeEditor
 			Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
 
 			DockContainer* mouseOverContainer = mRootContainer.findAtPos(windowPos);
+
 			if(mouseOverContainer == nullptr)
 			{
-				if(mRootContainer.mArea.contains(windowPos))
+				RectI overlayBounds = mRootContainer.getContentBounds();
+				if(overlayBounds.contains(windowPos))
 				{
 					insert(nullptr, draggedWidget, DockLocation::None);
 				}

+ 5 - 0
CamelotClient/Source/BsEditorWidgetContainer.cpp

@@ -240,6 +240,11 @@ namespace BansheeEditor
 		}
 	}
 
+	RectI EditorWidgetContainer::getContentBounds() const
+	{
+		return RectI(mX, mY + TitleBarHeight, mWidth, (UINT32)std::max(0, (INT32)mHeight - (INT32)TitleBarHeight));
+	}
+
 	void EditorWidgetContainer::_notifyWidgetDestroyed(EditorWidget* widget)
 	{
 		for(auto& curWidget : mWidgets)

+ 1 - 4
CamelotClient/Source/BsGUITabbedTitleBar.cpp

@@ -193,9 +193,6 @@ namespace BansheeEditor
 			curX += TAB_SPACING;
 
 			Vector2I offset(curX, curY);
-			if(mDragInProgress && btn == mDraggedBtn)
-				offset.x = mDragBtnOffset;
-			
 			btn->_setOffset(offset);
 			btn->_setWidth(optimalSize.x);
 			btn->_setHeight(optimalSize.y);
@@ -293,7 +290,7 @@ namespace BansheeEditor
 					mDragInProgress = true;
 				}
 
-				mDragBtnOffset = dragPos.x - bounds.x - mInitialDragOffset;
+				mDragBtnOffset = dragPos.x - mInitialDragOffset;
 				
 				Vector2I offset = mDraggedBtn->_getOffset();
 				INT32 diff = mDragBtnOffset - offset.x;

+ 2 - 1
EditorWindowDock.txt

@@ -1,5 +1,6 @@
 TODO:
- - Dock manager doesn't work as intended when I drag two windows onto it
+ - Docking/Undocking elements will cause an exception. Happened after TabbedTitleBar refactor
+ - When I dock two windows (maybe even just one?) and drag the title bar, layout seems to get messed up
  - Ensure that dragging items onto the title bar works
 
 Resize sliders