IPB

Welcome Guest ( Log In | Register )

60 Pages V  « < 3 4 5 6 7 > »   
Reply to this topicStart new topic
WSH Panel Mod, foo_uie_wsh_panel_mod
metal_termite
post May 2 2009, 18:33
Post #101





Group: Members
Posts: 538
Joined: 10-July 04
Member No.: 15248



QUOTE (NEMO7538 @ Apr 16 2009, 17:03) *
Thanks TP Wang
Regarding the volume control, I personally use :
v = Math.pow((100+fb.Volume)/100,2); and
fb.Volume = 100 * (Math.pow(v,1/2) - 1);


Where would I use that code to modify the horizontal volume bar sample provide with the plugin...

CODE
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }

// gdi.Font is changed, the last paramter is style flags
// FontStyleRegular = 0,
// FontStyleBold = 1,
// FontStyleItalic = 2,
// FontStyleBoldItalic = 3,
// FontStyleUnderline = 4,
// FontStyleStrikeout = 8
// Here is 0, means FontStyleRegular
var g_font = gdi.Font("Tahoma", 12, 0);
var g_drag = 0;

function on_paint(gr){
gr.SetTextRenderingHint(5);
var ww = window.Width;
var wh = window.Height;
var volume = fb.Volume;
var pos = window.Width * ((100+volume)/100);
var txt = (Math.ceil(volume)) + "dB";
gr.FillGradRect( 0, 0, pos, wh, 90, RGB(240,240,240), RGB(100,230,100));
gr.FillGradRect(pos, 0, ww-pos, wh, 90, RGB(240,240,240), RGB(190,190,190));
gr.DrawString(txt, g_font, RGB(64,64,128), 0, 0, ww, wh, 0x11005000);
gr.DrawRect(0,0, ww-1, wh-1, 1.0, RGB(150,150,150));
}

function on_mouse_lbtn_down(x,y){
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 / window.Width;
v = (v<0) ? 0 : (v<1) ? v : 1;
v = -100 * (1-v);
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();
}
//EOF
Go to the top of the page
+Quote Post
T.P Wang
post May 5 2009, 19:00
Post #102





Group: Developer
Posts: 486
Joined: 8-June 07
From: Chengdu
Member No.: 44175



v1.1.7 Released

@metal_termite:
CODE

function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }

// gdi.Font is changed, the last paramter is style flags
// FontStyleRegular = 0,
// FontStyleBold = 1,
// FontStyleItalic = 2,
// FontStyleBoldItalic = 3,
// FontStyleUnderline = 4,
// FontStyleStrikeout = 8
// Here is 0, means FontStyleRegular
var g_font = gdi.Font("Tahoma", 12, 0);
var g_drag = 0;


function len2vol(len) {
return 100 * (Math.sqrt(len) - 1);
}

function vol2len(vol) {
return Math.pow((100 + fb.Volume) / 100, 2);
}

function on_paint(gr) {
gr.SetTextRenderingHint(5);
var ww = window.Width;
var wh = window.Height;
var volume = fb.Volume;
var pos = window.Width * vol2len(volume);
var txt = (Math.ceil(volume)) + "dB";
gr.FillGradRect( 0, 0, pos, wh, 90, RGB(240,240,240), RGB(100,230,100));
gr.FillGradRect(pos, 0, ww-pos, wh, 90, RGB(240,240,240), RGB(190,190,190));
gr.DrawString(txt, g_font, RGB(64,64,128), 0, 0, ww, wh, 0x11005000);
gr.DrawRect(0,0, ww-1, wh-1, 1.0, RGB(150,150,150));
}

function on_mouse_lbtn_down(x,y) {
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 / window.Width;
v = (v<0) ? 0 : (v<1) ? v : 1;
v = len2vol(v);
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();
}
//EOF
Go to the top of the page
+Quote Post
Falstaff
post May 5 2009, 19:33
Post #103





Group: Members
Posts: 2797
Joined: 12-November 06
Member No.: 37463



thanx for the update, but this new version make out of order one of my script (rating system)

it was working fine with v1.1.6, but now with 1.1.7, i've got an error line 21

Error: WSH Panel Mod (HWND: 0x404c0): Erreur d'exécution Microsoft JScript:
Argument ou appel de procédure incorrect
Ln: 21, Col: 1

here is the line concerned:


img = gdi.image(fb.FoobarPath + "skins\\xchange\\bt\\"
+ ((i > (g_drag ? lrating : rating)) ? "_star-off" : "star" + (g_drag ? ((i==rating)?((i==lrating)?"-kill":"-hover") :"-hover") : "")) + ".png");


CODE

function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }

var g_drag = 0;
var bool;
var g_metadb;
var imgname;
var rating;
var nrating;
var lrating;
var img;
var hofset=0;
var imgw=15;
var g_tfo = fb.TitleFormat("%rating%");

on_item_focus_change();

function on_paint(gr){
//var info = g_metadb.GetFileInfo();
if (g_metadb) {
for (i = 1; i < 6; i++) {
img = gdi.image(fb.FoobarPath + "skins\\xchange\\bt\\"
+ ((i > (g_drag ? lrating : rating)) ? "_star-off" : "star" + (g_drag ? ((i==rating)?((i==lrating)?"-kill":"-hover") :"-hover") : "")) + ".png");
// + ((i > (g_drag ? lrating : rating)) ? "No" : "") +"Star" + (g_drag ? ((rating != lrating) ? "-hover" : "") : "") + ".png");
// + ((i > (g_drag ? lrating : rating)) ? "No" : (g_drag ? ((rating != lrating) ? "Red" : "") : "")) +"Star.png");
// + (g_drag ? ((rating != lrating) ? "Blue" : "") : "") + ((i > (g_drag ? lrating : rating)) ? "No" : "") +"Star.png");
gr.DrawImage(img, hofset+imgw*(i-1), 1, 16, 16, 0, 0, 16, 16);
}
}
}

function on_mouse_wheel(delta){}

function on_mouse_lbtn_up(x,y){
// fb.trace("button up");
if (lrating !=rating) {if (g_metadb) {
bool = g_metadb.UpdateFileInfoSimple("RATING",lrating);
}}
else {
bool = g_metadb.UpdateFileInfoSimple("RATING",0);}
}

function on_mouse_move(x, y) {
if (g_metadb) {
g_drag = 1;
nrating = Math.ceil((x-hofset)/imgw);
if (nrating > 5) nrating = 5;
if (nrating != lrating) {
lrating = nrating;
window.Repaint();
}
}
}
function on_mouse_leave() {
on_metadb_changed()
}

function on_item_focus_change() {
fb.trace("itm focus changed");
if (g_metadb) {window.UnwatchMetadb();}
//g_metadb = fb.GetFocusItem();
if (fb.IsPlaying | fb.IsPaused) g_metadb = fb.GetNowPlaying();
if (g_metadb) {
on_metadb_changed();
window.WatchMetadb(g_metadb);
}

}
function on_metadb_changed() {
g_drag = 0;
// fb.trace("changed");
rating = g_tfo.EvalWithMetadb(g_metadb);
if (rating == "?") {rating = 0;}
lrating = rating;
window.Repaint();
}

function on_playback_new_track(metadb) {on_item_focus_change();}
//EOF



what have you changed ?

thanx by advance smile.gif


EDIT : ignore, i have figured out the pb, one of the image file doesn't exist, but in 1.1.6, that wasn't generate any error, 1.1.7 does wink.gif

This post has been edited by Falstaff: May 5 2009, 19:36


--------------------
http://br3tt.online.fr/
Go to the top of the page
+Quote Post
T.P Wang
post May 5 2009, 19:45
Post #104





Group: Developer
Posts: 486
Joined: 8-June 07
From: Chengdu
Member No.: 44175



@Fallstaff:
Yes, now it's more strict, in order to prevent unexpectable result.
Go to the top of the page
+Quote Post
metal_termite
post May 6 2009, 14:32
Post #105





Group: Members
Posts: 538
Joined: 10-July 04
Member No.: 15248



Thanks T.P Wang
Go to the top of the page
+Quote Post
vogliadicane
post May 6 2009, 15:49
Post #106





Group: Members
Posts: 298
Joined: 17-February 09
Member No.: 67105



I used this script in the old wsh panel, in the new one it doesnīt work anymore. Any idea, why?

CODE
//--------
var weight_normal =400;
var weight_bold =800;
var italic_no =0;
var italic =1;
var uline_no =0;
var uline =1;
//--------
var align_top =0;
var align_middle=1;
var align_bottom=2;

var align_left =0;
var align_center=1;
var align_right =2;

var trim_no =0;
var trim_chara =1;
var trim_word =2;
var trim_elips_chara =3;
var trim_elips_word =4;
var trim_elips_path =5;

var flag_rtl =0x0001;
var flag_vert =0x0002;
var flag_nofit =0x0004;
var flag_dispctrl =0x0020;
var flag_nofallback =0x0400;
var flag_trailspace =0x0800;
var flag_nowrap =0x1000;
var flag_linelimit =0x2000;
var flag_noclip =0x4000;

