1
0

configtabs.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. #include <lib/std.mi>
  2. #include "attribs.m"
  3. function setTabs(int tabstate);
  4. function setTabContent(int contentstate);
  5. function OpenDrawer(int animate);
  6. function CloseDrawer(int animate);
  7. function updateAttribs();
  8. function ShowDrawer();
  9. function adjustSnapPoints(int DrawerOpen);
  10. Global Group frameGroup,PlayerMain,VideoVisGroup;
  11. Global Group tabs,tEQon,tEQoff,tOPTIONSon,tOPTIONSoff,tCOLORTHEMESon,tCOLORTHEMESoff;
  12. Global Group ContentEQ,ContentOPTIONS,ContentCOLORTHEMES;
  13. Global Layer mouseLayerEQ,mouseLayerOPTIONS,mouseLayerCOLORTHEMES;
  14. Global Button btnClose,btnOpen;
  15. Global Group Drawer,DrawerShadow,DrawerContent;
  16. Global GuiObject ColorThemes;
  17. Global Layout main;
  18. Global Int mychange;
  19. Global Boolean loaded=0;
  20. Global Timer deferred_opendrawer;
  21. System.onScriptLoaded() {
  22. initAttribs();
  23. frameGroup = getScriptGroup();
  24. main = frameGroup.getParentLayout();
  25. tabs=frameGroup.findObject("config.tabs");
  26. tEQon=frameGroup.findObject("config.tab.eq.on");
  27. tEQoff=frameGroup.findObject("config.tab.eq.off");
  28. tOPTIONSon=frameGroup.findObject("config.tab.options.on");
  29. tOPTIONSoff=frameGroup.findObject("config.tab.options.off");
  30. tCOLORTHEMESon=frameGroup.findObject("config.tab.colorthemes.on");
  31. tCOLORTHEMESoff=frameGroup.findObject("config.tab.colorthemes.off");
  32. ColorThemes=frameGroup.findObject("colorthemes");
  33. PlayerMain=frameGroup.findObject("player.main");
  34. VideoVisGroup = frameGroup.findObject("AVSGroup");
  35. ContentEQ=frameGroup.findObject("player.normal.drawer.eq");
  36. ContentOPTIONS=frameGroup.findObject("player.normal.drawer.options");
  37. ContentCOLORTHEMES=frameGroup.findObject("player.normal.drawer.colorthemes");
  38. mouseLayerEQ=frameGroup.findObject("mousetrapTabEQ");
  39. mouseLayerOPTIONS=frameGroup.findObject("mousetrapTabOPTIONS");
  40. mouseLayerCOLORTHEMES=frameGroup.findObject("mousetrapTabCOLORTHEMES");
  41. btnClose = frameGroup.findObject("drawer.button.close");
  42. btnOpen = frameGroup.findObject("drawer.button.open");
  43. drawer = frameGroup.findObject("player.normal.drawer");
  44. DrawerShadow = frameGroup.findObject("player.normal.drawer.shadow");
  45. DrawerContent = frameGroup.findObject("player.normal.drawer.content");
  46. int tabEQwidth=tEQon.getWidth();
  47. int tabOPTIONSwidth=tOPTIONSon.getWidth();
  48. int tOPTIONSx=tabEQwidth-3;
  49. int tCOLORTHEMESx=tabEQwidth+tabOPTIONSwidth-6;
  50. tOPTIONSon.setXmlParam("x",integertostring(tOPTIONSx));
  51. tOPTIONSoff.setXmlParam("x",integertostring(tOPTIONSx));
  52. tCOLORTHEMESoff.setXmlParam("x",integertostring(tCOLORTHEMESx));
  53. tCOLORTHEMESon.setXmlParam("x",integertostring(tCOLORTHEMESx));
  54. mychange = 1;
  55. setTabs(getPrivateInt("winamp5", "ConfigTab", 1));
  56. mychange = 0;
  57. if (getPrivateInt("winamp5", "DrawerOpen", 0)) {
  58. OpenDrawer(0);
  59. adjustSnapPoints(1);
  60. } else {
  61. adjustSnapPoints(0);
  62. }
  63. loaded=1;
  64. deferred_opendrawer = new Timer;
  65. deferred_opendrawer.setDelay(250);
  66. }
  67. System.onScriptUnloading() {
  68. delete deferred_opendrawer;
  69. }
  70. setTabs(int tabstate) {
  71. tEQon.hide();
  72. tOPTIONSon.hide();
  73. tCOLORTHEMESon.hide();
  74. if (tabstate==1) {
  75. tEQon.show();
  76. }
  77. if (tabstate==2) {
  78. tOPTIONSon.show();
  79. }
  80. if (tabstate==3) {
  81. tCOLORTHEMESon.show();
  82. }
  83. setTabContent(tabstate);
  84. setPrivateInt("winamp5", "ConfigTab", tabstate);
  85. updateAttribs();
  86. }
  87. setTabContent(int contentstate) {
  88. if (contentstate==1) {
  89. ContentEQ.show();
  90. ContentOPTIONS.hide();
  91. ContentCOLORTHEMES.hide();
  92. }
  93. if (contentstate==2) {
  94. ContentEQ.hide();
  95. ContentOPTIONS.show();
  96. ContentCOLORTHEMES.hide();
  97. }
  98. if (contentstate==3) {
  99. ContentEQ.hide();
  100. ContentOPTIONS.hide();
  101. ContentCOLORTHEMES.show();
  102. }
  103. }
  104. mouseLayerEQ.onLeftButtonDown(int x, int y) {
  105. setTabs(1);
  106. }
  107. mouseLayerOPTIONS.onLeftButtonDown(int x, int y) {
  108. setTabs(2);
  109. }
  110. mouseLayerCOLORTHEMES.onLeftButtonDown(int x, int y) {
  111. setTabs(3);
  112. }
  113. OpenDrawer(int animate) {
  114. btnOpen.hide();
  115. btnClose.show();
  116. main.beforeRedock();
  117. if (animate && scrollconfigdrawerattrib.getData() == "1") {
  118. lockUI();
  119. drawer.setTargetX(drawer.getGuiX());
  120. drawer.setTargetY(-147);
  121. drawer.setTargetW(drawer.getGuiW());
  122. drawer.setTargetH(drawer.getGuiH());
  123. drawer.setTargetSpeed(1);
  124. drawer.gotoTarget();
  125. } else {
  126. drawer.setXMLParam("y","-147");
  127. setPrivateInt("winamp5", "DrawerOpen", 1);
  128. ColorThemes.show();
  129. adjustSnapPoints(1);
  130. updateAttribs();
  131. main.Redock();
  132. }
  133. DrawerShadow.show();
  134. // main.setXmlParam("minimum_h", "397");
  135. }
  136. closeDrawer(int animate) {
  137. main.beforeRedock();
  138. // main.setXmlParam("minimum_h", "280");
  139. ColorThemes.hide();
  140. btnClose.hide();
  141. btnOpen.show();
  142. if (animate && scrollconfigdrawerattrib.getData() == "1") {
  143. lockUI();
  144. drawer.setTargetX(drawer.getGuiX());
  145. drawer.setTargetY(-263);
  146. drawer.setTargetW(drawer.getGuiW());
  147. drawer.setTargetH(drawer.getGuiH());
  148. drawer.setTargetSpeed(1);
  149. drawer.gotoTarget();
  150. } else {
  151. drawer.setXMLParam("y","-263");
  152. DrawerShadow.hide();
  153. setPrivateInt("winamp5", "DrawerOpen", 0);
  154. adjustSnapPoints(0);
  155. updateAttribs();
  156. main.redock();
  157. }
  158. }
  159. btnClose.onLeftClick() {
  160. closeDrawer(1);
  161. }
  162. btnOpen.onLeftClick() {
  163. openDrawer(1);
  164. }
  165. drawer.onTargetReached() {
  166. if (btnClose.isVisible()) {
  167. setPrivateInt("winamp5", "DrawerOpen", 1);
  168. ColorThemes.show();
  169. adjustSnapPoints(1);
  170. } else {
  171. DrawerShadow.hide();
  172. setPrivateInt("winamp5", "DrawerOpen", 0);
  173. adjustSnapPoints(0);
  174. }
  175. updateAttribs();
  176. main.redock();
  177. unlockUI();
  178. }
  179. ShowDrawer() {
  180. drawer.setXmlParam("y", "-147");
  181. ColorThemes.show();
  182. btnOpen.hide();
  183. btnClose.show();
  184. DrawerShadow.show();
  185. adjustSnapPoints(1);
  186. }
  187. adjustSnapPoints(int DrawerOpen) {
  188. int menuHeight=0;
  189. if (menubar_main_attrib.getData() == "0") menuHeight=17;
  190. if (DrawerOpen) {
  191. main.snapAdjust(0,0,0,0+menuHeight);
  192. } else {
  193. main.snapAdjust(0,0,0,116+menuHeight);
  194. }
  195. }
  196. menubar_main_attrib.onDataChanged() {
  197. int menuHeight=0;
  198. if (getData() == "0") menuHeight=17;
  199. main.beforeRedock();
  200. int DrawerOpen=getPrivateInt("winamp5", "DrawerOpen", 0);
  201. if (DrawerOpen) {
  202. main.snapAdjust(0,0,0,0+menuHeight);
  203. } else {
  204. main.snapAdjust(0,0,0,116+menuHeight);
  205. }
  206. main.Redock();
  207. }
  208. main.onResize(int x, int y, int w, int h) {
  209. int newXpos=w/2-163;
  210. DrawerContent.setXmlParam("x",integertostring(newXpos));
  211. }
  212. eq_visible_attrib.onDataChanged() {
  213. if (mychange) return;
  214. mychange = 1;
  215. if (getData() == "1") {
  216. main.getContainer().switchToLayout("normal"); // instead of main.show(), or linkwidth wont work
  217. deferred_opendrawer.start();
  218. } if (getData() == "0") {
  219. closeDrawer(1);
  220. }
  221. mychange = 0;
  222. }
  223. deferred_opendrawer.onTimer() {
  224. stop();
  225. setTabs(1);
  226. if (btnOpen.isVisible()) openDrawer(1);
  227. }
  228. updateAttribs() {
  229. if (mychange) return;
  230. mychange = 1;
  231. if (tabstate == 1 && !btnOpen.isVisible()) eq_visible_attrib.setData("1"); else eq_visible_attrib.setData("0");
  232. mychange = 0;
  233. }
  234. System.onKeyDown(String key) {
  235. if (key == "alt+g") {
  236. if (eq_visible_attrib.getData() == "0")
  237. eq_visible_attrib.setData("1");
  238. else
  239. eq_visible_attrib.setData("0");
  240. complete;
  241. }
  242. }