Ver código fonte

Drop down hit boxes now properly cause parent widget to expand its bounds to cover the hit box

Marko Pintera 10 anos atrás
pai
commit
4fbfa28fd6

+ 7 - 2
BansheeEngine/Include/BsGUIDropDownHitBox.h

@@ -40,12 +40,12 @@ namespace BansheeEngine
 		/**
 		/**
 		 * Sets a single rectangle bounds in which the hitbox will capture mouse events.
 		 * Sets a single rectangle bounds in which the hitbox will capture mouse events.
 		 */
 		 */
-		void setBounds(const Rect2I& bounds) { mBounds.clear(); mBounds.push_back(bounds); }
+		void setBounds(const Rect2I& bounds);
 
 
 		/**
 		/**
 		 * Sets complex bounds consisting of multiple rectangles in which the hitbox will capture mouse events.
 		 * Sets complex bounds consisting of multiple rectangles in which the hitbox will capture mouse events.
 		 */
 		 */
-		void setBounds(const Vector<Rect2I>& bounds) { mBounds = bounds; }
+		void setBounds(const Vector<Rect2I>& bounds);
 
 
 		/**
 		/**
 		 * Triggered when hit box loses focus (e.g. user clicks outside of its bounds).
 		 * Triggered when hit box loses focus (e.g. user clicks outside of its bounds).
@@ -60,6 +60,11 @@ namespace BansheeEngine
 	private:
 	private:
 		GUIDropDownHitBox(bool captureMouse, const GUIDimensions& dimensions);
 		GUIDropDownHitBox(bool captureMouse, const GUIDimensions& dimensions);
 
 
+		/**
+		 * @copydoc	GUIElementContainer::updateClippedBounds
+		 */
+		void updateClippedBounds() override;
+
 		virtual bool _commandEvent(const GUICommandEvent& ev);
 		virtual bool _commandEvent(const GUICommandEvent& ev);
 		virtual bool _mouseEvent(const GUIMouseEvent& ev);
 		virtual bool _mouseEvent(const GUIMouseEvent& ev);
 		virtual bool _isInBounds(const Vector2I position) const;
 		virtual bool _isInBounds(const Vector2I position) const;

+ 28 - 0
BansheeEngine/Source/BsGUIDropDownHitBox.cpp

@@ -28,6 +28,34 @@ namespace BansheeEngine
 
 
 	}
 	}
 
 
+	void GUIDropDownHitBox::setBounds(const Rect2I& bounds)
+	{
+		mBounds.clear();
+		mBounds.push_back(bounds);
+
+		updateClippedBounds();
+	}
+
+	void GUIDropDownHitBox::setBounds(const Vector<Rect2I>& bounds)
+	{
+		mBounds = bounds;
+
+		updateClippedBounds();
+	}
+
+	void GUIDropDownHitBox::updateClippedBounds()
+	{
+		mClippedBounds = Rect2I();
+
+		if (mBounds.size() > 0)
+		{
+			mClippedBounds = mBounds[0];
+
+			for (UINT32 i = 1; i < (UINT32)mBounds.size(); i++)
+				mClippedBounds.encapsulate(mBounds[i]);
+		}
+	}
+
 	bool GUIDropDownHitBox::_commandEvent(const GUICommandEvent& ev)
 	bool GUIDropDownHitBox::_commandEvent(const GUICommandEvent& ev)
 	{
 	{
 		bool processed = GUIElementContainer::_commandEvent(ev);
 		bool processed = GUIElementContainer::_commandEvent(ev);

+ 0 - 1
TODO.txt

@@ -27,7 +27,6 @@ Project window
 
 
 Right-clicking on an element to open a context menu doesn't seem to properly select the element first
 Right-clicking on an element to open a context menu doesn't seem to properly select the element first
  - This might only happen if the right click happens while another context menu is already open
  - This might only happen if the right click happens while another context menu is already open
-When clicking on drop down window it will interact with GUI elements beneath it
 
 
 Simple tasks:
 Simple tasks:
  - Hook up windows drag and drop support
  - Hook up windows drag and drop support