void GuiConsoleTextCtrl::onRender( Point2I offset, const RectI &updateRect ) { RectI ctrlRect( offset, getExtent() ); // if opaque, fill the update rect with the fill color if ( mProfile->mOpaque ) GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColor ); // if there's a border, draw the border if ( mProfile->mBorder ) renderBorder( ctrlRect, mProfile ); // If we have text to render. if ( mResult.isNotEmpty() ) { GFont *font = mProfile->mFont; GFX->getDrawUtil()->setBitmapModulation( mProfile->mFontColor ); for ( U32 i = 0; i < mLineLen.size(); i++ ) { Point2I tempOffset = offset; tempOffset += mProfile->mTextOffset; tempOffset.y += i * font->getHeight(); const UTF8 *line = mResult.c_str() + mStartLineOffset[i]; U32 lineLen = mLineLen[i]; GFX->getDrawUtil()->drawTextN( font, tempOffset, line, lineLen, mProfile->mFontColors ); } } // render the child controlsmResult renderChildControls(offset, updateRect); }
S32 GuiTabBookCtrl::calculatePageTabWidth( GuiTabPageCtrl *page ) { if( !page ) return mMinTabWidth; const char* text = page->getText(); if( !text || dStrlen(text) == 0 || mProfile == NULL || mProfile->mFont == NULL ) return mMinTabWidth; GFont *font = mProfile->mFont; return font->getStrNWidth( text, dStrlen(text) ); }
void GuiDecalEditorCtrl::renderGui( Point2I offset, const RectI &updateRect ) { Parent::renderGui( offset, updateRect ); PROFILE_SCOPE( GuiDecalEditorCtrl_renderGui ); // Show the pixelSize of the selected decal as a text overlay. if ( smRenderDecalPixelSize && mSELDecal != NULL ) { const F32 pixelSize = mSELDecal->calcPixelSize( mSaveViewport.extent.y, mLastCameraQuery.cameraMatrix.getPosition(), mSaveWorldToScreenScale.y ); // Find position onscreen to render the text. Point3F screenPos; bool onScreen = project( mSELDecal->mPosition, &screenPos ); if ( onScreen ) { // It is extremely annoying to require the GuiProfile to have a font // or to create one within the decal editor for only this single use, // so we instead rely on the fact that we already have a Gizmo, that // all Gizmo's have a GizmoProfile, and that GizmoProfile has a font. GFont *font = mGizmo->getProfile()->font; // Might as well use some colors defined in GizmoProfile too instead // of just hardcoding it here. const ColorI bgColor = mGizmo->getProfile()->inActiveColor; const ColorI textColor = mGizmo->getProfile()->activeColor; // Note: This mostly mirrors the way WorldEditor renders popupText for // the gizmo during a drag operation, consider unifying this into a utility method. char buf[256]; dSprintf( buf, 256, "%0.3f", pixelSize ); const U32 width = font->getStrWidth((const UTF8 *)buf);; const Point2I posi( (U32)screenPos.x, (U32)screenPos.y + 12 ); const Point2I minPt(posi.x - width / 2 - 2, posi.y - 1); const Point2I maxPt(posi.x + width / 2 + 2, posi.y + font->getHeight() + 1); GFXDrawUtil *drawer = GFX->getDrawUtil(); drawer->drawRectFill( minPt, maxPt, bgColor ); GFX->getDrawUtil()->setBitmapModulation( textColor ); GFX->getDrawUtil()->drawText( mProfile->mFont, Point2I( posi.x - width / 2, posi.y ), buf ); } } }