Просмотр исходного кода

Various improvements to the TitleBar and couple of GUI bug fixes

Marko Pintera 12 лет назад
Родитель
Сommit
cc40ddef9b

+ 2 - 1
BansheeEngine.sln

@@ -284,7 +284,8 @@ Global
 		{07B0C186-5173-46F2-BE26-7E4148BD0CCA}.Release|Mixed Platforms.Build.0 = Release|Win32
 		{07B0C186-5173-46F2-BE26-7E4148BD0CCA}.Release|Win32.ActiveCfg = Release|Win32
 		{07B0C186-5173-46F2-BE26-7E4148BD0CCA}.Release|Win32.Build.0 = Release|Win32
-		{07B0C186-5173-46F2-BE26-7E4148BD0CCA}.Release|x64.ActiveCfg = Release|Win32
+		{07B0C186-5173-46F2-BE26-7E4148BD0CCA}.Release|x64.ActiveCfg = Release|x64
+		{07B0C186-5173-46F2-BE26-7E4148BD0CCA}.Release|x64.Build.0 = Release|x64
 		{08975177-4A13-4EE7-BB21-3BB92FB3F3CC}.Debug|Any CPU.ActiveCfg = Debug|Win32
 		{08975177-4A13-4EE7-BB21-3BB92FB3F3CC}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
 		{08975177-4A13-4EE7-BB21-3BB92FB3F3CC}.Debug|Mixed Platforms.Build.0 = Debug|Win32

+ 1 - 1
BansheeEngine/Include/BsGUILayout.h

@@ -95,6 +95,7 @@ namespace BansheeEngine
 		void _markAsDirty() { mIsDirty = true; }
 		bool _isDirty();
 
+		virtual void _updateOptimalSizes() = 0;
 	protected:
 		CM::vector<GUILayoutEntry>::type mChildren;	
 		CM::vector<CM::Int2>::type mOptimalSizes;
@@ -103,7 +104,6 @@ namespace BansheeEngine
 
 		bool mIsDirty;
 
-		virtual void updateOptimalSizes() = 0;
 		virtual void updateInternal(CM::UINT32 x, CM::UINT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT8 widgetDepth, CM::UINT16 areaDepth) = 0;
 	};
 }

+ 1 - 1
BansheeEngine/Include/BsGUILayoutX.h

@@ -11,8 +11,8 @@ namespace BansheeEngine
 		GUILayoutX() {};
 		~GUILayoutX() {};
 
+		void _updateOptimalSizes();
 	protected:
-		void updateOptimalSizes();
 		void updateInternal(CM::UINT32 x, CM::UINT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
 	};
 }

+ 1 - 1
BansheeEngine/Include/BsGUILayoutY.h

@@ -11,8 +11,8 @@ namespace BansheeEngine
 		GUILayoutY() {};
 		~GUILayoutY() {};
 
+		void _updateOptimalSizes();
 	protected:
-		void updateOptimalSizes();
 		void updateInternal(CM::UINT32 x, CM::UINT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
 	};
 }

+ 1 - 1
BansheeEngine/Include/BsGUIWidget.h

@@ -26,7 +26,7 @@ namespace BansheeEngine
 		const GUISkin* getSkin() const;
 
 		CM::UINT8 getDepth() const { return mDepth; }
-		void setDepth(CM::UINT8 depth) { mDepth = depth; }
+		void setDepth(CM::UINT8 depth) { mDepth = depth; mWidgetIsDirty = true; }
 
 		bool inBounds(const CM::Int2& position) const;
 

+ 3 - 1
BansheeEngine/Source/BsEngineGUI.cpp

@@ -142,6 +142,8 @@ namespace BansheeEngine
 		tabbedBarButton.activeOn.texture = tabbedBarButton.hover.texture;
 		tabbedBarButton.fixedHeight = true;
 		tabbedBarButton.height = 13;
+		tabbedBarButton.minWidth = 10;
+		tabbedBarButton.maxWidth = 110;
 		tabbedBarButton.font = font;
 		tabbedBarButton.fontSize = DefaultFontSize;
 		tabbedBarButton.textHorzAlign = THA_Center;
@@ -154,7 +156,7 @@ namespace BansheeEngine
 		tabbedBarDropButton.fixedHeight = true;
 		tabbedBarDropButton.fixedWidth = true;
 		tabbedBarDropButton.height = 13;
