Skip to main content

Topic: WSH Panel Mod (Read 581721 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • chiwou
  • [*][*][*]
WSH Panel Mod
Reply #25
@NEMO: thanks for the templates, they are working pretty good

//edit
actually there are not  every time I close/start foobar I've to re-apply them, because they don't show up on start
but I use the panel width with window.Width
weird
  • Last Edit: 24 March, 2009, 02:04:36 PM by chiwou

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #26
Ver 1.1.0 Released, with some major changes.
Now implementing a "follow cursor" file info is now possible.

NOTICE
If you are using any of fb.GetNowPlaying(), fb.GetFocusItem(), on_playback_new_track() and on_items_selection_change(), please pay more attention to the ChangeLog.txt, Interfaces.txt and Callbacks.txt, because some features are not back backwards compatible.
  • Last Edit: 30 March, 2009, 03:09:11 PM by T.P Wang

  • NEMO7538
  • [*][*][*][*][*]
  • Developer
WSH Panel Mod
Reply #27
Thanks for the new version.
However, it seems that a callback would be needed: on_stopaftercurrent_changed (state) {} so that we can use the property properly.

  • TomBarlow
  • [*][*][*][*][*]
WSH Panel Mod
Reply #28
Is it possible to run a service using foo_run with this? I tried it but couldn't get it to work. Could it be possible in the future?

The only other thing missing for me is a fixed width font in the editor!  and maybe on_stopaftercurrent_changed (state) {}.

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #29
@NEMO7538:
Thanks for your advice, I'll add them in the next version.

@TomBarlow:
The editor window use "Courier New" font (which is monospaced font), It should be installed with XP by default...
  • Last Edit: 02 April, 2009, 07:09:39 AM by T.P Wang

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #30
1.1.1 released

@TomBarlow:
fb.RunContextCommand() is fixed, so you can run them now...
  • Last Edit: 02 April, 2009, 09:38:29 AM by T.P Wang

  • TomBarlow
  • [*][*][*][*][*]
WSH Panel Mod
Reply #31
Fantastic!! This version is great! I still can't get the run services things to run, is there a particular syntax? I'm using e.g. fb.RunContextCommand('Run services//Last.fm') , although I don't really know if that's right. For some reason they're not working as a regular CUI toolbar button either, maybe the problem with with foo_run?

And I definitely have Courier New installed, I can't think why it's not showing up. It's not too much of a problem.

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #32
@TomBarlow:
I tried it and it works, however, it will not be executed if there are no now playing content.
for exmaple:
fb.RunContextCommand("Run service/Google Artist");

And please contact me, I'll send you a debug version to find out why your font not work.
EDIT: I find out the problem, I'll fix that later.
  • Last Edit: 02 April, 2009, 10:52:10 AM by T.P Wang

  • NEMO7538
  • [*][*][*][*][*]
  • Developer
WSH Panel Mod
Reply #33
fb.RunContextCommand() only works with the nowplaying track. Is there a possibility to have it applied on the getfocusitem ?
Thanks

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #34
1.1.2 Released 

@TomBarlow:
You now can change font is foobar2000 Preferences, WSH Panel Mod

@NEMO7538
You can use fb.RunContextCommandWithMetadb(metadb) from now on.

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #35
For setting in Preferences->Display->WSH Panel Mod, Please read the following description.
This message is quoted from SciTE Doc
Quote
The value of each setting is a set of ',' separated fields, some of which have a subvalue after a ':'.
The fields are font, size, fore, back, italics, notitalics, bold, notbold, eolfilled, noteolfilled, underlined, notunderlined, and case. The font field has a subvalue which is the name of the font, the fore and back have colour subvalues, the size field has a numeric size subvalue, the case field has a subvalue of 'm', 'u', or 'l' for mixed, upper or lower case, and the bold, italics and eolfilled fields have no subvalue. The value "fore:#FF0000,font:Courier,size:14" represents 14 point, red Courier text.

Note that all fields is case sensitive.

WSH Panel Mod
Reply #36
I've never programmed this panel before so please excuse my ignorance.

I've seen several examples of how this panel can be programmed to be many things but could I use it to contain other panels. My thinking is a few buttons used to select which panel to display. I know I could PSS for this but that is a big step from 'normal' CUI.

  • TomBarlow
  • [*][*][*][*][*]
WSH Panel Mod
Reply #37
Thanks for the new version, fonts work well now. Could you explain what RunContextCommandWithMetadb does exactly, and how to use it, and how it's different from RunContextCommand? Thanks.

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #38
@Black_Over_Bills_Mothers:
Sorry, you cannot embed any other panels in WSH Panel.

@TomBarlow:
For example,
Code: [Select]
// Get current focus item handle
metadb = fb.GetFocusItem();
// Applying RunContextCommand to this handle
fb.RunContextCommandWithMetadb(metadb);


and something more:
fb.RunContextCommandWithMetadb(fb.GetNowPlaying()) is equivalent to fb.RunContextCommand(), since fb.RunContextCommand() apply on now playing item handle.
  • Last Edit: 04 April, 2009, 11:51:27 AM by T.P Wang

  • NEMO7538
  • [*][*][*][*][*]
  • Developer
WSH Panel Mod
Reply #39
Thank you TP Wang for the new version.

For those who are interested, I made a little toolbar to handle the rating :
Code: [Select]
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=20;
var imgw=20;
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 + "Images\\"
+ ((i > (g_drag ? lrating : rating)) ? "NoStar" : "Star" +  (g_drag ?  "-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), 4, 20, 16, 0, 0, 20, 16);
}
}
}

