Переглянути джерело

Merge branch 'development' into torqueScriptDocs

Charlie Patterson 12 роки тому
батько
коміт
84fc39e0d6

+ 2 - 0
engine/compilers/VisualStudio 2010/Torque 2D.vcxproj

@@ -365,6 +365,7 @@
     <ClCompile Include="..\..\source\graphics\TextureDictionary.cc" />
     <ClCompile Include="..\..\source\graphics\TextureHandle.cc" />
     <ClCompile Include="..\..\source\graphics\TextureManager.cc" />
+    <ClCompile Include="..\..\source\gui\containers\guiGridCtrl.cc" />
     <ClCompile Include="..\..\source\gui\guiArrayCtrl.cc" />
     <ClCompile Include="..\..\source\gui\guiBackgroundCtrl.cc" />
     <ClCompile Include="..\..\source\gui\guiBitmapBorderCtrl.cc" />
@@ -816,6 +817,7 @@
     <ClInclude Include="..\..\source\graphics\TextureHandle.h" />
     <ClInclude Include="..\..\source\graphics\TextureManager.h" />
     <ClInclude Include="..\..\source\graphics\TextureObject.h" />
+    <ClInclude Include="..\..\source\gui\containers\guiGridCtrl.h" />
     <ClInclude Include="..\..\source\gui\guiArrayCtrl.h" />
     <ClInclude Include="..\..\source\gui\guiBackgroundCtrl.h" />
     <ClInclude Include="..\..\source\gui\guiBitmapCtrl.h" />

+ 6 - 0
engine/compilers/VisualStudio 2010/Torque 2D.vcxproj.filters

@@ -1272,6 +1272,9 @@
     <ClCompile Include="..\..\source\persistence\taml\tamlCustom.cc">
       <Filter>persistence\taml</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\source\gui\containers\guiGridCtrl.cc">
+      <Filter>gui\containers</Filter>
+    </ClCompile>
     <ClCompile Include="..\..\source\2d\sceneobject\SceneObjectList.cc">
       <Filter>2d\sceneobject</Filter>
     </ClCompile>
@@ -2616,6 +2619,9 @@
     <ClInclude Include="..\..\source\persistence\taml\tamlCustom.h">
       <Filter>persistence\taml</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\source\gui\containers\guiGridCtrl.h">
+      <Filter>gui\containers</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\source\sim\simObjectTimerEvent.h">
       <Filter>sim</Filter>
     </ClInclude>

+ 2 - 0
engine/compilers/VisualStudio 2012/Torque 2D.vcxproj

@@ -372,6 +372,7 @@
     <ClCompile Include="..\..\source\graphics\TextureDictionary.cc" />
     <ClCompile Include="..\..\source\graphics\TextureHandle.cc" />
     <ClCompile Include="..\..\source\graphics\TextureManager.cc" />
+    <ClCompile Include="..\..\source\gui\containers\guiGridCtrl.cc" />
     <ClCompile Include="..\..\source\gui\guiArrayCtrl.cc" />
     <ClCompile Include="..\..\source\gui\guiBackgroundCtrl.cc" />
     <ClCompile Include="..\..\source\gui\guiBitmapBorderCtrl.cc" />
@@ -823,6 +824,7 @@
     <ClInclude Include="..\..\source\graphics\TextureHandle.h" />
     <ClInclude Include="..\..\source\graphics\TextureManager.h" />
     <ClInclude Include="..\..\source\graphics\TextureObject.h" />
+    <ClInclude Include="..\..\source\gui\containers\guiGridCtrl.h" />
     <ClInclude Include="..\..\source\gui\guiArrayCtrl.h" />
     <ClInclude Include="..\..\source\gui\guiBackgroundCtrl.h" />
     <ClInclude Include="..\..\source\gui\guiBitmapCtrl.h" />

+ 8 - 2
engine/compilers/VisualStudio 2012/Torque 2D.vcxproj.filters

@@ -1329,6 +1329,9 @@
     <ClCompile Include="..\..\source\persistence\taml\json\tamlJSONParser.cc">
       <Filter>persistence\taml\json</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\source\gui\containers\guiGridCtrl.cc">
