guiDefaultControlRender.cc 28 KB

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