Hi, thanks for great mod.
I used some code from here and made volume bar and seek bar. Seekbar has no problem because it's fool opacity. But volume bar is thins line and slider. Sometimes window background not erased - some trash on background from other windows or simply black fill. If I move some window above or minimize/maximize foobar - background looks as it must be.
"Pseudo transparent" checkbox checked, if I unchek this, background have no that problem, but have white color, what differs from my windows theme.
Anybody can help me with this problem? Maybe I must do some function like on_wmbgerase or something
function RGB(r,g,b,a){ return ((a<<24)|(r<<16)|(g<<8)|(b)); }
var g_font = gdi.Font("Calibri",14,0);
var g_drag = 0;
var ww = 16;
var wh = 9;
var vofset = 5;
var hlofset = 3;
var hrofset = 3;
var ih=25;
var iw=14;
var col_o = RGB(103,133,156,255); // progress bar frame
var col_i = RGB(23,53,76,255); // progress bar frame
var col1 = RGB(83,103,136,255); // progress bar gradien1
var col2 = RGB(103,133,156,255); // progress bar gradien2
var col_pb = RGB(133,163,186,255); // progress bar indicator frame
var col_bg = RGB(46,48,63,255); // background color
var col_txt = RGB(9,0,0,255); // Text color
var col_txt_sh = RGB(9,0,0,55); // Text color
var img = gdi.image(fb.FoobarPath+"Images\\volume2.png");
function HSV(h,s,v)
{
h=Math.abs(h%360);
s=(s<0)?0:(s>100)?100:s;
v=(v<0)?0:(v>100)?100:v;
s=s/100;
v=v/100;
h_i=Math.floor(h/60)%6;
f=h/60-Math.floor(h/60);
p=v*(1-s);
q=v*(1-f*s);
t=v*(1-(1-f)*s);
switch(h_i)
{
case 0:
return (0xff000000|(0xff*v<<16)|(0xff*t<<8)|(0xff*p));
break;
case 1:
return (0xff000000|(0xff*q<<16)|(0xff*v<<8)|(0xff*p));
break;
case 2:
return (0xff000000|(0xff*p<<16)|(0xff*v<<8)|(0xff*t));
break;
case 3:
return (0xff000000|(0xff*p<<16)|(0xff*q<<8)|(0xff*v));
break;
case 4:
return (0xff000000|(0xff*t<<16)|(0xff*p<<8)|(0xff*v));
break;
case 5:
return (0xff000000|(0xff*v<<16)|(0xff*p<<8)|(0xff*q));
break;
}
}
function nice_percent(x) {
var i = Math.round(x);
var y = Math.round((vol-Math.round(vol))*100);
ret = i+".";
if (Math.abs(y)<10) { ret = ret+"0"+Math.abs(y) } else { ret = ret+Math.abs(y) };
return (ret);
}
function on_paint(gr) {
hrofset = gr.CalcTextWidth("-100.00 dB",g_font)+3;
ww = window.Width-hlofset-hrofset-1;
volume = fb.Volume;
pos = (ww-3)*Math.pow((100+fb.Volume)/100,2);
// Background
gr.FillSolidRect(hlofset,vofset,ww,wh,col_bg);
gr.DrawRect(hlofset,vofset,ww,wh,1,col_o);
gr.DrawRect(hlofset+1,vofset+1,ww-2,wh-2,1,col_i);
// Volume bar
gr.FillGradRect(hlofset+2,vofset+2,pos,wh-3,90,RGB(50,150,190,192),RGB(30,130,160,192));
// Text volume level
vol = fb.Volume;
txt = fb.Volume>-100?nice_percent(vol)+" dB":"mute";
gr.SetTextRenderingHint(5);
gr.GdiDrawText(txt,g_font,HSV(0,0,65),hlofset+ww+5,vofset+1,window.Width-hlofset-ww-4,wh,0x00000025);
gr.GdiDrawText(txt,g_font,HSV(0,0,15),hlofset+ww+4,vofset,window.Width-hlofset-ww-4,wh,0x00000025);
// Glass effect
gr.FillGradRect(hlofset+1,vofset+1,ww-1,wh/2,90,RGB(255,255,255,84),RGB(255,255,255,0));
// Slider
gr.DrawImage(img,pos,(window.Height-ih)/2,iw,ih,0,0,iw,ih);
}
function on_mouse_lbtn_down(x,y){
g_drag = 0;
pos = (ww-3)*Math.pow((100+fb.Volume)/100,2);
// Check for marker move
if ((x>=pos && x<=pos+iw) && (y>=(window.Height-ih)/2 && y<=(window.Height-ih)/2+ih)) {
g_drag = 1;
return;
}
// Check for direct bar press
if ((x>=hlofset+2 && x<=window.Width-hrofset-2) && (y>=vofset+1 && y<vofset+wh)) {
g_drag = 1;
}
}
function on_mouse_lbtn_up(x,y){
on_mouse_move(x,y);
g_drag = 0;
}
function on_mouse_move(x,y){
if(g_drag){
var v = (x-hlofset-2) / (window.Width-hlofset-hrofset-4);
v = (v<0) ? 0 : (v<1) ? v : 1;
v = 100*(Math.pow(v,1/2)-1);
if(fb.Volume != v) fb.Volume = v;
}
}
function on_mouse_wheel(delta){
if(delta>0)
fb.VolumeUp();
else
fb.VolumeDown();
}
function on_volume_change(val){
window.Repaint();
}
function on_size() {
wh = window.Height-2*vofset-1;
}
//EOF