Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==PREPROCESSOR==
- // @name "JS Smooth Browser"
- // @version "20150927-1450-101"
- // @author "Br3tt aka Falstaff >> http://br3tt.deviantart.com"
- // @feature "v1.4"
- // @feature "watch-metadb"
- // @import "%fb2k_profile_path%wsh_br3tt\jssb\js\WSHcommon.js"
- // @import "%fb2k_profile_path%wsh_br3tt\jssb\js\WSHinputbox.js"
- // ==/PREPROCESSOR==
- images = {
- path: fb.ProfilePath+"\\wsh_br3tt\\jssb\\images\\",
- glass_reflect: null,
- loading_angle: 0,
- loading_draw: null
- };
- ppt = {
- sourceMode: window.GetProperty("_PROPERTY: Source Mode", 0), // 0 = Library, 1 = Playlist
- tagMode: window.GetProperty("_PROPERTY: Tag Mode", 1), // 1 = album, 2 = artist, 3 = genre
- albumArtId: 0, // 0 = front
- panelMode: window.GetProperty("_PROPERTY: Display Mode", 1), // 0 = text, 1 = stamps + text, 2 = lines + text, 3 = stamps no text
- albumsTFsorting: window.GetProperty("Sort Order - ALBUM", "%album artist% | %album% | %date% | %discnumber% | %tracknumber% | %title%"),
- artistsTFsorting: window.GetProperty("Sort Order - ARTIST", "%artist% | %album% | %date% | %discnumber% | %tracknumber% | %title%"),
- genresTFsorting: window.GetProperty("Sort Order - GENRE", "%genre% | %album artist% | %album% | %date% | %discnumber% | %tracknumber% | %title%"),
- showAllItem: window.GetProperty("_PROPERTY: Show ALL item", true),
- lineHeightMin: window.GetProperty("SYSTEM Minimal Line Height", 90),
- thumbnailWidthMin: window.GetProperty("SYSTEM thumbnails Minimal Width", 130),
- scrollRowDivider: window.GetProperty("SYSTEM Scroll Row Divider", 1),
- tf_groupkey_genre: fb.TitleFormat("%genre% ## %album artist% ^^ %album% ^^ %discnumber% ^^ %artist% ^^ %title% ^^ %date%"),
- tf_groupkey_artist: fb.TitleFormat("%artist% ## %album artist% ^^ %album% ^^ %discnumber% ^^ %title% ^^ %genre% ^^ %date%"),
- tf_groupkey_album: fb.TitleFormat("%album artist% ^^ %album% ## %discnumber% ^^ %artist% ^^ %title% ^^ %genre% ^^ %date%"),
- tf_path: fb.TitleFormat("$directory_path(%path%)\\"),
- tf_path_artist: fb.TitleFormat(window.GetProperty("_PROPERTY: Artist Images Folder", "X:\\XPS2720\\MP3\\artists\\%artist%.jpg")),
- tf_path_genre: fb.TitleFormat(images.path+"genres\\%genre%.jpg"),
- tf_crc: fb.TitleFormat("$crc32(%path%)"),
- tf_crc_artist: fb.TitleFormat("$crc32('artists'%artist%)"),
- tf_crc_genre: fb.TitleFormat("$crc32('genres'%genre%)"),
- tf_time_remaining: fb.TitleFormat("$if(%length%,-%playback_time_remaining%,'0:00')"),
- rowHeight: 22,
- rowScrollStep: 1,
- scrollSmoothness: 2.5,
- refreshRate: 40,
- refreshRateCover: 2,
- showHeaderBar: window.GetProperty("_DISPLAY: Show Top Bar", true),
- defaultHeaderBarHeight: 26,
- headerBarHeight: 26,
- enableCustomColors: window.GetProperty("_PROPERTY: Custom Colors", false),
- showwallpaper: window.GetProperty("_DISPLAY: Show Wallpaper", false),
- wallpaperalpha: 150,
- wallpaperblurred: window.GetProperty("_DISPLAY: Wallpaper Blurred", true),
- wallpaperblurvalue: 1.05,
- wallpapermode: window.GetProperty("_SYSTEM: Wallpaper Mode", 0),
- wallpaperpath: window.GetProperty("_PROPERTY: Default Wallpaper Path", ".\\wsh_br3tt\\jssb\\images\\default.png"),
- extra_font_size: window.GetProperty("_SYSTEM: Extra font size value", 0),
- enableTouchControl: window.GetProperty("_PROPERTY: Enable Scroll Touch Control", true)
- };
- cTouch = {
- down: false,
- y_start: 0,
- y_end: 0,
- y_current: 0,
- y_prev: 0,
- y_move: 0,
- scroll_delta: 0,
- t1: null,
- timer: false,
- multiplier: 0,
- delta: 0
- };
- cSettings = {
- visible: false
- };
- cFilterBox = {
- enabled: window.GetProperty("_PROPERTY: Enable Playlist Filter", true),
- default_w: 120,
- default_h: 20,
- w: 120,
- h: 20
- };
- cScrollBar = {
- enabled: window.GetProperty("_DISPLAY: Show Scrollbar", true),
- visible: true,
- themed: false,
- defaultWidth: get_system_scrollbar_width(),
- width: get_system_scrollbar_width(),
- ButtonType: {cursor: 0, up: 1, down: 2},
- defaultMinCursorHeight: 20,
- minCursorHeight: 20,
- timerID: false,
- timerCounter: -1
- };
- cover = {
- draw_glass_reflect: false,
- keepaspectratio: true,
- max_w: 0
- };
- timers = {
- coverLoad: false,
- coverDone: false,
- mouseWheel: false,
- saveCover: false,
- mouseDown: false,
- addItems: false,
- showMenu: false
- };
- /*
- ===================================================================================================
- Images cache
- ===================================================================================================
- */
- function reset_cover_timers() {
- if(timers.coverDone) {
- timers.coverDone && window.ClearTimeout(timers.coverDone);
- timers.coverDone = false;
- };
- };
- function on_load_image_done(tid, image){
- var tot = brw.groups.length;
- for(var k = 0; k < tot; k++) {
- if(brw.groups[k].metadb) {
- if(brw.groups[k].tid == tid && brw.groups[k].load_requested == 1) {
- brw.groups[k].load_requested = 2;
- brw.groups[k].cover_img = g_image_cache.getit(brw.groups[k].metadb, k, image);
- if(!isScrolling && !cScrollBar.timerID) {
- if(k < brw.groups.length && k >= g_start_ && k <= g_end_) {
- if(!timers.coverDone) {
- timers.coverDone = window.SetTimeout(function() {
- g_1x1 = false;
- brw.cover_repaint();
- timers.coverDone && window.ClearTimeout(timers.coverDone);
- timers.coverDone = false;
- }, 1);
- };
- }; else {
- if(!timers.coverDone) {
- timers.coverDone = window.SetTimeout(function() {
- g_1x1 = true;
- window.RepaintRect(0, 0, 1, 1);
- g_1x1 = false;
- timers.coverDone && window.ClearTimeout(timers.coverDone);
- timers.coverDone = false;
- }, 1);
- };
- };
- };
- break;
- };
- };
- };
- };
- function on_get_album_art_done(metadb, art_id, image, image_path) {
- var tot = brw.groups.length;
- if(ppt.albumArtId != 0) {
- for(var i = 0; i < tot; i++) {
- if(brw.groups[i].metadb) {
- if(brw.groups[i].metadb.Compare(metadb)) {
- brw.groups[i].cover_img = g_image_cache.getit(metadb, i, image);
- if(!isScrolling && !cScrollBar.timerID) {
- if(i < brw.groups.length && i >= g_start_ && i <= g_end_) {
- if(!timers.coverDone) {
- timers.coverDone = window.SetTimeout(function() {
- g_1x1 = false;
- brw.cover_repaint();
- timers.coverDone && window.ClearTimeout(timers.coverDone);
- timers.coverDone = false;
- }, 5);
- };
- }; else {
- g_1x1 = true;
- window.RepaintRect(0, 0, 1, 1);
- g_1x1 = false;
- };
- };
- break;
- };
- };
- };
- }; else {
- var i = art_id - 5;
- g_last = i;
- if(i < tot) {
- if(brw.groups[i].metadb) {
- brw.groups[i].cover_img = g_image_cache.getit(metadb, i, image);
- if(!isScrolling && !cScrollBar.timerID) {
- if(i < brw.groups.length && i >= g_start_ && i <= g_end_) {
- if(!timers.coverDone) {
- timers.coverDone = window.SetTimeout(function() {
- g_1x1 = false;
- brw.cover_repaint();
- timers.coverDone && window.ClearTimeout(timers.coverDone);
- timers.coverDone = false;
- }, 5);
- };
- }; else {
- g_1x1 = true;
- window.RepaintRect(0, 0, 1, 1);
- g_1x1 = false;
- };
- };
- };
- };
- };
- };
- //=================================================// Cover Tools
- image_cache = function () {
- this._cachelist = {};
- this.hit = function (metadb, albumIndex) {
- var img = this._cachelist[brw.groups[albumIndex].cachekey];
- if (typeof(img) == "undefined" || img == null) { // if image not in cache, we load it asynchronously
- //if(!isScrolling && !cScrollBar.timerID) { // and when no scrolling
- brw.groups[albumIndex].crc = check_cache(metadb, albumIndex);
- if(brw.groups[albumIndex].crc && brw.groups[albumIndex].load_requested == 0) {
- // load img from cache
- if(!timers.coverLoad) {
- if(!isScrolling && !cScrollBar.timerID) {
- timers.coverLoad = window.SetTimeout(function() {
- brw.groups[albumIndex].tid = load_image_from_cache(metadb, brw.groups[albumIndex].crc);
- brw.groups[albumIndex].load_requested = 1;
- timers.coverLoad && window.ClearTimeout(timers.coverLoad);
- timers.coverLoad = false;
- }, 1);
- }; else {
- timers.coverLoad = window.SetTimeout(function() {
- brw.groups[albumIndex].tid = load_image_from_cache(metadb, brw.groups[albumIndex].crc);
- brw.groups[albumIndex].load_requested = 1;
- timers.coverLoad && window.ClearTimeout(timers.coverLoad);
- timers.coverLoad = false;
- }, 20);
- };
- };
- }; else if(brw.groups[albumIndex].load_requested == 0) {
- // load img default method
- if(!timers.coverLoad) {
- timers.coverLoad = window.SetTimeout(function() {
- if(ppt.albumArtId==5) { // genre
- var arr = brw.groups[albumIndex].groupkey.split(" ^^ ");
- try {
- var genre_img = gdi.Image(images.path + "genres\\" + arr[0] + ".jpg");
- } catch(e) {
- var genre_img = gdi.Image(images.path + "genres\\" + "default.jpg");
- };
- brw.groups[albumIndex].cover_img = g_image_cache.getit(metadb, albumIndex, genre_img);
- brw.repaint();
- }; else {
- this.albumArtId = ppt.albumArtId == 0 ? albumIndex + 5 : ppt.albumArtId;
- utils.GetAlbumArtAsync(window.ID, metadb, this.albumArtId, true, false, false);
- };
- timers.coverLoad && window.ClearTimeout(timers.coverLoad);
- timers.coverLoad = false;
- }, (!isScrolling && !cScrollBar.timerID ? 5 : 20));
- };
- };
- //};
- };
- return img;
- };
- this.reset = function(key) {
- this._cachelist[key] = null;
- };
- this.getit = function (metadb, albumId, image) {
- var cw = cover.max_w;
- var ch = cw;
- var img;
- if(cover.keepaspectratio) {
- if(!image) {
- var pw = cw;
- var ph = ch;
- }; else {
- if(image.Height>=image.Width) {
- var ratio = image.Width / image.Height;
- var pw = cw * ratio;
- var ph = ch;
- }; else {
- var ratio = image.Height / image.Width;
- var pw = cw;
- var ph = ch * ratio;
- };
- };
- }; else {
- var pw = cw;
- var ph = ch;
- };
- // cover.type : 0 = nocover, 1 = external cover, 2 = embedded cover, 3 = stream
- if(brw.groups[albumId].tracktype != 3) {
- if(metadb) {
- if(image) {
- img = FormatCover(image, pw, ph, cover.draw_glass_reflect, false);
- cover.type = 1;
- }; else {
- img = FormatNoCover(albumId, pw, ph, cover.draw_glass_reflect, false, ppt.albumArtId);
- cover.type = 0;
- };
- };
- }; else {
- img = FormatNoCover(albumId, pw, ph, cover.draw_glass_reflect, false, ppt.albumArtId);
- cover.type = 3;
- };
- this._cachelist[brw.groups[albumId].cachekey] = img;
- // save img to cache
- if(cover.type == 1 && !brw.groups[albumId].save_requested) {
- if(!timers.saveCover) {
- brw.groups[albumId].save_requested = true;
- save_image_to_cache(metadb, albumId);
- timers.saveCover = window.SetTimeout(function() {
- window.ClearTimeout(timers.saveCover);
- timers.saveCover = false;
- }, 100);
- };
- };
- return img;
- };
- };
- var g_image_cache = new image_cache;
- function FormatCover(image, w, h, reflect, rawBitmap) {
- if(!image || w<=0 || h<=0) return image;
- if(reflect) {
- var new_img = image.Resize(w, h, 2);
- var gb = new_img.GetGraphics();
- if(h > w) {
- gb.DrawImage(cover.glass_reflect, Math.floor((h-w)/2)*-1 + 1, 1, h - 2, h - 2, 0, 0, cover.glass_reflect.Width, cover.glass_reflect.Height, 0, 150);
- }; else {
- gb.DrawImage(cover.glass_reflect, 1, Math.floor((w-h)/2)*-1 + 1, w - 2, w - 2, 0, 0, cover.glass_reflect.Width, cover.glass_reflect.Height, 0, 150);
- };
- new_img.ReleaseGraphics(gb);
- if(rawBitmap) {
- return new_img.CreateRawBitmap();
- }; else {
- return new_img;
- };
- }; else {
- if(rawBitmap) {
- return image.Resize(w, h, 2).CreateRawBitmap();
- }; else {
- return image.Resize(w, h, 2);
- };
- };
- };
- function FormatNoCover(albumId, w, h, reflect, rawBitmap, albumArtId) {
- switch(ppt.tagMode) {
- case 1:
- var crc = ppt.tf_crc.EvalWithMetadb(brw.groups[albumId].metadb);
- break;
- case 2:
- var crc = ppt.tf_crc_artist.EvalWithMetadb(brw.groups[albumId].metadb);
- break;
- case 3:
- var crc = ppt.tf_crc_genre.EvalWithMetadb(brw.groups[albumId].metadb);
- break;
- }
- var words = brw.groups[albumId].groupkey.split(" ");
- if(words.length > 1) {
- try {
- var chr = words[0][0].toUpperCase()+words[1][0].toUpperCase();
- }; catch(e) {
- var chr = words[0][0]+words[1][0];
- };
- }; else {
- if(brw.groups[albumId].groupkey.length > 1) {
- try {
- var chr = words[0][0].toUpperCase()+words[0][1].toUpperCase();
- }; catch(e) {
- var chr = words[0][0]+words[0][1];
- };
- }; else {
- try {
- var chr = words[0][0].toUpperCase();
- }; catch(e) {
- var chr = words[0][0];
- };
- };
- };
- var colors = Array(RGB(255,0,0), RGB(0,255,0), RGB(0,0,255), RGB(255,255,0), RGB(255,0,255), RGB(0,255,255));
- var idx = crc % colors.length;
- var image = gdi.CreateImage(w, h);
- var gb = image.GetGraphics();
- // draw nocover image
- gb.FillSolidRect(0, 0, w, h, RGB(255,255,255));
- gb.FillGradRect(0, 0, w, h, 45, colors[idx] & 0x55ffffff, colors[idx] & 0x40ffffff, 0.5);
- gb.SetTextRenderingHint(4);
- switch(albumArtId) {
- case 4: // artist
- gb.SetSmoothingMode(2);
- gb.FillEllipse(7, 2, w-14, h-14, RGBA(0,0,0,35));
- gb.FillEllipse(-5, h-12, w+10, 45, RGBA(0,0,0,35));
- gb.SetSmoothingMode(0);
- gb.DrawString(chr, gdi.Font("Arial", Math.round(h/10*3.0), 1), RGBA(0,0,0,120), 3, 2, w-6, h-12, cc_stringformat);
- break;
- case 5: // genre
- gb.SetSmoothingMode(2);
- gb.FillEllipse(1, 1, w-2, h-2, RGBA(0,0,0,35));
- gb.SetSmoothingMode(0);
- gb.DrawString(brw.groups[albumId].groupkey.substr(0,5).toUpperCase(), gdi.Font("Arial", Math.round(h/10*2.0), 1), RGBA(0,0,0,120), 0, 0, w, h, cc_stringformat);
- break;
- default: // album + others
- gb.SetSmoothingMode(2);
- gb.FillEllipse(1, 1, w-2, h-2, RGBA(0,0,0,35));
- gb.SetSmoothingMode(0);
- gb.DrawString("NO COVER", gdi.Font("Arial", Math.round(h/10*2), 1), RGBA(0,0,0,120), 0, 0, w, h, cc_stringformat);
- };
- image.ReleaseGraphics(gb);
- if(reflect) {
- var new_img = image.Resize(w, h, 2);
- var gb = new_img.GetGraphics();
- if(h > w) {
- gb.DrawImage(cover.glass_reflect, Math.floor((h-w)/2)*-1 + 1, 1, h - 2, h - 2, 0, 0, cover.glass_reflect.Width, cover.glass_reflect.Height, 0, 150);
- }; else {
- gb.DrawImage(cover.glass_reflect, 1, Math.floor((w-h)/2)*-1 + 1, w - 2, w - 2, 0, 0, cover.glass_reflect.Width, cover.glass_reflect.Height, 0, 150);
- };
- new_img.ReleaseGraphics(gb);
- if(rawBitmap) {
- return new_img.CreateRawBitmap();
- }; else {
- return new_img;
- };
- }; else {
- if(rawBitmap) {
- return image.CreateRawBitmap();
- }; else {
- return image;
- };
- };
- };
- /*
- ===================================================================================================
- Objects
- ===================================================================================================
- */
- oFilterBox = function() {
- this.images = {
- filterIcon: gdi.Image(images.path+"mag.png"),
- resetIcon_off: null,
- resetIcon_ov: null
- };
- this.getImages = function() {
- var gb;
- this.images.resetIcon_off = gdi.CreateImage(18, 18);
- gb = this.images.resetIcon_off.GetGraphics();
- gb.setSmoothingMode(2);
- var xpts1 = Array(6,5, 13,12, 12,13, 5,6);
- var xpts2 = Array(5,12, 12,5, 13,6, 6,13);
- gb.FillPolygon(RGB(170,170,170), 0, xpts1);
- gb.FillPolygon(RGB(170,170,170), 0, xpts2);
- gb.DrawLine(6,6, 12, 12, 2.0, RGBA(255,255,255,180));
- gb.DrawLine(6,12, 12, 6, 2.0, RGBA(255,255,255,180));
- gb.setSmoothingMode(0);
- this.images.resetIcon_off.ReleaseGraphics(gb);
- this.images.resetIcon_ov = gdi.CreateImage(18, 18);
- gb = this.images.resetIcon_ov.GetGraphics();
- gb.setSmoothingMode(2);
- gb.DrawLine(4,4, 14, 14, 3.0, RGBA(255,255,255,240));
- gb.DrawLine(4,14, 14, 4, 3.0, RGBA(255,255,255,240));
- gb.setSmoothingMode(0);
- this.images.resetIcon_ov.ReleaseGraphics(gb);
- this.images.resetIcon_dn = gdi.CreateImage(18, 18);
- gb = this.images.resetIcon_dn.GetGraphics();
- gb.setSmoothingMode(2);
- gb.DrawLine(4, 4, 14, 14, 3.0, RGBA(255,50,50,255));
- gb.DrawLine(4, 14, 14, 4, 3.0, RGBA(255,50,50,255));
- gb.setSmoothingMode(0);
- this.images.resetIcon_dn.ReleaseGraphics(gb);
- if(typeof(this.reset_bt) == "undefined") {
- this.reset_bt = new button(this.images.resetIcon_off, this.images.resetIcon_ov, this.images.resetIcon_dn);
- }; else {
- this.reset_bt.img[0] = this.images.resetIcon_off;
- this.reset_bt.img[1] = this.images.resetIcon_ov;
- this.reset_bt.img[2] = this.images.resetIcon_dn;
- };
- };
- this.getImages();
- this.on_init = function() {
- this.inputbox = new oInputbox(cFilterBox.w, cFilterBox.h, "", "Library Filter", RGB(240,240,240), 0, 0, RGB(150, 170, 255), g_sendResponse, "brw");
- this.inputbox.autovalidation = true;
- };
- this.on_init();
- this.draw = function(gr, x, y) {
- var bx = x;
- var by = y;
- var bw = this.inputbox.w + 44;
- //gr.FillSolidRect(bx-2, by, bw+2, 20, blendColors(g_color_normal_bg, RGB(255,255,255), 0.05));
- if(this.inputbox.edit) {
- gr.SetSmoothingMode(2);
- //gr.DrawRect(bx-3, by-1, bw+2, 21, 2.0, RGB(130,140,240));
- gr.SetSmoothingMode(0);
- }; else {
- //gr.DrawRect(bx-3, by-1, bw+2, 21, 1.0, blendColors(g_color_normal_txt, g_color_normal_bg, 0.75));
- };
- if(this.inputbox.text.length > 0) {
- this.reset_bt.draw(gr, bx-1, by+1, 255);
- }; else {
- gr.DrawImage(this.images.filterIcon.Resize(cFilterBox.h-1,cFilterBox.h-1,2) , bx, by, cFilterBox.h-1, cFilterBox.h-1, 0, 0, cFilterBox.h-1, cFilterBox.h-1, 0, 255);
- };
- for(var i = 0; i < cFilterBox.h-2; i+=2) {
- gr.FillSolidRect(bx+25+cFilterBox.w, by+2+i, 1, 1, RGB(100,100,100));
- };
- this.inputbox.draw(gr, bx+22, by, 0, 0);
- };
- this.on_mouse = function(event, x, y, delta) {
- switch(event) {
- case "lbtn_down":
- this.inputbox.check("down", x, y);
- if(this.inputbox.text.length > 0) this.reset_bt.checkstate("down", x, y);
- break;
- case "lbtn_up":
- this.inputbox.check("up", x, y);
- if(this.inputbox.text.length > 0) {
- if(this.reset_bt.checkstate("up", x, y) == ButtonStates.hover) {
- this.inputbox.text = "";
- this.inputbox.offset = 0;
- g_sendResponse();
- };
- };
- break;
- case "lbtn_dblclk":
- this.inputbox.check("dblclk", x, y);
- break;
- case "rbtn_down":
- this.inputbox.check("right", x, y);
- break;
- case "move":
- this.inputbox.check("move", x, y);
- if(this.inputbox.text.length > 0) this.reset_bt.checkstate("move", x, y);
- break;
- };
- };
- this.on_key = function(event, vkey) {
- switch(event) {
- case "down":
- this.inputbox.on_key_down(vkey);
- break;
- };
- };
- this.on_char = function(code) {
- this.inputbox.on_char(code);
- };
- this.on_focus = function(is_focused) {
- this.inputbox.on_focus(is_focused);
- };
- };
- oScrollbar = function(themed) {
- this.themed = themed;
- this.showButtons = true;
- this.buttons = Array(null, null, null);
- this.buttonType = {cursor: 0, up: 1, down: 2};
- this.buttonClick = false;
- this.color_bg = g_color_normal_bg;
- this.color_txt = g_color_normal_txt;
- if(this.themed) {
- this.theme = window.CreateThemeManager("scrollbar");
- }; else {
- this.theme = false;
- };
- this.setNewColors = function() {
- this.color_bg = g_color_normal_bg;
- this.color_txt = g_color_normal_txt;
- this.setButtons();
- this.setCursorButton();
- };
- this.setButtons = function() {
- // normal scroll_up Image
- // Draw Themed Scrollbar (lg/col)
- if(this.themed) {
- this.upImage_normal = gdi.CreateImage(this.w, this.w);
- var gb = this.upImage_normal.GetGraphics();
- try {
- this.theme.SetPartAndStateId(1, 1);
- this.theme.DrawThemeBackground(gb, 0, 0, this.w, this.w);
- }; catch(e) {
- DrawPolyStar(gb, 4, 4, this.w-8, 1, 3, 0, RGB(0,0,0), blendColors(this.color_txt, this.color_bg, 0.5), 0, 255);
- };
- }; else {
- this.upImage_normal = gdi.CreateImage(70, 70);
- var gb = this.upImage_normal.GetGraphics();
- DrawPolyStar(gb, 10, 16, 44, 1, 3, 0, RGB(0,0,0), blendColors(this.color_txt, this.color_bg, 0.5), 0, 255);
- };
- this.upImage_normal.ReleaseGraphics(gb);
- // hover scroll_up Image
- // Draw Themed Scrollbar (lg/col)
- if(this.themed) {
- this.upImage_hover = gdi.CreateImage(this.w, this.w);
- gb = this.upImage_hover.GetGraphics();
- try {
- this.theme.SetPartAndStateId(1, 2);
- this.theme.DrawThemeBackground(gb, 0, 0, this.w, this.w);
- }; catch(e) {
- DrawPolyStar(gb, 4, 4, this.w-8, 1, 3, 0, blendColors(this.color_txt, this.color_bg, 0.3), blendColors(this.color_txt, this.color_bg, 0.3), 0, 255);
- };
- }; else {
- this.upImage_hover = gdi.CreateImage(70, 70);
- var gb = this.upImage_hover.GetGraphics();
- DrawPolyStar(gb, 10, 16, 44, 1, 3, 0, blendColors(this.color_txt, this.color_bg, 0.3), blendColors(this.color_txt, this.color_bg, 0.3), 0, 255);
- };
- this.upImage_hover.ReleaseGraphics(gb);
- // down scroll_up Image
- // Draw Themed Scrollbar (lg/col)
- if(this.themed) {
- this.upImage_down = gdi.CreateImage(this.w, this.w);
- gb = this.upImage_down.GetGraphics();
- try {
- this.theme.SetPartAndStateId(1, 3);
- this.theme.DrawThemeBackground(gb, 0, 0, this.w, this.w);
- }; catch(e) {
- DrawPolyStar(gb, 4, 4, this.w-8, 1, 3, 0, RGB(0,0,0), blendColors(this.color_txt, this.color_bg, 0.05), 0, 255);
- };
- }; else {
- this.upImage_down = gdi.CreateImage(70, 70);
- gb = this.upImage_down.GetGraphics();
- DrawPolyStar(gb, 10, 13, 44, 1, 3, 0, RGB(0,0,0), blendColors(this.color_txt, this.color_bg, 0.05), 0, 255);
- };
- this.upImage_down.ReleaseGraphics(gb);
- // normal scroll_down Image
- // Draw Themed Scrollbar (lg/col)
- if(this.themed) {
- this.downImage_normal = gdi.CreateImage(this.w, this.w);
- gb = this.downImage_normal.GetGraphics();
- try {
- this.theme.SetPartAndStateId(1, 5);
- this.theme.DrawThemeBackground(gb, 0, 0, this.w, this.w);
- }; catch(e) {
- DrawPolyStar(gb, 4, 4, this.w-8, 1, 3, 0, RGB(0,0,0), blendColors(this.color_txt, this.color_bg, 0.5), 180, 255);
- };
- }; else {
- this.downImage_normal = gdi.CreateImage(70, 70);
- gb = this.downImage_normal.GetGraphics();
- DrawPolyStar(gb, 10, 10, 44, 1, 3, 0, RGB(0,0,0), blendColors(this.color_txt, this.color_bg, 0.5), 180, 255);
- };
- this.downImage_normal.ReleaseGraphics(gb);
- // hover scroll_down Image
- // Draw Themed Scrollbar (lg/col)
- if(this.themed) {
- this.downImage_hover = gdi.CreateImage(this.w, this.w);
- gb = this.downImage_hover.GetGraphics();
- try {
- this.theme.SetPartAndStateId(1, 6);
- this.theme.DrawThemeBackground(gb, 0, 0, this.w, this.w);
- }; catch(e) {
- DrawPolyStar(gb, 4, 4, this.w-8, 1, 3, 1, blendColors(this.color_txt, this.color_bg, 0.3), blendColors(this.color_txt, this.color_bg, 0.3), 180, 255);
- };
- }; else {
- this.downImage_hover = gdi.CreateImage(70, 70);
- gb = this.downImage_hover.GetGraphics();
- DrawPolyStar(gb, 10, 10, 44, 1, 3, 1, blendColors(this.color_txt, this.color_bg, 0.3), blendColors(this.color_txt, this.color_bg, 0.3), 180, 255);
- };
- this.downImage_hover.ReleaseGraphics(gb);
- // down scroll_down Image
- // Draw Themed Scrollbar (lg/col)
- if(this.themed) {
- this.downImage_down = gdi.CreateImage(this.w, this.w);
- gb = this.downImage_down.GetGraphics();
- try {
- this.theme.SetPartAndStateId(1, 7);
- this.theme.DrawThemeBackground(gb, 0, 0, this.w, this.w);
- }; catch(e) {
- DrawPolyStar(gb, 4, 4, this.w-8, 1, 3, 0, RGB(0,0,0), blendColors(this.color_txt, this.color_bg, 0.05), 180, 255);
- };
- }; else {
- this.downImage_down = gdi.CreateImage(70, 70);
- gb = this.downImage_down.GetGraphics();
- DrawPolyStar(gb, 10, 13, 44, 1, 3, 0, RGB(0,0,0), blendColors(this.color_txt, this.color_bg, 0.05), 180, 255);
- };
- this.downImage_down.ReleaseGraphics(gb);
- for(i = 1; i < this.buttons.length; i++) {
- switch(i) {
- case this.buttonType.cursor:
- this.buttons[this.buttonType.cursor] = new button(this.cursorImage_normal, this.cursorImage_hover, this.cursorImage_down);
- break;
- case this.buttonType.up:
- this.buttons[this.buttonType.up] = new button(this.upImage_normal.Resize(this.w,this.w,2), this.upImage_hover.Resize(this.w,this.w,2), this.upImage_down.Resize(this.w,this.w,2));
- break;
- case this.buttonType.down:
- this.buttons[this.buttonType.down] = new button(this.downImage_normal.Resize(this.w,this.w,2), this.downImage_hover.Resize(this.w,this.w,2), this.downImage_down.Resize(this.w,this.w,2));
- break;
- };
- };
- };
- this.setCursorButton = function() {
- // normal cursor Image
- this.cursorImage_normal = gdi.CreateImage(this.cursorw, this.cursorh);
- var gb = this.cursorImage_normal.GetGraphics();
- // Draw Themed Scrollbar (lg/col)
- if(this.themed) {
- try {
- this.theme.SetPartAndStateId(3, 1);
- this.theme.DrawThemeBackground(gb, 0, 0, this.cursorw, this.cursorh);
- if(this.cursorh >= 30) {
- this.theme.SetPartAndStateId(9, 1);
- this.theme.DrawThemeBackground(gb, 0, 0, this.cursorw, this.cursorh);
- };
- }; catch(e) {
- gb.FillSolidRect(1, 0, this.cursorw-2, this.cursorh, blendColors(this.color_txt, this.color_bg, 0.5));
- };
- }; else {
- gb.FillSolidRect(1, 0, this.cursorw-2, this.cursorh, blendColors(this.color_txt, this.color_bg, 0.5));
- };
- this.cursorImage_normal.ReleaseGraphics(gb);
- // hover cursor Image
- this.cursorImage_hover = gdi.CreateImage(this.cursorw, this.cursorh);
- gb = this.cursorImage_hover.GetGraphics();
- // Draw Themed Scrollbar (lg/col)
- if(this.themed) {
- try {
- this.theme.SetPartAndStateId(3, 2);
- this.theme.DrawThemeBackground(gb, 0, 0, this.cursorw, this.cursorh);
- if(this.cursorh >= 30) {
- this.theme.SetPartAndStateId(9, 2);
- this.theme.DrawThemeBackground(gb, 0, 0, this.cursorw, this.cursorh);
- };
- }; catch(e) {
- gb.FillSolidRect(1, 0, this.cursorw-2, this.cursorh, blendColors(this.color_txt, this.color_bg, 0.3));
- };
- }; else {
- gb.FillSolidRect(1, 0, this.cursorw-2, this.cursorh, blendColors(this.color_txt, this.color_bg, 0.3));
- };
- this.cursorImage_hover.ReleaseGraphics(gb);
- // down cursor Image
- this.cursorImage_down = gdi.CreateImage(this.cursorw, this.cursorh);
- gb = this.cursorImage_down.GetGraphics();
- // Draw Themed Scrollbar (lg/col)
- if(this.themed) {
- try {
- this.theme.SetPartAndStateId(3, 3);
- this.theme.DrawThemeBackground(gb, 0, 0, this.cursorw, this.cursorh);
- if(this.cursorh >= 30) {
- this.theme.SetPartAndStateId(9, 3);
- this.theme.DrawThemeBackground(gb, 0, 0, this.cursorw, this.cursorh);
- };
- }; catch(e) {
- gb.FillSolidRect(1, 0, this.cursorw-2, this.cursorh, blendColors(this.color_txt, this.color_bg, 0.05));
- };
- }; else {
- gb.FillSolidRect(1, 0, this.cursorw-2, this.cursorh, blendColors(this.color_txt, this.color_bg, 0.05));
- };
- this.cursorImage_down.ReleaseGraphics(gb);
- // create/refresh cursor Button in buttons array
- this.buttons[this.buttonType.cursor] = new button(this.cursorImage_normal, this.cursorImage_hover, this.cursorImage_down);
- this.buttons[this.buttonType.cursor].x = this.x;
- this.buttons[this.buttonType.cursor].y = this.cursory;
- };
- this.draw = function(gr) {
- // scrollbar background
- if(this.themed) {
- try {
- this.theme.SetPartAndStateId(6, 1);
- this.theme.DrawThemeBackground(gr, this.x, this.y, this.w, this.h);
- }; catch(e) {
- gr.FillSolidRect(this.x, this.y, this.w, this.h, this.color_bg & 0x25ffffff);
- gr.FillSolidRect(this.x, this.y, 1, this.h, this.color_txt & 0x05ffffff);
- };
- }; else {
- gr.FillSolidRect(this.x, this.y, this.w, this.h, this.color_bg & 0x25ffffff);
- gr.FillSolidRect(this.x, this.y, 1, this.h, this.color_txt & 0x05ffffff);
- };
- // scrollbar buttons
- if(cScrollBar.visible) this.buttons[this.buttonType.cursor].draw(gr, this.x, this.cursory, 200);
- if(this.showButtons) {
- this.buttons[this.buttonType.up].draw(gr, this.x, this.y, 200);
- this.buttons[this.buttonType.down].draw(gr, this.x, this.areay + this.areah, 200);
- };
- };
- this.updateScrollbar = function() {
- var prev_cursorh = this.cursorh;
- this.total = brw.rowsCount;
- this.rowh = ppt.rowHeight;
- this.totalh = this.total * this.rowh;
- // set scrollbar visibility
- cScrollBar.visible = (this.totalh > brw.h);
- // set cursor width/height
- this.cursorw = this.w;
- if(this.total > 0) {
- this.cursorh = Math.round((brw.h / this.totalh) * this.areah);
- if(this.cursorh < cScrollBar.minCursorHeight) this.cursorh = cScrollBar.minCursorHeight;
- }; else {
- this.cursorh = cScrollBar.minCursorHeight;
- };
- // set cursor y pos
- this.setCursorY();
- if(this.cursorh != prev_cursorh) this.setCursorButton();
- };
- this.setCursorY = function() {
- // set cursor y pos
- var ratio = scroll / (this.totalh - brw.h);
- this.cursory = this.areay + Math.round((this.areah - this.cursorh) * ratio);
- };
- this.setSize = function() {
- this.buttonh = cScrollBar.width;
- this.x = brw.x + brw.w;
- this.y = brw.y - ppt.headerBarHeight*0;
- this.w = cScrollBar.width;
- this.h = brw.h + ppt.headerBarHeight*0;
- if(this.showButtons) {
- this.areay = this.y + this.buttonh;
- this.areah = this.h - (this.buttonh * 2);
- }; else {
- this.areay = this.y;
- this.areah = this.h;
- };
- this.setButtons();
- };
- this.setScrollFromCursorPos = function() {
- // calc ratio of the scroll cursor to calc the equivalent item for the full list (with gh)
- var ratio = (this.cursory - this.areay) / (this.areah - this.cursorh);
- // calc idx of the item (of the full list with gh) to display at top of the panel list (visible)
- scroll = Math.round((this.totalh - brw.h) * ratio);
- };
- this.cursorCheck = function(event, x, y) {
- if(!this.buttons[this.buttonType.cursor]) return;
- switch(event) {
- case "down":
- var tmp = this.buttons[this.buttonType.cursor].checkstate(event, x, y);
- if(tmp == ButtonStates.down) {
- this.cursorClickX = x;
- this.cursorClickY = y;
- this.cursorDrag = true;
- this.cursorDragDelta = y - this.cursory;
- };
- break;
- case "up":
- this.buttons[this.buttonType.cursor].checkstate(event, x, y);
- if(this.cursorDrag) {
- this.setScrollFromCursorPos();
- brw.repaint();
- };
- this.cursorClickX = 0;
- this.cursorClickY = 0;
- this.cursorDrag = false;
- break;
- case "move":
- this.buttons[this.buttonType.cursor].checkstate(event, x, y);
- if(this.cursorDrag) {
- this.cursory = y - this.cursorDragDelta;
- if(this.cursory + this.cursorh > this.areay + this.areah) {
- this.cursory = (this.areay + this.areah) - this.cursorh;
- };
- if(this.cursory < this.areay) {
- this.cursory = this.areay;
- };
- this.setScrollFromCursorPos();
- brw.repaint();
- };
- break;
- case "leave":
- this.buttons[this.buttonType.cursor].checkstate(event, 0, 0);
- break;
- };
- };
- this._isHover = function(x, y) {
- return (x >= this.x && x <= this.x + this.w && y >= this.y && y <= this.y + this.h);
- };
- this._isHoverArea = function(x, y) {
- return (x >= this.x && x <= this.x + this.w && y >= this.areay && y <= this.areay + this.areah);
- };
- this._isHoverCursor = function(x, y) {
- return (x >= this.x && x <= this.x + this.w && y >= this.cursory && y <= this.cursory + this.cursorh);
- };
- this.on_mouse = function(event, x, y, delta) {
- this.isHover = this._isHover(x, y);
- this.isHoverArea = this._isHoverArea(x, y);
- this.isHoverCursor = this._isHoverCursor(x, y);
- this.isHoverButtons = this.isHover && !this.isHoverCursor && !this.isHoverArea;
- this.isHoverEmptyArea = this.isHoverArea && !this.isHoverCursor;
- var scroll_step = ppt.rowHeight;
- var scroll_step_page = brw.h;
- switch(event) {
- case "down":
- case "dblclk":
- if((this.isHoverCursor || this.cursorDrag) && !this.buttonClick && !this.isHoverEmptyArea) {
- this.cursorCheck(event, x, y);
- }; else {
- // buttons events
- var bt_state = ButtonStates.normal;
- for(var i = 1; i < 3; i++) {
- switch(i) {
- case 1: // up button
- bt_state = this.buttons[i].checkstate(event, x, y);
- if((event == "down" && bt_state == ButtonStates.down) || (event == "dblclk" && bt_state == ButtonStates.hover)) {
- this.buttonClick = true;
- scroll = scroll - scroll_step;
- scroll = check_scroll(scroll);
- if(!cScrollBar.timerID) {
- cScrollBar.timerID = window.SetInterval(function() {
- if(cScrollBar.timerCounter > 6) {
- scroll = scroll - scroll_step;
- scroll = check_scroll(scroll);
- }; else {
- cScrollBar.timerCounter++;
- };
- }, 80);
- };
- };
- break;
- case 2: // down button
- bt_state = this.buttons[i].checkstate(event, x, y);
- if((event == "down" && bt_state == ButtonStates.down) || (event == "dblclk" && bt_state == ButtonStates.hover)) {
- this.buttonClick = true;
- scroll = scroll + scroll_step;
- scroll = check_scroll(scroll);
- if(!cScrollBar.timerID) {
- cScrollBar.timerID = window.SetInterval(function() {
- if(cScrollBar.timerCounter > 6) {
- scroll = scroll + scroll_step;
- scroll = check_scroll(scroll);
- }; else {
- cScrollBar.timerCounter++;
- };
- }, 80);
- };
- };
- break;
- };
- };
- if(!this.buttonClick && this.isHoverEmptyArea) {
- // check click on empty area scrollbar
- if(y < this.cursory) {
- // up
- this.buttonClick = true;
- scroll = scroll - scroll_step_page;
- scroll = check_scroll(scroll);
- if(!cScrollBar.timerID) {
- cScrollBar.timerID = window.SetInterval(function() {
- if(cScrollBar.timerCounter > 6 && m_y < brw.scrollbar.cursory) {
- scroll = scroll - scroll_step_page;
- scroll = check_scroll(scroll);
- }; else {
- cScrollBar.timerCounter++;
- };
- }, 80);
- };
- }; else {
- // down
- this.buttonClick = true;
- scroll = scroll + scroll_step_page;
- scroll = check_scroll(scroll);
- if(!cScrollBar.timerID) {
- cScrollBar.timerID = window.SetInterval(function() {
- if(cScrollBar.timerCounter > 6 && m_y > brw.scrollbar.cursory + brw.scrollbar.cursorh) {
- scroll = scroll + scroll_step_page;
- scroll = check_scroll(scroll);
- }; else {
- cScrollBar.timerCounter++;
- };
- }, 80);
- };
- };
- };
- };
- break;
- case "right":
- case "up":
- if(cScrollBar.timerID) {
- window.ClearInterval(cScrollBar.timerID);
- cScrollBar.timerID = false;
- };
- cScrollBar.timerCounter = -1;
- this.cursorCheck(event, x, y);
- for(var i = 1; i < 3; i++) {
- this.buttons[i].checkstate(event, x, y);
- };
- this.buttonClick = false;
- break;
- case "move":
- this.cursorCheck(event, x, y);
- for(var i = 1; i < 3; i++) {
- this.buttons[i].checkstate(event, x, y);
- };
- break;
- case "wheel":
- if(!this.buttonClick) {
- this.updateScrollbar();
- };
- break;
- case "leave":
- this.cursorCheck(event, 0, 0);
- for(var i = 1; i < 3; i++) {
- this.buttons[i].checkstate(event, 0, 0);
- };
- break;
- };
- };
- };
- oGroup = function(index, start, handle, groupkey) {
- this.index = index;
- this.start = start;
- this.count = 1;
- this.metadb = handle;
- this.groupkey = groupkey;
- if(handle) {
- switch(ppt.tagMode) {
- case 1:
- this.cachekey = process_cachekey(ppt.tf_crc.EvalWithMetadb(handle));
- break;
- case 2:
- this.cachekey = process_cachekey(ppt.tf_crc_artist.EvalWithMetadb(handle));
- break;
- case 3:
- this.cachekey = process_cachekey(ppt.tf_crc_genre.EvalWithMetadb(handle));
- break;
- }
- this.tracktype = TrackType(handle.rawpath.substring(0, 4));
- }; else {
- this.cachekey = null;
- this.tracktype = 0;
- };
- //
- this.cover_img = null;
- this.load_requested = 0;
- this.save_requested = false;
- this.finalize = function(count, tracks, handles) {
- this.tra = tracks.slice(0);
- this.pl = handles.Clone();
- this.count = count;
- };
- //this.totalPreviousRows = 0
- };
- oBrowser = function(name) {
- this.name = name;
- this.groups = [];
- this.rows = [];
- this.SHIFT_start_id = null;
- this.SHIFT_count = 0;
- this.scrollbar = new oScrollbar(themed = cScrollBar.themed);
- this.keypressed = false;
- this.metadblist_selection = plman.GetPlaylistSelectedItems(g_active_playlist);
- var launch_timer = window.SetTimeout(function(){
- brw.populate(is_first_populate = true);
- launch_timer && window.ClearTimeout(launch_timer);
- launch_timer = false;
- }, 25);
- this.repaint = function() {
- repaint_main1 = repaint_main2;
- };
- this.cover_repaint = function() {
- repaint_cover1 = repaint_cover2;
- };
- this.update = function() {
- switch(ppt.panelMode) {
- case 1:
- case 3:
- // *** STAMP MODES ***
- this.stampDrawMode = (ppt.panelMode == 1 ? true : false);
- this.thumb_w = ppt.thumbnailWidthMin;
- this.marginLR = 0;
- // set margins betweens album stamps
- if(ppt.panelMode == 1) {
- this.marginTop = 2;
- this.marginBot = 2;
- this.marginSide = 2;
- this.marginCover = 12;
- }; else {
- this.marginTop = 0;
- this.marginBot = 0;
- this.marginSide = 0;
- this.marginCover = 1;
- };
- // Adjust Column
- this.totalColumns = Math.floor((this.w - this.marginLR * 2) / this.thumb_w);
- // count total of rows for the whole library
- this.rowsCount = Math.ceil(this.groups.length / this.totalColumns);
- var gapeWidth = (this.w - this.marginLR * 2) - (this.totalColumns * this.thumb_w);
- var deltaToAdd = Math.floor(gapeWidth / this.totalColumns);
- this.thumbnailWidth = this.thumb_w + deltaToAdd;
- // calc size of the cover art
- cover.max_w = (this.thumbnailWidth - (this.marginSide * 2) - (this.marginCover * 2));
- // Adjust Row & showList bloc Height
- if(ppt.panelMode == 1) {
- this.rowHeight = 10 + cover.max_w + 45;
- }; else {
- this.rowHeight = cover.max_w + 1;
- };
- break;
- case 0:
- case 2:
- // *** LINE MODES ***
- this.stampDrawMode = true;
- this.thumb_w = this.w;
- this.marginLR = 0;
- // set margins betweens album stamps
- this.marginTop = (ppt.panelMode > 0 ? 1 : 0);
- this.marginBot = (ppt.panelMode > 0 ? 2 : 0);
- this.marginSide = (ppt.panelMode > 0 ? 1 : 0);
- this.marginCover = (ppt.panelMode > 0 ? 7 : 2);
- // Adjust Column
- this.totalColumns = 1;
- // count total of rows for the whole library
- this.rowsCount = Math.ceil(this.groups.length / this.totalColumns);
- var gapeWidth = (this.w - this.marginLR * 2) - (this.totalColumns * this.thumb_w);
- var deltaToAdd = Math.floor(gapeWidth / this.totalColumns);
- this.thumbnailWidth = this.thumb_w + deltaToAdd;
- // calc size of the cover art
- cover.max_w = (ppt.lineHeightMin - (this.marginCover * 2));
- // Adjust Row & showList bloc Height
- this.rowHeight = ppt.lineHeightMin;
- break;
- };
- this.totalRows = Math.ceil(this.h / this.rowHeight);
- this.totalRowsVis = Math.floor(this.h / this.rowHeight);
- ppt.rowHeight = this.rowHeight;
- //
- scroll = Math.round(scroll / this.rowHeight) * this.rowHeight;
- scroll = check_scroll(scroll);
- //scroll_ = scroll + (this.rowHeight / ppt.scrollRowDivider);
- scroll_ = scroll;
- // scrollbar update
- this.scrollbar.updateScrollbar();
- // update images (scaled ones)
- get_images();
- this.repaint();
- };
- this.setSize = function(x, y, w, h) {
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.scrollbar.setSize();
- scroll = Math.round(scroll / ppt.rowHeight) * ppt.rowHeight;
- scroll = check_scroll(scroll);
- scroll_ = scroll;
- // scrollbar update
- this.scrollbar.updateScrollbar();
- this.update();
- };
- this.setList = function() {
- var end = this.groups.length;
- for(var i = 0; i < end; i++) {
- this.groups[i].load_requested = 0;
- };
- this.update();
- };
- this.init_groups = function() {
- var handle = null;
- var current = "";
- var previous = "";
- var g = 0, t = 0;
- var arr = [];
- var tr = [];
- var pl = plman.GetPlaylistItems(-1);
- var total = this.list.Count;
- var t_all = 0;
- if(ppt.showAllItem) {
- var tr_all = [];
- var pl_all = plman.GetPlaylistItems(-1);
- };
- var d1 = new Date();
- var t1 = d1.getSeconds()*1000 + d1.getMilliseconds();
- this.groups.splice(0, this.groups.length);
- switch(ppt.tagMode) {
- case 1: // album
- var tf = ppt.tf_groupkey_album;
- break;
- case 2: // artist
- var tf = ppt.tf_groupkey_artist;
- break;
- case 3: // genre
- var tf = ppt.tf_groupkey_genre;
- break;
- };
- var str_filter = process_string(filter_text);
- for(var i = 0; i < total; i++) {
- handle = this.list.Item(i);
- arr = tf.EvalWithMetadb(handle).split(" ## ");
- current = arr[0].toLowerCase();
- if(str_filter.length > 0) {
- var toAdd = match(arr[0]+" "+arr[1], str_filter);
- }; else {
- var toAdd = true;
- };
- if(toAdd) {
- if(current != previous) {
- if(g > 0) {
- // update current group
- this.groups[g-1].finalize(t, tr, pl);
- tr.splice(0, t);
- pl.RemoveAll();
- t = 0;
- };
- if(i < total) {
- // add new group
- tr.push(arr[1]);
- pl.Add(handle);
- if(ppt.showAllItem) {
- tr_all.push(arr[1]);
- pl_all.Add(handle);
- };
- t_all++;
- t++;
- this.groups.push(new oGroup(g+1, i, handle, arr[0]));
- g++;
- previous = current;
- };
- }; else {
- // add track to current group
- tr.push(arr[1]);
- pl.Add(handle);
- if(ppt.showAllItem) {
- tr_all.push(arr[1]);
- pl_all.Add(handle);
- };
- t_all++;
- t++;
- };
- };
- };
- if(g > 0) {
- // update last group properties
- this.groups[g-1].finalize(t, tr, pl);
- // add 1st group ("ALL" item)
- if(ppt.showAllItem && g > 1) {
- this.groups.unshift(new oGroup(0, 0, null, null));
- this.groups[0].finalize(t_all, tr_all, pl_all);
- };
- };
- var d2 = new Date();
- var t2 = d2.getSeconds()*1000 + d2.getMilliseconds();
- fb.trace("JSB POPULATE: init groups delay = "+Math.round(t2 - t1)+" /handleList count="+total);
- };
- this.populate = function(is_first_populate) {
- fb.trace("--> populate");
- if(this.list) this.list.Dispose();
- if(ppt.sourceMode == 0) {
- // populate library
- this.list = fb.GetLibraryItems();
- // define sort order
- switch(ppt.tagMode) {
- case 1: // album
- var TFsorting = ppt.albumsTFsorting;
- break;
- case 2: // artist
- var TFsorting = ppt.artistsTFsorting;
- break;
- case 3: // genre
- var TFsorting = ppt.genresTFsorting;
- break;
- };
- // sort the list
- if(TFsorting.length > 0) {
- fb.trace(".. TFsorting="+TFsorting);
- this.list.OrderByFormat(fb.TitleFormat(TFsorting), 1);
- };
- }; else {
- // populate current playlist
- this.list = plman.GetPlaylistItems(g_active_playlist);
- };
- this.init_groups();
- this.setList();
- this.scrollbar.updateScrollbar();
- this.repaint();
- g_first_populate_done = true;
- };
- this.activateItem = function(index) {
- if(this.groups.length == 0) return;
- this.selectedIndex = index;
- };
- this.sendItemToPlaylist = function(index) {
- if(this.groups.length == 0) return;
- // notify JSSmoothPlaylist panel to avoid "on_playlist_items_removed" until "on_playlist_items_added" was called (to avoid x2 call of populate function!)
- window.NotifyOthers("JSSmoothBRowser->JSSmoothPlaylist:avoid_on_playlist_items_removed_callbacks_on_sendItemToPlaylist", true);
- // parse stored tags
- if(ppt.showAllItem && index == 0 && this.groups.length > 1) {
- var arr = null;
- }; else {
- var arr = this.groups[index].groupkey.split(" ^^ ");
- };
- // ======================================
- // Send item tracks to JSBrowser playlist
- // ======================================
- // check if JSBrowser playlists are present
- var affectedItems = [];
- var pfound = false;
- var pfound_playing = false;
- var total = plman.PlaylistCount;
- var pidx = -1;
- var pidx_playing = -1;
- for(var i = 0; i < total; i++) {
- if(!pfound && plman.GetPlaylistName(i) == "Library selection") {
- pidx = i;
- pfound = true;
- };
- if(!pfound_playing && plman.GetPlaylistName(i) == "Library selection (playing)") {
- pidx_playing = i;
- pfound_playing = true;
- };
- if(pfound && pfound_playing) break;
- };
- if(utils.IsKeyPressed(VK_CONTROL)) {
- // initialize "Library selection" playlist
- if(pfound) {
- var from = plman.PlaylistItemCount(pidx);
- }; else {
- pidx = plman.PlaylistCount;
- plman.CreatePlaylist(pidx, "Library selection");
- var from = 0;
- };
- // *** insert tracks into pidx playlist
- plman.InsertPlaylistItems(pidx, from, brw.groups[index].pl, false);
- }; else {
- if(fb.IsPlaying) {
- if(plman.PlayingPlaylist == pidx) { // playing playlist is "Library selection"
- plman.RenamePlaylist(pidx, "Library selection (playing)");
- if(pfound_playing) {
- plman.RenamePlaylist(pidx_playing, "Library selection");
- // 1. initialize old "Library selection (playing)" playlist
- var tot = plman.PlaylistItemCount(pidx_playing);
- affectedItems.splice(0, affectedItems.length);
- for(var i = 0; i < tot; i++) {
- affectedItems.push(i);
- };
- plman.SetPlaylistSelection(pidx_playing, affectedItems, true);
- plman.RemovePlaylistSelection(pidx_playing, false);
- }; else {
- pidx_playing = plman.PlaylistCount;
- plman.CreatePlaylist(pidx_playing, "Library selection");
- };
- // *** insert tracks into pidx_playing playlist
- plman.InsertPlaylistItems(pidx_playing, 0, brw.groups[index].pl, false);
- plman.MovePlaylist(pidx_playing, pidx);
- plman.MovePlaylist(pidx + 1, pidx_playing);
- }; else {
- // initialize true "Library selection" playlist
- if(pfound) {
- // clear "Library selection" playlist content
- var tot = plman.PlaylistItemCount(pidx);
- for(var i = 0; i < tot; i++) {
- affectedItems.push(i);
- };
- plman.SetPlaylistSelection(pidx, affectedItems, true);
- plman.RemovePlaylistSelection(pidx, false);
- }; else {
- // create "Library selection" playlist
- pidx = plman.PlaylistCount;
- plman.CreatePlaylist(pidx, "Library selection");
- };
- // *** insert tracks into pidx playlist
- plman.InsertPlaylistItems(pidx, 0, brw.groups[index].pl, false);
- };
- }; else {
- // initialize "Library selection" playlist
- if(pfound) {
- // clear "Library selection" playlist content
- var tot = plman.PlaylistItemCount(pidx);
- for(var i = 0; i < tot; i++) {
- affectedItems.push(i);
- };
- plman.SetPlaylistSelection(pidx, affectedItems, true);
- plman.RemovePlaylistSelection(pidx, false);
- }; else {
- // create "Library selection" playlist
- pidx = plman.PlaylistCount;
- plman.CreatePlaylist(pidx, "Library selection");
- };
- // *** insert tracks into pidx playlist
- plman.InsertPlaylistItems(pidx, 0, brw.groups[index].pl, false);
- };
- plman.ActivePlaylist = pidx;
- };
- };
- this.getlimits = function() {
- // get visible stamps limits (start & end indexes)
- if(this.groups.length <= this.totalRowsVis * this.totalColumns) {
- var start_ = 0;
- var end_ = this.groups.length;
- }; else {
- var start_ = Math.round(scroll_/this.rowHeight) * this.totalColumns;
- var end_ = Math.round((scroll_ + wh + this.rowHeight) / this.rowHeight) * this.totalColumns;
- // check values / limits
- end_ = (this.groups.length < end_) ? this.groups.length : end_;
- start_ = start_ > 0 ? start_ - this.totalColumns : (start_ < 0 ? 0 : start_);
- };
- // save limits calculated into globals var
- g_start_ = start_;
- g_end_ = end_;
- };
- this.draw = function(gr) {
- var tmp, offset;
- var cx = 0;
- var ax, ay, by, rowStart, row, coverTop;
- var aw = this.thumbnailWidth - (this.marginSide * 2);
- var ah = this.rowHeight - this.marginTop - this.marginBot;
- if(ppt.panelMode > 0) {
- var coverWidth = cover.max_w;
- }; else {
- var coverWidth = 0;
- };
- var txt_color1, txt_color2, selbg_color;
- var total = this.groups.length;
- var all_x = -1, all_y = -1, all_w = 0, all_h = 0;
- this.getlimits();
- if(repaint_main || !repaintforced){
- repaint_main = false;
- repaintforced = false;
- // draw visible stamps (loop)
- for(var i = g_start_; i < g_end_; i++) {
- row = Math.floor(i / this.totalColumns);
- ax = this.x + (cx * this.thumbnailWidth) + this.marginSide + this.marginLR;
- ay = Math.floor(this.y + (row * this.rowHeight) + this.marginTop - scroll_);
- this.groups[i].x = ax;
- this.groups[i].y = ay;
- if(ay >= (0 - this.rowHeight) && ay < this.y + this.h) { // if stamp visible, we have to draw it
- // parse stored tags
- if(!(ppt.showAllItem && i == 0 && total > 1)) {
- if(this.groups[i].groupkey.length > 0) {
- var arr = this.groups[i].groupkey.split(" ^^ ");
- };
- };
- if(ppt.panelMode > 0) {
- // get cover
- if(ppt.showAllItem && i == 0 && total > 1) {
- this.groups[i].cover_img = images.all;
- }; else {
- this.groups[i].cover_img = g_image_cache.hit(this.groups[i].metadb, i);
- };
- };
- if(this.stampDrawMode) {
- // BG under cover
- if(ppt.panelMode == 0) {
- if(Math.floor(i/2) != Math.ceil(i/2)) {
- gr.FillSolidRect(ax, ay, aw, ah, g_color_normal_txt & 0x05ffffff);
- };
- }; else {
- gr.FillSolidRect(ax, ay, aw, ah, g_color_normal_txt & 0x10ffffff);
- gr.DrawRect(ax, ay, aw-1, ah-1, 1.0, g_color_normal_txt & 0x10ffffff);
- };
- // background selection
- if(i == this.selectedIndex) {
- txt_color1 = g_color_normal_bg;
- txt_color2 = blendColors(g_color_normal_bg, g_color_selected_bg, 0.25);
- selbg_color = g_color_selected_bg & 0xb0ffffff;
- gr.FillSolidRect(ax, ay, aw, ah, selbg_color);
- }; else {
- txt_color1 = g_color_normal_txt;
- txt_color2 = blendColors(g_color_normal_txt, g_color_normal_bg, 0.25);
- };
- }; else { // panelMode = 3 (Grid)
- // background selection
- if(i == this.selectedIndex) {
- txt_color1 = g_color_normal_bg;
- txt_color2 = blendColors(g_color_normal_bg, g_color_selected_bg, 0.25);
- selbg_color = g_color_selected_bg & 0xb0ffffff;
- }; else {
- txt_color1 = RGBA(240,240,240);
- txt_color2 = RGBA(220,220,220);
- selbg_color = RGBA(0,0,0,190);
- };
- };
- switch(ppt.panelMode) {
- case 1:
- case 3:
- coverTop = ppt.panelMode == 1 ? ay + 10 : ay;
- // draw cover
- if(this.groups[i].cover_img) {
- if(cover.keepaspectratio) {
- var max = this.groups[i].cover_img.Width > this.groups[i].cover_img.Height ? this.groups[i].cover_img.Width: this.groups[i].cover_img.Height;
- var rw = this.groups[i].cover_img.Width / max;
- var rh = this.groups[i].cover_img.Height / max;
- var im_w = (rw * coverWidth)-2;
- var im_h = (rh * coverWidth)-2;
- }; else {
- var im_w = coverWidth;
- var im_h = coverWidth;
- };
- // save coords ALL cover image:
- if(ppt.showAllItem && i == 0 && total > 1) {
- all_x = ax + Math.round((aw - im_w) / 2);
- all_y = coverTop + coverWidth - im_h;
- all_w = im_w;
- all_h = im_h;
- gr.DrawImage(this.groups[i].cover_img, ax + Math.round((aw - im_w) / 2), coverTop + coverWidth - im_h, im_w, im_h, 1, 1, this.groups[i].cover_img.Width-2, this.groups[i].cover_img.Height-2, 0, 190);
- }; else {
- gr.DrawImage(this.groups[i].cover_img, ax + Math.round((aw - im_w) / 2), coverTop + coverWidth - im_h, im_w, im_h, 1, 1, this.groups[i].cover_img.Width-2, this.groups[i].cover_img.Height-2);
- gr.DrawRect(ax + Math.round((aw - im_w) / 2), coverTop + coverWidth - im_h, im_w - 1, im_h - 1, 1.0, RGB(40,40,40));
- // grid text background rect
- if(ppt.panelMode == 3) {
- if(i == this.selectedIndex) {
- gr.FillSolidRect(ax + 2, coverTop + coverWidth - 42, aw - 4, 42, RGBA(150,150,150,150));
- };
- gr.FillSolidRect(ax + 2, coverTop + coverWidth - 42, aw - 4, 42, selbg_color);
- gr.FillSolidRect(ax + 2, coverTop + coverWidth - 42, aw - 4, 1, selbg_color);
- };
- };
- }; else {
- var im_w = coverWidth;
- var im_h = coverWidth;
- gr.DrawImage(images.loading_draw, ax + Math.round((aw - images.loading_draw.Width) / 2), ay + Math.round((aw - images.loading_draw.Height) / 2), images.loading_draw.Width, images.loading_draw.Height, 0, 0, images.loading_draw.Width, images.loading_draw.Height, images.loading_angle, 160);
- };
- // in Grid mode (panelMode = 3), if cover is in portrait mode, adjust width to the stamp width
- if(ppt.panelMode == 3 && im_h > im_w) {
- var frame_w = coverWidth;
- var frame_h = im_h;
- }; else {
- var frame_w = im_w;
- var frame_h = im_h;
- };
- if(g_rightClickedIndex > -1) {
- if(g_rightClickedIndex == i) {
- if(this.stampDrawMode) {
- gr.DrawRect(ax+1, ay+1, aw-2, ah-2, 2.0, g_color_normal_txt & 0x80ffffff);
- }; else {
- gr.setSmoothingMode(2);
- gr.DrawRect(ax + Math.round((aw - frame_w) / 2) + 2, coverTop + coverWidth - frame_h + 2, frame_w - 4, frame_h - 4, 3.0, RGBA(0,0,0,200));
- gr.setSmoothingMode(0);
- gr.DrawRect(ax + Math.round((aw - frame_w) / 2) + 1, coverTop + coverWidth - frame_h + 1, frame_w - 2, frame_h - 2, 3.0, g_color_normal_txt & 0xddffffff);
- };
- };
- }; else {
- if(i == this.activeIndex) {
- if(this.stampDrawMode) {
- gr.DrawRect(ax+1, ay+1, aw-2, ah-2, 2.0, g_color_normal_txt & 0x80ffffff);
- }; else {
- gr.setSmoothingMode(2);
- gr.DrawRect(ax + Math.round((aw - frame_w) / 2) + 2, coverTop + coverWidth - frame_h + 2, frame_w - 4, frame_h - 4, 3.0, RGBA(0,0,0,200));
- gr.setSmoothingMode(0);
- gr.DrawRect(ax + Math.round((aw - frame_w) / 2) + 1, coverTop + coverWidth - frame_h + 1, frame_w - 2, frame_h - 2, 3.0, g_color_normal_txt & 0xddffffff);
- };
- };
- };
- if(ppt.panelMode == 1) {
- // draw text
- if(ppt.showAllItem && i == 0 && total > 1) { // aggregate item ( [ALL] )
- try{
- gr.gdiDrawText("[All items]", gdi.Font("arial", 13, 1), txt_color1, ax + Math.round((aw - coverWidth) / 2), (coverTop + 5 + coverWidth), coverWidth, 16, DT_LEFT | DT_TOP | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- gr.gdiDrawText("("+(total-1)+" albums)", gdi.Font("arial", 12, 0), txt_color2, ax + Math.round((aw - coverWidth) / 2), (coverTop + 5 + coverWidth + 16), coverWidth, 16, DT_LEFT | DT_TOP | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- } catch(e) {}
- }; else {
- if(arr[1] == "?") {
- if(this.groups[i].count > 1) {
- var album_name = "(Singles)"
- }; else {
- var arr_t = this.groups[i].tra[0].split(" ^^ ");
- var album_name = "(Single) " + arr_t[2];
- };
- }; else {
- var album_name = arr[1];
- };
- try{
- gr.gdiDrawText(album_name, gdi.Font("arial", 13, 1), txt_color1, ax + Math.round((aw - coverWidth) / 2), (coverTop + 5 + coverWidth), coverWidth, 16, DT_LEFT | DT_TOP | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- gr.gdiDrawText(arr[0], gdi.Font("arial", 12, 0), txt_color2, ax + Math.round((aw - coverWidth) / 2), (coverTop + 5 + coverWidth + 16), coverWidth, 16, DT_LEFT | DT_TOP | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- } catch(e) {}
- };
- }; else if(this.groups[i].cover_img) { // panelMode = 3 (Grid)
- // draw text
- if(ppt.showAllItem && i == 0 && total > 1) { // aggregate item ( [ALL] )
- // nothing
- }; else {
- if(arr[1] == "?") {
- if(this.groups[i].count > 1) {
- var album_name = "(Singles)"
- }; else {
- var arr_t = this.groups[i].tra[0].split(" ^^ ");
- var album_name = "(Single) " + arr_t[2];
- };
- }; else {
- var album_name = arr[1];
- };
- try{
- gr.gdiDrawText(album_name, gdi.Font("arial", 13, 1), txt_color1, ax+10, (coverTop + 5 + coverWidth) - 42, aw-20, 16, DT_LEFT | DT_TOP | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- gr.gdiDrawText(arr[0], gdi.Font("arial", 12, 0), txt_color2, ax+10, (coverTop + 5 + coverWidth + 16) - 42, aw-20, 16, DT_LEFT | DT_TOP | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- } catch(e) {}
- };
- };
- break;
- case 0:
- case 2:
- coverTop = ay;
- if(ppt.panelMode > 0) {
- // draw cover
- this.coverMarginLeft = this.marginCover;
- if(this.groups[i].cover_img) {
- if(cover.keepaspectratio) {
- var max = this.groups[i].cover_img.Width > this.groups[i].cover_img.Height ? this.groups[i].cover_img.Width: this.groups[i].cover_img.Height;
- var rw = this.groups[i].cover_img.Width / max;
- var rh = this.groups[i].cover_img.Height / max;
- var im_w = (rw * coverWidth)-2;
- var im_h = (rh * coverWidth)-2;
- }; else {
- var im_w = coverWidth;
- var im_h = coverWidth;
- };
- var deltaY = Math.floor((ah - im_h)/2);
- var deltaX = Math.floor((coverWidth - im_w)/2);
- // save coords ALL cover image:
- if(ppt.showAllItem && i == 0 && total > 1) {
- all_x = ax + this.coverMarginLeft+deltaX;
- all_y = coverTop + deltaY;
- all_w = im_w;
- all_h = im_h;
- gr.DrawImage(this.groups[i].cover_img, ax+this.coverMarginLeft+deltaX, coverTop + deltaY, im_w, im_h, 1, 1, this.groups[i].cover_img.Width-2, this.groups[i].cover_img.Height-2, 0, 190);
- }; else {
- gr.DrawImage(this.groups[i].cover_img, ax+this.coverMarginLeft+deltaX, coverTop + deltaY, im_w, im_h, 1, 1, this.groups[i].cover_img.Width-2, this.groups[i].cover_img.Height-2);
- gr.DrawRect(ax+this.coverMarginLeft+deltaX, coverTop + deltaY, im_w - 1, im_h - 1, 1.0, RGB(40,40,40));
- };
- }; else {
- var im_w = coverWidth;
- var im_h = coverWidth;
- var deltaY = Math.floor((ah - im_h)/2);
- var deltaX = Math.floor((coverWidth - im_w)/2);
- gr.DrawImage(images.loading_draw, ax+this.coverMarginLeft+deltaX, coverTop + deltaY, coverWidth, coverWidth, 0, 0, images.loading_draw.Width, images.loading_draw.Height, images.loading_angle, 160);
- };
- };
- if(g_rightClickedIndex > -1) {
- if(g_rightClickedIndex == i) {
- gr.DrawRect(ax+1, ay+1, aw-2, ah-2, 2.0, g_color_normal_txt & 0x80ffffff);
- };
- }; else {
- if(i == this.activeIndex) {
- gr.DrawRect(ax+1, ay+1, aw-2, ah-2, 2.0, g_color_normal_txt & 0x80ffffff);
- };
- };
- if(ppt.panelMode < 3) {
- // draw text
- if(ppt.showAllItem && i==0 && total > 1) { // [ALL] item
- switch(ppt.tagMode) {
- case 1: // album
- try{
- gr.gdiDrawText("[All items]", gdi.Font("arial", 13, 1), txt_color1, ax + coverWidth + this.marginCover*2, ay - 10, aw - coverWidth - this.marginCover*3, ah, DT_LEFT | DT_VCENTER | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- gr.gdiDrawText("("+(total-1)+" albums)", gdi.Font("arial", 12, 0), txt_color2, ax + coverWidth + this.marginCover*2, ay + 10, aw - coverWidth - this.marginCover*3, ah, DT_LEFT | DT_VCENTER | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- } catch(e) {}
- break;
- case 2: // artist
- try{
- gr.gdiDrawText("[All items] ("+(total-1)+" artists)", gdi.Font("arial", 13, (i == this.selectedIndex ? 1 : 0)), txt_color1, ax + coverWidth + this.marginCover*2, ay, aw - coverWidth - this.marginCover*3, ah, DT_LEFT | DT_VCENTER | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- } catch(e) {}
- break;
- case 3: // genre
- try{
- gr.gdiDrawText("[All items] ("+(total-1)+" genres)", gdi.Font("arial", 13, (i == this.selectedIndex ? 1 : 0)), txt_color1, ax + coverWidth + this.marginCover*2, ay, aw - coverWidth - this.marginCover*3, ah, DT_LEFT | DT_VCENTER | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- } catch(e) {}
- break;
- };
- }; else {
- switch(ppt.tagMode) {
- case 1: // album
- if(arr[1] == "?") {
- if(this.groups[i].count > 1) {
- var album_name = "(Singles)"
- }; else {
- var arr_t = this.groups[i].tra[0].split(" ^^ ");
- var album_name = "(Single) " + arr_t[2];
- };
- }; else {
- var album_name = arr[1];
- };
- try{
- gr.gdiDrawText(album_name, gdi.Font("arial", 13, 1), txt_color1, ax + coverWidth + this.marginCover*2, ay - 10, aw - coverWidth - this.marginCover*3, ah, DT_LEFT | DT_VCENTER | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- gr.gdiDrawText(arr[0], gdi.Font("arial", 12, 0), txt_color2, ax + coverWidth + this.marginCover*2, ay + 10, aw - coverWidth - this.marginCover*3, ah, DT_LEFT | DT_VCENTER | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- } catch(e) {}
- break;
- case 2: // artist
- try{
- gr.gdiDrawText(arr[0], gdi.Font("arial", 13, (i == this.selectedIndex ? 1 : 0)), txt_color1, ax + coverWidth + this.marginCover*2, ay, aw - coverWidth - this.marginCover*3, ah, DT_LEFT | DT_VCENTER | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- } catch(e) {}
- break;
- case 3: // genre
- try{
- gr.gdiDrawText(arr[0], gdi.Font("arial", 13, (i == this.selectedIndex ? 1 : 0)), txt_color1, ax + coverWidth + this.marginCover*2, ay, aw - coverWidth - this.marginCover*3, ah, DT_LEFT | DT_VCENTER | DT_CALCRECT | DT_END_ELLIPSIS | DT_NOPREFIX);
- } catch(e) {}
- break;
- };
- };
- };
- break;
- };
- };
- // fill ALL cover image with the 1st four cover art found
- if(ppt.panelMode > 0 && i == g_end_ - 1) {
- // get cover
- if(all_x > -1 && ppt.showAllItem && g_start_ == 0 && total > 1) {
- var ii_w = Math.floor(all_w / 2);
- var ii_h = Math.floor(all_h / 2);
- var ii_x1 = all_x;
- var ii_x2 = ii_x1 + ii_w;
- var ii_y1 = all_y;
- var ii_y2 = ii_y1 + ii_h;
- var lim = this.groups.length;
- if(lim > 5) lim = 5;
- for(var ii=1; ii < lim; ii++) {
- if(this.groups[ii].cover_img) {
- switch(ii) {
- case 1:
- gr.DrawImage(this.groups[ii].cover_img, ii_x1, ii_y1, ii_w, ii_h, 1, 1, this.groups[ii].cover_img.Width-2, this.groups[ii].cover_img.Height-2);
- break;
- case 2:
- gr.DrawImage(this.groups[ii].cover_img, ii_x2, ii_y1, ii_w, ii_h, 1, 1, this.groups[ii].cover_img.Width-2, this.groups[ii].cover_img.Height-2);
- break;
- case 3:
- gr.DrawImage(this.groups[ii].cover_img, ii_x1, ii_y2, ii_w, ii_h, 1, 1, this.groups[ii].cover_img.Width-2, this.groups[ii].cover_img.Height-2);
- break;
- case 4:
- gr.DrawImage(this.groups[ii].cover_img, ii_x2, ii_y2, ii_w, ii_h, 1, 1, this.groups[ii].cover_img.Width-2, this.groups[ii].cover_img.Height-2);
- break;
- };
- };
- };
- gr.DrawRect(ii_x1, ii_y1, all_w-1, all_h-1, 1.0, RGB(40,40,40));
- gr.DrawRect(ii_x1, ii_y1, all_w-1, Math.round(all_h/2)-1, 1.0, RGB(40,40,40));
- gr.DrawRect(ii_x1, ii_y1, Math.round(all_w/2)-1, all_h-1, 1.0, RGB(40,40,40));
- };
- };
- // set next column index
- if(cx == this.totalColumns - 1) {
- cx = 0;
- }; else {
- cx++;
- };
- };
- // draw scrollbar
- if(cScrollBar.enabled) {
- brw.scrollbar && brw.scrollbar.draw(gr);
- };
- // draw top header bar
- if(ppt.showHeaderBar) {
- var nb_groups = (ppt.showAllItem && total > 1 ? total - 1 : total);
- var boxText = " "+nb_groups+" item"+(nb_groups > 1 ? "s " : " ");
- gr.FillGradRect(this.x, 0, this.w + (cScrollBar.enabled ? cScrollBar.width : 0), ppt.headerBarHeight-1, 0, RGBA(20,20,20,255), RGBA(0,0,0,160), 1.0);
- gr.FillSolidRect(this.x, ppt.headerBarHeight-2, this.w + (cScrollBar.enabled ? cScrollBar.width : 0), 1, RGBA(0,0,0,130));
- gr.gdiDrawText(boxText, gdi.Font(g_fname, g_fsize-2, 1), RGB(255,255,255), this.x, 0, this.w + (cScrollBar.enabled ? cScrollBar.width : 0), ppt.headerBarHeight-1, DT_RIGHT | DT_VCENTER | DT_CALCRECT | DT_NOPREFIX | DT_END_ELLIPSIS);
- };
- };
- };
- this._isHover = function(x, y) {
- return (x >= this.x && x <= this.x + this.w && y >= this.y && y <= this.y + this.h);
- };
- this.on_mouse = function(event, x, y, delta) {
- this.ishover = this._isHover(x, y);
- // get active item index at x,y coords...
- this.activeIndex = -1;
- if(this.ishover) {
- this.activeRow = Math.ceil((y + scroll_ - this.y) / this.rowHeight) - 1;
- if(y > this.y && x > this.x && x < this.x + this.w) {
- this.activeColumn = Math.ceil((x - this.x - this.marginLR) / this.thumbnailWidth) - 1;
- this.activeIndex = (this.activeRow * this.totalColumns) + this.activeColumn;
- this.activeIndex = this.activeIndex > this.groups.length - 1 ? -1 : this.activeIndex;
- };
- };
- if(brw.activeIndex != brw.activeIndexSaved) {
- brw.activeIndexSaved = brw.activeIndex;
- this.repaint();
- };
- switch(event) {
- case "down":
- if(this.ishover) {
- if(this.activeIndex > -1) {
- this.activateItem(this.activeIndex);
- if(ppt.sourceMode == 0) {
- this.sendItemToPlaylist(this.activeIndex);
- }; else {
- g_dnd_status = true;
- //g_dnd_handles = this.groups[this.activeIndex].pl;
- };
- };
- this.repaint(); // avirer
- }; else {
- if(cScrollBar.enabled && cScrollBar.visible) {
- this.scrollbar && this.scrollbar.on_mouse(event, x, y);
- };
- };
- break;
- case "up":
- //if(g_dnd_status && g_dnd_handles != null) {
- // window.NotifyOthers("JSBrowser::dragndrop", g_dnd_handles);
- g_dnd_status = false;
- //};
- if(cScrollBar.enabled && cScrollBar.visible) {
- this.scrollbar && this.scrollbar.on_mouse(event, x, y);
- };
- break;
- case "dblclk":
- if(this.ishover) {
- if(brw.activeIndex > -1) {
- if(ppt.sourceMode == 0) {
- // play first track of the selection
- plman.ExecutePlaylistDefaultAction(plman.ActivePlaylist, 0);
- }; else {
- plman.SetPlaylistFocusItemByHandle(plman.ActivePlaylist, brw.groups[brw.activeIndex].pl.Item(0));
- fb.Play();
- };
- };
- }; else {
- if(cScrollBar.enabled && cScrollBar.visible) {
- this.scrollbar && this.scrollbar.on_mouse(event, x, y);
- };
- };
- break;
- case "right":
- g_rightClickedIndex = this.activeIndex;
- if(this.ishover && this.activeIndex > -1) {
- this.activateItem(this.activeIndex);
- if(ppt.sourceMode == 0) {
- this.sendItemToPlaylist(this.activeIndex);
- }; else {
- g_dnd_status = true;
- //g_dnd_handles = this.groups[this.activeIndex].pl;
- };
- this.item_context_menu(x, y, this.activeIndex);
- }; else {
- this.settings_context_menu(x, y);
- };
- g_rightClickedIndex = -1;
- if(!this.ishover) {
- if(cScrollBar.enabled && cScrollBar.visible) {
- this.scrollbar && this.scrollbar.on_mouse(event, x, y);
- };
- };
- break;
- case "move":
- if(cScrollBar.enabled && cScrollBar.visible) {
- this.scrollbar && this.scrollbar.on_mouse(event, x, y);
- };
- break;
- case "wheel":
- if(cScrollBar.enabled && cScrollBar.visible) {
- this.scrollbar.updateScrollbar();
- };
- break;
- case "leave":
- if(cScrollBar.enabled && cScrollBar.visible) {
- this.scrollbar && this.scrollbar.on_mouse(event, x, y);
- };
- break;
- };
- };
- if(this.g_timeCover) {
- window.ClearInterval(this.g_timeCover);
- this.g_timeCover = false;
- };
- this.g_timeCover = window.SetInterval(function() {
- if(!window.IsVisible) {
- window_visible = false;
- return;
- };
- var repaint_1 = false;
- if(repaint_cover1 == repaint_cover2){
- repaint_cover2 = !repaint_cover1;
- repaint_1 = true;
- };
- if(repaint_1){
- repaintforced = true;
- repaint_main = true;
- images.loading_angle = (images.loading_angle+30) % 360;
- window.Repaint();
- };
- }, ppt.refreshRateCover);
- if(this.g_time) {
- window.ClearInterval(this.g_time);
- this.g_time = false;
- };
- this.g_time = window.SetInterval(function() {
- if(!window.IsVisible) {
- window_visible = false;
- return;
- };
- var repaint_1 = false;
- if(!window_visible){
- window_visible = true;
- on_mouse_lbtn_down(3,3,0);
- on_mouse_lbtn_up(3,3,0);
- scroll_ += 1;
- };
- if(repaint_main1 == repaint_main2){
- repaint_main2 = !repaint_main1;
- repaint_1 = true;
- };
- scroll = check_scroll(scroll);
- if(scroll - scroll_ < -5.5 || scroll - scroll_ > 5.5){
- scroll_ += (scroll - scroll_) / ppt.scrollSmoothness;
- isScrolling = true;
- repaint_1 = true;
- if(scroll_prev != scroll) brw.scrollbar.updateScrollbar();
- }; else {
- if(scroll_ != scroll) {
- scroll_ = scroll; // force to scroll_ value to fixe the 5.5 stop value for expanding album action
- repaint_1 = true;
- };
- if(isScrolling) {
- isScrolling = false;
- repaint_1 = true;
- };
- };
- if(repaint_1){
- repaintforced = true;
- repaint_main = true;
- images.loading_angle = (images.loading_angle+30) % 360;
- window.Repaint();
- };
- scroll_prev = scroll;
- }, ppt.refreshRate);
- this.item_context_menu = function(x, y, albumIndex) {
- var _menu = window.CreatePopupMenu();
- var Context = fb.CreateContextMenuManager();
- var _child01 = window.CreatePopupMenu();
- var _child02 = window.CreatePopupMenu();
- var crc = this.groups[albumIndex].cachekey;
- this.metadblist_selection = this.groups[albumIndex].pl.Clone();
- Context.InitContext(this.metadblist_selection);
- _menu.AppendMenuItem(MF_STRING, 1, "Settings...");
- _menu.AppendMenuSeparator();
- Context.BuildMenu(_menu, 2, -1);
- _child01.AppendTo(_menu, MF_STRING, "Selection...");
- _child01.AppendMenuItem(MF_STRING, 1010, "Reset Image Cache");
- _child02.AppendTo(_child01, MF_STRING, "Send to...");
- _child02.AppendMenuItem(MF_STRING, 2000, "a New playlist...");
- var pl_count = plman.PlaylistCount;
- if(pl_count > 1) {
- _child02.AppendMenuItem(MF_SEPARATOR, 0, "");
- };
- for(var i=0; i < pl_count; i++) {
- if(i != this.playlist && !fb.IsAutoPlaylist(i)) {
- _child02.AppendMenuItem(MF_STRING, 2001 + i, plman.GetPlaylistName(i));
- };
- };
- var ret = _menu.TrackPopupMenu(x, y);
- if(ret > 1 && ret < 800) {
- Context.ExecuteByID(ret - 2);
- }; else if(ret<2) {
- switch (ret) {
- case 1:
- //window.ShowProperties();
- this.settings_context_menu(x, y);
- break;
- };
- }; else {
- switch (ret) {
- case 1010:
- if(fso.FileExists(fb.ProfilePath + "wsh_br3tt\\cache\\imgcache\\" + crc)) {
- try {
- fso.DeleteFile(fb.ProfilePath + "wsh_br3tt\\cache\\imgcache\\" + crc);
- }; catch(e) {
- fb.trace("WSH Panel Error: Image cache ["+crc+"] can't be deleted on disk, file in use, try later or reload panel.");
- };
- };
- this.groups[albumIndex].tid = -1;
- this.groups[albumIndex].load_requested = 0;
- this.groups[albumIndex].save_requested = false;
- g_image_cache.reset(crc);
- this.groups[albumIndex].cover_img = null;
- this.repaint();
- break;
- case 2000:
- fb.RunMainMenuCommand("File/New playlist");
- plman.InsertPlaylistItems(plman.PlaylistCount-1, 0, this.metadblist_selection, false);
- break;
- default:
- var insert_index = plman.PlaylistItemCount(ret-2001);
- plman.InsertPlaylistItems((ret-2001), insert_index, this.metadblist_selection, false);
- };
- };
- _child01.Dispose();
- _child02.Dispose();
- _menu.Dispose();
- g_rbtn_click = false;
- return true;
- };
- this.settings_context_menu = function(x, y) {
- var _menu = window.CreatePopupMenu();
- var _menu0 = window.CreatePopupMenu();
- var _menu1 = window.CreatePopupMenu();
- var _menu2 = window.CreatePopupMenu();
- var _menu3 = window.CreatePopupMenu();
- var idx;
- _menu0.AppendMenuItem(MF_STRING, 50, "Library");
- _menu0.AppendMenuItem(MF_STRING, 51, "Playlist");
- _menu0.CheckMenuRadioItem(50, 51, 50 + ppt.sourceMode);
- _menu0.AppendTo(_menu,MF_STRING, "Source");
- _menu.AppendMenuSeparator();
- _menu1.AppendMenuItem(MF_STRING, 111, "Album");
- _menu1.AppendMenuItem(MF_STRING, 112, "Artist");
- _menu1.AppendMenuItem(MF_STRING, 113, "Genre");
- _menu1.CheckMenuRadioItem(111, 113, 110 + ppt.tagMode);
- _menu1.AppendTo(_menu,MF_STRING, "Columns");
- _menu2.AppendMenuItem(MF_STRING, 900, "Column");
- _menu2.AppendMenuItem(MF_STRING, 901, "Album Art (bottom labels)");
- _menu2.AppendMenuItem(MF_STRING, 902, "Album Art (right labels)");
- _menu2.AppendMenuItem(MF_STRING, 903, "Album Art Grid");
- _menu2.CheckMenuRadioItem(900, 903, 900 + ppt.panelMode);
- _menu2.AppendMenuSeparator();
- _menu2.AppendMenuItem(MF_STRING, 910, "Header Bar");
- _menu2.CheckMenuItem(910, ppt.showHeaderBar);
- _menu2.AppendMenuItem(MF_STRING, 911, "Aggregate Item");
- _menu2.CheckMenuItem(911, ppt.showAllItem);
- _menu2.AppendTo(_menu,MF_STRING, "Display");
- _menu3.AppendMenuItem(MF_STRING, 200, "Show");
- _menu3.CheckMenuItem(200, ppt.showwallpaper);
- _menu3.AppendMenuItem(MF_STRING, 220, "Blur");
- _menu3.CheckMenuItem(220, ppt.wallpaperblurred);
- _menu3.AppendMenuSeparator();
- _menu3.AppendMenuItem(MF_STRING, 210, "Default");
- _menu3.AppendMenuItem(MF_STRING, 211, "Playing Album Cover");
- _menu3.CheckMenuRadioItem(210, 211, ppt.wallpapermode == 0 ? 211 : 210);
- _menu3.AppendTo(_menu,MF_STRING, "Background Wallpaper");
- //_menu.AppendMenuSeparator();
- //_menu.AppendMenuItem(MF_STRING, 990, "Reload Library");
- _menu.AppendMenuSeparator();
- _menu.AppendMenuItem(MF_STRING, 991, "Panel Properties");
- _menu.AppendMenuItem(MF_STRING, 992, "Configure...");
- idx = _menu.TrackPopupMenu(x,y);
- switch(true) {
- case (idx >= 50 && idx <= 51):
- ppt.sourceMode = idx - 50;
- window.SetProperty("_PROPERTY: Source Mode", ppt.sourceMode);
- window.Reload();
- break;
- case (idx >= 111 && idx <= 113):
- ppt.tagMode = idx - 110;
- window.SetProperty("_PROPERTY: Tag Mode", ppt.tagMode);
- switch(ppt.tagMode) {
- case 1:
- ppt.albumArtId = 0;
- if(idx = 111 && ppt.lineHeightMin < 44) {
- ppt.lineHeightMin = 44;
- window.SetProperty("SYSTEM Minimal Line Height", ppt.lineHeightMin);
- };
- break;
- case 2:
- ppt.albumArtId = 4;
- break;
- case 3:
- ppt.albumArtId = 5;
- break;
- };
- g_image_cache = new image_cache;
- CollectGarbage();
- brw.populate(true);
- brw.setList();
- break;
- case (idx == 200):
- ppt.showwallpaper = !ppt.showwallpaper;
- window.SetProperty("_DISPLAY: Show Wallpaper", ppt.showwallpaper);
- brw.repaint();
- break;
- case (idx == 210):
- ppt.wallpapermode = 99;
- window.SetProperty("_SYSTEM: Wallpaper Mode", ppt.wallpapermode);
- if(fb.IsPlaying) g_wallpaperImg = setWallpaperImg(ppt.wallpaperpath, fb.GetNowPlaying());
- brw.repaint();
- break;
- case (idx == 211):
- ppt.wallpapermode = 0;
- window.SetProperty("_SYSTEM: Wallpaper Mode", ppt.wallpapermode);
- if(fb.IsPlaying) g_wallpaperImg = setWallpaperImg(ppt.wallpaperpath, fb.GetNowPlaying());
- brw.repaint();
- break;
- case (idx == 220):
- ppt.wallpaperblurred = !ppt.wallpaperblurred;
- window.SetProperty("_DISPLAY: Wallpaper Blurred", ppt.wallpaperblurred);
- if(fb.IsPlaying) g_wallpaperImg = setWallpaperImg(ppt.wallpaperpath, fb.GetNowPlaying());
- brw.repaint();
- break;
- case (idx >= 900 && idx <= 903):
- ppt.panelMode = idx - 900;
- window.SetProperty("_PROPERTY: Display Mode", ppt.panelMode);
- g_image_cache = new image_cache;
- CollectGarbage();
- brw.setList();
- break;
- case (idx == 910):
- ppt.showHeaderBar = !ppt.showHeaderBar;
- window.SetProperty("_DISPLAY: Show Top Bar", ppt.showHeaderBar);
- get_metrics();
- break;
- case (idx == 911):
- ppt.showAllItem = !ppt.showAllItem;
- window.SetProperty("_PROPERTY: Show ALL item", ppt.showAllItem);
- brw.populate(false);
- break;
- case (idx == 990):
- brw.populate(true);
- break;
- case (idx == 991):
- window.ShowProperties();
- break;
- case (idx == 992):
- window.ShowConfigure();
- break;
- };
- _menu3.Dispose();
- _menu2.Dispose();
- _menu1.Dispose();
- _menu0.Dispose();
- _menu.Dispose();
- return true;
- };
- };
- /*
- ===================================================================================================
- Main
- ===================================================================================================
- */
- var g_seconds = 0;
- var g_time_remaining = null;
- var gtt = fb.CreateProfiler();
- var g_dnd_handles = null;
- var g_dnd_status = false;
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var Img = new ActiveXObject("WIA.ImageFile.1");
- var IP = new ActiveXObject("WIA.ImageProcess.1");
- IP.Filters.Add(IP.FilterInfos("Scale").FilterID); //ID = 1
- IP.Filters.Add(IP.FilterInfos("Crop").FilterID); //ID = 2
- IP.Filters.Add(IP.FilterInfos("Convert").FilterID); //ID = 3
- var WshShell = new ActiveXObject("WScript.Shell");
- var htmlfile = new ActiveXObject('htmlfile');
- var cover_path = new RegExp("(artwork)|(cover)|(scan)|(image)");
- var cover_img = "*front*.*-*cover*.*-*.*".split("-");
- var stub_image, cell_null;
- var brw = null;
- var g_1x1 = false;
- var g_last = 0;
- var isScrolling = false;
- var g_zoom_percent = 100;
- var g_filterbox = null;
- var filter_text = "";
- var g_instancetype = window.InstanceType;
- var g_counter_repaint = 0;
- // fonts
- var g_font = null;
- var g_font_headers = null;
- var g_font_group1 = null;
- var g_font_group2 = null;
- var g_font_rating = null;
- var g_font_mood = null;
- var g_font_guifx_found = utils.CheckFont("guifx v2 transports");
- var g_font_wingdings2_found = utils.CheckFont("wingdings 2");
- //
- var ww = 0, wh = 0;
- var g_metadb = null;
- var g_focus = false;
- var foo_playcount = utils.CheckComponent("foo_playcount", true);
- clipboard = {
- selection: null
- };
- // wallpaper infos
- var wpp_img_info = {orient: 0, cut: 0, cut_offset: 0, ratio: 0, x: 0, y: 0, w: 0, h: 0};
- var m_x = 0, m_y = 0;
- var g_active_playlist = null;
- var g_populate_opt = 1;
- // color vars
- var g_color_normal_bg = 0;
- var g_color_selected_bg = 0;
- var g_color_normal_txt = 0;
- var g_color_selected_txt = 0;
- var g_color_highlight = 0;
- var g_syscolor_window_bg = 0;
- var g_syscolor_highlight = 0;
- var g_syscolor_button_bg = 0;
- var g_syscolor_button_txt = 0;
- // boolean to avoid callbacks
- var g_avoid_on_playlists_changed = false;
- var g_avoid_on_item_focus_change = false;
- var g_avoid_on_playlist_items_added = false;
- var g_avoid_on_playlist_items_removed = false;
- var g_avoid_on_playlist_items_removed_callbacks_on_sendItemToPlaylist = false;
- var g_avoid_on_playlist_items_reordered = false;
- // mouse actions
- var g_lbtn_click = false;
- var g_rbtn_click = false;
- //
- var g_total_duration_text = "";
- var g_first_populate_done = false;
- var repaintforced = false;
- var launch_time = fb.CreateProfiler("launch_time");
- var form_text = "";
- var repaint_main = true, repaint_main1 = true, repaint_main2 = true;
- var repaint_cover = true, repaint_cover1 = true, repaint_cover2 = true;
- var window_visible = false;
- var scroll_ = 0, scroll = 0, scroll_prev = 0;
- var time222;
- var g_start_ = 0, g_end_ = 0;
- var g_last = 0;
- var g_wallpaperImg = null;
- var g_rightClickedIndex = -1;
- function on_init() {
- window.DlgCode = DLGC_WANTALLKEYS;
- get_font();
- get_colors();
- get_metrics();
- g_active_playlist = plman.ActivePlaylist;
- switch(ppt.tagMode) {
- case 1:
- ppt.albumArtId = 0;
- break;
- case 2:
- ppt.albumArtId = 4;
- break;
- case 3:
- ppt.albumArtId = 5;
- break;
- };
- brw = new oBrowser("brw");
- g_filterbox = new oFilterBox();
- g_filterbox.inputbox.visible = true;
- };
- on_init();
- // START
- function on_size() {
- window.DlgCode = DLGC_WANTALLKEYS;
- ww = window.Width;
- wh = window.Height;
- window.MinWidth = 200;
- window.MinHeight = 200;
- // set wallpaper
- if(fb.IsPlaying) {
- g_wallpaperImg = setWallpaperImg(ppt.wallpaperpath, fb.GetNowPlaying());
- }; else {
- //g_wallpaperImg = null;
- g_wallpaperImg = setWallpaperImg(ppt.wallpaperpath, fb.GetNowPlaying());
- };
- get_images();
- // set Size of browser
- if(cScrollBar.enabled) {
- brw.setSize(0, (ppt.showHeaderBar ? ppt.headerBarHeight : 0), ww - cScrollBar.width, wh - (ppt.showHeaderBar ? ppt.headerBarHeight : 0));
- }; else {
- brw.setSize(0, (ppt.showHeaderBar ? ppt.headerBarHeight : 0), ww, wh - (ppt.showHeaderBar ? ppt.headerBarHeight : 0));
- };
- };
- function on_paint(gr) {
- if(!ww) return;
- if(!g_1x1) {
- //gr.FillSolidRect(0, 0, ww, wh, RGBA(210,210,215,255));
- // draw background under playlist
- if(fb.IsPlaying && g_wallpaperImg && ppt.showwallpaper) {
- gr.GdiDrawBitmap(g_wallpaperImg, 0, 0, ww, wh, 0, 0, g_wallpaperImg.Width, g_wallpaperImg.Height);
- gr.FillSolidRect(0, 0, ww, wh, g_color_normal_bg & RGBA(255,255,255,ppt.wallpaperalpha));
- }; else {
- //gr.FillSolidRect(0, 0, ww, wh, g_color_normal_bg);
- if(g_wallpaperImg && ppt.showwallpaper) {
- gr.GdiDrawBitmap(g_wallpaperImg, 0, 0, ww, wh, 0, 0, g_wallpaperImg.Width, g_wallpaperImg.Height);
- gr.FillSolidRect(0, 0, ww, wh, g_color_normal_bg & RGBA(255,255,255,ppt.wallpaperalpha));
- }; else {
- gr.FillSolidRect(0, 0, ww, wh, g_color_normal_bg);
- };
- };
- brw && brw.draw(gr);
- if(ppt.showHeaderBar) {
- // inputBox
- if(cFilterBox.enabled && g_filterbox) {
- if(g_filterbox.inputbox.visible) {
- g_filterbox.draw(gr, 5, 2);
- };
- };
- };
- };
- // tweak to fix bug in timer/memory/repaint handle in WSH Panel Mod with timers
- g_counter_repaint++;
- if(g_counter_repaint > 500) {
- g_counter_repaint = 0;
- CollectGarbage();
- };
- };
- function on_mouse_lbtn_down(x, y) {
- g_lbtn_click = true;
- g_rbtn_click = false;
- // stop inertia
- if(cTouch.timer) {
- window.ClearInterval(cTouch.timer);
- cTouch.timer = false;
- // stop scrolling but not abrupt, add a little offset for the stop
- if(Math.abs(scroll - scroll_) > ppt.rowHeight) {
- scroll = (scroll > scroll_ ? scroll_ + ppt.rowHeight : scroll_ - ppt.rowHeight);
- scroll = check_scroll(scroll);
- };
- };
- var is_scroll_enabled = brw.rowsCount > brw.totalRowsVis;
- if(ppt.enableTouchControl && is_scroll_enabled) {
- if(brw._isHover(x, y) && !brw.scrollbar._isHover(x, y)) {
- if(!timers.mouseDown) {
- cTouch.y_prev = y;
- cTouch.y_start = y;
- if(cTouch.t1) {
- cTouch.t1.Reset();
- }; else {
- cTouch.t1 = fb.CreateProfiler("t1");
- };
- timers.mouseDown = window.SetTimeout(function() {
- window.ClearTimeout(timers.mouseDown);
- timers.mouseDown = false;
- if(Math.abs(cTouch.y_start - m_y) > 015) {
- cTouch.down = true;
- }; else {
- brw.on_mouse("down", x, y);
- };
- },50);
- };
- }; else {
- brw.on_mouse("down", x, y);
- };
- }; else {
- brw.on_mouse("down", x, y);
- };
- // inputBox
- if(ppt.showHeaderBar && cFilterBox.enabled && g_filterbox.inputbox.visible) {
- g_filterbox.on_mouse("lbtn_down", x, y);
- };
- };
- function on_mouse_lbtn_up(x, y) {
- // inputBox
- if(ppt.showHeaderBar && cFilterBox.enabled && g_filterbox.inputbox.visible) {
- g_filterbox.on_mouse("lbtn_up", x, y);
- };
- brw.on_mouse("up", x, y);
- if(timers.mouseDown) {
- window.ClearTimeout(timers.mouseDown);
- timers.mouseDown = false;
- if(Math.abs(cTouch.y_start - m_y) <= 030) {
- brw.on_mouse("down", x, y);
- };
- };
- // create scroll inertia on mouse lbtn up
- if(cTouch.down) {
- cTouch.down = false;
- cTouch.y_end = y;
- cTouch.scroll_delta = scroll - scroll_;
- if(Math.abs(cTouch.scroll_delta) > 015 ) {
- cTouch.multiplier = ((1000 - cTouch.t1.Time) / 20);
- cTouch.delta = Math.round((cTouch.scroll_delta) / 015);
- if(cTouch.multiplier < 1) cTouch.multiplier = 1;
- if(cTouch.timer) window.ClearInterval(cTouch.timer);
- cTouch.timer = window.SetInterval(function() {
- scroll += cTouch.delta * cTouch.multiplier;
- scroll = check_scroll(scroll);
- cTouch.multiplier = cTouch.multiplier - 1;
- cTouch.delta = cTouch.delta - (cTouch.delta / 10);
- if(cTouch.multiplier < 1) {
- window.ClearInterval(cTouch.timer);
- cTouch.timer = false;
- };
- }, 75);
- };
- };
- g_lbtn_click = false;
- };
- function on_mouse_lbtn_dblclk(x, y, mask) {
- if(y >= brw.y) {
- brw.on_mouse("dblclk", x, y);
- }; else if(x > brw.x && x < brw.x + brw.w) {
- //brw.showNowPlaying();
- }; else {
- brw.on_mouse("dblclk", x, y);
- };
- };
- function on_mouse_rbtn_down(x, y, mask) {
- g_rbtn_click = true;
- if(!utils.IsKeyPressed(VK_SHIFT)) {
- // inputBox
- if(ppt.showHeaderBar && cFilterBox.enabled && g_filterbox.inputbox.visible) {
- g_filterbox.on_mouse("rbtn_down", x, y);
- };
- brw.on_mouse("right", x, y);
- };
- };
- function on_mouse_rbtn_up(x, y){
- g_rbtn_click = false;
- if(!utils.IsKeyPressed(VK_SHIFT)) {
- return true;
- };
- };
- function on_mouse_move(x, y) {
- if(m_x == x && m_y == y) return;
- // inputBox
- if(ppt.showHeaderBar && cFilterBox.enabled && g_filterbox.inputbox.visible) {
- g_filterbox.on_mouse("move", x, y);
- };
- if(cTouch.down) {
- cTouch.y_current = y;
- cTouch.y_move = (cTouch.y_current - cTouch.y_prev);
- if(x < brw.w) {
- scroll -= cTouch.y_move;
- cTouch.scroll_delta = scroll - scroll_;
- if(Math.abs(cTouch.scroll_delta) < 030) cTouch.y_start = cTouch.y_current;
- cTouch.y_prev = cTouch.y_current;
- };
- }; else {
- brw.on_mouse("move", x, y);
- };
- m_x = x;
- m_y = y;
- };
- function on_mouse_wheel(step){
- if(utils.IsKeyPressed(VK_CONTROL)) {
- if(ppt.panelMode == 1 || ppt.panelMode == 3) { // Stamps mode != Lines mode
- var previous = ppt.thumbnailWidthMin;
- //g_scroll_rows = Math.round(scroll / brw.rowHeight);
- ppt.thumbnailWidthMin += step * Math.floor(ppt.thumbnailWidthMin / 4);
- if(ppt.thumbnailWidthMin < 130) ppt.thumbnailWidthMin = 125;
- if(ppt.thumbnailWidthMin > 230) ppt.thumbnailWidthMin = 225;
- if(previous != ppt.thumbnailWidthMin) {
- g_image_cache = new image_cache;
- CollectGarbage();
- window.SetProperty("SYSTEM thumbnails Minimal Width", ppt.thumbnailWidthMin);
- brw.setList();
- };
- return;
- }; else if(ppt.panelMode == 0) {
- var previous = ppt.lineHeightMin;
- ppt.lineHeightMin += step * Math.floor(ppt.lineHeightMin / 4);
- if(ppt.tagMode == 1) {
- if(ppt.lineHeightMin < 44) ppt.lineHeightMin = 44;
- }; else {
- if(ppt.lineHeightMin < 22) ppt.lineHeightMin = 22;
- };
- if(ppt.lineHeightMin > 100) ppt.lineHeightMin = 100;
- if(previous != ppt.lineHeightMin) {
- g_image_cache = new image_cache;
- CollectGarbage();
- window.SetProperty("SYSTEM Minimal Line Height", ppt.lineHeightMin);
- brw.setList();
- };
- return;
- }; else if(ppt.panelMode == 2) {
- var previous = ppt.lineHeightMin;
- ppt.lineHeightMin += step * Math.floor(ppt.lineHeightMin / 4);
- if(ppt.lineHeightMin < 60) ppt.lineHeightMin = 60;
- if(ppt.lineHeightMin > 180) ppt.lineHeightMin = 180;
- if(previous != ppt.lineHeightMin) {
- g_image_cache = new image_cache;
- CollectGarbage();
- window.SetProperty("SYSTEM Minimal Line Height", ppt.lineHeightMin);
- brw.setList();
- };
- return;
- };
- };
- scroll -= step * (brw.rowHeight / ppt.scrollRowDivider * ppt.rowScrollStep);
- scroll = check_scroll(scroll)
- brw.on_mouse("wheel", m_x, m_y, step);
- };
- function on_mouse_leave() {
- // inputBox
- if(ppt.showHeaderBar && cFilterBox.enabled && g_filterbox.inputbox.visible) {
- g_filterbox.on_mouse("leave", 0, 0);
- };
- brw.on_mouse("leave", 0, 0);
- };
- //=================================================// Metrics & Fonts & Colors & Images
- function get_metrics() {
- if(ppt.showHeaderBar) {
- ppt.headerBarHeight = Math.round(ppt.defaultHeaderBarHeight * g_zoom_percent / 100);
- ppt.headerBarHeight = Math.floor(ppt.headerBarHeight / 2) != ppt.headerBarHeight / 2 ? ppt.headerBarHeight : ppt.headerBarHeight - 1;
- }; else {
- ppt.headerBarHeight = 0;
- };
- cScrollBar.width = Math.floor(cScrollBar.defaultWidth * g_zoom_percent / 100);
- cScrollBar.minCursorHeight = Math.round(cScrollBar.defaultMinCursorHeight * g_zoom_percent / 100);
- if(brw) {
- brw.setSize(0, ppt.headerBarHeight, ww - cScrollBar.width, wh - ppt.headerBarHeight);
- brw.setList();
- };
- };
- function get_images() {
- // PLAY icon
- images.play_on = gdi.CreateImage(70, 70);
- var gb = images.play_on.GetGraphics();
- DrawPolyStar(gb, 12-2, 12, 46, 1, 3, 2, g_color_normal_bg, g_color_normal_txt, 90, 255);
- images.play_on.ReleaseGraphics(gb);
- images.play_off = gdi.CreateImage(70, 70);
- var gb = images.play_off.GetGraphics();
- DrawPolyStar(gb, 16-2, 16, 38, 1, 3, 2, g_color_normal_bg, g_color_normal_txt, 90, 255);
- images.play_off.ReleaseGraphics(gb);
- images.all = gdi.CreateImage(150, 150);
- var gb = images.all.GetGraphics();
- gb.FillSolidRect(0, 0, 150, 150, RGB(0,0,0));
- images.all.ReleaseGraphics(gb);
- var img_loading = gdi.Image(images.path+"load.png");
- var iw = Math.round(ppt.rowHeight / 2);
- images.loading_draw = img_loading.Resize(iw, iw, 7);
- };
- function get_font() {
- var font_error = false;
- var default_font = null;
- if (g_instancetype == 0) {
- default_font = window.GetFontCUI(FontTypeCUI.items);
- g_font_headers = window.GetFontCUI(FontTypeCUI.labels);
- }; else if (g_instancetype == 1) {
- default_font = window.GetFontDUI(FontTypeDUI.playlists);
- g_font_headers = window.GetFontDUI(FontTypeDUI.tabs);
- };
- // tweaks to fix a problem with WSH Panel Mod on Font object Name property
- try {
- g_fname = default_font.Name;
- g_fsize = default_font.Size;
- g_fstyle = default_font.Style;
- }; catch(e) {
- fb.trace("WSH Panel Error: Unable to use the default font. Using Arial font instead.");
- g_fname = "arial";
- g_fsize = 12;
- g_fstyle = 0;
- font_error = true;
- };
- // adjust font size if extra zoom activated
- g_fsize += ppt.extra_font_size;
- g_font = gdi.Font(g_fname, g_fsize, g_fstyle);
- g_zoom_percent = Math.floor(g_fsize / 12 * 100);
- g_font_group1 = gdi.Font(g_fname, (g_fsize * 160 / 100), 1);
- g_font_group2 = gdi.Font(g_fname, (g_fsize * 140 / 100), 0);
- if(g_font_guifx_found) {
- g_font_rating = gdi.Font("guifx v2 transports", (g_fsize * 140 / 100), 0);
- g_font_mood = gdi.Font("guifx v2 transports", (g_fsize * 130 / 100), 0);
- }; else if(g_font_wingdings2_found) {
- g_font_rating = gdi.Font("wingdings 2", (g_fsize * 140 / 100), 0);
- g_font_mood = gdi.Font("wingdings 2", (g_fsize * 200 / 100), 0);
- }; else {
- g_font_rating = gdi.Font("arial", (g_fsize * 140 / 100), 0);
- g_font_mood = gdi.Font("arial", (g_fsize * 140 / 100), 0);
- };
- };
- function get_colors() {
- var arr;
- // get some system colors
- g_syscolor_window_bg = utils.GetSysColor(COLOR_WINDOW);
- g_syscolor_highlight = utils.GetSysColor(COLOR_HIGHLIGHT);
- g_syscolor_button_bg = utils.GetSysColor(COLOR_BTNFACE);
- g_syscolor_button_txt = utils.GetSysColor(COLOR_BTNTEXT);
- arr = window.GetProperty("CUSTOM COLOR TEXT NORMAL", "180-180-180").split("-");
- g_color_normal_txt = RGB(arr[0], arr[1], arr[2]);
- arr = window.GetProperty("CUSTOM COLOR TEXT SELECTED", "200-210-255").split("-");
- g_color_selected_txt = RGB(arr[0], arr[1], arr[2]);
- arr = window.GetProperty("CUSTOM COLOR BACKGROUND NORMAL", "25-25-35").split("-");
- g_color_normal_bg = RGB(arr[0], arr[1], arr[2]);
- arr = window.GetProperty("CUSTOM COLOR BACKGROUND SELECTED", "130-150-255").split("-");
- g_color_selected_bg = RGB(arr[0], arr[1], arr[2]);
- arr = window.GetProperty("CUSTOM COLOR HIGHLIGHT", "255-175-50").split("-");
- g_color_highlight = RGB(arr[0], arr[1], arr[2]);
- // get custom colors from window ppt first
- if(!ppt.enableCustomColors) {
- // get UI colors set in UI Preferences if no custom color set
- if (g_instancetype == 0) {
- g_color_normal_txt = window.GetColorCUI(ColorTypeCUI.text);
- g_color_selected_txt = window.GetColorCUI(ColorTypeCUI.selection_text);
- g_color_normal_bg = window.GetColorCUI(ColorTypeCUI.background);
- g_color_selected_bg = window.GetColorCUI(ColorTypeCUI.selection_background);
- g_color_highlight = window.GetColorCUI(ColorTypeCUI.active_item_frame);
- }; else if (g_instancetype == 1) {
- g_color_normal_txt = window.GetColorDUI(ColorTypeDUI.text);
- g_color_selected_txt = window.GetColorDUI(ColorTypeDUI.selection);
- g_color_normal_bg = window.GetColorDUI(ColorTypeDUI.background);
- g_color_selected_bg = g_color_selected_txt;
- g_color_highlight = window.GetColorDUI(ColorTypeDUI.highlight);
- };
- };
- };
- function on_font_changed() {
- get_font();
- get_metrics();
- brw.repaint();
- };
- function on_colors_changed() {
- get_colors();
- get_images();
- if(brw) brw.scrollbar.setNewColors();
- g_filterbox.getImages();
- brw.repaint();
- };
- function on_script_unload() {
- brw.g_time && window.ClearInterval(brw.g_time);
- brw.g_time = false;
- brw.g_timeCover && window.ClearInterval(brw.g_timeCover);
- brw.g_timeCover = false;
- };
- //=================================================// Keyboard Callbacks
- function on_key_up(vkey) {
- if(cSettings.visible) {
- }; else {
- // inputBox
- if(cFilterBox.enabled && g_filterbox.inputbox.visible) {
- g_filterbox.on_key("up", vkey);
- };
- // scroll keys up and down RESET (step and timers)
- brw.keypressed = false;
- cScrollBar.timerCounter = -1;
- cScrollBar.timerID && window.ClearTimeout(cScrollBar.timerID);
- cScrollBar.timerID = false;
- if(vkey == VK_SHIFT) {
- brw.SHIFT_start_id = null;
- brw.SHIFT_count = 0;
- };
- };
- brw.repaint();
- };
- function on_key_down(vkey) {
- var mask = GetKeyboardMask();
- if(cSettings.visible) {
- }; else {
- //if(dragndrop.drag_in) return true;
- // inputBox
- if(cFilterBox.enabled && g_filterbox.inputbox.visible) {
- g_filterbox.on_key("down", vkey);
- };
- var act_pls = g_active_playlist;
- if (mask == KMask.none) {
- switch (vkey) {
- case VK_F2:
- break;
- case VK_F5:
- // refresh covers
- g_image_cache = new image_cache;
- CollectGarbage();
- brw.repaint();
- break;
- case VK_F6:
- break;
- case VK_TAB:
- break;
- case VK_BACK:
- break;
- case VK_ESCAPE:
- case 222:
- break;
- case VK_UP:
- if(brw.rowsCount > 0 && !brw.keypressed && !cScrollBar.timerID) {
- brw.keypressed = true;
- reset_cover_timers();
- };
- break;
- case VK_DOWN:
- if(brw.rowsCount > 0 && !brw.keypressed && !cScrollBar.timerID) {
- brw.keypressed = true;
- reset_cover_timers();
- };
- break;
- case VK_PGUP:
- if(brw.rowsCount > 0 && !brw.keypressed && !cScrollBar.timerID) {
- brw.keypressed = true;
- reset_cover_timers();
- };
- break;
- case VK_PGDN:
- if(brw.rowsCount > 0 && !brw.keypressed && !cScrollBar.timerID) {
- brw.keypressed = true;
- reset_cover_timers();
- };
- break;
- case VK_RETURN:
- // play/enqueue focused item
- break;
- case VK_END:
- if(brw.rowsCount > 0) {
- };
- break;
- case VK_HOME:
- if(brw.rowsCount > 0) {
- };
- break;
- case VK_DELETE:
- if(!fb.IsAutoPlaylist(act_pls)) {
- };
- break;
- };
- }; else {
- switch(mask) {
- case KMask.shift:
- switch(vkey) {
- case VK_SHIFT: // SHIFT key alone
- break;
- case VK_UP: // SHIFT + KEY UP
- break;
- case VK_DOWN: // SHIFT + KEY DOWN
- break;
- };
- break;
- case KMask.ctrl:
- if(vkey==65) { // CTRL+A
- };
- if(vkey==88) { // CTRL+X
- if(!fb.IsAutoPlaylist(act_pls)) {
- };
- };
- if(vkey==67) { // CTRL+C
- };
- if(vkey==86) { // CTRL+V
- };
- if(vkey==70) { // CTRL+F
- fb.RunMainMenuCommand("Edit/Search");
- };
- if(vkey==73) { // CTRL+I
- };
- if(vkey==78) { // CTRL+N
- fb.RunMainMenuCommand("File/New playlist");
- };
- if(vkey==79) { // CTRL+O
- fb.RunMainMenuCommand("File/Open...");
- };
- if(vkey==80) { // CTRL+P
- fb.RunMainMenuCommand("File/Preferences");
- };
- if(vkey==83) { // CTRL+S
- fb.RunMainMenuCommand("File/Save playlist...");
- };
- if(vkey==84) { // CTRL+T
- };
- if(vkey == 48) { // CTRL + 0
- };
- break;
- case KMask.alt:
- switch(vkey) {
- case 65: // ALT+A
- fb.RunMainMenuCommand("View/Always on Top");
- break;
- case VK_ALT: // ALT key alone
- break;
- };
- break;
- };
- };
- };
- };
- function on_char(code) {
- // inputBox
- if(cFilterBox.enabled && g_filterbox.inputbox.visible) {
- g_filterbox.on_char(code);
- };
- };
- //=================================================// Playback Callbacks
- function on_playback_stop(reason) {
- g_seconds = 0;
- g_time_remaining = null;
- g_metadb = null;
- switch(reason) {
- case 0: // user stop
- case 1: // eof (e.g. end of playlist)
- // update wallpaper
- if(ppt.showwallpaper) {
- g_wallpaperImg = setWallpaperImg(ppt.wallpaperpath, null);
- };
- brw.repaint();
- break;
- case 2: // starting_another (only called on user action, i.e. click on next button)
- break;
- };
- };
- function on_playback_new_track(metadb) {
- g_metadb = metadb;
- if(ppt.showwallpaper) {
- g_wallpaperImg = setWallpaperImg(ppt.wallpaperpath, metadb);
- };
- brw.repaint();
- };
- function on_playback_starting(cmd, is_paused) {
- };
- function on_playback_time(time) {
- g_seconds = time;
- g_time_remaining = ppt.tf_time_remaining.Eval(true);
- };
- //=================================================// Library Callbacks
- function on_library_items_added() {
- //fb.trace("..on_library_items_added "+gtt.Time);
- brw.populate(is_first_populate = false);
- };
- function on_library_items_removed() {
- //fb.trace("..on_library_items_removed "+gtt.Time);
- brw.populate(is_first_populate = false);
- };
- function on_library_items_changed() {
- //fb.trace("..on_library_items_changed "+gtt.Time);
- brw.populate(is_first_populate = false);
- //ask_for_reloading_library();
- //on_tags_updated();
- };
- //=================================================// Playlist Callbacks
- function on_playlists_changed() {
- if(plman.ActivePlaylist < 0 || plman.ActivePlaylist > plman.PlaylistCount - 1) {
- plman.ActivePlaylist = 0;
- };
- if(g_active_playlist != plman.ActivePlaylist) {
- g_active_playlist = plman.ActivePlaylist;
- };
- };
- function on_playlist_switch() {
- //fb.trace("pl switch");
- g_active_playlist = plman.ActivePlaylist;
- if(ppt.sourceMode == 1) {
- brw.populate(is_first_populate = true);
- };
- };
- function on_playlist_items_added(playlist_idx) {
- g_avoid_on_playlist_items_removed_callbacks_on_sendItemToPlaylist = false;
- if(ppt.sourceMode == 1) {
- if(playlist_idx == g_active_playlist) {
- brw.populate(is_first_populate = false);
- };
- };
- };
- function on_playlist_items_removed(playlist_idx, new_count) {
- if(g_avoid_on_playlist_items_removed_callbacks_on_sendItemToPlaylist) return;
- //fb.trace("items removed");
- if(ppt.sourceMode == 1) {
- if(playlist_idx == g_active_playlist) {
- brw.populate(is_first_populate = true);
- };
- };
- };
- function on_playlist_items_reordered(playlist_idx) {
- if(ppt.sourceMode == 1) {
- if(playlist_idx == g_active_playlist) {
- brw.populate(is_first_populate = true);
- };
- };
- };
- function on_item_focus_change(playlist, from, to) {
- };
- function on_metadb_changed(metadb_or_metadbs, fromhook) {
- // rebuild list
- if(ppt.sourceMode == 1) {
- if(filter_text.length > 0) {
- brw.populate(is_first_populate = true);
- }; else {
- brw.populate(is_first_populate = false);
- };
- };
- };
- function on_item_selection_change() {
- brw.repaint();
- };
- function on_playlist_items_selection_change() {
- brw.repaint();
- };
- function on_focus(is_focused) {
- //fb.trace("on focus");
- g_focus = is_focused;
- if(!is_focused) {
- brw.repaint();
- };
- };
- //=================================================// Custom functions
- function match(input, str){
- var temp = "";
- input = input.toLowerCase();
- for(var j in str){
- if(input.indexOf(str[j]) < 0)
- return false;
- };
- return true;
- };
- function check_playlist(name){
- var pl_name = "", pl_idx = -1;
- for(var i=0; i < plman.PlaylistCount; i++) {
- pl_name = plman.GetPlaylistName(i);
- if(pl_name == name) {
- pl_idx = i;
- break;
- };
- };
- return pl_idx;
- };
- function process_string(str){
- str_ = [];
- str = str.toLowerCase();
- while(str !=(temp = str.replace(" "," ")))
- str = temp;
- var str = str.split(" ").sort();
- for(var i in str){
- if(str[i] != "")
- str_[str_.length] = str[i];
- };
- return str_;
- };
- function check_scroll(scroll___){
- if(scroll___ < 0)
- scroll___ = 0;
- var g1 = brw.h - (brw.totalRowsVis * ppt.rowHeight);
- //var scroll_step = Math.ceil(ppt.rowHeight / ppt.scrollRowDivider);
- //var g2 = Math.floor(g1 / scroll_step) * scroll_step;
- var end_limit = (brw.rowsCount * ppt.rowHeight) - (brw.totalRowsVis * ppt.rowHeight) - g1;
- if(scroll___ != 0 && scroll___ > end_limit) {
- scroll___ = end_limit;
- };
- return scroll___;
- };
- // ===================================================== // Wallpaper
- function setWallpaperImg(path, metadb) {
- var fmt_path = fb.TitleFormat(path).Eval(true);
- var fmt_path_arr = utils.Glob(fmt_path).toArray();
- if(fmt_path_arr.length > 0) {
- var final_path = fmt_path_arr[0];
- }; else {
- var final_path = null;
- };
- if(metadb && ppt.wallpapermode == 0) {
- var tmp_img = utils.GetAlbumArtV2(metadb, ppt.wallpapermode);
- }; else {
- if(final_path) {
- tmp_img = gdi.Image(final_path);
- }; else {
- tmp_img = null;
- };
- };
- if(!tmp_img) {
- if(final_path) {
- tmp_img = gdi.Image(final_path);
- }; else {
- tmp_img = null;
- };
- };
- g_wallpaperImg = null;
- var img = FormatWallpaper(tmp_img, ww, wh, 2, 0, 0, "", true);
- return img;
- };
- function draw_blurred_image(image,ix,iy,iw,ih,bx,by,bw,bh,blur_value,overlay_color) {
- var blurValue = blur_value;
- var imgA = image.Resize(iw*blurValue/100,ih*blurValue/100,2);
- var imgB = imgA.resize(iw, ih, 2);
- var bbox = gdi.CreateImage(bw, bh);
- // Get graphics interface like "gr" in on_paint
- var gb = bbox.GetGraphics();
- var offset = 90-blurValue;
- gb.DrawImage(imgB, 0-offset, 0-(ih-bh)-offset, iw+offset*2, ih+offset*2, 0, 0, imgB.Width, imgB.Height, 0, 255);
- bbox.ReleaseGraphics(gb);
- var newImg = gdi.CreateImage(iw, ih);
- var gb = newImg.GetGraphics();
- if(ix!=bx || iy!=by || iw!=bw || ih!=bh) {
- gb.DrawImage(image, ix, iy, iw, ih, 0, 0, image.Width, image.Height, 0, 255);
- gb.FillSolidRect(bx,by,bw,bh,0xffffffff);
- };
- gb.DrawImage(bbox, bx, by, bw, bh, 0, 0, bbox.Width, bbox.Height, 0, 255);
- // overlay
- if(overlay_color!=null) {
- gb.FillSolidRect(bx,by,bw,bh,overlay_color);
- };
- // top border of blur area
- if(ix!=bx || iy!=by || iw!=bw || ih!=bh) {
- gb.FillSolidRect(bx,by,bw,1,0x22ffffff);
- gb.FillSolidRect(bx,by-1,bw,1,0x22000000);
- };
- newImg.ReleaseGraphics(gb);
- return newImg;
- };
- function FormatWallpaper(image, iw, ih, interpolation_mode, display_mode, angle, txt, rawBitmap) {
- if(!image||!iw||!ih) return image;
- var i, j;
- var panel_ratio = iw / ih;
- wpp_img_info.ratio = image.Width / image.Height;
- wpp_img_info.orient = 0;
- if(wpp_img_info.ratio > panel_ratio) {
- wpp_img_info.orient = 1;
- // 1/3 : default image is in landscape mode
- switch(display_mode) {
- case 0: // Filling
- //wpp_img_info.w = iw * wpp_img_info.ratio / panel_ratio;
- wpp_img_info.w = ih * wpp_img_info.ratio;
- wpp_img_info.h = ih;
- wpp_img_info.cut = wpp_img_info.w - iw;
- wpp_img_info.x = 0 - (wpp_img_info.cut / 2);
- wpp_img_info.y = 0;
- break;
- case 1: // Adjust
- wpp_img_info.w = iw;
- wpp_img_info.h = ih / wpp_img_info.ratio * panel_ratio;
- wpp_img_info.cut = ih - wpp_img_info.h;
- wpp_img_info.x = 0;
- wpp_img_info.y = wpp_img_info.cut / 2;
- break;
- case 2: // Stretch
- wpp_img_info.w = iw;
- wpp_img_info.h = ih;
- wpp_img_info.cut = 0;
- wpp_img_info.x = 0;
- wpp_img_info.y = 0;
- break;
- };
- }; else if(wpp_img_info.ratio < panel_ratio) {
- wpp_img_info.orient = 2;
- // 2/3 : default image is in portrait mode
- switch(display_mode) {
- case 0: // Filling
- wpp_img_info.w = iw;
- //wpp_img_info.h = ih / wpp_img_info.ratio * panel_ratio;
- wpp_img_info.h = iw / wpp_img_info.ratio;
- wpp_img_info.cut = wpp_img_info.h - ih;
- wpp_img_info.x = 0;
- wpp_img_info.y = 0 - (wpp_img_info.cut / 4);
- break;
- case 1: // Adjust
- wpp_img_info.h = ih;
- wpp_img_info.w = iw * wpp_img_info.ratio / panel_ratio;
- wpp_img_info.cut = iw - wpp_img_info.w;
- wpp_img_info.y = 0;
- wpp_img_info.x = wpp_img_info.cut / 2;
- break;
- case 2: // Stretch
- wpp_img_info.w = iw;
- wpp_img_info.h = ih;
- wpp_img_info.cut = 0;
- wpp_img_info.x = 0;
- wpp_img_info.y = 0;
- break;
- };
- }; else {
- // 3/3 : default image is a square picture, ratio = 1
- wpp_img_info.w = iw;
- wpp_img_info.h = ih;
- wpp_img_info.cut = 0;
- wpp_img_info.x = 0;
- wpp_img_info.y = 0;
- };
- var tmp_img = gdi.CreateImage(iw, ih);
- var gp = tmp_img.GetGraphics();
- gp.SetInterpolationMode(interpolation_mode);
- gp.DrawImage(image, wpp_img_info.x, wpp_img_info.y, wpp_img_info.w, wpp_img_info.h, 0, 0, image.Width, image.Height, angle, 255);
- tmp_img.ReleaseGraphics(gp);
- // blur it!
- if(ppt.wallpaperblurred) {
- var blur_factor = ppt.wallpaperblurvalue; // [1-90]
- tmp_img = draw_blurred_image(tmp_img,0,0,tmp_img.Width,tmp_img.Height,0,0,tmp_img.Width,tmp_img.Height,blur_factor,0x00ffffff);
- };
- CollectGarbage();
- if(rawBitmap) {
- return tmp_img.CreateRawBitmap();
- }; else {
- return tmp_img;
- };
- };
- function g_sendResponse() {
- if(g_filterbox.inputbox.text.length == 0) {
- filter_text = "";
- }; else {
- filter_text = g_filterbox.inputbox.text;
- };
- // filter in current panel
- brw.populate(true);
- };
- function on_notify_data(name, info) {
- switch(name) {
- case "JSSmoothBRowser->JSSmoothPlaylist:avoid_on_playlist_items_removed_callbacks_on_sendItemToPlaylist":
- g_avoid_on_playlist_items_removed_callbacks_on_sendItemToPlaylist = true;
- break;
- };
- };
- // ======================================================================================================================= //
- function getpath(path){
- var img_path = "";
- var path_, temp, subFlds, tmp;
- for(var iii = 0; iii < 2; iii++){
- if(tmp = getpath_(iii == 0 ? path :(path + "..\\")))
- return tmp;
- try {
- subFlds = new Enumerator(fso.GetFolder((iii == 0 ? path : (path + "..\\"))).SubFolders);
- }; catch(err) { return null };
- for (; !subFlds.atEnd(); subFlds.moveNext()) {
- temp = subFlds.item() + "\\";
- if(temp.toLowerCase().match(cover_path)){
- if(tmp = getpath_(temp))
- return tmp;
- };
- };
- };
- return null;
- };
- function getpath_(temp){
- var img_path = "", path_;
- for(var iii in cover_img){
- path_ = utils.Glob(temp + cover_img[iii], exc_mask = FILE_ATTRIBUTE_DIRECTORY, inc_mask = 0xffffffff).toArray();
- for(var j in path_){
- if(path_[j].toLowerCase().indexOf(".jpg") > -1 || path_[j].toLowerCase().indexOf(".png") > -1 || path_[j].toLowerCase().indexOf(".gif") > -1 ){
- return path_[j];
- };
- };
- };
- return null;
- };
- function check_cache(metadb, albumIndex){
- //var crc = ppt.tf_crc.EvalWithMetadb(metadb);
- var crc = brw.groups[albumIndex].cachekey;
- if(fso.FileExists(fb.ProfilePath + "wsh_br3tt\\cache\\imgcache\\" + crc)) {
- return crc;
- };
- return null;
- };
- function load_image_from_cache(metadb, crc){
- if(fso.FileExists(fb.ProfilePath + "wsh_br3tt\\cache\\imgcache\\" + crc)){ // image in folder cache
- var tdi = gdi.LoadImageAsync(window.ID, fb.ProfilePath + "wsh_br3tt\\cache\\imgcache\\" + crc);
- return tdi;
- }; else {
- return -1;
- };
- };
- function save_image_to_cache(metadb, albumIndex) {
- var tran = false;
- switch(ppt.tagMode) {
- case 1:
- var path = ppt.tf_path.EvalWithMetadb(metadb);
- var path_ = getpath_(path);
- break;
- case 2:
- var path_ = ppt.tf_path_artist.EvalWithMetadb(metadb);
- break;
- case 3:
- var path_ = ppt.tf_path_genre.EvalWithMetadb(metadb);
- break;
- };
- if(path_) {
- var crc = brw.groups[albumIndex].cachekey;
- }; else {
- return false;
- };
- var comm = "wscript //E:jscript \"" + fb.ProfilePath + "wsh_br3tt\\cache\\LoadIMG.js\" \""
- + fb.ProfilePath + "\" \""+ path_ + "\" \"" + crc + "\" \"" + tran + "\"";
- WshShell.Run(comm, false, false);
- };
- function process_cachekey(str){
- var str_return = "";
- str = str.toLowerCase();
- var len = str.length;
- for(var i = 0;i < len; i++){
- var charcode = str.charCodeAt(i);
- if(charcode > 96 && charcode < 123)
- str_return += str.charAt(i);
- if(charcode > 47 && charcode < 58)
- str_return += str.charAt(i);
- };
- return str_return;
- };
- on_load();
- function on_load(){
- if(!fso.FileExists(fb.ProfilePath + "wsh_br3tt\\cache\\LoadIMG.js")){
- var data = "var fso = new ActiveXObject(\"Scripting.FileSystemObject\");\r\n"
- + "var Img = new ActiveXObject(\"WIA.ImageFile.1\");\r\n"
- + "var IP = new ActiveXObject(\"WIA.ImageProcess.1\");\r\n"
- + "IP.Filters.Add(IP.FilterInfos(\"Scale\").FilterID);//ID = 1\r\n"
- + "IP.Filters.Add(IP.FilterInfos(\"Crop\").FilterID);//ID = 2\r\n"
- + "IP.Filters.Add(IP.FilterInfos(\"Convert\").FilterID);//ID = 3\r\n"
- + "function resize_image(path,crc,tranparent)\r\n"
- + "{\r\n"
- + " var ratio = 1;\r\n"
- + " var cachesize = 150;\r\n"
- + " var img_w = cachesize, img_h = cachesize, cr_x = 0, cr_y = 0;\r\n"
- + " try{\r\n"
- + " Img.LoadFile(path);\r\n"
- + " }catch(err){\r\n"
- + " return false;\r\n"
- + " }\r\n"
- + "if(Img.Height >= Img.Width) {\r\n"
- + " ratio = Img.Width / Img.Height;\r\n"
- + " img_w = img_w * ratio;\r\n"
- + " cr_x = (img_h - img_w)/2;\r\n"
- + "} else {\r\n"
- + " ratio = Img.Height / Img.Width;\r\n"
- + " img_h = img_h * ratio;\r\n"
- + " cr_y = (img_w - img_h)/2;\r\n"
- + "}\r\n"
- + " IP.Filters(1).Properties(\"MaximumWidth\") = img_w;\r\n"
- + " IP.Filters(1).Properties(\"MaximumHeight\") = img_h;\r\n"
- + " if(tranparent == \"true\"){\r\n"
- + " IP.Filters(3).Properties(\"FormatID\").Value = '{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}';\r\n"
- + " }else{\r\n"
- + " IP.Filters(3).Properties(\"FormatID\").Value = '{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}';\r\n"
- + " IP.Filters(3).Properties(\"Quality\").Value = 75; \r\n"
- + " }\r\n"
- + " //IP.Filters(2).Properties(\"Left\") = cr_x;\r\n"
- + " //IP.Filters(2).Properties(\"Top\") = cr_y;\r\n"
- + " //IP.Filters(2).Properties(\"Right\") = cr_x;\r\n"
- + " //IP.Filters(2).Properties(\"Bottom\") = cr_y;\r\n"
- + " Img = IP.Apply(Img);\r\n"
- + " try{\r\n"
- + " if(fso.FileExists(WScript.arguments(0) + \"\\\\wsh_br3tt\\\\cache\\\\imgcache\\\\\" + crc))\r\n"
- + " fso.DeleteFile(WScript.arguments(0)+ \"\\\\wsh_br3tt\\\\cache\\\\imgcache\\\\\" + crc);\r\n"
- + " Img.SaveFile(WScript.arguments(0) + \"\\\\wsh_br3tt\\\\cache\\\\imgcache\\\\\" + crc);\r\n"
- + " }catch(err){\r\n"
- + " return false;\r\n"
- + " }\r\n"
- + " return true;\r\n"
- + "}\r\n"
- + "resize_image(WScript.arguments(1),WScript.arguments(2),WScript.arguments(3));";
- if(!fso.FolderExists(fb.ProfilePath + "wsh_br3tt"))
- fso.CreateFolder(fb.ProfilePath + "wsh_br3tt");
- if(!fso.FolderExists(fb.ProfilePath + "wsh_br3tt\\cache"))
- fso.CreateFolder(fb.ProfilePath + "wsh_br3tt\\cache");
- if(!fso.FolderExists(fb.ProfilePath + "wsh_br3tt\\cache\\imgcache"))
- fso.CreateFolder(fb.ProfilePath + "wsh_br3tt\\cache\\imgcache");
- var file = fso.CreateTextFile(fb.ProfilePath + "wsh_br3tt\\cache\\LoadIMG.js", true, 65001);
- file.WriteLine(data);
- file.Close();
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement