| 283 | } |
| 284 | |
| 285 | void UILinearLayout::packHorizontal() { |
| 286 | if ( mPacking ) |
| 287 | return; |
| 288 | mPacking = true; |
| 289 | bool sizeChanged = false; |
| 290 | Sizef size( getPixelsSize() ); |
| 291 | |
| 292 | if ( getLayoutWidthPolicy() == SizePolicy::MatchParent ) { |
| 293 | Float w = getMatchParentWidth(); |
| 294 | |
| 295 | if ( (int)w != (int)getPixelsSize().getWidth() ) { |
| 296 | sizeChanged = true; |
| 297 | size.setWidth( w ); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | if ( getLayoutHeightPolicy() == SizePolicy::MatchParent && 0 == getLayoutWeight() ) { |
| 302 | Float h = getMatchParentHeight(); |
| 303 | |
| 304 | if ( (int)h != (int)getPixelsSize().getHeight() ) { |
| 305 | sizeChanged = true; |
| 306 | size.setHeight( h ); |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | if ( sizeChanged ) |
| 311 | setInternalPixelsSize( size ); |
| 312 | |
| 313 | applyHeightPolicyOnChildren(); |
| 314 | |
| 315 | Float curX = mPaddingPx.Left; |
| 316 | Float maxY = 0; |
| 317 | Sizei freeSize = getTotalUsedSize(); |
| 318 | |
| 319 | Node* child = mChild; |
| 320 | |
| 321 | while ( NULL != child ) { |
| 322 | if ( child->isWidget() && child->isVisible() ) { |
| 323 | UIWidget* widget = static_cast<UIWidget*>( child ); |
| 324 | Rectf margin = widget->getLayoutPixelsMargin(); |
| 325 | |
| 326 | curX += eeceil( margin.Left ); |
| 327 | |
| 328 | Vector2f pos( curX, mPaddingPx.Top ); |
| 329 | |
| 330 | if ( widget->getLayoutWeight() != 0 ) { |
| 331 | Float totSize = |
| 332 | ( getLayoutWidthPolicy() == SizePolicy::MatchParent || |
| 333 | getLayoutWidthPolicy() == SizePolicy::Fixed ) |
| 334 | ? getPixelsSize().getWidth() - mPaddingPx.Left - mPaddingPx.Right |
| 335 | : getParent()->getPixelsSize().getWidth() - mLayoutMarginPx.Right - |
| 336 | mLayoutMarginPx.Left - mPaddingPx.Left - mPaddingPx.Right; |
| 337 | Float newSize = eemax( |
| 338 | eeceil( totSize - freeSize.getWidth() ) * widget->getLayoutWeight(), 0.f ); |
| 339 | |
| 340 | widget->setPixelsSize( newSize, widget->getPixelsSize().getHeight() ); |
| 341 | } |
| 342 |
nothing calls this directly
no test coverage detected