Quellcode durchsuchen

Fixing drop down windows so they can properly handle drop down lists within them

BearishSun vor 9 Jahren
Ursprung
Commit
3bc7345b29

+ 1 - 1
Source/BansheeEditor/Include/BsDropDownWindow.h

@@ -55,7 +55,7 @@ namespace BansheeEngine
 		friend class DropDropWindowManager;
 
 		/**	Triggered when the user clicks outside of the drop down area. */
-		void dropDownFocusLost();
+		void dropDownFocusGained();
 
 		SPtr<RenderWindow> mRenderWindow;
 		HSceneObject mSceneObject;

+ 10 - 6
Source/BansheeEditor/Source/BsDropDownWindow.cpp

@@ -23,15 +23,14 @@ namespace BansheeEngine
 
 		mGUI = mSceneObject->addComponent<CGUIWidget>(camera);
 
-		mGUI->setDepth(0); // Needs to be in front of everything
+		mGUI->setDepth(1); // Needs to be in front of everything (except other drop down and tooltip elements)
 		mGUI->setSkin(BuiltinEditorResources::instance().getSkin());
 
 		mRootPanel = mGUI->getPanel()->addNewElement<GUIPanel>();
 		
 		GUIPanel* frontHitBoxPanel = mRootPanel->addNewElement<GUIPanel>(std::numeric_limits<INT16>::min());
 		mFrontHitBox = GUIDropDownHitBox::create(false, false);
-		mFrontHitBox->onFocusLost.connect(std::bind(&DropDownWindow::dropDownFocusLost, this));
-		mFrontHitBox->setFocus(true);
+		mFrontHitBox->onFocusGained.connect(std::bind(&DropDownWindow::dropDownFocusGained, this));
 		frontHitBoxPanel->addElement(mFrontHitBox);
 
 		GUIPanel* backHitBoxPanel = mRootPanel->addNewElement<GUIPanel>(std::numeric_limits<INT16>::max());
@@ -98,13 +97,18 @@ namespace BansheeEngine
 		DropDownAreaPlacement::HorzDir horzDir;
 		DropDownAreaPlacement::VertDir vertDir;
 		Rect2I placementBounds = dropDownPlacement.getOptimalBounds(width, height, availableBounds, horzDir, vertDir);
+		placementBounds.width = width;
+		placementBounds.height = height;
 
 		mRootPanel->setPosition(placementBounds.x, placementBounds.y);
 		mRootPanel->setWidth(width);
 		mRootPanel->setHeight(height);
 
-		mFrontHitBox->setBounds(Rect2I(placementBounds.x, placementBounds.y, width, height));
-		mBackHitBox->setBounds(Rect2I(placementBounds.x, placementBounds.y, width, height));
+		Vector<Rect2I> nonDropDownBounds;
+		availableBounds.cut(placementBounds, nonDropDownBounds);
+
+		mFrontHitBox->setBounds(nonDropDownBounds);
+		mBackHitBox->setBounds(placementBounds);
 
 		mWidth = width;
 		mHeight = height;
@@ -115,7 +119,7 @@ namespace BansheeEngine
 		DropDownWindowManager::instance().close();
 	}
 
-	void DropDownWindow::dropDownFocusLost()
+	void DropDownWindow::dropDownFocusGained()
 	{
 		close();
 	}

+ 3 - 3
Source/BansheeEngine/Include/BsGUIDropDownHitBox.h

@@ -61,13 +61,13 @@ namespace BansheeEngine
 		void updateClippedBounds() override;
 
 		/** @copydoc GUIElementContainer::_commandEvent */
-		virtual bool _commandEvent(const GUICommandEvent& ev) override;
+		bool _commandEvent(const GUICommandEvent& ev) override;
 
 		/** @copydoc GUIElementContainer::_mouseEvent */
-		virtual bool _mouseEvent(const GUIMouseEvent& ev) override;
+		bool _mouseEvent(const GUIMouseEvent& ev) override;
 
 		/** @copydoc GUIElementContainer::_isInBounds */
-		virtual bool _isInBounds(const Vector2I position) const override;
+		bool _isInBounds(const Vector2I position) const override;
 
 		Vector<Rect2I> mBounds;
 		bool mCaptureMouseOver;