guiDefaultControlRender.cpp
Engine/source/gui/core/guiDefaultControlRender.cpp
Public Variables
colorBlack (0, 0, 0)
colorDarkGray (64, 64, 64)
colorLightGray (192, 192, 192)
colorWhite (255, 255, 255)
Public Functions
renderBorder(const RectI & bounds, GuiControlProfile * profile)
renderFilledBorder(const RectI & bounds, GuiControlProfile * profile)
renderFixedBitmapBordersFilled(const RectI & bounds, S32 baseMultiplier, GuiControlProfile * profile)
renderFixedBitmapBordersFilledIndex(const RectI & bounds, S32 startIndex, GuiControlProfile * profile)
renderLoweredBox(const RectI & bounds, GuiControlProfile * profile)
renderRaisedBox(const RectI & bounds, GuiControlProfile * profile)
renderSizableBitmapBordersFilled(const RectI & bounds, S32 baseMultiplier, GuiControlProfile * profile)
renderSizableBitmapBordersFilledIndex(const RectI & bounds, S32 startIndex, GuiControlProfile * profile)
renderSlightlyLoweredBox(const RectI & bounds, GuiControlProfile * profile)
renderSlightlyRaisedBox(const RectI & bounds, GuiControlProfile * profile)
Detailed Description
Public Variables
ColorI colorBlack (0, 0, 0)
ColorI colorDarkGray (64, 64, 64)
ColorI colorGray (128, 128, 128)
ColorI colorLightGray (192, 192, 192)
ColorI colorWhite (255, 255, 255)
Public Functions
renderBorder(const RectI & bounds, GuiControlProfile * profile)
renderFilledBorder(const RectI & bounds, const ColorI & borderColor, const ColorI & fillColor, U32 thickness)
renderFilledBorder(const RectI & bounds, GuiControlProfile * profile)
renderFixedBitmapBordersFilled(const RectI & bounds, S32 baseMultiplier, GuiControlProfile * profile)
renderFixedBitmapBordersFilledIndex(const RectI & bounds, S32 startIndex, GuiControlProfile * profile)
renderLoweredBox(const RectI & bounds, GuiControlProfile * profile)
renderRaisedBox(const RectI & bounds, GuiControlProfile * profile)
renderSizableBitmapBordersFilled(const RectI & bounds, S32 baseMultiplier, GuiControlProfile * profile)
renderSizableBitmapBordersFilledIndex(const RectI & bounds, S32 startIndex, GuiControlProfile * profile)
renderSlightlyLoweredBox(const RectI & bounds, GuiControlProfile * profile)
renderSlightlyRaisedBox(const RectI & bounds, GuiControlProfile * profile)
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "platform/platform.h" 25#include "gui/core/guiDefaultControlRender.h" 26 27#include "gui/core/guiTypes.h" 28#include "core/color.h" 29#include "math/mRect.h" 30#include "gfx/gfxDevice.h" 31#include "gfx/gfxDrawUtil.h" 32 33 34static ColorI colorLightGray(192, 192, 192); 35static ColorI colorGray(128, 128, 128); 36static ColorI colorDarkGray(64, 64, 64); 37static ColorI colorWhite(255,255,255); 38static ColorI colorBlack(0,0,0); 39 40void renderRaisedBox( const RectI &bounds, GuiControlProfile *profile ) 41{ 42 S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1; 43 S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1; 44 45 GFXDrawUtil* drawUtil = GFX->getDrawUtil(); 46 47 drawUtil->drawRectFill( bounds, profile->mFillColor); 48 drawUtil->drawLine(l, t, l, b - 1, colorWhite); 49 drawUtil->drawLine(l, t, r - 1, t, colorWhite); 50 51 drawUtil->drawLine(l, b, r, b, colorBlack); 52 drawUtil->drawLine(r, b - 1, r, t, colorBlack); 53 54 drawUtil->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor); 55 drawUtil->drawLine(r - 1, b - 2, r - 1, t + 1, profile->mBorderColor); 56} 57 58void renderSlightlyRaisedBox( const RectI &bounds, GuiControlProfile *profile ) 59{ 60 S32 l = bounds.point.x + 1, r = bounds.point.x + bounds.extent.x - 1; 61 S32 t = bounds.point.y + 1, b = bounds.point.y + bounds.extent.y - 1; 62 63 GFXDrawUtil *drawer = GFX->getDrawUtil(); 64 drawer->drawRectFill( bounds, profile->mFillColor); 65 drawer->drawLine(l, t, l, b, profile->mBorderColor); 66 drawer->drawLine(l, t, r, t, profile->mBorderColor); 67 drawer->drawLine(l + 1, b, r, b, profile->mBorderColor); 68 drawer->drawLine(r, t + 1, r, b - 1, profile->mBorderColor); 69} 70 71void renderLoweredBox( const RectI &bounds, GuiControlProfile *profile ) 72{ 73 S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1; 74 S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1; 75 76 GFXDrawUtil* drawUtil = GFX->getDrawUtil(); 77 78 drawUtil->drawRectFill( bounds, profile->mFillColor); 79 80 drawUtil->drawLine(l, b, r, b, colorWhite); 81 drawUtil->drawLine(r, b - 1, r, t, colorWhite); 82 83 drawUtil->drawLine(l, t, r - 1, t, colorBlack); 84 drawUtil->drawLine(l, t + 1, l, b - 1, colorBlack); 85 86 drawUtil->drawLine(l + 1, t + 1, r - 2, t + 1, profile->mBorderColor); 87 drawUtil->drawLine(l + 1, t + 2, l + 1, b - 2, profile->mBorderColor); 88} 89 90void renderSlightlyLoweredBox( const RectI &bounds, GuiControlProfile *profile ) 91{ 92 S32 l = bounds.point.x + 1, r = bounds.point.x + bounds.extent.x - 1; 93 S32 t = bounds.point.y + 1, b = bounds.point.y + bounds.extent.y - 1; 94 95 GFXDrawUtil* drawUtil = GFX->getDrawUtil(); 96 97 drawUtil->drawRectFill( bounds, profile->mFillColor); 98 drawUtil->drawLine(l, b, r, b, profile->mBorderColor); 99 drawUtil->drawLine(r, t, r, b - 1, profile->mBorderColor); 100 drawUtil->drawLine(l, t, l, b - 1, profile->mBorderColor); 101 drawUtil->drawLine(l + 1, t, r - 1, t, profile->mBorderColor); 102} 103 104void renderBorder( const RectI &bounds, GuiControlProfile *profile ) 105{ 106 S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1; 107 S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1; 108 109 GFXDrawUtil *drawer = GFX->getDrawUtil(); 110 111 switch(profile->mBorder) 112 { 113 case 1: 114 drawer->drawRect(bounds, profile->mBorderColor); 115 break; 116 case 2: 117 drawer->drawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorHL); 118 drawer->drawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorHL); 119 drawer->drawLine(r, t, r, b, profile->mBevelColorHL); 120 drawer->drawLine(l, b, r - 1, b, profile->mBevelColorHL); 121 drawer->drawLine(l, t, r - 1, t, profile->mBorderColorNA); 122 drawer->drawLine(l, t + 1, l, b - 1, profile->mBorderColorNA); 123 drawer->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColorNA); 124 drawer->drawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColorNA); 125 break; 126 case 3: 127 drawer->drawLine(l, b, r, b, profile->mBevelColorHL); 128 drawer->drawLine(r, t, r, b - 1, profile->mBevelColorHL); 129 drawer->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mFillColor); 130 drawer->drawLine(r - 1, t + 1, r - 1, b - 2, profile->mFillColor); 131 drawer->drawLine(l, t, l, b - 1, profile->mBorderColorNA); 132 drawer->drawLine(l + 1, t, r - 1, t, profile->mBorderColorNA); 133 drawer->drawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorLL); 134 drawer->drawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorLL); 135 break; 136 case 4: 137 drawer->drawLine(l, t, l, b - 1, profile->mBevelColorHL); 138 drawer->drawLine(l + 1, t, r, t, profile->mBevelColorHL); 139 drawer->drawLine(l, b, r, b, profile->mBevelColorLL); 140 drawer->drawLine(r, t + 1, r, b - 1, profile->mBevelColorLL); 141 drawer->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor); 142 drawer->drawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColor); 143 break; 144 case 5: 145 renderFilledBorder( bounds, profile ); 146 break; 147 // 148 case -1: 149 // Draw a simple sizable border with corners 150 // Taken from the 'Skinnable GUI Controls in TGE' resource by Justin DuJardin 151 if(profile->mBitmapArrayRects.size() >= 8) 152 { 153 drawer->clearBitmapModulation(); 154 155 RectI destRect; 156 RectI stretchRect; 157 RectI* mBitmapBounds = profile->mBitmapArrayRects.address(); 158 159 // Indices into the bitmap array 160 enum 161 { 162 BorderTopLeft = 0, 163 BorderTop, 164 BorderTopRight, 165 BorderLeft, 166 //Fill, 167 BorderRight, 168 BorderBottomLeft, 169 BorderBottom, 170 BorderBottomRight, 171 NumBitmaps 172 }; 173 174 // Draw all corners first. 175 176 //top left border 177 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]); 178 //top right border 179 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]); 180 181 //bottom left border 182 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]); 183 //bottom right border 184 drawer->drawBitmapSR(profile->mTextureObject,Point2I( 185 bounds.point.x + bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x, 186 bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomRight].extent.y), 187 mBitmapBounds[BorderBottomRight]); 188 189 // End drawing corners 190 191 // Begin drawing sides and top stretched borders 192 193 //start with top line stretch 194 destRect.point.x = bounds.point.x + mBitmapBounds[BorderTopLeft].extent.x; 195 destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x - mBitmapBounds[BorderTopLeft].extent.x; 196 destRect.extent.y = mBitmapBounds[BorderTop].extent.y; 197 destRect.point.y = bounds.point.y; 198 //stretch it 199 stretchRect = mBitmapBounds[BorderTop]; 200 stretchRect.inset(1,0); 201 //draw it 202 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 203 //bottom line stretch 204 destRect.point.x = bounds.point.x + mBitmapBounds[BorderBottomLeft].extent.x; 205 destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x - mBitmapBounds[BorderBottomLeft].extent.x; 206 destRect.extent.y = mBitmapBounds[BorderBottom].extent.y; 207 destRect.point.y = bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottom].extent.y; 208 //stretch it 209 stretchRect = mBitmapBounds[BorderBottom]; 210 stretchRect.inset(1,0); 211 //draw it 212 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 213 //left line stretch 214 destRect.point.x = bounds.point.x; 215 destRect.extent.x = mBitmapBounds[BorderLeft].extent.x; 216 destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTopLeft].extent.y - mBitmapBounds[BorderBottomLeft].extent.y; 217 destRect.point.y = bounds.point.y + mBitmapBounds[BorderTopLeft].extent.y; 218 //stretch it 219 stretchRect = mBitmapBounds[BorderLeft]; 220 stretchRect.inset(0,1); 221 //draw it 222 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 223 //right line stretch 224 destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[BorderRight].extent.x; 225 destRect.extent.x = mBitmapBounds[BorderRight].extent.x; 226 destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTopRight].extent.y - mBitmapBounds[BorderBottomRight].extent.y; 227 destRect.point.y = bounds.point.y + mBitmapBounds[BorderTopRight].extent.y; 228 //stretch it 229 stretchRect = mBitmapBounds[BorderRight]; 230 stretchRect.inset(0,1); 231 //draw it 232 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 233 234 // End drawing sides and top stretched borders 235 break; 236 } 237 case -2: 238 // Draw a simple sizable border with corners that is filled in 239 renderSizableBitmapBordersFilled(bounds, 1, profile); 240 break; 241 case -3: 242 // Draw a simple fixed height border with center fill horizontally. 243 renderFixedBitmapBordersFilled( bounds, 1, profile ); 244 break; 245 246 } 247} 248 249void renderFilledBorder( const RectI &bounds, GuiControlProfile *profile ) 250{ 251 renderFilledBorder( bounds, profile->mBorderColor, profile->mFillColor, profile->mBorderThickness ); 252} 253 254void renderFilledBorder( const RectI &bounds, const ColorI &borderColor, const ColorI &fillColor, U32 thickness ) 255{ 256 RectI fillBounds = bounds; 257 fillBounds.inset( thickness, thickness ); 258 259 GFX->getDrawUtil()->drawRectFill( bounds, borderColor ); 260 GFX->getDrawUtil()->drawRectFill( fillBounds, fillColor ); 261} 262 263// Render out the sizable bitmap borders based on a multiplier into the bitmap array 264// Based on the 'Skinnable GUI Controls in TGE' resource by Justin DuJardin 265void renderSizableBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier, GuiControlProfile *profile) 266{ 267 // Indices into the bitmap array 268 S32 numBitmaps = 9; 269 S32 borderTopLeft = numBitmaps * baseMultiplier - numBitmaps; 270 S32 borderTop = 1 + borderTopLeft; 271 S32 borderTopRight = 2 + borderTopLeft; 272 S32 borderLeft = 3 + borderTopLeft; 273 S32 fill = 4 + borderTopLeft; 274 S32 borderRight = 5 + borderTopLeft; 275 S32 borderBottomLeft = 6 + borderTopLeft; 276 S32 borderBottom = 7 + borderTopLeft; 277 S32 borderBottomRight = 8 + borderTopLeft; 278 279 GFXDrawUtil *drawer = GFX->getDrawUtil(); 280 281 drawer->clearBitmapModulation(); 282 283 if(profile->mBitmapArrayRects.size() >= (numBitmaps * baseMultiplier)) 284 { 285 RectI destRect; 286 RectI stretchRect; 287 RectI* mBitmapBounds = profile->mBitmapArrayRects.address(); 288 289 // Draw all corners first. 290 291 //top left border 292 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]); 293 //top right border 294 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]); 295 296 //bottom left border 297 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]); 298 //bottom right border 299 drawer->drawBitmapSR(profile->mTextureObject,Point2I( 300 bounds.point.x + bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x, 301 bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomRight].extent.y), 302 mBitmapBounds[borderBottomRight]); 303 304 // End drawing corners 305 306 // Begin drawing sides and top stretched borders 307 308 //start with top line stretch 309 destRect.point.x = bounds.point.x + mBitmapBounds[borderTopLeft].extent.x; 310 destRect.extent.x = bounds.extent.x - mBitmapBounds[borderTopRight].extent.x - mBitmapBounds[borderTopLeft].extent.x; 311 destRect.extent.y = mBitmapBounds[borderTop].extent.y; 312 destRect.point.y = bounds.point.y; 313 //stretch it 314 stretchRect = mBitmapBounds[borderTop]; 315 stretchRect.inset(1,0); 316 //draw it 317 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 318 //bottom line stretch 319 destRect.point.x = bounds.point.x + mBitmapBounds[borderBottomLeft].extent.x; 320 destRect.extent.x = bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x - mBitmapBounds[borderBottomLeft].extent.x; 321 destRect.extent.y = mBitmapBounds[borderBottom].extent.y; 322 destRect.point.y = bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottom].extent.y; 323 //stretch it 324 stretchRect = mBitmapBounds[borderBottom]; 325 stretchRect.inset(1,0); 326 //draw it 327 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 328 //left line stretch 329 destRect.point.x = bounds.point.x; 330 destRect.extent.x = mBitmapBounds[borderLeft].extent.x; 331 destRect.extent.y = bounds.extent.y - mBitmapBounds[borderTopLeft].extent.y - mBitmapBounds[borderBottomLeft].extent.y; 332 destRect.point.y = bounds.point.y + mBitmapBounds[borderTopLeft].extent.y; 333 //stretch it 334 stretchRect = mBitmapBounds[borderLeft]; 335 stretchRect.inset(0,1); 336 //draw it 337 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 338 //right line stretch 339 destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x; 340 destRect.extent.x = mBitmapBounds[borderRight].extent.x; 341 destRect.extent.y = bounds.extent.y - mBitmapBounds[borderTopRight].extent.y - mBitmapBounds[borderBottomRight].extent.y; 342 destRect.point.y = bounds.point.y + mBitmapBounds[borderTopRight].extent.y; 343 //stretch it 344 stretchRect = mBitmapBounds[borderRight]; 345 stretchRect.inset(0,1); 346 //draw it 347 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 348 //fill stretch 349 destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x; 350 destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x; 351 destRect.extent.y = bounds.extent.y - mBitmapBounds[borderTop].extent.y - mBitmapBounds[borderBottom].extent.y; 352 destRect.point.y = bounds.point.y + mBitmapBounds[borderTop].extent.y; 353 //stretch it 354 stretchRect = mBitmapBounds[fill]; 355 stretchRect.inset(1,1); 356 //draw it 357 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 358 359 // End drawing sides and top stretched borders 360 } 361} 362 363 364// Render out the sizable bitmap borders based on a multiplier into the bitmap array 365// Based on the 'Skinnable GUI Controls in TGE' resource by Justin DuJardin 366void renderSizableBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex, GuiControlProfile *profile ) 367{ 368 // Indices into the bitmap array 369 S32 numBitmaps = 9; 370 S32 borderTopLeft = startIndex; 371 S32 borderTop = 1 + borderTopLeft; 372 S32 borderTopRight = 2 + borderTopLeft; 373 S32 borderLeft = 3 + borderTopLeft; 374 S32 fill = 4 + borderTopLeft; 375 S32 borderRight = 5 + borderTopLeft; 376 S32 borderBottomLeft = 6 + borderTopLeft; 377 S32 borderBottom = 7 + borderTopLeft; 378 S32 borderBottomRight = 8 + borderTopLeft; 379 380 GFXDrawUtil *drawer = GFX->getDrawUtil(); 381 382 drawer->clearBitmapModulation(); 383 if(profile->mBitmapArrayRects.size() >= (startIndex + numBitmaps)) 384 { 385 RectI destRect; 386 RectI stretchRect; 387 RectI* mBitmapBounds = profile->mBitmapArrayRects.address(); 388 389 // Draw all corners first. 390 391 //top left border 392 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderTopLeft]); 393 //top right border 394 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderTopRight].extent.x,bounds.point.y),mBitmapBounds[borderTopRight]); 395 396 //bottom left border 397 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomLeft].extent.y),mBitmapBounds[borderBottomLeft]); 398 //bottom right border 399 drawer->drawBitmapSR(profile->mTextureObject,Point2I( 400 bounds.point.x + bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x, 401 bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottomRight].extent.y), 402 mBitmapBounds[borderBottomRight]); 403 404 // End drawing corners 405 406 // Begin drawing sides and top stretched borders 407 408 //start with top line stretch 409 destRect.point.x = bounds.point.x + mBitmapBounds[borderTopLeft].extent.x; 410 destRect.extent.x = bounds.extent.x - mBitmapBounds[borderTopRight].extent.x - mBitmapBounds[borderTopLeft].extent.x; 411 destRect.extent.y = mBitmapBounds[borderTop].extent.y; 412 destRect.point.y = bounds.point.y; 413 //stretch it 414 stretchRect = mBitmapBounds[borderTop]; 415 stretchRect.inset(1,0); 416 //draw it 417 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 418 //bottom line stretch 419 destRect.point.x = bounds.point.x + mBitmapBounds[borderBottomLeft].extent.x; 420 destRect.extent.x = bounds.extent.x - mBitmapBounds[borderBottomRight].extent.x - mBitmapBounds[borderBottomLeft].extent.x; 421 destRect.extent.y = mBitmapBounds[borderBottom].extent.y; 422 destRect.point.y = bounds.point.y + bounds.extent.y - mBitmapBounds[borderBottom].extent.y; 423 //stretch it 424 stretchRect = mBitmapBounds[borderBottom]; 425 stretchRect.inset(1,0); 426 //draw it 427 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 428 //left line stretch 429 destRect.point.x = bounds.point.x; 430 destRect.extent.x = mBitmapBounds[borderLeft].extent.x; 431 destRect.extent.y = bounds.extent.y - mBitmapBounds[borderTopLeft].extent.y - mBitmapBounds[borderBottomLeft].extent.y; 432 destRect.point.y = bounds.point.y + mBitmapBounds[borderTopLeft].extent.y; 433 //stretch it 434 stretchRect = mBitmapBounds[borderLeft]; 435 stretchRect.inset(0,1); 436 //draw it 437 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 438 //left line stretch 439 destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x; 440 destRect.extent.x = mBitmapBounds[borderRight].extent.x; 441 destRect.extent.y = bounds.extent.y - mBitmapBounds[borderTopRight].extent.y - mBitmapBounds[borderBottomRight].extent.y; 442 destRect.point.y = bounds.point.y + mBitmapBounds[borderTopRight].extent.y; 443 //stretch it 444 stretchRect = mBitmapBounds[borderRight]; 445 stretchRect.inset(0,1); 446 //draw it 447 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 448 //fill stretch 449 destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x; 450 destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x; 451 destRect.extent.y = bounds.extent.y - mBitmapBounds[borderTop].extent.y - mBitmapBounds[borderBottom].extent.y; 452 destRect.point.y = bounds.point.y + mBitmapBounds[borderTop].extent.y; 453 //stretch it 454 stretchRect = mBitmapBounds[fill]; 455 stretchRect.inset(1,1); 456 //draw it 457 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 458 459 // End drawing sides and top stretched borders 460 } 461} 462 463 464 465// Render out the fixed bitmap borders based on a multiplier into the bitmap array 466// It renders left and right caps, with a sizable fill area in the middle to reach 467// the x extent. It does not stretch in the y direction. 468void renderFixedBitmapBordersFilled( const RectI &bounds, S32 baseMultiplier, GuiControlProfile *profile ) 469{ 470 // Indices into the bitmap array 471 S32 numBitmaps = 3; 472 S32 borderLeft = numBitmaps * baseMultiplier - numBitmaps; 473 S32 fill = 1 + borderLeft; 474 S32 borderRight = 2 + borderLeft; 475 476 GFXDrawUtil *drawer = GFX->getDrawUtil(); 477 478 drawer->clearBitmapModulation(); 479 if(profile->mBitmapArrayRects.size() >= (numBitmaps * baseMultiplier)) 480 { 481 RectI destRect; 482 RectI stretchRect; 483 RectI* mBitmapBounds = profile->mBitmapArrayRects.address(); 484 485 // Draw all corners first. 486 487 //left border 488 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]); 489 //right border 490 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]); 491 492 // End drawing corners 493 494 // Begin drawing fill 495 496 //fill stretch 497 destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x; 498 destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x; 499 destRect.extent.y = mBitmapBounds[fill].extent.y; 500 destRect.point.y = bounds.point.y; 501 //stretch it 502 stretchRect = mBitmapBounds[fill]; 503 stretchRect.inset(1,0); 504 //draw it 505 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 506 507 // End drawing fill 508 } 509} 510 511// Render out the fixed bitmap borders based on a multiplier into the bitmap array 512// It renders left and right caps, with a sizable fill area in the middle to reach 513// the x extent. It does not stretch in the y direction. 514void renderFixedBitmapBordersFilledIndex( const RectI &bounds, S32 startIndex, GuiControlProfile *profile ) 515{ 516 // Indices into the bitmap array 517 S32 numBitmaps = 3; 518 S32 borderLeft = startIndex; 519 S32 fill = 1 + startIndex; 520 S32 borderRight = 2 + startIndex; 521 522 GFXDrawUtil *drawer = GFX->getDrawUtil(); 523 drawer->clearBitmapModulation(); 524 if(profile->mBitmapArrayRects.size() >= (startIndex + numBitmaps)) 525 { 526 RectI destRect; 527 RectI stretchRect; 528 RectI* mBitmapBounds = profile->mBitmapArrayRects.address(); 529 530 // Draw all corners first. 531 532 //left border 533 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[borderLeft]); 534 //right border 535 drawer->drawBitmapSR(profile->mTextureObject,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[borderRight].extent.x,bounds.point.y),mBitmapBounds[borderRight]); 536 537 // End drawing corners 538 539 // Begin drawing fill 540 541 //fill stretch 542 destRect.point.x = bounds.point.x + mBitmapBounds[borderLeft].extent.x; 543 destRect.extent.x = (bounds.extent.x) - mBitmapBounds[borderLeft].extent.x - mBitmapBounds[borderRight].extent.x; 544 destRect.extent.y = mBitmapBounds[fill].extent.y; 545 destRect.point.y = bounds.point.y; 546 //stretch it 547 stretchRect = mBitmapBounds[fill]; 548 stretchRect.inset(1,0); 549 //draw it 550 drawer->drawBitmapStretchSR(profile->mTextureObject,destRect,stretchRect); 551 552 // End drawing fill 553 } 554} 555