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

Removed various uses of GUIWidget::getOwnerWindow in preparation of complete removal of that method

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

+ 1 - 1
BansheeEngine/Include/BsGUIDropDownBoxManager.h

@@ -11,7 +11,7 @@ namespace BansheeEngine
 	public:
 		~GUIDropDownBoxManager();
 
-		CM::GameObjectHandle<GUIDropDownBox> openDropDownBox(CM::Viewport* target, CM::RenderWindow* window, const GUIDropDownAreaPlacement& placement,
+		CM::GameObjectHandle<GUIDropDownBox> openDropDownBox(CM::Viewport* target, const GUIDropDownAreaPlacement& placement,
 			const GUIDropDownData& dropDownData, const GUISkin& skin, GUIDropDownType type, std::function<void()> onClosedCallback);
 		void closeDropDownBox();
 

+ 1 - 1
BansheeEngine/Source/BsGUIContextMenu.cpp

@@ -21,7 +21,7 @@ namespace BansheeEngine
 	{
 		GUIDropDownAreaPlacement placement = GUIDropDownAreaPlacement::aroundPosition(position);
 
-		GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget.getTarget(), widget.getOwnerWindow(), 
+		GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget.getTarget(), 
 			placement, getDropDownData(), widget.getSkin(), GUIDropDownType::ContextMenu, boost::bind(&GUIContextMenu::onMenuClosed, this));
 
 		GUIManager::instance().enableSelectiveInput(boost::bind(&GUIContextMenu::close, this));

+ 2 - 2
BansheeEngine/Source/BsGUIDropDownBoxManager.cpp

@@ -10,13 +10,13 @@ namespace BansheeEngine
 		closeDropDownBox();
 	}
 
-	CM::GameObjectHandle<GUIDropDownBox> GUIDropDownBoxManager::openDropDownBox(CM::Viewport* target, CM::RenderWindow* window, const GUIDropDownAreaPlacement& placement,
+	CM::GameObjectHandle<GUIDropDownBox> GUIDropDownBoxManager::openDropDownBox(CM::Viewport* target, const GUIDropDownAreaPlacement& placement,
 		const GUIDropDownData& dropDownData, const GUISkin& skin, GUIDropDownType type, std::function<void()> onClosedCallback)
 	{
 		closeDropDownBox();
 
 		mDropDownSO = SceneObject::create("DropDownBox");
-		mDropDownBox = mDropDownSO->addComponent<GUIDropDownBox>(target, window, placement, dropDownData, skin, type);
+		mDropDownBox = mDropDownSO->addComponent<GUIDropDownBox>(target, nullptr, placement, dropDownData, skin, type);
 		mOnClosedCallback = onClosedCallback;
 
 		return mDropDownBox;

+ 1 - 1
BansheeEngine/Source/BsGUIListBox.cpp

@@ -100,7 +100,7 @@ namespace BansheeEngine
 		GUIWidget& widget = _getParentWidget();
 		GUIDropDownAreaPlacement placement = GUIDropDownAreaPlacement::aroundBoundsHorz(getBounds());
 
-		GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget.getTarget(), widget.getOwnerWindow(), 
+		GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget.getTarget(), 
 			placement, dropDownData, widget.getSkin(), GUIDropDownType::MenuBar, boost::bind(&GUIListBox::onListBoxClosed, this));
 
 		GUIManager::instance().enableSelectiveInput(boost::bind(&GUIListBox::closeListBox, this));

+ 8 - 7
CamelotClient/Include/BsDockManager.h

@@ -18,11 +18,11 @@ namespace BansheeEditor
 			~DockContainer();
 
 			void setArea(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height);
-			void makeLeaf(BS::GUIWidget* widgetParent, EditorWidget* widget);
-			void addLeft(BS::GUIWidget* widgetParent, EditorWidget* widget);
-			void addRight(BS::GUIWidget* widgetParent, EditorWidget* widget);
-			void addTop(BS::GUIWidget* widgetParent, EditorWidget* widget);
-			void addBottom(BS::GUIWidget* widgetParent, EditorWidget* widget);
+			void makeLeaf(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
+			void addLeft(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
+			void addRight(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
+			void addTop(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
+			void addBottom(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget);
 
 			DockContainer* find(EditorWidgetContainer* widgetContainer);
 
@@ -46,7 +46,7 @@ namespace BansheeEditor
 			static const CM::UINT32 SliderSize;
 
 		private:
-			void splitContainer(BS::GUIWidget* widgetParent, EditorWidget* widget, bool horizontal, bool newChildIsFirst);
+			void splitContainer(BS::GUIWidget* widgetParent, CM::RenderWindow* parentWindow, EditorWidget* widget, bool horizontal, bool newChildIsFirst);
 		};
 
 		enum class DockLocation
@@ -58,7 +58,7 @@ namespace BansheeEditor
 			None
 		};
 	public:
-		DockManager(BS::GUIWidget* parent);
+		DockManager(BS::GUIWidget* parent, CM::RenderWindow* parentWindow);
 		~DockManager();
 
 		void render(const CM::Viewport* viewport, CM::RenderQueue& renderQueue);
@@ -71,6 +71,7 @@ namespace BansheeEditor
 		static const CM::Color HIGHLIGHT_COLOR;
 
 		BS::GUIWidget* mParent;
+		CM::RenderWindow* mParentWindow;
 		DockContainer mRootContainer;
 
 		CM::HMesh mDropOverlayMesh;

+ 1 - 1
CamelotClient/Include/BsEditorWidgetContainer.h

@@ -8,7 +8,7 @@ namespace BansheeEditor
 	class EditorWidgetContainer
 	{
 	public:
-		EditorWidgetContainer(BS::GUIWidget* parent);
+		EditorWidgetContainer(BS::GUIWidget* parent, CM::RenderWindow* renderWindow);
 		virtual ~EditorWidgetContainer();
 
 		void add(EditorWidget& widget);

+ 2 - 1
CamelotClient/Include/BsGUIMenuBar.h

@@ -14,7 +14,7 @@ namespace BansheeEditor
 		};
 
 	public:
-		GUIMenuBar(BS::GUIWidget* parent);
+		GUIMenuBar(BS::GUIWidget* parent, CM::RenderWindow* parentWindow);
 		virtual ~GUIMenuBar();
 
 		void setArea(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height);
@@ -26,6 +26,7 @@ namespace BansheeEditor
 	private:
 		static const CM::UINT32 NUM_ELEMENTS_AFTER_CONTENT;
 
+		CM::RenderWindow* mParentWindow;
 		BS::GUIWidget* mParentWidget;
 		BS::GUIArea* mMainArea;
 		BS::GUIArea* mBackgroundArea;

+ 2 - 1
CamelotClient/Include/BsGUITabbedTitleBar.h

@@ -8,7 +8,7 @@ namespace BansheeEditor
 	class GUITabbedTitleBar
 	{
 	public:
-		GUITabbedTitleBar(BS::GUIWidget* parent);
+		GUITabbedTitleBar(BS::GUIWidget* parent, CM::RenderWindow* parentWindow);
 		virtual ~GUITabbedTitleBar();
 
 		void setSize(CM::UINT32 width, CM::UINT32 height);
@@ -35,6 +35,7 @@ namespace BansheeEditor
 		BS::GUIButton* mMinBtn;
 		BS::GUIButton* mCloseBtn;
 		GUIWindowDropArea* mLastDropElement;
+		CM::RenderWindow* mParentWindow;
 
 		void tabToggled(CM::UINT32 tabIdx);
 		void tabClosed();

+ 1 - 0
CamelotClient/Include/BsGUIWindowFrameWidget.h

@@ -16,6 +16,7 @@ namespace BansheeEditor
 		static const CM::UINT32 RESIZE_BORDER_WIDTH;
 
 		BS::GUIArea* mWindowFrameArea;
+		CM::RenderWindow* mParentWindow;
 		GUIWindowFrame* mWindowFrame;
 
 		virtual void update();

+ 20 - 20
CamelotClient/Source/BsDockManager.cpp

@@ -91,37 +91,37 @@ namespace BansheeEditor
 		}
 	}
 
-	void DockManager::DockContainer::makeLeaf(GUIWidget* widgetParent, EditorWidget* widget)
+	void DockManager::DockContainer::makeLeaf(GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidget* widget)
 	{
 		mIsLeaf = true;
-		mWidgets = cm_new<EditorWidgetContainer>(widgetParent);
+		mWidgets = cm_new<EditorWidgetContainer>(widgetParent, parentWindow);
 
 		mWidgets->add(*widget);
 		mWidgets->setPosition(mX, mY);
 		mWidgets->setSize(mWidth, mHeight);
 	}
 
-	void DockManager::DockContainer::addLeft(BS::GUIWidget* widgetParent, EditorWidget* widget)
+	void DockManager::DockContainer::addLeft(BS::GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidget* widget)
 	{
-		splitContainer(widgetParent, widget, false, true);
+		splitContainer(widgetParent, parentWindow, widget, false, true);
 	}
 
-	void DockManager::DockContainer::addRight(BS::GUIWidget* widgetParent, EditorWidget* widget)
+	void DockManager::DockContainer::addRight(BS::GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidget* widget)
 	{
-		splitContainer(widgetParent, widget, false, false);
+		splitContainer(widgetParent, parentWindow, widget, false, false);
 	}
 
-	void DockManager::DockContainer::addTop(BS::GUIWidget* widgetParent, EditorWidget* widget)
+	void DockManager::DockContainer::addTop(BS::GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidget* widget)
 	{
-		splitContainer(widgetParent, widget, true, true);
+		splitContainer(widgetParent, parentWindow, widget, true, true);
 	}
 
-	void DockManager::DockContainer::addBottom(BS::GUIWidget* widgetParent, EditorWidget* widget)
+	void DockManager::DockContainer::addBottom(BS::GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidget* widget)
 	{
-		splitContainer(widgetParent, widget, true, false);
+		splitContainer(widgetParent, parentWindow, widget, true, false);
 	}
 
-	void DockManager::DockContainer::splitContainer(BS::GUIWidget* widgetParent, EditorWidget* widget, bool horizontal, bool newChildIsFirst)
+	void DockManager::DockContainer::splitContainer(BS::GUIWidget* widgetParent, RenderWindow* parentWindow, EditorWidget* widget, bool horizontal, bool newChildIsFirst)
 	{
 		UINT32 idxA = newChildIsFirst ? 0 : 1;
 		UINT32 idxB = (idxA + 1) % 2;
@@ -129,7 +129,7 @@ namespace BansheeEditor
 		mChildren[idxA] = cm_new<DockContainer>();
 		mChildren[idxB] = cm_new<DockContainer>(*this);
 
-		mChildren[idxA]->makeLeaf(widgetParent, widget);
+		mChildren[idxA]->makeLeaf(widgetParent, parentWindow, widget);
 
 		mIsLeaf = false;
 		mIsHorizontal = horizontal;
@@ -184,8 +184,8 @@ namespace BansheeEditor
 		return nullptr;
 	}
 
-	DockManager::DockManager(BS::GUIWidget* parent)
-		:mParent(parent), mMouseOverContainer(nullptr), mHighlightedDropLoc(DockLocation::None)
+	DockManager::DockManager(BS::GUIWidget* parent, CM::RenderWindow* parentWindow)
+		:mParent(parent), mParentWindow(parentWindow), mMouseOverContainer(nullptr), mHighlightedDropLoc(DockLocation::None)
 	{
 		mTopDropPolygon = cm_newN<Vector2>(4);
 		mBotDropPolygon = cm_newN<Vector2>(4);
@@ -260,16 +260,16 @@ namespace BansheeEditor
 			switch(location)
 			{
 			case DockLocation::Left:
-				container->addLeft(mParent, widgetToInsert);
+				container->addLeft(mParent, mParentWindow, widgetToInsert);
 				break;
 			case DockLocation::Right:
-				container->addRight(mParent, widgetToInsert);
+				container->addRight(mParent, mParentWindow, widgetToInsert);
 				break;
 			case DockLocation::Top:
-				container->addTop(mParent, widgetToInsert);
+				container->addTop(mParent, mParentWindow, widgetToInsert);
 				break;
 			case DockLocation::Bottom:
-				container->addBottom(mParent, widgetToInsert);
+				container->addBottom(mParent, mParentWindow, widgetToInsert);
 				break;
 			}
 		}
@@ -278,7 +278,7 @@ namespace BansheeEditor
 			if(mRootContainer.mWidgets != nullptr)
 				CM_EXCEPT(InternalErrorException, "Trying to insert a widget into dock manager root container but one already exists.");
 
-			mRootContainer.makeLeaf(mParent, widgetToInsert);
+			mRootContainer.makeLeaf(mParent, mParentWindow, widgetToInsert);
 		}
 	}
 
