BsEngineGUI.cpp 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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. #include "CmFileSystem.h"
  13. using namespace CamelotFramework;
  14. namespace BansheeEngine
  15. {
  16. const String EngineGUI::DefaultFontPath = "C:\\arial.ttf";
  17. const UINT32 EngineGUI::DefaultFontSize = 10;
  18. const String EngineGUI::WindowBackgroundTexture = "..\\..\\..\\..\\Data\\Editor\\Skin\\WindowBgTile.psd";
  19. const String EngineGUI::ButtonNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ButtonNormal.psd";
  20. const String EngineGUI::ButtonHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ButtonHover.psd";
  21. const String EngineGUI::WindowFrameNormal = "..\\..\\..\\..\\Data\\Editor\\Skin\\WindowFrameNormal.psd";
  22. const String EngineGUI::WindowFrameFocused = "..\\..\\..\\..\\Data\\Editor\\Skin\\WindowFrameFocused.psd";
  23. const String EngineGUI::WindowTitleBarBg = "..\\..\\..\\..\\Data\\Editor\\Skin\\WindowTitleBarBg.psd";
  24. const String EngineGUI::WindowCloseButtonNormal = "..\\..\\..\\..\\Data\\Editor\\Skin\\WindowCloseBtnNormal.psd";
  25. const String EngineGUI::WindowCloseButtonHover = "..\\..\\..\\..\\Data\\Editor\\Skin\\WindowCloseBtnHover.psd";
  26. const String EngineGUI::WindowMinButtonNormal = "..\\..\\..\\..\\Data\\Editor\\Skin\\WindowMinBtnNormal.psd";
  27. const String EngineGUI::WindowMinButtonHover = "..\\..\\..\\..\\Data\\Editor\\Skin\\WindowMinBtnHover.psd";
  28. const String EngineGUI::TabbedBarBtnNormal = "..\\..\\..\\..\\Data\\Editor\\Skin\\TabbedButtonNormal.psd";
  29. const String EngineGUI::TabbedBarBtnActive = "..\\..\\..\\..\\Data\\Editor\\Skin\\TabbedButtonActive.psd";
  30. const String EngineGUI::InputBoxNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\InputBoxNormal.psd";
  31. const String EngineGUI::InputBoxHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\InputBoxHover.psd";
  32. const String EngineGUI::InputBoxFocusedTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\InputBoxFocused.psd";
  33. const String EngineGUI::ScrollBarUpNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarUpNormal.psd";
  34. const String EngineGUI::ScrollBarUpHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarUpHover.psd";
  35. const String EngineGUI::ScrollBarUpActiveTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarUpActive.psd";
  36. const String EngineGUI::ScrollBarDownNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarDownNormal.psd";
  37. const String EngineGUI::ScrollBarDownHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarDownHover.psd";
  38. const String EngineGUI::ScrollBarDownActiveTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarDownActive.psd";
  39. const String EngineGUI::ScrollBarLeftNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarLeftNormal.psd";
  40. const String EngineGUI::ScrollBarLeftHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarLeftHover.psd";
  41. const String EngineGUI::ScrollBarLeftActiveTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarLeftActive.psd";
  42. const String EngineGUI::ScrollBarRightNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarRightNormal.psd";
  43. const String EngineGUI::ScrollBarRightHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarRightHover.psd";
  44. const String EngineGUI::ScrollBarRightActiveTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarRightActive.psd";
  45. const String EngineGUI::ScrollBarHandleHorzNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarHorzHandleNormal.psd";
  46. const String EngineGUI::ScrollBarHandleHorzHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarHorzHandleHover.psd";
  47. const String EngineGUI::ScrollBarHandleHorzActiveTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarHorzHandleActive.psd";
  48. const String EngineGUI::ScrollBarHandleVertNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarVertHandleNormal.psd";
  49. const String EngineGUI::ScrollBarHandleVertHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarVertHandleHover.psd";
  50. const String EngineGUI::ScrollBarHandleVertActiveTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarVertHandleActive.psd";
  51. const String EngineGUI::DropDownBtnNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\DropDownNormal.psd";
  52. const String EngineGUI::DropDownBtnHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\DropDownHover.psd";
  53. const String EngineGUI::DropDownBoxBgTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\DropDownBoxBg.psd";
  54. const String EngineGUI::DropDownBoxEntryNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\DropDownButtonNormal.psd";
  55. const String EngineGUI::DropDownBoxEntryHoverTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\DropDownButtonHover.psd";
  56. const String EngineGUI::DropDownBoxBtnUpNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\DropDownBoxBtnUpNormal.psd";
  57. const String EngineGUI::DropDownBoxBtnDownNormalTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\DropDownBoxBtnDownNormal.psd";
  58. const String EngineGUI::DropDownBoxBtnUpArrowTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\DropDownBoxBtnUpArrow.psd";
  59. const String EngineGUI::DropDownBoxBtnDownArrowTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\DropDownBoxBtnDownArrow.psd";
  60. const String EngineGUI::ScrollBarBgTex = "..\\..\\..\\..\\Data\\Editor\\Skin\\ScrollBarBg.psd";
  61. EngineGUI::EngineGUI()
  62. {
  63. // TODO - Normally I want to load this from some file
  64. // Label
  65. // TODO - Instead of importing font every time, try to save a resource and then just load it?
  66. HFont font;
  67. {
  68. ImportOptionsPtr fontImportOptions = Importer::instance().createImportOptions(DefaultFontPath);
  69. if(rtti_is_of_type<FontImportOptions>(fontImportOptions))
  70. {
  71. FontImportOptions* importOptions = static_cast<FontImportOptions*>(fontImportOptions.get());
  72. Vector<CamelotFramework::UINT32>::type fontSizes;
  73. fontSizes.push_back(DefaultFontSize);
  74. importOptions->setFontSizes(fontSizes);
  75. importOptions->setAntialiasing(false);
  76. }
  77. font = Importer::instance().import(DefaultFontPath, fontImportOptions);
  78. }
  79. GUIElementStyle labelStyle;
  80. labelStyle.font = font;
  81. labelStyle.fontSize = DefaultFontSize;
  82. labelStyle.fixedWidth = false;
  83. labelStyle.fixedHeight = true;
  84. labelStyle.height = 16;
  85. labelStyle.minWidth = 10;
  86. mSkin.setStyle(GUILabel::getGUITypeName(), labelStyle);
  87. // Window frame
  88. HTexture windowFrameNormalTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowFrameNormal));
  89. HTexture windowFrameFocusedTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowFrameFocused));
  90. GUIElementStyle windowFrameStyle;
  91. windowFrameStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowFrameNormalTex));
  92. windowFrameStyle.focused.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowFrameFocusedTex));
  93. windowFrameStyle.border.left = 1;
  94. windowFrameStyle.border.right = 1;
  95. windowFrameStyle.border.top = 1;
  96. windowFrameStyle.border.bottom = 1;
  97. mSkin.setStyle("WindowFrame", windowFrameStyle);
  98. // Button
  99. HTexture buttonNormalTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ButtonNormalTex));
  100. HTexture buttonHoverTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ButtonHoverTex));
  101. GUIElementStyle buttonStyle;
  102. buttonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(buttonNormalTex));
  103. buttonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(buttonHoverTex));
  104. buttonStyle.border.left = 5;
  105. buttonStyle.border.right = 5;
  106. buttonStyle.border.top = 5;
  107. buttonStyle.border.bottom = 5;
  108. buttonStyle.margins.left = 4;
  109. buttonStyle.margins.right = 4;
  110. buttonStyle.margins.top = 4;
  111. buttonStyle.margins.bottom = 4;
  112. buttonStyle.contentOffset.left = 2;
  113. buttonStyle.contentOffset.right = 2;
  114. buttonStyle.fixedHeight = true;
  115. buttonStyle.height = 21;
  116. buttonStyle.minWidth = 50;
  117. buttonStyle.font = font;
  118. buttonStyle.fontSize = DefaultFontSize;
  119. buttonStyle.textHorzAlign = THA_Center;
  120. buttonStyle.textVertAlign = TVA_Center;
  121. mSkin.setStyle(GUIButton::getGUITypeName(), buttonStyle);
  122. // Window background texture
  123. HTexture windowBgTexture = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowBackgroundTexture));
  124. GUIElementStyle windowBgStyle;
  125. windowBgStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowBgTexture));
  126. mSkin.setStyle("WindowBackground", windowBgStyle);
  127. // Window title bar background
  128. HTexture windowTitleBarBg = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowTitleBarBg));
  129. GUIElementStyle titleBarBgStyle;
  130. titleBarBgStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowTitleBarBg));
  131. titleBarBgStyle.fixedHeight = true;
  132. titleBarBgStyle.height = 13;
  133. mSkin.setStyle("TitleBarBackground", titleBarBgStyle);
  134. // Tabbed title bar tab button
  135. HTexture tabbedBarBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + TabbedBarBtnNormal));
  136. HTexture tabbedBarBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + TabbedBarBtnActive));
  137. GUIElementStyle tabbedBarButton;
  138. tabbedBarButton.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(tabbedBarBtnNormal));
  139. tabbedBarButton.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(tabbedBarBtnActive));
  140. tabbedBarButton.active.texture = tabbedBarButton.hover.texture;
  141. tabbedBarButton.normalOn.texture = tabbedBarButton.hover.texture;
  142. tabbedBarButton.hoverOn.texture = tabbedBarButton.hover.texture;
  143. tabbedBarButton.activeOn.texture = tabbedBarButton.hover.texture;
  144. tabbedBarButton.fixedHeight = true;
  145. tabbedBarButton.height = 13;
  146. tabbedBarButton.minWidth = 10;
  147. tabbedBarButton.maxWidth = 110;
  148. tabbedBarButton.font = font;
  149. tabbedBarButton.fontSize = DefaultFontSize;
  150. tabbedBarButton.textHorzAlign = THA_Center;
  151. tabbedBarButton.textVertAlign = TVA_Center;
  152. mSkin.setStyle("TabbedBarBtn", tabbedBarButton);
  153. // Tabbed title bar drag/drop button
  154. GUIElementStyle tabbedBarDropButton;
  155. tabbedBarDropButton.fixedHeight = true;
  156. tabbedBarDropButton.fixedWidth = true;
  157. tabbedBarDropButton.height = 13;
  158. tabbedBarDropButton.width = 6;
  159. mSkin.setStyle("TabbedBarDropArea", tabbedBarDropButton);
  160. // Window minimize button
  161. HTexture winMinBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowMinButtonNormal));
  162. HTexture winMinBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowMinButtonHover));
  163. GUIElementStyle winMinButtonStyle;
  164. winMinButtonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMinBtnNormal));
  165. winMinButtonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMinBtnHover));
  166. winMinButtonStyle.active.texture = winMinButtonStyle.hover.texture;
  167. winMinButtonStyle.fixedHeight = true;
  168. winMinButtonStyle.fixedWidth = true;
  169. winMinButtonStyle.height = 7;
  170. winMinButtonStyle.width = 8;
  171. mSkin.setStyle("WinMinimizeBtn", winMinButtonStyle);
  172. // Window close button
  173. HTexture winCloseBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowCloseButtonNormal));
  174. HTexture winCloseBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + WindowCloseButtonHover));
  175. GUIElementStyle winCloseButtonStyle;
  176. winCloseButtonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winCloseBtnNormal));
  177. winCloseButtonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winCloseBtnHover));
  178. winCloseButtonStyle.active.texture = winCloseButtonStyle.active.texture;
  179. winCloseButtonStyle.fixedHeight = true;
  180. winCloseButtonStyle.fixedWidth = true;
  181. winCloseButtonStyle.height = 7;
  182. winCloseButtonStyle.width = 8;
  183. mSkin.setStyle("WinCloseBtn", winCloseButtonStyle);
  184. // Input box
  185. HTexture inputBoxNormalTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + InputBoxNormalTex));
  186. HTexture inputBoxHoverTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + InputBoxHoverTex));
  187. HTexture inputBoxFocusedTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + InputBoxFocusedTex));
  188. GUIElementStyle inputBoxStyle;
  189. inputBoxStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxNormalTex));
  190. inputBoxStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxHoverTex));
  191. inputBoxStyle.focused.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxFocusedTex));
  192. inputBoxStyle.active.texture = inputBoxStyle.normal.texture;
  193. inputBoxStyle.border.left = 5;
  194. inputBoxStyle.border.right = 5;
  195. inputBoxStyle.border.top = 5;
  196. inputBoxStyle.border.bottom = 5;
  197. inputBoxStyle.margins.left = 4;
  198. inputBoxStyle.margins.right = 4;
  199. inputBoxStyle.margins.top = 4;
  200. inputBoxStyle.margins.bottom = 4;
  201. inputBoxStyle.contentOffset.left = 2;
  202. inputBoxStyle.contentOffset.right = 2;
  203. inputBoxStyle.fixedHeight = true;
  204. inputBoxStyle.height = 21;
  205. inputBoxStyle.minWidth = 10;
  206. inputBoxStyle.font = font;
  207. inputBoxStyle.fontSize = DefaultFontSize;
  208. inputBoxStyle.textHorzAlign = THA_Left;
  209. inputBoxStyle.textVertAlign = TVA_Top;
  210. mSkin.setStyle(GUIInputBox::getGUITypeName(), inputBoxStyle);
  211. /************************************************************************/
  212. /* SCROLL BAR */
  213. /************************************************************************/
  214. // Up button
  215. HTexture scrollUpBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarUpNormalTex));
  216. HTexture scrollUpBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarUpHoverTex));
  217. HTexture scrollUpBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarUpActiveTex));
  218. GUIElementStyle scrollUpBtnStyle;
  219. scrollUpBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollUpBtnNormal));
  220. scrollUpBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollUpBtnHover));
  221. scrollUpBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollUpBtnActive));
  222. scrollUpBtnStyle.fixedHeight = true;
  223. scrollUpBtnStyle.fixedWidth = true;
  224. scrollUpBtnStyle.height = 4;
  225. scrollUpBtnStyle.width = 8;
  226. mSkin.setStyle("ScrollUpBtn", scrollUpBtnStyle);
  227. // Down button
  228. HTexture scrollDownBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarDownNormalTex));
  229. HTexture scrollDownBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarDownHoverTex));
  230. HTexture scrollDownBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarDownActiveTex));
  231. GUIElementStyle scrollDownBtnStyle;
  232. scrollDownBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollDownBtnNormal));
  233. scrollDownBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollDownBtnHover));
  234. scrollDownBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollDownBtnActive));
  235. scrollDownBtnStyle.fixedHeight = true;
  236. scrollDownBtnStyle.fixedWidth = true;
  237. scrollDownBtnStyle.height = 4;
  238. scrollDownBtnStyle.width = 8;
  239. mSkin.setStyle("ScrollDownBtn", scrollDownBtnStyle);
  240. // Left button
  241. HTexture scrollLeftBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarLeftNormalTex));
  242. HTexture scrollLeftBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarLeftHoverTex));
  243. HTexture scrollLeftBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarLeftActiveTex));
  244. GUIElementStyle scrollLeftBtnStyle;
  245. scrollLeftBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollLeftBtnNormal));
  246. scrollLeftBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollLeftBtnHover));
  247. scrollLeftBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollLeftBtnActive));
  248. scrollLeftBtnStyle.fixedHeight = true;
  249. scrollLeftBtnStyle.fixedWidth = true;
  250. scrollLeftBtnStyle.height = 8;
  251. scrollLeftBtnStyle.width = 4;
  252. mSkin.setStyle("ScrollLeftBtn", scrollLeftBtnStyle);
  253. // Right button
  254. HTexture scrollRightBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarRightNormalTex));
  255. HTexture scrollRightBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarRightHoverTex));
  256. HTexture scrollRightBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarRightActiveTex));
  257. GUIElementStyle scrollRightBtnStyle;
  258. scrollRightBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollRightBtnNormal));
  259. scrollRightBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollRightBtnHover));
  260. scrollRightBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollRightBtnActive));
  261. scrollRightBtnStyle.fixedHeight = true;
  262. scrollRightBtnStyle.fixedWidth = true;
  263. scrollRightBtnStyle.height = 8;
  264. scrollRightBtnStyle.width = 4;
  265. mSkin.setStyle("ScrollRightBtn", scrollRightBtnStyle);
  266. // Horizontal handle
  267. HTexture scrollBarHorzBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarHandleHorzNormalTex));
  268. HTexture scrollBarHorzBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarHandleHorzHoverTex));
  269. HTexture scrollBarHorzBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarHandleHorzActiveTex));
  270. GUIElementStyle scrollBarHorzBtnStyle;
  271. scrollBarHorzBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarHorzBtnNormal));
  272. scrollBarHorzBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarHorzBtnHover));
  273. scrollBarHorzBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarHorzBtnActive));
  274. scrollBarHorzBtnStyle.fixedHeight = true;
  275. scrollBarHorzBtnStyle.fixedWidth = true;
  276. scrollBarHorzBtnStyle.height = 6;
  277. scrollBarHorzBtnStyle.width = 4;
  278. mSkin.setStyle("ScrollBarHorzBtn", scrollBarHorzBtnStyle);
  279. // Vertical handle
  280. HTexture scrollBarVertBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarHandleVertNormalTex));
  281. HTexture scrollBarVertBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarHandleVertHoverTex));
  282. HTexture scrollBarVertBtnActive = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarHandleVertActiveTex));
  283. GUIElementStyle scrollBarVertBtnStyle;
  284. scrollBarVertBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarVertBtnNormal));
  285. scrollBarVertBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarVertBtnHover));
  286. scrollBarVertBtnStyle.active.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarVertBtnActive));
  287. scrollBarVertBtnStyle.fixedHeight = true;
  288. scrollBarVertBtnStyle.fixedWidth = true;
  289. scrollBarVertBtnStyle.height = 4;
  290. scrollBarVertBtnStyle.width = 6;
  291. mSkin.setStyle("ScrollBarVertBtn", scrollBarVertBtnStyle);
  292. HTexture scrollBarBg = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + ScrollBarBgTex));
  293. SpriteTexturePtr scrollBarBgPtr = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(scrollBarBg));
  294. // Vertical scroll bar
  295. GUIElementStyle vertScrollBarStyle;
  296. vertScrollBarStyle.normal.texture = scrollBarBgPtr;
  297. vertScrollBarStyle.hover.texture = scrollBarBgPtr;
  298. vertScrollBarStyle.active.texture = scrollBarBgPtr;
  299. vertScrollBarStyle.fixedHeight = false;
  300. vertScrollBarStyle.fixedWidth = true;
  301. vertScrollBarStyle.minHeight = 16;
  302. vertScrollBarStyle.width = 8;
  303. mSkin.setStyle("ScrollBarVert", vertScrollBarStyle);
  304. // Horizontal scroll bar
  305. GUIElementStyle horzScrollBarStyle;
  306. horzScrollBarStyle.normal.texture = scrollBarBgPtr;
  307. horzScrollBarStyle.hover.texture = scrollBarBgPtr;
  308. horzScrollBarStyle.active.texture = scrollBarBgPtr;
  309. horzScrollBarStyle.fixedHeight = true;
  310. horzScrollBarStyle.fixedWidth = false;
  311. horzScrollBarStyle.minWidth = 16;
  312. horzScrollBarStyle.height = 8;
  313. mSkin.setStyle("ScrollBarHorz", horzScrollBarStyle);
  314. /************************************************************************/
  315. /* DROP DOWN BOX */
  316. /************************************************************************/
  317. // DropDown button
  318. HTexture dropDownListNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBtnNormalTex));
  319. HTexture dropDownListHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBtnHoverTex));
  320. GUIElementStyle dropDownListStyle;
  321. dropDownListStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownListNormal));
  322. dropDownListStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownListHover));
  323. dropDownListStyle.active.texture = dropDownListStyle.hover.texture;
  324. dropDownListStyle.fixedHeight = true;
  325. dropDownListStyle.fixedWidth = false;
  326. dropDownListStyle.height = 13;
  327. dropDownListStyle.width = 30;
  328. dropDownListStyle.contentOffset.left = 3;
  329. dropDownListStyle.contentOffset.right = 11;
  330. dropDownListStyle.contentOffset.top = 1;
  331. dropDownListStyle.contentOffset.bottom = 1;
  332. dropDownListStyle.border.left = 1;
  333. dropDownListStyle.border.right = 10;
  334. dropDownListStyle.border.top = 1;
  335. dropDownListStyle.border.bottom = 1;
  336. dropDownListStyle.font = font;
  337. dropDownListStyle.fontSize = DefaultFontSize;
  338. dropDownListStyle.textHorzAlign = THA_Left;
  339. dropDownListStyle.textVertAlign = TVA_Top;
  340. mSkin.setStyle("DropDownList", dropDownListStyle);
  341. // DropDown scroll up button arrow
  342. HTexture dropDownBtnScrollUpArrow = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnUpArrowTex));
  343. GUIElementStyle dropDownScrollUpBtnArrowStyle;
  344. dropDownScrollUpBtnArrowStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollUpArrow));
  345. dropDownScrollUpBtnArrowStyle.hover.texture = dropDownScrollUpBtnArrowStyle.normal.texture;
  346. dropDownScrollUpBtnArrowStyle.active.texture = dropDownScrollUpBtnArrowStyle.hover.texture;
  347. dropDownScrollUpBtnArrowStyle.fixedHeight = true;
  348. dropDownScrollUpBtnArrowStyle.fixedWidth = false;
  349. dropDownScrollUpBtnArrowStyle.height = 7;
  350. dropDownScrollUpBtnArrowStyle.width = 30;
  351. dropDownScrollUpBtnArrowStyle.border.left = 1;
  352. dropDownScrollUpBtnArrowStyle.border.right = 1;
  353. dropDownScrollUpBtnArrowStyle.border.top = 1;
  354. dropDownScrollUpBtnArrowStyle.border.bottom = 1;
  355. mSkin.setStyle("DropDownScrollUpBtnArrow", dropDownScrollUpBtnArrowStyle);
  356. // DropDown scroll up button
  357. HTexture dropDownBtnScrollUpNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnUpNormalTex));
  358. GUIElementStyle dropDownScrollUpBtnStyle;
  359. dropDownScrollUpBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollUpNormal));
  360. dropDownScrollUpBtnStyle.hover.texture = dropDownScrollUpBtnStyle.normal.texture;
  361. dropDownScrollUpBtnStyle.active.texture = dropDownScrollUpBtnStyle.hover.texture;
  362. dropDownScrollUpBtnStyle.fixedHeight = true;
  363. dropDownScrollUpBtnStyle.fixedWidth = false;
  364. dropDownScrollUpBtnStyle.height = 7;
  365. dropDownScrollUpBtnStyle.width = 30;
  366. dropDownScrollUpBtnStyle.border.left = 1;
  367. dropDownScrollUpBtnStyle.border.right = 1;
  368. dropDownScrollUpBtnStyle.border.top = 1;
  369. dropDownScrollUpBtnStyle.border.bottom = 1;
  370. mSkin.setStyle("DropDownScrollUpBtn", dropDownScrollUpBtnStyle);
  371. // DropDown scroll down button arrow
  372. HTexture dropDownBtnScrollDownArrow = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnDownArrowTex));
  373. GUIElementStyle dropDownScrollDownBtnArrowStyle;
  374. dropDownScrollDownBtnArrowStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollDownArrow));
  375. dropDownScrollDownBtnArrowStyle.hover.texture = dropDownScrollDownBtnArrowStyle.normal.texture;
  376. dropDownScrollDownBtnArrowStyle.active.texture = dropDownScrollDownBtnArrowStyle.hover.texture;
  377. dropDownScrollDownBtnArrowStyle.fixedHeight = true;
  378. dropDownScrollDownBtnArrowStyle.fixedWidth = false;
  379. dropDownScrollDownBtnArrowStyle.height = 7;
  380. dropDownScrollDownBtnArrowStyle.width = 30;
  381. dropDownScrollDownBtnArrowStyle.border.left = 1;
  382. dropDownScrollDownBtnArrowStyle.border.right = 1;
  383. dropDownScrollDownBtnArrowStyle.border.top = 1;
  384. dropDownScrollDownBtnArrowStyle.border.bottom = 1;
  385. mSkin.setStyle("DropDownScrollDownBtnArrow", dropDownScrollDownBtnArrowStyle);
  386. // DropDown scroll down button
  387. HTexture dropDownBtnScrollDownNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBtnDownNormalTex));
  388. GUIElementStyle dropDownScrollDownBtnStyle;
  389. dropDownScrollDownBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBtnScrollDownNormal));
  390. dropDownScrollDownBtnStyle.hover.texture = dropDownScrollDownBtnStyle.normal.texture;
  391. dropDownScrollDownBtnStyle.active.texture = dropDownScrollDownBtnStyle.hover.texture;
  392. dropDownScrollDownBtnStyle.fixedHeight = true;
  393. dropDownScrollDownBtnStyle.fixedWidth = false;
  394. dropDownScrollDownBtnStyle.height = 7;
  395. dropDownScrollDownBtnStyle.width = 30;
  396. dropDownScrollDownBtnStyle.border.left = 1;
  397. dropDownScrollDownBtnStyle.border.right = 1;
  398. dropDownScrollDownBtnStyle.border.top = 1;
  399. dropDownScrollDownBtnStyle.border.bottom = 1;
  400. mSkin.setStyle("DropDownScrollDownBtn", dropDownScrollDownBtnStyle);
  401. // DropDown entry button
  402. HTexture dropDownEntryBtnNormal = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryNormalTex));
  403. HTexture dropDownEntryBtnHover = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxEntryHoverTex));
  404. GUIElementStyle dropDownEntryBtnStyle;
  405. dropDownEntryBtnStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownEntryBtnNormal));
  406. dropDownEntryBtnStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownEntryBtnHover));
  407. dropDownEntryBtnStyle.active.texture = dropDownEntryBtnStyle.hover.texture;
  408. dropDownEntryBtnStyle.fixedHeight = true;
  409. dropDownEntryBtnStyle.fixedWidth = false;
  410. dropDownEntryBtnStyle.height = 14;
  411. dropDownEntryBtnStyle.width = 30;
  412. dropDownEntryBtnStyle.border.left = 1;
  413. dropDownEntryBtnStyle.border.right = 1;
  414. dropDownEntryBtnStyle.border.top = 1;
  415. dropDownEntryBtnStyle.border.bottom = 1;
  416. mSkin.setStyle("DropDownEntryBtn", dropDownEntryBtnStyle);
  417. // DropDown box frame
  418. HTexture dropDownBoxBgTex = static_resource_cast<Texture>(Importer::instance().import(FileSystem::getCurrentPath() + "\\" + DropDownBoxBgTex));
  419. GUIElementStyle dropDownBoxStyle;
  420. dropDownBoxStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(dropDownBoxBgTex));
  421. dropDownBoxStyle.hover.texture = dropDownEntryBtnStyle.normal.texture;
  422. dropDownBoxStyle.active.texture = dropDownEntryBtnStyle.hover.texture;
  423. dropDownBoxStyle.fixedHeight = false;
  424. dropDownBoxStyle.fixedWidth = false;
  425. dropDownBoxStyle.height = 14;
  426. dropDownBoxStyle.width = 30;
  427. dropDownBoxStyle.border.left = 1;
  428. dropDownBoxStyle.border.right = 1;
  429. dropDownBoxStyle.border.top = 1;
  430. dropDownBoxStyle.border.bottom = 1;
  431. mSkin.setStyle("DropDownBox", dropDownBoxStyle);
  432. }
  433. }