BsEngineGUI.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. #include "BsEngineGUI.h"
  2. #include "BsGUIElementStyle.h"
  3. #include "BsGUILabel.h"
  4. #include "BsGUIButton.h"
  5. #include "BsGUIInputBox.h"
  6. #include "BsTextSprite.h"
  7. #include "BsSpriteTexture.h"
  8. #include "CmFont.h"
  9. #include "CmFontImportOptions.h"
  10. #include "CmImporter.h"
  11. #include "CmRTTIType.h"
  12. using namespace CamelotFramework;
  13. namespace BansheeEngine
  14. {
  15. const String EngineGUI::DefaultFontPath = "C:\\arial.ttf";
  16. const UINT32 EngineGUI::DefaultFontSize = 10;
  17. const String EngineGUI::WindowBackgroundTexture = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowBgTile.psd";
  18. const String EngineGUI::ButtonNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ButtonNormal.psd";
  19. const String EngineGUI::ButtonHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ButtonHover.psd";
  20. const String EngineGUI::WindowFrameNormal = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowFrameNormal.psd";
  21. const String EngineGUI::WindowFrameFocused = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowFrameFocused.psd";
  22. const String EngineGUI::WindowTitleBarBg = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowTitleBarBg.psd";
  23. const String EngineGUI::WindowCloseButtonNormal = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowCloseBtnNormal.psd";
  24. const String EngineGUI::WindowCloseButtonHover = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowCloseBtnHover.psd";
  25. const String EngineGUI::WindowMinButtonNormal = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowMinBtnNormal.psd";
  26. const String EngineGUI::WindowMinButtonHover = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowMinBtnHover.psd";
  27. const String EngineGUI::TabbedBarBtnNormal = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\TabbedButtonNormal.psd";
  28. const String EngineGUI::TabbedBarBtnActive = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\TabbedButtonActive.psd";
  29. const String EngineGUI::InputBoxNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\InputBoxNormal.psd";
  30. const String EngineGUI::InputBoxHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\InputBoxHover.psd";
  31. const String EngineGUI::InputBoxFocusedTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\InputBoxFocused.psd";
  32. const String EngineGUI::ScrollBarUpNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarUpNormal.psd";
  33. const String EngineGUI::ScrollBarUpHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarUpHover.psd";
  34. const String EngineGUI::ScrollBarUpActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarUpActive.psd";
  35. const String EngineGUI::ScrollBarDownNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarDownNormal.psd";
  36. const String EngineGUI::ScrollBarDownHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarDownHover.psd";
  37. const String EngineGUI::ScrollBarDownActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarDownActive.psd";
  38. const String EngineGUI::ScrollBarLeftNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarLeftNormal.psd";
  39. const String EngineGUI::ScrollBarLeftHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarLeftHover.psd";
  40. const String EngineGUI::ScrollBarLeftActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarLeftActive.psd";
  41. const String EngineGUI::ScrollBarRightNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarRightNormal.psd";
  42. const String EngineGUI::ScrollBarRightHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarRightHover.psd";
  43. const String EngineGUI::ScrollBarRightActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarRightActive.psd";
  44. const String EngineGUI::ScrollBarHandleHorzNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarHorzHandleNormal.psd";
  45. const String EngineGUI::ScrollBarHandleHorzHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarHorzHandleHover.psd";
  46. const String EngineGUI::ScrollBarHandleHorzActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarHorzHandleActive.psd";
  47. const String EngineGUI::ScrollBarHandleVertNormalTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarVertHandleNormal.psd";
  48. const String EngineGUI::ScrollBarHandleVertHoverTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarVertHandleHover.psd";
  49. const String EngineGUI::ScrollBarHandleVertActiveTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarVertHandleActive.psd";
  50. const String EngineGUI::ScrollBarBgTex = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\ScrollBarBg.psd";
  51. EngineGUI::EngineGUI()
  52. {
  53. // TODO - Normally I want to load this from some file
  54. // Label
  55. // TODO - Instead of importing font every time, try to save a resource and then just load it?
  56. HFont font;
  57. {
  58. ImportOptionsPtr fontImportOptions = Importer::instance().createImportOptions(DefaultFontPath);
  59. if(rtti_is_of_type<FontImportOptions>(fontImportOptions))
  60. {
  61. FontImportOptions* importOptions = static_cast<FontImportOptions*>(fontImportOptions.get());
  62. Vector<CamelotFramework::UINT32>::type fontSizes;
  63. fontSizes.push_back(DefaultFontSize);
  64. importOptions->setFontSizes(fontSizes);
  65. importOptions->setAntialiasing(false);
  66. }
  67. font = Importer::instance().import(DefaultFontPath, fontImportOptions);
  68. }
  69. GUIElementStyle labelStyle;
  70. labelStyle.font = font;
  71. labelStyle.fontSize = DefaultFontSize;
  72. labelStyle.fixedWidth = false;
  73. labelStyle.fixedHeight = true;
  74. labelStyle.height = 16;
  75. labelStyle.minWidth = 10;
  76. mSkin.setStyle(GUILabel::getGUITypeName(), labelStyle);
  77. // Window frame
  78. HTexture windowFrameNormalTex = static_resource_cast<Texture>(Importer::instance().import(WindowFrameNormal));
  79. HTexture windowFrameFocusedTex = static_resource_cast<Texture>(Importer::instance().import(WindowFrameFocused));
  80. GUIElementStyle windowFrameStyle;
  81. windowFrameStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowFrameNormalTex));
  82. windowFrameStyle.focused.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowFrameFocusedTex));
  83. windowFrameStyle.border.left = 1;
  84. windowFrameStyle.border.right = 1;
  85. windowFrameStyle.border.top = 1;
  86. windowFrameStyle.border.bottom = 1;
  87. mSkin.setStyle("WindowFrame", windowFrameStyle);
  88. // Button
  89. HTexture buttonNormalTex = static_resource_cast<Texture>(Importer::instance().import(ButtonNormalTex));
  90. HTexture buttonHoverTex = static_resource_cast<Texture>(Importer::instance().import(ButtonHoverTex));
  91. GUIElementStyle buttonStyle;
  92. buttonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(buttonNormalTex));
  93. buttonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(buttonHoverTex));
  94. buttonStyle.border.left = 5;
  95. buttonStyle.border.right = 5;
  96. buttonStyle.border.top = 5;
  97. buttonStyle.border.bottom = 5;
  98. buttonStyle.margins.left = 4;
  99. buttonStyle.margins.right = 4;
  100. buttonStyle.margins.top = 4;
  101. buttonStyle.margins.bottom = 4;
  102. buttonStyle.contentOffset.left = 2;
  103. buttonStyle.contentOffset.right = 2;
  104. buttonStyle.fixedHeight = true;
  105. buttonStyle.height = 21;
  106. buttonStyle.minWidth = 50;
  107. buttonStyle.font = font;
  108. buttonStyle.fontSize = DefaultFontSize;
  109. buttonStyle.textHorzAlign = THA_Center;
  110. buttonStyle.textVertAlign = TVA_Center;
  111. mSkin.setStyle(GUIButton::getGUITypeName(), buttonStyle);
  112. // Window background texture
  113. HTexture windowBgTexture = static_resource_cast<Texture>(Importer::instance().import(WindowBackgroundTexture));
  114. GUIElementStyle windowBgStyle;
  115. windowBgStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowBgTexture));
  116. mSkin.setStyle("WindowBackground", windowBgStyle);
  117. // Window title bar background
  118. HTexture windowTitleBarBg = static_resource_cast<Texture>(Importer::instance().import(WindowTitleBarBg));
  119. GUIElementStyle titleBarBgStyle;
  120. titleBarBgStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowTitleBarBg));
  121. titleBarBgStyle.fixedHeight = true;
  122. titleBarBgStyle.height = 13;
  123. mSkin.setStyle("TitleBarBackground", titleBarBgStyle);
  124. // Tabbed title bar tab button
  125. HTexture tabbedBarBtnNormal = static_resource_cast<Texture>(Importer::instance().import(TabbedBarBtnNormal));
  126. HTexture tabbedBarBtnActive = static_resource_cast<Texture>(Importer::instance().import(TabbedBarBtnActive));
  127. GUIElementStyle tabbedBarButton;
  128. tabbedBarButton.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(tabbedBarBtnNormal));
  129. tabbedBarButton.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(tabbedBarBtnActive));
  130. tabbedBarButton.active.texture = tabbedBarButton.hover.texture;
  131. tabbedBarButton.normalOn.texture = tabbedBarButton.hover.texture;
  132. tabbedBarButton.hoverOn.texture = tabbedBarButton.hover.texture;
  133. tabbedBarButton.activeOn.texture = tabbedBarButton.hover.texture;
  134. tabbedBarButton.fixedHeight = true;
  135. tabbedBarButton.height = 13;
  136. tabbedBarButton.minWidth = 10;
  137. tabbedBarButton.maxWidth = 110;
  138. tabbedBarButton.font = font;
  139. tabbedBarButton.fontSize = DefaultFontSize;
  140. tabbedBarButton.textHorzAlign = THA_Center;
  141. tabbedBarButton.textVertAlign = TVA_Center;
  142. mSkin.setStyle("TabbedBarBtn", tabbedBarButton);
  143. // Tabbed title bar drag/drop button
  144. GUIElementStyle tabbedBarDropButton;
  145. tabbedBarDropButton.fixedHeight = true;
  146. tabbedBarDropButton.fixedWidth = true;
  147. tabbedBarDropButton.height = 13;
  148. tabbedBarDropButton.width = 6;
  149. mSkin.setStyle("TabbedBarDropArea", tabbedBarDropButton);
  150. // Window minimize button
  151. HTexture winMinBtnNormal = static_resource_cast<Texture>(Importer::instance().import(WindowMinButtonNormal));
  152. HTexture winMinBtnHover = static_resource_cast<Texture>(Importer::instance().import(WindowMinButtonHover));
  153. GUIElementStyle winMinButtonStyle;
  154. winMinButtonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMinBtnNormal));
  155. winMinButtonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMinBtnHover));
  156. winMinButtonStyle.active.texture = winMinButtonStyle.hover.texture;
  157. winMinButtonStyle.fixedHeight = true;
  158. winMinButtonStyle.fixedWidth = true;
  159. winMinButtonStyle.height = 7;
  160. winMinButtonStyle.width = 8;
  161. mSkin.setStyle("WinMinimizeBtn", winMinButtonStyle);
  162. // Window close button
  163. HTexture winCloseBtnNormal = static_resource_cast<Texture>(Importer::instance().import(WindowCloseButtonNormal));
  164. HTexture winCloseBtnHover = static_resource_cast<Texture>(Importer::instance().import(WindowCloseButtonHover));
  165. GUIElementStyle winCloseButtonStyle;
  166. winCloseButtonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winCloseBtnNormal));
  167. winCloseButtonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winCloseBtnHover));
  168. winCloseButtonStyle.active.texture = winCloseButtonStyle.active.texture;
  169. winCloseButtonStyle.fixedHeight = true;
  170. winCloseButtonStyle.fixedWidth = true;
  171. winCloseButtonStyle.height = 7;
  172. winCloseButtonStyle.width = 8;
  173. mSkin.setStyle("WinCloseBtn", winCloseButtonStyle);
  174. // Input box
  175. HTexture inputBoxNormalTex = static_resource_cast<Texture>(Importer::instance().import(InputBoxNormalTex));
  176. HTexture inputBoxHoverTex = static_resource_cast<Texture>(Importer::instance().import(InputBoxHoverTex));
  177. HTexture inputBoxFocusedTex = static_resource_cast<Texture>(Importer::instance().import(InputBoxFocusedTex));
  178. GUIElementStyle inputBoxStyle;
  179. inputBoxStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxNormalTex));
  180. inputBoxStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxHoverTex));
  181. inputBoxStyle.focused.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxFocusedTex));
  182. inputBoxStyle.active.texture = inputBoxStyle.focused.texture;
  183. inputBoxStyle.border.left = 5;
  184. inputBoxStyle.border.right = 5;
  185. inputBoxStyle.border.top = 5;
  186. inputBoxStyle.border.bottom = 5;
  187. inputBoxStyle.margins.left = 4;
  188. inputBoxStyle.margins.right = 4;
  189. inputBoxStyle.margins.top = 4;
  190. inputBoxStyle.margins.bottom = 4;
  191. inputBoxStyle.contentOffset.left = 2;
  192. inputBoxStyle.contentOffset.right = 2;
  193. inputBoxStyle.fixedHeight = true;
  194. inputBoxStyle.height = 21;
  195. inputBoxStyle.minWidth = 10;
  196. inputBoxStyle.font = font;
  197. inputBoxStyle.fontSize = DefaultFontSize;
  198. inputBoxStyle.textHorzAlign = THA_Left;
  199. inputBoxStyle.textVertAlign = TVA_Top;
  200. mSkin.setStyle(GUIInputBox::getGUITypeName(), inputBoxStyle);
  201. /************************************************************************/
  202. /* SCROLL BAR */
  203. /************************************************************************/
  204. // Up button
  205. HTexture scrollUpBtnNormal = static_resource_cast<Texture>(Importer::instance().import(ScrollBarUpNormalTex));
  206. HTexture scrollUpBtnHover = static_resource_cast<Texture>(Importer::instance().import(ScrollBarUpHoverTex));
  207. HTexture scrollUpBtnActive = static_resource_cast<Texture>(Importer::instance().import(ScrollBarUpActiveTex));
  208. GUIElementStyle scrollUpBtnStyle;
  209. scrollUpBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollUpBtnNormal));
  210. scrollUpBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollUpBtnHover));
  211. scrollUpBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollUpBtnActive));
  212. scrollUpBtnStyle.fixedHeight = true;
  213. scrollUpBtnStyle.fixedWidth = true;
  214. scrollUpBtnStyle.height = 4;
  215. scrollUpBtnStyle.width = 8;
  216. mSkin.setStyle("ScrollUpBtn", scrollUpBtnStyle);
  217. // Down button
  218. HTexture scrollDownBtnNormal = static_resource_cast<Texture>(Importer::instance().import(ScrollBarDownNormalTex));
  219. HTexture scrollDownBtnHover = static_resource_cast<Texture>(Importer::instance().import(ScrollBarDownHoverTex));
  220. HTexture scrollDownBtnActive = static_resource_cast<Texture>(Importer::instance().import(ScrollBarDownActiveTex));
  221. GUIElementStyle scrollDownBtnStyle;
  222. scrollDownBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollDownBtnNormal));
  223. scrollDownBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollDownBtnHover));
  224. scrollDownBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollDownBtnActive));
  225. scrollDownBtnStyle.fixedHeight = true;
  226. scrollDownBtnStyle.fixedWidth = true;
  227. scrollDownBtnStyle.height = 4;
  228. scrollDownBtnStyle.width = 8;
  229. mSkin.setStyle("ScrollDownBtn", scrollDownBtnStyle);
  230. // Left button
  231. HTexture scrollLeftBtnNormal = static_resource_cast<Texture>(Importer::instance().import(ScrollBarLeftNormalTex));
  232. HTexture scrollLeftBtnHover = static_resource_cast<Texture>(Importer::instance().import(ScrollBarLeftHoverTex));
  233. HTexture scrollLeftBtnActive = static_resource_cast<Texture>(Importer::instance().import(ScrollBarLeftActiveTex));
  234. GUIElementStyle scrollLeftBtnStyle;
  235. scrollLeftBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollLeftBtnNormal));
  236. scrollLeftBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollLeftBtnHover));
  237. scrollLeftBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollLeftBtnActive));
  238. scrollLeftBtnStyle.fixedHeight = true;
  239. scrollLeftBtnStyle.fixedWidth = true;
  240. scrollLeftBtnStyle.height = 8;
  241. scrollLeftBtnStyle.width = 4;
  242. mSkin.setStyle("ScrollLeftBtn", scrollLeftBtnStyle);
  243. // Right button
  244. HTexture scrollRightBtnNormal = static_resource_cast<Texture>(Importer::instance().import(ScrollBarRightNormalTex));
  245. HTexture scrollRightBtnHover = static_resource_cast<Texture>(Importer::instance().import(ScrollBarRightHoverTex));
  246. HTexture scrollRightBtnActive = static_resource_cast<Texture>(Importer::instance().import(ScrollBarRightActiveTex));
  247. GUIElementStyle scrollRightBtnStyle;
  248. scrollRightBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollRightBtnNormal));
  249. scrollRightBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollRightBtnHover));
  250. scrollRightBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollRightBtnActive));
  251. scrollRightBtnStyle.fixedHeight = true;
  252. scrollRightBtnStyle.fixedWidth = true;
  253. scrollRightBtnStyle.height = 8;
  254. scrollRightBtnStyle.width = 4;
  255. mSkin.setStyle("ScrollRightBtn", scrollRightBtnStyle);
  256. // Horizontal handle
  257. HTexture scrollBarHorzBtnNormal = static_resource_cast<Texture>(Importer::instance().import(ScrollBarHandleHorzNormalTex));
  258. HTexture scrollBarHorzBtnHover = static_resource_cast<Texture>(Importer::instance().import(ScrollBarHandleHorzHoverTex));
  259. HTexture scrollBarHorzBtnActive = static_resource_cast<Texture>(Importer::instance().import(ScrollBarHandleHorzActiveTex));
  260. GUIElementStyle scrollBarHorzBtnStyle;
  261. scrollBarHorzBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarHorzBtnNormal));
  262. scrollBarHorzBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarHorzBtnHover));
  263. scrollBarHorzBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarHorzBtnActive));
  264. scrollBarHorzBtnStyle.fixedHeight = true;
  265. scrollBarHorzBtnStyle.fixedWidth = true;
  266. scrollBarHorzBtnStyle.height = 6;
  267. scrollBarHorzBtnStyle.width = 4;
  268. mSkin.setStyle("ScrollBarHorzBtn", scrollBarHorzBtnStyle);
  269. // Vertical handle
  270. HTexture scrollBarVertBtnNormal = static_resource_cast<Texture>(Importer::instance().import(ScrollBarHandleVertNormalTex));
  271. HTexture scrollBarVertBtnHover = static_resource_cast<Texture>(Importer::instance().import(ScrollBarHandleVertHoverTex));
  272. HTexture scrollBarVertBtnActive = static_resource_cast<Texture>(Importer::instance().import(ScrollBarHandleVertActiveTex));
  273. GUIElementStyle scrollBarVertBtnStyle;
  274. scrollBarVertBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarVertBtnNormal));
  275. scrollBarVertBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarVertBtnHover));
  276. scrollBarVertBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarVertBtnActive));
  277. scrollBarVertBtnStyle.fixedHeight = true;
  278. scrollBarVertBtnStyle.fixedWidth = true;
  279. scrollBarVertBtnStyle.height = 4;
  280. scrollBarVertBtnStyle.width = 6;
  281. mSkin.setStyle("ScrollBarVertBtn", scrollBarVertBtnStyle);
  282. HTexture scrollBarBg = static_resource_cast<Texture>(Importer::instance().import(ScrollBarBgTex));
  283. SpriteTexturePtr scrollBarBgPtr = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarBg));
  284. // Vertical scroll bar
  285. GUIElementStyle vertScrollBarStyle;
  286. vertScrollBarStyle.normal.texture = scrollBarBgPtr;
  287. vertScrollBarStyle.hover.texture = scrollBarBgPtr;
  288. vertScrollBarStyle.active.texture = scrollBarBgPtr;
  289. vertScrollBarStyle.fixedHeight = false;
  290. vertScrollBarStyle.fixedWidth = true;
  291. vertScrollBarStyle.minHeight = 16;
  292. vertScrollBarStyle.width = 8;
  293. mSkin.setStyle("ScrollBarVert", vertScrollBarStyle);
  294. // Horizontal scroll bar
  295. GUIElementStyle horzScrollBarStyle;
  296. horzScrollBarStyle.normal.texture = scrollBarBgPtr;
  297. horzScrollBarStyle.hover.texture = scrollBarBgPtr;
  298. horzScrollBarStyle.active.texture = scrollBarBgPtr;
  299. horzScrollBarStyle.fixedHeight = true;
  300. horzScrollBarStyle.fixedWidth = false;
  301. horzScrollBarStyle.minWidth = 16;
  302. horzScrollBarStyle.height = 8;
  303. mSkin.setStyle("ScrollBarHorz", horzScrollBarStyle);
  304. }
  305. }