Browse Source

Fixed GUIPanelContainer so it returns valid optimal size
Added scroll area to inspector window

Marko Pintera 11 years ago
parent
commit
b920bd4f26

+ 4 - 4
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -49,15 +49,15 @@ namespace BansheeEngine
 		// technically provides "infinite" space
 		UINT32 contentLayoutWidth = width;
 		if(mHorzBarType != ScrollBarType::NeverShow)
-			contentLayoutWidth = mContentLayout->_getOptimalSize().x;
+			contentLayoutWidth = std::max((UINT32)mContentLayout->_getOptimalSize().x, mWidth);
 
 		UINT32 contentLayoutHeight = height;
 		if(mVertBarType != ScrollBarType::NeverShow)
-			contentLayoutHeight = mContentLayout->_getOptimalSize().y;
+			contentLayoutHeight = std::max((UINT32)mContentLayout->_getOptimalSize().y, mHeight);
 
 		mContentLayout->_updateLayoutInternal(x, y, contentLayoutWidth, contentLayoutHeight, clipRect, widgetDepth, areaDepth);
-		mContentWidth = mContentLayout->_getActualWidth();
-		mContentHeight = mContentLayout->_getActualHeight();
+		mContentWidth = std::max(mContentLayout->_getActualWidth(), mWidth);
+		mContentHeight = std::max(mContentLayout->_getActualHeight(), mHeight);
 
 		mClippedContentWidth = width;
 		mClippedContentHeight = height;

+ 7 - 4
MBansheeEditor/Inspector/InspectorWindow.cs

@@ -15,6 +15,7 @@ namespace BansheeEditor
         }
 
         private List<InspectorData> inspectorData = new List<InspectorData>();
+        private GUIScrollArea inspectorScrollArea;
         private GUILayout inspectorLayout;
 
         internal void SetObjectToInspect(SceneObject so)
@@ -23,7 +24,9 @@ namespace BansheeEditor
 
             // TODO - Create SceneObject gui elements (name + transform)
 
-            inspectorLayout = GUI.layout.AddLayoutY();
+            inspectorScrollArea = new GUIScrollArea();
+            GUI.layout.AddElement(inspectorScrollArea);
+            inspectorLayout = inspectorScrollArea.layout;
 
             Component[] allComponents = so.GetComponents();
             for (int i = 0; i < allComponents.Length; i++)
@@ -90,10 +93,10 @@ namespace BansheeEditor
 
             inspectorData.Clear();
 
-            if (inspectorLayout != null)
+            if (inspectorScrollArea != null)
             {
-                inspectorLayout.Destroy();
-                inspectorLayout = null;
+                inspectorScrollArea.Destroy();
+                inspectorScrollArea = null;
             }
         }
 

+ 14 - 1
SBansheeEditor/Source/BsGUIPanelContainer.cpp

@@ -51,7 +51,20 @@ namespace BansheeEngine
 
 	Vector2I GUIPanelContainer::_getOptimalSize() const
 	{
-		return Vector2I(0, 0);
+		const Vector<ScriptGUIArea*> areas = mGUIPanel->getAreas();
+
+		Vector2I optimalSize;
+
+		for (auto& scriptArea : areas)
+		{
+			GUIArea* area = scriptArea->getInternalValue();
+			area->_update();
+
+			optimalSize.x = std::max(optimalSize.x, area->getLayout()._getOptimalSize().x);
+			optimalSize.y = std::max(optimalSize.y, area->getLayout()._getOptimalSize().y);
+		}
+
+		return optimalSize;
 	}
 
 	const String& GUIPanelContainer::getGUITypeName()