+      <Filter>gui\containers</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\source\audio\audio.h">
@@ -2751,12 +2754,15 @@
     <ClInclude Include="..\..\source\persistence\taml\json\tamlJSONParser.h">
       <Filter>persistence\taml\json</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\source\gui\containers\guiGridCtrl.h">
+      <Filter>gui\containers</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\source\sim\simBase_ScriptBinding.h">
       <Filter>sim</Filter>
     </ClInclude>
     <ClInclude Include="..\..\source\console\scriptBinding.h">
-      <Filter>console</Filter>
-    </ClInclude>
+      <Filter>console</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <CustomBuild Include="..\..\source\math\mMath_ASM.asm">

+ 7 - 1
engine/compilers/Xcode/Torque2D.xcodeproj/project.pbxproj

@@ -448,6 +448,7 @@
 		86D770BB1656873C0046D71F /* stringUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86BC815116518D4600D96ADF /* stringUnit.cpp */; };
 		86D770BC1656873C0046D71F /* unicode.cc in Sources */ = {isa = PBXBuildFile; fileRef = 86BC815316518D4600D96ADF /* unicode.cc */; };
 		86D770C3165687450046D71F /* osxFileDialogs.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8609FE3216556F22004662ED /* osxFileDialogs.mm */; };
+		86DE5688171F05F60054CB83 /* guiGridCtrl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 86DE5686171F05F60054CB83 /* guiGridCtrl.cc */; };
 		86EA5B401678C7C700598E68 /* osxCocoaUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 86EA5B3F1678C7C700598E68 /* osxCocoaUtilities.mm */; };
 		86EC5AC7165C1E0100757872 /* osxTorqueView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 86EC5AC6165C1E0100757872 /* osxTorqueView.mm */; };
 /* End PBXBuildFile section */
@@ -1357,6 +1358,8 @@
 		86D76F74165682BF0046D71F /* platformGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platformGL.h; sourceTree = "<group>"; };
 		86D76F76165683240046D71F /* osxOutlineGL.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = osxOutlineGL.cc; sourceTree = "<group>"; };
 		86D76F77165683240046D71F /* osxOutlineGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = osxOutlineGL.h; sourceTree = "<group>"; };
+		86DE5686171F05F60054CB83 /* guiGridCtrl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = guiGridCtrl.cc; sourceTree = "<group>"; };
+		86DE5687171F05F60054CB83 /* guiGridCtrl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = guiGridCtrl.h; sourceTree = "<group>"; };
 		86EA5B3E1678C7C700598E68 /* osxCocoaUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = osxCocoaUtilities.h; sourceTree = "<group>"; };
 		86EA5B3F1678C7C700598E68 /* osxCocoaUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = osxCocoaUtilities.mm; sourceTree = "<group>"; };
 		86EC5AC5165C1E0100757872 /* osxTorqueView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = osxTorqueView.h; sourceTree = "<group>"; };
@@ -2438,6 +2441,8 @@
 		86BC7FE816518D4600D96ADF /* containers */ = {
 			isa = PBXGroup;
 			children = (
+				86DE5686171F05F60054CB83 /* guiGridCtrl.cc */,
+				86DE5687171F05F60054CB83 /* guiGridCtrl.h */,
 				86BC7FE916518D4600D96ADF /* guiAutoScrollCtrl.cc */,
 				86BC7FEA16518D4600D96ADF /* guiAutoScrollCtrl.h */,
 				86BC7FEB16518D4600D96ADF /* guiCtrlArrayCtrl.cc */,
@@ -3386,6 +3391,7 @@
 				2AD4214D17043413005BB8AD /* tamlBinaryReader.cc in Sources */,
 				2AD4214E17043413005BB8AD /* tamlBinaryWriter.cc in Sources */,
 				2ACAFD4A1705CF4A0022601C /* tamlJSONParser.cc in Sources */,
+				86DE5688171F05F60054CB83 /* guiGridCtrl.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -3543,7 +3549,7 @@
 					../../lib/lpng,
 					../../lib/ljpeg,
 					../../lib/lungif,
-					../../source/persistence/rapidjson,
+					../../source/persistence/rapidjson/include,
 					../../source/testing/googleTest,
 					../../source/testing/googleTest/include,
 					"$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Versions/Current/Frameworks/QD.framework/Headers",

+ 1 - 1
engine/compilers/Xcode/Torque2D.xcodeproj/xcshareddata/xcschemes/Torque2D.xcscheme

@@ -44,7 +44,7 @@
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
-      buildConfiguration = "Release"
+      buildConfiguration = "Debug"
       ignoresPersistentStateOnLaunch = "NO"
       debugDocumentVersioning = "YES"
       allowLocationSimulation = "YES">

+ 6 - 0
engine/compilers/Xcode_iOS/Torque2D.xcodeproj/project.pbxproj

@@ -32,6 +32,7 @@
 		2AF1C54B16B439D900C1CF3A /* declaredAssets.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2AF1C54716B439D900C1CF3A /* declaredAssets.cc */; };
 		2AF1C54C16B439D900C1CF3A /* referencedAssets.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2AF1C54916B439D900C1CF3A /* referencedAssets.cc */; };
 		33230F1656FA2C7C493DA2D2 /* guiSliderCtrl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 332307DBC5B7EEEB22E5A736 /* guiSliderCtrl.cc */; };
