MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / defaultTooltipRender

Method defaultTooltipRender

Engine/source/gui/core/guiControl.cpp:461–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

459//-----------------------------------------------------------------------------
460
461bool GuiControl::defaultTooltipRender( const Point2I &hoverPos, const Point2I &cursorPos, const char* tipText )
462{
463 // Short Circuit.
464 if (!mAwake)
465 return false;
466
467 if ( dStrlen( mTooltip ) == 0 && ( tipText == NULL || dStrlen( tipText ) == 0 ) )
468 return false;
469
470 String renderTip( mTooltip );
471 if ( tipText != NULL )
472 renderTip = tipText;
473
474 // Need to have root.
475 GuiCanvas *root = getRoot();
476 if ( !root )
477 return false;
478
479 GFont *font = mTooltipProfile->mFont;
480
481 GFXDrawUtil* drawUtil = GFX->getDrawUtil();
482
483 // Support for multi-line tooltip text...
484
485 Vector<U32> startLineOffsets, lineLengths;
486
487 font->wrapString( renderTip, U32_MAX, startLineOffsets, lineLengths );
488
489 // The width is the longest line.
490 U32 tipWidth = 0;
491 for ( U32 i = 0; i < lineLengths.size(); i++ )
492 {
493 U32 width = font->getStrNWidth( renderTip.c_str() + startLineOffsets[i], lineLengths[i] );
494
495 if ( width > tipWidth )
496 tipWidth = width;
497 }
498
499 // The height is the number of lines times the height of the font.
500 U32 tipHeight = lineLengths.size() * font->getHeight();
501
502 // Vars used:
503 // Screensize (for position check)
504 // Offset to get position of cursor
505 // textBounds for text extent.
506 Point2I screensize = getRoot()->getWindowSize();
507 Point2I offset = hoverPos;
508 Point2I textBounds;
509
510 // Offset below cursor image
511 offset.y += 20; // TODO: Attempt to fix?: root->getCursorExtent().y;
512
513 // Create text bounds...
514
515 // Pixels above/below the text
516 const U32 vMargin = 2;
517 // Pixels left/right of the text
518 const U32 hMargin = 4;

Callers

nothing calls this directly

Calls 13

getDrawUtilMethod · 0.80
wrapStringMethod · 0.80
getStrNWidthMethod · 0.80
drawRectFillMethod · 0.80
drawRectMethod · 0.80
setBitmapModulationMethod · 0.80
drawTextNMethod · 0.80
dStrlenFunction · 0.50
sizeMethod · 0.45
c_strMethod · 0.45
getHeightMethod · 0.45
getWindowSizeMethod · 0.45

Tested by

no test coverage detected