Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==PREPROCESSOR==
- // @name "WSH Tabbed Playlist Manager"
- // @version "3.3.0"
- // @author "Br3tt aka Falstaff >> http://br3tt.deviantart.com"
- // @feature "dragdrop"
- // ==/PREPROCESSOR==
- // [Requirements]
- // * foobar2000 v1.1 or better >> http://foobar2000.org
- // * WSH panel Mod v1.5.2 or better >> http://http://code.google.com/p/foo-wsh-panel-mod/downloads/list
- // [/Requirements]
- //=================================================// General declarations
- // Used in window.SetCursor()
- // {{
- IDC_ARROW = 32512;
- IDC_HAND = 32649;
- // }}
- // Use with GdiDrawText()
- // {{
- var DT_LEFT = 0x00000000;
- var DT_RIGHT = 0x00000002;
- var DT_TOP = 0x00000000;
- var DT_CENTER = 0x00000001;
- var DT_VCENTER = 0x00000004;
- var DT_WORDBREAK = 0x00000010;
- var DT_SINGLELINE = 0x00000020;
- var DT_CALCRECT = 0x00000400;
- var DT_NOPREFIX = 0x00000800;
- var DT_EDITCONTROL = 0x00002000;
- var DT_END_ELLIPSIS = 0x00008000;
- // }}
- // Keyboard Flags & Tools
- // {{
- var VK_BACK = 0x08;
- var VK_RETURN = 0x0D;
- var VK_SHIFT = 0x10;
- var VK_CONTROL = 0x11;
- var VK_ALT = 0x12;
- var VK_ESCAPE = 0x1B;
- var VK_PGUP = 0x21;
- var VK_PGDN = 0x22;
- var VK_END = 0x23;
- var VK_HOME = 0x24;
- var VK_LEFT = 0x25;
- var VK_UP = 0x26;
- var VK_RIGHT = 0x27;
- var VK_DOWN = 0x28;
- var VK_INSERT = 0x2D;
- var VK_DELETE = 0x2E;
- var KMask = {
- none: 0,
- ctrl: 1,
- shift: 2,
- ctrlshift: 3,
- ctrlalt: 4,
- ctrlaltshift: 5,
- alt: 6
- };
- function GetKeyboardMask() {
- var c = utils.IsKeyPressed(VK_CONTROL) ? true : false;
- var a = utils.IsKeyPressed(VK_ALT) ? true : false;
- var s = utils.IsKeyPressed(VK_SHIFT) ? true : false;
- var ret = KMask.none;
- if (c && !a && !s) ret = KMask.ctrl;
- if (!c && !a && s) ret = KMask.shift;
- if (c && !a && s) ret = KMask.ctrlshift;
- if (c && a && !s) ret = KMask.ctrlalt;
- if (c && a && s) ret = KMask.ctrlaltshift;
- if (!c && a && !s) ret = KMask.alt;
- return ret;
- }
- // }}
- // Used in window.GetColorCUI()
- // {{
- ColorTypeCUI = {
- text: 0,
- selection_text: 1,
- inactive_selection_text: 2,
- background: 3,
- selection_background: 4,
- inactive_selection_background: 5,
- active_item_frame: 6
- };
- // Used in window.GetFontCUI()
- FontTypeCUI = {
- items: 0,
- labels: 1
- };
- // Used in window.GetColorDUI()
- ColorTypeDUI = {
- text: 0,
- background: 1,
- highlight: 2,
- selection: 3
- };
- // Used in window.GetFontDUI()
- FontTypeDUI = {
- defaults: 0,
- tabs: 1,
- lists: 2,
- playlists: 3,
- statusbar: 4,
- console: 5
- };
- // }}
- // Used in gr.DrawString()
- // {{
- function StringFormat() {
- var h_align = 0, v_align = 0, trimming = 0, flags = 0;
- switch (arguments.length) {
- case 3:
- trimming = arguments[2];
- case 2:
- v_align = arguments[1];
- case 1:
- h_align = arguments[0];
- break;
- default:
- return 0;
- }
- return ((h_align << 28) | (v_align << 24) | (trimming << 20) | flags);
- }
- StringAlignment = {Near: 0, Centre: 1, Far: 2};
- var lt_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Near);
- var ct_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Near);
- var rt_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Near);
- var lc_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Centre);
- var cc_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Centre);
- var rc_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Centre);
- var lb_stringformat = StringFormat(StringAlignment.Near, StringAlignment.Far);
- var cb_stringformat = StringFormat(StringAlignment.Centre, StringAlignment.Far);
- var rb_stringformat = StringFormat(StringAlignment.Far, StringAlignment.Far);
- // }}
- // Used everywhere!
- // {{
- function RGB(r, g, b) {
- return (0xff000000 | (r << 16) | (g << 8) | (b))
- }
- function RGBA(r, g, b, a) {
- return ((a << 24) | (r << 16) | (g << 8) | (b))
- }
- // }}
- // VB wrapper
- // {{
- var vb = {};
- vb.Function = function (func) {
- return function () {
- return vb.Function.eval.call(this, func, arguments);
- }
- };
- vb.Function.eval = function (func) {
- var args = Array.prototype.slice.call(arguments[1]);
- for (var i=0;i<args.length;i++) {
- if (typeof args[i] != 'string') continue;
- args[i] = '"' + args[i].replace(/"/g, '" + Chr(34) + "') + '"';
- }
- var vbe;
- vbe = new ActiveXObject('ScriptControl');
- vbe.Language = 'VBScript';
- return vbe.eval(func + '(' + args.join(', ') + ')');
- };
- var InputBox = vb.Function('InputBox');
- var MsgBox = vb.Function('MsgBox');
- // }}
- //=================================================// Button object
- ButtonStates = {normal: 0, hover: 1, down: 2};
- button = function (normal, hover, down) {
- this.img = Array(normal, hover, down);
- this.w = this.img[0].Width;
- this.h = this.img[0].Height;
- this.state = ButtonStates.normal;
- this.draw = function (gr, x, y, alpha) {
- this.x = x;
- this.y = y;
- this.img[this.state] && gr.DrawImage(this.img[this.state], this.x, this.y, this.w, this.h, 0, 0, this.w, this.h, 0, alpha);
- }
- this.display_context_menu = function (x, y, id) {}
- this.repaint = function () {
- window.RepaintRect(this.x, this.y, this.w, this.h);
- }
- this.checkstate = function (event, x, y) {
- this.ishover = (x > this.x && x < this.x + this.w - 1 && y > this.y && y < this.y + this.h - 1);
- this.old = this.state;
- switch (event) {
- case "down":
- switch(this.state) {
- case ButtonStates.normal:
- case ButtonStates.hover:
- this.state = this.ishover ? ButtonStates.down : ButtonStates.normal;
- break;
- }
- break;
- case "up":
- this.state = this.ishover ? ButtonStates.hover : ButtonStates.normal;
- break;
- case "right":
- if(this.ishover) this.display_context_menu(x, y, id);
- break;
- case "move":
- switch(this.state) {
- case ButtonStates.normal:
- case ButtonStates.hover:
- this.state = this.ishover ? ButtonStates.hover : ButtonStates.normal;
- break;
- }
- break;
- case "leave":
- this.state = this.isdown ? ButtonStates.down : ButtonStates.normal;
- break;
- }
- if(this.state!=this.old) this.repaint();
- return this.state;
- }
- };
- //=================================================// Global Variables
- var g_instancetype = window.InstanceType;
- var g_textcolor;
- var g_textcolor_sel;
- var g_textcolor_hl;
- var g_backcolor;
- var top_tab_margin = window.GetProperty("_Top tabs margin", 2);
- var inter_tab_margin = window.GetProperty("_Inter tabs margin", 2);
- var background_colour = {};
- var label_colour = {};
- //=================================================// Images
- var close_img_off, close_img_ov, autoplaylist_marker_off, autoplaylist_marker_on;
- var newtab_img_off, newtab_img_ov, newpl_img_off, newpl_img_ov;
- var plmenu1_img_off, plmenu1_img_ov, plmenu2_img_off, plmenu2_img_ov;
- var scroll_left_img_off, scroll_left_img_ov, scroll_right_img_off, scroll_right_img_off;
- //=================================================// OBJECT tab
- var bt_w = 18;
- tab_CONST = {
- width: 60,
- min_width: 70,
- max_width: 100,
- height: 26,
- pad_top: 0,
- pad_left: 2,
- pad_left_default: 2,
- pad_right: bt_w*2,
- scroll: false,
- scroll_step: 40,
- pos: 0
- };
- panel = {
- custom_textcolor: window.GetProperty("*USER.custom.text.color.normal", "RGB(240,240,240)"),
- custom_textcolor_selection: window.GetProperty("*USER.custom.text.color.selection", "RGB(64,128,250)"),
- custom_textcolor_highlight: window.GetProperty("*USER.custom.text.color.highlight", "RGB(64,128,250)"),
- custom_backcolor: window.GetProperty("*USER.custom.background.color", "RGB(0,0,0)"),
- custom_colors: window.GetProperty("SYSTEM.panel.custom.colors", false)
- };
- TabStates = {
- normal: 0,
- hover: 1,
- active: 2
- };
- tab = function () {
- this.create = function(label, id) {
- if (typeof this.tabname == "undefined") {
- this.label = label;
- this.id = id;
- if (fb.ActivePlaylist == id) {
- this.state = TabStates.active;
- } else {
- this.state = TabStates.normal;
- }
- this.x = 0;
- this.y = 0;
- this.w = 0;
- this.h = 0;
- this.colour_text = RGB(0, 0, 0);
- this.colour_bg = RGB(240, 240, 240);
- // creating the close tab button of this sheet
- this.bt_close = new button(close_img_off, close_img_ov, close_img_ov);
- }
- }
- this.draw = function (gr, x, y, alpha) {
- var delta_move = 0;
- this.w = tab_CONST.width;
- this.h = tab_CONST.height;
- this.x = tab_CONST.pos + tab_CONST.pad_left + (this.w + 0) * this.id;
- this.y = y;
- // set delta on mouse drag to move items to their new place preview
- if(g_drag) {
- if(this.x+this.w>mouse_x && this.id < g_drag_source_id) {
- delta_move = mytab[g_drag_source_id].w;
- }
- if(this.x<mouse_x && this.id > g_drag_source_id) {
- delta_move = mytab[g_drag_source_id].w * -1;
- }
- }
- // set colours
- switch (this.state) {
- case TabStates.normal:
- this.label_colour = label_colour.normal;
- this.bg_colour_1 = background_colour.normal;
- break;
- case TabStates.hover:
- if(g_drag) {
- this.label_colour = label_colour.hover;
- this.bg_colour_1 = background_colour.hover;
- } else {
- this.label_colour = label_colour.hover;
- this.bg_colour_1 = background_colour.hover;
- }
- break;
- case TabStates.active:
- this.label_colour = label_colour.active;
- this.bg_colour_1 = background_colour.active;
- break;
- }
- if(!g_drag || (g_drag && this.id!=g_drag_source_id)) {
- if(this.x+delta_move > tab_CONST.pad_left-tab_CONST.width && x < ww-tab_CONST.pad_right) {
- // Drawing a tab
- if(this.state==TabStates.active){
- gr.FillSolidRect(this.x+delta_move, this.y+this.h-1, this.w, 1, g_backcolor);
- gr.FillSolidRect(this.x+delta_move, this.y+this.h-1, this.w, 1, RGBA(0,0,0,50));
- gr.FillSolidRect(this.x+delta_move-1, this.y+top_tab_margin-1, this.w - inter_tab_margin+2, this.h+5+1, g_textcolor&0x55ffffff);
- gr.FillSolidRect(this.x+delta_move-1, this.y+top_tab_margin-1, this.w - inter_tab_margin+2, this.h+5+1, RGBA(255,255,255,50));
- gr.FillSolidRect(this.x+delta_move, this.y+top_tab_margin, this.w - inter_tab_margin, this.h+5, this.bg_colour_1);
- gr.FillGradRect(this.x+delta_move, this.y+top_tab_margin, this.w - inter_tab_margin, this.h+5, 90, 0, g_textcolor&0x35ffffff, 1.0);
- gr.GdiDrawText(this.label, g_font_headers, g_backcolor, this.x + 6 + delta_move, this.y + top_tab_margin - 0, this.w - 21 - inter_tab_margin, this.h-top_tab_margin, DT_NOPREFIX | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS);
- gr.GdiDrawText(this.label, g_font_headers, this.label_colour, this.x + 6 + delta_move, this.y + top_tab_margin - 1, this.w - 21 - inter_tab_margin, this.h-top_tab_margin, DT_NOPREFIX | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS);
- } else {
- gr.FillSolidRect(this.x+delta_move, this.y+top_tab_margin, this.w - inter_tab_margin, this.h+5-1, g_backcolor);
- gr.FillSolidRect(this.x+delta_move, this.y+top_tab_margin, this.w - inter_tab_margin, this.h+5-1, g_textcolor&0xaaffffff);
- gr.FillSolidRect(this.x+delta_move+1, this.y+top_tab_margin+1, this.w - inter_tab_margin-2, this.h+5-1, g_backcolor);
- gr.FillSolidRect(this.x+delta_move+1, this.y+top_tab_margin+1, this.w - inter_tab_margin-2, this.h+5-1, background_colour.normal);
- if(this.state==TabStates.normal){
- gr.FillGradRect(this.x+delta_move+1, this.y+top_tab_margin+1, this.w - inter_tab_margin-2, this.h+5-1, 90, g_backcolor&0x55ffffff, background_colour.normal, 1.0);
- } else {
- gr.FillGradRect(this.x+delta_move+1, this.y+top_tab_margin+1, this.w - inter_tab_margin-2, this.h+5-1, 90, background_colour.normal, g_backcolor&0x55ffffff, 1.0);
- }
- gr.FillSolidRect(this.x+delta_move, this.y+this.h-2, this.w - inter_tab_margin, 1, RGBA(0,0,0,80));
- gr.FillSolidRect(this.x+delta_move, this.y+this.h-3, this.w - inter_tab_margin, 1, RGBA(0,0,0,30));
- gr.FillSolidRect(this.x+delta_move, this.y+this.h-4, this.w - inter_tab_margin, 1, RGBA(0,0,0,10));
- gr.FillSolidRect(this.x+delta_move, this.y+this.h-1, this.w, 1, g_backcolor);
- gr.FillSolidRect(this.x+delta_move, this.y+this.h-1, this.w, 1, RGBA(0,0,0,50));
- gr.GdiDrawText(this.label, g_font_headers, g_textcolor, this.x + 6 + delta_move, this.y + top_tab_margin - 0, this.w - 20 - inter_tab_margin, this.h-top_tab_margin, DT_NOPREFIX | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS);
- gr.GdiDrawText(this.label, g_font_headers, this.label_colour, this.x + 6 + delta_move, this.y + top_tab_margin - 1, this.w - 20 - inter_tab_margin, this.h-top_tab_margin, DT_NOPREFIX | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS);
- }
- // Drawing the close tab button in the tab (only is there are more than 1 sheet !)
- this.bt_close.draw(gr, Math.floor(this.x + this.w - 14 - inter_tab_margin + delta_move), this.y + top_tab_margin + 2, 255, "");
- // autoplaylist mark
- if(fb.IsAutoPlaylist(this.id)) {
- /*
- if(this.state!=TabStates.active){
- gr.FillSolidRect(Math.ceil(this.x+delta_move), this.y+top_tab_margin, 5, 6, g_backcolor);
- gr.FillSolidRect(Math.ceil(this.x+delta_move), this.y+top_tab_margin, 5, 6, RGBA(0,0,0,10));
- gr.DrawImage(autoplaylist_marker_off, Math.ceil(this.x+delta_move), this.y+top_tab_margin, autoplaylist_marker_off.Width, autoplaylist_marker_off.Height, 0, 0, autoplaylist_marker_off.Width, autoplaylist_marker_off.Height, 0, 255);
- } else {
- gr.FillSolidRect(Math.ceil(this.x+delta_move-1), this.y+top_tab_margin-1, 6, 7, g_backcolor);
- gr.FillSolidRect(Math.ceil(this.x+delta_move-1), this.y+top_tab_margin-1, 6, 7, RGBA(0,0,0,10));
- gr.DrawImage(autoplaylist_marker_on, Math.ceil(this.x+delta_move-1), this.y+top_tab_margin-1, autoplaylist_marker_on.Width, autoplaylist_marker_on.Height, 0, 0, autoplaylist_marker_on.Width, autoplaylist_marker_on.Height, 0, 255);
- }
- */
- }
- }
- }
- // draw the dragged item
- if(g_drag) {
- // Drawing a tab
- try {
- gr.FillSolidRect(mouse_x-mytab[g_drag_source_id].w/2-1, this.y+top_tab_margin-1, this.w - inter_tab_margin+2, this.h+5+1, g_backcolor&0x77ffffff);
- gr.DrawRect(mouse_x-mytab[g_drag_source_id].w/2-0, this.y+top_tab_margin-1, this.w - inter_tab_margin+0, this.h+5+1, 1.0, g_textcolor&0x55ffffff);
- gr.GdiDrawText(mytab[g_drag_source_id].label, g_font_headers, g_backcolor, mouse_x - mytab[g_drag_source_id].w/2 + 7, this.y + top_tab_margin - 0, this.w - 13 - inter_tab_margin, this.h-top_tab_margin, DT_NOPREFIX | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS);
- gr.GdiDrawText(mytab[g_drag_source_id].label, g_font_headers, label_colour.active, mouse_x - mytab[g_drag_source_id].w/2 + 7, this.y + top_tab_margin - 1, this.w - 13 - inter_tab_margin, this.h-top_tab_margin, DT_NOPREFIX | DT_CALCRECT | DT_VCENTER | DT_END_ELLIPSIS);
- // autoplaylist mark
- if(fb.IsAutoPlaylist(mytab[g_drag_source_id].id)) {}
- } catch(e) {}
- }
- }
- this.checkstate = function (event, x, y, id) {
- this.ishover = ((x>tab_CONST.pad_left && x<ww-tab_CONST.pad_right ) && x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h)?true:false;
- this.ishoverX = ((x>tab_CONST.pad_left && x<ww-tab_CONST.pad_right) && x > this.x && x < this.x + this.w)?true:false;
- switch (event) {
- case "down":
- switch(this.state) {
- case TabStates.normal:
- break;
- case TabStates.hover:
- if(this.ishover) {
- for(i=0;i<mytab.length;i++) {
- mytab[i].state = TabStates.normal;
- }
- g_drag_source_id = this.id;
- this.state = TabStates.active;
- window.Repaint();
- }
- break;
- case TabStates.active:
- g_drag_source_id = this.id;
- break;
- }
- break;
- case "right":
- if(this.ishover) {
- playlist_context_menu(x, y, this.id);
- }
- break;
- case "up":
- switch(this.state) {
- case TabStates.normal:
- break;
- case TabStates.hover:
- if(g_drag && this.id!=g_drag_source_id) {
- fb.MovePlaylist(g_drag_source_id, this.id);
- fb.ActivePlaylist = this.id;
- refresh_playlists();
- window.Repaint();
- }
- break;
- case TabStates.active:
- fb.ActivePlaylist = this.id;
- break;
- }
- g_drag && window.Repaint();
- break;
- case "move":
- switch(this.state) {
- case TabStates.normal:
- if(g_drag) {
- if(this.ishoverX) {
- this.state = TabStates.hover;
- window.Repaint();
- }
- } else {
- if(this.ishover) {
- this.state = TabStates.hover;
- window.Repaint();
- }
- }
- break;
- case TabStates.hover:
- if(g_drag) {
- if(!this.ishoverX) {
- this.state = TabStates.normal;
- window.Repaint();
- }
- } else {
- if(!this.ishover) {
- this.state = TabStates.normal;
- window.Repaint();
- }
- }
- break;
- case TabStates.active:
- break;
- }
- if(this.ishover) {
- if(g_handles!=null) {
- var insert_index = fb.PlaylistItemCount(this.id);
- plman.InsertPlaylistItems(this.id, insert_index, g_handles, false);
- }
- g_handles = null;
- }
- break;
- case "leave":
- if(fb.ActivePlaylist != this.id) {
- this.state = TabStates.normal;
- window.Repaint();
- }
- break;
- }
- return this.state;
- }
- };
- //=================================================// Tools
- function RGB(r, g, b) {
- return (0xff000000 | (r << 16) | (g << 8) | (b))
- }
- function RGBA(r, g, b, a) {
- return ((a << 24) | (r << 16) | (g << 8) | (b))
- }
- //=================================================// Global Variables
- // Buttons global variables
- var mybutton = Array();
- var buttons_padx = 0;
- var buttons_pady = 0;
- // Tabs global variables
- var mytab = Array(new tab);
- var g_tooltip = window.CreateTooltip();
- var g_font_headers = null;
- // Common global variables
- var ww = 0;
- var wh = 0;
- var mouse_x;
- var mouse_y;
- var show_tooltip;
- var hand;
- var g_left_click = 0;
- var g_drag = false;
- var g_drag_source_id;
- var g_scrollitems_delta = 0;
- var g_scrollitems_timer = false;
- var new_pl = false;
- var timer_new_pl = false;
- var previous_active_pl = 0;
- // WSH drag and drop globals
- var g_handles = null;
- //==========================================================================/ on_size
- function on_size() {
- if (!window.Width || !window.Height) return;
- if(g_instancetype == 0) { // CUI
- window.MinWidth = 200;
- window.MinHeight = tab_CONST.height+5;
- } else if(g_instancetype == 1) { // DUI
- window.MinWidth = 200;
- window.MinHeight = tab_CONST.height+5;
- window.MaxHeight = tab_CONST.height+5;
- }
- ww = window.Width;
- wh = window.Height;
- if(ww==0 && wh==0) return true;
- get_font();
- get_colors();
- refresh_buttons();
- refresh_playlists();
- }
- //==========================================================================/ on_paint
- function on_paint(gr) {
- var i;
- previous_active_pl = fb.ActivePlaylist;
- // draw panel background
- gr.FillSolidRect(0, 0, ww, wh, g_backcolor);
- gr.FillSolidRect(0, 0, ww, tab_CONST.height, RGBA(255,255,255,19));
- //gr.FillGradRect(0, tab_CONST.height-5, ww, 4, 90, 0, RGBA(0,0,0,40), 1.0);
- gr.FillSolidRect(0, tab_CONST.height-2, ww, 1, RGBA(0,0,0,30));
- gr.FillSolidRect(0, tab_CONST.height-1, ww, 1, g_backcolor);
- gr.FillSolidRect(0, tab_CONST.height-1, ww, 1, RGBA(0,0,0,50));
- // if no scroll tabs, add playlist button have to be draw under the tabs
- if(!tab_CONST.scroll && !g_drag) {
- mybutton[0].draw(gr, tab_CONST.pos + tab_CONST.pad_left + (mytab.length * (tab_CONST.width + 0)), tab_CONST.pad_top, 255);
- }
- // draw the tabs
- for (i=0; i < mytab.length; i++) {
- mytab[i].draw(gr, 0, tab_CONST.pad_top, 255);
- }
- // draw undertab background
- gr.FillSolidRect(0, tab_CONST.height+tab_CONST.pad_top, ww, wh-tab_CONST.height, g_backcolor);
- gr.FillSolidRect(0, tab_CONST.height+tab_CONST.pad_top, ww, wh-tab_CONST.height, g_textcolor&0x25ffffff);
- gr.FillGradRect(0, tab_CONST.height+tab_CONST.pad_top-1, ww, wh-tab_CONST.height+1, 90, 0, g_backcolor);
- //draw buttons
- for (i = 0; i < mybutton.length; i++) {
- switch (i) {
- case 0:
- // Add a new playlist
- if(tab_CONST.scroll) {
- if (tab_CONST.scroll) {
- mybutton[i].draw(gr, ww - bt_w*2, tab_CONST.pad_top, 255);
- } else {
- mybutton[i].draw(gr, tab_CONST.pos + tab_CONST.pad_left + (mytab.length * (tab_CONST.width + 0)), tab_CONST.pad_top, 255);
- }
- }
- break;
- case 1:
- if (!tab_CONST.scroll) gr.FillGradRect(ww - bt_w - 3, tab_CONST.pad_top, 6, tab_CONST.height, 0, 0, RGB(0,0,0), 1.0);
- mybutton[i].draw(gr, ww - bt_w, tab_CONST.pad_top, 255);
- break;
- case 2:
- if (tab_CONST.scroll) {
- gr.FillGradRect(bt_w-4, tab_CONST.pad_top, 6, tab_CONST.height, 0, RGB(0,0,0), 0, 1.0);
- mybutton[i].draw(gr, 0, tab_CONST.pad_top, 255);
- }
- break;
- case 3:
- if (tab_CONST.scroll) {
- gr.FillGradRect(ww - bt_w*3 - 3, tab_CONST.pad_top, 6, tab_CONST.height, 0, 0, RGB(0,0,0), 1.0);
- mybutton[i].draw(gr, ww - bt_w*3, tab_CONST.pad_top, 255);
- }
- break;
- }
- }
- }
- //==========================================================================/ playlists_changed
- function on_playlists_changed() {
- var prev_total_pl = mytab.length;
- refresh_playlists();
- if(prev_total_pl<fb.PlaylistCount) {
- new_pl = true;
- if(!timer_new_pl) {
- timer_new_pl = window.SetTimeout(function() {
- fb.ActivePlaylist = mytab.length-1;
- if(tab_CONST.scroll) {
- scroll_to_right_limit();
- } else {
- window.Repaint();
- }
- timer_new_pl = false;
- }, 10);
- }
- }
- window.Repaint();
- }
- function on_playlist_switch() {
- refresh_playlists();
- window.Repaint();
- }
- //==========================================================================/ lbtn_down
- function on_mouse_lbtn_down(x, y) {
- var i;
- for (i = 0; i < mybutton.length; i++) {
- mybutton[i].checkstate("down", x, y, i);
- }
- if (x > tab_CONST.pad_left && x < ww - tab_CONST.pad_right) {
- for (i=0; i < mytab.length; i++) {
- if(mytab[i].bt_close.checkstate("down", x, y, i)!=ButtonStates.down) {
- mytab[i].checkstate("down", x, y, i);
- if(mytab[i].ishover) g_left_click = 1;
- }
- }
- }
- }
- function on_mouse_lbtn_dblclk(x, y, mask) {
- on_mouse_lbtn_down(x, y);
- }
- //==========================================================================/ lbtn_up
- function on_mouse_lbtn_up(x, y) {
- var i;
- var j;
- var active_pl;
- var nb_pl;
- var top_refresh_columns_width = 0;
- new_pl = false;
- g_left_click = 0;
- // buttons actions
- if(!g_drag) {
- for (i = 0; i < mybutton.length; i++) {
- switch (i) {
- case 0:
- if (mybutton[i].checkstate("up", x, y, i) == ButtonStates.hover) {
- fb.CreatePlaylist(mytab.length, "");
- new_pl = true;
- if(!timer_new_pl) {
- timer_new_pl = window.SetTimeout(function() {
- fb.ActivePlaylist = mytab.length-1;
- if(tab_CONST.scroll) {
- scroll_to_right_limit();
- } else {
- window.Repaint();
- }
- timer_new_pl = false;
- }, 10);
- }
- }
- break;
- case 1:
- if (mybutton[i].checkstate("up", x, y, i) == ButtonStates.hover) {
- playlist_command_menu(x, y, i);
- }
- break;
- case 2:
- if (mybutton[i].checkstate("up", x, y, i) == ButtonStates.hover) {
- on_mouse_wheel(1);
- }
- break;
- case 3:
- if (mybutton[i].checkstate("up", x, y, i) == ButtonStates.hover) {
- on_mouse_wheel(-1);
- }
- break;
- }
- }
- } else {
- window.Repaint();
- }
- for (i=0; i < mytab.length; i++) {
- if (mytab[i].bt_close.checkstate("up", x, y, i) == ButtonStates.hover) {
- active_pl = fb.ActivePlaylist;
- nb_pl = mytab.length;
- mytab.splice(i,1);
- fb.RemovePlaylist(i);
- if (i == active_pl) {
- if (nb_pl > 1) {
- if(i == nb_pl - 1) {
- fb.ActivePlaylist = i - 1;
- } else {
- fb.ActivePlaylist = active_pl;
- }
- }
- }
- if (tab_CONST.scroll) {
- tab_CONST.pos = tab_CONST.pos < tab_CONST.min_width * -1 ? tab_CONST.pos + tab_CONST.min_width + 0 : tab_CONST.pos;
- } else {
- tab_CONST.pos = 0;
- }
- refresh_playlists();
- } else {
- mytab[i].checkstate("up", x, y, i);
- }
- }
- g_drag = false;
- }
- //==========================================================================/ mouse_move
- function on_mouse_move(x, y) {
- var i;
- if(!g_drag && x==mouse_x && y==mouse_y) return true;
- g_drag = (g_left_click>2)?true:false;
- if(g_left_click>0) g_left_click++;
- hand = false;
- if(!g_drag) {
- for (i=0; i < mybutton.length; i++) {
- mybutton[i].checkstate("move", x, y, i);
- if(mybutton[i].ishover == true) hand = true;
- }
- }
- if (x > 0 && x < ww) {
- show_tooltip = false;
- for (i=0; i < mytab.length; i++) {
- mytab[i].checkstate("move", x, y, i);
- if(mytab[i].ishover) {
- show_tooltip = true;
- var total_item = fb.PlaylistItemCount(i);
- total_item = (total_item>1?" - ["+total_item+" items]":(total_item>0?" [1 item]":" [no item]"));
- if(g_tooltip.Text != mytab[i].label+total_item) {
- g_tooltip.Deactivate();
- g_tooltip.Text = mytab[i].label+total_item;
- }
- }
- if (x > tab_CONST.pad_left && x < ww - tab_CONST.pad_right) {
- mytab[i].bt_close.checkstate("move", x, y, i);
- if(mytab[i].bt_close.ishover) hand=true;
- } else {
- mytab[i].bt_close.state = ButtonStates.normal;
- mytab[i].bt_close.repaint();
- }
- }
- if(show_tooltip) {
- g_tooltip.Activate();
- } else {
- g_tooltip.Deactivate();
- g_tooltip.Text="";
- }
- } else {
- g_tooltip.Deactivate();
- g_tooltip.Text="";
- }
- // tab item scroll on mouse drag item over boundaries
- if((g_drag && !g_scrollitems_timer) || elp_dragging) {
- if(tab_CONST.scroll && x<tab_CONST.pad_left) {
- g_scrollitems_delta = 1;
- if(elp_dragging) {
- on_mouse_wheel(g_scrollitems_delta);
- window.Repaint();
- } else {
- g_scrollitems_timer = window.SetTimeout(function() {
- on_mouse_wheel(g_scrollitems_delta);
- g_scrollitems_timer = false;
- window.Repaint();
- // if drag on, we call again mouse_move to check if scroll item is still invoked or not
- if(g_drag || elp_dragging) on_mouse_move(mouse_x, mouse_y);
- }, 80);
- }
- } else if (tab_CONST.scroll && x>ww-tab_CONST.pad_right) {
- g_scrollitems_delta = -1;
- if(elp_dragging) {
- on_mouse_wheel(g_scrollitems_delta);
- window.Repaint();
- } else {
- g_scrollitems_timer = window.SetTimeout(function() {
- on_mouse_wheel(g_scrollitems_delta);
- g_scrollitems_timer = false;
- window.Repaint();
- // if drag on, we call again mouse_move to check if scroll item is still invoked or not
- if(g_drag || elp_dragging) on_mouse_move(mouse_x, mouse_y);
- }, 80);
- }
- } else {
- // timer reset if no more scroll invoked
- g_scrollitems_timer && window.ClearTimeout(g_scrollitems_timer);
- g_scrollitems_timer = false;
- // repaint action when no scroll invoked
- window.Repaint();
- }
- }
- // when drag stop, timer is to reset
- if(!g_drag && !elp_dragging) {
- g_scrollitems_timer && window.ClearTimeout(g_scrollitems_timer);
- g_scrollitems_timer = false;
- }
- var mouseCursor = hand?IDC_HAND:IDC_ARROW;
- window.SetCursor(mouseCursor);
- g_handles = null;
- mouse_x = x;
- mouse_y = y;
- }
- //==========================================================================/ mouse_leave
- function on_mouse_leave() {
- var i;
- for (i = 0; i < mybutton.length; i++) {
- mybutton[i].checkstate("leave", 0, 0, i);
- }
- for (i = 0; i < mytab.length; i++) {
- mytab[i].checkstate("leave", 0, 0, i);
- mytab[i].bt_close.checkstate("leave", 0, 0, i);
- }
- g_tooltip.Text="";
- }
- function on_font_changed() {
- get_font();
- window.Repaint();
- }
- function on_colors_changed() {
- get_colors();
- refresh_buttons();
- refresh_playlists();
- window.Repaint();
- }
- // ===============================================================================/ playlist context menu
- function playlist_context_menu(x, y, id) {
- var MF_SEPARATOR = 0x00000800;
- var MF_STRING = 0x00000000;
- var _menu = window.CreatePopupMenu();
- var idx;
- _menu.AppendMenuItem(MF_STRING, 1, "Rename this playlist");
- if(fb.IsAutoPlaylist(id) && mytab[id].label.substring(0,13)!="#Quicksearch*") _menu.AppendMenuItem(MF_STRING, 3, "Edit Autoplaylist Properties");
- idx = _menu.TrackPopupMenu(x, y);
- switch (idx) {
- case 1:
- var playlistname = InputBox("Rename the playlist: "+mytab[id].label, "Rename a playlist", mytab[id].label);
- if(!playlistname || playlistname == "") playlistname = mytab[id].label;
- if (playlistname.length > 1 || (playlistname.length == 1 && (playlistname >= "a" && playlistname <= "z") || (playlistname >= "A" && playlistname <= "Z") || (playlistname >= "0" && playlistname <= "9"))) {
- mytab[id].label = playlistname;
- fb.RenamePlaylist(id, playlistname);
- window.Repaint();
- }
- break;
- case 2:
- break;
- case 3:
- fb.ShowAutoPlaylistUI(id);
- break;
- }
- _menu.Dispose();
- return true;
- }
- // ===============================================================================/ playlist command menu
- function playlist_command_menu(x, y, id) {
- var MF_SEPARATOR = 0x00000800;
- var MF_STRING = 0x00000000;
- var _menu = window.CreatePopupMenu();
- var idx;
- var ind;
- ind=fb.ActivePlaylist;
- _menu.AppendMenuItem(MF_STRING, 1, "Show active playlist tab");
- _menu.AppendMenuItem(MF_SEPARATOR, 0, "");
- _menu.AppendMenuItem(MF_STRING, 2, "Rename the active Playlist");
- _menu.AppendMenuItem(MF_STRING, 3, "Save the active Playlist");
- _menu.AppendMenuItem(MF_STRING, 4, "Load a Playlist");
- _menu.AppendMenuItem(MF_STRING, 5, "Open Playlist Manager");
- idx = _menu.TrackPopupMenu(x, y);
- switch (idx) {
- case 1:
- show_active_playlist();
- break;
- case 2:
- playlistname = InputBox("Rename the playlist: "+mytab[ind].label, "Rename a playlist", mytab[ind].label);
- if(!playlistname || playlistname == "") playlistname = mytab[ind].label;
- if (playlistname.length > 1 || (playlistname.length == 1 && (playlistname >= "a" && playlistname <= "z") || (playlistname >= "A" && playlistname <= "Z") || (playlistname >= "0" && playlistname <= "9"))) {
- mytab[ind].label = playlistname;
- fb.RenamePlaylist(ind, playlistname);
- window.Repaint();
- }
- break;
- case 3:
- fb.RunMainMenuCommand("File/Save Playlist...");
- break;
- case 4:
- fb.RunMainMenuCommand("File/Load Playlist...");
- break;
- case 5:
- fb.RunMainMenuCommand("View/Playlist Manager");
- break;
- }
- _menu.Dispose();
- return true;
- }
- //==========================================================================/ refresh_playlists
- function refresh_playlists() {
- var i;
- tab_CONST.scroll = false;
- tab_CONST.pad_left = tab_CONST.pad_left_default;
- tab_CONST.pad_right = bt_w*2;
- // reset array
- mytab.splice(0, mytab.length);
- // init of the tabs (one tab per playlist found)
- for (i=0; i < fb.PlaylistCount; i++) {
- mytab.push(new tab);
- mytab[i].create(fb.GetPlaylistName(i), i);
- }
- var free_width = ww - tab_CONST.pad_left - tab_CONST.pad_right;
- tab_CONST.width = free_width / mytab.length;
- // force tab width to the minimal width if smaller (then horizontal scroll will be activated!)
- if (tab_CONST.width < tab_CONST.min_width) {
- tab_CONST.scroll = true;
- tab_CONST.pad_left = bt_w + 2;
- tab_CONST.pad_right = bt_w*3 - inter_tab_margin*0;
- tab_CONST.width = tab_CONST.min_width;
- } else {
- tab_CONST.pos = 0;
- tab_CONST.scroll = false;
- tab_CONST.pad_left = tab_CONST.pad_left_default ;
- tab_CONST.pad_right = bt_w*2;
- if(tab_CONST.width > tab_CONST.max_width) tab_CONST.width = tab_CONST.max_width;
- }
- check_all_buttons();
- }
- //==========================================================================/ rbtn_down
- function on_mouse_rbtn_down(x, y) {
- var i;
- if (x > tab_CONST.pad_left && x < ww - tab_CONST.pad_right) {
- for (i = 0; i < mytab.length; i++) {
- mytab[i].checkstate("right", x, y, i);
- }
- }
- }
- //==========================================================================/ mouse_wheel
- function on_mouse_wheel(delta) {
- var i;
- var ex_pos = tab_CONST.pos;
- var total_area = tab_CONST.width * mytab.length;
- var visible_area = ww - tab_CONST.pad_left - tab_CONST.pad_right;
- if (total_area > visible_area) {
- var delta_area_right = total_area - visible_area + tab_CONST.pos;
- var scroll_area_right = delta_area_right>=tab_CONST.scroll_step?tab_CONST.scroll_step:delta_area_right;
- var delta_area_left = tab_CONST.pos * -1;
- var scroll_area_left = delta_area_left>=tab_CONST.scroll_step?tab_CONST.scroll_step:delta_area_left;
- if (delta < 0) {
- tab_CONST.pos = tab_CONST.pos - scroll_area_right;
- } else {
- tab_CONST.pos = tab_CONST.pos + scroll_area_left;
- }
- } else {
- tab_CONST.scroll = false;
- tab_CONST.pos = 0;
- }
- on_mouse_move(mouse_x, mouse_y);
- window.Repaint();
- }
- function scroll_to_right_limit() {
- var total_area = tab_CONST.width * mytab.length+1;
- var visible_area = ww - tab_CONST.pad_left - tab_CONST.pad_right;
- tab_CONST.pos = 0 - (total_area - visible_area);
- tab_CONST.pos++;
- window.Repaint();
- }
- function show_active_playlist() {
- var visible_area = ww - tab_CONST.pad_left - tab_CONST.pad_right;
- if(tab_CONST.scroll) {
- if(mytab[fb.ActivePlaylist].x < tab_CONST.pad_left) {
- tab_CONST.pos += mytab[fb.ActivePlaylist].x*-1 + tab_CONST.pad_left;
- }
- if(mytab[fb.ActivePlaylist].x+tab_CONST.width > ww-tab_CONST.pad_right) {
- tab_CONST.pos -= (mytab[fb.ActivePlaylist].x - visible_area + tab_CONST.pad_right + 08);
- }
- }
- window.Repaint();
- }
- //=================================================// Keyboard Callbacks
- function on_key_up(vkey) {
- }
- function on_key_down(vkey) {
- var mask = GetKeyboardMask();
- var focus_id;
- if (mask == KMask.none) {
- switch (vkey) {
- case VK_END:
- if(tab_CONST.scroll) {
- tab_CONST.pos = 0 - ((mytab.length*tab_CONST.width) - (ww-tab_CONST.pad_left-tab_CONST.pad_right));
- window.Repaint();
- }
- break;
- case VK_HOME:
- if(tab_CONST.scroll) {
- tab_CONST.pos = 0;
- window.Repaint();
- }
- break;
- }
- } else {
- switch(mask) {
- case KMask.ctrl:
- if(vkey==65) { // CTRL+A
- fb.RunMainMenuCommand("Edit/Select all");
- window.Repaint();
- }
- if(vkey==70) { // CTRL+F
- fb.RunMainMenuCommand("Edit/Search");
- }
- 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...");
- }
- break;
- case KMask.alt:
- if(vkey==65) { // ALT+A
- fb.RunMainMenuCommand("View/Always on Top");
- }
- break;
- }
- }
- }
- function on_notify_data(name, info) {
- switch(name) {
- case "WSH_playlist_drag_drop": // send from a WSH playlist panel to simulate a drag and drop feature
- g_handles = info;
- break;
- }
- }
- //=================================================// Drag'n'Drop Callbacks
- var elp_dragging = false;
- function on_drag_enter() {
- elp_dragging = true;
- }
- function on_drag_leave() {
- elp_dragging = false;
- }
- function on_drag_over(action, x, y, mask) {
- on_mouse_move(x, y);
- }
- function GetIDfromXpos(x) {
- var idx = Math.floor((x - tab_CONST.pos - tab_CONST.pad_left) / tab_CONST.width);
- return idx;
- }
- function on_drag_drop(action, x, y, mask) {
- elp_dragging = false;
- var idx = GetIDfromXpos(x);
- // We are going to process the dropped items to a playlist
- action.ToPlaylist();
- action.Playlist = idx;
- action.ToSelect = false;
- }
- function check_all_buttons() {
- if(tab_CONST.scroll) {
- mybutton[0] = new button(newpl_img_off, newpl_img_ov, newpl_img_ov);
- } else {
- mybutton[0] = new button(newtab_img_off, newtab_img_ov, newtab_img_ov);
- }
- if(tab_CONST.scroll) {
- mybutton[1] = new button(plmenu1_img_off, plmenu1_img_ov, plmenu1_img_ov);
- } else {
- mybutton[1] = new button(plmenu2_img_off, plmenu2_img_ov, plmenu2_img_ov);
- }
- mybutton[2] = new button(scroll_left_img_off, scroll_left_img_ov, scroll_left_img_ov);
- mybutton[3] = new button(scroll_right_img_off, scroll_right_img_ov, scroll_right_img_ov);
- }
- //=================================================// Draw buttons
- function refresh_buttons() {
- var i;
- var gb;
- var gui_font;
- // ***
- newtab_img_off = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = newtab_img_off.GetGraphics();
- gb.FillSolidRect(0, top_tab_margin, newtab_img_off.Width, newtab_img_off.Height+5-top_tab_margin, g_backcolor);
- gb.FillSolidRect(0, top_tab_margin, newtab_img_off.Width, newtab_img_off.Height+5-top_tab_margin, g_textcolor&0xaaffffff);
- gb.FillSolidRect(1, top_tab_margin+1, newtab_img_off.Width-2, newtab_img_off.Height+5-top_tab_margin-1, g_backcolor);
- gb.FillSolidRect(1, top_tab_margin+1, newtab_img_off.Width-2, newtab_img_off.Height+5-top_tab_margin-1, background_colour.normal);
- gb.FillGradRect(1, top_tab_margin+1, newtab_img_off.Width-2, newtab_img_off.Height+5-top_tab_margin-1, 90, g_backcolor&0x55ffffff, background_colour.normal, 1.0);
- gb.FillSolidRect(0, newtab_img_off.Height-2, newtab_img_off.Width, 1, RGBA(0,0,0,80));
- gb.FillSolidRect(0, newtab_img_off.Height-3, newtab_img_off.Width, 1, RGBA(0,0,0,30));
- gb.FillSolidRect(0, newtab_img_off.Height-4, newtab_img_off.Width, 1, RGBA(0,0,0,10));
- gb.FillSolidRect(0, newtab_img_off.Height-1, newtab_img_off.Width, 1, g_backcolor);
- gb.FillSolidRect(0, newtab_img_off.Height-1, newtab_img_off.Width, 1, RGBA(0,0,0,50));
- gui_font = gdi.Font("guifx v2 transports", 12, 0);
- gb.SetTextRenderingHint(3);
- gb.DrawString("=", gui_font, g_textcolor, 0, top_tab_margin-1, newtab_img_off.Width, newtab_img_off.Height-top_tab_margin, cc_stringformat);
- gb.DrawString("=", gui_font, label_colour.normal, 0, top_tab_margin-2, newtab_img_off.Width, newtab_img_off.Height-top_tab_margin, cc_stringformat);
- newtab_img_off.ReleaseGraphics(gb);
- newtab_img_ov = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = newtab_img_ov.GetGraphics();
- gb.FillSolidRect(0, 1, newtab_img_ov.Width, newtab_img_ov.Height+5-1, g_backcolor);
- gb.FillSolidRect(0, 1, newtab_img_ov.Width, newtab_img_ov.Height+5-1, g_textcolor&0xaaffffff);
- gb.FillSolidRect(1, 2, newtab_img_ov.Width-2, newtab_img_ov.Height+5-2, g_backcolor);
- gb.FillSolidRect(1, 2, newtab_img_ov.Width-2, newtab_img_ov.Height+5-2, background_colour.normal);
- gb.FillGradRect(1, 2, newtab_img_ov.Width-2, newtab_img_ov.Height+5-2, 90, background_colour.normal, g_backcolor&0x55ffffff, 1.0);
- gb.FillSolidRect(0, newtab_img_ov.Height-2, newtab_img_ov.Width, 1, RGBA(0,0,0,80));
- gb.FillSolidRect(0, newtab_img_ov.Height-3, newtab_img_ov.Width, 1, RGBA(0,0,0,30));
- gb.FillSolidRect(0, newtab_img_ov.Height-4, newtab_img_ov.Width, 1, RGBA(0,0,0,10));
- gb.FillSolidRect(0, newtab_img_ov.Height-1, newtab_img_ov.Width, 1, g_backcolor);
- gb.FillSolidRect(0, newtab_img_ov.Height-1, newtab_img_ov.Width, 1, RGBA(0,0,0,50));
- gui_font = gdi.Font("guifx v2 transports", 14, 0);
- gb.SetTextRenderingHint(3);
- gb.DrawString("=", gui_font, g_textcolor, 0, top_tab_margin-1, newtab_img_ov.Width, newtab_img_ov.Height-top_tab_margin, cc_stringformat);
- gb.DrawString("=", gui_font, label_colour.hover, 0, top_tab_margin-2, newtab_img_ov.Width, newtab_img_ov.Height-top_tab_margin, cc_stringformat);
- newtab_img_ov.ReleaseGraphics(gb);
- newpl_img_off = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = newpl_img_off.GetGraphics();
- gb.FillSolidRect(0, 0, newpl_img_off.Width, newpl_img_off.Height, g_backcolor);
- gb.FillGradRect(0, 0, newpl_img_off.Width, newpl_img_off.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gui_font = gdi.Font("guifx v2 transports", 12, 0);
- gb.SetTextRenderingHint(3);
- gb.DrawString("=", gui_font, g_textcolor&0x55ffffff, 0, top_tab_margin+5, newpl_img_off.Width, newpl_img_off.Height, ct_stringformat);
- newpl_img_off.ReleaseGraphics(gb);
- newpl_img_ov = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = newpl_img_ov.GetGraphics();
- gb.FillSolidRect(0, 0, newpl_img_ov.Width, newpl_img_ov.Height, g_backcolor);
- gb.FillGradRect(0, 0, newpl_img_ov.Width, newpl_img_ov.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gui_font = gdi.Font("guifx v2 transports", 14, 0);
- gb.SetTextRenderingHint(3);
- gb.DrawString("=", gui_font, g_textcolor, 0, top_tab_margin+4, newpl_img_ov.Width, newpl_img_ov.Height, ct_stringformat);
- newpl_img_ov.ReleaseGraphics(gb);
- // ***
- plmenu2_img_off = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = plmenu2_img_off.GetGraphics();
- gb.FillSolidRect(0, 0, plmenu2_img_off.Width, plmenu2_img_off.Height, g_backcolor);
- gb.FillGradRect(0, 0, plmenu2_img_off.Width, plmenu2_img_off.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gb.FillGradRect(0, 0, 1, plmenu2_img_off.Height, 90, RGBA(0,0,0,0), RGBA(255,255,255,75), 0.5);
- gui_font = gdi.Font("guifx v2 transports", 13, 0);
- gb.SetTextRenderingHint(5);
- gb.DrawString("s", gui_font, g_textcolor&0x55ffffff, 0, top_tab_margin+5, plmenu2_img_off.Width, plmenu2_img_off.Height+20, ct_stringformat);
- plmenu2_img_off.ReleaseGraphics(gb);
- plmenu2_img_ov = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = plmenu2_img_ov.GetGraphics();
- gb.FillSolidRect(0, 0, plmenu2_img_ov.Width, plmenu2_img_ov.Height, g_backcolor);
- gb.FillGradRect(0, 0, plmenu2_img_ov.Width, plmenu2_img_ov.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gb.FillGradRect(0, 0, 1, plmenu2_img_off.Height, 90, RGBA(0,0,0,0), RGBA(255,255,255,75), 0.5);
- gui_font = gdi.Font("guifx v2 transports", 13, 0);
- gb.SetTextRenderingHint(5);
- gb.DrawString("s", gui_font, g_textcolor, 0, top_tab_margin+5, plmenu2_img_ov.Width, plmenu2_img_ov.Height, ct_stringformat);
- plmenu2_img_ov.ReleaseGraphics(gb);
- plmenu1_img_off = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = plmenu1_img_off.GetGraphics();
- gb.FillSolidRect(0, 0, plmenu1_img_off.Width, plmenu1_img_off.Height, g_backcolor);
- gb.FillGradRect(0, 0, plmenu1_img_off.Width, plmenu1_img_off.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gui_font = gdi.Font("guifx v2 transports", 13, 0);
- gb.SetTextRenderingHint(5);
- gb.DrawString("s", gui_font, g_textcolor&0x55ffffff, 0, top_tab_margin+5, plmenu1_img_off.Width, plmenu1_img_off.Height+20, ct_stringformat);
- plmenu1_img_off.ReleaseGraphics(gb);
- plmenu1_img_ov = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = plmenu1_img_ov.GetGraphics();
- gb.FillSolidRect(0, 0, plmenu1_img_ov.Width, plmenu1_img_ov.Height, g_backcolor);
- gb.FillGradRect(0, 0, plmenu1_img_ov.Width, plmenu1_img_ov.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gui_font = gdi.Font("guifx v2 transports", 13, 0);
- gb.SetTextRenderingHint(5);
- gb.DrawString("s", gui_font, g_textcolor, 0, top_tab_margin+5, plmenu1_img_ov.Width, plmenu1_img_ov.Height, ct_stringformat);
- plmenu1_img_ov.ReleaseGraphics(gb);
- // ***
- scroll_left_img_off = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = scroll_left_img_off.GetGraphics();
- gb.FillSolidRect(0, 0, scroll_left_img_off.Width, scroll_left_img_off.Height, g_backcolor);
- gb.FillGradRect(0, 0, scroll_left_img_off.Width, scroll_left_img_off.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gb.FillGradRect(scroll_left_img_off.Width-1, 0, 1, scroll_left_img_off.Height, 90, RGBA(0,0,0,0), RGBA(255,255,255,75), 0.5);
- gui_font = gdi.Font("guifx v2 transports", 14, 0);
- gb.SetTextRenderingHint(5);
- gb.DrawString("<", gui_font, g_textcolor&0x55ffffff, 0, top_tab_margin+4, scroll_left_img_off.Width, scroll_left_img_off.Height, ct_stringformat);
- scroll_left_img_off.ReleaseGraphics(gb);
- scroll_left_img_ov = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = scroll_left_img_ov.GetGraphics();
- gb.FillSolidRect(0, 0, scroll_left_img_ov.Width, scroll_left_img_ov.Height, g_backcolor);
- gb.FillGradRect(0, 0, scroll_left_img_ov.Width, scroll_left_img_ov.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gb.FillGradRect(scroll_left_img_off.Width-1, 0, 1, scroll_left_img_off.Height, 90, RGBA(0,0,0,0), RGBA(255,255,255,75), 0.5);
- gui_font = gdi.Font("guifx v2 transports", 14, 0);
- gb.SetTextRenderingHint(5);
- gb.DrawString("<", gui_font, g_textcolor, -1, top_tab_margin+4, scroll_left_img_ov.Width, scroll_left_img_ov.Height, ct_stringformat);
- scroll_left_img_ov.ReleaseGraphics(gb);
- scroll_right_img_off = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = scroll_right_img_off.GetGraphics();
- gb.FillSolidRect(0, 0, scroll_right_img_off.Width, scroll_right_img_off.Height, g_backcolor);
- gb.FillGradRect(0, 0, scroll_right_img_off.Width, scroll_right_img_off.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gb.FillGradRect(0, 0, 1, scroll_left_img_off.Height, 90, RGBA(0,0,0,0), RGBA(255,255,255,75), 0.5);
- gui_font = gdi.Font("guifx v2 transports", 14, 0);
- gb.SetTextRenderingHint(5);
- gb.DrawString(">", gui_font, g_textcolor&0x55ffffff, 0, top_tab_margin+4, scroll_right_img_off.Width, scroll_right_img_off.Height, ct_stringformat);
- scroll_right_img_off.ReleaseGraphics(gb);
- scroll_right_img_ov = gdi.CreateImage(bt_w, tab_CONST.height);
- gb = scroll_right_img_ov.GetGraphics();
- gb.FillSolidRect(0, 0, scroll_right_img_ov.Width, scroll_right_img_ov.Height, g_backcolor);
- gb.FillGradRect(0, 0, scroll_right_img_ov.Width, scroll_right_img_ov.Height, 90, 0, g_textcolor&0x28ffffff, 1.0);
- gb.FillGradRect(0, 0, 1, scroll_left_img_off.Height, 90, RGBA(0,0,0,0), RGBA(255,255,255,75), 0.5);
- gui_font = gdi.Font("guifx v2 transports", 14, 0);
- gb.SetTextRenderingHint(5);
- gb.DrawString(">", gui_font, g_textcolor, 1, top_tab_margin+4, scroll_right_img_ov.Width, scroll_right_img_ov.Height, ct_stringformat);
- scroll_right_img_ov.ReleaseGraphics(gb);
- // ***
- close_img_off = gdi.CreateImage(12, 12);
- gb = close_img_off.GetGraphics();
- gb.SetSmoothingMode(2);
- //gb.FillEllipse(0, 0, 11, 11, background_colour.normal);
- gb.FillRoundRect(1, 1, 9, 9, 1, 1, background_colour.normal);
- gb.DrawLine(3, 3, 8, 8, 1.0, label_colour.normal);
- gb.DrawLine(8, 3, 3, 8, 1.0, label_colour.normal);
- close_img_off.ReleaseGraphics(gb);
- close_img_ov = gdi.CreateImage(12, 12);
- gb = close_img_ov.GetGraphics();
- gb.SetSmoothingMode(2);
- //gb.FillEllipse(0, 0, 11, 11, RGB(210, 050, 050));
- gb.FillRoundRect(1, 1, 9, 9, 1, 1, RGB(210, 050, 050));
- gb.DrawLine(3, 3, 8, 8, 1.0, RGB(240, 240, 240));
- gb.DrawLine(8, 3, 3, 8, 1.0, RGB(240, 240, 240));
- close_img_ov.ReleaseGraphics(gb);
- // ***
- autoplaylist_marker_off = gdi.CreateImage(7, 7);
- gb = autoplaylist_marker_off.GetGraphics();
- gb.SetSmoothingMode(2);
- //gb.FillSolidRect(0, 0, 6, 7, g_backcolor);
- var points = Array(0,4, 4,0, 4,5, 0,5);
- gb.FillPolygon(g_textcolor, 0, points);
- gb.FillPolygon(RGBA(255,255,255,50), 0, points);
- gb.DrawPolygon(g_textcolor&0xbbffffff, 1.0, points);
- gb.DrawPolygon(RGBA(255,255,255,50), 1.0, points);
- gb.DrawLine(0,6,5,6,1.0,RGBA(0,0,0,100));
- gb.DrawLine(5,0,5,5,1.0,RGBA(0,0,0,100));
- autoplaylist_marker_off.ReleaseGraphics(gb);
- autoplaylist_marker_on = gdi.CreateImage(8, 8);
- gb = autoplaylist_marker_on.GetGraphics();
- gb.SetSmoothingMode(2);
- //gb.FillSolidRect(0, 0, 6, 7, g_backcolor);
- var points = Array(0,5, 5,0, 5,6, 0,6);
- gb.FillPolygon(g_backcolor, 0, points);
- gb.DrawPolygon(RGBA(255,255,255,50), 1.0, points);
- gb.DrawPolygon(g_textcolor&0x25ffffff, 1.0, points);
- gb.DrawLine(0,7,6,7,1.0,RGBA(0,0,0,75));
- gb.DrawLine(6,0,6,6,1.0,RGBA(0,0,0,75));
- autoplaylist_marker_on.ReleaseGraphics(gb);
- // initialize button's attributs
- for (i = 0; i < 4; i++) {
- switch (i) {
- case 0: // add new playlist button
- mybutton.push(new button(newtab_img_off, newtab_img_ov, newtab_img_ov));
- break;
- case 1: // menu
- if(tab_CONST.scroll) {
- mybutton.push(new button(plmenu1_img_off, plmenu1_img_ov, plmenu1_img_ov));
- } else {
- mybutton.push(new button(plmenu2_img_off, plmenu2_img_ov, plmenu2_img_ov));
- }
- break;
- case 2: // scroll left
- mybutton.push(new button(scroll_left_img_off, scroll_left_img_ov, scroll_left_img_ov));
- break;
- case 3: // scroll right
- mybutton.push(new button(scroll_right_img_off, scroll_right_img_ov, scroll_right_img_ov));
- break;
- }
- }
- CollectGarbage();
- }
- //==========================================================================/ on_mouse_right_button
- function on_mouse_rbtn_up(x, y) {
- //return true;
- }
- //==========================================================================/ Get Colors & Fonts
- function get_colors() {
- if(g_instancetype == 0) { // CUI
- g_textcolor = window.GetColorCUI(ColorTypeCUI.text);
- g_textcolor_sel = window.GetColorCUI(ColorTypeCUI.selection_text);
- g_textcolor_hl = window.GetColorCUI(ColorTypeCUI.active_item_frame);
- g_backcolor = window.GetColorCUI(ColorTypeCUI.background);
- } else if(g_instancetype == 1) { // DUI
- g_textcolor = window.GetColorDUI(ColorTypeDUI.text);
- g_textcolor_sel = window.GetColorDUI(ColorTypeDUI.selection);
- g_textcolor_hl = window.GetColorDUI(ColorTypeDUI.highlight);
- g_backcolor = window.GetColorDUI(ColorTypeDUI.background);
- };
- // Custom colors set in Properties of the panel
- if(panel.custom_colors) {
- try{
- if(panel.custom_textcolor.length>0) g_textcolor = eval(panel.custom_textcolor);
- if(panel.custom_textcolor_selection.length>0) {
- g_textcolor_sel = eval(panel.custom_textcolor_selection);
- g_backcolor_sel = g_textcolor_sel;
- };
- if(panel.custom_backcolor.length>0) g_backcolor = eval(panel.custom_backcolor);
- if(panel.custom_textcolor_highlight.length>0) g_textcolor_hl = eval(panel.custom_textcolor_highlight);
- } catch(e) {};
- };
- background_colour.normal = g_textcolor&0xbbffffff;
- background_colour.hover = g_textcolor&0xbccfffff;
- background_colour.active = g_backcolor;
- background_colour.drag = g_backcolor;
- label_colour.normal = g_backcolor;
- label_colour.hover = g_backcolor&0xeeffffff;
- label_colour.active = g_textcolor&0xeeffffff;
- label_colour.drag = g_textcolor&0xeeffffff;
- }
- function get_font() {
- if (g_instancetype == 0) { // CUI
- g_font_headers = window.GetFontCUI(FontTypeCUI.labels);
- } else if (g_instancetype == 1) { // DUI
- g_font_headers = window.GetFontDUI(FontTypeDUI.tabs);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement