Browse Source

- Updated the formatting for the guiGridCtrl source to coincide with the coding standard used in other parts of the engine.

MichPerry-GG 12 years ago
parent
commit
fa975ba44d

+ 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" />
@@ -822,6 +823,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 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,6 +2754,9 @@
     <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>
   </ItemGroup>
   <ItemGroup>
     <CustomBuild Include="..\..\source\math\mMath_ASM.asm">

+ 46 - 18
engine/source/gui/containers/guiGridCtrl.cc

@@ -1,40 +1,52 @@
 #include "gui/containers/guiGridCtrl.h"
 
+//------------------------------------------------------------------------------
+
 IMPLEMENT_CONOBJECT(GuiGridControl);
 
+//------------------------------------------------------------------------------
+
 GuiGridControl::GuiGridControl()
 {
 	mIsContainer = true;
 }
 
+//------------------------------------------------------------------------------
+
 void GuiGridControl::initPersistFields()
 {
 	Parent::initPersistFields();
 
-	addField("Rows",		TypeStringTableEntryVector, Offset(mGridRows, GuiGridControl));
-	addField("Columns",     TypeStringTableEntryVector, Offset(mGridCols, GuiGridControl));
-
+	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;
+	if (!Parent::onWake())
+        return false;
 
 	return true;
 }
 
+//------------------------------------------------------------------------------
+
 void GuiGridControl::onSleep()
 {
 	Parent::onSleep();
 }
 
+//------------------------------------------------------------------------------
 
 void GuiGridControl::inspectPostApply()
 {
-	resize(getPosition(), getExtent());
+    resize(getPosition(), getExtent());
 }
 
+//------------------------------------------------------------------------------
+
 bool GuiGridControl::IsPointInGridControl(GuiControl* ctrl, const Point2I& pt)
 {
 	if (mRowSizes.size() > 0 && mColSizes.size() > 0)
@@ -45,24 +57,28 @@ bool GuiGridControl::IsPointInGridControl(GuiControl* ctrl, const Point2I& pt)
 		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)
+		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)
+	
+    if (ctrl)
 	{
 		RectI ctrlRect = GetGridRect(ctrl);
 		if (ctrl->getExtent().isZero())
@@ -86,6 +102,8 @@ void GuiGridControl::addObject(SimObject *obj)
 	Parent::addObject(obj);
 }
 
+//------------------------------------------------------------------------------
+
 void GuiGridControl::removeObject(SimObject *obj)
 {
 	for(int idx =0; idx < objectList.size();idx++)
@@ -100,13 +118,13 @@ void GuiGridControl::removeObject(SimObject *obj)
 	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));
+	Point2I actualNewExtent = Point2I(  getMax(mMinExtent.x, newExtent.x), getMax(mMinExtent.y, newExtent.y));
 	mBounds.set(newPosition, actualNewExtent);
 
 	bool bFirstResize = false;
@@ -134,7 +152,7 @@ void GuiGridControl::resize(const Point2I &newPosition, const Point2I &newExtent
 	AdjustGrid(mBounds.extent);
 
 	//resize and position all child controls.
-	int idx=0;
+	int idx = 0;
 	for(i = begin(); i != end(); i++)
 	{
 		GuiControl *ctrl = static_cast<GuiControl *>(*i);
@@ -159,13 +177,15 @@ void GuiGridControl::resize(const Point2I &newPosition, const Point2I &newExtent
 	}
 
 	GuiControl *parent = getParent();
+
 	if (parent)
 		parent->childResized(this);
 
 	setUpdate();
-
 }
 
+//------------------------------------------------------------------------------
+
 RectI GuiGridControl::GetGridRect(GuiControl* ctrl)
 {
 	S32 col = dAtoi(ctrl->getDataField( StringTable->insert("Col"), NULL));
@@ -176,8 +196,11 @@ RectI GuiGridControl::GetGridRect(GuiControl* ctrl)
 	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;
+	if (colSpan < 1)
+        colSpan = 1;
+
+	if (rowSpan < 1)
+        rowSpan = 1;
 
 	RectI newRect(0,0,0,0);
 
@@ -185,6 +208,7 @@ RectI GuiGridControl::GetGridRect(GuiControl* ctrl)
 	{
 		newRect.point.x += mColSizes[i];
 	}
+
 	for(int i =col; i < col+colSpan; i++)
 	{
 		newRect.extent.x += mColSizes[i];
@@ -194,6 +218,7 @@ RectI GuiGridControl::GetGridRect(GuiControl* ctrl)
 	{
 		newRect.point.y += mRowSizes[i];
 	}
+
 	for(int i =row; i < row+rowSpan; i++)
 	{
 		newRect.extent.y += mRowSizes[i];
@@ -202,6 +227,8 @@ RectI GuiGridControl::GetGridRect(GuiControl* ctrl)
 	return newRect;
 }
 
+//------------------------------------------------------------------------------
+
 void GuiGridControl::AdjustGrid(const Point2I& newExtent)
 {
 	mColSizes.clear();
@@ -210,6 +237,8 @@ void GuiGridControl::AdjustGrid(const Point2I& newExtent)
 	AdjustGridItems(newExtent.y, mGridRows, mRowSizes);
 }
 
+//------------------------------------------------------------------------------
+
 void GuiGridControl::AdjustGridItems(S32 size, Vector<StringTableEntry>& strItems, Vector<S32>& items)
 {
 	Vector<GridItem> GridItems;
@@ -218,7 +247,6 @@ void GuiGridControl::AdjustGridItems(S32 size, Vector<StringTableEntry>& strItem
 	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++)
 	{
@@ -268,7 +296,7 @@ void GuiGridControl::AdjustGridItems(S32 size, Vector<StringTableEntry>& strItem
 		}
 	}
 
-	//step two: iterate the grid columns again, and fill in any percentage based sizing, and setup the correct grid array.
+    //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)
@@ -282,7 +310,7 @@ void GuiGridControl::AdjustGridItems(S32 size, Vector<StringTableEntry>& strItem
 		else if (gi.IsPercentage)
 		{
 			F32 perc = gi.Size / 100.0f;
-			S32 realSize = sizeForPerc * perc;
+			S32 realSize = sizeForPerc * (S32)perc;
 			remainingSize -= realSize;
 			items.push_back(realSize);
 		}

+ 1 - 1
engine/source/gui/containers/guiGridCtrl.h

@@ -13,7 +13,7 @@ class GuiGridControl : public GuiControl
 {
 private:
 
-	struct GridItem
+    struct GridItem
 	{
 		int Size;
 		bool IsPercentage;