Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //edit this line or comment it out if you don't a fixed size....
- window.MinWidth = window.MinHeight = window.MaxWidth = window.MaxHeight = 375;
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //no need to edit anything below here///////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- var g_metadb = fb.GetFocusItem();
- var g_img, new_width, new_height = null;
- dui = window.InstanceType;
- var g_tooltip = window.CreateTooltip();
- var hover = null;
- window.GetProperty("aspect",1);
- window.GetProperty("id",0);
- function RGB(r,g,b) {
- return (0xff000000|(r<<16)|(g<<8)|(b));
- }
- function on_size() {
- ww = window.Width;
- wh = window.Height;
- }
- function on_colors_changed() {
- window.Repaint();
- }
- function on_paint(gr) {
- gr.FillSolidRect(0, 0, ww, wh, dui ==1 ? window.GetColorDUI(1) : window.GetColorCUI(3));
- if (g_img) {
- if(window.GetProperty("aspect") == 1) {
- var scale_w = ww / g_img.Width;
- var scale_h = wh / g_img.Height;
- scale = Math.min(scale_w, scale_h);
- var pos_x = 0, pos_y = 0;
- if (scale_w < scale_h)
- pos_y = (wh - g_img.height * scale) / 2;
- else if (scale_w > scale_h)
- pos_x = (ww - g_img.Width * scale) / 2;
- new_width = g_img.Width * scale;
- new_height = g_img.Height * scale
- } else {
- pos_x = 0;
- pos_y = 0;
- new_width = ww;
- new_height = wh;
- }
- gr.DrawImage(g_img, pos_x, pos_y, new_width, new_height, 0, 0, g_img.Width, g_img.Height);
- }
- if(dui == 1) gr.DrawRect(0,0, window.Width, window.Height, 1.0, RGB(160,160,160));
- }
- function on_item_focus_change() {
- g_metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
- is_embedded = "No";
- if(g_metadb) {
- type = window.GetProperty("id");
- g_img = utils.GetAlbumArtEmbedded(g_metadb.rawpath, type);
- if(g_img) {
- is_embedded = "Yes";
- } else {
- g_img = utils.GetAlbumArtV2(g_metadb, type);
- }
- window.Repaint();
- }
- }
- function on_playback_new_track() {
- on_item_focus_change();
- }
- on_item_focus_change();
- function on_mouse_move(x,y) {
- if(!hover && g_img) {
- 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) + ".";
- g_tooltip.Activate();
- hover = true;
- }
- }
- function on_mouse_leave() {
- g_tooltip.Deactivate();
- hover = null;
- }
- function on_mouse_rbtn_up(x, y) {
- var MF_SEPARATOR = 0x00000800;
- var MF_STRING = 0x00000000;
- var _menu = window.CreatePopupMenu();
- var idx;
- _menu.AppendMenuItem(MF_STRING, 1, "Refresh");
- _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
- _menu.AppendMenuItem(MF_STRING, 2, "Correct Aspect Ratio");
- _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
- _menu.AppendMenuItem(MF_STRING, 4, "Front Cover");
- _menu.AppendMenuItem(MF_STRING, 5, "Back Cover");
- _menu.AppendMenuItem(MF_STRING, 6, "Disc");
- _menu.AppendMenuItem(MF_STRING, 7, "Icon");
- _menu.AppendMenuItem(MF_STRING, 8, "Artist");
- _menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
- //_menu.AppendMenuItem(MF_STRING, 9, "Properties");
- _menu.AppendMenuItem(MF_STRING, 10, "Configure...");
- _menu.CheckMenuItem(2, window.GetProperty("aspect") == 0 ? 0x0 : 0x8);
- _menu.CheckMenuRadioItem(4, 8, window.GetProperty("id")+4);
- idx = _menu.TrackPopupMenu(x, y);
- switch(idx) {
- case 1:
- on_item_focus_change();
- break;
- case 2:
- window.GetProperty("aspect") == 0 ? window.SetProperty("aspect", 1) : window.SetProperty("aspect", 0);
- window.Repaint();
- break;
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- window.SetProperty("id", idx-4);
- on_item_focus_change();
- break;
- case 9:
- window.ShowProperties();
- break;
- case 10:
- window.ShowConfigure();
- break;
- }
- _menu.Dispose();
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement