Advertisement
Guest User

marc2003

a guest
Jan 15th, 2010
12,862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //edit this line or comment it out if you don't a fixed size....
  2. window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 375;
  3.  
  4. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  5. //no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
  6. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  7. var g_metadb = fb.GetFocusItem();
  8. var g_img, new_width, new_height = null;
  9. dui = window.InstanceType;
  10.  
  11. var g_tooltip = window.CreateTooltip();
  12. var hover = null;
  13. window.GetProperty("aspect",1);
  14. window.GetProperty("id",0);
  15.  
  16. function RGB(r,g,b) {
  17.     return (0xff000000|(r<<16)|(g<<8)|(b));
  18. }
  19.  
  20. function on_size() {
  21.     ww = window.Width;
  22.     wh = window.Height;
  23. }
  24.  
  25. function on_colors_changed() {
  26.     window.Repaint();
  27. }
  28.  
  29. function on_paint(gr) {
  30.     gr.FillSolidRect(0, 0, ww, wh, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
  31.     if (g_img) {
  32.         if(window.GetProperty("aspect") == 1) {
  33.             var scale_w = ww / g_img.Width;
  34.             var scale_h = wh / g_img.Height;
  35.             scale = Math.min(scale_w, scale_h);
  36.             var pos_x = 0, pos_y = 0;
  37.             if (scale_w < scale_h)
  38.                 pos_y = (wh - g_img.height * scale) / 2;
  39.             else if (scale_w > scale_h)
  40.                 pos_x = (ww - g_img.Width * scale) / 2;
  41.             new_width = g_img.Width * scale;
  42.             new_height = g_img.Height * scale
  43.         } else {
  44.             pos_x = 0;
  45.             pos_y = 0;
  46.             new_width = ww;
  47.             new_height = wh;
  48.         }
  49.         gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height);
  50.     }
  51.     if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
  52. }
  53.  
  54. function on_item_focus_change() {
  55.     g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
  56.     is_embedded = "No";
  57.     if(g_metadb) {
  58.         type = window.GetProperty("id");
  59.         g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
  60.         if(g_img) {
  61.             is_embedded = "Yes";
  62.         } else {
  63.             g_img = utils.GetAlbumArtV2(g_metadb, type);
  64.         }
  65.         window.Repaint();
  66.     }
  67. }
  68.  
  69. function on_playback_new_track() {
  70.     on_item_focus_change();
  71. }
  72.  
  73. on_item_focus_change();
  74.  
  75. function on_mouse_move(x,y) {
  76.     if(!hover && g_img) {
  77.         g_tooltip.Text = "Embedded image: " + is_embedded + ". Actual size: " + g_img.Width + " x " + g_img.Height + ". Current size: " + Math.round(new_width) + " x " + Math.round(new_height) + ".";
  78.         g_tooltip.Activate();
  79.         hover = true;
  80.     }
  81. }
  82.  
  83. function on_mouse_leave() {
  84.     g_tooltip.Deactivate();
  85.     hover = null;
  86. }
  87.  
  88. function on_mouse_rbtn_up(x, y) {
  89.     var MF_SEPARATOR = 0x00000800;
  90.     var MF_STRING = 0x00000000;
  91.     var _menu = window.CreatePopupMenu();
  92.     var idx;
  93.     _menu.AppendMenuItem(MF_STRING, 1, "Refresh");
  94.     _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
  95.     _menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
  96.     _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
  97.     _menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
  98.     _menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
  99.     _menu.AppendMenuItem(MF_STRING, 6, "Disc");
  100.     _menu.AppendMenuItem(MF_STRING, 7, "Icon");
  101.     _menu.AppendMenuItem(MF_STRING, 8, "Artist");
  102.     _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
  103.     //_menu.AppendMenuItem(MF_STRING, 9, "Properties");
  104.     _menu.AppendMenuItem(MF_STRING, 10, "Configure...");
  105.     _menu.CheckMenuItem(2, window.GetProperty("aspect") == 0 ? 0x0 : 0x8);
  106.     _menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
  107.     idx = _menu.TrackPopupMenu(x, y);
  108.     switch(idx) {
  109.         case 1:
  110.             on_item_focus_change();
  111.             break;
  112.         case 2:
  113.             window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
  114.             window.Repaint();
  115.             break;
  116.         case 4:
  117.         case 5:
  118.         case 6:
  119.         case 7:
  120.         case 8:
  121.             window.SetProperty("id", idx-4);
  122.             on_item_focus_change();
  123.             break;
  124.         case 9:
  125.             window.ShowProperties();
  126.             break;
  127.         case 10:
  128.             window.ShowConfigure();
  129.             break;
  130.     }
  131.     _menu.Dispose();
  132.     return true;
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement