Browse Source

I no longer send GUI events to element parents, but instead send them to elements directly since parents were sometimes incorrectly receiving and processing child events they shouldn't have

Marko Pintera 12 years ago
parent
commit
72802ddea2

+ 5 - 0
BansheeEngine/Include/BsGUIScrollArea.h

@@ -33,6 +33,10 @@ namespace BansheeEngine
 	protected:
 		~GUIScrollArea();
 
+		/**
+		 * @copydoc GUIElement::updateBounds()
+		 */
+		virtual void updateClippedBounds();
 	private:
 		GUIScrollArea(GUIWidget& parent, ScrollBarType vertBarType, ScrollBarType horzBarType, 
 			const GUIElementStyle* scrollBarStyle, const GUIElementStyle* scrollAreaStyle, const GUILayoutOptions& layoutOptions);
@@ -61,5 +65,6 @@ namespace BansheeEngine
 		void horzScrollUpdate(float pct);
 		void _updateLayoutInternal(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height,
 			CM::RectI clipRect, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
+
 	};
 }

+ 10 - 0
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -32,6 +32,16 @@ namespace BansheeEngine
 
 	}
 
+	void GUIScrollArea::updateClippedBounds()
+	{
+		RectI bounds(0, 0, mWidth, mHeight);
+		bounds.clip(mClipRect);
+		bounds.x += mOffset.x;
+		bounds.y += mOffset.y;
+
+		mClippedBounds = bounds;
+	}
+
 	void GUIScrollArea::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
 	{

+ 3 - 75
BansheeEngine/Source/BsGUIWidget.cpp

@@ -114,89 +114,17 @@ namespace BansheeEngine
 
 	bool GUIWidget::_mouseEvent(GUIElement* element, const GUIMouseEvent& ev)
 	{
-		// If an element has any parents we send the events to all parents first and only then to the children unless
-		// the parents process them
-		Stack<GUIElement*>::type todo;
-		GUIElementBase* curElement = element;
-		do
-		{
-			if(curElement->_getType() == GUIElementBase::Type::Element)
-				todo.push(static_cast<GUIElement*>(curElement));
-
-			curElement = curElement->_getParent();
-		} while(curElement != nullptr);
-		
-		while(true)
-		{
-			GUIElement* elem = todo.top();
-			todo.pop();
-
-			if(elem->mouseEvent(ev))
-				return true;
-
-			if(todo.size() == 0)
-				return false;
-		}
-
-		return false;
+		return element->mouseEvent(ev);
 	}
 
 	bool GUIWidget::_textInputEvent(GUIElement* element, const GUITextInputEvent& ev)
 	{
-		// If an element has any parents we send the events to all parents first and only then to the children unless
-		// the parents process them
-		Stack<GUIElement*>::type todo;
-		GUIElementBase* curElement = element;
-		do
-		{
-			if(curElement->_getType() == GUIElementBase::Type::Element)
-				todo.push(static_cast<GUIElement*>(curElement));
-
-			curElement = curElement->_getParent();
-		} while(curElement != nullptr);
-
-		while(true)
-		{
-			GUIElement* elem = todo.top();
-			todo.pop();
-
-			if(elem->textInputEvent(ev))
-				return true;
-
-			if(todo.size() == 0)
-				return false;
-		}
-
-		return false;
+		return element->textInputEvent(ev);
 	}
 
 	bool GUIWidget::_commandEvent(GUIElement* element, const GUICommandEvent& ev)
 	{
-		// If an element has any parents we send the events to all parents first and only then to the children unless
-		// the parents process them
-		Stack<GUIElement*>::type todo;
-		GUIElementBase* curElement = element;
-		do
-		{
-			if(curElement->_getType() == GUIElementBase::Type::Element)
-				todo.push(static_cast<GUIElement*>(curElement));
-
-			curElement = curElement->_getParent();
-		} while(curElement != nullptr);
-
-		while(true)
-		{
-			GUIElement* elem = todo.top();
-			todo.pop();
-
-			if(elem->commandEvent(ev))
-				return true;
-
-			if(todo.size() == 0)
-				return false;
-		}
-
-		return false;
+		return element->commandEvent(ev);
 	}
 
 	void GUIWidget::registerElement(GUIElement* elem)

+ 2 - 1
EditorWindowDock.txt

@@ -1,5 +1,6 @@
 TODO:
- - Dock manager currently eats all mouse input. Modify GUIManager so it will recursively try to send input to all elements under the cursor until one processes it
+ - Fix various issues with dragging windows onto tabbed title bar and test it properly
+ - Also test for any new issues with the element container parenting system
 
 Resize sliders
  - Add a button between docked windows