| 171 | } |
| 172 | |
| 173 | void UILinearLayout::packVertical() { |
| 174 | if ( mPacking ) |
| 175 | return; |
| 176 | mPacking = true; |
| 177 | setMatchParentIfNeededVerticalGrowth(); |
| 178 | |
| 179 | applyWidthPolicyOnChildren(); |
| 180 | |
| 181 | Float curY = mPaddingPx.Top; |
| 182 | Float maxX = 0; |
| 183 | Sizei freeSize = getTotalUsedSize(); |
| 184 | |
| 185 | Node* child = mChild; |
| 186 | |
| 187 | while ( NULL != child ) { |
| 188 | if ( child->isWidget() && child->isVisible() ) { |
| 189 | UIWidget* widget = child->asType<UIWidget>(); |
| 190 | Rectf margin = widget->getLayoutPixelsMargin(); |
| 191 | |
| 192 | curY += eeceil( margin.Top ); |
| 193 | |
| 194 | Vector2f pos( mPaddingPx.Left, curY ); |
| 195 | |
| 196 | if ( widget->getLayoutWeight() != 0 ) { |
| 197 | Float totSize = |
| 198 | ( getLayoutHeightPolicy() == SizePolicy::MatchParent || |
| 199 | getLayoutHeightPolicy() == SizePolicy::Fixed ) |
| 200 | ? getPixelsSize().getHeight() - mPaddingPx.Top - mPaddingPx.Bottom |
| 201 | : getParent()->getPixelsSize().getHeight() - mLayoutMarginPx.Bottom - |
| 202 | mLayoutMarginPx.Top - mPaddingPx.Top - mPaddingPx.Bottom; |
| 203 | Float newSize = eemax( |
| 204 | eeceil( totSize - freeSize.getHeight() ) * widget->getLayoutWeight(), 0.f ); |
| 205 | |
| 206 | widget->setPixelsSize( widget->getPixelsSize().getWidth(), newSize ); |
| 207 | } |
| 208 | |
| 209 | switch ( Font::getHorizontalAlign( widget->getLayoutGravity() ) ) { |
| 210 | case UI_HALIGN_CENTER: |
| 211 | pos.x = ( getPixelsSize().getWidth() - mPaddingPx.Left - mPaddingPx.Right - |
| 212 | widget->getPixelsSize().getWidth() ) / |
| 213 | 2; |
| 214 | break; |
| 215 | case UI_HALIGN_RIGHT: |
| 216 | pos.x = getPixelsSize().getWidth() - mPaddingPx.Left - mPaddingPx.Right - |
| 217 | widget->getPixelsSize().getWidth() - |
| 218 | widget->getLayoutPixelsMargin().Right; |
| 219 | break; |
| 220 | case UI_HALIGN_LEFT: |
| 221 | default: |
| 222 | pos.x = widget->getLayoutPixelsMargin().Left + mPaddingPx.Left; |
| 223 | break; |
| 224 | } |
| 225 | |
| 226 | widget->setPixelsPosition( pos ); |
| 227 | |
| 228 | curY += eeceil( widget->getPixelsSize().getHeight() + margin.Bottom ); |
| 229 | |
| 230 | if ( widget->getLayoutWidthPolicy() != SizePolicy::MatchParent ) { |
nothing calls this directly
no test coverage detected