Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==PREPROCESSOR==
- // @name "Album Art"
- // @author "Marc2003"
- // @feature "v1.4"
- // @feature "watch-metadb"
- // ==/PREPROCESSOR==
- function on_selection_changed() {
- p.item_focus_change();
- }
- function on_playlist_switch() {
- p.item_focus_change();
- }
- function on_playback_new_track() {
- p.item_focus_change();
- }
- function on_playback_dynamic_info_track() {
- p.item_focus_change();
- }
- function on_playback_stop() {
- p.item_focus_change();
- }
- function on_item_focus_change() {
- p.item_focus_change();
- }
- function on_mouse_leave() {
- if (typeof b == "object") b.leave();
- if (typeof r == "object") r.leave();
- if (typeof li == "object") li.leave();
- if (typeof s == "object") s.leave();
- }
- function on_mouse_rbtn_up(x, y) {
- p.rbtn_up(x, y);
- return true;
- }
- function panel(name, features) {
- this.item_focus_change = function() {
- switch(this.selection_mode) {
- case 0:
- this.metadb = fb.GetSelection();
- break;
- case 1:
- this.metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
- break;
- case 2:
- this.metadb = fb.GetFocusItem();
- break;
- }
- if (this.metadb && typeof on_metadb_changed == "function") on_metadb_changed();
- }
- this.colors_changed = function() {
- }
- this.font_changed = function() {
- }
- this.size = function() {
- this.w = window.Width;
- this.h = window.Height;
- }
- this.move = function(x, y) {
- this.mx = x;
- this.my = y;
- }
- this.rbtn_up = function(x, y) {
- var MF_STRING = 0x00000000;
- var _menu = window.CreatePopupMenu();
- var idx;
- switch(true) {
- case typeof a == "object" && a.trace(x, y):
- _menu.AppendMenuItem(MF_STRING, 1, "Refresh");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 2, "Front");
- _menu.AppendMenuItem(MF_STRING, 3, "Back");
- _menu.AppendMenuItem(MF_STRING, 4, "Disc");
- _menu.AppendMenuItem(MF_STRING, 5, "Icon");
- _menu.AppendMenuItem(MF_STRING, 6, "Artist");
- _menu.CheckMenuRadioItem(2, 6, a.id + 2);
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 16, "Top");
- _menu.AppendMenuItem(MF_STRING, 15, "Centre");
- _menu.AppendMenuItem(MF_STRING, 17, "Adjust");
- _menu.AppendMenuItem(MF_STRING, 18, "Stretch");
- //_menu.AppendMenuSeparator();
- //_menu.AppendMenuItem(MF_STRING, 5000, "Properties");
- _menu.CheckMenuRadioItem(15, 18, a.type == "crop" ? 15 : a.type == "crop top" ? 16 : a.type == "centre" ? 17 : 18);
- //_menu.AppendMenuSeparator();
- break;
- case typeof c == "object" && (!this.check_feature("now_playing") || np_cd) && c.trace(x, y):
- _menu.AppendMenuItem(MF_STRING, 1, "Refresh");
- //_menu.AppendMenuSeparator();
- break;
- }
- //_menu.AppendMenuItem(MF_STRING, 10, "Configure...");
- idx = _menu.TrackPopupMenu(x, y);
- switch(idx) {
- case 1:
- on_item_focus_change();
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- a.id = idx - 2;
- window.SetProperty("artreader_id", a.id);
- on_item_focus_change();
- break;
- case 10:
- window.ShowConfigure();
- break;
- case 15:
- case 16:
- case 17:
- case 18:
- a.type = idx == 15 ? "crop" : idx == 16 ? "crop top" : idx == 17 ? "centre" : "stretch";
- window.SetProperty("artreader_image_type", a.type);
- window.RepaintRect(a.x, a.y, a.w, a.h);
- break;
- case 5000:
- window.ShowProperties();
- break;
- }
- _menu.Dispose();
- }
- this.features_init = function() {
- for (i = 0; i < this.features.length; i++) {
- switch(this.features[i]) {
- case "metadb":
- this.selection_mode = window.GetProperty("selection_mode", 1);
- this.metadb = fb.GetFocusItem();
- break;
- }
- }
- }
- this.check_feature = function(f) {
- for (i = 0; i < this.features.length; i++) {
- if (this.features[i] == f) return true;
- }
- return false;
- }
- this.tt = function(t) {
- if (this.tooltip.Text == t) return;
- this.tooltip.Text = t;
- this.tooltip.Activate();
- }
- this.ttd = function() {
- this.tooltip.Text = "";
- this.tooltip.Deactivate();
- }
- this.draw_image = function(gr, img, pos_x, pos_y, width, height, type, border, alpha) {
- if (!img) return;
- gr.SetInterpolationMode(7);
- switch(type) {
- case "crop":
- case "crop top":
- var sr = img.Width / img.Height;
- var dr = width / height;
- if (sr < dr) {
- var r = img.Width / width;
- var ch = height * r;
- var sy = Math.round((img.Height - ch) / (type == "crop top" ? 1000 : 2));
- var cw = img.Width;
- var sx = 0;
- } else {
- var r = img.Height / height;
- var cw = width * r;
- var sx = Math.round((img.Width - cw) / 2);
- var ch = img.Height;
- var sy = 0;
- }
- gr.DrawImage(img, pos_x, pos_y, width, height, sx + 5, sy + 5, cw - 10, ch - 10, 0, alpha || 255);
- if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border);
- break;
- case "stretch":
- gr.DrawImage(img, pos_x, pos_y, width, height, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255);
- if (border) gr.DrawRect(pos_x, pos_y, width - 1, height - 1, 1, border);
- break;
- case "centre":
- default:
- var s = Math.min(width / img.Width, height / img.Height);
- var nw = Math.round(img.Width * s);
- var nh = Math.round(img.Height * s);
- pos_x += Math.round((width - nw) / 2);
- pos_y += Math.round((height - nh) / 2);
- //for full image, in nex line -change all on 0 or 1
- //example: gr.DrawImage(img, pos_x, pos_y-1, nw, nh, 1, -1, img.Width-1, img.Height+1, 0, alpha || 255);
- gr.DrawImage(img, pos_x, pos_y, nw, nh, 5, 5, img.Width-10, img.Height-10, 0, alpha || 255);
- if (border) gr.DrawRect(pos_x, pos_y, nw - 1, nh - 1, 1, border);
- break;
- }
- }
- this.name = name;
- this.features = features;
- this.dui = window.InstanceType;
- this.tooltip = window.CreateTooltip();
- this.w = 0;
- this.h = 0;
- this.mx = 0;
- this.my = 0;
- this.metadb = fb.GetFocusItem();
- this.vb = new ActiveXObject("ScriptControl");
- this.vb.Language = "VBScript";
- this.artist = "";
- this.artist_tf = "%artist%";
- this.list_font_size = 11;
- this.features_init();
- this.colors_changed();
- this.font_changed();
- }
- function artreader(x, y, w, h) {
- this.draw = function(gr) {
- if (!this.img) return;
- p.draw_image(gr, this.img, this.x, this.y, this.w, this.h, this.type);
- }
- this.metadb_changed = function() {
- if (!p.metadb) return;
- this.img && this.img.Dispose();
- this.path = "";
- this.img = utils.GetAlbumArtV2(p.metadb, this.id);
- window.RepaintRect(this.x, this.y, this.w, this.h);
- utils.GetAlbumArtAsync(window.ID, p.metadb, this.id);
- }
- this.get_album_art_done = function(ip) {
- this.path = ip;
- }
- this.trace = function(x, y) {
- return (x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h);
- }
- this.wheel = function(step) {
- if (!this.trace(p.mx, p.my)) return false;
- this.id -= step;
- if (this.id < 0) this.id = 4;
- if (this.id > 4) this.id = 0;
- window.SetProperty("artreader_id", this.id);
- this.metadb_changed();
- return true;
- }
- this.move = function(x, y) {
- if (this.trace(x, y)) {
- // next line show picture size
- //if (this.img) p.tt("Original size: " + this.img.Width + "x" + this.img.Height + "px");
- //return true;
- } else {
- p.ttd();
- return false;
- }
- }
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.id = window.GetProperty("artreader_id", 0);
- this.img = null;
- this.path = null;
- this.type = window.GetProperty("artreader_image_type", "centre");
- }
- //Begin
- var p = new panel("Art Reader", ["metadb"]);
- var a = new artreader(0, 0, 100, 100);
- on_item_focus_change();
- function on_size() {
- p.size();
- a.w = p.w;
- a.h = p.h;
- }
- function on_paint(gr) {
- a.draw(gr);
- if (!a.img) p.centre_tex;
- }
- function on_metadb_changed() {
- a.metadb_changed();
- }
- function on_get_album_art_done(metadb, art_id, im, ip) {
- a.get_album_art_done(ip);
- }
- function on_mouse_wheel(step) {
- a.wheel(step);
- }
- //next line alow you to skroll images with mouse (front,back,artist..)
- //function on_mouse_move(x, y) {
- //p.move(x, y);
- //a.move(x, y);
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement