Browse Source

Fixed an issue where docked widget containers with a titlebar would overwrite the main window non client move areas

Marko Pintera 11 years ago
parent
commit
53a15ba994

+ 1 - 0
BansheeEditor/Include/BsEditorWidgetContainer.h

@@ -25,6 +25,7 @@ namespace BansheeEditor
 		EditorWindow* getParentWindow() const { return mParentWindow; }
 		EditorWindow* getParentWindow() const { return mParentWindow; }
 
 
 		CM::RectI getContentBounds() const;
 		CM::RectI getContentBounds() const;
+		CM::Vector<CM::RectI>::type getDraggableAreas() const;
 
 
 		void _notifyWidgetDestroyed(EditorWidgetBase* widget);
 		void _notifyWidgetDestroyed(EditorWidgetBase* widget);
 
 

+ 2 - 0
BansheeEditor/Include/BsGUITabbedTitleBar.h

@@ -28,6 +28,8 @@ namespace BansheeEditor
 		CM::UINT32 getTabIdx(CM::UINT32 position) const;
 		CM::UINT32 getTabIdx(CM::UINT32 position) const;
 		CM::UINT32 getNumTabs() const { return (CM::UINT32)mTabButtons.size(); }
 		CM::UINT32 getNumTabs() const { return (CM::UINT32)mTabButtons.size(); }
 
 
+		CM::Vector<CM::RectI>::type calcDraggableAreas(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height) const;
+
 		boost::signal<void(CM::UINT32)> onTabActivated;
 		boost::signal<void(CM::UINT32)> onTabActivated;
 		boost::signal<void(CM::UINT32)> onTabClosed;
 		boost::signal<void(CM::UINT32)> onTabClosed;
 		boost::signal<void(CM::UINT32)> onTabDraggedOff;
 		boost::signal<void(CM::UINT32)> onTabDraggedOff;

+ 28 - 24
BansheeEditor/Source/BsEditorApplication.cpp

@@ -266,37 +266,41 @@ namespace BansheeEditor
 		gMainSyncedCA().readSubresource(dbgCursor.getInternalPtr(), 0, cursorPixelData);
 		gMainSyncedCA().readSubresource(dbgCursor.getInternalPtr(), 0, cursorPixelData);
 		gMainSyncedCA().submitToCoreThread(true);
 		gMainSyncedCA().submitToCoreThread(true);
 
 
