| 357 | } |
| 358 | |
| 359 | void UITextView::onAutoSize() { |
| 360 | bool sizeChanged = false; |
| 361 | |
| 362 | if ( ( mFlags & UI_AUTO_SIZE && 0 == getSize().getWidth() ) ) { |
| 363 | setInternalPixelsSize( Sizef( getTextWidth(), mTextCache.getTextHeight() ) ); |
| 364 | sizeChanged = true; |
| 365 | } |
| 366 | |
| 367 | if ( mWidthPolicy == SizePolicy::WrapContent ) { |
| 368 | Float totW = (int)getTextWidth() + mPaddingPx.Left + mPaddingPx.Right; |
| 369 | |
| 370 | if ( !getMaxWidthEq().empty() ) { |
| 371 | Float oldW = totW; |
| 372 | totW = eemin( totW, getMaxSizePx().getWidth() ); |
| 373 | if ( oldW != totW ) |
| 374 | setClipType( ClipType::ContentBox ); |
| 375 | } |
| 376 | if ( mSize.x != totW ) { |
| 377 | setInternalPixelsWidth( totW ); |
| 378 | sizeChanged = true; |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | if ( mHeightPolicy == SizePolicy::WrapContent ) { |
| 383 | Float totH = (int)mTextCache.getTextHeight() + mPaddingPx.Top + mPaddingPx.Bottom; |
| 384 | if ( !getMaxHeightEq().empty() ) { |
| 385 | Float oldH = totH; |
| 386 | totH = eemin( totH, getMaxSizePx().getHeight() ); |
| 387 | if ( oldH != totH ) |
| 388 | setClipType( ClipType::ContentBox ); |
| 389 | } |
| 390 | if ( mSize.y != totH ) { |
| 391 | setInternalPixelsHeight( totH ); |
| 392 | sizeChanged = true; |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | if ( sizeChanged ) { |
| 397 | updateTextOverflow(); |
| 398 | notifyLayoutAttrChange(); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | void UITextView::alignFix() { |
| 403 | switch ( Font::getHorizontalAlign( getFlags() ) ) { |
nothing calls this directly
no test coverage detected