-		tabbedBarDropButton.width = 15;
+		tabbedBarDropButton.width = 6;
 
 		mSkin.setStyle("TabbedBarDropArea", tabbedBarDropButton);
 

+ 2 - 2
BansheeEngine/Source/BsGUIElement.cpp

@@ -51,13 +51,13 @@ namespace BansheeEngine
 
 	void GUIElement::_setWidgetDepth(UINT8 depth) 
 	{ 
-		mDepth |= 24 << depth; 
+		mDepth |= depth << 24; 
 		markAsDirty();
 	}
 
 	void GUIElement::_setAreaDepth(UINT16 depth) 
 	{ 
-		mDepth |= 8 << depth; 
+		mDepth |= depth << 8; 
 		markAsDirty();
 	}
 

+ 1 - 1
BansheeEngine/Source/BsGUILayout.cpp

@@ -261,7 +261,7 @@ namespace BansheeEngine
 
 	void GUILayout::_update(UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT8 widgetDepth, UINT16 areaDepth)
 	{
-		updateOptimalSizes(); // We calculate optimal sizes of all layouts as a pre-processing step, as they are requested often during update
+		_updateOptimalSizes(); // We calculate optimal sizes of all layouts as a pre-processing step, as they are requested often during update
 		updateInternal(x, y, width, height, widgetDepth, areaDepth);
 		mIsDirty = false;
 	}

+ 4 - 4
BansheeEngine/Source/BsGUILayoutX.cpp

@@ -8,13 +8,13 @@ using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	void GUILayoutX::updateOptimalSizes()
+	void GUILayoutX::_updateOptimalSizes()
 	{
 		// Update all children first, otherwise we can't determine out own optimal size
 		for(auto& child : mChildren)
 		{
 			if(child.isLayout())
-				updateOptimalSizes();
+				child.layout->_updateOptimalSizes();
 		}
 
 		if(mChildren.size() != mOptimalSizes.size())
@@ -350,8 +350,8 @@ namespace BansheeEngine
 				child.element->_setWidgetDepth(widgetDepth);
 				child.element->_setAreaDepth(areaDepth);
 
-				UINT32 clippedWidth = (UINT32)std::min((INT32)child.element->_getWidth(), (INT32)width - offset.x);
-				UINT32 clippedHeight = (UINT32)std::min((INT32)child.element->_getHeight(), (INT32)height - offset.y);
+				UINT32 clippedWidth = (UINT32)std::min((INT32)child.element->_getWidth(), (INT32)width - (INT32)xOffset);
+				UINT32 clippedHeight = (UINT32)std::min((INT32)child.element->_getHeight(), (INT32)height - (INT32)yOffset);
 
 				child.element->_setClipRect(Rect(0, 0, clippedWidth, clippedHeight));
 			}

+ 4 - 4
BansheeEngine/Source/BsGUILayoutY.cpp

@@ -8,13 +8,13 @@ using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	void GUILayoutY::updateOptimalSizes()
+	void GUILayoutY::_updateOptimalSizes()
 	{
 		// Update all children first, otherwise we can't determine out own optimal size
 		for(auto& child : mChildren)
 		{
 			if(child.isLayout())
-				updateOptimalSizes();
+				child.layout->_updateOptimalSizes();
 		}
 
 		if(mChildren.size() != mOptimalSizes.size())
@@ -354,8 +354,8 @@ namespace BansheeEngine
 				child.element->_setWidgetDepth(widgetDepth);
 				child.element->_setAreaDepth(areaDepth);
 
-				UINT32 clippedWidth = (UINT32)std::min((INT32)child.element->_getWidth(), (INT32)width - offset.x);
-				UINT32 clippedHeight = (UINT32)std::min((INT32)child.element->_getHeight(), (INT32)height - offset.y);
+				UINT32 clippedWidth = (UINT32)std::min((INT32)child.element->_getWidth(), (INT32)width - (INT32)xOffset);
+				UINT32 clippedHeight = (UINT32)std::min((INT32)child.element->_getHeight(), (INT32)height - (INT32)yOffset);
 
 				child.element->_setClipRect(Rect(0, 0, clippedWidth, clippedHeight));
 			}

+ 1 - 1
BansheeEngine/Source/BsGUIManager.cpp

