1
0

videoavs.m 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. #include <lib/std.mi>
  2. #include <lib/config.mi>
  3. #define MAIN_ATTRIBS_MGR
  4. Function updateVisCmd();
  5. Function updateOpenCloseDirection();
  6. // this implements the main app drawer
  7. #include "drawer.m"
  8. // this loads the skin config attributes definitions
  9. #include "attribs.m"
  10. Global Layout main, shade;
  11. Global Container maincontainer;
  12. Global Group frameGroup, ButtonsVideo,ButtonsVis,ButtonsVideoDetach,ButtonsVisDetach,ButtonsVideoSwitchto,ButtonsVisSwitchto;
  13. Global Button btnOpen,btnClose,btnMaximize,btnRestore, btnVisDetach, btnVideoDetach, btnVisSwitchto, btnVideoSwitchto;
  14. Global Layer resizer,resizerDrawer,OpenCloseHider;
  15. Global GuiObject VideoVisGroup;
  16. Global Int evershown;
  17. Global Int ismaximized;
  18. Global Int lasttotop;
  19. //------------------------------------------------------------------------
  20. // script startup
  21. //------------------------------------------------------------------------
  22. System.onScriptLoaded() {
  23. // init skin attributes for this script
  24. initAttribs();
  25. // bind objects
  26. frameGroup = getScriptGroup();
  27. btnOpen = frameGroup.findObject("videoavs.open");
  28. btnClose = frameGroup.findObject("videoavs.close");
  29. btnMaximize = frameGroup.findObject("button.vid.max");
  30. btnRestore = frameGroup.findObject("button.vid.restore");
  31. resizer = frameGroup.findObject("player.main.resizer");
  32. resizerDrawer = frameGroup.findObject("drawer.resizer");
  33. ButtonsVideo = frameGroup.findObject("buttons.video");
  34. ButtonsVis = frameGroup.findObject("buttons.vis");
  35. ButtonsVideoDetach = frameGroup.findObject("buttons.video.detach");
  36. ButtonsVisDetach = frameGroup.findObject("buttons.vis.detach");
  37. BtnVisDetach = ButtonsVisDetach.findObject("button.vis.detach");
  38. BtnVideoDetach = ButtonsVideoDetach.findObject("button.vid.detach");
  39. ButtonsVideoSwitchto = frameGroup.findObject("buttons.video.switchto");
  40. ButtonsVisSwitchto = frameGroup.findObject("buttons.vis.switchto");
  41. BtnVisSwitchto = ButtonsVisSwitchto.findObject("button.vis.Switchto");
  42. BtnVideoSwitchto = ButtonsVideoSwitchto.findObject("button.vid.Switchto");
  43. OpenCloseHider=frameGroup.findObject("openclosehider");
  44. main = frameGroup.getParentLayout();
  45. maincontainer = main.getContainer();
  46. VideoVisGroup = frameGroup.findObject("AVSGroup");
  47. VideoVisGroup.hide();
  48. // bind drawer script attribs to our attribs
  49. __drawer_directiontop_attrib = drawer_directiontop_attrib;
  50. __scrolldrawerattrib = scrolldrawerattrib;
  51. __drawer_directionbypass_attrib = drawer_directionbypass_attrib;
  52. __vis_detach_attrib = vis_detach_attrib;
  53. __video_detach_attrib = video_detach_attrib;
  54. // startup drawer script
  55. initDrawer(main, "VideoAVS");
  56. // more init
  57. if (vis_detach_attrib.getData() == "1" && video_detach_attrib.getData() == "1") OpenCloseHider.show();
  58. else OpenCloseHider.hide();
  59. lasttotop = 0;
  60. }
  61. //------------------------------------------------------------------------
  62. // grab a handle to the windowshade layout, can't get it in onScriptLoaded since it doesn't exists yet
  63. // also, first time we are shown, we update the viscmd button's action
  64. //------------------------------------------------------------------------
  65. main.onSetVisible(int show) {
  66. if (!evershown) {
  67. evershown = 1;
  68. if (!shade) {
  69. shade = maincontainer.getLayout("shade");
  70. }
  71. updateVisCmd();
  72. updateOpenCloseDirection();
  73. }
  74. }
  75. //------------------------------------------------------------------------
  76. // script shutdown
  77. //------------------------------------------------------------------------
  78. System.onScriptUnloading() {
  79. // shutdown the drawer script
  80. shutdownDrawer();
  81. }
  82. //------------------------------------------------------------------------
  83. // drawer script backend
  84. //------------------------------------------------------------------------
  85. Int getDrawerClosedHeight() {
  86. return 280; // this is the size of the layout when the drawer is closed
  87. }
  88. Int getDefaultDrawerOpenHeight() {
  89. return 510; // this is the default size of the layout, used when it opens the first time
  90. }
  91. // whenever the main window is resized while its drawer is closed, we change the height of the drawer the
  92. // next time it opens so that video will fit 4:3
  93. Int getDrawerOpenAutoHeight(int layoutwidth) {
  94. return (layoutwidth-6)*(3/4)+55+270;
  95. }
  96. WindowHolder getVisWindowHolder() {
  97. WindowHolder wh = getScriptGroup().findObject("myviswnd");
  98. return wh; // we return our vis windowholder object
  99. }
  100. WindowHolder getVideoWindowHolder() {
  101. WindowHolder wh = getScriptGroup().findObject("myvideownd");
  102. return wh; // we return our video windowholder object
  103. }
  104. //------------------------------------------------------------------------
  105. // optional drawer events
  106. //------------------------------------------------------------------------
  107. onDoneOpeningDrawer() {
  108. // nothing to do
  109. }
  110. onDoneClosingDrawer() {
  111. VideoVisGroup.hide();
  112. }
  113. onBeforeOpeningDrawer() {
  114. resizer.setXmlParam("resize", "bottomright");
  115. resizerDrawer.setXmlParam("resize", "bottomright");
  116. btnOpen.hide();
  117. main.setXmlParam("minimum_h", "380");
  118. VideoVisGroup.show();
  119. }
  120. onBeforeClosingDrawer() {
  121. resizer.setXmlParam("resize", "right");
  122. resizerDrawer.setXmlParam("resize", "right");
  123. main.setXmlParam("minimum_h", "280");
  124. btnOpen.show();
  125. }
  126. onShowVis() {
  127. ButtonsVideo.hide();
  128. ButtonsVideoDetach.hide();
  129. ButtonsVideoSwitchto.hide();
  130. ButtonsVis.show();
  131. ButtonsVisDetach.show();
  132. if (video_detach_attrib.getData() == "0") ButtonsVisSwitchto.show();
  133. }
  134. onHideVis() {
  135. ButtonsVis.hide();
  136. ButtonsVisDetach.hide();
  137. ButtonsVisSwitchto.hide();
  138. }
  139. onShowVideo() {
  140. ButtonsVis.hide();
  141. ButtonsVisDetach.hide();
  142. ButtonsVisSwitchto.hide();
  143. ButtonsVideo.show();
  144. ButtonsVideoDetach.show();
  145. if (vis_detach_attrib.getData() == "0") ButtonsVideoSwitchto.show();
  146. }
  147. onHideVideo() {
  148. ButtonsVideo.hide();
  149. ButtonsVideoDetach.hide();
  150. ButtonsVideoSwitchto.hide();
  151. }
  152. onDetachVideo() {
  153. ButtonsVisSwitchto.hide();
  154. if (vis_detach_attrib.getData() == "1") OpenCloseHider.show();
  155. }
  156. onAttachVideo() {
  157. ButtonsVisSwitchto.show();
  158. OpenCloseHider.hide();
  159. }
  160. onDetachVis() {
  161. ButtonsVideoSwitchto.hide();
  162. if (video_detach_attrib.getData() == "1") OpenCloseHider.show();
  163. }
  164. onAttachVis() {
  165. ButtonsVideoSwitchto.show();
  166. OpenCloseHider.hide();
  167. }
  168. onBeforeRestore() {
  169. btnMaximize.show();
  170. btnRestore.hide();
  171. }
  172. onBeforeMaximize() {
  173. btnRestore.show();
  174. btnMaximize.hide();
  175. }
  176. onCancelMaximize() {
  177. btnMaximize.show();
  178. btnRestore.hide();
  179. }
  180. // -----------------------------------------------------------------------
  181. // drawer control
  182. // -----------------------------------------------------------------------
  183. btnOpen.onLeftClick() {
  184. openDrawer();
  185. }
  186. btnClose.onLeftClick() {
  187. closeDrawer();
  188. }
  189. btnMaximize.onLeftClick() {
  190. maximizeWindow();
  191. }
  192. btnRestore.onLeftClick() {
  193. restoreWindow();
  194. }
  195. BtnVisDetach.onLeftClick() {
  196. detachVis();
  197. }
  198. BtnVideoDetach.onLeftClick() {
  199. detachVideo();
  200. }
  201. BtnVisSwitchto.onLeftClick() {
  202. switchToVideo();
  203. }
  204. BtnVideoSwitchto.onLeftClick() {
  205. switchToVis();
  206. }
  207. // -----------------------------------------------------------------------
  208. // when the player window is moved on the screen, we should update the up/down arrow for the open/close buttons since the
  209. // drawer may have changed the direction it will open depending on user settings
  210. // -----------------------------------------------------------------------
  211. main.onMove() {
  212. updateOpenCloseDirection();
  213. }
  214. // -----------------------------------------------------------------------
  215. // just invert the images when the direction is to top and restore them otherwise
  216. // -----------------------------------------------------------------------
  217. updateOpenCloseDirection() {
  218. if (isDrawerToTop()) {
  219. if (!lasttotop) {
  220. btnClose.setXmlParam("image", "player.button.videoavs");
  221. btnClose.setXmlParam("downimage", "player.button.videoavs.pressed");
  222. btnClose.setXmlParam("hoverImage", "player.button.videoavs.hover");
  223. btnOpen.setXmlParam("image", "player.button.videoavs.up");
  224. btnOpen.setXmlParam("downimage", "player.button.videoavs.up.pressed");
  225. btnOpen.setXmlParam("hoverImage", "player.button.videoavs.up.hover");
  226. lasttotop = 1;
  227. }
  228. } else {
  229. if (lasttotop) {
  230. btnOpen.setXmlParam("image", "player.button.videoavs");
  231. btnOpen.setXmlParam("downimage", "player.button.videoavs.pressed");
  232. btnOpen.setXmlParam("hoverImage", "player.button.videoavs.hover");
  233. btnClose.setXmlParam("image", "player.button.videoavs.up");
  234. btnClose.setXmlParam("downimage", "player.button.videoavs.up.pressed");
  235. btnClose.setXmlParam("hoverImage", "player.button.videoavs.up.hover");
  236. lasttotop = 0;
  237. }
  238. }
  239. }
  240. // -----------------------------------------------------------------------
  241. updateVisCmd() {
  242. Button btn = getScriptGroup().findObject("button.vis.misc");
  243. if (btn) {
  244. if (viscmd_menu_attrib.getData() == "1") {
  245. btn.setXmlParam("action", "Vis_Menu");
  246. } else {
  247. btn.setXmlParam("action", "Vis_Cfg");
  248. }
  249. }
  250. }