| 221 | } |
| 222 | |
| 223 | void GuiStackControl::stackVertical(bool fromTop) |
| 224 | { |
| 225 | if( empty() ) |
| 226 | return; |
| 227 | |
| 228 | S32 begin, end, step; |
| 229 | if ( fromTop ) |
| 230 | { |
| 231 | // Stack from Child0 at top to ChildN at bottom |
| 232 | begin = 0; |
| 233 | end = size(); |
| 234 | step = 1; |
| 235 | } |
| 236 | else |
| 237 | { |
| 238 | // Stack from ChildN at top to Child0 at bottom |
| 239 | begin = size()-1; |
| 240 | end = -1; |
| 241 | step = -1; |
| 242 | } |
| 243 | |
| 244 | // Place each visible child control |
| 245 | S32 maxWidth = 0; |
| 246 | Point2I curPos(0, 0); |
| 247 | for ( S32 i = begin; i != end; i += step ) |
| 248 | { |
| 249 | GuiControl * gc = dynamic_cast<GuiControl*>( at(i) ); |
| 250 | if ( gc && gc->isVisible() ) |
| 251 | { |
| 252 | // Add padding between controls |
| 253 | if ( curPos.y > 0 ) |
| 254 | curPos.y += mPadding; |
| 255 | |
| 256 | Point2I childPos = curPos; |
| 257 | if ( !mChangeChildPosition ) |
| 258 | childPos.x = gc->getLeft(); |
| 259 | |
| 260 | Point2I childSize( gc->getExtent() ); |
| 261 | if ( mChangeChildSizeToFit ) |
| 262 | childSize.x = getWidth(); |
| 263 | |
| 264 | gc->resize( childPos, childSize ); |
| 265 | |
| 266 | curPos.y += gc->getHeight(); |
| 267 | maxWidth = getMax( maxWidth, childPos.x + childSize.x ); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | if ( mDynamicSize ) |
| 272 | { |
| 273 | // Conform our size to the sum of the child sizes. |
| 274 | Point2I newPos( getPosition() ); |
| 275 | Point2I newSize( mDynamicNonStackExtent ? maxWidth : getWidth(), curPos.y ); |
| 276 | |
| 277 | newSize.setMax( getMinExtent() ); |
| 278 | |
| 279 | // Grow the stack up instead of down? |
| 280 | if ( mDynamicPos ) |
nothing calls this directly
no test coverage detected