@@ -439,7 +439,7 @@ namespace BansheeEngine
 
 			for(auto& widget : mWidgets)
 			{
-				if(widget->inBounds(screenPos))
+				if(widget->getOwnerWindow() == window && widget->inBounds(screenPos))
 				{
 					const Matrix4& worldTfrm = widget->SO()->getWorldTfrm();
 

+ 17 - 11
CamelotClient/BsGUITabbedTitleBar.cpp

@@ -13,7 +13,7 @@ using namespace BansheeEngine;
 namespace BansheeEditor
 {
 	TabbedTitleBar::TabbedTitleBar(const HSceneObject& parent)
-		:GUIWidget(parent), mLastDropElement(nullptr), mMinBtn(nullptr), mCloseBtn(nullptr), mMainArea(nullptr)
+		:GUIWidget(parent), mLastDropElement(nullptr), mMinBtn(nullptr), mCloseBtn(nullptr), mMainArea(nullptr), mMainLayout(nullptr)
 	{
 
 	}
@@ -30,7 +30,7 @@ namespace BansheeEditor
 
 	void TabbedTitleBar::insertTab(UINT32 idx, const CM::String& name)
 	{
-		GUIToggle* newTabToggle = GUIToggle::create(*this, GUILayoutOptions::expandableX(13, 100, 200), name, EngineGUI::instance().getSkin().getStyle("TabbedBarBtn"));
+		GUIToggle* newTabToggle = GUIToggle::create(*this, name, EngineGUI::instance().getSkin().getStyle("TabbedBarBtn"));
 		GUITexture* newDragDropElement = GUITexture::create(*this, GUIImageScaleMode::StretchToFit, EngineGUI::instance().getSkin().getStyle("TabbedBarDropArea"));
 
 		idx = Math::Clamp(idx, 0U, (UINT32)mTabButtons.size());
@@ -38,8 +38,8 @@ namespace BansheeEditor
 		mTabButtons.insert(mTabButtons.begin() + idx, newTabToggle);
 		mDragDropElements.insert(mDragDropElements.begin() + idx, newDragDropElement);
 
-		mMainArea->getLayout().insertElement(idx * 2, newTabToggle);
-		mMainArea->getLayout().insertElement(idx * 2, newDragDropElement);
+		mMainLayout->insertElement(idx * 2, newTabToggle);
+		mMainLayout->insertElement(idx * 2, newDragDropElement);
 	}
 
 	void TabbedTitleBar::removeTab(UINT32 idx)
@@ -49,8 +49,8 @@ namespace BansheeEditor
 
 		idx = Math::Clamp(idx, 0U, (UINT32)mTabButtons.size() - 1);
 
-		mMainArea->getLayout().removeElement(mTabButtons[idx]);
-		mMainArea->getLayout().removeElement(mDragDropElements[idx]);
+		mMainLayout->removeElement(mTabButtons[idx]);
+		mMainLayout->removeElement(mDragDropElements[idx]);
 
 		mTabButtons.erase(mTabButtons.begin() + idx);
 		mDragDropElements.erase(mDragDropElements.begin() + idx);
@@ -60,11 +60,13 @@ namespace BansheeEditor
 	{
 		GUIWidget::initialize(target, ownerWindow);
 
-		GUIArea* backgroundArea = GUIArea::create(*this, 0, 0, 0, 0, 500);
+		GUIArea* backgroundArea = GUIArea::create(*this, 0, 1, 0, 13, 500);
 		GUITexture* titleBarBg = GUITexture::create(*this, GUIImageScaleMode::StretchToFit, EngineGUI::instance().getSkin().getStyle("TitleBarBackground"));
+		GUIFixedSpace& space1 = backgroundArea->getLayout().addSpace(1);
 		backgroundArea->getLayout().addElement(titleBarBg);
+		GUIFixedSpace& space2 = backgroundArea->getLayout().addSpace(1);
 
-		mMainArea = GUIArea::create(*this, 0, 0, 0, 0, 499);
+		mMainArea = GUIArea::create(*this, 0, 1, 0, 13, 499);
 
 		GUITexture* dragDropElement = GUITexture::create(*this, GUILayoutOptions::expandableX(13, 20), GUIImageScaleMode::StretchToFit, EngineGUI::instance().getSkin().getStyle("TabbedBarDropArea"));
 		mLastDropElement = dragDropElement;
@@ -72,9 +74,13 @@ namespace BansheeEditor
 		mMinBtn = GUIButton::create(*this, "", EngineGUI::instance().getSkin().getStyle("WinMinimizeBtn"));
 		mCloseBtn = GUIButton::create(*this, "", EngineGUI::instance().getSkin().getStyle("WinCloseBtn"));
 
-		mMainArea->getLayout().addElement(dragDropElement);
-		mMainArea->getLayout().addElement(mMinBtn);
-		mMainArea->getLayout().addElement(mCloseBtn);
+		GUIFixedSpace& space3 = mMainArea->getLayout().addSpace(1);
+		mMainLayout = &mMainArea->getLayout().addLayoutX();
+		mMainLayout->addElement(dragDropElement);
+		mMainLayout->addElement(mMinBtn);
+		GUIFixedSpace& space4 = mMainLayout->addSpace(3);
+		mMainLayout->addElement(mCloseBtn);
+		GUIFixedSpace& space5 = mMainArea->getLayout().addSpace(3);
 
 		addTab("TEST!");
 	}

+ 1 - 0
CamelotClient/BsGUITabbedTitleBar.h

@@ -26,6 +26,7 @@ namespace BansheeEditor
 		CM::vector<BS::GUIToggle*>::type mTabButtons;
 
 		BS::GUIArea* mMainArea;
+		BS::GUILayout* mMainLayout;
 		BS::GUIButton* mMinBtn;
 		BS::GUIButton* mCloseBtn;
 		BS::GUITexture* mLastDropElement;

+ 7 - 7
CamelotClient/CmEditorWindow.cpp

@@ -58,11 +58,11 @@ namespace BansheeEditor
 
 		//// DEBUG
 		
-		//GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 0);
-		//GUILayout& layout = backgroundArea->getLayout();
+		GUIArea* dbgArea = GUIArea::create(*mGUI, 0, 13, 0, 0, 1998);
+		GUILayout& layout = dbgArea->getLayout();
 		
 		mDbgLabel = GUILabel::create(*mGUI, "Testing test");
-		/*layout.addElement(mDbgLabel);*/
+		layout.addElement(mDbgLabel);
 
 		
 		//GUIFlexibleSpace& space4 = otherLayout.addFlexibleSpace();
@@ -75,11 +75,11 @@ namespace BansheeEditor
 		//otherLayout.addElement(GUIButton::create(*mGUI, "Test"));
 		//otherLayout.addElement(GUIWindowFrame::create(*mGUI));
 		
-		//GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 2000);
-		//backgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUILayoutOptions::expandableXY(), GUIImageScaleMode::RepeatToFit, mGUI->getSkin()->getStyle("WindowBackground")));
+		GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 2000);
+		backgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUILayoutOptions::expandableXY(), GUIImageScaleMode::RepeatToFit, mGUI->getSkin()->getStyle("WindowBackground")));
 
