Lucky Luciano
Try out this Seekbar config in a WSH panel and see what it does for you (edit it if you like) . . .
// ================================================================
// Script for foobar2000 component "WSH Panel Mod"
// Description........: Horizontal seekbar with 1-second refresh intervals, time display, and mouse hover effects: tooltips and glowing panel edges
// Author.............: Maxim Terpilovsky (http://terpilovsky.ru)
//
// this edition modified by derty2
// ================================================================
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_SINGLELINE = 0x00000020;
var DT_CALCRECT = 0x00000400;
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); } //---orig---> 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)); }
function TimeFmt(t) {
var zpad = function(n) {
var str = n.toString();
return (str.length<2) ? "0"+str : str;
}
var h = Math.floor(t/3600); t-=h*3600;
var m = Math.floor(t/60); t-=m*60;
var s = Math.floor(t);
if(h>0) return h.toString()+":"+zpad(m)+":"+zpad(s);
return m.toString()+":"+zpad(s);
}
//----------------------------------------------------------------------------
// gdi.Font is changed, the last paramter is style flags
// FontStyleRegular = 0,
// FontStyleBold = 1,
// FontStyleItalic = 2,
// FontStyleBoldItalic = 3,
// FontStyleUnderline = 4,
// FontStyleStrikeout = 8
// Here we are using 0, meaning FontStyleRegular
if ( utils.CheckFont( "Verdana" ) ) { //---orig---> if ( utils.CheckFont( "Segoe UI" ) ) {
var g_font = gdi.Font("Verdana", 11, 2); //---orig---> var g_font = gdi.Font("Segoe UI", 11);
} else {
var g_font = gdi.Font("Tahoma", 12);
}
var g_titlefmt = fb.TitleFormat("%playback_time% / %length%"); //--orig--> //var g_titlefmt = fb.TitleFormat("$if(%ispaused%,Paused '//' ,)[%artist% - %title% ]%playback_time% / %length%");
var g_fileinfo = null;
//---------------------------- COLOR SCHEMES FOR TIME ELAPSED BAR
//var g_colors = new Array(RGB(0,120,0), RGB(0,110,0), RGB(0,75,0), RGB(0,65,0));
//var g_colors = new Array(RGB(105,125,160), RGB(85,105,160), RGB(46,48,63), RGB(46,48,63));
//var g_colors = new Array(RGB(64,54,39), RGB(162,98,10), RGB(88,70,44), RGB(88,70,44));
//var g_colors = new Array(RGB(6,53,46), RGB(34,28,0), RGB(0,120,30), RGB(100,162,95));
//var g_colors = new Array(RGB(0,50,0), RGB(120,10,90), RGB(40,0,40), RGB(46,48,63));
var g_colors = new Array(RGB(0,0,0), RGB(0,0,0), RGB(0,0,0), RGB(46,48,63));
var g_drag = 0;
var g_drag_seek = 0;
var g_hover_seek;
var g_hover;
var g_clicked = 0;
//------------------------------------------------------------------ function on_paint(gr) START
function on_paint(gr){
var ww = window.Width;
var wh = window.Height;
var spos = 0;
var length = fb.PlaybackLength;
var stxt;
gr.SetSmoothingMode(2);
if(length <= 0) { stxt = "0:00 / 0:00"; }
if(length > 0) {
if ( g_drag && g_drag_seek ) {
spos = window.Width * g_drag_seek;
stxt = "Seek " + TimeFmt(g_drag_seek * length) + " / " + TimeFmt(length);
}
else if ( g_drag ) {
spos = window.Width;
stxt = "Seek " + TimeFmt(g_drag_seek * length) + " / " + TimeFmt(length);
}
spos = window.Width * (fb.PlaybackTime / length);
stxt = g_titlefmt.Eval();
}
else if ( fb.PlaybackTime ) { stxt = "Streaming..."; }
gr.FillSolidRect(0, 80, ww-20, wh+20, RGB(0,0,0)); //---orig---> gr.FillSolidRect(0, 0, ww, wh, RGB(120,120,120));
gr.FillGradRect( 0, 0, spos, wh, 10, g_colors[2], g_colors[1], g_colors[1]); //---orig---> gr.FillGradRect( 0, 0, spos, wh, 90, g_colors[0], g_colors[2]);
//--- fills unused space with color:
// gr.FillGradRect( spos, 0, ww-spos, wh, 90, RGB(100,100,100), RGB(140,140,140)); <<<<<<<<<<<< original
// gr.FillGradRect( spos, 0, ww-spos, wh, 0, RGB(64,70,85), RGB(80,70,85)); <<<<<<<<<<<< previous = mid-grey
gr.FillGradRect( spos, 0, ww-spos, wh, -90, RGB(20,20,20), RGB(40,40,40));
gr.GdiDrawText(stxt, g_font, RGB(214,147,95), 0, 0, ww, wh, DT_CENTER | DT_VCENTER | DT_SINGLELINE); //--orig: gr.GdiDrawText(stxt, g_font, RGB(255,255,255), 0, 0, ww, wh, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
gr.DrawRect( ww-1, 0, 0, wh, 1.0, RGB(0,0,0));
//--- draws thin border
// gr.DrawRect(-1,0, ww+1, wh-1, 1.0, RGB(150,150,150)); <<<<<<<<<<<< original
// gr.DrawRect(0, 0, ww-1, wh-1, 1.0, RGB(116,90,90)); <<<<<<<<<<<< my previous = orange-grey
// gr.DrawRect(0, 0, ww-1, wh-1, 1.0, RGB(64,77,85)); <<<<<<<<<<<< previous
gr.DrawRect(0, 0, ww-1, wh-1, 1.0, RGB(64,120,85)); //<<<<<<<<<<<< Green
if ( g_clicked ) {
gr.DrawRoundRect(0, 0, ww-1, wh-1, 1, 1, 1, RGBA(70,240,60,200)); //---orig---> gr.DrawRoundRect(0, 0, ww-1, wh-1, 4, 4, 1, RGBA(255,255,255,200));
}
else if ( g_hover ) {
//--- displays a thin border frame when mouse hovers over the panel:
// gr.DrawRoundRect(0, 0, ww-1, wh-1, 4, 4, 1, RGBA(255,255,255,100)); <<<<<<<<<<<<<<< Original
// gr.DrawRoundRect(0, 0, ww-1, wh-1, 1, 1, 1, RGBA(207,121,5,200)); <<<<<<<<<<<<<<< My previous choice = orange, thin
// gr.DrawRoundRect(0, 0, ww-1, wh-1, 1, 1, 1, RGBA(20,20,20,20)); <<<<<<<<<<<<<<< My previous choice = black-grey
gr.DrawRoundRect(0, 0, ww-1, wh-1, 1, 1, 1, RGBA(117,231,172,120));
}
if ( g_hover_seek ) {
var text_w = gr.CalcTextWidth(g_hover_seek, g_font) + 5;
if ( (g_hover + text_w) > ww) g_hover -= text_w + 4;
gr.FillSolidRect(g_hover - 2, 3, text_w + 2, wh-6, RGB(0,0,150));
gr.GdiDrawText(g_hover_seek, g_font, RGB(255,255,255), g_hover, 4, text_w, wh-8, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT);
}
}
//------------------------------------------------------------------ function on_paint(gr) END
function on_mouse_lbtn_down(x,y){
g_drag = 1;
g_clicked = 1;
g_hover = 0;
on_mouse_move(x,y);
}
function on_mouse_lbtn_up(x,y){
if( g_drag ) {
g_drag = 0;
g_drag_seek = x / window.Width;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
fb.PlaybackTime = fb.PlaybackLength * g_drag_seek;
}
g_clicked = 0;
}
function on_mouse_move(x,y) {
window.SetCursor(32649);
if(g_drag) {
g_drag_seek = x / window.Width;
g_drag_seek = (g_drag_seek<0) ? 0 : (g_drag_seek<1) ? g_drag_seek : 1;
}
g_hover_seek = null;
if ( x <= window.Width && fb.PlaybackLength > 0) {
g_hover_seek = x / (window.Width);
g_hover_seek = (g_hover_seek<0) ? 0 : (g_hover_seek<1) ? g_hover_seek : 1;
g_hover_seek = TimeFmt(g_hover_seek * fb.PlaybackLength);
}
else { g_hover_seek = null; }
g_hover = x + 4;
window.Repaint();
}
function on_mouse_leave() {
g_hover_seek = null;
g_hover = null;
g_clicked = 0;
window.SetCursor(32512);
window.Repaint();
}
function on_mouse_wheel(delta){
if(delta>0)
fb.VolumeUp();
else
fb.VolumeDown();
}
function on_playback_new_track(info){
window.Repaint();
}
function on_playback_stop(){
window.Repaint();
}
function on_playback_seek(time){
window.Repaint();
}
function on_playback_pause(state){
window.Repaint();
}
function on_playback_time(time){
window.Repaint();
}
function on_volume_change(val){
window.Repaint();
}
//EOF