-		RENDER_WINDOW_DESC modalWindowDesc;
-		modalWindowDesc.width = 200;
-		modalWindowDesc.height = 200;
-		modalWindowDesc.left = 0;
-		modalWindowDesc.top = 0;
-		modalWindowDesc.title = "ModalWindow";
-		modalWindowDesc.fullscreen = false;
-		modalWindowDesc.border = WindowBorder::None;
-		modalWindowDesc.toolWindow = true;
-		modalWindowDesc.modal = true;
+		/************************************************************************/
+		/* 								MODAL WINDOW                      		*/
+		/************************************************************************/
+
+		//RENDER_WINDOW_DESC modalWindowDesc;
+		//modalWindowDesc.width = 200;
+		//modalWindowDesc.height = 200;
+		//modalWindowDesc.left = 0;
+		//modalWindowDesc.top = 0;
+		//modalWindowDesc.title = "ModalWindow";
+		//modalWindowDesc.fullscreen = false;
+		//modalWindowDesc.border = WindowBorder::None;
+		//modalWindowDesc.toolWindow = true;
+		//modalWindowDesc.modal = true;
 
 
-		RenderWindowPtr modalWindow = RenderWindow::create(modalWindowDesc, gApplication().getPrimaryWindow());
+		//RenderWindowPtr modalWindow = RenderWindow::create(modalWindowDesc, gApplication().getPrimaryWindow());
 
 
-		HSceneObject modalSceneObject = SceneObject::create("ModalWindow");
+		//HSceneObject modalSceneObject = SceneObject::create("ModalWindow");
 
 
-		HCamera modalCamera = modalSceneObject->addComponent<Camera>();
-		modalCamera->initialize(modalWindow, 0.0f, 0.0f, 1.0f, 1.0f);
-		modalCamera->setNearClipDistance(5);
-		modalCamera->setAspectRatio(1.0f);
-		modalCamera->setIgnoreSceneRenderables(true);
+		//HCamera modalCamera = modalSceneObject->addComponent<Camera>();
+		//modalCamera->initialize(modalWindow, 0.0f, 0.0f, 1.0f, 1.0f);
+		//modalCamera->setNearClipDistance(5);
+		//modalCamera->setAspectRatio(1.0f);
+		//modalCamera->setIgnoreSceneRenderables(true);
 
 
-		HGUIWidget modalGUI = modalSceneObject->addComponent<GUIWidget>(modalCamera->getViewport().get());
-		modalGUI->setDepth(128);
+		//HGUIWidget modalGUI = modalSceneObject->addComponent<GUIWidget>(modalCamera->getViewport().get());
+		//modalGUI->setDepth(128);
 
 
-		modalGUI->setSkin(EditorGUI::instance().getSkin());
+		//modalGUI->setSkin(EditorGUI::instance().getSkin());
 
 
-		GUIArea* modalArea = GUIArea::createStretchedXY(*modalGUI, 0, 0, 0, 0, 500);
-		GUIButton* modalButton = GUIButton::create(*modalGUI, HString(L"Close"));
-		modalButton->onClick.connect(boost::bind(&EditorApplication::closeModalWindow, modalWindow, modalSceneObject));
+		//GUIArea* modalArea = GUIArea::createStretchedXY(*modalGUI, 0, 0, 0, 0, 500);
+		//GUIButton* modalButton = GUIButton::create(*modalGUI, HString(L"Close"));
+		//modalButton->onClick.connect(boost::bind(&EditorApplication::closeModalWindow, modalWindow, modalSceneObject));
 
 
-		modalArea->getLayout().addElement(modalButton);
+		//modalArea->getLayout().addElement(modalButton);
 
 
 
 
 		/************************************************************************/
 		/************************************************************************/

+ 5 - 0
BansheeEditor/Source/BsEditorWidgetContainer.cpp

@@ -245,6 +245,11 @@ namespace BansheeEditor
 		return RectI(mX, mY + TitleBarHeight, mWidth, (UINT32)std::max(0, (INT32)mHeight - (INT32)TitleBarHeight));
 		return RectI(mX, mY + TitleBarHeight, mWidth, (UINT32)std::max(0, (INT32)mHeight - (INT32)TitleBarHeight));
 	}
 	}
 
 
+	Vector<RectI>::type EditorWidgetContainer::getDraggableAreas() const
+	{
+		return mTitleBar->calcDraggableAreas(mX, mY, mWidth, TitleBarHeight);
+	}
+
 	void EditorWidgetContainer::_notifyWidgetDestroyed(EditorWidgetBase* widget)
 	void EditorWidgetContainer::_notifyWidgetDestroyed(EditorWidgetBase* widget)
 	{
 	{
 		for(auto& curWidget : mWidgets)
 		for(auto& curWidget : mWidgets)

+ 2 - 0
BansheeEditor/Source/BsEditorWindow.cpp

@@ -36,6 +36,8 @@ namespace BansheeEditor
 		UINT32 widgetHeight = (UINT32)std::max(0, (INT32)getHeight() - 2);
 		UINT32 widgetHeight = (UINT32)std::max(0, (INT32)getHeight() - 2);
 
 
 		mWidgets->setSize(widgetWidth, widgetHeight);
 		mWidgets->setSize(widgetWidth, widgetHeight);
+
+		Platform::setCaptionNonClientAreas(*mRenderWindow.get(), mWidgets->getDraggableAreas());
 	}
 	}
 
 
 	void EditorWindow::widgetRemoved()
 	void EditorWindow::widgetRemoved()