+		860A196C171F0666000E9FE8 /* guiGridCtrl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 860A196A171F0666000E9FE8 /* guiGridCtrl.cc */; };
 		8610F32F16AEEC670015BCEB /* main.cs in Resources */ = {isa = PBXBuildFile; fileRef = 8610F32D16AEEC670015BCEB /* main.cs */; };
 		8610F33016AEEC670015BCEB /* modules in Resources */ = {isa = PBXBuildFile; fileRef = 8610F32E16AEEC670015BCEB /* modules */; };
 		8652F2A216C1483B00639EFE /* torque2d.png in Resources */ = {isa = PBXBuildFile; fileRef = 8652F2A116C1483B00639EFE /* torque2d.png */; };
@@ -561,6 +562,8 @@
 		2AF1C54A16B439D900C1CF3A /* referencedAssets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = referencedAssets.h; sourceTree = "<group>"; };
 		332307DBC5B7EEEB22E5A736 /* guiSliderCtrl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = guiSliderCtrl.cc; sourceTree = "<group>"; };
 		33230911303CCA4C673E1A22 /* guiSliderCtrl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = guiSliderCtrl.h; sourceTree = "<group>"; };
+		860A196A171F0666000E9FE8 /* guiGridCtrl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = guiGridCtrl.cc; sourceTree = "<group>"; };
+		860A196B171F0666000E9FE8 /* guiGridCtrl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = guiGridCtrl.h; sourceTree = "<group>"; };
 		8610F32D16AEEC670015BCEB /* main.cs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.cs; path = ../../../main.cs; sourceTree = "<group>"; };
 		8610F32E16AEEC670015BCEB /* modules */ = {isa = PBXFileReference; lastKnownFileType = folder; name = modules; path = ../../../modules; sourceTree = "<group>"; };
 		8652F2A116C1483B00639EFE /* torque2d.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = torque2d.png; path = ../torque2d.png; sourceTree = "<group>"; };
@@ -2189,6 +2192,8 @@
 		867BAE4B16AEC9050033868F /* containers */ = {
 			isa = PBXGroup;
 			children = (
+				860A196A171F0666000E9FE8 /* guiGridCtrl.cc */,
+				860A196B171F0666000E9FE8 /* guiGridCtrl.h */,
 				867BAE4C16AEC9050033868F /* guiAutoScrollCtrl.cc */,
 				867BAE4D16AEC9050033868F /* guiAutoScrollCtrl.h */,
 				867BAE4E16AEC9050033868F /* guiCtrlArrayCtrl.cc */,
@@ -3522,6 +3527,7 @@
 				2AD42166170434F0005BB8AD /* tamlJSONReader.cc in Sources */,
 				2AD42167170434F0005BB8AD /* tamlJSONWriter.cc in Sources */,
 				2ACAFD471705CF340022601C /* tamlJSONParser.cc in Sources */,
+				860A196C171F0666000E9FE8 /* guiGridCtrl.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 330 - 0
engine/source/gui/containers/guiGridCtrl.cc

@@ -0,0 +1,330 @@
+#include "gui/containers/guiGridCtrl.h"
+
+//------------------------------------------------------------------------------
+
+IMPLEMENT_CONOBJECT(GuiGridControl);
+
+//------------------------------------------------------------------------------
+
+GuiGridControl::GuiGridControl()
+{
+	mIsContainer = true;
+}
+
+//------------------------------------------------------------------------------
+
+void GuiGridControl::initPersistFields()
+{
+	Parent::initPersistFields();
+
+	addField("Rows",		TypeStringTableEntryVector, Offset(mGridRows, GuiGridControl), "Number of rows in the grid");
+	addField("Columns",     TypeStringTableEntryVector, Offset(mGridCols, GuiGridControl), "Number of columns in the grid");
+}
+
+//------------------------------------------------------------------------------
+
+bool GuiGridControl::onWake()
+{
+	if (!Parent::onWake())
+        return false;
+
+	return true;
+}
+
+//------------------------------------------------------------------------------
+
+void GuiGridControl::onSleep()
+{
+	Parent::onSleep();
+}
+
+//------------------------------------------------------------------------------
+
+void GuiGridControl::inspectPostApply()
+{
+    resize(getPosition(), getExtent());
+}
+
+//------------------------------------------------------------------------------
+
+bool GuiGridControl::IsPointInGridControl(GuiControl* ctrl, const Point2I& pt)
+{
+	if (mRowSizes.size() > 0 && mColSizes.size() > 0)
+	{
+		RectI gridRect = GetGridRect(ctrl);
+		RectI ctrlRect = ctrl->getBounds();
+
+		Point2I chkPt = gridRect.point + ctrlRect.point;
+		Point2I chkBound = chkPt + ctrlRect.extent;
+
+		if (pt.x >= chkPt.x && pt.x <= chkBound.x && pt.y >= chkPt.y && pt.y <= chkBound.y)
+			return true;
+		else
+			return false;
+	}
+	else
+    {
+		return false;
+    }
+
+}
+
+//------------------------------------------------------------------------------
+
+void GuiGridControl::addObject(SimObject *obj)
+{
+	if (mRowSizes.size() <= 0 && mRowSizes.size() <= 0)
+		AdjustGrid(mBounds.extent);
+
+	GuiControl *ctrl = static_cast<GuiControl *>(obj);
+	
+    if (ctrl)
+	{
+		RectI ctrlRect = GetGridRect(ctrl);
+		if (ctrl->getExtent().isZero())
+		{
+			ctrl->setExtent(ctrlRect.extent);
+		}
+		else
+		{
+			if (ctrl->mBounds.extent.x > ctrlRect.extent.x)
+				ctrl->mBounds.extent.x = ctrlRect.extent.x;
+			if (ctrl->mBounds.extent.y > ctrlRect.extent.y)
+				ctrl->mBounds.extent.y = ctrlRect.extent.y;
+		}
+
+		Point2I pt = ctrl->getPosition();
+		mOrginalControlPos.push_back(pt);
+		pt += ctrlRect.point;
+		ctrl->setPosition(pt);
+	}
+
+	Parent::addObject(obj);
+}
+
+//------------------------------------------------------------------------------
+
+void GuiGridControl::removeObject(SimObject *obj)
+{
+	for(int idx =0; idx < objectList.size();idx++)
+	{
+		if ( objectList[idx] == obj )
+		{
+			mOrginalControlPos.erase(idx);
+			break;
+		}
+	}
+
+	Parent::removeObject(obj);
+}
+
+//------------------------------------------------------------------------------
+
+void GuiGridControl::resize(const Point2I &newPosition, const Point2I &newExtent)
+{
+	setUpdate();
+
+	Point2I actualNewExtent = Point2I(  getMax(mMinExtent.x, newExtent.x), getMax(mMinExtent.y, newExtent.y));
+	mBounds.set(newPosition, actualNewExtent);
+
+	bool bFirstResize = false;
+	iterator i;
+	Vector<Point2I> oldCtrlExtent;
+	
+	if (mRowSizes.size() == 0 && mColSizes.size() == 0)
+	{
+		bFirstResize = true;
+	}
+	else
+	{
+		for(i = begin(); i != end(); i++)
+		{
+			GuiControl *ctrl = static_cast<GuiControl *>(*i);
+			if (ctrl)
+			{
+				RectI newRect = GetGridRect(ctrl);		
+				oldCtrlExtent.push_back(newRect.extent);
+			}
+		}
+
+	}
+
+	AdjustGrid(mBounds.extent);
+
+	//resize and position all child controls.
+	int idx = 0;
+	for(i = begin(); i != end(); i++)
+	{
+		GuiControl *ctrl = static_cast<GuiControl *>(*i);
+		if (ctrl)
+		{
+			RectI newRect = GetGridRect(ctrl);		
+			
+			if (ctrl->getExtent().x == 0 && ctrl->getExtent().y == 0)
+				ctrl->setExtent(newRect.extent);
+
+			ctrl->setPosition(mOrginalControlPos[idx] + newRect.point);
+
+			if (bFirstResize)
+			{
+				ctrl->parentResized(newRect.extent, newRect.extent);
+			}
+			else
+			{
+				ctrl->parentResized(oldCtrlExtent[idx++], newRect.extent);
+			}
+		}
+	}
+
+	GuiControl *parent = getParent();
+
+	if (parent)
+		parent->childResized(this);
+
+	setUpdate();
+}
+
+//------------------------------------------------------------------------------
+
+RectI GuiGridControl::GetGridRect(GuiControl* ctrl)
+{
+	S32 col = dAtoi(ctrl->getDataField( StringTable->insert("Col"), NULL));
+	S32 row = dAtoi(ctrl->getDataField( StringTable->insert("Row"), NULL));
+	S32 colSpan = dAtoi(ctrl->getDataField( StringTable->insert("ColSpan"), NULL));
+	S32 rowSpan = dAtoi(ctrl->getDataField( StringTable->insert("RowSpan"), NULL));
+
+	AssertFatal (col < mColSizes.size(), "Col is out of bounds");
+	AssertFatal (row < mRowSizes.size(), "Row is out of bounds");
+
+	if (colSpan < 1)
+        colSpan = 1;
+
+	if (rowSpan < 1)
+        rowSpan = 1;
+
+	RectI newRect(0,0,0,0);
+
+	for(int i = 0; i < col; i++)
+	{
+		newRect.point.x += mColSizes[i];
+	}
+
+	for(int i =col; i < col+colSpan; i++)
+	{
+		newRect.extent.x += mColSizes[i];
+	}
+	
+	for(int i = 0; i < row; i++)
+	{
+		newRect.point.y += mRowSizes[i];
+	}
+
+	for(int i =row; i < row+rowSpan; i++)
+	{
+		newRect.extent.y += mRowSizes[i];
+	}
+
+	return newRect;
+}
+
+//------------------------------------------------------------------------------
+
+void GuiGridControl::AdjustGrid(const Point2I& newExtent)
+{
+	mColSizes.clear();
+	mRowSizes.clear();
+	AdjustGridItems(newExtent.x, mGridCols, mColSizes);
+	AdjustGridItems(newExtent.y, mGridRows, mRowSizes);
+}
+
+//------------------------------------------------------------------------------
+
+void GuiGridControl::AdjustGridItems(S32 size, Vector<StringTableEntry>& strItems, Vector<S32>& items)
+{
+	Vector<GridItem> GridItems;
+	S32 bFoundStar = false;
+	S32 IndexRemaining = -1;
+	S32 totalSize = 0;
+	S32 idx =0;
+
+	//First step : Convert the string based column data into a GridItem vector.
+	for(auto col = strItems.begin(); col != strItems.end(); ++col, idx++)
+	{
+		StringTableEntry str = *col;
+
+		int len = dStrlen(str);
+		AssertFatal(len >= 1, "Item can not be blank.");
+		
+		//we support three types of values (absolute size in pixels, percentage based, and remaining size in pixels).
+		if (str[0] == '*') // use the remaining space left in the columns.
+		{
+			AssertFatal(!bFoundStar, "Can only use one * item field");
+			GridItem gi;
+			gi.IsAbsolute = false;
+			gi.IsPercentage = false;
+			gi.IsRemaining = true;
+			gi.Size = 0;
+			GridItems.push_back(gi);
+		}
+		else if ( len > 1 && str[len-1] == '%' ) //percentage based
+		{
+			char* tmp = new char[len-1];
+			dStrncpy(tmp, str, len-1);
+			int perc = dAtoi(tmp);
+			delete tmp;
+
+			GridItem gi;
+			gi.IsAbsolute = false;
+			gi.IsPercentage = true;
+			gi.IsRemaining = false;
+			gi.Size = perc;
+			GridItems.push_back(gi);
+
+		}
+		else //standard absolute pixel based
+		{
+			int px = dAtoi(str);
+
+			GridItem gi;
+			gi.IsAbsolute = true;
+			gi.IsPercentage = false;
+			gi.IsRemaining = false;
+			gi.Size = px;
+			GridItems.push_back(gi);
+
+			totalSize += px;
+		}
+	}
+
+    //step two: iterate the grid columns again, and fill in any percentage based sizing, and setup the correct grid array.
+	int remainingSize = size - totalSize;
+	int sizeForPerc = remainingSize;
+	for(int i = 0; i < GridItems.size(); ++i)
+	{
+		GridItem gi = GridItems[i];
+
+		if (gi.IsAbsolute)
+		{
+			items.push_back(gi.Size);
+		}
+		else if (gi.IsPercentage)
+		{
+			F32 perc = gi.Size / 100.0f;
+			S32 realSize = sizeForPerc * (S32)perc;
+			remainingSize -= realSize;
+			items.push_back(realSize);
+		}
+		else if(gi.IsRemaining)
+		{
+			//place holder for the moment.
+			items.push_back(0);
+			IndexRemaining = i;
+		}			
+	}
+
+	if (IndexRemaining >= 0)
+	{
+		items[IndexRemaining] = remainingSize;
+		remainingSize = 0;
+	}
+}

+ 55 - 0
engine/source/gui/containers/guiGridCtrl.h

@@ -0,0 +1,55 @@
+#ifndef _GUIGRIDCTRL_H_
+#define _GUIGRIDCTRL_H_
+
+#ifndef _GUICONTROL_H_
+#include "gui/guiControl.h"
+#endif
+
+#include "graphics/dgl.h"
+#include "console/console.h"
+#include "console/consoleTypes.h"
+
+class GuiGridControl : public GuiControl
+{
+private:
+
+    struct GridItem
+	{
+		int Size;
+		bool IsPercentage;
+		bool IsRemaining;
+		bool IsAbsolute;
+	};
+
+private:
+	typedef GuiControl Parent;
+
+	Vector<StringTableEntry> mGridRows;
+	Vector<StringTableEntry> mGridCols;
+
+	Vector<S32> mRowSizes;
+	Vector<S32> mColSizes;
+	Vector<Point2I> mOrginalControlPos;
+
+	void AdjustGrid(const Point2I& newExtent);
+	void AdjustGridItems(S32 size, Vector<StringTableEntry>& strItems, Vector<S32>& items);
+	RectI GetGridRect(GuiControl* ctrl);
+	bool IsPointInGridControl(GuiControl* ctrl, const Point2I& pt);
+
+
+public:
+	GuiGridControl();
+
+	void resize(const Point2I &newPosition, const Point2I &newExtent);
+	void inspectPostApply();
+
+	void addObject(SimObject *obj);
+	void removeObject(SimObject *obj);
+	bool onWake();
+	void onSleep();
+
+	static void initPersistFields();
+	DECLARE_CONOBJECT(GuiGridControl);
+};
+
+#endif // _GUIGRIDCTRL_H_