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

GuiTabPageCtrl Update Text Bug

This fixes a bug where the tabs would not resize when text is updated.
Peter Robinson 2 месяцев назад
Родитель
Сommit
a4099fae87

+ 22 - 0
engine/source/gui/containers/guiTabPageCtrl.cc

@@ -153,4 +153,26 @@ void GuiTabPageCtrl::onRender(Point2I offset, const RectI &updateRect)
 void GuiTabPageCtrl::parentResized(const Point2I& oldParentExtent, const Point2I& newParentExtent)
 {
 	//Do nothing. If the parent of a page resized then it will tell us what size to be later.
+}
+
+void GuiTabPageCtrl::resize(const Point2I& newPosition, const Point2I& newExtent)
+{
+	Point2I oldExtent = mBounds.extent;
+	bool extentChanged = (newExtent != oldExtent);
+
+	if (extentChanged)
+	{
+		mBounds.set(mBounds.point, newExtent);
+		iterator i;
+		for (i = begin(); i != end(); i++)
+		{
+			GuiControl* ctrl = static_cast<GuiControl*>(*i);
+			ctrl->parentResized(oldExtent - (ctrl->mRenderInsetLT + ctrl->mRenderInsetRB), newExtent - (ctrl->mRenderInsetLT + ctrl->mRenderInsetRB));
+		}
+
+		if (isMethod("onResize"))
+		{
+			Con::executef(this, 2, "onResize");
+		}
+	}
 }

+ 1 - 0
engine/source/gui/containers/guiTabPageCtrl.h

@@ -45,6 +45,7 @@ class GuiTabPageCtrl : public GuiControl
       virtual void setText(const char *txt = NULL); ///< Override setText function to signal parent we need to update.
 	  void onRender(Point2I offset, const RectI &updateRect);
 	  void parentResized(const Point2I& oldParentExtent, const Point2I& newParentExtent);
+	  void resize(const Point2I& newPosition, const Point2I& newExtent);
 };
 
 #endif //_GUITABPAGECTRL_H_