Procházet zdrojové kódy

Fixed dock manager highlight detection

Marko Pintera před 12 roky
rodič
revize
0d5bcab0d0

+ 8 - 11
BansheeEngine/Source/BsGUIManager.cpp

@@ -631,17 +631,6 @@ namespace BansheeEngine
 
 				mLastCursorLocalPos = curLocalPos;
 			}
-
-			// Also if drag is in progress send DragAndDrop events
-			if(DragAndDropManager::instance().isDragInProgress())
-			{
-				if(mElementUnderCursor != nullptr)
-				{
-					mMouseEvent.setDragAndDropDraggedData(mElementUnderCursor, localPos, DragAndDropManager::instance().getDragTypeId(), DragAndDropManager::instance().getDragData());
-					if(sendMouseEvent(mWidgetUnderCursor, mElementUnderCursor, mMouseEvent))
-						event.markAsUsed();
-				}
-			}
 		}
 		else // Otherwise, send MouseMove events if we are hovering over any element
 		{
@@ -657,6 +646,14 @@ namespace BansheeEngine
 					mLastCursorLocalPos = localPos;
 				}
 
+				// Also if drag is in progress send DragAndDrop events
+				if(DragAndDropManager::instance().isDragInProgress())
+				{
+					mMouseEvent.setDragAndDropDraggedData(mElementUnderCursor, localPos, DragAndDropManager::instance().getDragTypeId(), DragAndDropManager::instance().getDragData());
+					if(sendMouseEvent(mWidgetUnderCursor, mElementUnderCursor, mMouseEvent))
+						event.markAsUsed();
+				}
+
 				if(Math::abs(event.mouseWheelScrollAmount) > 0.00001f)
 				{
 					mMouseEvent.setMouseWheelScrollData(mElementUnderCursor, event.mouseWheelScrollAmount);

+ 5 - 0
CamelotClient/Include/BsDockManager.h

@@ -61,6 +61,11 @@ namespace BansheeEditor
 		DockManager(BS::GUIWidget* parent, CM::RenderWindow* parentWindow);
 		~DockManager();
 
+		/**
+		 * @brief	Internal method. Called once every frame.
+		 */
+		void update();
+
 		void render(const CM::Viewport* viewport, CM::RenderQueue& renderQueue);
 		void insert(EditorWidgetContainer* relativeTo, EditorWidget* widgetToInsert, DockLocation location);
 

+ 46 - 37
CamelotClient/Source/BsDockManager.cpp

@@ -14,6 +14,7 @@
 #include "BsBuiltinMaterialManager.h"
 #include "BsGUIWidget.h"
 #include "BsCamera.h"
+#include "BsDragAndDropManager.h"
 #include "CmVertexDataDesc.h"
 
 using namespace CamelotFramework;
@@ -208,6 +209,12 @@ namespace BansheeEditor
 		cm_deleteN(mRightDropPolygon, 4);
 	}
 