+ 27 - 6
BansheeEditor/Source/BsGUITabbedTitleBar.cpp

@@ -248,7 +248,6 @@ namespace BansheeEditor
 		RectI tabClipRect = clipRect;
 		RectI tabClipRect = clipRect;
 		tabClipRect.width -= endButtonWidth;
 		tabClipRect.width -= endButtonWidth;
 
 
-		CM::Vector<CM::RectI>::type nonClientAreas;
 		{
 		{
 			Vector2I optimalSize = mBackgroundImage->_getOptimalSize();
 			Vector2I optimalSize = mBackgroundImage->_getOptimalSize();
 			Vector2I offset(x + 1, y + 1);
 			Vector2I offset(x + 1, y + 1);
@@ -271,7 +270,6 @@ namespace BansheeEditor
 			Vector2I optimalSize = btn->_getOptimalSize();
 			Vector2I optimalSize = btn->_getOptimalSize();
 
 
 			tabBtnHeight = optimalSize.y;
 			tabBtnHeight = optimalSize.y;
-			nonClientAreas.push_back(RectI(curX, curY, TAB_SPACING, tabBtnHeight));
 			curX += TAB_SPACING;
 			curX += TAB_SPACING;
 
 
 			Vector2I offset;
 			Vector2I offset;
@@ -297,9 +295,6 @@ namespace BansheeEditor
 			curX += optimalSize.x;
 			curX += optimalSize.x;
 		}
 		}
 
 
-		UINT32 remainingWidth = (UINT32)std::max(0, (INT32)(width - curX - endButtonWidth - 1));
-		nonClientAreas.push_back(RectI(curX, curY, remainingWidth, tabBtnHeight));
-
 		INT32 optionBtnXPos = x + width - endButtonWidth - 1;
 		INT32 optionBtnXPos = x + width - endButtonWidth - 1;
 		{
 		{
 			INT32 optionBtnYPos = curY + Math::floorToInt((tabBtnHeight - minBtnOptimalSize.y) * 0.5f);
 			INT32 optionBtnYPos = curY + Math::floorToInt((tabBtnHeight - minBtnOptimalSize.y) * 0.5f);
@@ -329,8 +324,34 @@ namespace BansheeEditor
 			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			mCloseBtn->_setClipRect(elemClipRect);
 			mCloseBtn->_setClipRect(elemClipRect);
 		}
 		}
+	}
+
+	Vector<RectI>::type GUITabbedTitleBar::calcDraggableAreas(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height) const
+	{
+		CM::Vector<CM::RectI>::type draggableAreas;
+
+		UINT32 curX = x + 1;
+		UINT32 curY = y;
+		for(UINT32 i = 0; i < (UINT32)mTabButtons.size(); i++)
+		{
+			GUITabButton* btn = mTabButtons[i];
+			Vector2I optimalSize = btn->_getOptimalSize();
+
+			draggableAreas.push_back(RectI(curX, curY, TAB_SPACING, height));
+
+			curX += TAB_SPACING + optimalSize.x;
+		}
+
+		Vector2I minBtnOptimalSize = mMinBtn->_getOptimalSize();
+		Vector2I closeBtnOptimalSize = mCloseBtn->_getOptimalSize();
+
+		UINT32 endButtonWidth = minBtnOptimalSize.x + closeBtnOptimalSize.x + OPTION_BTN_SPACING;
+		UINT32 remainingWidth = (UINT32)std::max(0, (INT32)(width - curX - endButtonWidth - 1));
+
+		if(remainingWidth > 0)
+			draggableAreas.push_back(RectI(curX, curY, remainingWidth, height));
 
 
-		Platform::setCaptionNonClientAreas(*mParentWindow, nonClientAreas);
+		return draggableAreas;
 	}
 	}
 
 
 	void GUITabbedTitleBar::tabToggled(CM::UINT32 tabIdx, bool toggledOn)
 	void GUITabbedTitleBar::tabToggled(CM::UINT32 tabIdx, bool toggledOn)