소스 검색

Expand Control and Centering

Improved the expand control to better support being centered. The control now re-centers as it expands. And does the onResized callback with each iteration of the expansion. It also now correctly handle having a child resized which affects the expanded state.
Peter Robinson 3 년 전
부모
커밋
830b80ffdb
2개의 변경된 파일24개의 추가작업 그리고 2개의 파일을 삭제
  1. 23 2
      engine/source/gui/containers/guiExpandCtrl.cc
  2. 1 0
      engine/source/gui/containers/guiExpandCtrl.h

+ 23 - 2
engine/source/gui/containers/guiExpandCtrl.cc

@@ -116,6 +116,12 @@ void GuiExpandCtrl::parentResized(const Point2I &oldParentExtent, const Point2I
 	setUpdate();
 	setUpdate();
 }
 }
 
 
+void GuiExpandCtrl::childResized(GuiControl* child)
+{
+	calcExpandedExtent();
+	Parent::childResized(child);
+}
+
 void GuiExpandCtrl::setCollapsedExtent(const Point2I &extent)
 void GuiExpandCtrl::setCollapsedExtent(const Point2I &extent)
 {
 {
 	mCollapsedExtent = extent;
 	mCollapsedExtent = extent;
@@ -170,12 +176,27 @@ bool GuiExpandCtrl::processExpansion()
 		mBounds.extent.x = processValue(progress, mExpandedExtent.x, mCollapsedExtent.x);
 		mBounds.extent.x = processValue(progress, mExpandedExtent.x, mCollapsedExtent.x);
 		mBounds.extent.y = processValue(progress, mExpandedExtent.y, mCollapsedExtent.y);
 		mBounds.extent.y = processValue(progress, mExpandedExtent.y, mCollapsedExtent.y);
 	}
 	}
-	setUpdate();
 
 
-	GuiControl *parent = getParent();
+	GuiControl* parent = getParent();
 	if (parent)
 	if (parent)
+	{
+		if (mHorizSizing == horizResizeCenter)
+		{
+			mBounds.point.x = (parent->mBounds.extent.x - mBounds.extent.x) / 2;
+		}
+		if (mVertSizing == vertResizeCenter)
+		{
+			mBounds.point.y = (parent->mBounds.extent.y - mBounds.extent.y) / 2;
+		}
+
 		parent->childResized(this);
 		parent->childResized(this);
+	}
+	setUpdate();
 
 
+	if (isMethod("onResize"))
+	{
+		Con::executef(this, 2, "onResize");
+	}
 
 
 	if (mAnimationProgress >= 1.0f)
 	if (mAnimationProgress >= 1.0f)
 	{
 	{

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

@@ -60,6 +60,7 @@ public:
 	GuiExpandCtrl();
 	GuiExpandCtrl();
 
 
    virtual void parentResized(const Point2I &oldParentExtent, const Point2I &newParentExtent);
    virtual void parentResized(const Point2I &oldParentExtent, const Point2I &newParentExtent);
+   virtual void childResized(GuiControl* child);
 
 
    inline bool getExpanded() { return mExpanded; };
    inline bool getExpanded() { return mExpanded; };
    void setExpanded(bool isExpanded);
    void setExpanded(bool isExpanded);