@@ -453,7 +453,7 @@ namespace BansheeEditor
 		if(event.getType() != GUIMouseEventType::MouseMove) // TODO - Replace with DragAndDrop event
 			return;
 
-		if(widget->getOwnerWindow() != mParent->getOwnerWindow())
+		if(widget->getTarget() != mParent->getTarget())
 			return;
 
 		const Int2& widgetRelPos = event.getPosition();

+ 2 - 2
CamelotClient/Source/BsEditorWidgetContainer.cpp

@@ -13,10 +13,10 @@ namespace BansheeEditor
 {
 	const CM::UINT32 EditorWidgetContainer::TitleBarHeight = 13;
 
-	EditorWidgetContainer::EditorWidgetContainer(BS::GUIWidget* parent)
+	EditorWidgetContainer::EditorWidgetContainer(BS::GUIWidget* parent, RenderWindow* renderWindow)
 		:mParent(parent), mX(0), mY(0), mWidth(0), mHeight(0), mTitleBar(nullptr), mActiveWidget(-1)
 	{
-		mTitleBar = cm_new<GUITabbedTitleBar>(parent);
+		mTitleBar = cm_new<GUITabbedTitleBar>(parent, renderWindow);
 		mTitleBar->onTabActivated.connect(boost::bind(&EditorWidgetContainer::tabActivated, this, _1));
 		mTitleBar->onTabClosed.connect(boost::bind(&EditorWidgetContainer::tabClosed, this, _1));
 		mTitleBar->onTabDraggedOff.connect(boost::bind(&EditorWidgetContainer::tabDraggedOff, this, _1));

+ 1 - 1
CamelotClient/Source/BsEditorWindow.cpp

@@ -8,7 +8,7 @@ using namespace BansheeEngine;
 namespace BansheeEditor
 {
 	EditorWindow::EditorWindow()
-		:EditorWindowBase(), mWidgets(cm_new<EditorWidgetContainer>(mGUI.get()))
+		:EditorWindowBase(), mWidgets(cm_new<EditorWidgetContainer>(mGUI.get(), mRenderWindow.get()))
 	{
 		updateSize();
 		

+ 5 - 4
CamelotClient/Source/BsGUIMenuBar.cpp

@@ -19,8 +19,9 @@ namespace BansheeEditor
 {
 	const UINT32 GUIMenuBar::NUM_ELEMENTS_AFTER_CONTENT = 8;
 
-	GUIMenuBar::GUIMenuBar(BS::GUIWidget* parent)
-		:mParentWidget(parent), mMainArea(nullptr), mBackgroundArea(nullptr), mBgTexture(nullptr), mLogoTexture(nullptr), mSubMenuOpen(false), mSubMenuButton(nullptr)
+	GUIMenuBar::GUIMenuBar(BS::GUIWidget* parent, RenderWindow* parentWindow)
+		:mParentWidget(parent), mParentWindow(parentWindow), mMainArea(nullptr), mBackgroundArea(nullptr), 
+		mBgTexture(nullptr), mLogoTexture(nullptr), mSubMenuOpen(false), mSubMenuButton(nullptr)
 	{
 		mBackgroundArea = GUIArea::create(*parent, 0, 0, 1, 13, 9900);
 		mMainArea = GUIArea::create(*parent, 0, 0, 1, 13, 9899);
@@ -252,7 +253,7 @@ namespace BansheeEditor
 
 		GUIDropDownAreaPlacement placement = GUIDropDownAreaPlacement::aroundBoundsHorz(subMenu->button->getBounds());
 
-		GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget.getTarget(), widget.getOwnerWindow(), 
+		GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget.getTarget(), 
 			placement, dropDownData, widget.getSkin(), GUIDropDownType::MenuBar, boost::bind(&GUIMenuBar::onSubMenuClosed, this));
 
 		GUIManager::instance().enableSelectiveInput(boost::bind(&GUIMenuBar::closeSubMenu, this));
@@ -338,6 +339,6 @@ namespace BansheeEditor
 			nonClientAreas.push_back(emptyArea);
 		}
 
-		Platform::setCaptionNonClientAreas(*mParentWidget->getOwnerWindow(), nonClientAreas);
+		Platform::setCaptionNonClientAreas(*mParentWindow, nonClientAreas);
 	}
 }

+ 3 - 3
CamelotClient/Source/BsGUITabbedTitleBar.cpp

@@ -16,8 +16,8 @@ using namespace BansheeEngine;
 
 namespace BansheeEditor
 {
-	GUITabbedTitleBar::GUITabbedTitleBar(BS::GUIWidget* parent)
-		:mLastDropElement(nullptr), mMinBtn(nullptr), mCloseBtn(nullptr), 
+	GUITabbedTitleBar::GUITabbedTitleBar(BS::GUIWidget* parent, CM::RenderWindow* parentWindow)
+		:mParentWindow(parentWindow), mLastDropElement(nullptr), mMinBtn(nullptr), mCloseBtn(nullptr), 
 		mMainArea(nullptr), mMainLayout(nullptr), mParentWidget(parent), mBackgroundArea(nullptr), mUniqueTabIdx(0), mActiveTabIdx(0)
 	{
 		mBackgroundArea = GUIArea::create(*parent, 0, 0, 1, 13, 9900);
@@ -202,6 +202,6 @@ namespace BansheeEditor
 
 		nonClientAreas.push_back(mLastDropElement->getBounds());
 
-		Platform::setCaptionNonClientAreas(*mParentWidget->getOwnerWindow(), nonClientAreas);
+		Platform::setCaptionNonClientAreas(*mParentWindow, nonClientAreas);
 	}
 }

+ 4 - 4
CamelotClient/Source/BsGUIWindowFrameWidget.cpp

@@ -16,8 +16,8 @@ namespace BansheeEditor
 {
 	const UINT32 WindowFrameWidget::RESIZE_BORDER_WIDTH = 3;
 
-	WindowFrameWidget::WindowFrameWidget(const HSceneObject& parent, CM::Viewport* target, CM::RenderWindow* ownerWindow, const GUISkin& skin)
-		:GUIWidget(parent, target, ownerWindow), mWindowFrameArea(nullptr)
+	WindowFrameWidget::WindowFrameWidget(const HSceneObject& parent, CM::Viewport* target, CM::RenderWindow* parentWindow, const GUISkin& skin)
+		:GUIWidget(parent, target, parentWindow), mWindowFrameArea(nullptr), mParentWindow(parentWindow)
 	{
 		setSkin(skin);
 
@@ -50,7 +50,7 @@ namespace BansheeEditor
 
 	void WindowFrameWidget::ownerWindowFocusChanged()
 	{
-		mWindowFrame->setFocused(getOwnerWindow()->hasFocus());
+		mWindowFrame->setFocused(mParentWindow->hasFocus());
 
 		GUIWidget::ownerWindowFocusChanged();
 	}
@@ -104,6 +104,6 @@ namespace BansheeEditor
 		nonClientAreas[7].area = Rect(x + width - RESIZE_BORDER_WIDTH, y + height - RESIZE_BORDER_WIDTH, 
 			RESIZE_BORDER_WIDTH, RESIZE_BORDER_WIDTH);
 
-		Platform::setResizeNonClientAreas(*getOwnerWindow(), nonClientAreas);
+		Platform::setResizeNonClientAreas(*mParentWindow, nonClientAreas);
 	}
 }

+ 2 - 1
CamelotClient/Source/BsMainEditorWindow.cpp

@@ -27,7 +27,8 @@ namespace BansheeEditor
 	}
 
 	MainEditorWindow::MainEditorWindow(const CM::RenderWindowPtr& renderWindow)
-		:EditorWindowBase(renderWindow), mDockManager(cm_new<DockManager>(mGUI.get())), mMenuBar(cm_new<GUIMenuBar>(mGUI.get()))
+		:EditorWindowBase(renderWindow), mDockManager(cm_new<DockManager>(mGUI.get(), mRenderWindow.get())), 
+		mMenuBar(cm_new<GUIMenuBar>(mGUI.get(), mRenderWindow.get()))
 	{
 		updateAreas();
 

+ 1 - 1
TODO.txt

@@ -26,7 +26,7 @@ Update GUIWidget input handling:
 Generating a report only generates it on the active thread. I need a way to generate profiler reports on the render thread as well. Maybe extend CoreThreadAccessor?
 
 
-
+TODO: Viewport can be modified from the sim thread, but is used on the core thread without any syncronization mechanisms. Maybe add a method that returns VIEWPORT_DATA, and have that used on the core thread.
 
 I still re-create GUIWidget mesh every frame instead of just updating it.