-		//GUIArea* windowFrameArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 1999);
-		//windowFrameArea->getLayout().addElement(GUIWindowFrame::create(*mGUI));
+		GUIArea* windowFrameArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 1999);
+		windowFrameArea->getLayout().addElement(GUIWindowFrame::create(*mGUI));
 
 		//GUIArea* titleBarBackgroundArea = GUIArea::create(*mGUI, 0, 1, 0, 11, 1999);
 		//titleBarBackgroundArea->getLayout().addSpace(1);

+ 1 - 0
CamelotCore/Source/CmApplication.cpp

@@ -54,6 +54,7 @@ namespace CamelotFramework
 		HighLevelGpuProgramManager::startUp(cm_new<HighLevelGpuProgramManager>());
 
 		RenderSystemManager::startUp(cm_new<RenderSystemManager>());
+
 		mPrimaryWindow = RenderSystemManager::instance().initialize(desc.renderSystem, desc.primaryWindowDesc);
 
 		RendererManager::startUp(cm_new<RendererManager>());

+ 2 - 0
CamelotCore/Source/CmRenderSystem.cpp

@@ -458,6 +458,8 @@ namespace CamelotFramework {
 
 		while(true)
 		{
+			// TODO - This might be causing a deadlock in Release mode. I'm thinking because mCommandsCompleted isn't marked as volatile.
+
 			// Check if our command id is in the completed list
 			auto iter = mCommandsCompleted.begin();
 			for(; iter != mCommandsCompleted.end(); ++iter)