function on_mouse_wheel(delta){}


function on_mouse_lbtn_up(x,y){
// fb.trace("button up");
if (lrating !=rating) {if (g_metadb) {
bool = fb.RunContextCommandWithMetadb("Rating/"+((lrating==0) ? "<not set>" : lrating),g_metadb);
}}
}

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 (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


For it to work:
  • you need the playback statistics standard component, with "Rating"as an entry in your context menu
  • you need to place "Star.png", "NoStar.png" and "Star-hover.png" in your foobar/Images directory. Sample:
@T.P. Wang: Since we have a metadb handle, it would be nice (if possible) to have a callback when metadb data is changed. Thanks.
  • Last Edit: 04 April, 2009, 04:18:31 PM by NEMO7538

  • tedgo
  • [*][*][*][*][*]
WSH Panel Mod
Reply #40
@NEMO7538
Thanks for this sample!
I'm on replacing most settings of PSS in my config with WSH Panel mod, but i'm unfortunately too dumb to do it right...
Now i finally have a sample i can work with.

  • chiwou
  • [*][*][*]
WSH Panel Mod
Reply #41
@NEMO: could you please change your seekbar/volume config so that it use the window.Width/Height of the wsh panel *please*

and thanks for the rating buttons

  • NEMO7538
  • [*][*][*][*][*]
  • Developer
WSH Panel Mod
Reply #42
This is another one for "Stop after current"
Code: [Select]
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
var g_drag = 0;
var imgname;
var img;
function on_init(bool) {
imgname =bool  ?  "sac.png" : "playing.png";
img = gdi.image(fb.FoobarPath + "Images\\" + imgname);
window.Repaint();
};

on_init(fb.StopAfterCurrent);

function on_paint(gr){

gr.DrawImage(img, 0, 4, 20, 16, 0, 0, 20, 16);
}

function on_mouse_move(x, y) {

if (g_drag==0) {

on_init(!fb.StopAfterCurrent);
g_drag = 1;
}

}
function on_mouse_leave() {
if (g_drag==1) {

on_init(fb.StopAfterCurrent);
g_drag = 0;
}
}
function on_mouse_lbtn_up(x,y){

fb.StopAfterCurrent = !fb.StopAfterCurrent;
window.Repaint();

// g_drag = 0;
}


function on_playlist_stop_after_current_changed(state) {on_init(fb.StopAfterCurrent);}

//EOF
Where you need to use those two images: (In Foobar/Images directory)

.. and yet another one for the playback order :
Code: [Select]
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
var PlaybackOrder = {
Default: 0,
RepeatPlaylist: 1,
RepeatTrack: 2,
Random: 3,
ShuffleTracks: 4,
ShuffleAlbums: 5,
ShuffleFolders: 6
}


var PlaybackOrderText = new Array(
"Default", // = 0
"Repeat (Playlist)",
"Repeat (Track)",
"Random",
"Shuffle (tracks)",
"Shuffle (albums)",
"Shuffle (folders)") ;

var g_font = gdi.Font("Arial", 11, 1);
var g_drag = 0;
var txt = "";
var bool;
function on_init() {
on_playback_order_changed(fb.PlaybackOrder);
};

on_init();
function on_paint(gr){
gr.SetTextRenderingHint(0);
gr.SetSmoothingMode(2);
// gr.FillGradRect(  3, 3,    0, window.Height-3, 90, RGB(240,240,240), RGB(100,230,100));
gr.DrawRect(15, 1, window.Width-36, 20, 1, RGB(64,64,64));
gr.FillGradRect(16, 2, window.Width-38, 18, 70, RGB(240,240,240), RGB(190,190,190));
gr.DrawString(txt, g_font, RGB(124,128,164), 5, 0, window.Width-15, 22, 0x11005000);

}

function on_mouse_wheel(delta){
if(delta>0) {if (fb.PlaybackOrder==6) fb.PlaybackOrder=0;
else fb.PlaybackOrder= fb.PlaybackOrder+1;}

else
{if (fb.PlaybackOrder==0) fb.PlaybackOrder=6;
else fb.PlaybackOrder= fb.PlaybackOrder-1;}
}
function on_mouse_lbtn_up(x,y){

if (fb.PlaybackOrder==0) fb.PlaybackOrder=4;
else fb.PlaybackOrder= 0;

// fb.trace("order="+fb.PlaybackOrder)

g_drag = 0;
}
function on_playback_order_changed(new_order_index) {
txt = PlaybackOrderText[fb.PlaybackOrder];

window.Repaint();
}
//EOF
Without images ... just click or use the mouse wheel.

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #43
@NEMO7538:
Thanks for your advice, I now considering to include that feature in the next version.
However, I think l should restrict it to watch only one metadb handle at a time.

  • NEMO7538
  • [*][*][*][*][*]
  • Developer
WSH Panel Mod
Reply #44
@NEMO: could you please change your seekbar/volume config so that it use the window.Width/Height of the wsh panel
Here it is :
Volume bar:
Code: [Select]
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
var g_font = gdi.Font("Tahoma", 12, 0);
var g_drag = 0;
var ww;
var hofset = 10;
var wh = 12;
var vofset;
var grad;

function on_paint(gr){
vofset = (window.Height-wh)/2;
grad = Math.pow((100+fb.Volume)/100,2);
ww = 5*Math.floor((window.Width - 2*hofset)/5);
var i = 0;
while (i < ww) {
var col = (grad<=0)  ? RGB(168,168,168) : (i<=grad*ww) ? RGB(32+128*i/ww,164*(1-i/ww),32*(1-i/ww)) :  RGB(168,168,168);
gr.FillSolidRect(hofset+1+i,vofset,4,wh, col);
i = i +5;
}
gr.DrawRect(hofset,vofset, i, wh, 1.0, RGB(192,192,192));
}
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-hofset)/ww;
v = (v<0) ? 0 : (v<1) ? v : 1;
v = 100 * (Math.pow(v,1/2) - 1);
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_playback_time(time){
window.Repaint();
}
//EOF
Seekbar
Code: [Select]
function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
var g_font = gdi.Font("Tahoma", 12, 0);
var g_drag = 0;
var hofset = 10;
var wh = 13;
var vofset;
var length;
var grad;


function on_paint(gr){
vofset = (window.Height-wh)/2;
ww = 5*Math.floor((window.Width - 2*hofset)/5);
// fb.trace("ww="+ww);
length = fb.PlaybackLength;
grad = 0;
if (length > 0) {
grad = fb.PlaybackTime/fb.PlaybackLength;}

var i = 0;
while (i < ww) {

var col = (grad<=0)  ? RGB(168,168,168) : (i<=grad*ww) ? RGB(0,32+48*(1-i/ww),96+64*(1-i/ww)) :  RGB(128+48*(1-i/ww),128+48*(1-i/ww),128+48*(1-i/ww));
gr.FillSolidRect(hofset+1+i,vofset,4,wh, col);
i = i +5;
}
gr.DrawRect(hofset,vofset, i, wh, 1.0, RGB(192,192,192));
}
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-hofset)/ww;
v = (v<0) ? 0 : (v<1) ? v : 1;
fb.PlaybackTime = fb.PlaybackLength * v;



}

}
function on_mouse_wheel(delta){
if(delta>0)
fb.PlaybackTime = fb.PlaybackTime + delta;
else
fb.PlaybackTime = fb.PlaybackTime + delta;
}
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();
}
You need to adjust wh manually, however;
  • Last Edit: 04 April, 2009, 03:04:56 PM by NEMO7538

  • chiwou
  • [*][*][*]
WSH Panel Mod
Reply #45
yeah I know  but especially for the seekbar it would be nice if it use the window.width (for resizing etc...)

but thanks for the answer ^^

  • NEMO7538
  • [*][*][*][*][*]
  • Developer
WSH Panel Mod
Reply #46
I now considering to include that feature in the next version.
However, I think l should restrict it to watch only one metadb handle at a time.
Yes, I understand it may cause performance issues. My request was for the rating panel to be refreshed when rating is set by another mean (the real context menu item, for instance).

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #47
v1.1.3 Released.

Notes:
  • Previous editor properties will not transfer to this version, so make a backup of your editor properties, and edit them again in the Preferences->Display->WSH Panel Mod.
  • Some important notes is added, please check Callbacks.txt for details.

@NEMO7538:
WSH Panel now can get notified when metadb is changed

  • NEMO7538
  • [*][*][*][*][*]
  • Developer
WSH Panel Mod
Reply #48
Thanks ... it works well now. I have updated the rating toolbar coded above. There is still a little annoyance with the fact that we don't get notified when the playlist has changed, so the stars does not exactly match the track which is selected in the new playlist ... but thanks anyway.

I have posted the toolbars and images here just in case someone wants to get all of them.
Please note that images are to be placed in Foobar/Images directory.
  • Last Edit: 04 April, 2009, 04:31:12 PM by NEMO7538

  • fbuser
  • [*][*][*][*][*]
  • Developer
WSH Panel Mod
Reply #49
yeah I know  but especially for the seekbar it would be nice if it use the window.width (for resizing etc...)

but thanks for the answer ^^
I didn't test it for this specific Seekbar, but it works for my Seekbar which had the same problem. You need to add the following code to make it dependent of the window.width:
Code: [Select]
on_size=function() {
  ww=window.Width;
}