1
0

coverflow.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /********************************************************\
  2. ** Filename: coverflow.m **
  3. ** Version: 1.0 **
  4. ** Date: 20. Nov. 2007 - 15:25 **
  5. **********************************************************
  6. ** Type: winamp.wasabi/maki **
  7. ** Project: Cover Flow **
  8. **********************************************************
  9. ** Author: Martin Poehlmann aka Deimos **
  10. ** E-Mail: [email protected] **
  11. ** Internet: http://www.skinconsortium.com **
  12. ** http://home.cs.tum.edu/~poehlman **
  13. \********************************************************/
  14. #include <lib/std.mi>
  15. #include <lib/pldir.mi>
  16. Function update();
  17. Function fade (GuiObject o, int alpha, float s);
  18. Class GuiObject AlbumCover;
  19. Class AlbumCover playButton;
  20. Global AlbumCover prev2, prev1, curr, next1, next2;
  21. Global String sprev2, sprev1, scurr, snext1, snext2;
  22. Global playButton bprev2, bprev1, bcurr, bnext1, bnext2;
  23. Global text info;
  24. #define CENTER_VAR SGrp
  25. Global Group sg;
  26. #include <lib/com/centerlayer.m>
  27. #undef CENTER_VAR
  28. Global PlEdit PleditListener;
  29. Global Timer delay;
  30. System.onScriptLoaded ()
  31. {
  32. sg = getScriptGroup();
  33. PleditListener = new PlEdit;
  34. prev2 = sg.getObject("aa.prev2");
  35. prev1 = sg.getObject("aa.prev1");
  36. curr = sg.getObject("aa.curr");
  37. next1 = sg.getObject("aa.next1");
  38. next2 = sg.getObject("aa.next2");
  39. bprev2 = sg.getObject("play.prev2");
  40. bprev1 = sg.getObject("play.prev1");
  41. bcurr = sg.getObject("play.curr");
  42. bnext1 = sg.getObject("play.next1");
  43. bnext2 = sg.getObject("play.next2");
  44. info = sg.getParent().findObject("info");
  45. _SGrpInit(sg, sg.getParent(), 1, 0);
  46. delay = new Timer;
  47. delay.setDelay(10);
  48. update();
  49. }
  50. System.onScriptUnloading ()
  51. {
  52. delete delay;
  53. }
  54. System.onTitleChange (String newtitle)
  55. {
  56. update();
  57. }
  58. update ()
  59. {
  60. int cur = PlEdit.getCurrentIndex();
  61. int max = PlEdit.getNumTracks();
  62. if (cur > 1)
  63. {
  64. prev2.setXmlParam("source", PlEdit.getFileName(cur-2));
  65. prev2.show();
  66. sprev2 = PlEdit.getTitle(cur-2);
  67. }
  68. else prev2.hide();
  69. if (cur > 0)
  70. {
  71. prev1.setXmlParam("source", PlEdit.getFileName(cur-1));
  72. prev1.show();
  73. sprev1 = PlEdit.getTitle(cur-1);
  74. }
  75. else prev1.hide();
  76. scurr = PlEdit.getTitle(cur);
  77. if (cur < max-2)
  78. {
  79. next2.setXmlParam("source", PlEdit.getFileName(cur+2));
  80. next2.show();
  81. snext2 = PlEdit.getTitle(cur+2);
  82. }
  83. else next2.hide();
  84. if (cur < max-1)
  85. {
  86. next1.setXmlParam("source", PlEdit.getFileName(cur+1));
  87. next1.show();
  88. snext1 = PlEdit.getTitle(cur+1);
  89. }
  90. else next1.hide();
  91. }
  92. PleditListener.onPleditModified ()
  93. {
  94. if (delay) delay.start();
  95. }
  96. delay.onTimer ()
  97. {
  98. delay.stop();
  99. update();
  100. }
  101. AlbumCover.onRightButtonDown (int x, int y)
  102. {
  103. popupmenu p = new popupmenu;
  104. p.addCommand("Get Album Art", 1, 0, 0);
  105. p.addCommand("Refresh Album Art", 2, 0, 0);
  106. p.addCommand("Open Folder", 3, 0, 0);
  107. int result = p.popatmouse();
  108. delete p;
  109. String pis = getXmlParam("source");
  110. if (pis == "") pis = system.getPlayItemString();
  111. if (result == 1)
  112. {
  113. if (system.getAlbumArt(pis) > 0)
  114. {
  115. setXmlParam("notfoundimage", getXmlParam("notfoundimage")); // a nesty refresh - isn't it?
  116. }
  117. }
  118. else if (result == 2)
  119. {
  120. setXmlParam("notfoundimage", getXmlParam("notfoundimage")); // a nesty refresh - isn't it?
  121. }
  122. else if (result == 3)
  123. {
  124. System.navigateUrl(getPath(pis));
  125. }
  126. }
  127. AlbumCover.onLeftButtonDblClk (int x, int y)
  128. {
  129. if (AlbumCover == playButton)
  130. return;
  131. String pis = getXmlParam("source");
  132. if (pis == "") pis = system.getPlayItemString();
  133. System.navigateUrl(getPath(pis));
  134. }
  135. AlbumCover.onEnterArea ()
  136. {
  137. if (!findObject("aa." + getToken(getId(), ".", 1)).isVisible())
  138. {
  139. return;
  140. }
  141. int cur = PlEdit.getCurrentIndex();
  142. if (AlbumCover == prev2 || AlbumCover == bprev2)
  143. info.setText(sprev2);
  144. else if (AlbumCover == prev1 || AlbumCover == bprev1)
  145. info.setText(sprev1);
  146. else if (AlbumCover == curr || AlbumCover == bcurr)
  147. info.setText(scurr);
  148. else if (AlbumCover == next1 || AlbumCover == bnext1)
  149. info.setText(snext1);
  150. else if (AlbumCover == next2 || AlbumCover == bnext2)
  151. info.setText(snext2);
  152. GuiObject o = sg.findObject("play." + getToken(getId(), ".", 1));
  153. if (o )
  154. {
  155. fade(o, 255, 0.133);
  156. }
  157. }
  158. AlbumCover.onLeaveArea ()
  159. {
  160. info.setText("");
  161. GuiObject o = sg.findObject("play." + getToken(getId(), ".", 1));
  162. if (o)
  163. {
  164. fade(o, 0, 0.3);
  165. }
  166. }
  167. playButton.onLeftButtonUp (int x, int y)
  168. {
  169. int cur = PlEdit.getCurrentIndex();
  170. if (playButton == bprev2)
  171. PlEdit.playTrack(cur-2);
  172. else if (playButton == bprev1)
  173. PlEdit.playTrack(cur-1);
  174. else if (playButton == bnext1)
  175. PlEdit.playTrack(cur+1);
  176. else if (playButton == bnext2)
  177. PlEdit.playTrack(cur+2);
  178. setAlpha(0);
  179. info.setTexT("");
  180. }
  181. fade (GuiObject o, int alpha, float s)
  182. {
  183. o.cancelTarget();
  184. o.setTargetA(alpha);
  185. o.setTargetSpeed(s);
  186. o.gotoTarget();
  187. }