function StrFmt(alignH,alignV,trim,flag){ return ((alignH<<28)|(alignV<<24)|(trim<<20)|flag); }
//--------
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);
}
//----------------------------------------------------------------------------

var g_font = gdi.Font(-12, weight_normal, italic, uline_no, "MeiryoKe_PGothic");
var g_titlefmt = fb.TitleFormat("%playback_time%/%length% %samplerate%Hz %bitrate%kbps");
var g_fileinfo = null;

var g_drag = 0;
var g_drag_seek = 0;

function on_paint(gr){
var ww = window.Width;
var wh = window.Height;
var pos = 0;
var length = fb.PlaybackLength;
var txt;

if(length > 0){
if(g_drag){
pos = window.Width * g_drag_seek;
txt = "Seek " + TimeFmt(g_drag_seek * length) + " / " + TimeFmt(length);
}
else{
pos = window.Width * (fb.PlaybackTime / length);
txt = g_titlefmt.Eval();
}
}

gr.FillGradRect( 0, 0, pos, wh, 90, RGB(255,255,255), RGB(255,255,255));
gr.FillGradRect(pos, 0, ww-pos, wh, 90, RGB(157,253,41), RGB(157,253,41));


}
function on_size(){
}
function on_focus(focused){
//fb.trace("focus " + focused);
}
function on_key_down(key){
//fb.trace("key " + key);
}
function on_mouse_lbtn_down(x,y){
g_drag = 1;
}
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;
}
}
function on_mouse_move(x,y){
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;
window.Repaint();
}
}
function on_mouse_wheel(delta){
//fb.trace("wheel " + delta);
}
//--------
function on_playback_starting(cmd, paused){
}
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){
}
function on_playback_edited(){
}
function on_playback_dynamic_info(){
}
function on_playback_dynamic_info_track(){
}
function on_playback_time(time){
window.Repaint();
}
function on_volume_change(val){
}

//EOF
Go to the top of the page
+Quote Post
tedgo
post May 6 2009, 16:03
Post #107





Group: Members
Posts: 1089
Joined: 16-April 04
From: Bavaria, Germany
Member No.: 13548



Change
var g_font = gdi.Font(-12, weight_normal, italic, uline_no, "MeiryoKe_PGothic");

to:
var g_font = gdi.Font("MeiryoKe_PGothic", 12, 2);

EDIT:
I can't see, where you call this variable, so you could also delete the whole line and the whole part above
//-------
function RGB...

So this should work (as you don't have any text in your progressbar)
CODE

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);
}
//----------------------------------------------------------------------------
var g_fileinfo = null;
var g_drag = 0;
var g_drag_seek = 0;

function on_paint(gr){
var ww = window.Width;
var wh = window.Height;
var pos = 0;
var length = fb.PlaybackLength;
if(length > 0){
if(g_drag){
pos = window.Width * g_drag_seek;
}
else{
pos = window.Width * (fb.PlaybackTime / length);
}
}
gr.FillGradRect( 0, 0, pos, wh, 90, RGB(255,255,255), RGB(255,255,255));
gr.FillGradRect(pos, 0, ww-pos, wh, 90, RGB(157,253,41), RGB(157,253,41));
}

function on_mouse_lbtn_down(x,y){
g_drag = 1;
}

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;
}
}

function on_mouse_move(x,y){
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;
window.Repaint();
}
}

function on_playback_new_track(info){
window.Repaint();
}

function on_playback_stop(){
window.Repaint();
}

function on_playback_seek(time){
window.Repaint();
}

function on_playback_time(time){
window.Repaint();
}
//EOF


This post has been edited by tedgo: May 6 2009, 16:20
Go to the top of the page
+Quote Post
vogliadicane
post May 6 2009, 18:37
Post #108





Group: Members
Posts: 298
Joined: 17-February 09
Member No.: 67105



works now, Thanks a lot! biggrin.gif
Go to the top of the page
+Quote Post
tedgo
post May 6 2009, 18:56
Post #109





Group: Members
Posts: 1089
Joined: 16-April 04
From: Bavaria, Germany
Member No.: 13548



But now there is no way to add text for the moment! wink.gif

This post has been edited by tedgo: May 6 2009, 18:57
Go to the top of the page
+Quote Post
vogliadicane
post May 6 2009, 19:10
Post #110





Group: Members
Posts: 298
Joined: 17-February 09
Member No.: 67105



QUOTE (tedgo @ May 6 2009, 18:56) *
But now there is no way to add text for the moment! wink.gif


yes, I know, I donīt want it, thatīs why I (at least tried to) delete anything for it... smile.gif

still there is this ding-dong sound at startup, saying itīs not quite ok now, Iīll try to find out, why... I really donīt have any idea about Jscript, so trial and error is the way smile.gif
Go to the top of the page
+Quote Post
tedgo
post May 6 2009, 19:26
Post #111





Group: Members
Posts: 1089
Joined: 16-April 04
From: Bavaria, Germany
Member No.: 13548



Hm, i haven't tried it, but it should work without an error...
Maybe you have to change on_playback_new_track(ifo) to on_playback_new_track(metadb).

Have you took a look at the console?
There you can see the error and the line in which it occurs.

This post has been edited by tedgo: May 6 2009, 19:27
Go to the top of the page
+Quote Post
vogliadicane
post May 6 2009, 20:13
Post #112





Group: Members
Posts: 298
Joined: 17-February 09
Member No.: 67105



QUOTE (tedgo @ May 6 2009, 19:26) *
Have you took a look at the console?
There you can see the error and the line in which it occurs.


oh yes, console, always forget about it....

Error: foo_uie_wsh_panel_mod: Laufzeitfehler in Microsoft JScript:
Falsche Anzahl an Argumenten oder ungültige Eigenschaftszuweisung
Ln: 3, Col: 1

Falls ich mich nicht irre, bist Du doch Deutscher, oder? wink.gif

Ln:3 = Line 3? itīs empty

played around without success...

P.S. The on_playback_new_track(metadb) didnīt solve it...

Go to the top of the page
+Quote Post
tedgo
post May 6 2009, 20:34
Post #113





Group: Members
Posts: 1089
Joined: 16-April 04
From: Bavaria, Germany
Member No.: 13548



Tried it now and sorry, it works...
I don't get any error message with the script.
Do you have another WSH Panel mod in your config which could cause the error?
Go to the top of the page
+Quote Post
vogliadicane
post May 6 2009, 21:33
Post #114





Group: Members
Posts: 298
Joined: 17-February 09
Member No.: 67105



QUOTE (tedgo @ May 6 2009, 20:34) *
Tried it now and sorry, it works...
I don't get any error message with the script.
Do you have another WSH Panel mod in your config which could cause the error?


strange, I removed all other WSH panels, same...

well, I can live with it, everything works, but still strange

This post has been edited by vogliadicane: May 6 2009, 21:33
Go to the top of the page
+Quote Post
tedgo
post May 6 2009, 21:50
Post #115





Group: Members
Posts: 1089
Joined: 16-April 04
From: Bavaria, Germany
Member No.: 13548



Really strange...
I tried it with a fresh portable install and my own config (which has 8 wsh panel mods inside now...).
Works on both without 'ping' and error on xp with wsh panel mod 1.1.7.

This post has been edited by tedgo: May 6 2009, 21:51
Go to the top of the page
+Quote Post
vogliadicane
post May 7 2009, 09:41
Post #116





Group: Members
Posts: 298
Joined: 17-February 09
Member No.: 67105



QUOTE (tedgo @ May 6 2009, 21:50) *
Really strange...
I tried it with a fresh portable install and my own config (which has 8 wsh panel mods inside now...).
Works on both without 'ping' and error on xp with wsh panel mod 1.1.7.


just for information: today thereīs no more ping. I didnīt change anything just restart the computer. Letīs put it to the X-Files.

This post has been edited by vogliadicane: May 7 2009, 09:41
Go to the top of the page
+Quote Post
TomBarlow
post May 7 2009, 22:22
Post #117





Group: Members
Posts: 585
Joined: 30-July 07
Member No.: 45750



I just got a weird error on startup in one of my wsh panels:

Error: WSH Panel Mod (HWND: 0x701e8): (null):
(null)
Ln: 193, Col: 2

I just updated foo_audioscrobbler. Line 193 is:
if (metadb)
which is inside a function for getting album art, metadb should have come from fb.IsPlaying?fb.GetNowPlaying():fb.GetFocusItem(), foobar wasn't playing on startup so it should be fb.GetFocusItem(). The code worked when I clicked Apply. Odd...
Go to the top of the page
+Quote Post
T.P Wang
post May 8 2009, 12:03
Post #118





Group: Developer
Posts: 486
Joined: 8-June 07
From: Chengdu
Member No.: 44175



TomBarlow, vogliadicane:
I think it's because the IActiveScriptSiteInterruptPoll interface introduced in 1.1.7, I've add the interface in order to prevent infinity loop, but it's limited time is too low for you ( 5 secs ), so weird errors occured.

I've removed the IActiveScriptSiteInterruptPoll interface from the latest build, you can get it here:
LINK Removed because of critical bug.

