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

Method alignFix

src/eepp/ui/uitextview.cpp:402–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

400}
401
402void UITextView::alignFix() {
403 switch ( Font::getHorizontalAlign( getFlags() ) ) {
404 case UI_HALIGN_CENTER:
405 mRealAlignOffset.x =
406 (Float)( (Int32)( ( mSize.x - mPaddingPx.Left - mPaddingPx.Right ) * 0.5f -
407 getTextWidth() * 0.5f ) );
408 break;
409 case UI_HALIGN_RIGHT:
410 mRealAlignOffset.x =
411 ( (Float)mSize.x - mPaddingPx.Left - mPaddingPx.Right - (Float)getTextWidth() );
412 break;
413 case UI_HALIGN_LEFT:
414 mRealAlignOffset.x = 0;
415 break;
416 }
417
418 switch ( Font::getVerticalAlign( getFlags() ) ) {
419 case UI_VALIGN_CENTER: {
420 Float height = mSize.y - mPaddingPx.Top - mPaddingPx.Bottom;
421 Float fontSize = mTextCache.getCharacterSize();
422 Float lineSpacing = mTextCache.getFont()->getLineSpacing( fontSize );
423 Float center = eefloor( ( lineSpacing - fontSize ) * 0.5f );
424 Float textHeight = mTextCache.getTextHeight();
425 mRealAlignOffset.y = eefloor( ( height - textHeight + center ) * 0.5f );
426 break;
427 }
428 case UI_VALIGN_BOTTOM:
429 mRealAlignOffset.y =
430 ( (Float)mSize.y - mPaddingPx.Top - mPaddingPx.Bottom -
431 (Float)mTextCache.getFont()->getAscent( mTextCache.getCharacterSize() ) );
432 break;
433 case UI_VALIGN_TOP:
434 mRealAlignOffset.y = 0;
435 break;
436 }
437}
438
439Uint32 UITextView::onFocusLoss() {
440 UIWidget::onFocusLoss();

Callers

nothing calls this directly

Calls 8

getHorizontalAlignFunction · 0.85
getTextWidthFunction · 0.85
getVerticalAlignFunction · 0.85
getAscentMethod · 0.80
getCharacterSizeMethod · 0.45
getLineSpacingMethod · 0.45
getFontMethod · 0.45
getTextHeightMethod · 0.45

Tested by

no test coverage detected