MCPcopy Create free account
hub / github.com/SpartanJ/eepp / onAutoSize

Method onAutoSize

src/eepp/ui/uitextview.cpp:359–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357}
358
359void 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
402void UITextView::alignFix() {
403 switch ( Font::getHorizontalAlign( getFlags() ) ) {

Callers

nothing calls this directly

Calls 6

getTextWidthFunction · 0.85
eeminFunction · 0.85
getWidthMethod · 0.45
getTextHeightMethod · 0.45
emptyMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected