guiDefaultControlRender.cc 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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. switch(profile->mBorder)
  103. {
  104. case 1:
  105. dglDrawRect(bounds, profile->mBorderColor);
  106. break;
  107. case 2:
  108. dglDrawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorHL);
  109. dglDrawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorHL);
  110. dglDrawLine(r, t, r, b, profile->mBevelColorHL);
  111. dglDrawLine(l, b, r - 1, b, profile->mBevelColorHL);
  112. dglDrawLine(l, t, r - 1, t, profile->mBorderColorNA);
  113. dglDrawLine(l, t + 1, l, b - 1, profile->mBorderColorNA);
  114. dglDrawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColorNA);
  115. dglDrawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColorNA);
  116. break;
  117. case 3:
  118. dglDrawLine(l, b, r, b, profile->mBevelColorHL);
  119. dglDrawLine(r, t, r, b - 1, profile->mBevelColorHL);
  120. dglDrawLine(l + 1, b - 1, r - 1, b - 1, profile->mFillColor);
  121. dglDrawLine(r - 1, t + 1, r - 1, b - 2, profile->mFillColor);
  122. dglDrawLine(l, t, l, b - 1, profile->mBorderColorNA);
  123. dglDrawLine(l + 1, t, r - 1, t, profile->mBorderColorNA);
  124. dglDrawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorLL);
  125. dglDrawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorLL);
  126. break;
  127. case 4:
  128. dglDrawLine(l, t, l, b - 1, profile->mBevelColorHL);
  129. dglDrawLine(l + 1, t, r, t, profile->mBevelColorHL);
  130. dglDrawLine(l, b, r, b, profile->mBevelColorLL);
  131. dglDrawLine(r, t + 1, r, b - 1, profile->mBevelColorLL);
  132. dglDrawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor);
  133. dglDrawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColor);
  134. break;
  135. case 5:
  136. renderFilledBorder( bounds, profile );
  137. break;
  138. case 6:// Draw boarder only on top and left
  139. dglDrawLine(l, t, l, b, profile->mBorderColor);
  140. dglDrawLine(l, t, r, t, profile->mBorderColor);
  141. break;
  142. case 7:// Draw boarder only on bottom and right
  143. dglDrawLine(r, t, r, b, profile->mBorderColor);
  144. dglDrawLine(l, b, r, b, profile->mBorderColor);
  145. break;
  146. // DAW:
  147. case -1:
  148. // Draw a simple sizable border with corners
  149. // Taken from the 'Skinnable GUI Controls in TGE' resource by Justin DuJardin
  150. if(profile->mBitmapArrayRects.size() >= 8)
  151. {
  152. dglClearBitmapModulation();
  153. RectI destRect;
  154. RectI stretchRect;
  155. RectI* mBitmapBounds = profile->mBitmapArrayRects.address();
  156. // DAW: Indices into the bitmap array
  157. enum
  158. {
  159. BorderTopLeft = 0,
  160. BorderTop,
  161. BorderTopRight,
  162. BorderLeft,
  163. //Fill,
  164. BorderRight,
  165. BorderBottomLeft,
  166. BorderBottom,
  167. BorderBottomRight,
  168. NumBitmaps
  169. };
  170. // Draw all corners first.
  171. //top left border
  172. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
  173. //top right border
  174. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
  175. //bottom left border
  176. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
  177. //bottom right border
  178. dglDrawBitmapSR(profile->mTextureHandle,Point2I(
  179. bounds.point.x + bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x,
  180. bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomRight].extent.y),
  181. mBitmapBounds[BorderBottomRight]);
  182. // End drawing corners
  183. // Begin drawing sides and top stretched borders
  184. //start with top line stretch
  185. destRect.point.x = bounds.point.x + mBitmapBounds[BorderTopRight].extent.x;
  186. destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x - mBitmapBounds[BorderTopLeft].extent.x;
  187. destRect.extent.y = mBitmapBounds[BorderTop].extent.y;
  188. destRect.point.y = bounds.point.y;
  189. //stretch it
  190. stretchRect = mBitmapBounds[BorderTop];
  191. stretchRect.inset(1,0);
  192. //draw it
  193. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  194. //bottom line stretch
  195. destRect.point.x = bounds.point.x + mBitmapBounds[BorderBottomRight].extent.x;
  196. destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x - mBitmapBounds[BorderBottomLeft].extent.x;
  197. destRect.extent.y = mBitmapBounds[BorderBottom].extent.y;
  198. destRect.point.y = bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottom].extent.y;
  199. //stretch it
  200. stretchRect = mBitmapBounds[BorderBottom];
  201. stretchRect.inset(1,0);
  202. //draw it
  203. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  204. //left line stretch
  205. destRect.point.x = bounds.point.x;
  206. destRect.extent.x = mBitmapBounds[BorderLeft].extent.x;
  207. destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTopLeft].extent.y - mBitmapBounds[BorderBottomLeft].extent.y;
  208. destRect.point.y = bounds.point.y + mBitmapBounds[BorderTopLeft].extent.y;
  209. //stretch it
  210. stretchRect = mBitmapBounds[BorderLeft];
  211. stretchRect.inset(0,1);
  212. //draw it
  213. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  214. //left line stretch
  215. destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[BorderRight].extent.x;
  216. destRect.extent.x = mBitmapBounds[BorderRight].extent.x;
  217. destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTopRight].extent.y - mBitmapBounds[BorderBottomRight].extent.y;
  218. destRect.point.y = bounds.point.y + mBitmapBounds[BorderTopRight].extent.y;
  219. //stretch it
  220. stretchRect = mBitmapBounds[BorderRight];
  221. stretchRect.inset(0,1);
  222. //draw it
  223. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  224. // End drawing sides and top stretched borders
  225. break;
  226. }
  227. case -2:
  228. // Draw a simple sizable border with corners that is filled in
  229. renderSizableBitmapBordersFilled(bounds, 1, profile);
  230. break;
  231. case -3:
  232. // Draw a simple fixed height border with center fill horizontally.
  233. renderFixedBitmapBordersFilled( bounds, 1, profile );
  234. break;
  235. }
  236. }
  237. void renderFilledBorder( RectI &bounds, GuiControlProfile *profile )
  238. {
  239. renderFilledBorder( bounds, profile->mBorderColor, profile->mFillColor );
  240. }
  241. void renderFilledBorder( RectI &bounds, ColorI &borderColor, ColorI &fillColor )
  242. {
  243. RectI fillBounds = bounds;
  244. fillBounds.inset( 1, 1 );
  245. dglDrawRect( bounds, borderColor );
  246. dglDrawRectFill( fillBounds, fillColor );
  247. }
  248. // DAW: Render out the sizable bitmap borders based on a multiplier into the bitmap array
  249. // Based on the 'Skinnable GUI Controls in TGE' resource by Justin DuJardin
  250. void renderSizableBitmapBordersFilled(RectI &bounds, S32 baseMultiplier, GuiControlProfile *profile)
  251. {
  252. // DAW: Indices into the bitmap array
  253. S32 NumBitmaps = 9;
  254. S32 BorderTopLeft = NumBitmaps * baseMultiplier - NumBitmaps;
  255. S32 BorderTop = 1 + BorderTopLeft;
  256. S32 BorderTopRight = 2 + BorderTopLeft;
  257. S32 BorderLeft = 3 + BorderTopLeft;
  258. S32 Fill = 4 + BorderTopLeft;
  259. S32 BorderRight = 5 + BorderTopLeft;
  260. S32 BorderBottomLeft = 6 + BorderTopLeft;
  261. S32 BorderBottom = 7 + BorderTopLeft;
  262. S32 BorderBottomRight = 8 + BorderTopLeft;
  263. dglClearBitmapModulation();
  264. if(profile->mBitmapArrayRects.size() >= (NumBitmaps * baseMultiplier))
  265. {
  266. RectI destRect;
  267. RectI stretchRect;
  268. RectI* mBitmapBounds = profile->mBitmapArrayRects.address();
  269. // Draw all corners first.
  270. //top left border
  271. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
  272. //top right border
  273. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
  274. //bottom left border
  275. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
  276. //bottom right border
  277. dglDrawBitmapSR(profile->mTextureHandle,Point2I(
  278. bounds.point.x + bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x,
  279. bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomRight].extent.y),
  280. mBitmapBounds[BorderBottomRight]);
  281. // End drawing corners
  282. // Begin drawing sides and top stretched borders
  283. //start with top line stretch
  284. destRect.point.x = bounds.point.x + mBitmapBounds[BorderTopRight].extent.x;
  285. destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x - mBitmapBounds[BorderTopLeft].extent.x;
  286. destRect.extent.y = mBitmapBounds[BorderTop].extent.y;
  287. destRect.point.y = bounds.point.y;
  288. //stretch it
  289. stretchRect = mBitmapBounds[BorderTop];
  290. stretchRect.inset(1,0);
  291. //draw it
  292. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  293. //bottom line stretch
  294. destRect.point.x = bounds.point.x + mBitmapBounds[BorderBottomRight].extent.x;
  295. destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x - mBitmapBounds[BorderBottomLeft].extent.x;
  296. destRect.extent.y = mBitmapBounds[BorderBottom].extent.y;
  297. destRect.point.y = bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottom].extent.y;
  298. //stretch it
  299. stretchRect = mBitmapBounds[BorderBottom];
  300. stretchRect.inset(1,0);
  301. //draw it
  302. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  303. //left line stretch
  304. destRect.point.x = bounds.point.x;
  305. destRect.extent.x = mBitmapBounds[BorderLeft].extent.x;
  306. destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTopLeft].extent.y - mBitmapBounds[BorderBottomLeft].extent.y;
  307. destRect.point.y = bounds.point.y + mBitmapBounds[BorderTopLeft].extent.y;
  308. //stretch it
  309. stretchRect = mBitmapBounds[BorderLeft];
  310. stretchRect.inset(0,1);
  311. //draw it
  312. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  313. //left line stretch
  314. destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[BorderRight].extent.x;
  315. destRect.extent.x = mBitmapBounds[BorderRight].extent.x;
  316. destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTopRight].extent.y - mBitmapBounds[BorderBottomRight].extent.y;
  317. destRect.point.y = bounds.point.y + mBitmapBounds[BorderTopRight].extent.y;
  318. //stretch it
  319. stretchRect = mBitmapBounds[BorderRight];
  320. stretchRect.inset(0,1);
  321. //draw it
  322. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  323. //fill stretch
  324. destRect.point.x = bounds.point.x + mBitmapBounds[BorderLeft].extent.x;
  325. destRect.extent.x = (bounds.extent.x) - mBitmapBounds[BorderLeft].extent.x - mBitmapBounds[BorderRight].extent.x;
  326. destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTop].extent.y - mBitmapBounds[BorderBottom].extent.y;
  327. destRect.point.y = bounds.point.y + mBitmapBounds[BorderTop].extent.y;
  328. //stretch it
  329. stretchRect = mBitmapBounds[Fill];
  330. stretchRect.inset(1,1);
  331. //draw it
  332. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  333. // End drawing sides and top stretched borders
  334. }
  335. }
  336. // DAW: Render out the sizable bitmap borders based on a multiplier into the bitmap array
  337. // Based on the 'Skinnable GUI Controls in TGE' resource by Justin DuJardin
  338. void renderSizableBitmapBordersFilledIndex(RectI &bounds, S32 startIndex, GuiControlProfile *profile)
  339. {
  340. // DAW: Indices into the bitmap array
  341. S32 NumBitmaps = 9;
  342. S32 BorderTopLeft = startIndex;
  343. S32 BorderTop = 1 + BorderTopLeft;
  344. S32 BorderTopRight = 2 + BorderTopLeft;
  345. S32 BorderLeft = 3 + BorderTopLeft;
  346. S32 Fill = 4 + BorderTopLeft;
  347. S32 BorderRight = 5 + BorderTopLeft;
  348. S32 BorderBottomLeft = 6 + BorderTopLeft;
  349. S32 BorderBottom = 7 + BorderTopLeft;
  350. S32 BorderBottomRight = 8 + BorderTopLeft;
  351. dglClearBitmapModulation();
  352. if(profile->mBitmapArrayRects.size() >= (startIndex + NumBitmaps))
  353. {
  354. RectI destRect;
  355. RectI stretchRect;
  356. RectI* mBitmapBounds = profile->mBitmapArrayRects.address();
  357. // Draw all corners first.
  358. //top left border
  359. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderTopLeft]);
  360. //top right border
  361. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x,bounds.point.y),mBitmapBounds[BorderTopRight]);
  362. //bottom left border
  363. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x,bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomLeft].extent.y),mBitmapBounds[BorderBottomLeft]);
  364. //bottom right border
  365. dglDrawBitmapSR(profile->mTextureHandle,Point2I(
  366. bounds.point.x + bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x,
  367. bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottomRight].extent.y),
  368. mBitmapBounds[BorderBottomRight]);
  369. // End drawing corners
  370. // Begin drawing sides and top stretched borders
  371. //start with top line stretch
  372. destRect.point.x = bounds.point.x + mBitmapBounds[BorderTopLeft].extent.x;
  373. destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderTopRight].extent.x - mBitmapBounds[BorderTopLeft].extent.x;
  374. destRect.extent.y = mBitmapBounds[BorderTop].extent.y;
  375. destRect.point.y = bounds.point.y;
  376. //stretch it
  377. stretchRect = mBitmapBounds[BorderTop];
  378. stretchRect.inset(1,0);
  379. //draw it
  380. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  381. //bottom line stretch
  382. destRect.point.x = bounds.point.x + mBitmapBounds[BorderBottomLeft].extent.x;
  383. destRect.extent.x = bounds.extent.x - mBitmapBounds[BorderBottomRight].extent.x - mBitmapBounds[BorderBottomLeft].extent.x;
  384. destRect.extent.y = mBitmapBounds[BorderBottom].extent.y;
  385. destRect.point.y = bounds.point.y + bounds.extent.y - mBitmapBounds[BorderBottom].extent.y;
  386. //stretch it
  387. stretchRect = mBitmapBounds[BorderBottom];
  388. stretchRect.inset(1,0);
  389. //draw it
  390. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  391. //left line stretch
  392. destRect.point.x = bounds.point.x;
  393. destRect.extent.x = mBitmapBounds[BorderLeft].extent.x;
  394. destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTopLeft].extent.y - mBitmapBounds[BorderBottomLeft].extent.y;
  395. destRect.point.y = bounds.point.y + mBitmapBounds[BorderTopLeft].extent.y;
  396. //stretch it
  397. stretchRect = mBitmapBounds[BorderLeft];
  398. stretchRect.inset(0,1);
  399. //draw it
  400. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  401. //left line stretch
  402. destRect.point.x = bounds.point.x + bounds.extent.x - mBitmapBounds[BorderRight].extent.x;
  403. destRect.extent.x = mBitmapBounds[BorderRight].extent.x;
  404. destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTopRight].extent.y - mBitmapBounds[BorderBottomRight].extent.y;
  405. destRect.point.y = bounds.point.y + mBitmapBounds[BorderTopRight].extent.y;
  406. //stretch it
  407. stretchRect = mBitmapBounds[BorderRight];
  408. stretchRect.inset(0,1);
  409. //draw it
  410. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  411. //fill stretch
  412. destRect.point.x = bounds.point.x + mBitmapBounds[BorderLeft].extent.x;
  413. destRect.extent.x = (bounds.extent.x) - mBitmapBounds[BorderLeft].extent.x - mBitmapBounds[BorderRight].extent.x;
  414. destRect.extent.y = bounds.extent.y - mBitmapBounds[BorderTop].extent.y - mBitmapBounds[BorderBottom].extent.y;
  415. destRect.point.y = bounds.point.y + mBitmapBounds[BorderTop].extent.y;
  416. //stretch it
  417. stretchRect = mBitmapBounds[Fill];
  418. stretchRect.inset(1,1);
  419. //draw it
  420. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  421. // End drawing sides and top stretched borders
  422. }
  423. }
  424. // DAW: Render out the fixed bitmap borders based on a multiplier into the bitmap array
  425. // It renders left and right caps, with a sizable fill area in the middle to reach
  426. // the x extent. It does not stretch in the y direction.
  427. void renderFixedBitmapBordersFilled(RectI &bounds, S32 baseMultiplier, GuiControlProfile *profile)
  428. {
  429. // DAW: Indices into the bitmap array
  430. S32 NumBitmaps = 3;
  431. S32 BorderLeft = NumBitmaps * baseMultiplier - NumBitmaps;
  432. S32 Fill = 1 + BorderLeft;
  433. S32 BorderRight = 2 + BorderLeft;
  434. dglClearBitmapModulation();
  435. if(profile->mBitmapArrayRects.size() >= (NumBitmaps * baseMultiplier))
  436. {
  437. RectI destRect;
  438. RectI stretchRect;
  439. RectI* mBitmapBounds = profile->mBitmapArrayRects.address();
  440. // Draw all corners first.
  441. //left border
  442. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderLeft]);
  443. //right border
  444. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderRight].extent.x,bounds.point.y),mBitmapBounds[BorderRight]);
  445. // End drawing corners
  446. // Begin drawing fill
  447. //fill stretch
  448. destRect.point.x = bounds.point.x + mBitmapBounds[BorderLeft].extent.x;
  449. destRect.extent.x = (bounds.extent.x) - mBitmapBounds[BorderLeft].extent.x - mBitmapBounds[BorderRight].extent.x;
  450. destRect.extent.y = mBitmapBounds[Fill].extent.y;
  451. destRect.point.y = bounds.point.y;
  452. //stretch it
  453. stretchRect = mBitmapBounds[Fill];
  454. stretchRect.inset(1,0);
  455. //draw it
  456. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  457. // End drawing fill
  458. }
  459. }
  460. // DAW: Render out the fixed bitmap borders based on a multiplier into the bitmap array
  461. // It renders left and right caps, with a sizable fill area in the middle to reach
  462. // the x extent. It does not stretch in the y direction.
  463. void renderFixedBitmapBordersFilledIndex(RectI &bounds, S32 startIndex, GuiControlProfile *profile)
  464. {
  465. // DAW: Indices into the bitmap array
  466. S32 NumBitmaps = 3;
  467. S32 BorderLeft = startIndex;
  468. S32 Fill = 1 + startIndex;
  469. S32 BorderRight = 2 + startIndex;
  470. dglClearBitmapModulation();
  471. if(profile->mBitmapArrayRects.size() >= (startIndex + NumBitmaps))
  472. {
  473. RectI destRect;
  474. RectI stretchRect;
  475. RectI* mBitmapBounds = profile->mBitmapArrayRects.address();
  476. // Draw all corners first.
  477. //left border
  478. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x,bounds.point.y),mBitmapBounds[BorderLeft]);
  479. //right border
  480. dglDrawBitmapSR(profile->mTextureHandle,Point2I(bounds.point.x + bounds.extent.x - mBitmapBounds[BorderRight].extent.x,bounds.point.y),mBitmapBounds[BorderRight]);
  481. // End drawing corners
  482. // Begin drawing fill
  483. //fill stretch
  484. destRect.point.x = bounds.point.x + mBitmapBounds[BorderLeft].extent.x;
  485. destRect.extent.x = (bounds.extent.x) - mBitmapBounds[BorderLeft].extent.x - mBitmapBounds[BorderRight].extent.x;
  486. destRect.extent.y = mBitmapBounds[Fill].extent.y;
  487. destRect.point.y = bounds.point.y;
  488. //stretch it
  489. stretchRect = mBitmapBounds[Fill];
  490. stretchRect.inset(1,0);
  491. //draw it
  492. dglDrawBitmapStretchSR(profile->mTextureHandle,destRect,stretchRect);
  493. // End drawing fill
  494. }
  495. }
  496. // DAW: Render out the fixed bitmap borders based on a multiplier into the bitmap array
  497. // It renders left and right caps, with a sizable fill area in the middle to reach
  498. // the x extent. It does not stretch in the y direction.
  499. void renderFixedBitmapBordersStretchYFilled(RectI &bounds, S32 baseMultiplier, GuiControlProfile *profile)
  500. {
  501. // DAW: Indices into the bitmap array
  502. S32 NumBitmaps = 3;
  503. S32 BorderLeft = NumBitmaps * baseMultiplier - NumBitmaps;
  504. S32 Fill = 1 + BorderLeft;
  505. S32 BorderRight = 2 + BorderLeft;
  506. dglClearBitmapModulation();
  507. if(profile->mBitmapArrayRects.size() >= (NumBitmaps * baseMultiplier))
  508. {
  509. RectI destRect;
  510. RectI stretchRect;
  511. RectI* mBitmapBounds = profile->mBitmapArrayRects.address();
  512. // Draw all corners first.
  513. //left border
  514. dglDrawBitmapStretchSR(profile->mTextureHandle, RectI( bounds.point.x, bounds.point.y, mBitmapBounds[BorderLeft].extent.x, bounds.extent.y ), mBitmapBounds[BorderLeft] );
  515. //right border
  516. 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] );
  517. // End drawing corners
  518. // Begin drawing fill
  519. //fill stretch
  520. destRect.point.x = bounds.point.x + mBitmapBounds[BorderLeft].extent.x;
  521. destRect.extent.x = (bounds.extent.x) - mBitmapBounds[BorderLeft].extent.x - mBitmapBounds[BorderRight].extent.x;
  522. destRect.extent.y = bounds.extent.y;
  523. destRect.point.y = bounds.point.y;
  524. //stretch it
  525. stretchRect = mBitmapBounds[Fill];
  526. stretchRect.inset(1,0);
  527. //draw it
  528. dglDrawBitmapStretchSR(profile->mTextureHandle, destRect, stretchRect);
  529. // End drawing fill
  530. }
  531. }