guiDynamicCtrlArrayCtrl.cpp
Engine/source/gui/containers/guiDynamicCtrlArrayCtrl.cpp
Public Functions
ConsoleDocClass(GuiDynamicCtrlArrayControl , "@brief A container that arranges children into <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">grid.\n\n</a>" "This container maintains <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> 2D grid of GUI controls. If one is added, deleted , " "or resized, then the grid is updated. The insertion order into the grid is " "determined by the internal order of the children(ie. the order of addition).< br >" "Children are added <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the grid by row or column until they fill the assocated " "<a href="/coding/class/classguidynamicctrlarraycontrol/">GuiDynamicCtrlArrayControl</a> extent(width or height). For example, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> " "<a href="/coding/class/classguidynamicctrlarraycontrol/">GuiDynamicCtrlArrayControl</a> with 15 children, and< <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> >fillRowFirst</<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> > set <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> " "true may be arranged as <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">follows:\n\n</a>" "< pre >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "1 2 3 4 5 6\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "7 8 9 10 11 12\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "13 14 15\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "</pre >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "If< <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> >dynamicSize</<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> > were set <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> true in this case, the <a href="/coding/class/classguidynamicctrlarraycontrol/">GuiDynamicCtrlArrayControl</a> " "height would be calculated <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> fit the 3 rows of child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classguidynamicctrlarraycontrol/">GuiDynamicCtrlArrayControl</a>()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " colSize=\"128\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " rowSize = \"18\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " colSpacing = \"2\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " rowSpacing = \"2\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " frozen = \"0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " autoCellSize = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " fillRowFirst = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " dynamicSize = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " padding = \"0 0 0 0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " //Properties not specific <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> this <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> have been omitted from this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example.\n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup GuiContainers" )
DefineEngineMethod(GuiDynamicCtrlArrayControl , refresh , void , () , "Recalculates the position and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1ab7d671599a7b25ca99a487fa341bc33a">size</a> of this <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> and all its children." )
Detailed Description
Public Functions
ConsoleDocClass(GuiDynamicCtrlArrayControl , "@brief A container that arranges children into <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">grid.\n\n</a>" "This container maintains <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> 2D grid of GUI controls. If one is added, deleted , " "or resized, then the grid is updated. The insertion order into the grid is " "determined by the internal order of the children(ie. the order of addition).< br >" "Children are added <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the grid by row or column until they fill the assocated " "<a href="/coding/class/classguidynamicctrlarraycontrol/">GuiDynamicCtrlArrayControl</a> extent(width or height). For example, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> " "<a href="/coding/class/classguidynamicctrlarraycontrol/">GuiDynamicCtrlArrayControl</a> with 15 children, and< <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> >fillRowFirst</<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> > set <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> " "true may be arranged as <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">follows:\n\n</a>" "< pre >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "1 2 3 4 5 6\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "7 8 9 10 11 12\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "13 14 15\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "</pre >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "If< <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> >dynamicSize</<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> > were set <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> true in this case, the <a href="/coding/class/classguidynamicctrlarraycontrol/">GuiDynamicCtrlArrayControl</a> " "height would be calculated <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> fit the 3 rows of child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "<a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classguidynamicctrlarraycontrol/">GuiDynamicCtrlArrayControl</a>()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " colSize=\"128\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " rowSize = \"18\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " colSpacing = \"2\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " rowSpacing = \"2\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " frozen = \"0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " autoCellSize = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " fillRowFirst = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " dynamicSize = \"1\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " padding = \"0 0 0 0\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " //Properties not specific <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> this <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> have been omitted from this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example.\n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup GuiContainers" )
DefineEngineMethod(GuiDynamicCtrlArrayControl , refresh , void , () , "Recalculates the position and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1ab7d671599a7b25ca99a487fa341bc33a">size</a> of this <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> and all its children." )
IMPLEMENT_CONOBJECT(GuiDynamicCtrlArrayControl )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "console/engineAPI.h" 25#include "platform/platform.h" 26#include "gui/containers/guiDynamicCtrlArrayCtrl.h" 27 28 29GuiDynamicCtrlArrayControl::GuiDynamicCtrlArrayControl() 30{ 31 mCols = 0; 32 mColSize = 64; 33 mRows = 0; 34 mRowSize = 64; 35 mRowSpacing = 0; 36 mColSpacing = 0; 37 mIsContainer = true; 38 39 mResizing = false; 40 41 mSizeToChildren = false; 42 mAutoCellSize = false; 43 44 mFrozen = false; 45 mDynamicSize = false; 46 mFillRowFirst = true; 47 48 mPadding.set( 0, 0, 0, 0 ); 49} 50 51GuiDynamicCtrlArrayControl::~GuiDynamicCtrlArrayControl() 52{ 53} 54 55IMPLEMENT_CONOBJECT(GuiDynamicCtrlArrayControl); 56 57ConsoleDocClass( GuiDynamicCtrlArrayControl, 58 "@brief A container that arranges children into a grid.\n\n" 59 60 "This container maintains a 2D grid of GUI controls. If one is added, deleted, " 61 "or resized, then the grid is updated. The insertion order into the grid is " 62 "determined by the internal order of the children (ie. the order of addition).<br>" 63 64 "Children are added to the grid by row or column until they fill the assocated " 65 "GuiDynamicCtrlArrayControl extent (width or height). For example, a " 66 "GuiDynamicCtrlArrayControl with 15 children, and <i>fillRowFirst</i> set to " 67 "true may be arranged as follows:\n\n" 68 69 "<pre>\n" 70 "1 2 3 4 5 6\n" 71 "7 8 9 10 11 12\n" 72 "13 14 15\n" 73 "</pre>\n" 74 75 "If <i>dynamicSize</i> were set to true in this case, the GuiDynamicCtrlArrayControl " 76 "height would be calculated to fit the 3 rows of child controls.\n\n" 77 78 "@tsexample\n" 79 "new GuiDynamicCtrlArrayControl()\n" 80 "{\n" 81 " colSize = \"128\";\n" 82 " rowSize = \"18\";\n" 83 " colSpacing = \"2\";\n" 84 " rowSpacing = \"2\";\n" 85 " frozen = \"0\";\n" 86 " autoCellSize = \"1\";\n" 87 " fillRowFirst = \"1\";\n" 88 " dynamicSize = \"1\";\n" 89 " padding = \"0 0 0 0\";\n" 90 " //Properties not specific to this control have been omitted from this example.\n" 91 "};\n" 92 "@endtsexample\n\n" 93 94 "@ingroup GuiContainers" 95); 96 97// ConsoleObject... 98 99void GuiDynamicCtrlArrayControl::initPersistFields() 100{ 101 addField( "colCount", TypeS32, Offset( mCols, GuiDynamicCtrlArrayControl ), 102 "Number of columns the child controls have been arranged into. This " 103 "value is calculated automatically when children are added, removed or " 104 "resized; writing it directly has no effect." ); 105 106 addField( "colSize", TypeS32, Offset( mColSize, GuiDynamicCtrlArrayControl ), 107 "Width of each column. If <i>autoCellSize</i> is set, this will be " 108 "calculated automatically from the widest child control" ); 109 110 addField( "rowCount", TypeS32, Offset( mRows, GuiDynamicCtrlArrayControl ), 111 "Number of rows the child controls have been arranged into. This value " 112 "is calculated automatically when children are added, removed or resized; " 113 "writing it directly has no effect." ); 114 115 addField( "rowSize", TypeS32, Offset( mRowSize, GuiDynamicCtrlArrayControl ), 116 "Height of each row. If <i>autoCellSize</i> is set, this will be " 117 "calculated automatically from the tallest child control" ); 118 119 addField( "rowSpacing", TypeS32, Offset( mRowSpacing, GuiDynamicCtrlArrayControl ), 120 "Spacing between rows" ); 121 122 addField( "colSpacing", TypeS32, Offset( mColSpacing, GuiDynamicCtrlArrayControl ), 123 "Spacing between columns" ); 124 125 addField( "frozen", TypeBool, Offset( mFrozen, GuiDynamicCtrlArrayControl ), 126 "When true, the array will not update when new children are added or in " 127 "response to child resize events. This is useful to prevent unnecessary " 128 "resizing when adding, removing or resizing a number of child controls." ); 129 130 addField( "autoCellSize", TypeBool, Offset( mAutoCellSize, GuiDynamicCtrlArrayControl ), 131 "When true, the cell size is set to the widest/tallest child control." ); 132 133 addField( "fillRowFirst", TypeBool, Offset( mFillRowFirst, GuiDynamicCtrlArrayControl ), 134 "Controls whether rows or columns are filled first.\n\nIf true, controls are " 135 "added to the grid left-to-right (to fill a row); then rows are added " 136 "top-to-bottom as shown below:\n" 137 "<pre>1 2 3 4\n" 138 "5 6 7 8</pre>\n" 139 "If false, controls are added to the grid top-to-bottom (to fill a column); " 140 "then columns are added left-to-right as shown below:\n" 141 "<pre>1 3 5 7\n" 142 "2 4 6 8</pre>" ); 143 144 addField( "dynamicSize", TypeBool, Offset( mDynamicSize, GuiDynamicCtrlArrayControl ), 145 "If true, the width or height of this control will be automatically " 146 "calculated based on the number of child controls (width if " 147 "<i>fillRowFirst</i> is false, height if <i>fillRowFirst</i> is true)." ); 148 149 addField( "padding", TypeRectSpacingI, Offset( mPadding, GuiDynamicCtrlArrayControl ), 150 "Padding around the top, bottom, left, and right of this control. This " 151 "reduces the area available for child controls." ); 152 153 Parent::initPersistFields(); 154} 155 156 157// SimObject... 158 159void GuiDynamicCtrlArrayControl::inspectPostApply() 160{ 161 resize(getPosition(), getExtent()); 162 Parent::inspectPostApply(); 163} 164 165 166// SimSet... 167 168void GuiDynamicCtrlArrayControl::addObject(SimObject *obj) 169{ 170 Parent::addObject(obj); 171 172 if ( !mFrozen ) 173 refresh(); 174} 175 176 177// GuiControl... 178 179bool GuiDynamicCtrlArrayControl::resize(const Point2I &newPosition, const Point2I &newExtent) 180{ 181 if ( size() == 0 ) 182 return Parent::resize( newPosition, newExtent ); 183 184 if ( mResizing ) 185 return false; 186 187 mResizing = true; 188 189 // Calculate the cellSize based on our widest/tallest child control 190 // if the flag to do so is set. 191 if ( mAutoCellSize ) 192 { 193 mColSize = 1; 194 mRowSize = 1; 195 196 for ( U32 i = 0; i < size(); i++ ) 197 { 198 GuiControl *child = dynamic_cast<GuiControl*>(operator [](i)); 199 if ( child && child->isVisible() ) 200 { 201 if ( mColSize < child->getWidth() ) 202 mColSize = child->getWidth(); 203 if ( mRowSize < child->getHeight() ) 204 mRowSize = child->getHeight(); 205 } 206 } 207 } 208 209 // Count number of visible, children guiControls. 210 S32 numChildren = 0; 211 for ( U32 i = 0; i < size(); i++ ) 212 { 213 GuiControl *child = dynamic_cast<GuiControl*>(operator [](i)); 214 if ( child && child->isVisible() ) 215 numChildren++; 216 } 217 218 // Calculate number of rows and columns. 219 if ( !mFillRowFirst ) 220 { 221 mRows = 1; 222 while ( ( ( mRows + 1 ) * mRowSize + mRows * mRowSpacing ) <= ( newExtent.y - ( mPadding.top + mPadding.bottom ) ) ) 223 mRows++; 224 225 mCols = numChildren / mRows; 226 if ( numChildren % mRows > 0 ) 227 mCols++; 228 } 229 else 230 { 231 mCols = 1; 232 while ( ( ( mCols + 1 ) * mColSize + mCols * mColSpacing ) <= ( newExtent.x - ( mPadding.left + mPadding.right ) ) ) 233 mCols++; 234 235 mRows = numChildren / mCols; 236 if ( numChildren % mCols > 0 ) 237 mRows++; 238 } 239 240 // Place each child... 241 S32 childcount = 0; 242 for ( S32 i = 0; i < size(); i++ ) 243 { 244 // Place control 245 GuiControl *gc = dynamic_cast<GuiControl*>(operator [](i)); 246 247 // Added check if child is visible. Invisible children don't take part 248 if ( gc && gc->isVisible() ) 249 { 250 S32 curCol, curRow; 251 252 // Get the current column and row... 253 if ( mFillRowFirst ) 254 { 255 curCol = childcount % mCols; 256 curRow = childcount / mCols; 257 } 258 else 259 { 260 curCol = childcount / mRows; 261 curRow = childcount % mRows; 262 } 263 264 // Reposition and resize 265 Point2I newPos( mPadding.left + curCol * ( mColSize + mColSpacing ), mPadding.top + curRow * ( mRowSize + mRowSpacing ) ); 266 gc->resize( newPos, Point2I( mColSize, mRowSize ) ); 267 268 childcount++; 269 } 270 } 271 272 Point2I realExtent( newExtent ); 273 274 if ( mDynamicSize ) 275 { 276 if ( mFillRowFirst ) 277 realExtent.y = mRows * mRowSize + ( mRows - 1 ) * mRowSpacing + ( mPadding.top + mPadding.bottom ); 278 else 279 realExtent.x = mCols * mColSize + ( mCols - 1 ) * mColSpacing + ( mPadding.left + mPadding.right ); 280 } 281 282 mResizing = false; 283 284 return Parent::resize( newPosition, realExtent ); 285} 286 287void GuiDynamicCtrlArrayControl::childResized(GuiControl *child) 288{ 289 Parent::childResized(child); 290 291 if ( !mFrozen ) 292 refresh(); 293} 294 295void GuiDynamicCtrlArrayControl::refresh() 296{ 297 resize( getPosition(), getExtent() ); 298} 299 300DefineEngineMethod( GuiDynamicCtrlArrayControl, refresh, void, (),, 301 "Recalculates the position and size of this control and all its children." ) 302{ 303 object->refresh(); 304} 305