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

Method onRender

Engine/source/gui/game/guiProgressBitmapCtrl.cpp:201–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199//-----------------------------------------------------------------------------
200
201void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
202{
203 RectI ctrlRect(offset, getExtent());
204
205 //grab lowest dimension
206 if(getHeight() <= getWidth())
207 mDim = getHeight();
208 else
209 mDim = getWidth();
210
211 GFXDrawUtil* drawUtil = GFX->getDrawUtil();
212
213 drawUtil->clearBitmapModulation();
214
215 if(mNumberOfBitmaps == 1)
216 {
217 //draw the progress with image
218 S32 width = (S32)((F32)(getWidth()) * mProgress);
219 if (width > 0)
220 {
221 //drawing stretch bitmap
222 RectI progressRect = ctrlRect;
223 progressRect.extent.x = width;
224 drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRect, mProfile->mBitmapArrayRects[0]);
225 }
226 }
227 else if(mNumberOfBitmaps >= 3)
228 {
229 //drawing left-end bitmap
230 RectI progressRectLeft(ctrlRect.point.x, ctrlRect.point.y, mDim, mDim);
231 drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRectLeft, mProfile->mBitmapArrayRects[0]);
232
233 //draw the progress with image
234 S32 width = (S32)((F32)(getWidth()) * mProgress);
235 if (width > mDim)
236 {
237 //drawing stretch bitmap
238 RectI progressRect = ctrlRect;
239 progressRect.point.x += mDim;
240 progressRect.extent.x = (width - mDim - mDim);
241 if (progressRect.extent.x < 0)
242 progressRect.extent.x = 0;
243 drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRect, mProfile->mBitmapArrayRects[1]);
244
245 //drawing right-end bitmap
246 RectI progressRectRight(progressRect.point.x + progressRect.extent.x, ctrlRect.point.y, mDim, mDim );
247 drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRectRight, mProfile->mBitmapArrayRects[2]);
248 }
249 }
250 else
251 Con::warnf("guiProgressBitmapCtrl only processes an array of bitmaps == 1 or >= 3");
252
253 //if there's a border, draw it
254 if (mProfile->mBorder)
255 drawUtil->drawRect(ctrlRect, mProfile->mBorderColor);
256
257 Parent::onRender( offset, updateRect );
258

Callers

nothing calls this directly

Calls 8

getWidthFunction · 0.85
getDrawUtilMethod · 0.80
clearBitmapModulationMethod · 0.80
drawBitmapStretchSRMethod · 0.80
getBitmapResourceMethod · 0.80
drawRectMethod · 0.80
getHeightFunction · 0.50
warnfFunction · 0.50

Tested by

no test coverage detected