Browse Source

Drag and droping a window with a scroll area no longer causes an exception because scroll area children didn't have their parent switched
Drag'n'drop operation now properly ends once mouse is released

Marko Pintera 12 years ago
parent
commit
c114926009

+ 2 - 0
BansheeEngine/Include/BsGUIScrollArea.h

@@ -74,5 +74,7 @@ namespace BansheeEngine
 		void horzScrollUpdate(float pct);
 		void _updateLayoutInternal(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height,
 			CM::Rect clipRect, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
+
+		virtual void _changeParentWidget(GUIWidget* widget);
 	};
 }

+ 5 - 0
BansheeEngine/Source/BsDragAndDropManager.cpp

@@ -23,5 +23,10 @@ namespace BansheeEngine
 	{
 		if(mDropCallback != nullptr)
 			mDropCallback(processed);
+
+		mDragTypeId = 0;
+		mData = nullptr;
+		mDropCallback = nullptr;
+		mIsDragInProgress = false;
 	}
 }

+ 13 - 0
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -246,6 +246,19 @@ namespace BansheeEngine
 		return false;
 	}
 
+	void GUIScrollArea::_changeParentWidget(GUIWidget* widget)
+	{
+		GUIElement::_changeParentWidget(widget);
+
+		// These two elements are not part of a layout so I need to make sure to
+		// update them manually
+		if(mVertScroll != nullptr)
+			mVertScroll->_changeParentWidget(widget);
+
+		if(mHorzScroll != nullptr)
+			mHorzScroll->_changeParentWidget(widget);
+	}
+
 	GUIScrollArea* GUIScrollArea::create(GUIWidget& parent, const GUIElementStyle* style)
 	{
 		if(style == nullptr)

+ 1 - 1
CamelotClient/Source/BsEditorWidgetContainer.cpp

@@ -187,7 +187,7 @@ namespace BansheeEditor
 
 	void EditorWidgetContainer::tabDroppedCallback(bool wasDragProcessed)
 	{
-		if(!wasDragProcessed)
+		if(!wasDragProcessed && DragAndDropManager::instance().getDragTypeId() == (UINT32)DragAndDropType::EditorWidget)
 		{
 			EditorWindow* newWindow = EditorWindow::create();