Guest User

graphical browser for WSH

a guest
Jan 24th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 126.27 KB | None | 0 0
  1. // ==PREPROCESSOR==
  2. // @name "CoverFlow View v1.4"
  3. // @version "1.4.0"
  4. // @author "Br3tt aka Falstaff >> http://br3tt.deviantart.com"
  5. // @feature "v1.4"
  6. // @feature "watch-metadb"
  7. // @feature "dragdrop"
  8. // ==/PREPROCESSOR==
  9.  
  10. // [Requirements]
  11. // * foobar2000 v1.1 or better >> http://foobar2000.org
  12. // * WSH panel Mod v1.5.2 or better >> http://code.google.com/p/foo-wsh-panel-mod/downloads/list
  13. // [/Requirements]
  14.  
  15. // [Installation]
  16. // * import/paste this jscript into a WSH Panel Mod instance of your foobar2000 layout (DUI or CUI)
  17. // [/Installation]
  18.  
  19. // [Informations]
  20. // * change colors and fonts in foobar2000 Preferences > DefaultUI or ColumsUI
  21. // * Some Settings (*USER_xxx ones only) can be changed in window Properties
  22. // * middle click on cover > Send album tracks to specific playlist "CoverFlow View"
  23. // * keyboard keys : left/right arrows, Home/End, page up/down, spacebar to set focus on the centered album, Return key to play ...
  24. // * Type as you Search feature : type artist name with keyboard to automatically set the focus on its first album
  25. // * Think about it >> Adjust size/effects of the panel according to your cpu capacities to avoid bad perf
  26. // [/Informations]
  27.  
  28. //=================================================// General declarations
  29. SM_CXVSCROLL = 2;
  30. SM_CYHSCROLL = 3;
  31. DLGC_WANTARROWS = 0x0001;
  32. DLGC_WANTALLKEYS = 0x0004;
  33. var padding_top=10;
  34. // }}
  35. // Use with MenuManager()
  36. // {{
  37. MF_STRING = 0x00000000;
  38. MF_SEPARATOR = 0x00000800;
  39. MF_GRAYED = 0x00000001;
  40. MF_DISABLED = 0x00000002;
  41. MF_POPUP = 0x00000010;
  42. // }}
  43. // Used in window.SetCursor()
  44. // {{
  45. IDC_ARROW = 32512;
  46. IDC_IBEAM = 32513;
  47. IDC_WAIT = 32514;
  48. IDC_CROSS = 32515;
  49. IDC_UPARROW = 32516;
  50. IDC_SIZE = 32640;
  51. IDC_ICON = 32641;
  52. IDC_SIZENWSE = 32642;
  53. IDC_SIZENESW = 32643;
  54. IDC_SIZEWE = 32644;
  55. IDC_SIZENS = 32645;
  56. IDC_SIZEALL = 32646;
  57. IDC_NO = 32648;
  58. IDC_APPSTARTING = 32650;
  59. IDC_HAND = 32649;
  60. IDC_HELP = 32651;
  61. // }}
  62. // Use with GdiDrawText()
  63. // {{
  64. var DT_LEFT = 0x00000000;
  65. var DT_RIGHT = 0x00000002;
  66. var DT_TOP = 0x00000000;
  67. var DT_CENTER = 0x00000001;
  68. var DT_VCENTER = 0x00000004;
  69. var DT_WORDBREAK = 0x00000010;
  70. var DT_SINGLELINE = 0x00000020;
  71. var DT_CALCRECT = 0x00000400;
  72. var DT_NOPREFIX = 0x00000800;
  73. var DT_EDITCONTROL = 0x00002000;
  74. var DT_END_ELLIPSIS = 0x00008000;
  75. // }}
  76. // Keyboard Flags & Tools
  77. // {{
  78. var VK_BACK = 0x08;
  79. var VK_RETURN = 0x0D;
  80. var VK_SHIFT = 0x10;
  81. var VK_CONTROL = 0x11;
  82. var VK_ALT = 0x12;
  83. var VK_ESCAPE = 0x1B;
  84. var VK_PGUP = 0x21;
  85. var VK_PGDN = 0x22;
  86. var VK_END = 0x23;
  87. var VK_HOME = 0x24;
  88. var VK_LEFT = 0x25;
  89. var VK_UP = 0x26;
  90. var VK_RIGHT = 0x27;
  91. var VK_DOWN = 0x28;
  92. var VK_INSERT = 0x2D;
  93. var VK_DELETE = 0x2E;
  94. var VK_SPACEBAR = 0x20;
  95. var KMask = {
  96. none: 0,
  97. ctrl: 1,
  98. shift: 2,
  99. ctrlshift: 3,
  100. ctrlalt: 4,
  101. ctrlaltshift: 5,
  102. alt: 6
  103. };
  104. function GetKeyboardMask() {
  105. var c = utils.IsKeyPressed(VK_CONTROL) ? true : false;
  106. var a = utils.IsKeyPressed(VK_ALT) ? true : false;
  107. var s = utils.IsKeyPressed(VK_SHIFT) ? true : false;
  108. var ret = KMask.none;
  109. if (c && !a && !s) ret = KMask.ctrl;
  110. if (!c && !a && s) ret = KMask.shift;
  111. if (c && !a && s) ret = KMask.ctrlshift;
  112. if (c && a && !s) ret = KMask.ctrlalt;
  113. if (c && a && s) ret = KMask.ctrlaltshift;
  114. if (!c && a && !s) ret = KMask.alt;
  115. return ret;
  116. };
  117. // }}
  118. // {{
  119. // Used in window.GetColorCUI()
  120. ColorTypeCUI = {
  121. text: 0,
  122. selection_text: 1,
  123. inactive_selection_text: 2,
  124. background: 3,
  125. selection_background: 4,
  126. inactive_selection_background: 5,
  127. active_item_frame: 6
  128. };
  129. // Used in window.GetFontCUI()
  130. FontTypeCUI = {
  131. items: 0,
  132. labels: 1
  133. };
  134. // Used in window.GetColorDUI()
  135. ColorTypeDUI = {
  136. text: 0,
  137. background: 1,
  138. highlight: 2,
  139. selection: 3
  140. };
  141. // Used in window.GetFontDUI()
  142. FontTypeDUI = {
  143. defaults: 0,
  144. tabs: 1,
  145. lists: 2,
  146. playlists: 3,
  147. statusbar: 4,
  148. console: 5
  149. };
  150. //}}
  151. // {{
  152. // Used in gr.DrawString()
  153. function StringFormat() {
  154. var h_align = 0,
  155. v_align = 0,
  156. trimming = 0,
  157. flags = 0;
  158. switch (arguments.length) {
  159. case 3:
  160. trimming = arguments[2];
  161. case 2:
  162. v_align = arguments[1];
  163. case 1:
  164. h_align = arguments[0];
  165. break;
  166. default:
  167. return 0;
  168. };
  169. return ((h_align << 28) | (v_align << 24) | (trimming << 20) | flags);
  170. };
  171. StringAlignment = {
  172. Near: 0,
  173. Centre: 1,
  174. Far: 2
  175. };
  176. var lt_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Near);
  177. var ct_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Near);
  178. var rt_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Near);
  179. var lc_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Centre);
  180. var cc_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Centre);
  181. var rc_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Centre);
  182. var lb_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Far);
  183. var cb_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Far);
  184. var rb_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Far);
  185. //}}
  186. // {{
  187. // Used in utils.GetAlbumArt()
  188. AlbumArtId = {
  189. front: 0,
  190. back: 1,
  191. disc: 2,
  192. icon: 3,
  193. artist: 4
  194. };
  195. //}}
  196. // {{
  197. // Used everywhere!
  198. function RGB(r, g, b) {
  199. return (0xff000000 | (r << 16) | (g << 8) | (b));
  200. };
  201. function RGBA(r, g, b, a) {
  202. return ((a << 24) | (r << 16) | (g << 8) | (b));
  203. };
  204. function getAlpha(color) {
  205. return ((color >> 24) & 0xff);
  206. }
  207.  
  208. function getRed(color) {
  209. return ((color >> 16) & 0xff);
  210. }
  211.  
  212. function getGreen(color) {
  213. return ((color >> 8) & 0xff);
  214. }
  215.  
  216. function getBlue(color) {
  217. return (color & 0xff);
  218. }
  219. function num(strg, nb) {
  220. var i;
  221. var str = strg.toString();
  222. var k = nb - str.length;
  223. if (k > 0) {
  224. for (i=0;i<k;i++) {
  225. str = "0" + str;
  226. };
  227. };
  228. return str.toString();
  229. };
  230. //Time formatting secondes -> 0:00
  231. function TimeFromSeconds(t){
  232. var zpad = function(n){
  233. var str = n.toString();
  234. return (str.length<2) ? "0"+str : str;
  235. };
  236. var h = Math.floor(t/3600); t-=h*3600;
  237. var m = Math.floor(t/60); t-=m*60;
  238. var s = Math.floor(t);
  239. if(h>0) return h.toString()+":"+zpad(m)+":"+zpad(s);
  240. return m.toString()+":"+zpad(s);
  241. };
  242. function TrackType(trkpath) {
  243. var taggable;
  244. var type;
  245. switch (trkpath) {
  246. case "file":
  247. taggable = 1;
  248. type = 0;
  249. break;
  250. case "cdda":
  251. taggable = 1;
  252. type = 1;
  253. break;
  254. case "FOO_":
  255. taggable = 0;
  256. type = 2;
  257. break;
  258. case "http":
  259. taggable = 0;
  260. type = 3;
  261. break;
  262. case "mms:":
  263. taggable = 0;
  264. type = 3;
  265. break;
  266. case "unpa":
  267. taggable = 0;
  268. type = 4;
  269. break;
  270. default:
  271. taggable = 0;
  272. type = 5;
  273. };
  274. return type;
  275. };
  276. function replaceAll(str, search, repl) {
  277. while (str.indexOf(search) != -1) {
  278. str = str.replace(search, repl);
  279. };
  280. return str;
  281. };
  282. function removeAccents(str) {
  283. var norm = new Array('À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë',
  284. 'Ì','Í','Î','Ï', 'Ð','Ñ','Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü','Ý',
  285. 'Þ','ß');
  286. var spec = new Array('A','A','A','A','A','A','AE','C','E','E','E','E',
  287. 'I','I','I','I', 'D','N','O','O','O','O','O','O','U','U','U','U','Y',
  288. 'b','SS');
  289. for (var i = 0; i < spec.length; i++) {
  290. str = replaceAll(str, norm[i], spec[i]);
  291. };
  292. return str;
  293. };
  294. //}}
  295.  
  296. //=================================================// Button object
  297. ButtonStates = {normal: 0, hover: 1, down: 2};
  298. button = function (normal, hover, down) {
  299. this.img = Array(normal, hover, down);
  300. this.w = this.img[0].Width;
  301. this.h = this.img[0].Height;
  302. this.state = ButtonStates.normal;
  303. this.update = function (normal, hover, down) {
  304. this.img = Array(normal, hover, down);
  305. };
  306. this.draw = function (gr, x, y, alpha) {
  307. this.x = x;
  308. this.y = y;
  309. this.img[this.state] && gr.DrawImage(this.img[this.state], this.x, this.y, this.w, this.h, 0, 0, this.w, this.h);
  310. };
  311. this.display_context_menu = function (x, y, id) {};
  312. this.repaint = function () {
  313. window.RepaintRect(this.x, this.y, this.w, this.h);
  314. };
  315. this.checkstate = function (event, x, y) {
  316. this.ishover = (x > this.x && x < this.x + this.w - 1 && y > this.y && y < this.y + this.h - 1);
  317. this.old = this.state;
  318. switch (event) {
  319. case "down":
  320. switch(this.state) {
  321. case ButtonStates.normal:
  322. case ButtonStates.hover:
  323. this.state = this.ishover ? ButtonStates.down : ButtonStates.normal;
  324. break;
  325. };
  326. break;
  327. case "up":
  328. this.state = this.ishover ? ButtonStates.hover : ButtonStates.normal;
  329. break;
  330. case "right":
  331. if(this.ishover) this.display_context_menu(x, y, id);
  332. break;
  333. case "move":
  334. switch(this.state) {
  335. case ButtonStates.normal:
  336. case ButtonStates.hover:
  337. this.state = this.ishover ? ButtonStates.hover : ButtonStates.normal;
  338. break;
  339. };
  340. break;
  341. case "leave":
  342. this.state = this.isdown ? ButtonStates.down : ButtonStates.normal;
  343. break;
  344. };
  345. if(this.state!=this.old) this.repaint();
  346. return this.state;
  347. };
  348. };
  349.  
  350. //=================================================// Tools (general)
  351. function get_system_scrollbar_width() {
  352. var tmp = utils.GetSystemMetrics(SM_CXVSCROLL);
  353. return tmp;
  354. };
  355.  
  356. function get_system_scrollbar_height() {
  357. var tmp = utils.GetSystemMetrics(SM_CYHSCROLL);
  358. return tmp;
  359. };
  360.  
  361. String.prototype.repeat = function(num) {
  362. return new Array(num+1).join(this);
  363. };
  364.  
  365. function getTimestamp() {
  366. var d, s1, s2, s3, hh, min, sec, timestamp;
  367. d = new Date();
  368. s1 = d.getFullYear();
  369. s2 = (d.getMonth() + 1);
  370. s3 = d.getDate();
  371. hh = d.getHours();
  372. min = d.getMinutes();
  373. sec = d.getSeconds();
  374. if(s3.length == 1) s3 = "0" + s3;
  375. timestamp = s1 + ((s2 < 10) ? "-0" : "-") + s2 + ((s3 < 10) ? "-0" : "-" ) + s3 + ((hh < 10) ? " 0" : " ") + hh + ((min < 10) ? ":0" : ":") + min + ((sec < 10) ? ":0" : ":") + sec;
  376. return timestamp;
  377. };
  378.  
  379. //=================================================// Image declarations
  380. var nocover;
  381. var nocover_img;
  382. var streamcover;
  383. var streamcover_img;
  384. var loading;
  385. var loading_img;
  386. var star_img_off;
  387. var star_img_on;
  388. var star_img_hov;
  389. var star_img_kill;
  390. var toggle_scrollbar;
  391. var menu_button;
  392. var glass_reflect_img;
  393. var fading_bottom_height=140;
  394. var cover_padding_left=0;
  395. //=================================================// Cover Tools
  396. image_cache = function () {
  397. this._cachelist = {};
  398. this.hit = function (item) {
  399. var img = this._cachelist[item.metadb.Path];
  400. if (list.drag_stop && typeof img == "undefined") {
  401. if(!cover.load_timer) {
  402. cover.load_timer = window.SetTimeout(function() {
  403. utils.GetAlbumArtAsync(window.ID, item.metadb, 0, true, false, false);
  404. cover.load_timer && window.ClearTimeout(cover.load_timer);
  405. cover.load_timer = false;
  406. }, 1);
  407. };
  408. };
  409. return img;
  410. };
  411. this.getit = function (item, image) {
  412. var img;
  413. var quotient = (panel.flat_mode) ? 2 : 12;
  414. if(cover.keepaspectratio) {
  415. if(!image) {
  416. var pw = (cover.w+cover.margin*quotient);
  417. var ph = (cover.h+cover.margin*quotient);
  418. } else {
  419. if(image.Height>=image.Width) {
  420. var ratio = image.Width / image.Height;
  421. var pw = (cover.w+cover.margin*quotient)*ratio;
  422. var ph = (cover.h+cover.margin*quotient);
  423. } else {
  424. var ratio = image.Height / image.Width;
  425. var pw = (cover.w+cover.margin*quotient);
  426. var ph = (cover.h+cover.margin*quotient)*ratio;
  427. };
  428. };
  429. } else {
  430. var pw = (cover.w+cover.margin*quotient);
  431. var ph = (cover.h+cover.margin*quotient);
  432. };
  433. // item.cover_type : 0 = nocover, 1 = external cover, 2 = embedded cover, 3 = stream
  434. if(item.track_type!=3) {
  435. if(item.metadb) {
  436. img = FormatCover(image, pw, ph);
  437. if(!img) {
  438. img = nocover_img;
  439. item.cover_type = 0;
  440. } else {
  441. item.cover_type = 1;
  442. };
  443. };
  444. } else {
  445. img = streamcover_img;
  446. item.cover_type = 3;
  447. };
  448. this._cachelist[item.metadb.Path] = img;
  449. return img;
  450. };
  451. };
  452. var g_image_cache = new image_cache;
  453.  
  454. function FormatCover(image, w, h) {
  455. if(!image || w<=0 || h<=0) return image;
  456. return image.Resize(w, h, 2);
  457. };
  458.  
  459. function reset_cover_timers() {
  460. cover.load_timer && window.ClearTimeout(cover.load_timer);
  461. cover.load_timer = false;
  462. };
  463.  
  464. function on_get_album_art_done(metadb, art_id, image, image_path) {
  465. var len = list.item.length;
  466. for(var i=0;i<len;i++) {
  467. if(list.item[i].metadb) {
  468. if(list.item[i].metadb.Compare(metadb)) {
  469. list.item[i].cover_img = g_image_cache.getit(list.item[i], image);
  470. if(!list.item[i].y) list.item[i].y = 5; else if(list.item[i].y<5) list.item[i].y = 5;
  471. try{
  472. window.RepaintRect(cover.pad_left_mid-10, list.item[i].y-10, ww-cover.pad_left_mid+20, list.item[i].h+20);
  473. } catch(e) {};
  474. break;
  475. };
  476. };
  477. };
  478. };
  479.  
  480. //=================================================// Item Object
  481. ItemStates = {normal: 0, hover: 1, selected: 2};
  482. item = function (id, idx, gh_id) {
  483. var i;
  484. if (typeof this.id == "undefined") {
  485. if(id<0) {
  486. this.id = id;
  487. this.idx = idx;
  488. this.gh_id = gh_id;
  489. this.metadb = false;
  490. this.albumartist = "";
  491. this.album = "";
  492. this.track_type = null;
  493. this.group_info = "";
  494. } else {
  495. this.id = id;
  496. this.idx = idx;
  497. this.gh_id = gh_id;
  498. this.metadb = list.handlelist.Item(this.id);
  499. if(this.metadb) {
  500. this.albumartist = tf_albumartist.EvalWithMetadb(this.metadb);
  501. this.album = tf_album.EvalWithMetadb(this.metadb);
  502. this.track_type = TrackType(this.metadb.rawpath.substring(0,4));
  503. this.group_info = tf_group_info.EvalWithMetadb(this.metadb);
  504. this.group_key = tf_group_key.EvalWithMetadb(this.metadb);
  505. };
  506. };
  507. this.left = 0;
  508. this.top = 0;
  509. };
  510.  
  511. this.update_infos = function() {
  512. if(this.metadb) {
  513. this.albumartist = tf_albumartist.EvalWithMetadb(this.metadb);
  514. this.track_type = TrackType(this.metadb.rawpath.substring(0,4));
  515. this.group_info = tf_group_info.EvalWithMetadb(this.metadb);
  516. this.group_key = tf_group_key.EvalWithMetadb(this.metadb);
  517. } else {
  518. this.albumartist = "";
  519. this.track_type = null;
  520. this.group_info = "";
  521. };
  522. };
  523.  
  524. this.draw = function(gr, id, idx, gh_id, level, show) {
  525.  
  526. this.h = cover.h;
  527. this.w = cover.h;
  528. this.x = cover_padding_left+10;
  529. number_per_row = Math.floor(ww/(cover.h+cover.pad_left_mid+cover.pad_right_mid));
  530.  
  531. this.x += ((gh_id)%number_per_row)*(cover.h+cover_padding_left+cover_padding_right);
  532. this.y = Math.floor((idx)/number_per_row)*this.h-padding_top;
  533.  
  534. // cover
  535. if(this.id>=0) {
  536. this.cover_img = g_image_cache.hit(this);
  537. if(typeof(this.cover_img) != "undefined") {
  538. // *** check aspect ratio *** //
  539. if(this.cover_img.Height>=this.cover_img.Width) {
  540. var ratio = this.cover_img.Width / this.cover_img.Height;
  541. var pw = this.w*ratio;
  542. var ph = this.h;
  543. this.left = Math.floor((ph-pw) / 2);
  544. this.top = 0;
  545. this.x += this.left;
  546. this.y += this.top;
  547. this.w = this.w - this.left*2 - cover.margin - 1;
  548. this.h = this.h - this.top*2 - cover.margin - 1;
  549. } else {
  550. var ratio = this.cover_img.Height / this.cover_img.Width;
  551. var pw = this.w;
  552. var ph = this.h*ratio;
  553. this.top = Math.floor((pw-ph) / 2);
  554. this.left = 0;
  555. this.x += this.left;
  556. this.y += this.top;
  557. this.w = this.w - this.left*2 - cover.margin - 1;
  558. this.h = this.h - this.top*2 - cover.margin - 1;
  559. };
  560. // Draw true Cover
  561. gr.DrawImage(this.cover_img, this.x, Math.floor(cover.margin/2)+this.y, this.w, this.h, 1, 1, this.cover_img.Width-2, this.cover_img.Height-2);
  562. gr.DrawRect(this.x, Math.floor(cover.margin/2)+this.y, this.w-1, this.h-1, 1.0, RGB(90,90,90));
  563. } else {
  564. // adjust cover size with margin
  565. this.w = this.w - cover.margin - 1;
  566. this.h = this.h - cover.margin - 1;
  567. gr.DrawRect(this.x, Math.floor(cover.margin/2)+this.y, this.w-1, this.h-1, 1.0, g_textcolor&0x40ffffff);
  568. };
  569. // Draw text item info if flat mode activated
  570. if(panel.show_text) {
  571. var text_y = this.y+this.h+this.top+Math.floor(cover.margin/2);
  572. var text_x = this.x-15;
  573. var text_h = cover.margin;
  574. var text_w = this.w+30;
  575. if(list.item[list.mid].id>=0) {
  576. try {
  577. gr.GdiDrawText(this.album, g_font, g_textcolor, text_x, text_y, text_w, text_h, DT_CENTER | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
  578. } catch(e) {
  579. gr.GdiDrawText(this.album, gdi.Font("tahoma", 11), g_textcolor, text_x, text_y, text_w, text_h, DT_CENTER | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
  580. };
  581. };
  582. };
  583. // focus item border (selection marker)
  584. if(typeof(this.cover_img) != "undefined" && this.gh_id == list.selected_gh_id) {
  585. list.focus_id_item_idx = this.idx;
  586. if(cover.draw_focus_border) {
  587. gr.DrawRect(this.x, Math.floor(cover.margin/2)+this.y+2, this.w-cover.margin*0-2, this.h-cover.margin*0-2, 4.0, g_backcolor_sel);
  588. };
  589. };
  590. // total tracks counter
  591. if(panel.tracks_counter_show) {
  592. if(typeof(this.cover_img) != "undefined") {
  593. gr.SetSmoothingMode(2);
  594. gr.FillRoundRect(this.x-7, Math.floor(cover.margin/2)+this.y-6, 28, 16, 3, 3, RGBA(0,0,0,210));
  595. gr.DrawRoundRect(this.x-6, Math.floor(cover.margin/2)+this.y-5, 26, 14, 1, 1, 1.0, RGBA(255,255,255,60));
  596. gr.DrawRoundRect(this.x-7, Math.floor(cover.margin/2)+this.y-6, 28, 16, 1, 1, 1.0, RGBA(0,0,0,200));
  597. gr.GdiDrawText(list.groups[this.gh_id], mini_font, RGB(250,250,250), this.x-6, Math.floor(cover.margin/2)+this.y-6, 29, 16, DT_CENTER | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
  598. gr.SetSmoothingMode(0);
  599. };
  600. };
  601. };
  602. this.y = this.y + Math.floor(cover.margin/2);
  603. };
  604.  
  605. this.checkstate = function (event, x, y, id) {
  606. if(y<toolbar.delta) return true;
  607. if(this.id>=0) {
  608. this.ishover = (x > this.x && x < this.x + this.w && y >= this.y && y < this.y + this.h);
  609. } else {
  610. this.ishover = false;
  611. };
  612. switch (event) {
  613. case "down":
  614. if(this.id>=0) {
  615. if(plman.IsPlaylistItemSelected(panel.active_playlist, this.id)) {
  616. if(this.ishover) {
  617. if(panel.lock_playlist) {
  618. this.checkstate("mid", x, y, id);
  619. } else {
  620. SelectGroupItems(this.id, this.gh_id, true);
  621. };
  622. if(panel.scroll_effect) {
  623. if(this.idx<list.mid) {
  624. var tmp = list.mid - this.idx;
  625. scrollcoverflow(0, tmp, scroll.factor);
  626. } else if(this.idx>list.mid) {
  627. var tmp = this.idx - list.mid;
  628. scrollcoverflow(tmp, 0, scroll.factor);
  629. }
  630. }
  631. g_saved = this;
  632. refresh_spv(panel.active_playlist, bool_on_size);
  633. };
  634. } else {
  635.  
  636. if(this.ishover) {
  637.  
  638. if(utils.IsKeyPressed(VK_SHIFT)) {
  639. if(list.focus_id != this.id) {
  640. if(list.SHIFT_start_id!=null) {
  641. //SelectAtoB(list.SHIFT_start_id, this.id);
  642. } else {
  643. //SelectAtoB(list.focus_id, this.id);
  644. };
  645. };
  646. } else if(utils.IsKeyPressed(VK_CONTROL)) {
  647. if(panel.lock_playlist) {
  648. this.checkstate("mid", x, y, id);
  649. } else {
  650. SelectGroupItems(this.id, this.gh_id, true);
  651. if(panel.scroll_effect) {
  652. if(this.idx<list.mid) {
  653. var tmp = list.mid - this.idx;
  654. scrollcoverflow(0, tmp, scroll.factor);
  655. } else if(this.idx>list.mid) {
  656. var tmp = this.idx - list.mid;
  657. scrollcoverflow(tmp, 0, scroll.factor);
  658. }
  659. }
  660. };
  661. } else {
  662. list.selected_gh_id = this.gh_id;
  663. list.focus_id = this.id;
  664. bypass.on_item_focus_change = true;
  665. SelectGroupItems(this.id, this.gh_id, true);
  666. if(panel.scroll_effect) {
  667. if(this.idx<list.mid) {
  668. var tmp = list.mid - this.idx;
  669. scrollcoverflow(0, tmp, scroll.factor);
  670. } else if(this.idx>list.mid) {
  671. var tmp = this.idx - list.mid;
  672. scrollcoverflow(tmp, 0, scroll.factor);
  673. }
  674. }
  675. g_saved = this;
  676. if(panel.lock_playlist) {
  677. g_saved.checkstate("mid", x, y, id);
  678. };
  679. };
  680. };
  681. };
  682. } else {
  683. g_saved = null;
  684. };
  685. break;
  686.  
  687. case "dblclk":
  688. if(this.id>=0 && g_saved!=null) {
  689. if(plman.IsPlaylistItemSelected(panel.active_playlist, this.id)) {
  690. if(panel.lock_playlist) {
  691. if(this.id==g_saved.id) {
  692. plman.ExecutePlaylistDefaultAction(panel.active_playlist, list.hlist[g_saved.gh_id]);
  693. g_saved = null;
  694. };
  695. } else {
  696. if(this.id==g_saved.id) {
  697. plman.ExecutePlaylistDefaultAction(panel.active_playlist, list.hlist[g_saved.gh_id]);
  698. g_saved = null;
  699. window.Repaint();
  700. };
  701. };
  702. };
  703. };
  704. break;
  705.  
  706. case "mid":
  707. if(this.ishover) {
  708. if(plman.GetPlaylistName(panel.active_playlist)!="CoverFlow View") {
  709. SelectGroupItems(this.id, this.gh_id, true);
  710. var found = false;
  711. var playlist_CF_id = 0;
  712. var source_pl = panel.active_playlist;
  713. var pl_count = plman.PlaylistCount;
  714. for(var i=0; i<pl_count; i++) {
  715. if(plman.GetPlaylistName(i)=="CoverFlow View") {
  716. found = true;
  717. playlist_CF_id = i;
  718. break;
  719. };
  720. };
  721. if(!found) {
  722. bypass.on_playlists_changed = true;
  723. playlist_CF_id = plman.PlaylistCount;
  724. plman.CreatePlaylist(plman.PlaylistCount, "CoverFlow View");
  725. };
  726. plman.ActivePlaylist = playlist_CF_id;
  727. fb.ClearPlaylist();
  728. var insert_index = fb.PlaylistItemCount(playlist_CF_id);
  729. plman.InsertPlaylistItems(playlist_CF_id, insert_index, plman.GetPlaylistSelectedItems(source_pl), false);
  730. plman.SetPlaylistFocusItem(playlist_CF_id, 0);
  731. };
  732. };
  733. break;
  734.  
  735. case "right":
  736. if(this.ishover) {
  737. if(panel.lock_playlist) {
  738. list.selected_gh_id = this.gh_id;
  739. list.focus_id = this.id;
  740. bypass.on_item_focus_change = true;
  741. this.checkstate("mid", x, y, id);
  742. } else {
  743. list.selected_gh_id = this.gh_id;
  744. list.focus_id = this.id;
  745. bypass.on_item_focus_change = true;
  746. SelectGroupItems(this.id, this.gh_id, true);
  747. };
  748. };
  749. break;
  750.  
  751. case "up":
  752.  
  753. break;
  754.  
  755. case "move":
  756.  
  757. break;
  758.  
  759. case "leave":
  760.  
  761. break;
  762. };
  763. return this.ishover;
  764. };
  765. };
  766.  
  767. //=================================================// Titleformat field
  768. var tf_path = fb.TitleFormat("$left(%_path_raw%,4)");
  769. var tf_albumartist = fb.TitleFormat("$if(%length%,%album artist%,'Stream')");
  770. var tf_album = fb.TitleFormat("$if2(%album%,$if(%length%,'Single(s)','web radios'))");
  771. var tf_group_key = fb.TitleFormat(window.GetProperty("*USER.group Key", "%album artist%%album%"));
  772. var tf_group_info = fb.TitleFormat(window.GetProperty("*USER.group TF text info", "%album artist%[ | %album%][ | %date%]"));
  773.  
  774. //=================================================// Globals
  775. var g_instancetype = window.InstanceType;
  776. var g_font = null;
  777. var g_font_headers = null;
  778. var mini_font = gdi.Font("uni 05_53", 8, 0);
  779. var ww = 0, wh = 0;
  780. var mouse_x = 0, mouse_y = 0;
  781. var g_textcolor = 0, g_textcolor_sel = 0, g_textcolor_hl = 0, g_backcolor = 0, g_backcolor_sel = 0;
  782. var g_metadb;
  783. var bool_on_size = false;
  784. var number_per_row;
  785. var g_search_string = "";
  786. var incsearch_font = gdi.Font("lucida console", 9, 0);
  787. var incsearch_font_big = gdi.Font("lucida console", 20, 1);
  788. var clear_incsearch_timer = false;
  789. var incsearch_timer = false;
  790. var incsearch_timer_lock = false;
  791. var g_saved = null;
  792. var hand = false;
  793. var g_menu_displayed = false;
  794. var g_drag = false;
  795.  
  796. bypass = {
  797. on_item_focus_change: false,
  798. on_playlists_changed: false
  799. };
  800. panel = {
  801. max_width: 250,
  802. max_height: 250,
  803. arr_buttons: Array(),
  804. show_text: window.GetProperty("SYSTEM.panel.album.info", true),
  805. lock_playlist: window.GetProperty("SYSTEM.panel.lock.playlist", false),
  806. active_playlist: window.GetProperty("SYSTEM.panel.active.playlist", 0),
  807. vertical_mode: true,
  808. scroll_effect: window.GetProperty("SYSTEM.panel.scroll.effect", false),
  809. flat_mode: window.GetProperty("SYSTEM.panel.flat.mode", true),
  810. custom_textcolor: window.GetProperty("*USER.custom.text.color.normal", "RGB(0,0,0)"),
  811. custom_textcolor_selection: window.GetProperty("*USER.custom.text.color.selection", "RGB(183,50,0)"),
  812. custom_backcolor: window.GetProperty("*USER.custom.background.color", "RGB(255,255,255)"),
  813. custom_colors: window.GetProperty("SYSTEM.panel.custom.colors", true),
  814. tracks_counter_show: window.GetProperty("*USER.total.tracks.visible", false),
  815. side_shadows_show: window.GetProperty("SYSTEM.side.shadows.visible", false),
  816. properties_separator: window.GetProperty("----------------------------", "----------------------------")
  817. };
  818. list = {
  819. first_launch: true,
  820. total: 0,
  821. total_gh: 0,
  822. start_id: 0,
  823. nbvis: 0,
  824. mid: 0,
  825. item: Array(),
  826. hlist: Array(),
  827. groups: Array(),
  828. handlelist: null,
  829. metadblist_selection: plman.GetPlaylistSelectedItems(panel.active_playlist),
  830. focus_id: 0,
  831. focus_id_item_idx: 0,
  832. selected_gh_id: 0,
  833. marker_id: 0,
  834. gh_id: 0,
  835. mousewheel_timer_value: 20,
  836. key_timer_value: 60,
  837. nowplaying: 0,
  838. SHIFT_start_id: null,
  839. SHIFT_count: 0,
  840. inc_search_noresult: false,
  841. nb_cover_to_draw: 0,
  842. buttonclicked: false,
  843. drag_stop: true,
  844. drag_timer: false
  845. };
  846. images = {
  847. nocover: window.GetProperty("*USER.image.nocover", ".\\images\\nocover.png"),
  848. stream: window.GetProperty("*USER.image.stream", ".\\images\\stream.png"),
  849. loading: window.GetProperty("*USER.image.loading", ".\\images\\loading.png")
  850. };
  851. scroll = {
  852. delta: 0,
  853. step: 0,
  854. timerID: false,
  855. nbcovers: 0,
  856. direction: 0,
  857. factor: 2
  858. };
  859. toolbar = {
  860. h: 0,
  861. lock: false,
  862. button_total: 3,
  863. buttons: Array(),
  864. timerID_on: false,
  865. timerID_off: false,
  866. timerID1: false,
  867. timerID2: false,
  868. collapsed_y: -24,
  869. delta: 0,
  870. step: 3,
  871. state: false
  872. };
  873. scrollbar = {
  874. theme: false,
  875. themed: window.GetProperty("SYSTEM.scrollbar.themed", false),
  876. show: window.GetProperty("SYSTEM.scrollbar.visible", false),
  877. visible: true,
  878. step: 3,
  879. letter: null,
  880. button_total: 2,
  881. arr_buttons: Array(),
  882. timerID: false
  883. }
  884. hscrollbar = {
  885. hover: false,
  886. x: 0,
  887. y: 0,
  888. default_h: get_system_scrollbar_height(),
  889. h: get_system_scrollbar_height(),
  890. w: 0
  891. };
  892. vscrollbar = {
  893. hover: false,
  894. x: 0,
  895. y: 0,
  896. default_w: get_system_scrollbar_width(),
  897. w: get_system_scrollbar_width(),
  898. h: 0
  899. };
  900. scrollbarbt = {
  901. timerID1: false,
  902. timerID2: false,
  903. timer1_value: 400,
  904. timer2_value: 60
  905. };
  906. button_up = {
  907. img_normal: null,
  908. img_hover: null,
  909. img_down: null,
  910. x: 0,
  911. y: 0,
  912. w: hscrollbar.default_h,
  913. h: hscrollbar.default_h
  914. };
  915. button_down = {
  916. img_normal: null,
  917. img_hover: null,
  918. img_down: null,
  919. x: 0,
  920. y: 0,
  921. w: hscrollbar.default_h,
  922. h: hscrollbar.default_h
  923. };
  924. cursor = {
  925. bt: null,
  926. img_normal: null,
  927. img_hover: null,
  928. img_down: null,
  929. popup: null,
  930. x: 0,
  931. y: 0,
  932. w: hscrollbar.default_h,
  933. h: hscrollbar.default_h,
  934. default_w: hscrollbar.default_h+3,
  935. hover: false,
  936. drag: false,
  937. grap_x: 0,
  938. timerID: false,
  939. last_x: 0
  940. };
  941. cover = {
  942. margin_default: 2,
  943. margin: 2,
  944. max_size: window.GetProperty("*USER.cover.maximum.size", 100),
  945. keepaspectratio: window.GetProperty("*USER.cover.keep.ratio.aspect", true),
  946. w: 0,
  947. h: 0,
  948. top_offset: 0,
  949. default_pad_top_mid: 32,
  950. default_pad_bot_mid: 36,
  951. pad_top_mid: 32,
  952. pad_bot_mid: 36,
  953. default_pad_left_mid: 15,
  954. default_pad_right_mid: 12,
  955. pad_left_mid: 15,
  956. pad_right_mid: 12,
  957. normal_delta: 20,
  958. draw_focus_border: window.GetProperty("SYSTEM.cover.draw.focus.border", true),
  959. load_timer: false
  960. };
  961.  
  962. function scrollcoverflow(from, to, step_factor) {
  963. var diff = to - from;
  964. var tmp1, tmp2;
  965. //Adapt to number of covers
  966. scroll.nbcovers = Math.abs(diff);
  967. var tval = Math.round(60/scroll.nbcovers);
  968. if(tval<40) tval = 40;
  969. if(panel.flat_mode) {
  970. scroll.step = Math.floor(cover.w/(scroll.nbcovers==1?step_factor+1:scroll.nbcovers>(panel.flat_mode?2:3)?1:step_factor));
  971. } else {
  972. scroll.step = Math.floor((cover.w - cover.normal_delta*2)/(scroll.nbcovers==1?step_factor+1:scroll.nbcovers>(panel.flat_mode?2:3)?1:step_factor));
  973. };
  974. if(diff<0) {
  975. if(list.item[list.mid].gh_id<list.total_gh-1) {
  976. if(panel.flat_mode) {
  977. scroll.delta = (cover.w*scroll.nbcovers); // delta > 0
  978. } else {
  979. scroll.delta = ((cover.w - cover.normal_delta*2)*scroll.nbcovers); // delta > 0
  980. };
  981. tmp1 = scroll.delta;
  982. for(var j = 0; j < scroll.nbcovers; j++) {
  983. scrolldown_spv(panel.active_playlist,number_per_row);
  984. };
  985. scroll.timerID && window.ClearInterval(scroll.timerID);
  986. scroll.timerID = window.SetInterval(function() {
  987. tmp2 = scroll.delta;
  988. scroll.delta = scroll.delta - scroll.step;
  989. if(scroll.delta <= 0) {
  990. scroll.delta = 0;
  991. window.ClearInterval(scroll.timerID);
  992. scroll.timerID = false;
  993. window.Repaint();
  994. } else {
  995. // pas de repaint au 1er cran de scrolling
  996. if(tmp2!=tmp1) window.Repaint();
  997. };
  998. }, tval);
  999. };
  1000. } else {
  1001. if(list.item[list.mid].gh_id>0 ) {
  1002. if(panel.flat_mode) {
  1003. scroll.delta = (cover.w*scroll.nbcovers) * -1; // delta < 0
  1004. } else {
  1005. scroll.delta = ((cover.w - cover.normal_delta*2)*scroll.nbcovers) * -1; // delta < 0
  1006. };
  1007. tmp1 = scroll.delta;
  1008. for(var j = 0; j < scroll.nbcovers; j++) {
  1009. scrollup_spv(panel.active_playlist);
  1010. };
  1011. scroll.timerID && window.ClearInterval(scroll.timerID);
  1012. scroll.timerID = window.SetInterval(function() {
  1013. tmp2 = scroll.delta;
  1014. scroll.delta = scroll.delta + scroll.step;
  1015. if(scroll.delta >= 0) {
  1016. scroll.delta = 0;
  1017. window.ClearInterval(scroll.timerID);
  1018. scroll.timerID = false;
  1019. window.Repaint();
  1020. } else {
  1021. // pas de repaint au 1er cran de scrolling
  1022. if(tmp2!=tmp1) window.Repaint();
  1023. };
  1024. }, tval);
  1025. };
  1026. };
  1027. };
  1028.  
  1029. function refresh_spv_cursor(pls) {
  1030. var ratio = (cursor.y-vscrollbar.y) / (vscrollbar.h-cursor.h);
  1031. if(ratio>1) ratio = 1;
  1032. if(ratio<0) ratio = 0;
  1033. var r = Math.round(ratio * list.total_gh);
  1034. set_gh_id(pls, list.hlist[r-1]);
  1035. window.Repaint();
  1036. }
  1037.  
  1038. function set_gh_id(pls, id) {
  1039. reset_cover_timers();
  1040. // RAZ actual list
  1041. list.item.splice(0, list.item.length);
  1042. if(list.total_gh<=0) return true;
  1043. // rech gh idx of the searched item
  1044. list.gh_id = get_gh_id(id);
  1045. if(list.gh_id==null) {
  1046. list.gh_id = 0;
  1047. };
  1048. var r = list.gh_id - list.mid;
  1049. if(r<0) {
  1050. list.start_id = Math.abs(r);
  1051. r = 0;
  1052. } else {
  1053. list.start_id = 0;
  1054. };
  1055. for(var k = 0; k < list.nbvis; k++) {
  1056. if(k>=list.start_id && r<list.total_gh) {
  1057. list.item.push(new item(list.hlist[r] , k, r));
  1058. r++;
  1059. } else {
  1060. list.item.push(new item(-1 , k, -1));
  1061. };
  1062. };
  1063. };
  1064. function scrollup_spv(pls,loop) {
  1065. var r = list.item[list.mid].gh_id;
  1066. loop = typeof loop !== 'undefined' ? loop : 1;
  1067. for(var l=0; l<loop; l++) {
  1068. if(r>0) {
  1069. var s = list.item[0].gh_id;
  1070. if(s>0) {
  1071. list.item.unshift(new item(list.hlist[s-1] , 0, s-1));
  1072. } else {
  1073. list.item.unshift(new item(-1 , 0, -1));
  1074. };
  1075. list.item.pop();
  1076. };
  1077. var len = list.item.length;
  1078. for(var i=0; i<len; i++) {
  1079. list.item[i].idx = i;
  1080. };
  1081. setcursorx();
  1082. };
  1083. };
  1084.  
  1085. function scrolldown_spv(pls,loop) {
  1086. var r = list.item[list.mid].gh_id;
  1087. loop = typeof loop !== 'undefined' ? loop : 1;
  1088. if(r<list.total_gh-(list.nbvis-(number_per_row*2))) {
  1089. for(var l=0; l<loop; l++) {
  1090. var s = list.item[list.item.length-1].gh_id;
  1091. if(s>0 && s<list.total_gh-1) {
  1092. list.item.push(new item(list.hlist[s+1] , 0, s+1));
  1093. } else {
  1094. list.item.push(new item(-1 , 0, -1));
  1095. };
  1096. list.item.shift();
  1097.  
  1098. var len = list.item.length;
  1099. for(var i=0; i<len; i++) {
  1100. list.item[i].idx = i;
  1101. };
  1102. setcursorx();
  1103. };
  1104. };
  1105. };
  1106.  
  1107. function refresh_spv(pls, force) {
  1108. reset_cover_timers();
  1109. // RAZ actual list
  1110. list.item.splice(0, list.item.length);
  1111. if(list.total_gh<=0) return true;
  1112. // rech gh idx of the focus item
  1113. list.gh_id = get_gh_id(list.focus_id);
  1114. if(list.gh_id==null) {
  1115. init_active_pls();
  1116. return true;
  1117. };
  1118. list.selected_gh_id = list.gh_id;
  1119. var r = list.gh_id - list.mid;
  1120. if(r<0) {
  1121. list.start_id = Math.abs(r);
  1122. r = 0;
  1123. } else {
  1124. list.start_id = 0;
  1125. };
  1126. for(var k = 0; k < list.nbvis; k++) {
  1127. if(k>=list.start_id && r<list.total_gh) {
  1128. list.item.push(new item(list.hlist[r] , k, r));
  1129. r++;
  1130. } else {
  1131. list.item.push(new item(-1 , k, -1));
  1132. };
  1133. };
  1134. if(scrollbar.show) {
  1135. if(list.total_gh<2) scrollbar.visible = false; else scrollbar.visible=true;
  1136. } else {
  1137. scrollbar.visible = false;
  1138. };
  1139. if(panel.vertical_mode) {
  1140. cursor.h = Math.round(vscrollbar.h / list.total_gh);
  1141. // boundaries for cursor height
  1142. if(cursor.h>vscrollbar.h) cursor.h = vscrollbar.h;
  1143. if(cursor.h<cursor.default_w) cursor.h = cursor.default_w;
  1144. } else {
  1145. cursor.w = Math.round(hscrollbar.w / list.total_gh);
  1146. // boundaries for cursor height
  1147. if(cursor.w>hscrollbar.w) cursor.w = hscrollbar.w;
  1148. if(cursor.w<cursor.default_w) cursor.w = cursor.default_w;
  1149. };
  1150. // redraw cursor image
  1151. set_scroller();
  1152. // set cursor position
  1153. setcursorx();
  1154. };
  1155.  
  1156. function get_gh_id(focus_id) {
  1157. var mid_id = Math.floor(list.total_gh / 2);
  1158. if(focus_id < list.hlist[mid_id]) {
  1159. var start_id = 0;
  1160. } else {
  1161. var start_id = mid_id;
  1162. };
  1163. for(var i = start_id; i < list.total_gh; i++) {
  1164. if(i<list.total_gh-1) {
  1165. if(focus_id >= list.hlist[i] && focus_id < list.hlist[i+1]) {
  1166. return i;
  1167. };
  1168. } else { // we are on the last item of the array
  1169. if(focus_id >= list.hlist[i]) {
  1170. return i;
  1171. } else {
  1172. //fb.trace("error: gh_id not found");
  1173. return null;
  1174. };
  1175. };
  1176. };
  1177. };
  1178.  
  1179. function setcursorx() {
  1180. if(list.item.length>0) {
  1181. var centered_gh_id = list.item[0].gh_id;
  1182. var scroll_bottom = list.total_gh-list.nbvis/2;
  1183. if(scroll_bottom<0) scroll_bottom=centered_gh_id;
  1184. var ratio = centered_gh_id / (scroll_bottom-1);
  1185. if (ratio>1) ratio=1;
  1186. cursor.y = vscrollbar.y + Math.round(ratio * (vscrollbar.h+100-cursor.h));
  1187. } else {
  1188. cursor.y = vscrollbar.y;
  1189. };
  1190. };
  1191.  
  1192. function init_active_pls() {
  1193. var temp_key1;
  1194. var temp_key2;
  1195. var metadb = null;
  1196. var count = 0;
  1197.  
  1198. //var d1 = new Date();
  1199. //var t1 = d1.getSeconds()*1000 + d1.getMilliseconds();
  1200. //fb.trace("avant="+t1);
  1201.  
  1202. list.hlist.splice(0, list.hlist.length);
  1203. list.groups.splice(0, list.groups.length);
  1204. if(list.handlelist) list.handlelist.Dispose();
  1205. list.handlelist = plman.GetPlaylistItems(panel.active_playlist);
  1206. list.total = list.handlelist.Count;
  1207. for (var i = 0; i < list.total; i++) {
  1208. metadb = list.handlelist.Item(i);
  1209. temp_key2 = tf_group_key.EvalWithMetadb(metadb);
  1210. if(temp_key1 != temp_key2){
  1211. if(i>0) {
  1212. list.groups.push(count);
  1213. };
  1214. count = 0;
  1215. list.hlist.push(i);
  1216. temp_key1 = temp_key2;
  1217. };
  1218. count++;
  1219. // on last item
  1220. if(i == list.total - 1) {
  1221. list.groups.push(count);
  1222. };
  1223. };
  1224. list.total_gh = list.hlist.length;
  1225.  
  1226. //var d2 = new Date();
  1227. //var t2 = d2.getSeconds()*1000 + d2.getMilliseconds();
  1228. //fb.trace("old apres="+t2+" ==> delta = "+Math.round(t2-t1)+" // total_gh="+list.total_gh);
  1229. };
  1230.  
  1231. //=================================================// Colour & Font Callbacks
  1232. function on_font_changed() {
  1233. get_font();
  1234. on_playlist_switch();
  1235. };
  1236.  
  1237. function on_colors_changed() {
  1238. get_colors();
  1239. init_icons();
  1240. redraw_stub_images();
  1241. init_hscrollbar_buttons();
  1242. set_scroller();
  1243. g_image_cache = new image_cache;
  1244. CollectGarbage();
  1245. on_playlist_switch();
  1246. };
  1247.  
  1248. //=================================================// Init
  1249. function on_init() {
  1250. };
  1251.  
  1252. //=================================================// OnSize
  1253. function on_size() {
  1254. if (!window.Width || !window.Height) return;
  1255.  
  1256. window.DlgCode = DLGC_WANTALLKEYS;
  1257.  
  1258. bool_on_size = true;
  1259.  
  1260. if(g_instancetype == 0) { // CUI
  1261. window.MinWidth = 160;
  1262. window.MinHeight = 160;
  1263. } else if(g_instancetype == 1) { // DUI
  1264. window.MinWidth = 160;
  1265. window.MinHeight = 160;
  1266. };
  1267. ww = window.Width;
  1268. wh = window.Height;
  1269.  
  1270. number_per_row = Math.floor(ww/(cover.h+cover.pad_left_mid+cover.pad_right_mid));
  1271.  
  1272. if(ww>wh) {
  1273. panel.vertical_mode = false;
  1274. if(wh<160) wh = 158;
  1275. } else {
  1276. panel.vertical_mode = true;
  1277. if(ww<160) ww = 158;
  1278. };
  1279. panel.vertical_mode = true;
  1280. // test TF group text, if empty, reset to default
  1281. var temp = window.GetProperty("*USER.group TF text info", "%album artist%[ | %album%][ | %date%]");
  1282. if(temp=="") window.SetProperty("*USER.group TF text info", "%album artist%[ | %album%][ | %date%]");
  1283. tf_group_info = fb.TitleFormat(window.GetProperty("*USER.group TF text info", "%album artist%[ | %album%][ | %date%]"));
  1284.  
  1285. get_font();
  1286. get_colors();
  1287. init_icons();
  1288. recalc_datas();
  1289. redraw_stub_images();
  1290.  
  1291. // only on first launch
  1292. if(list.first_launch) {
  1293. list.first_launch = false;
  1294. on_playlist_switch();
  1295. } else {
  1296. // if just a window resize, refresh list.item and repaint
  1297. g_image_cache = new image_cache;
  1298. CollectGarbage();
  1299. refresh_spv(panel.active_playlist, true);
  1300. };
  1301. //added REMOVE focus
  1302. list.focus_id = 0;
  1303. };
  1304.  
  1305. //=================================================// OnPaint
  1306. function on_paint(gr) {
  1307. //gr.FillSolidRect(0, 0, ww, wh, RGB(0,0,0));
  1308. var draw_top_grad=true;
  1309. if(list.item.length>0) {
  1310. var mid2;
  1311. list.item[list.mid].draw(gr, list.item[list.mid].id, list.mid, list.item[list.mid].gh_id, 0, true);
  1312. if(list.item[list.mid].gh_id==0) draw_top_grad=false;
  1313. for(var idx = 1; idx < list.item.length; idx++) {
  1314. mid2 = list.mid + idx;
  1315. if(mid2>=0 && mid2<=list.item.length-1) {
  1316. list.item[mid2].draw(gr, list.item[mid2].id, mid2, list.item[mid2].gh_id, idx*-1, true);
  1317. };
  1318. };
  1319. /*
  1320. mid2 = list.mid + 1;
  1321. if(mid2>=0 && mid2<=list.item.length-1) {
  1322. list.item[mid2].draw(gr, list.item[mid2].id, mid2, list.item[mid2].gh_id, -1, true);
  1323. fb.trace('test');
  1324. };
  1325. */
  1326. } else {
  1327. if(fb.PlaylistCount>0) {
  1328. var text_top = fb.GetPlaylistName(fb.ActivePlaylist);
  1329. var text_bot = "This playlist is empty";
  1330. } else {
  1331. var text_top = "Br3tt's WSH CoverFlow";
  1332. var text_bot = "Create a playlist to start!";
  1333. };
  1334. // if empty playlist, display text info
  1335. gr.SetTextRenderingHint(5);
  1336. gr.DrawString(text_top, gdi.Font("Tahoma", 17, 0), g_textcolor&0x40ffffff, 0, -20, ww, wh, cc_stringformat);
  1337. gr.DrawString(text_bot, gdi.Font("Tahoma", 13, 0), g_textcolor&0x40ffffff, 0, 20, ww, wh, cc_stringformat);
  1338. gr.FillGradRect(40, Math.floor(wh/2), ww-80, 1, 0, 0, g_textcolor&0x40ffffff, 0.5);
  1339.  
  1340. };
  1341.  
  1342. // draw scrollbar
  1343. if(list.total_gh>0 && scrollbar.visible && scrollbar.show) {
  1344. if(panel.vertical_mode) {
  1345. // draw scrollbar background
  1346. try {
  1347. scrollbar.theme.SetPartAndStateId(6, 1);
  1348. scrollbar.theme.DrawThemeBackground(gr, ww-vscrollbar.w, 0, vscrollbar.w, wh);
  1349. } catch(e) {
  1350. gr.FillSolidRect(ww-vscrollbar.w, 0, vscrollbar.w, wh, g_backcolor&0x77ffffff);
  1351. gr.FillSolidRect(ww-vscrollbar.w, 0, 1, wh, RGBA(0,0,0,20));
  1352. };
  1353.  
  1354. // draw cursor
  1355. cursor.bt.draw(gr, ww-vscrollbar.w, cursor.y, 255);
  1356.  
  1357. try {
  1358. scrollbar.theme.SetPartAndStateId(9, 1);
  1359. scrollbar.theme.DrawThemeBackground(gr, ww-vscrollbar.w, cursor.y, cursor.w, cursor.h);
  1360. } catch(e) {};
  1361.  
  1362. // draw scrollbar buttons (up/down)
  1363. for(i=0;i<scrollbar.arr_buttons.length;i++) {
  1364. switch (i) {
  1365. case 0:
  1366. scrollbar.arr_buttons[i].draw(gr, ww-vscrollbar.w, button_up.y, 255);
  1367. break;
  1368. case 1:
  1369. scrollbar.arr_buttons[i].draw(gr, ww-vscrollbar.w, button_down.y, 255);
  1370. break;
  1371. };
  1372. };
  1373.  
  1374. if(cursor.drag) {
  1375. //scrollbar.letter = list.item[Math.floor(list.nbvis/2)].group_key.substring(0,1).toUpperCase();
  1376. //cursor.popup && gr.DrawImage(cursor.popup, ww-vscrollbar.w-cursor.popup.Width-00, cursor.y+Math.floor(cursor.h/2)-Math.floor(cursor.popup.Height/2), cursor.popup.Width, cursor.popup.Height, 0, 0, cursor.popup.Width, cursor.popup.Height);
  1377. //cursor.popup && gr.GdiDrawText(scrollbar.letter, gdi.Font("segoe ui", 14, 0), g_backcolor, ww-vscrollbar.w-cursor.popup.Width-00, cursor.y+Math.floor(cursor.h/2)-Math.floor(cursor.popup.Height/2), cursor.popup.Width-5, cursor.popup.Height, DT_CENTER | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
  1378. };
  1379. } else {
  1380.  
  1381. // draw scrollbar background
  1382. try {
  1383. scrollbar.theme.SetPartAndStateId(4, 1);
  1384. scrollbar.theme.DrawThemeBackground(gr, 0, wh-hscrollbar.h, ww, hscrollbar.h);
  1385. gr.FillSolidRect(0, wh-hscrollbar.h-1, ww, 1, RGBA(0,0,0,10));
  1386. } catch(e) {
  1387. gr.FillSolidRect(0, wh-hscrollbar.h, ww, hscrollbar.h, g_backcolor&0x77ffffff);
  1388. gr.FillSolidRect(0, wh-hscrollbar.h, ww, 1, RGBA(0,0,0,20));
  1389. };
  1390.  
  1391. // draw cursor
  1392. try {
  1393. cursor.bt.draw(gr, cursor.x, cursor.y, 255);
  1394. } catch(e) {};
  1395.  
  1396. try {
  1397. scrollbar.theme.SetPartAndStateId(8, 1);
  1398. scrollbar.theme.DrawThemeBackground(gr, cursor.x, wh-hscrollbar.h+0, cursor.w, cursor.h);
  1399. } catch(e) {};
  1400.  
  1401. // draw scrollbar buttons (up/down)
  1402. for(i=0;i<scrollbar.arr_buttons.length;i++) {
  1403. switch (i) {
  1404. case 0:
  1405. scrollbar.arr_buttons[i].draw(gr, button_up.x, button_up.y, 255);
  1406. break;
  1407. case 1:
  1408. scrollbar.arr_buttons[i].draw(gr, button_down.x, button_down.y, 255);
  1409. break;
  1410. };
  1411. };
  1412.  
  1413. if(cursor.drag) {
  1414. scrollbar.letter = list.item[Math.floor(list.nbvis/2)].group_key.substring(0,1).toUpperCase();
  1415. cursor.popup && gr.DrawImage(cursor.popup, cursor.x+Math.floor(cursor.w/2)-Math.floor(cursor.popup.Width/2), wh-hscrollbar.h-cursor.popup.Height, cursor.popup.Width, cursor.popup.Height, 0, 0, cursor.popup.Width, cursor.popup.Height);
  1416. cursor.popup && gr.GdiDrawText(scrollbar.letter, gdi.Font("segoe ui", 14, 0), g_backcolor, cursor.x+Math.floor(cursor.w/2)-Math.floor(cursor.popup.Width/2), wh-hscrollbar.h-cursor.popup.Height, cursor.popup.Width, cursor.popup.Height-5, DT_CENTER | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
  1417. };
  1418. };
  1419. };
  1420.  
  1421. // Incremental Search Tooltip (bot/left corner)
  1422. if(g_search_string.length>0) {
  1423. gr.SetSmoothingMode(2);
  1424. var tt_x = Math.floor((ww / 2) - ((g_search_string.length*13)+(10*2)) / 2);
  1425. var tt_y = Math.floor(wh/2) - 30;
  1426. var tt_w = ((g_search_string.length*13)+(10*2));
  1427. var tt_h = 60;
  1428. gr.FillRoundRect(tt_x, tt_y, tt_w, tt_h, 5, 5, RGBA(0,0,0,150));
  1429. gr.DrawRoundRect(tt_x, tt_y, tt_w, tt_h, 5, 5, 2.0, RGBA(255,255,255,200));
  1430. gr.DrawRoundRect(tt_x+2, tt_y+2, tt_w-4, tt_h-4, 3, 3, 1.0, RGBA(0,0,0,150));
  1431. gr.GdiDrawText(g_search_string, incsearch_font_big, RGB(0,0,0), tt_x+1, tt_y+1 , tt_w , tt_h, DT_CENTER | DT_NOPREFIX | DT_CALCRECT | DT_VCENTER);
  1432. gr.GdiDrawText(g_search_string, incsearch_font_big, list.inc_search_noresult?RGB(255,75,75):RGB(250,250,250), tt_x, tt_y , tt_w , tt_h, DT_CENTER | DT_NOPREFIX | DT_CALCRECT | DT_VCENTER);
  1433. };
  1434.  
  1435. if(draw_top_grad) gr.FillGradRect(0, 0, ww, fading_bottom_height, 90, RGBA(255,255,255,255), RGBA(255,255,255,0),1);
  1436. gr.FillGradRect(0, wh-fading_bottom_height+2, ww, fading_bottom_height, 90, RGBA(255,255,255,0), RGBA(255,255,255,255),1);
  1437.  
  1438. };
  1439.  
  1440. //=================================================// Mouse Callbacks
  1441. function on_mouse_lbtn_down(x, y) {
  1442.  
  1443. g_drag = true;
  1444.  
  1445. bool_on_size = false;
  1446.  
  1447. var len = list.item.length;
  1448. var mid2 = 0;
  1449. if(list.total_gh>0) {
  1450. for(var i = 0; i < len; i++) {
  1451. mid2 = i;
  1452. if(mid2>=0 && mid2<=len-1) {
  1453. if(list.item[mid2].checkstate("down", x, y, mid2)) {
  1454. break;
  1455. };
  1456. };
  1457. };
  1458. };
  1459.  
  1460. if(list.total_gh>0 && scrollbar.visible && scrollbar.show) {
  1461. if(panel.vertical_mode) {
  1462. if(cursor.bt.checkstate("down", x, y)==ButtonStates.down) {
  1463. cursor.drag = true;
  1464. cursor.grap_y = y - cursor.y;
  1465. cursor.last_y = cursor.y;
  1466. };
  1467. if(vscrollbar.hover && !cursor.drag) {
  1468. scrollbar.step = Math.floor(list.nb_cover_to_draw/2);
  1469. if(scrollbar.step<1) scrollbar.step = 1;
  1470. if(y<cursor.y) {
  1471. if(!list.buttonclicked) {
  1472. list.buttonclicked = true;
  1473. on_scrolling(scrollbar.step, 1);
  1474. scrollbarbt.timerID1 = window.SetTimeout(function () {
  1475. on_mouse_wheel(scrollbar.step);
  1476. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  1477. scrollbarbt.timerID1 = false;
  1478. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  1479. scrollbarbt.timerID2 = window.SetInterval(function () {
  1480. if(hscrollbar.hover) {
  1481. if(mouse_x>ww-vscrollbar.w && cursor.y > mouse_y) {
  1482. on_mouse_wheel(scrollbar.step);
  1483. };
  1484. };
  1485. }, scrollbarbt.timer2_value);
  1486. }, scrollbarbt.timer1_value);
  1487. };
  1488. } else {
  1489. if(!list.buttonclicked) {
  1490. list.buttonclicked = true;
  1491. on_scrolling(-1*scrollbar.step, 1);
  1492. scrollbarbt.timerID1 = window.SetTimeout(function () {
  1493. on_mouse_wheel(-1*scrollbar.step);
  1494. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  1495. scrollbarbt.timerID1 = false;
  1496. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  1497. scrollbarbt.timerID2 = window.SetInterval(function () {
  1498. if(hscrollbar.hover) {
  1499. if(mouse_x>ww-vscrollbar.w && cursor.y+cursor.h < mouse_y) {
  1500. on_mouse_wheel(-1*scrollbar.step);
  1501. };
  1502. };
  1503. }, scrollbarbt.timer2_value);
  1504. }, scrollbarbt.timer1_value);
  1505. };
  1506. };
  1507. };
  1508. } else {
  1509. if(cursor.bt.checkstate("down", x, y)==ButtonStates.down) {
  1510. cursor.drag = true;
  1511. cursor.grap_x = x - cursor.x;
  1512. cursor.last_x = cursor.x;
  1513. };
  1514. if(hscrollbar.hover && !cursor.drag) {
  1515. scrollbar.step = Math.floor(list.nb_cover_to_draw/2);
  1516. if(scrollbar.step<1) scrollbar.step = 1;
  1517. if(x<cursor.x) {
  1518. if(!list.buttonclicked) {
  1519. list.buttonclicked = true;
  1520. on_scrolling(scrollbar.step, 1);
  1521. scrollbarbt.timerID1 = window.SetTimeout(function () {
  1522. on_mouse_wheel(scrollbar.step);
  1523. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  1524. scrollbarbt.timerID1 = false;
  1525. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  1526. scrollbarbt.timerID2 = window.SetInterval(function () {
  1527. if(hscrollbar.hover) {
  1528. if(mouse_y>wh-hscrollbar.h && cursor.x > mouse_x) {
  1529. on_mouse_wheel(scrollbar.step);
  1530. };
  1531. };
  1532. }, scrollbarbt.timer2_value);
  1533. }, scrollbarbt.timer1_value);
  1534. };
  1535. } else {
  1536. if(!list.buttonclicked) {
  1537. list.buttonclicked = true;
  1538. on_scrolling(-1*scrollbar.step, 1);
  1539. scrollbarbt.timerID1 = window.SetTimeout(function () {
  1540. on_mouse_wheel(-1*scrollbar.step);
  1541. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  1542. scrollbarbt.timerID1 = false;
  1543. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  1544. scrollbarbt.timerID2 = window.SetInterval(function () {
  1545. if(hscrollbar.hover) {
  1546. if(mouse_y>wh-hscrollbar.h && cursor.x+cursor.w < mouse_x) {
  1547. on_mouse_wheel(-1*scrollbar.step);
  1548. };
  1549. };
  1550. }, scrollbarbt.timer2_value);
  1551. }, scrollbarbt.timer1_value);
  1552. };
  1553. };
  1554. };
  1555. };
  1556.  
  1557. // check scrollbar buttons (UP & DOWN buttons)
  1558. for(i=0;i<scrollbar.arr_buttons.length;i++) {
  1559. switch(i) {
  1560. case 0:
  1561. if(scrollbar.arr_buttons[i].checkstate("down", x, y)==ButtonStates.down) {
  1562. if(!list.buttonclicked) {
  1563. list.buttonclicked = true;
  1564. on_mouse_wheel(1);
  1565. scrollbarbt.timerID1 = window.SetTimeout(function () {
  1566. reset_cover_timers();
  1567. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  1568. scrollbarbt.timerID1 = false;
  1569. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  1570. scrollbarbt.timerID2 = window.SetInterval(function () {
  1571. on_mouse_wheel(1);
  1572. }, scrollbarbt.timer2_value+10);
  1573. }, scrollbarbt.timer1_value);
  1574. };
  1575. };
  1576. break;
  1577. case 1:
  1578. if(scrollbar.arr_buttons[i].checkstate("down", x, y)==ButtonStates.down) {
  1579. if(!list.buttonclicked) {
  1580. list.buttonclicked = true;
  1581. on_mouse_wheel(-1);
  1582. scrollbarbt.timerID1 = window.SetTimeout(function () {
  1583. reset_cover_timers();
  1584. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  1585. scrollbarbt.timerID1 = false;
  1586. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  1587. scrollbarbt.timerID2 = window.SetInterval(function () {
  1588. on_mouse_wheel(-1);
  1589. }, scrollbarbt.timer2_value+10);
  1590. }, scrollbarbt.timer1_value);
  1591. };
  1592. };
  1593. break;
  1594. };
  1595. };
  1596. };
  1597.  
  1598. // check panel buttons
  1599. for(var i=0;i<toolbar.buttons.length;i++) {
  1600. switch(i) {
  1601. case 0:
  1602. if(!panel.lock_playlist) {
  1603. if(fb.IsPlaying || list.total_gh>0) {
  1604. toolbar.buttons[i].checkstate("down", x, y);
  1605. };
  1606. };
  1607. break;
  1608. default:
  1609. toolbar.buttons[i].checkstate("down", x, y);
  1610. };
  1611. };
  1612.  
  1613. };
  1614.  
  1615. function on_mouse_lbtn_dblclk(x, y, mask) {
  1616. if(list.total_gh>0) {
  1617. if(panel.vertical_mode) {
  1618. if(x<cover.pad_left_mid) {
  1619. //ShowNowPlaying();
  1620. } else if(x<ww-cover.pad_right_mid) {
  1621. var len = list.item.length;
  1622. for(var i=0;i<len;i++) {
  1623. list.item[i].checkstate("dblclk", x, y, i);
  1624. };
  1625. } else {
  1626. on_mouse_lbtn_down(x, y);
  1627. };
  1628. } else {
  1629. if(y<cover.pad_top_mid) {
  1630. //ShowNowPlaying();
  1631. } else if(y<wh-cover.pad_bot_mid) {
  1632. var len = list.item.length;
  1633. for(var i=0;i<len;i++) {
  1634. if(list.item[i].id>=0) {
  1635. list.item[i].checkstate("dblclk", x, y, i);
  1636. };
  1637. };
  1638. } else {
  1639. on_mouse_lbtn_down(x, y);
  1640. };
  1641. };
  1642. };
  1643. };
  1644.  
  1645. function on_mouse_lbtn_up(x, y) {
  1646.  
  1647. // scrollbar button up and down RESET
  1648. list.buttonclicked = false;
  1649. scrollbar.timerID && window.ClearTimeout(scrollbar.timerID);
  1650. scrollbar.timerID = false;
  1651. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  1652. scrollbarbt.timerID1 = false;
  1653. scrollbarbt.timerID2 && window.ClearTimeout(scrollbarbt.timerID2);
  1654. scrollbarbt.timerID2 = false;
  1655.  
  1656. if(list.drag_timer) {
  1657. window.ClearTimeout(list.drag_timer);
  1658. list.drag_timer = false;
  1659. list.drag_stop = true;
  1660. }
  1661.  
  1662. // check panel buttons
  1663. for(i=0;i<toolbar.buttons.length;i++) {
  1664. switch(i) {
  1665. case 0:
  1666. if(!panel.lock_playlist) {
  1667. if(fb.IsPlaying || list.total_gh>0) {
  1668. if(toolbar.buttons[i].checkstate("up", x, y)==ButtonStates.hover) {
  1669. ShowNowPlaying();
  1670. };
  1671. };
  1672. };
  1673. break;
  1674. case 1:
  1675. if(toolbar.buttons[i].checkstate("up", x, y)==ButtonStates.hover) {
  1676. g_menu_displayed = true;
  1677. settings_menu(x, y);
  1678. };
  1679. break;
  1680. case 2:
  1681. if(panel.lock_playlist) {
  1682. if(toolbar.buttons[i].checkstate("up", x, y)==ButtonStates.hover) {
  1683. panel.lock_playlist = false;
  1684. window.SetProperty("SYSTEM.panel.lock.playlist", panel.lock_playlist);
  1685. plman.ActivePlaylist = panel.active_playlist;
  1686. };
  1687. };
  1688. break;
  1689. };
  1690. };
  1691.  
  1692. // toolbar collapse if mouse out after a lbtn up
  1693. if(!toolbar.lock) {
  1694. if(y>30 || x<10 || x>ww-vscrollbar.w-10) {
  1695. if(toolbar.delta==0) {
  1696. toolbar.timerID_on && window.ClearTimeout(toolbar.timerID_on);
  1697. toolbar.timerID_on = false;
  1698. };
  1699. if(toolbar.state) {
  1700. if(!toolbar.timerID_off) {
  1701. if(toolbar.delta == toolbar.collapsed_y*-1) {
  1702. toolbar.timerID_off = window.SetTimeout(function() {
  1703. if(!toolbar.timerID2) {
  1704. toolbar.timerID2 = window.SetInterval(function() {
  1705. toolbar.delta -= toolbar.step;
  1706. if(toolbar.delta <= 0) {
  1707. toolbar.delta = 0;
  1708. toolbar.state = false;
  1709. window.ClearInterval(toolbar.timerID2);
  1710. toolbar.timerID2 = false;
  1711. };
  1712. window.RepaintRect(0, 0, ww, 30);
  1713. }, 30);
  1714. } ;
  1715. toolbar.timerID_off && window.ClearTimeout(toolbar.timerID_off);
  1716. toolbar.timerID_off = false;
  1717. }, 400);
  1718. };
  1719. };
  1720. };
  1721. };
  1722. };
  1723.  
  1724. if(list.total_gh>0) {
  1725.  
  1726. // check scrollbar buttons
  1727. cursor.bt.checkstate("up", x, y);
  1728. for(var i=0;i<scrollbar.arr_buttons.length;i++) {
  1729. scrollbar.arr_buttons[i].checkstate("up", x, y);
  1730. };
  1731.  
  1732. if(cursor.drag) {
  1733. window.RepaintRect(0, wh-hscrollbar.h, ww, hscrollbar.h);
  1734. cursor.drag = false;
  1735. } else {
  1736. // check items
  1737. var len = list.item.length;
  1738. for(i=0;i<len;i++) {
  1739. list.item[i].checkstate("up", x, y, i);
  1740. };
  1741. };
  1742.  
  1743. setcursorx();
  1744.  
  1745. window.Repaint();
  1746. };
  1747.  
  1748. g_drag = false;
  1749. };
  1750.  
  1751. function on_mouse_mbtn_down(x, y, mask) {
  1752. bool_on_size = false;
  1753. var len = list.item.length;
  1754. if(list.total_gh>0) {
  1755. for(var i=0;i<len;i++) {
  1756. list.item[i].checkstate("mid", x, y, i);
  1757. };
  1758. };
  1759. };
  1760.  
  1761. function on_mouse_rbtn_down(x, y) {
  1762. bool_on_size = false;
  1763. var len = list.item.length;
  1764. var item_found = false;
  1765. var mid2 = list.mid;
  1766.  
  1767. if(list.total_gh>0) {
  1768. if(list.item[list.mid].checkstate("right", x, y, list.mid)) {
  1769. item_found = true;
  1770. } else {
  1771. for(var i = 1; i < len; i++) {
  1772. mid2 = i;
  1773. if(mid2>=0 && mid2<=len-1) {
  1774. if(list.item[mid2].checkstate("right", x, y, mid2)==true) {
  1775. item_found = true;
  1776. break;
  1777. };
  1778. };
  1779. };
  1780. };
  1781. if(item_found) {
  1782. if(y>toolbar.delta) {
  1783. new_context_menu(x, y, list.item[mid2].id, list.item[mid2].idx);
  1784. };
  1785. };
  1786. };
  1787. };
  1788.  
  1789. function on_mouse_rbtn_up(x, y) {
  1790. if(!utils.IsKeyPressed(VK_SHIFT)) {
  1791. return true;
  1792. };
  1793. };
  1794.  
  1795. function on_mouse_move(x, y) {
  1796.  
  1797. if(x==mouse_x && y==mouse_y) return true;
  1798.  
  1799. hand = false;
  1800.  
  1801. if(cursor.drag) {
  1802. list.drag_stop = false;
  1803. if(list.drag_timer) {
  1804. window.ClearTimeout(list.drag_timer);
  1805. list.drag_timer = false;
  1806. }
  1807. list.drag_timer = window.SetTimeout(function() {
  1808. list.drag_stop = true;
  1809. window.ClearTimeout(list.drag_timer);
  1810. list.drag_timer = false;
  1811. window.Repaint();
  1812. }, 25);
  1813. } else {
  1814. list.drag_stop = true;
  1815. };
  1816.  
  1817. if(list.total_gh>0 && scrollbar.visible && scrollbar.show) {
  1818. if(panel.vertical_mode) {
  1819. vscrollbar.hover = (x>=ww-vscrollbar.w && x<=ww && y>=vscrollbar.y && y<=vscrollbar.y+vscrollbar.h);
  1820. cursor.hover = (x>=cursor.x && x<=cursor.x+cursor.w && y>=cursor.y && y<=cursor.y+cursor.h);
  1821. // check buttons
  1822. cursor.bt.checkstate("move", x, y);
  1823.  
  1824. for(var i=0;i<scrollbar.arr_buttons.length;i++) {
  1825. scrollbar.arr_buttons[i].checkstate("move", x, y);
  1826. };
  1827. if(cursor.drag && mouse_y!=y) {
  1828. reset_cover_timers();
  1829. cursor.y = y - cursor.grap_y;
  1830. // check boundaries
  1831. if(cursor.y<vscrollbar.y) cursor.y = vscrollbar.y;
  1832. if(cursor.y>vscrollbar.y+vscrollbar.h-cursor.h) cursor.y = vscrollbar.y+vscrollbar.h-cursor.h;
  1833. if(!cursor.timerID) {
  1834. cursor.timerID = window.SetTimeout(function() {
  1835. refresh_spv_cursor(fb.ActivePlaylist);
  1836. window.Repaint();
  1837. cursor.timerID = false;
  1838. }, 30);
  1839. };
  1840. };
  1841. } else {
  1842. hscrollbar.hover = (y>=wh-hscrollbar.h && y<=wh && x>=hscrollbar.x && x<=hscrollbar.x+hscrollbar.w);
  1843. cursor.hover = (x>=cursor.x && x<=cursor.x+cursor.w && y>=cursor.y && y<=cursor.y+cursor.h);
  1844. // check buttons
  1845. cursor.bt.checkstate("move", x, y);
  1846.  
  1847. for(var i=0;i<scrollbar.arr_buttons.length;i++) {
  1848. scrollbar.arr_buttons[i].checkstate("move", x, y);
  1849. };
  1850. if(cursor.drag && mouse_x!=x) {
  1851. reset_cover_timers();
  1852. cursor.x = x - cursor.grap_x;
  1853. // check boundaries
  1854. if(cursor.x<hscrollbar.x) cursor.x = hscrollbar.x;
  1855. if(cursor.x>hscrollbar.x+hscrollbar.w-cursor.w) cursor.x = hscrollbar.x+hscrollbar.w-cursor.w;
  1856. if(!cursor.timerID) {
  1857. cursor.timerID = window.SetTimeout(function() {
  1858. refresh_spv_cursor(panel.active_playlist);
  1859. window.Repaint();
  1860. cursor.timerID && window.ClearTimeout(cursor.timerID);
  1861. cursor.timerID = false;
  1862. }, 30);
  1863. };
  1864. };
  1865. };
  1866. };
  1867.  
  1868. // check panel buttons
  1869. for(var j=0;j<toolbar.buttons.length;j++) {
  1870. switch (j) {
  1871. case 0:
  1872. if(!panel.lock_playlist) {
  1873. if(fb.IsPlaying || list.total_gh>0) {
  1874. if(toolbar.buttons[j].checkstate("move", x, y)==ButtonStates.hover) {
  1875. hand = true;
  1876. };
  1877. };
  1878. };
  1879. break;
  1880. case 2:
  1881. if(panel.lock_playlist) {
  1882. if(toolbar.buttons[j].checkstate("move", x, y)==ButtonStates.hover) {
  1883. hand = true;
  1884. };
  1885. };
  1886. break;
  1887. default:
  1888. if(toolbar.buttons[j].checkstate("move", x, y)==ButtonStates.hover) {
  1889. hand = true;
  1890. };
  1891. };
  1892. };
  1893.  
  1894. // hide/show toolbar
  1895. var vscrollbar_w = panel.vertical_mode ? (scrollbar.visible?vscrollbar.w:0) : 0;
  1896. if(!toolbar.lock && !g_drag) {
  1897. if(y>=0 && y<=15 && x>10 && x<ww-vscrollbar_w-10) {
  1898. if(toolbar.delta==toolbar.collapsed_y*-1) {
  1899. toolbar.timerID_off && window.ClearTimeout(toolbar.timerID_off);
  1900. toolbar.timerID_off = false;
  1901. };
  1902. if(!toolbar.timerID_on) {
  1903. if(toolbar.delta==0) {
  1904. toolbar.timerID_on = window.SetTimeout(function() {
  1905. toolbar.timerID2 && window.ClearInterval(toolbar.timerID2);
  1906. toolbar.timerID2 = false;
  1907. if(!toolbar.timerID1) {
  1908. toolbar.timerID1 = window.SetInterval(function() {
  1909. toolbar.delta += toolbar.step;
  1910. if(toolbar.collapsed_y + toolbar.delta >= 0) {
  1911. toolbar.delta = toolbar.collapsed_y*-1;
  1912. toolbar.state = true;
  1913. window.ClearInterval(toolbar.timerID1);
  1914. toolbar.timerID1 = false;
  1915. };
  1916. window.RepaintRect(0, 0, ww, 30);
  1917. }, 30);
  1918. };
  1919. toolbar.timerID_on && window.ClearTimeout(toolbar.timerID_on);
  1920. toolbar.timerID_on = false;
  1921. }, 400);
  1922. } else if(toolbar.timerID2) {
  1923. toolbar.timerID2 && window.ClearInterval(toolbar.timerID2);
  1924. toolbar.timerID2 = false;
  1925. if(!toolbar.timerID1) {
  1926. toolbar.timerID1 = window.SetInterval(function() {
  1927. toolbar.delta += toolbar.step;
  1928. if(toolbar.collapsed_y + toolbar.delta >= 0) {
  1929. toolbar.delta = toolbar.collapsed_y*-1;
  1930. toolbar.state = true;
  1931. window.ClearInterval(toolbar.timerID1);
  1932. toolbar.timerID1 = false;
  1933. };
  1934. window.RepaintRect(0, 0, ww, 30);
  1935. }, 30);
  1936. };
  1937. };
  1938. };
  1939. } else if(y>30 || x<10 || x>ww-vscrollbar_w-10) {
  1940. if(toolbar.delta==0) {
  1941. toolbar.timerID_on && window.ClearTimeout(toolbar.timerID_on);
  1942. toolbar.timerID_on = false;
  1943. };
  1944. if(toolbar.state) {
  1945. if(!toolbar.timerID_off) {
  1946. if(toolbar.delta == toolbar.collapsed_y*-1) {
  1947. toolbar.timerID_off = window.SetTimeout(function() {
  1948. if(!toolbar.timerID2) {
  1949. toolbar.timerID2 = window.SetInterval(function() {
  1950. toolbar.delta -= toolbar.step;
  1951. if(toolbar.delta <= 0) {
  1952. toolbar.delta = 0;
  1953. toolbar.state = false;
  1954. window.ClearInterval(toolbar.timerID2);
  1955. toolbar.timerID2 = false;
  1956. };
  1957. window.RepaintRect(0, 0, ww, 30);
  1958. }, 30);
  1959. } ;
  1960. toolbar.timerID_off && window.ClearTimeout(toolbar.timerID_off);
  1961. toolbar.timerID_off = false;
  1962. }, 400);
  1963. };
  1964. };
  1965. };
  1966. };
  1967. };
  1968.  
  1969. // Mouse Cursor
  1970. window.SetCursor(hand? IDC_HAND : IDC_ARROW);
  1971.  
  1972. mouse_x = x;
  1973. mouse_y = y;
  1974. };
  1975.  
  1976. function on_mouse_wheel(delta) {
  1977.  
  1978. var abs_delta = Math.abs(delta);
  1979. reset_cover_timers();
  1980.  
  1981. if(list.total_gh>0) {
  1982. if(!scrollbar.timerID) {
  1983. if(abs_delta>=1) {
  1984. if(delta>0) {
  1985. if(panel.scroll_effect) {
  1986. for(var i=0; i<abs_delta-1; i++) {
  1987. scrollup_spv(panel.active_playlist);
  1988. };
  1989. scrollcoverflow(0, 1, scroll.factor);
  1990. } else {
  1991. for(var i=0; i<abs_delta; i++) {
  1992. // ADAPT TO NUMBER OF COVERS
  1993. for(var s=0; s<number_per_row; s++)
  1994. scrollup_spv(panel.active_playlist);
  1995. };
  1996. };
  1997. scrollbar.timerID = window.SetTimeout(function () {
  1998. window.Repaint();
  1999. scrollbar.timerID && window.ClearTimeout(scrollbar.timerID);
  2000. scrollbar.timerID = false;
  2001. }, list.mousewheel_timer_value);
  2002. } else {
  2003. if(panel.scroll_effect) {
  2004. scrolldown_spv(panel.active_playlist,number_per_row);
  2005. scrollcoverflow(1, 0, scroll.factor);
  2006. } else {
  2007. for(var i=0; i<abs_delta; i++) {
  2008. // ADAPT TO NUMBER OF COVERS
  2009. scrolldown_spv(panel.active_playlist,number_per_row);
  2010. };
  2011. };
  2012. scrollbar.timerID = window.SetTimeout(function () {
  2013. window.Repaint();
  2014. scrollbar.timerID && window.ClearTimeout(scrollbar.timerID);
  2015. scrollbar.timerID = false;
  2016. }, list.mousewheel_timer_value);
  2017. };
  2018. };
  2019. };
  2020. };
  2021. };
  2022.  
  2023. function on_scrolling(delta, factor) {
  2024.  
  2025. var abs_delta = Math.abs(delta);
  2026. reset_cover_timers();
  2027.  
  2028. if(list.total_gh>0) {
  2029. if(!scrollbar.timerID) {
  2030. if(abs_delta>=1) {
  2031. if(delta>0) {
  2032. if(panel.scroll_effect) {
  2033. scrollcoverflow(0, abs_delta, factor);
  2034. } else {
  2035. for(var i=0; i<abs_delta; i++) {
  2036. scrollup_spv(panel.active_playlist);
  2037. };
  2038. scrollbar.timerID = window.SetTimeout(function () {
  2039. window.Repaint();
  2040. scrollbar.timerID && window.ClearTimeout(scrollbar.timerID);
  2041. scrollbar.timerID = false;
  2042. }, list.mousewheel_timer_value);
  2043. };
  2044. } else {
  2045. if(panel.scroll_effect) {
  2046. scrollcoverflow(abs_delta, 0, factor);
  2047. } else {
  2048. for(var i=0; i<abs_delta; i++) {
  2049. scrolldown_spv(panel.active_playlist,number_per_row);
  2050. }
  2051. scrollbar.timerID = window.SetTimeout(function () {
  2052. window.Repaint();
  2053. scrollbar.timerID && window.ClearTimeout(scrollbar.timerID);
  2054. scrollbar.timerID = false;
  2055. }, list.mousewheel_timer_value);
  2056. };
  2057. };
  2058. };
  2059. };
  2060. };
  2061. };
  2062.  
  2063. function on_mouse_leave() {
  2064. var len = list.item.length;
  2065. if(list.total_gh>0) {
  2066. for(var i=0;i<len;i++) {
  2067. list.item[i].checkstate("leave", 0, 0, i);
  2068. };
  2069. };
  2070. for(i=0;i<toolbar.buttons.length;i++) {
  2071. toolbar.buttons[i].checkstate("leave", 0, 0);
  2072. };
  2073.  
  2074. // toolbar is to hide if visible or amorced
  2075. if(toolbar.delta==0) {
  2076. toolbar.timerID_on && window.ClearTimeout(toolbar.timerID_on);
  2077. toolbar.timerID_on = false;
  2078. };
  2079. if(!toolbar.lock && !g_drag) {
  2080. if(!g_menu_displayed) {
  2081. if(!toolbar.timerID_off) {
  2082. toolbar.timerID_off = window.SetTimeout(function() {
  2083. if(!toolbar.timerID2) {
  2084. toolbar.timerID2 = window.SetInterval(function() {
  2085. toolbar.delta -= toolbar.step;
  2086. if(toolbar.delta <= 0) {
  2087. toolbar.delta = 0;
  2088. toolbar.state = false;
  2089. window.ClearInterval(toolbar.timerID2);
  2090. toolbar.timerID2 = false;
  2091. };
  2092. window.RepaintRect(0, 0, ww, 30);
  2093. }, 30);
  2094. } ;
  2095. toolbar.timerID_off && window.ClearTimeout(toolbar.timerID_off);
  2096. toolbar.timerID_off = false;
  2097. }, 400);
  2098. };
  2099. };
  2100. };
  2101. window.Repaint();
  2102. };
  2103.  
  2104. //=================================================// Callbacks
  2105.  
  2106. function on_playlist_switch() {
  2107. // set/check the active playlist for the panel
  2108. if(!panel.lock_playlist) {
  2109. panel.active_playlist = plman.ActivePlaylist;
  2110. };
  2111.  
  2112. // test if there is an active playlist focused (may happen whenyou delete a playlist from pl manager)
  2113. if(plman.ActivePlaylist < 0 || plman.ActivePlaylist > fb.PlaylistCount) {
  2114. if(fb.PlaylistCount>0) {
  2115. plman.ActivePlaylist = 0;
  2116. };
  2117. };
  2118. init_active_pls();
  2119. list.focus_id = plman.GetPlaylistFocusItemIndex(panel.active_playlist);
  2120. if(list.focus_id<0) {
  2121. list.focus_id = 0;
  2122. }
  2123. //added REMOVE focus
  2124. list.focus_id = 0;
  2125. refresh_spv(panel.active_playlist, true);
  2126. window.Repaint();
  2127. };
  2128.  
  2129. function on_playlist_items_added(playlist_idx) {
  2130. if(playlist_idx==panel.active_playlist) {
  2131. on_playlist_switch();
  2132. };
  2133. plman.SetActivePlaylistContext();
  2134. };
  2135.  
  2136. function on_playlist_items_removed(playlist_idx, new_count) {
  2137. if(playlist_idx==panel.active_playlist) {
  2138. on_playlist_switch();
  2139. };
  2140. plman.SetActivePlaylistContext();
  2141. };
  2142.  
  2143. function on_playlist_items_reordered(playlist_idx) {
  2144. if(playlist_idx==panel.active_playlist) {
  2145. on_playlist_switch();
  2146. };
  2147. };
  2148.  
  2149. function on_selection_changed(metadb) {
  2150. };
  2151.  
  2152. function on_playlist_items_selection_change() {
  2153. };
  2154.  
  2155. function on_playlists_changed() {
  2156. if(bypass.on_playlists_changed) {
  2157. //bypass.on_playlists_changed = false;
  2158. return true;
  2159. } else {
  2160. if(panel.lock_playlist) {
  2161. // unlock on playlist changed because locked playlist may have be moved or deleted
  2162. panel.lock_playlist = !panel.lock_playlist;
  2163. window.SetProperty("SYSTEM.panel.lock.playlist", panel.lock_playlist);
  2164. plman.ActivePlaylist = panel.active_playlist;
  2165. window.Repaint();
  2166. };
  2167. };
  2168. };
  2169.  
  2170. function on_item_focus_change(playlist, from, to) {
  2171. if(bypass.on_item_focus_change || to<0) {
  2172. //bypass.on_item_focus_change = false;
  2173. return true;
  2174. };
  2175. //bypass.on_item_focus_change = false;
  2176. if(playlist==panel.active_playlist) {
  2177. list.focus_id = to;
  2178. plman.SetActivePlaylistContext();
  2179. refresh_spv(panel.active_playlist, bool_on_size);
  2180. bool_on_size = false;
  2181. window.Repaint();
  2182. };
  2183. };
  2184.  
  2185. function on_metadb_changed(metadb_or_metadbs, fromhook) {
  2186. var len = list.item.length;
  2187. for(var i=0;i<len;i++) {
  2188. list.item[i].update_infos();
  2189. };
  2190. window.Repaint();
  2191. };
  2192.  
  2193. function on_focus(is_focused) {
  2194. if(is_focused) {
  2195. plman.SetActivePlaylistContext();
  2196. };
  2197. };
  2198.  
  2199. //=================================================// Keyboard Callbacks
  2200. function on_key_up(vkey) {
  2201. // scrollbar button up and down RESET
  2202. list.buttonclicked = false;
  2203. scrollbar.timerID && window.ClearTimeout(scrollbar.timerID);
  2204. scrollbar.timerID = false;
  2205. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  2206. scrollbarbt.timerID1 = false;
  2207. scrollbarbt.timerID2 && window.ClearTimeout(scrollbarbt.timerID2);
  2208. scrollbarbt.timerID2 = false;
  2209. };
  2210.  
  2211. function on_key_down(vkey) {
  2212. var mask = GetKeyboardMask();
  2213.  
  2214. if (mask == KMask.none) {
  2215. switch (vkey) {
  2216. case VK_SHIFT:
  2217. list.SHIFT_count = 0;
  2218. break;
  2219. case VK_BACK:
  2220. if(g_search_string.length>0) {
  2221. var tt_x = Math.floor((ww / 2) - ((g_search_string.length*13)+(10*2)) / 2);
  2222. var tt_y = Math.floor(wh/2) - 30;
  2223. var tt_w = ((g_search_string.length*13)+(10*2));
  2224. var tt_h = 60;
  2225. g_search_string = g_search_string.substring(0, g_search_string.length-1);
  2226. window.RepaintRect(0, tt_y-2, ww, tt_h+4);
  2227. clear_incsearch_timer && window.ClearInterval(clear_incsearch_timer);
  2228. incsearch_timer && window.ClearTimeout(incsearch_timer);
  2229. incsearch_timer = window.SetTimeout(function () {
  2230. IncrementalSearch();
  2231. window.ClearTimeout(incsearch_timer);
  2232. incsearch_timer = false;
  2233. }, 400);
  2234. };
  2235. break;
  2236. case VK_ESCAPE:
  2237. case 222:
  2238. var tt_x = Math.floor((ww / 2) - ((g_search_string.length*13)+(10*2)) / 2);
  2239. var tt_y = Math.floor(wh/2) - 30;
  2240. var tt_w = ((g_search_string.length*13)+(10*2));
  2241. var tt_h = 60;
  2242. g_search_string = "";
  2243. window.RepaintRect(0, tt_y-2, ww, tt_h+4);
  2244. break;
  2245. case VK_UP:
  2246. case VK_LEFT:
  2247. if(list.total_gh>0) {
  2248. if(!list.buttonclicked) {
  2249. list.buttonclicked = true;
  2250. on_mouse_wheel(1);
  2251. window.Repaint();
  2252. scrollbarbt.timerID1 = window.SetTimeout(function () {
  2253. reset_cover_timers();
  2254. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  2255. scrollbarbt.timerID1 = false;
  2256. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  2257. scrollbarbt.timerID2 = window.SetInterval(function () {
  2258. on_mouse_wheel(1);
  2259. }, scrollbarbt.timer2_value);
  2260. }, scrollbarbt.timer1_value);
  2261. };
  2262. };
  2263. break;
  2264. case VK_DOWN:
  2265. case VK_RIGHT:
  2266. if(list.total_gh>0) {
  2267. if(!list.buttonclicked) {
  2268. list.buttonclicked = true;
  2269. on_mouse_wheel(-1);
  2270. window.Repaint();
  2271. scrollbarbt.timerID1 = window.SetTimeout(function () {
  2272. reset_cover_timers();
  2273. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  2274. scrollbarbt.timerID1 = false;
  2275. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  2276. scrollbarbt.timerID2 = window.SetInterval(function () {
  2277. on_mouse_wheel(-1);
  2278. }, scrollbarbt.timer2_value);
  2279. }, scrollbarbt.timer1_value);
  2280. };
  2281. };
  2282. break;
  2283. case VK_PGUP:
  2284. if(list.total_gh>0) {
  2285. scrollbar.step = Math.floor(list.nb_cover_to_draw/2);
  2286. if(scrollbar.step<1) scrollbar.step = 1;
  2287. if(!list.buttonclicked) {
  2288. list.buttonclicked = true;
  2289. on_mouse_wheel(scrollbar.step);
  2290. window.Repaint();
  2291. scrollbarbt.timerID1 = window.SetTimeout(function () {
  2292. reset_cover_timers();
  2293. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  2294. scrollbarbt.timerID1 = false;
  2295. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  2296. scrollbarbt.timerID2 = window.SetInterval(function () {
  2297. on_mouse_wheel(scrollbar.step);
  2298. }, scrollbarbt.timer2_value);
  2299. }, scrollbarbt.timer1_value);
  2300. };
  2301. };
  2302. break;
  2303. case VK_PGDN:
  2304. if(list.total_gh>0) {
  2305. scrollbar.step = Math.floor(list.nb_cover_to_draw/2);
  2306. if(scrollbar.step<1) scrollbar.step = 1;
  2307. if(!list.buttonclicked) {
  2308. list.buttonclicked = true;
  2309. on_mouse_wheel(scrollbar.step*-1);
  2310. window.Repaint();
  2311. scrollbarbt.timerID1 = window.SetTimeout(function () {
  2312. reset_cover_timers();
  2313. scrollbarbt.timerID1 && window.ClearTimeout(scrollbarbt.timerID1);
  2314. scrollbarbt.timerID1 = false;
  2315. scrollbarbt.timerID2 && window.ClearInterval(scrollbarbt.timerID2);
  2316. scrollbarbt.timerID2 = window.SetInterval(function () {
  2317. on_mouse_wheel(scrollbar.step*-1);
  2318. }, scrollbarbt.timer2_value);
  2319. }, scrollbarbt.timer1_value);
  2320. };
  2321. };
  2322. break;
  2323. case VK_RETURN:
  2324. // play focus item
  2325. if(list.total_gh>0) {
  2326. plman.ExecutePlaylistDefaultAction(panel.active_playlist, list.focus_id);
  2327. };
  2328. break;
  2329. case VK_END:
  2330. if(list.total_gh>0) {
  2331. plman.SetPlaylistFocusItem(panel.active_playlist, list.total-1);
  2332. plman.ClearPlaylistSelection(panel.active_playlist);
  2333. plman.SetPlaylistSelectionSingle(panel.active_playlist, list.total-1, true);
  2334. };
  2335. break;
  2336. case VK_HOME:
  2337. if(list.total_gh>0) {
  2338. plman.SetPlaylistFocusItem(panel.active_playlist, 0);
  2339. plman.ClearPlaylistSelection(panel.active_playlist);
  2340. plman.SetPlaylistSelectionSingle(panel.active_playlist, 0, true);
  2341. };
  2342. break;
  2343. case VK_DELETE:
  2344. if(list.total_gh>0) {
  2345. if(!fb.IsAutoPlaylist(panel.active_playlist)) {
  2346. plman.RemovePlaylistSelection(panel.active_playlist, false);
  2347. plman.SetPlaylistSelectionSingle(panel.active_playlist, plman.GetPlaylistFocusItemIndex(panel.active_playlist), true);
  2348. };
  2349. };
  2350. break;
  2351. case VK_SPACEBAR:
  2352. if(g_search_string.length==0) {
  2353. if(list.total_gh>0) {
  2354. if(panel.lock_playlist) {
  2355. plman.SetPlaylistFocusItem(panel.active_playlist, new_focus_id);
  2356. plman.ClearPlaylistSelection(panel.active_playlist);
  2357. plman.SetPlaylistSelectionSingle(panel.active_playlist, new_focus_id, true);
  2358. var mid_idx = Math.floor(list.nbvis/2);
  2359. list.item[mid_idx].checkstate("mid", list.item[mid_idx].x+5, list.item[mid_idx].y+5, mid_idx);
  2360. } else {
  2361. var new_focus_id = list.item[Math.floor(list.nbvis/2)].id;
  2362. SelectGroupItems(new_focus_id, get_gh_id(new_focus_id), true);
  2363. };
  2364. };
  2365. break;
  2366. };
  2367. };
  2368. } else {
  2369. switch(mask) {
  2370. case KMask.shift:
  2371. break;
  2372. case KMask.ctrl:
  2373. if(vkey==65) { // CTRL+A
  2374. fb.RunMainMenuCommand("Edit/Select all");
  2375. window.Repaint();
  2376. };
  2377. if(vkey==70) { // CTRL+F
  2378. fb.RunMainMenuCommand("Edit/Search");
  2379. };
  2380. if(vkey==78) { // CTRL+N
  2381. fb.RunMainMenuCommand("File/New playlist");
  2382. };
  2383. if(vkey==79) { // CTRL+O
  2384. fb.RunMainMenuCommand("File/Open...");
  2385. };
  2386. if(vkey==80) { // CTRL+P
  2387. fb.RunMainMenuCommand("File/Preferences");
  2388. };
  2389. if(vkey==83) { // CTRL+S
  2390. fb.RunMainMenuCommand("File/Save playlist...");
  2391. };
  2392. break;
  2393. case KMask.alt:
  2394. if(vkey==65) { // ALT+A
  2395. fb.RunMainMenuCommand("View/Always on Top");
  2396. };
  2397. break;
  2398. };
  2399. };
  2400. };
  2401.  
  2402. function on_char(code) {
  2403. if(list.total_gh>0) {
  2404. var tt_x = Math.floor((ww / 2) - ((g_search_string.length*13)+(10*2)) / 2);
  2405. var tt_y = Math.floor(wh/2) - 30;
  2406. var tt_w = ((g_search_string.length*13)+(10*2));
  2407. var tt_h = 60;
  2408. if(code==32 && g_search_string.length==0) return true; // SPACE Char not allowed on 1st char
  2409. if(g_search_string.length<=20 && tt_w<=ww-50) {
  2410. if (code > 31) {
  2411. g_search_string = g_search_string + String.fromCharCode(code).toUpperCase();
  2412. window.RepaintRect(0, tt_y-2, ww, tt_h+4);
  2413. clear_incsearch_timer && window.ClearInterval(clear_incsearch_timer);
  2414. clear_incsearch_timer = false;
  2415. incsearch_timer && window.ClearTimeout(incsearch_timer);
  2416. incsearch_timer = window.SetTimeout(function () {
  2417. IncrementalSearch();
  2418. window.ClearTimeout(incsearch_timer);
  2419. incsearch_timer = false;
  2420. }, 400);
  2421. };
  2422. };
  2423. };
  2424. };
  2425.  
  2426. //=================================================// Playback Callbacks
  2427.  
  2428. function on_playback_new_track(info) {
  2429. g_metadb = fb.GetNowPlaying();
  2430. bypass.on_item_focus_change = true;
  2431. window.Repaint();
  2432. };
  2433.  
  2434. function on_playback_stop(reason) {
  2435. if(reason==0) { // on user Stop
  2436. g_metadb = fb.GetFocusItem();
  2437. on_metadb_changed();
  2438. };
  2439. };
  2440.  
  2441. function on_playback_pause(state){
  2442. };
  2443.  
  2444. function on_playback_time(time) {
  2445. };
  2446.  
  2447. //=================================================// Font & Colors
  2448. function get_font() {
  2449. if (g_instancetype == 0) { // CUI
  2450. g_font = window.GetFontCUI(FontTypeCUI.items);
  2451. g_font_headers = window.GetFontCUI(FontTypeCUI.labels);
  2452. } else if (g_instancetype == 1) { // DUI
  2453. g_font = window.GetFontDUI(FontTypeDUI.playlists);
  2454. g_font_headers = window.GetFontDUI(FontTypeDUI.tabs);
  2455. };
  2456. };
  2457.  
  2458. function get_colors() {
  2459. if(g_instancetype == 0) { // CUI
  2460. g_textcolor = window.GetColorCUI(ColorTypeCUI.text);
  2461. g_textcolor_sel = window.GetColorCUI(ColorTypeCUI.selection_text);
  2462. g_textcolor_hl = window.GetColorCUI(ColorTypeCUI.active_item_frame);
  2463. g_backcolor = window.GetColorCUI(ColorTypeCUI.background);
  2464. g_backcolor_sel = window.GetColorCUI(ColorTypeCUI.selection_background);
  2465. } else if(g_instancetype == 1) { // DUI
  2466. g_textcolor = window.GetColorDUI(ColorTypeDUI.text);
  2467. g_textcolor_sel = window.GetColorDUI(ColorTypeDUI.selection);
  2468. g_textcolor_hl = window.GetColorDUI(ColorTypeDUI.highlight);
  2469. g_backcolor = window.GetColorDUI(ColorTypeDUI.background);
  2470. g_backcolor_sel = g_textcolor_sel;
  2471. };
  2472.  
  2473. // Custom colors set in Properties of the panel
  2474. if(panel.custom_colors) {
  2475. try{
  2476. if(panel.custom_textcolor.length>0) g_textcolor = eval(panel.custom_textcolor);
  2477. if(panel.custom_textcolor_selection.length>0) {
  2478. g_textcolor_sel = eval(panel.custom_textcolor_selection);
  2479. g_backcolor_sel = g_textcolor_sel;
  2480. };
  2481. if(panel.custom_backcolor.length>0) g_backcolor = eval(panel.custom_backcolor);
  2482. } catch(e) {};
  2483. };
  2484.  
  2485. g_backcolor_R = getRed(g_backcolor);
  2486. g_backcolor_G = getGreen(g_backcolor);
  2487. g_backcolor_B = getBlue(g_backcolor);
  2488. };
  2489.  
  2490. //=================================================// Images (general)
  2491. function set_scroller() {
  2492. var gb;
  2493.  
  2494. if(panel.vertical_mode) {
  2495. try {
  2496. cursor.img_normal = gdi.CreateImage(cursor.w, cursor.h);
  2497. } catch(e) {
  2498. cursor.h = cursor.default_h;
  2499. cursor.img_normal = gdi.CreateImage(cursor.w, cursor.h);
  2500. };
  2501.  
  2502. gb = cursor.img_normal.GetGraphics();
  2503. // Draw Themed Scrollbar (lg/col)
  2504. try {
  2505. scrollbar.theme.SetPartAndStateId(3, 1);
  2506. scrollbar.theme.DrawThemeBackground(gb, 0, 0, cursor.w, cursor.h);
  2507. } catch(e) {
  2508. gb.FillSolidRect(3, 0, cursor.w-6, cursor.h, g_textcolor&0x44ffffff);
  2509. };
  2510. cursor.img_normal.ReleaseGraphics(gb);
  2511.  
  2512. cursor.img_hover = gdi.CreateImage(cursor.w, cursor.h);
  2513. gb = cursor.img_hover.GetGraphics();
  2514. // Draw Themed Scrollbar (lg/col)
  2515. try {
  2516. scrollbar.theme.SetPartAndStateId(3, 2);
  2517. scrollbar.theme.DrawThemeBackground(gb, 0, 0, cursor.w, cursor.h);
  2518. } catch(e) {
  2519. gb.FillSolidRect(3, 0, cursor.w-6, cursor.h, g_textcolor&0x88ffffff);
  2520. };
  2521. cursor.img_hover.ReleaseGraphics(gb);
  2522. cursor.bt = new button(cursor.img_normal, cursor.img_hover, cursor.img_hover);
  2523. } else {
  2524. try {
  2525. cursor.img_normal = gdi.CreateImage(cursor.w, cursor.h);
  2526. } catch(e) {
  2527. cursor.h = cursor.default_h;
  2528. cursor.img_normal = gdi.CreateImage(cursor.w, cursor.h);
  2529. };
  2530.  
  2531. gb = cursor.img_normal.GetGraphics();
  2532. // Draw Themed Scrollbar (lg/col)
  2533. try {
  2534. scrollbar.theme.SetPartAndStateId(2, 1);
  2535. scrollbar.theme.DrawThemeBackground(gb, 0, 0, cursor.w, cursor.h);
  2536. } catch(e) {
  2537. gb.FillSolidRect(0, 3, cursor.w, cursor.h-5, g_textcolor&0x44ffffff);
  2538. };
  2539. cursor.img_normal.ReleaseGraphics(gb);
  2540.  
  2541. cursor.img_hover = gdi.CreateImage(cursor.w, cursor.h);
  2542. gb = cursor.img_hover.GetGraphics();
  2543. // Draw Themed Scrollbar (lg/col)
  2544. try {
  2545. scrollbar.theme.SetPartAndStateId(2, 2);
  2546. scrollbar.theme.DrawThemeBackground(gb, 0, 0, cursor.w, cursor.h);
  2547. } catch(e) {
  2548. gb.FillSolidRect(0, 3, cursor.w, cursor.h-5, g_textcolor&0x88ffffff);
  2549. };
  2550. cursor.img_hover.ReleaseGraphics(gb);
  2551. cursor.bt = new button(cursor.img_normal, cursor.img_hover, cursor.img_hover);
  2552. };
  2553. };
  2554.  
  2555. function init_hscrollbar_buttons() {
  2556. var i, gb;
  2557.  
  2558. cursor.popup = gdi.CreateImage(22, 27);
  2559. gb = cursor.popup.GetGraphics();
  2560. gb.SetSmoothingMode(2);
  2561. gb.FillRoundRect(0,0,22-1,22-1,3,3,g_textcolor);
  2562. gb.DrawRoundRect(0,0,22-1,22-1,3,3,1.0,RGBA(0,0,0,150));
  2563. var points = Array(7,22-2, 11,22-2+6, 22-7,22-2);
  2564. gb.FillPolygon(g_textcolor, 0, points);
  2565. gb.DrawPolygon(RGBA(0,0,0,150), 1.0, points);
  2566. gb.SetSmoothingMode(0);
  2567. gb.FillSolidRect(6,22-4,22-10,3,g_textcolor);
  2568. cursor.popup.ReleaseGraphics(gb);
  2569.  
  2570. button_up.img_normal = gdi.CreateImage(button_up.w, button_up.h);
  2571. gb = button_up.img_normal.GetGraphics();
  2572. // Draw Themed Scrollbar (lg/col)
  2573. try {
  2574. scrollbar.theme.SetPartAndStateId(1, 9);
  2575. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_up.w, button_up.h);
  2576. } catch(e) {
  2577. gb.SetSmoothingMode(2);
  2578. var mid_y = Math.round(button_up.h/2);
  2579. gb.DrawLine(10, mid_y-4, 6, mid_y+0, 2.0, g_textcolor&0x44ffffff);
  2580. gb.DrawLine(7, mid_y+0, 10, mid_y+3, 2.0, g_textcolor&0x44ffffff);
  2581. };
  2582. button_up.img_normal.ReleaseGraphics(gb);
  2583.  
  2584. button_up.img_hover = gdi.CreateImage(button_up.w, button_up.h);
  2585. gb = button_up.img_hover.GetGraphics();
  2586. // Draw Themed Scrollbar (lg/col)
  2587. try {
  2588. scrollbar.theme.SetPartAndStateId(1, 10);
  2589. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_up.w, button_up.h);
  2590. } catch(e) {
  2591. gb.SetSmoothingMode(2);
  2592. var mid_y = Math.round(button_up.h/2);
  2593. gb.DrawLine(10, mid_y-4, 6, mid_y+0, 2.0, g_textcolor&0x88ffffff);
  2594. gb.DrawLine(7, mid_y+0, 10, mid_y+3, 2.0, g_textcolor&0x88ffffff);
  2595. };
  2596. button_up.img_hover.ReleaseGraphics(gb);
  2597.  
  2598. button_up.img_down = gdi.CreateImage(button_up.w, button_up.h);
  2599. gb = button_up.img_down.GetGraphics();
  2600. // Draw Themed Scrollbar (lg/col)
  2601. try {
  2602. scrollbar.theme.SetPartAndStateId(1, 11);
  2603. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_up.w, button_up.h);
  2604. } catch(e) {
  2605. gb.SetSmoothingMode(2);
  2606. var mid_y = Math.round(button_up.h/2);
  2607. gb.DrawLine(10, mid_y-4, 6, mid_y+0, 2.0, g_textcolor);
  2608. gb.DrawLine(7, mid_y+0, 10, mid_y+3, 2.0, g_textcolor);
  2609. };
  2610. button_up.img_down.ReleaseGraphics(gb);
  2611.  
  2612. button_down.img_normal = gdi.CreateImage(button_down.w, button_down.h);
  2613. gb = button_down.img_normal.GetGraphics();
  2614. // Draw Themed Scrollbar (lg/col)
  2615. try {
  2616. scrollbar.theme.SetPartAndStateId(1, 13);
  2617. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_down.w, button_down.h);
  2618. } catch(e) {
  2619. gb.SetSmoothingMode(2);
  2620. var mid_y = Math.round(button_up.h/2);
  2621. gb.DrawLine(button_down.w-11, mid_y-4, button_down.w-7, mid_y+0, 2.0, g_textcolor&0x44ffffff);
  2622. gb.DrawLine(button_down.w-8, mid_y+0, button_down.w-11, mid_y+3, 2.0, g_textcolor&0x44ffffff);
  2623. };
  2624. button_down.img_normal.ReleaseGraphics(gb);
  2625.  
  2626. button_down.img_hover = gdi.CreateImage(button_down.w, button_down.h);
  2627. gb = button_down.img_hover.GetGraphics();
  2628. // Draw Themed Scrollbar (lg/col)
  2629. try {
  2630. scrollbar.theme.SetPartAndStateId(1, 14);
  2631. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_down.w, button_down.h);
  2632. } catch(e) {
  2633. gb.SetSmoothingMode(2);
  2634. var mid_y = Math.round(button_up.h/2);
  2635. gb.DrawLine(button_down.w-11, mid_y-4, button_down.w-7, mid_y+0, 2.0, g_textcolor&0x88ffffff);
  2636. gb.DrawLine(button_down.w-8, mid_y+0, button_down.w-11, mid_y+3, 2.0, g_textcolor&0x88ffffff);
  2637. };
  2638. button_down.img_hover.ReleaseGraphics(gb);
  2639.  
  2640. button_down.img_down = gdi.CreateImage(button_down.w, button_down.h);
  2641. gb = button_down.img_down.GetGraphics();
  2642. // Draw Themed Scrollbar (lg/col)
  2643. try {
  2644. scrollbar.theme.SetPartAndStateId(1, 15);
  2645. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_down.w, button_down.h);
  2646. } catch(e) {
  2647. gb.SetSmoothingMode(2);
  2648. var mid_y = Math.round(button_up.h/2);
  2649. gb.DrawLine(button_down.w-11, mid_y-4, button_down.w-7, mid_y+0, 2.0, g_textcolor);
  2650. gb.DrawLine(button_down.w-8, mid_y+0, button_down.w-11, mid_y+3, 2.0, g_textcolor);
  2651. };
  2652. button_down.img_down.ReleaseGraphics(gb);
  2653.  
  2654. scrollbar.arr_buttons.splice(0, scrollbar.arr_buttons.length);
  2655. for(i=0;i<scrollbar.button_total;i++) {
  2656. switch(i) {
  2657. case 0:
  2658. scrollbar.arr_buttons.push(new button(button_up.img_normal, button_up.img_hover, button_up.img_down));
  2659. break;
  2660. case 1:
  2661. scrollbar.arr_buttons.push(new button(button_down.img_normal, button_down.img_hover, button_down.img_down));
  2662. break;
  2663. };
  2664. };
  2665. };
  2666.  
  2667. function init_vscrollbar_buttons() {
  2668. var i, gb;
  2669.  
  2670. cursor.popup = gdi.CreateImage(27, 22);
  2671. gb = cursor.popup.GetGraphics();
  2672. gb.SetSmoothingMode(2);
  2673. gb.FillRoundRect(0,0,22-1,22-1,3,3,g_textcolor);
  2674. gb.DrawRoundRect(0,0,22-1,22-1,3,3,1.0,RGBA(0,0,0,150));
  2675. var points = Array(22-2,7, 22-2+6,11, 22-2,22-7);
  2676. gb.FillPolygon(g_textcolor, 0, points);
  2677. gb.DrawPolygon(RGBA(0,0,0,150), 1.0, points);
  2678. gb.SetSmoothingMode(0);
  2679. gb.FillSolidRect(22-4,6,3,22-10,g_textcolor);
  2680. cursor.popup.ReleaseGraphics(gb);
  2681.  
  2682. button_up.img_normal = gdi.CreateImage(button_up.w, button_up.h);
  2683. gb = button_up.img_normal.GetGraphics();
  2684. // Draw Themed Scrollbar (lg/col)
  2685. try {
  2686. scrollbar.theme.SetPartAndStateId(1, 1);
  2687. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_up.w, button_up.h);
  2688. } catch(e) {
  2689. gb.SetSmoothingMode(2);
  2690. var mid_x = Math.round(button_up.w/2);
  2691. gb.DrawLine(mid_x-4, 10, mid_x+0, 5, 2.0, g_textcolor&0x44ffffff);
  2692. gb.DrawLine(mid_x+0, 6, mid_x+3, 10, 2.0, g_textcolor&0x44ffffff);
  2693. };
  2694. button_up.img_normal.ReleaseGraphics(gb);
  2695.  
  2696. button_up.img_hover = gdi.CreateImage(button_up.w, button_up.h);
  2697. gb = button_up.img_hover.GetGraphics();
  2698. // Draw Themed Scrollbar (lg/col)
  2699. try {
  2700. scrollbar.theme.SetPartAndStateId(1, 2);
  2701. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_up.w, button_up.h);
  2702. } catch(e) {
  2703. gb.SetSmoothingMode(2);
  2704. var mid_x = Math.round(button_up.w/2);
  2705. gb.DrawLine(mid_x-4, 10, mid_x+0, 5, 2.0, g_textcolor&0x88ffffff);
  2706. gb.DrawLine(mid_x+0, 6, mid_x+3, 10, 2.0, g_textcolor&0x88ffffff);
  2707. };
  2708. button_up.img_hover.ReleaseGraphics(gb);
  2709.  
  2710. button_up.img_down = gdi.CreateImage(button_up.w, button_up.h);
  2711. gb = button_up.img_down.GetGraphics();
  2712. // Draw Themed Scrollbar (lg/col)
  2713. try {
  2714. scrollbar.theme.SetPartAndStateId(1, 3);
  2715. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_up.w, button_up.h);
  2716. } catch(e) {
  2717. gb.SetSmoothingMode(2);
  2718. var mid_x = Math.round(button_up.w/2);
  2719. gb.DrawLine(mid_x-4, 10, mid_x+0, 5, 2.0, g_textcolor);
  2720. gb.DrawLine(mid_x+0, 6, mid_x+3, 10, 2.0, g_textcolor);
  2721. };
  2722. button_up.img_down.ReleaseGraphics(gb);
  2723.  
  2724. button_down.img_normal = gdi.CreateImage(button_down.w, button_down.h);
  2725. gb = button_down.img_normal.GetGraphics();
  2726. // Draw Themed Scrollbar (lg/col)
  2727. try {
  2728. scrollbar.theme.SetPartAndStateId(1, 5);
  2729. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_down.w, button_down.h);
  2730. } catch(e) {
  2731. gb.SetSmoothingMode(2);
  2732. var mid_x = Math.round(button_up.w/2);
  2733. gb.DrawLine(mid_x-4, button_down.h-11, mid_x+0, button_down.h-6, 2.0, g_textcolor&0x44ffffff);
  2734. gb.DrawLine(mid_x+0, button_down.h-7, mid_x+3, button_down.h-11, 2.0, g_textcolor&0x44ffffff);
  2735. };
  2736. button_down.img_normal.ReleaseGraphics(gb);
  2737.  
  2738. button_down.img_hover = gdi.CreateImage(button_down.w, button_down.h);
  2739. gb = button_down.img_hover.GetGraphics();
  2740. // Draw Themed Scrollbar (lg/col)
  2741. try {
  2742. scrollbar.theme.SetPartAndStateId(1, 6);
  2743. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_down.w, button_down.h);
  2744. } catch(e) {
  2745. gb.SetSmoothingMode(2);
  2746. var mid_x = Math.round(button_up.w/2);
  2747. gb.DrawLine(mid_x-4, button_down.h-11, mid_x+0, button_down.h-6, 2.0, g_textcolor&0x88ffffff);
  2748. gb.DrawLine(mid_x+0, button_down.h-7, mid_x+3, button_down.h-11, 2.0, g_textcolor&0x88ffffff);
  2749. };
  2750. button_down.img_hover.ReleaseGraphics(gb);
  2751.  
  2752. button_down.img_down = gdi.CreateImage(button_down.w, button_down.h);
  2753. gb = button_down.img_down.GetGraphics();
  2754. // Draw Themed Scrollbar (lg/col)
  2755. try {
  2756. scrollbar.theme.SetPartAndStateId(1, 7);
  2757. scrollbar.theme.DrawThemeBackground(gb, 0, 0, button_down.w, button_down.h);
  2758. } catch(e) {
  2759. gb.SetSmoothingMode(2);
  2760. var mid_x = Math.round(button_up.w/2);
  2761. gb.DrawLine(mid_x-4, button_down.h-11, mid_x+0, button_down.h-6, 2.0, g_textcolor);
  2762. gb.DrawLine(mid_x+0, button_down.h-7, mid_x+3, button_down.h-11, 2.0, g_textcolor);
  2763. };
  2764. button_down.img_down.ReleaseGraphics(gb);
  2765.  
  2766. scrollbar.arr_buttons.splice(0, scrollbar.arr_buttons.length);
  2767. for(i=0;i<scrollbar.button_total;i++) {
  2768. switch(i) {
  2769. case 0:
  2770. scrollbar.arr_buttons.push(new button(button_up.img_normal, button_up.img_hover, button_up.img_down));
  2771. break;
  2772. case 1:
  2773. scrollbar.arr_buttons.push(new button(button_down.img_normal, button_down.img_hover, button_down.img_down));
  2774. break;
  2775. };
  2776. };
  2777. };
  2778.  
  2779. //=================================================// Init Icons and Images (no_cover ...)
  2780. function init_icons() {
  2781. var gb;
  2782. var gui_font;
  2783.  
  2784. nocover = gdi.CreateImage(200, 200);
  2785. gb = nocover.GetGraphics();
  2786. gb.SetSmoothingMode(2);
  2787. gb.FillSolidRect(0,0,200,200,g_textcolor);
  2788. gb.FillGradRect(0,0,200,200,90,g_backcolor&0xbbffffff,g_backcolor,1.0);
  2789. gb.SetTextRenderingHint(3);
  2790. gui_font = gdi.Font("Segoe UI", 108, 1);
  2791. gb.DrawString("NO", gui_font, g_textcolor&0x25ffffff, 0, 0, 200, 110, cc_stringformat);
  2792. gui_font = gdi.Font("Segoe UI", 48, 1);
  2793. gb.DrawString("COVER", gui_font, g_textcolor&0x20ffffff, 1, 70, 200, 110, cc_stringformat);
  2794. gb.FillSolidRect(24, 155, 152, 20, g_textcolor&0x15ffffff);
  2795. nocover.ReleaseGraphics(gb);
  2796. };
  2797.  
  2798. function recalc_datas() {
  2799.  
  2800. if(toolbar.lock) {
  2801. toolbar.delta = toolbar.collapsed_y*-1;
  2802. toolbar.state = true;
  2803. };
  2804.  
  2805. if(panel.vertical_mode) {
  2806.  
  2807. if(panel.flat_mode) {
  2808. cover.margin = panel.show_text ? 28 : 12;
  2809. if(scrollbar.show) {
  2810. cover.pad_right_mid = cover.default_pad_right_mid - 26 + vscrollbar.default_w;
  2811. } else {
  2812. cover.pad_right_mid = cover.default_pad_right_mid - 26;
  2813. }
  2814. } else {
  2815. cover.margin = cover.margin_default;
  2816. if(scrollbar.show) {
  2817. cover.pad_right_mid = cover.default_pad_right_mid + vscrollbar.default_w;
  2818. } else {
  2819. cover.pad_right_mid = cover.default_pad_right_mid;
  2820. }
  2821. };
  2822. cover.h = ww - cover.pad_left_mid - cover.pad_right_mid;
  2823. if(cover.h>cover.max_size) cover.h = cover.max_size;
  2824. cover.w = cover.h;
  2825.  
  2826. if(panel.flat_mode) {
  2827. number_per_row = Math.floor(ww/(cover.h+cover.pad_left_mid+cover.pad_right_mid));
  2828. list.nbvis = (Math.floor(wh/(cover.h+cover.margin*0))+1)*(number_per_row);
  2829. number_per_column = list.nbvis/number_per_row;
  2830.  
  2831. cover_padding_left = (ww-cover.h*number_per_row)/(number_per_row)/2;
  2832. cover_padding_right = (ww-cover.h*number_per_row)/(number_per_row)/2;
  2833.  
  2834. if(list.nbvis/2==Math.floor(list.nbvis/2)) {
  2835. //list.nbvis--;
  2836. }
  2837. //list.mid = Math.floor(list.nbvis/2);
  2838. list.mid=0;
  2839. list.nb_cover_to_draw = Math.floor(wh/(cover.h+cover.margin*0)) + 2;
  2840. } else {
  2841. list.nbvis = Math.floor(wh/(cover.h-cover.normal_delta*2)) + 2 + 20;
  2842. if(list.nbvis/2==Math.floor(list.nbvis/2)) {
  2843. list.nbvis--;
  2844. }
  2845. list.mid = Math.floor(list.nbvis/2);
  2846. list.nb_cover_to_draw = Math.floor(wh/(cover.h-cover.normal_delta*2)) + 2;
  2847. };
  2848.  
  2849. if(scrollbar.themed) {
  2850. scrollbar.theme = window.CreateThemeManager("scrollbar");
  2851. } else {
  2852. scrollbar.theme = false;
  2853. };
  2854. init_vscrollbar_buttons();
  2855.  
  2856. button_up.x = ww - button_up.w;
  2857. button_up.y = 0;
  2858. button_down.x = ww - button_down.w;
  2859. button_down.y = wh - button_down.h;
  2860. vscrollbar.y = button_up.h;
  2861. vscrollbar.h = wh - button_up.h - button_down.h;
  2862. cursor.x = ww-vscrollbar.w;
  2863. cursor.y = vscrollbar.y;
  2864. cursor.w = vscrollbar.w;
  2865.  
  2866. } else {
  2867.  
  2868. if(panel.flat_mode) {
  2869. cover.margin = 10;
  2870. } else {
  2871. cover.margin = cover.margin_default;
  2872. };
  2873.  
  2874. // mid cover (max size)
  2875. if(scrollbar.show) {
  2876. cover.pad_bot_mid = cover.default_pad_bot_mid - (panel.flat_mode?0:5);
  2877. } else {
  2878. cover.pad_bot_mid = cover.default_pad_bot_mid - hscrollbar.default_h - (panel.flat_mode?0:5);
  2879. }
  2880. if(panel.show_text) {
  2881. cover.pad_top_mid = cover.default_pad_top_mid - (panel.flat_mode?16:0);
  2882. } else {
  2883. cover.pad_top_mid = cover.default_pad_top_mid - 16;
  2884. cover.pad_bot_mid -= (panel.flat_mode?10:0);
  2885. };
  2886. cover.w = wh - cover.pad_top_mid - cover.pad_bot_mid;
  2887. if(cover.w>cover.max_size) cover.w = cover.max_size;
  2888. cover.h = cover.w;
  2889.  
  2890. if(panel.flat_mode) {
  2891. list.nbvis = Math.floor(ww/(cover.w+cover.margin*0)) + 2 + 20;
  2892. if(list.nbvis/2==Math.floor(list.nbvis/2)) {
  2893. list.nbvis--;
  2894. }
  2895. list.mid = Math.floor(list.nbvis/2);
  2896. list.nb_cover_to_draw = Math.floor(ww/(cover.w+cover.margin*0)) + 2;
  2897. } else {
  2898. list.nbvis = Math.floor(ww/(cover.w-cover.normal_delta*2)) + 2 + 20;
  2899. if(list.nbvis/2==Math.floor(list.nbvis/2)) {
  2900. list.nbvis--;
  2901. }
  2902. list.mid = Math.floor(list.nbvis/2);
  2903. list.nb_cover_to_draw = Math.floor(ww/(cover.w-cover.normal_delta*2)) + 2;
  2904. };
  2905.  
  2906. if(scrollbar.themed) {
  2907. scrollbar.theme = window.CreateThemeManager("scrollbar");
  2908. } else {
  2909. scrollbar.theme = false;
  2910. };
  2911. init_hscrollbar_buttons();
  2912.  
  2913. button_up.x = 0;
  2914. button_up.y = wh - hscrollbar.h;
  2915. button_down.x = ww - button_down.w;
  2916. button_down.y = wh - hscrollbar.h;
  2917. hscrollbar.x = button_up.w;
  2918. hscrollbar.w = ww - button_up.w - button_down.w;
  2919. cursor.y = wh - hscrollbar.h;
  2920. cursor.x = hscrollbar.x;
  2921. cursor.h = hscrollbar.h;
  2922. };
  2923. };
  2924.  
  2925. function redraw_stub_images() {
  2926. if(gdi.Image(images.nocover)) {
  2927. nocover_img = FormatCover(gdi.Image(images.nocover), cover.w, cover.h);
  2928. } else {
  2929. nocover_img = FormatCover(nocover, cover.w, cover.h);
  2930. };
  2931. if(gdi.Image(images.stream)) {
  2932. streamcover_img = FormatCover(gdi.Image(images.stream), cover.w, cover.h);
  2933. } else {
  2934. streamcover_img = FormatCover(streamcover, cover.w, cover.h);
  2935. };
  2936. if(gdi.Image(images.loading)) {
  2937. var img_loading_USER = gdi.Image(images.loading);
  2938. loading_img = FormatCover(img_loading_USER, img_loading_USER.Width, img_loading_USER.Height);
  2939. } else {
  2940. loading_img = FormatCover(loading, cover.w, cover.h);
  2941. };
  2942. };
  2943.  
  2944. function SelectGroupItems(start_id, start_gh_id, setfocus) {
  2945. var count = 0;
  2946. var affectedItems = Array();
  2947.  
  2948. if(!utils.IsKeyPressed(VK_CONTROL)) plman.ClearPlaylistSelection(panel.active_playlist);
  2949.  
  2950. if(start_gh_id<list.total_gh-1) {
  2951. var last_id = list.hlist[start_gh_id+1];
  2952. } else {
  2953. var last_id = list.total;
  2954. };
  2955. for(var i = start_id; i < last_id; i++) {
  2956. affectedItems.push(i);
  2957. if(++count>9999) break;
  2958. };
  2959. plman.SetPlaylistSelection(panel.active_playlist, affectedItems, true);
  2960. if(setfocus) {
  2961. plman.SetPlaylistFocusItem(panel.active_playlist, start_id);
  2962. };
  2963. CollectGarbage();
  2964. };
  2965.  
  2966. function ShowSelected() {
  2967. if(panel.lock_playlist) return true;
  2968.  
  2969. if(plman.PlaylistItemCount(plman.ActivePlaylist)==0 || !fb.GetFocusItem(false)) return true;
  2970. plman.ClearPlaylistSelection(plman.ActivePlaylist);
  2971. var pid = plman.GetPlaylistFocusItemIndex(plman.ActivePlaylist);
  2972. plman.SetPlaylistFocusItem(plman.ActivePlaylist, pid);
  2973. plman.SetPlaylistSelectionSingle(plman.ActivePlaylist, pid, true);
  2974. if(pid>=0 && pid<list.total) {
  2975. refresh_spv(plman.ActivePlaylist, true);
  2976. };
  2977. };
  2978.  
  2979. function ShowNowPlaying() {
  2980. if(panel.lock_playlist) return true;
  2981. if(fb.IsPlaying) {
  2982. if(plman.PlaylistItemCount(plman.PlayingPlaylist)==0) {
  2983. return true;
  2984. };
  2985. plman.ClearPlaylistSelection(plman.PlayingPlaylist);
  2986. list.nowplaying = plman.GetPlayingItemLocation();
  2987. var pid = list.nowplaying.PlaylistItemIndex;
  2988. if(pid>=0 && pid<plman.PlaylistItemCount(plman.PlayingPlaylist)) {
  2989. plman.SetPlaylistFocusItem(plman.PlayingPlaylist, pid);
  2990. plman.SetPlaylistSelectionSingle(plman.PlayingPlaylist, pid, true);
  2991. plman.ActivePlaylist = plman.PlayingPlaylist;
  2992. refresh_spv(plman.PlayingPlaylist, true);
  2993. };
  2994. } else {
  2995. if(plman.PlaylistItemCount(plman.ActivePlaylist)==0 || !fb.GetFocusItem(false)) return true;
  2996. plman.ClearPlaylistSelection(plman.ActivePlaylist);
  2997. var pid = plman.GetPlaylistFocusItemIndex(plman.ActivePlaylist);
  2998. plman.SetPlaylistFocusItem(plman.ActivePlaylist, pid);
  2999. plman.SetPlaylistSelectionSingle(plman.ActivePlaylist, pid, true);
  3000. if(pid>=0 && pid<list.total) {
  3001. refresh_spv(plman.ActivePlaylist, true);
  3002. };
  3003. };
  3004. };
  3005.  
  3006. function ShowSearchedItem(pls, pid) {
  3007. if(list.total==0 || !fb.GetFocusItem(false)) return true;
  3008. if(pid<0) {
  3009. pid = plman.GetPlaylistFocusItemIndex(pls);
  3010. };
  3011.  
  3012. plman.SetPlaylistFocusItem(pls, pid);
  3013. plman.ClearPlaylistSelection(pls);
  3014. plman.SetPlaylistSelectionSingle(pls, pid, true);
  3015. refresh_spv(pls, true);
  3016.  
  3017. if(panel.lock_playlist) {
  3018. incsearch_timer_lock = window.SetTimeout(function() {
  3019. var mid_idx = Math.floor(list.nbvis/2);
  3020. list.item[mid_idx].checkstate("mid", list.item[mid_idx].x+5, list.item[mid_idx].y+5, mid_idx);
  3021. incsearch_timer_lock && window.ClearTimeout(incsearch_timer_lock);
  3022. incsearch_timer_lock = false;
  3023. }, 100);
  3024. };
  3025. };
  3026.  
  3027. function IncrementalSearch() {
  3028. var count=0;
  3029. var groupkey;
  3030. var chr;
  3031. var gstart;
  3032. var pid = -1;
  3033. var grp_first_item_id;
  3034.  
  3035. // exit if no search string in cache
  3036. if(g_search_string.length<=0) return true;
  3037.  
  3038. // 1st char of the search string
  3039. var first_chr = g_search_string.substring(0,1);
  3040. var len = g_search_string.length;
  3041.  
  3042. // which start point for the search
  3043. if(list.total_gh>500) {
  3044. grp_first_item_id = list.hlist[Math.floor(list.total_gh/2)];
  3045. groupkey = tf_group_key.EvalWithMetadb(list.handlelist.Item(grp_first_item_id));
  3046. chr = groupkey.substring(0,1);
  3047. if(first_chr.charCodeAt(first_chr) > chr.charCodeAt(chr)) {
  3048. gstart = Math.floor(list.total_gh/2);
  3049. } else {
  3050. gstart = 0;
  3051. };
  3052. } else {
  3053. gstart = 0;
  3054. };
  3055.  
  3056. var format_str = "";
  3057. for(var i=gstart;i<list.total_gh;i++) {
  3058. grp_first_item_id = list.hlist[i];
  3059. groupkey = tf_group_key.EvalWithMetadb(list.handlelist.Item(grp_first_item_id));
  3060. format_str = groupkey.substring(0,len).toUpperCase();
  3061. if(format_str==g_search_string) {
  3062. pid = list.hlist[i];
  3063. break;
  3064. };
  3065. };
  3066.  
  3067. if(pid>=0) { // found!
  3068. plman.ClearPlaylistSelection(panel.active_playlist);
  3069. ShowSearchedItem(panel.active_playlist, pid);
  3070. } else {
  3071. list.inc_search_noresult = true;
  3072. window.Repaint();
  3073. };
  3074.  
  3075. clear_incsearch_timer && window.ClearTimeout(clear_incsearch_timer);
  3076. clear_incsearch_timer = window.SetTimeout(function () {
  3077. // reset incremental search string after 2 seconds without any key pressed
  3078. var tt_x = Math.floor((ww / 2) - ((g_search_string.length*13)+(10*2)) / 2);
  3079. var tt_y = Math.floor(wh/2) - 30;
  3080. var tt_w = ((g_search_string.length*13)+(10*2));
  3081. var tt_h = 60;
  3082. g_search_string = "";
  3083. window.RepaintRect(0, tt_y-2, ww, tt_h+4);
  3084. clear_incsearch_timer && window.ClearTimeout(clear_incsearch_timer);
  3085. clear_incsearch_timer = false;
  3086. list.inc_search_noresult = false;
  3087. }, 1000);
  3088. };
  3089.  
  3090. //=================================================// Item Context Menu
  3091. function new_context_menu(x, y, id, array_id) {
  3092.  
  3093. var _menu = window.CreatePopupMenu();
  3094. var Context = fb.CreateContextMenuManager();
  3095.  
  3096. var _child01 = window.CreatePopupMenu();
  3097. var _child02 = window.CreatePopupMenu();
  3098.  
  3099. list.metadblist_selection = plman.GetPlaylistSelectedItems(panel.active_playlist);
  3100. Context.InitContext(list.metadblist_selection);
  3101. Context.BuildMenu(_menu, 1, -1);
  3102.  
  3103. _menu.AppendMenuItem(MF_SEPARATOR, 0, "");
  3104. _menu.AppendMenuItem(MF_STRING | MF_POPUP, _child01.ID, "Selection...");
  3105.  
  3106. _child01.AppendMenuItem((fb.IsAutoPlaylist(panel.active_playlist))?MF_DISABLED|MF_GRAYED:MF_STRING, 1000, "Remove");
  3107. _child01.AppendMenuItem(MF_STRING | MF_POPUP, _child02.ID, "Add to...");
  3108.  
  3109. _child02.AppendMenuItem(MF_STRING, 2000, "a New playlist...");
  3110. _child02.AppendMenuItem(MF_SEPARATOR, 0, "");
  3111. var pl_count = fb.PlaylistCount;
  3112. for(var i=0;i<pl_count;i++) {
  3113. if(i!=panel.active_playlist && !fb.IsAutoPlaylist(i)) {
  3114. _child02.AppendMenuItem(MF_STRING, 2001+i, plman.GetPlaylistName(i));
  3115. };
  3116. };
  3117.  
  3118. var ret = _menu.TrackPopupMenu(x, y);
  3119. if(ret<800) {
  3120. Context.ExecuteByID(ret - 1);
  3121. } else if(ret<1000) {
  3122. switch (ret) {
  3123. case 880:
  3124.  
  3125. break;
  3126. case 890:
  3127.  
  3128. break;
  3129. };
  3130. } else {
  3131. switch (ret) {
  3132. case 1000:
  3133. plman.RemovePlaylistSelection(panel.active_playlist, false);
  3134. break;
  3135. case 2000:
  3136. fb.RunMainMenuCommand("File/New playlist");
  3137. plman.InsertPlaylistItems(plman.PlaylistCount-1, 0, list.metadblist_selection, false);
  3138. break;
  3139. default:
  3140. var insert_index = plman.PlaylistItemCount(ret-2001);
  3141. plman.InsertPlaylistItems((ret-2001), insert_index, list.metadblist_selection, false);
  3142. };
  3143. };
  3144. };
  3145.  
  3146. function settings_menu(x, y) {
  3147. var idx;
  3148. var _menu = window.CreatePopupMenu();
  3149. var _appearance = window.CreatePopupMenu();
  3150.  
  3151. var current_pl_name = plman.GetPlaylistName(plman.ActivePlaylist);
  3152. var lock_enabled = (current_pl_name!="CoverFlow View" && list.total_gh>0);
  3153.  
  3154. _menu.AppendMenuItem(MF_STRING, 99, "Lock Toolbar");
  3155. _menu.CheckMenuItem(99, toolbar.lock?1:0);
  3156. _menu.AppendMenuItem((lock_enabled || panel.lock_playlist)?MF_STRING:MF_DISABLED|MF_GRAYED, 1, "Lock to Current Playlist");
  3157. _menu.CheckMenuItem(1, panel.lock_playlist?1:0);
  3158. _menu.AppendMenuItem(MF_SEPARATOR, 0, "");
  3159. _menu.AppendMenuItem(MF_STRING, 5, "CoverFlow Mode");
  3160. _menu.AppendMenuItem(MF_STRING, 6, "Flat Mode");
  3161. _menu.CheckMenuRadioItem(5, 6, panel.flat_mode?6:5);
  3162. _menu.AppendMenuItem(MF_SEPARATOR, 0, "");
  3163.  
  3164. _appearance.AppendTo(_menu, MF_STRING, "Appearance");
  3165. _appearance.AppendMenuItem(MF_STRING, 2, "Show Scrollbar");
  3166. _appearance.CheckMenuItem(2, scrollbar.show?1:0);
  3167. _appearance.AppendMenuItem(MF_STRING, 3, "Themed Scrollbar Style");
  3168. _appearance.CheckMenuItem(3, scrollbar.themed?1:0);
  3169. _appearance.AppendMenuItem(MF_STRING, 4, "Use Scroll Effect");
  3170. _appearance.CheckMenuItem(4, panel.scroll_effect?1:0);
  3171. _appearance.AppendMenuItem(MF_STRING, 7, "Use Custom Colors");
  3172. _appearance.CheckMenuItem(7, panel.custom_colors?1:0);
  3173. if(!panel.vertical_mode) {
  3174. _appearance.AppendMenuItem(MF_STRING, 8, "Show Album Info");
  3175. _appearance.CheckMenuItem(8, panel.show_text?1:0);
  3176. };
  3177. if(panel.flat_mode) {
  3178. // tracks_counter_show: window.GetProperty("*USER.total.tracks.visible", true),
  3179. _appearance.AppendMenuItem(MF_STRING, 10, "Show Tracks Counter");
  3180. _appearance.CheckMenuItem(10, panel.tracks_counter_show?1:0);
  3181. };
  3182.  
  3183. _menu.AppendMenuItem(MF_SEPARATOR, 0, "");
  3184. _menu.AppendMenuItem((list.total>0)?MF_STRING:MF_DISABLED|MF_GRAYED, 22, "Refresh CoverFlow");
  3185. _menu.AppendMenuItem(MF_SEPARATOR, 0, "");
  3186. _menu.AppendMenuItem(MF_STRING, 20, "Properties");
  3187. _menu.AppendMenuItem(MF_STRING, 21, "Configure...");
  3188. idx = _menu.TrackPopupMenu(x, y);
  3189.  
  3190. switch(idx) {
  3191. case 1:
  3192. if(panel.lock_playlist) {
  3193. // unlock, set ActivePlaylist with locked playlist
  3194. panel.lock_playlist = false;
  3195. window.SetProperty("SYSTEM.panel.lock.playlist", panel.lock_playlist);
  3196. plman.ActivePlaylist = panel.active_playlist;
  3197. } else {
  3198. //ShowSelected();
  3199. //window.Repaint();
  3200. // lock current playlist
  3201. panel.lock_playlist = true;
  3202. window.SetProperty("SYSTEM.panel.lock.playlist", panel.lock_playlist);
  3203. panel.active_playlist = plman.ActivePlaylist;
  3204. window.SetProperty("SYSTEM.panel.active.playlist", panel.active_playlist);
  3205. //
  3206. var mid_idx = Math.floor(list.nbvis/2);
  3207. mid_idx = list.focus_id_item_idx;
  3208. //mid_idx = list.marker_id;
  3209. list.item[mid_idx].checkstate("mid", list.item[mid_idx].x+5, list.item[mid_idx].y+5, mid_idx);
  3210. };
  3211. break;
  3212. case 2:
  3213. if(list.total_gh>=2) {
  3214. scrollbar.show = !scrollbar.show;
  3215. if(scrollbar.show) {
  3216. scrollbar.visible = true;
  3217. } else {
  3218. scrollbar.visible = false;
  3219. };
  3220. } else {
  3221. scrollbar.visible = false;
  3222. };
  3223. window.SetProperty("SYSTEM.scrollbar.visible", scrollbar.show);
  3224. //
  3225. recalc_datas();
  3226. redraw_stub_images();
  3227. g_image_cache = new image_cache;
  3228. CollectGarbage();
  3229. on_playlist_switch();
  3230. break;
  3231. case 3:
  3232. scrollbar.themed = !scrollbar.themed;
  3233. window.SetProperty("SYSTEM.scrollbar.themed", scrollbar.themed);
  3234. if(scrollbar.themed) {
  3235. scrollbar.theme = window.CreateThemeManager("scrollbar");
  3236. } else {
  3237. scrollbar.theme = false;
  3238. };
  3239. if(panel.vertical_mode) {
  3240. init_vscrollbar_buttons();
  3241. } else {
  3242. init_hscrollbar_buttons();
  3243. };
  3244. set_scroller();
  3245. window.Repaint();
  3246. break;
  3247. case 4:
  3248. panel.scroll_effect = !panel.scroll_effect;
  3249. window.SetProperty("SYSTEM.panel.scroll.effect", panel.scroll_effect);
  3250. window.Repaint();
  3251. break;
  3252. case 5:
  3253. case 6:
  3254. panel.flat_mode = !panel.flat_mode;
  3255. window.SetProperty("SYSTEM.panel.flat.mode", panel.flat_mode);
  3256. //
  3257. recalc_datas();
  3258. redraw_stub_images();
  3259. g_image_cache = new image_cache;
  3260. CollectGarbage();
  3261. on_playlist_switch();
  3262. break;
  3263. case 7:
  3264. panel.custom_colors = !panel.custom_colors;
  3265. window.SetProperty("SYSTEM.panel.custom.colors", panel.custom_colors);
  3266. on_colors_changed();
  3267. break;
  3268. case 8:
  3269. panel.show_text = !panel.show_text;
  3270. window.SetProperty("SYSTEM.panel.album.info", panel.show_text);
  3271. //
  3272. recalc_datas();
  3273. redraw_stub_images();
  3274. g_image_cache = new image_cache;
  3275. CollectGarbage();
  3276. on_playlist_switch();
  3277. break;
  3278. case 10:
  3279. panel.tracks_counter_show = !panel.tracks_counter_show;
  3280. window.SetProperty("*USER.total.tracks.visible", panel.tracks_counter_show),
  3281. window.Repaint();
  3282. break;
  3283. case 20:
  3284. window.ShowProperties();
  3285. break;
  3286. case 21:
  3287. window.ShowConfigure();
  3288. break;
  3289. case 22:
  3290. redraw_stub_images();
  3291. g_image_cache = new image_cache;
  3292. CollectGarbage();
  3293. on_playlist_switch();
  3294. break;
  3295. case 99:
  3296. toolbar.lock = !toolbar.lock;
  3297. window.SetProperty("SYSTEM.toolbar.lock", toolbar.lock);
  3298. break;
  3299. default:
  3300.  
  3301. };
  3302. _appearance.Dispose();
  3303. _menu.Dispose();
  3304. g_menu_displayed = false;
  3305. // toolbar collapse
  3306. if(!toolbar.lock) {
  3307. if(toolbar.delta==0) {
  3308. toolbar.timerID_on && window.ClearTimeout(toolbar.timerID_on);
  3309. toolbar.timerID_on = false;
  3310. };
  3311. if(toolbar.state) {
  3312. if(!toolbar.timerID_off) {
  3313. if(toolbar.delta == toolbar.collapsed_y*-1) {
  3314. toolbar.timerID_off = window.SetTimeout(function() {
  3315. if(!toolbar.timerID2) {
  3316. toolbar.timerID2 = window.SetInterval(function() {
  3317. toolbar.delta -= toolbar.step;
  3318. if(toolbar.delta <= 0) {
  3319. toolbar.delta = 0;
  3320. toolbar.state = false;
  3321. window.ClearInterval(toolbar.timerID2);
  3322. toolbar.timerID2 = false;
  3323. };
  3324. window.RepaintRect(0, 0, ww, 30);
  3325. }, 30);
  3326. } ;
  3327. toolbar.timerID_off && window.ClearTimeout(toolbar.timerID_off);
  3328. toolbar.timerID_off = false;
  3329. }, 400);
  3330. };
  3331. };
  3332. };
  3333. };
  3334. return true;
  3335. }
  3336.  
  3337. //=================================================// Drag'n'Drop Callbacks
  3338. var wsh_dragging = false;
  3339.  
  3340. function on_drag_enter() {
  3341. wsh_dragging = true;
  3342. };
  3343.  
  3344. function on_drag_leave() {
  3345. wsh_dragging = false;
  3346. };
  3347.  
  3348. function on_drag_over(action, x, y, mask) {
  3349. on_mouse_move(x, y);
  3350. };
  3351.  
  3352. function on_drag_drop(action, x, y, mask) {
  3353. wsh_dragging = false;
  3354. // We are going to process the dropped items to a playlist
  3355. action.ToPlaylist();
  3356. action.Playlist = plman.ActivePlaylist;
  3357. action.ToSelect = false;
  3358. };
Add Comment
Please, Sign In to add comment