+	void DockManager::update()
+	{
+		if(!DragAndDropManager::instance().isDragInProgress())
+			mHighlightedDropLoc = DockLocation::None;
+	}
+
 	void DockManager::render(const Viewport* viewport, CM::RenderQueue& renderQueue)
 	{
 		float invViewportWidth = 1.0f / (viewport->getWidth() * 0.5f);
@@ -445,63 +452,65 @@ namespace BansheeEditor
 
 	void DockManager::onGUIMouseEvent(GUIWidget* widget, GUIElement* element, const GUIMouseEvent& event)
 	{
-		if(event.getType() != GUIMouseEventType::MouseMove) // TODO - Replace with DragAndDrop event
-			return;
-
 		if(widget->getTarget() != mParent->getTarget())
 			return;
 
-		const Vector2I& widgetRelPos = event.getPosition();
-
-		const Matrix4& worldTfrm = widget->SO()->getWorldTfrm();
-
-		Vector4 tfrmdPos = worldTfrm.multiply3x4(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
-		Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
-		Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
+		if(event.getType() == GUIMouseEventType::MouseDragAndDropDragged)
+		{
+			const Vector2I& widgetRelPos = event.getPosition();
 
-		DockContainer* mouseOverContainer = mRootContainer.findAtPos(windowPos);
+			const Matrix4& worldTfrm = widget->SO()->getWorldTfrm();
 
+			Vector4 tfrmdPos = worldTfrm.multiply3x4(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
+			Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
+			Vector2I windowPos(Math::roundToInt(windowPosVec.x), Math::roundToInt(windowPosVec.y));
 
+			DockContainer* mouseOverContainer = mRootContainer.findAtPos(windowPos);
 
 
 
-		// DEBUG ONLY
-		mouseOverContainer = &mRootContainer;
-		// END DEBUG ONLY
+			// DEBUG ONLY
+			mouseOverContainer = &mRootContainer;
+			// END DEBUG ONLY
 
 
 
 
 
 
-		// Check if we need to highlight any drop locations
-		if(mouseOverContainer)
-		{
-			if(insidePolygon(mTopDropPolygon, 4, windowPosVec))
-				mHighlightedDropLoc = DockLocation::Top;
-			else if(insidePolygon(mBotDropPolygon, 4, windowPosVec))
-				mHighlightedDropLoc = DockLocation::Bottom;
-			else if(insidePolygon(mLeftDropPolygon, 4, windowPosVec))
-				mHighlightedDropLoc = DockLocation::Left;
-			else if(insidePolygon(mRightDropPolygon, 4, windowPosVec))
-				mHighlightedDropLoc = DockLocation::Right;
-			else
-				mHighlightedDropLoc = DockLocation::None;
-		}
+			// Check if we need to highlight any drop locations
+			if(mouseOverContainer)
+			{
+				if(insidePolygon(mTopDropPolygon, 4, windowPosVec))
+					mHighlightedDropLoc = DockLocation::Top;
+				else if(insidePolygon(mBotDropPolygon, 4, windowPosVec))
+					mHighlightedDropLoc = DockLocation::Bottom;
+				else if(insidePolygon(mLeftDropPolygon, 4, windowPosVec))
+					mHighlightedDropLoc = DockLocation::Left;
+				else if(insidePolygon(mRightDropPolygon, 4, windowPosVec))
+					mHighlightedDropLoc = DockLocation::Right;
+				else
+					mHighlightedDropLoc = DockLocation::None;
+			}
 
-		// Update mesh if needed
-		if(mouseOverContainer == mMouseOverContainer)
-			return;
+			// Update mesh if needed
+			if(mouseOverContainer == mMouseOverContainer)
+				return;
 
-		mMouseOverContainer = mouseOverContainer;
+			mMouseOverContainer = mouseOverContainer;
 
-		if(mMouseOverContainer == nullptr)
-		{
-			mDropOverlayMesh = HMesh();
+			if(mMouseOverContainer == nullptr)
+			{
+				mDropOverlayMesh = HMesh();
+			}
+			else
+			{
+				updateDropOverlay(mMouseOverContainer->mX, mMouseOverContainer->mY, mMouseOverContainer->mWidth, mMouseOverContainer->mHeight);
+			}
 		}
-		else
+		else if(event.getType() == GUIMouseEventType::MouseDragAndDropDropped)
 		{
-			updateDropOverlay(mMouseOverContainer->mX, mMouseOverContainer->mY, mMouseOverContainer->mWidth, mMouseOverContainer->mHeight);
+			int a = 5; // TODO
 		}
 	}
 

+ 1 - 0
CamelotClient/Source/BsMainEditorWindow.cpp

@@ -117,6 +117,7 @@ namespace BansheeEditor
 
 	void MainEditorWindow::update()
 	{
+		mDockManager->update();
 		PROFILE_CALL(ProfilerOverlay::instance().update(), "ProfilerOverlay");
 	}
 }

+ 0 - 9
EditorWindowDock.txt

@@ -6,20 +6,11 @@ Initial:
  - Dragging another editor window over the window shows the drop overlay and you can dock that window onto any side
    - Currently the overlay is always shown and will trigger on mouse move and not only mouse drag
 
-Undock:
- - Dragging on a title of a docked window undocks it
-
 Resize sliders
  - Add a button between docked windows
  - Allow the button to be dragged, and it will automatically resize separating widgets
 
-TitleBar dock/undock move
- - Dragging a title bar will move the title bar button while the cursor is within the widget area
-   - If there are other title bars this will allow you to reposition the title bar
-   - If cursor leaves the title bar (or widget area?) close the window and start actual drag and drop operation
-
 TitleBar dock/undock 
- - Releasing the dragged window anywhere not on editor will re-open the window at that location
  - Releasing the dragged window over the drop overlay will dock the window
  - Moving the dragged window over a title bar will temporarily dock the title bar and allow you to move it (as in first step)
    - If you release the mouse the window will then be permanently docked at that location