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

Method defaultTooltipRender

Engine/source/gui/core/guiControl.cpp:454–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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