| 939 | } |
| 940 | |
| 941 | bool GuiParticleGraphCtrl::renderGraphTooltip(Point2I cursorPos, StringTableEntry tooltip) |
| 942 | { |
| 943 | // Short Circuit. |
| 944 | if (!mAwake) |
| 945 | return false; |
| 946 | if ( dStrlen( tooltip ) == 0 ) |
| 947 | return false; |
| 948 | |
| 949 | // Need to have root. |
| 950 | GuiCanvas *root = getRoot(); |
| 951 | if ( !root ) |
| 952 | return false; |
| 953 | |
| 954 | if (!mTooltipProfile) |
| 955 | setTooltipProfile( mProfile ); |
| 956 | |
| 957 | GFont *font = mTooltipProfile->mFont; |
| 958 | |
| 959 | // Fetch Canvas. |
| 960 | GuiCanvas *pCanvas = getRoot(); |
| 961 | |
| 962 | //Vars used: |
| 963 | //Screensize (for position check) |
| 964 | //Offset to get position of cursor |
| 965 | //textBounds for text extent. |
| 966 | Point2I screensize = pCanvas->getWindowSize(); |
| 967 | Point2I offset = cursorPos; |
| 968 | Point2I textBounds; |
| 969 | S32 textWidth = font->getStrWidth(tooltip); |
| 970 | |
| 971 | //Offset below cursor image |
| 972 | offset.y -= root->getCursorExtent().y; |
| 973 | //Create text bounds. |
| 974 | textBounds.x = textWidth+8; |
| 975 | textBounds.y = font->getHeight() + 4; |
| 976 | |
| 977 | // Check position/width to make sure all of the tooltip will be rendered |
| 978 | // 5 is given as a buffer against the edge |
| 979 | if (screensize.x < offset.x + textBounds.x + 5) |
| 980 | offset.x = screensize.x - textBounds.x - 5; |
| 981 | |
| 982 | // And ditto for the height |
| 983 | if(screensize.y < offset.y + textBounds.y + 5) |
| 984 | offset.y = cursorPos.y - textBounds.y - 5; |
| 985 | |
| 986 | // Set rectangle for the box, and set the clip rectangle. |
| 987 | RectI rect(offset, textBounds); |
| 988 | GFX->setClipRect(rect); |
| 989 | |
| 990 | // Fetch Draw Utility. |
| 991 | GFXDrawUtil* pDrawUtil = GFX->getDrawUtil(); |
| 992 | |
| 993 | // Draw Filler bit, then border on top of that |
| 994 | pDrawUtil->drawRectFill(rect, ColorI(mTooltipProfile->mFillColor.red, mTooltipProfile->mFillColor.green, mTooltipProfile->mFillColor.blue, 200) ); |
| 995 | pDrawUtil->drawRect( rect, mTooltipProfile->mBorderColor ); |
| 996 | |
| 997 | // Draw the text centered in the tool tip box |
| 998 | pDrawUtil->setBitmapModulation( mTooltipProfile->mFontColor ); |
nothing calls this directly
no test coverage detected