If you find it's ok, please let me know.

This post has been edited by T.P Wang: May 8 2009, 19:06
Go to the top of the page
+Quote Post
vogliadicane
post May 12 2009, 13:17
Post #119





Group: Members
Posts: 298
Joined: 17-February 09
Member No.: 67105



QUOTE (T.P Wang @ May 8 2009, 12:03) *
TomBarlow, vogliadicane:
I think it's because the IActiveScriptSiteInterruptPoll interface introduced in 1.1.7, I've add the interface in order to prevent infinity loop, but it's limited time is too low for you ( 5 secs ), so weird errors occured.


this might also be the reason for errors using the included PBOButton script?

e.g. '$buttons' not defined...
Go to the top of the page
+Quote Post
TomBarlow
post May 15 2009, 10:24
Post #120





Group: Members
Posts: 585
Joined: 30-July 07
Member No.: 45750



T.P. Wang, I have a wsh panel that displays album art, and it works fine, except I've found the window seems to redraw whenever another window is moved over it- e.g. the preferences window, configure dialog, console etc. I'm only calling window.Repaint() from inside on_playback_new_track, on_item_focus_change and on_playback_dynamic_info_track, so I don't think it should be redrawing- it slows everything down by a lot when it does. Would you be able to stop it doing that?

It happens with my other wsh panels but it's only noticeable on the one with art.

Cheers smile.gif
Go to the top of the page
+Quote Post
2E7AH
post May 16 2009, 09:57
Post #121





Group: Validating
Posts: 2424
Joined: 21-May 08
Member No.: 53675



@T.P.Wang
I need some help, regarding using VBS in WSH:
All those shared scripts are made in Jscript (which is similar but very different than VBS), so I can't find example in VBS and get feeling how to use it in WSH panel
For example, I've made VBS to open/close CD tray. I could make CUI button and link it to VB script file, but I'm curious how this can be done using VBS in WSH?
And why JScript is somehow prefered over VBS?
Go to the top of the page
+Quote Post
AngryWolf
post May 16 2009, 13:23
Post #122





Group: Members
Posts: 3
Joined: 16-May 09
From: Kharkov, UA
Member No.: 69857



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 rolleyes.gif

CODE
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


This post has been edited by AngryWolf: May 16 2009, 22:22
Go to the top of the page
+Quote Post
Falstaff
post May 16 2009, 13:46
Post #123





Group: Members
Posts: 2797
Joined: 12-November 06
Member No.: 37463



yes, with Pseudo Transparent WSH, the refresh of the background is badly handled "sometimes" (often ...)
==>it keeps the previous main background as background on track change (so when the main background change too !!)

i had yo use tweaks in my PSS config to refresh the WSH background by resizing the WSH panel twice to refresh its background to fit the real background ...

can a fix be done T.P ?

This post has been edited by Falstaff: May 16 2009, 13:48


--------------------
http://br3tt.online.fr/
Go to the top of the page
+Quote Post
T.P Wang
post May 16 2009, 16:37
Post #124





Group: Developer
Posts: 486
Joined: 8-June 07
From: Chengdu
Member No.: 44175



@vogliadicane:
Yes, and I assume that you've seen a popup message which described that.

@TomBarlow:
Windows XP sends WM_PAINT message to window which is overlapped, or the window won't display right, it's by design. FYI: You won't get that message if you are using Vista.

In fact, I've optimized the repaint operations to repaint the region which is necessary, so on_paint() get called doesn't mean the whole panel will be repainted.

So, my suggestion is, there should be only necessary drawing, logical and numeric operations in on_paint(). There should be no object creation such as reading images (Notes & Hints: #7).
If you don't care about alpha channel of an Image, you can create RawBitmap, and use gr.GdiDrawBitmap() method to speed up drawing operations(however, don't create RawBitmap during on_paint()).

This post has been edited by T.P Wang: May 16 2009, 16:38
Go to the top of the page
+Quote Post
Falstaff
post May 16 2009, 16:45
Post #125





Group: Members
Posts: 2797
Joined: 12-November 06
Member No.: 37463



QUOTE (T.P Wang @ May 16 2009, 16:37) *
...
In fact, I've optimized the repaint operations to repaint the region which is necessary, so on_paint() get called doesn't mean the whole panel will be repainted.
...


what a shame, it is really not compliant with the Pseudo Transparency mode sad.gif

can you disable this 'optimization' when Transparency is actived ???


--------------------
http://br3tt.online.fr/
Go to the top of the page
+Quote Post

60 Pages V  « < 3 4 5 6 7 > » 
Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st April 2014 - 12:46