Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: WSH Panel Mod (Read 815784 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod

Reply #525
@TPWang: no problem at all! i can live with what i have right now!

@marc2003: thanks for the seekbar code. By the way i though it wasnt a good idea to create all those variables in the painting function. If anyone is interested i modyfied it to change that.

WSH Panel Mod

Reply #526
well i didn't create that code - but most of those variables need to be set inside that function. i suppose the time/length could be defined on a per track basis but i see little benefit to be gained by changing it.

WSH Panel Mod

Reply #527
well i didn't create that code - but most of those variables need to be set inside that function. i suppose the time/length could be defined on a per track basis but i see little benefit to be gained by changing it.

I think that on heavy configs with a lot of WSh panels updating every second, that changes a lot!

WSH Panel Mod

Reply #528
well mines updating 10 times a second now and you still get 0% cpu usage. can't see any problems with it myself.

edit: i'd still be interested to look at your changes though.

WSH Panel Mod

Reply #529
T.P.Wang Please tell me is it even possible to create buttons on the bottom right coordinates???

Because all configs i have studied using only the upper left coordinates!

I'm hopless, give me peace of mind so i can move on!!





WSH Panel Mod

Reply #530
Yes you can but you just have to reposition them on resize.

WSH Panel Mod

Reply #531
just subtract the button dimensions from the panel width/height. eg...

var x = window.Width - 20;
var y = window.Height -20;


WSH Panel Mod

Reply #532
carmenm can you give me a some example code that i can work with.
I´m just  to dumb to figure it out my self .


WSH Panel Mod

Reply #533
marc2003 yes that much i know but when you resize the window mouse hover area is not moving with the button images. until you press apply

WSH Panel Mod

Reply #534
Here is the code. buttons working but when you drag the window larger then click inside the large rectangle and you see where my problem is.



Code: [Select]
//COVERS


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));
}
var g_font = gdi.Font("Segoe UI", 16, 0);

var g_img = null;



Buttons  = [];

function Button( title, x, y, w, h, func) {
   
this.left = x ;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;
    this.func = func;

Buttons.push(this);
this.onMove = function (x, y) {
    (((this.left < x+180) && (x+180 < this.right) && (this.top < y) && (y < this.bottom)) ? this.hover1 = true : this.hover1 = false);
(((this.left < x+120) && (x+120 < this.right) && (this.top < y) && (y < this.bottom)) ? this.hover2 = true : this.hover2 = false);
(((this.left < x+60) && (x+60 < this.right) && (this.top < y) && (y < this.bottom)) ? this.hover3 = true : this.hover3 = false);
(((this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom)) ? this.hover4 = true : this.hover4 = false);


}

this.draw = function (gr) {
var wh=window.height-60;
var normal=RGB(170, 170, 0);
var hover=RGB(100, 100, 100);
var lw=2;

(this.hover1 ? color1 = normal : color1 = hover );
(this.hover2 ? color2 = normal : color2 = hover );
(this.hover3 ? color3 = normal : color3 = hover );
(this.hover4 ? color4 = normal : color4 = hover );

gr.DrawRect(window.width/2-115, wh, this.w, this.h, lw,color1);
gr.DrawRect(window.width/2-55, wh, this.w, this.h, lw, color2);
gr.DrawRect(window.width/2+5, wh, this.w, this.h, lw, color3);
gr.DrawRect(window.width/2+65, wh, this.w, this.h, lw, color4);


}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

  this.onClick = function (x, y) {
  if (this.hover1,this.hover2,this.hover3,this.hover4) {
  this.func && this.func();
  }
}

}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function on_size() {

var ww=window.Width;
var wh=window.Height;
var x=ww/2;
var y=wh-60;
var w=50;
var h=50;

new Button("Front",x-115, y, w, h,  function (){
 if (a == 0)
a = 1;
a=1,b=0,c=0,d=0;
})
a = 1;

new Button("Back",x-55, y, w, h,  function (){
 if (b == 0)
b = 1;
a=1,b=1,c=0,d=0;
})
b = null;

new Button("CD",x+5, y, w, h,  function (){
 if (c == 0)
c = 1;
a=1,b=0,c=1,d=0;
})
c = null;

new Button("Artist",x+65, y, w, h,  function (){
 if (d == 0)
d = 0;
a=0,b=0,c=0,d=1;
})
d = null;


}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function on_paint(gr) {
gr.DrawRect(window.Width/2-120, window.Height-65, 240, 60, 2, RGB(200,200,0));

gr.GdiDrawText("Front", g_font, RGB(100,100,100), window.Width/2-108,window.Height-45, 100, 20, format = 0);
gr.GdiDrawText("Back", g_font, RGB(100,100,100), window.Width/2-46,window.Height-45, 100, 20, format = 0);
gr.GdiDrawText("CD", g_font, RGB(100,100,100), window.Width/2+20,window.Height-45, 100, 20, format = 0);
gr.GdiDrawText("Artist", g_font, RGB(100,100,100), window.Width/2+71,window.Height-45, 100, 20, format = 0);

var ww=window.Width-10;
var wh=window.Height-80;
var scale_w = ww / 200;
var scale_h = wh / 200;
var scale = Math.min(scale_w, scale_h);
var pos_x = 0, pos_y = 0;
if (scale_w < scale_h)
pos_y = (wh - 200 * scale) / 2;
else if (scale_w > scale_h)
pos_x = (ww - 200 * scale) / 2;

if (a==1) {
var color1=RGB(250,0,0);
var color2=RGB(50,50,50);
}
if (b==1) {
var color1=RGB(0,250,0);
var color2=RGB(50,50,50);
}
if (c==1) {
var color1=RGB(0,0,250);
var color2=RGB(50,50,50);
}
if (d==1) {
var color1=RGB(150,150,150);
var color2=RGB(50,50,50);
}
gr.DrawRect(pos_x+5, pos_y+5, 200 * scale, 200 * scale, 5, color1);

if (g_img) {
// Keep aspect ratio
var scale_w = ww / g_img.Width;
var scale_h = wh / g_img.Height;
var scale = Math.min(scale_w, scale_h);
var pos_x = 0, pos_y = 0;

if (scale_w < scale_h)
pos_y = (wh - g_img.height * scale) / 2;
else if (scale_w > scale_h)
pos_x = (ww - g_img.Width * scale) / 2;

gr.DrawImage(g_img, pos_x+8, pos_y+8, g_img.Width * scale-5, g_img.Height * scale-5, 0, 0, g_img.Width, g_img.Height);
}


buttonsDraw(gr);

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function buttonsDraw(gr) {
for (i in Buttons) {
Buttons[i].draw(gr);
}

}
function on_mouse_move(x, y) {
  for (i in Buttons ) {
        Buttons [i].onMove(x, y);
}


window.RepaintRect(window.Width/2-120, window.Height-65, 240, 60);


//window.RepaintRect(0, window.height-65, window.width, 60);
//window.Repaint();
}

function on_mouse_lbtn_down(x, y) {
for (i in Buttons ) {
Buttons [i].onClick(x,y);
}
//window.RepaintRect(this.left, this.top, this.w, this.h);
window.Repaint();
}

function on_focus(is_focused) {

window.Repaint();
}




WSH Panel Mod

Reply #535
Sorry but i dnot see the problem. For me resizing your script works fine. The only thing i see is that it is extremely slow. I see it when i move the mouse over the buttons

WSH Panel Mod

Reply #536
Thats the problem the mouse hover area stretches with the window and if you click some empty area in the big rectangle near the buttons you'll see that the buttons still working.

After resizing the window there is like thousand invisible buttons streched out, thats why it's taking so much cpu.

WSH Panel Mod

Reply #537
Wow but that s normal!!!
You create the buttons in the size function. In each size function call you create new buttons without releasing the last ones.
You need to create them as global variables and move them in the size function.

WSH Panel Mod

Reply #538
Thanx for your help but i give up! Before my hair is going grey.

I go and learn some javascript for a fev years and then gome back and try again. 

WSH Panel Mod

Reply #539
is there anything you're doing that particularly requires WSH panel mod? you could quite easily make an album art switcher like that using panel stack splitter.

WSH Panel Mod

Reply #540
Nope and i have already done this with pss. I just want to learn wsh panel coding and this was good practice for start.

WSH Panel Mod

Reply #541
Hi T.P. , first of all thanks a lot for this amazing plugin !

It's working great, but I do have some issues with one of my scripts: it is a simple toolbar, to replace the default menu ( File / Edit / View /etc ).
I used this post form Falstaff (thx by the way), providing a simple solutions to use images as buttons.

I slightly modded it, so that buttons stay "down" when you click on them, and drag your mouse, while holding your click ( that's the m_drag variable)

first of all, the script: It doesn't throw any errors in the console

Code: [Select]
var MF_SEPARATOR = 0x00000800;
var MF_ENABLED = 0x00000000;
var MF_GRAYED = 0x00000001;
var MF_DISABLED = 0x00000002;
var MF_UNCHECKED = 0x00000000;
var MF_CHECKED = 0x00000008;
var MF_STRING = 0x00000000;
var MF_POPUP = 0x00000010;
var MF_RIGHTJUSTIFY = 0x00004000;

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

// OBJECT button
button = function () {
    this._attrb = {};

    this.create = function (path_normal, path_hover, path_down) {
        this._attrb.normal = gdi.Image(path_normal);
        this._attrb.hover = gdi.Image(path_hover);
        this._attrb.down = gdi.Image(path_down);
        if (typeof this._attrb.x == "undefined") this._attrb.x = 0;
        if (typeof this._attrb.y == "undefined") this._attrb.y = 0;
        this._attrb.w = this._attrb.normal.Width;
        this._attrb.h = this._attrb.normal.Height;
        if (typeof this._attrb.state == "undefined") this._attrb.state = 0;
    }

    this.draw = function (gr, bx, by, alpha, label) {
        var image;
        this._attrb.x = bx;
        this._attrb.y = by;
        switch (this._attrb.state) {
        case 0:
            image = this._attrb.normal;
            break;
        case 1:
            image = this._attrb.hover;
            break;
        case 2:
            image = this._attrb.down;
            break;
        }
        gr.DrawImage(image, bx, by, this._attrb.w, this._attrb.h, 0, 0, this._attrb.w, this._attrb.h, 0, alpha);
    }

    this.checkstate = function (action, x, y) {
        switch (action) {
        case "down":
            if (x > this._attrb.x && x < this._attrb.x + this._attrb.w && y > this._attrb.y && y < this._attrb.y + this._attrb.h) {
                this._attrb.state = 2;
                window.Repaint();
            } else if (this._attrb.state == 2) {
                this._attrb.state = 0;
                window.Repaint();
            }
            break;
        case "move":
            if (x > this._attrb.x && x < this._attrb.x + this._attrb.w && y > this._attrb.y && y < this._attrb.y + this._attrb.h) {
                this._attrb.state = 1;
                window.Repaint();
            } else if (this._attrb.state == 1) {
                this._attrb.state = 0;
                window.Repaint();
            }
            break;
        case "up":
            this._attrb.state = 0;
            break;
        }
        return this._attrb.state;
    }

}

var ButtonStates = {
    normal: 0,
    hover: 1,
    down: 2
};
// END BUTTONS

var ww = 0, wh = 0;
var filedir = fb.FoobarPath + "phoenix\\";
var m_drag = null;

var img_top_back = gdi.Image(filedir + "top_back.png");

var font = gdi.Font("Dollis",20,0);

var menufichier = new button;
var menuedit = new button;
var menuview = new button;
var menupb = new button;
var menulib = new button;
var menuh = new button;

//Script start

function on_size(){
var wh = window.Height;
var ww = window.Width;

menufichier.create(filedir+"top_menu_file_normal.png", filedir+"top_menu_file_hover.png",  filedir+"top_menu_file_down.png");
menuedit.create(filedir+"top_menu_edit_normal.png", filedir+"top_menu_edit_hover.png",  filedir+"top_menu_edit_down.png");
menuview.create(filedir+"top_menu_view_normal.png", filedir+"top_menu_view_hover.png",  filedir+"top_menu_view_down.png");
menupb.create(filedir+"top_menu_playback_normal.png", filedir+"top_menu_playback_hover.png",  filedir+"top_menu_playback_down.png");
menulib.create(filedir+"top_menu_library_normal.png", filedir+"top_menu_library_hover.png",  filedir+"top_menu_library_down.png");
menuh.create(filedir+"top_menu_help_normal.png", filedir+"top_menu_help_hover.png",  filedir+"top_menu_help_down.png");
}
 
function on_paint(gr){
var wh = window.Height;
var ww = window.Width;
gr.SetSmoothingMode(4);
gr.SetInterpolationMode(7);

gr.DrawImage( img_top_back, 0, 0, ww, wh, 0, 0, img_top_back.Width,  img_top_back.Height);

var top= wh/2-13;
var offset = 12;

menufichier.draw(gr,offset,top,255);
menuedit.draw(gr,offset+75,top,255);
menuview.draw(gr,offset+145,top,255);
menupb.draw(gr,offset+220,top,255);
menulib.draw(gr,offset+380,top,255);
menuh.draw(gr,offset+515,top,255);
}

function on_mouse_lbtn_down(x,y){

if (menufichier.checkstate("down",x,y)==ButtonStates.down) {
m_drag = true;

var menuman = fb.CreateMainMenuManager();
var menu = window.CreatePopupMenu();
var ret;

// Build a menu based on "View"
menuman.Init("file");
menuman.BuildMenu(menu, 1, 128);

// Show menu
ret = menu.TrackPopupMenu(x, y);

fb.trace(ret);

if (ret > 0)
{
// Execute menu commands
// "ID" is based on which is generated
menuman.ExecuteByID(ret - 1);
}

menuman.Dispose();
menu.Dispose();

}

if (menuedit.checkstate("down",x,y)==ButtonStates.down) {
m_drag = true;

var menuman = fb.CreateMainMenuManager();
var menu = window.CreatePopupMenu();
var ret;

// Build a menu based on "View"
menuman.Init("edit");
menuman.BuildMenu(menu, 1, 128);

// Show menu
ret = menu.TrackPopupMenu(x, y);

fb.trace(ret);

if (ret > 0)
{
// Execute menu commands
// "ID" is based on which is generated
menuman.ExecuteByID(ret - 1);
}

menuman.Dispose();
menu.Dispose();

}

if (menuview.checkstate("down",x,y)==ButtonStates.down) {
m_drag = true;

var menuman = fb.CreateMainMenuManager();
var menu = window.CreatePopupMenu();
var ret;

// Build a menu based on "View"
menuman.Init("view");
menuman.BuildMenu(menu, 1, 128);

// Show menu
ret = menu.TrackPopupMenu(x, y);

fb.trace(ret);

if (ret > 0)
{
// Execute menu commands
// "ID" is based on which is generated
menuman.ExecuteByID(ret - 1);
}

menuman.Dispose();
menu.Dispose();

}

if (menupb.checkstate("down",x,y)==ButtonStates.down) {
m_drag = true;

var menuman = fb.CreateMainMenuManager();
var menu = window.CreatePopupMenu();
var ret;

// Build a menu based on "View"
menuman.Init("playback");
menuman.BuildMenu(menu, 1, 128);

// Show menu
ret = menu.TrackPopupMenu(x, y);

fb.trace(ret);

if (ret > 0)
{
// Execute menu commands
// "ID" is based on which is generated
menuman.ExecuteByID(ret - 1);
}

menuman.Dispose();
menu.Dispose();

}

if (menulib.checkstate("down",x,y)==ButtonStates.down) {
m_drag = true;

var menuman = fb.CreateMainMenuManager();
var menu = window.CreatePopupMenu();
var ret;

// Build a menu based on "View"
menuman.Init("library");
menuman.BuildMenu(menu, 1, 128);

// Show menu
ret = menu.TrackPopupMenu(x, y);

fb.trace(ret);

if (ret > 0)
{
// Execute menu commands
// "ID" is based on which is generated
menuman.ExecuteByID(ret - 1);
}

menuman.Dispose();
menu.Dispose();

}

if (menuh.checkstate("down",x,y)==ButtonStates.down) {
m_drag = true;

var menuman = fb.CreateMainMenuManager();
var menu = window.CreatePopupMenu();
var ret;

// Build a menu based on "View"
menuman.Init("help");
menuman.BuildMenu(menu, 1, 128);

// Show menu
ret = menu.TrackPopupMenu(x, y);

fb.trace(ret);

if (ret > 0)
{
// Execute menu commands
// "ID" is based on which is generated
menuman.ExecuteByID(ret - 1);
}

menuman.Dispose();
menu.Dispose();

}
}

function on_mouse_lbtn_up(x,y){
menufichier.checkstate("up",x,y);
menuedit.checkstate("up",x,y);
menuview.checkstate("up",x,y);
menupb.checkstate("up",x,y);
menulib.checkstate("up",x,y);
menuh.checkstate("up",x,y);

m_drag = false;
window.Repaint();
}

function on_mouse_move(x,y){

if(!m_drag){
menufichier.checkstate("move",x,y);
menuedit.checkstate("move",x,y);
menuview.checkstate("move",x,y);
menupb.checkstate("move",x,y);
menulib.checkstate("move",x,y);
menuh.checkstate("move",x,y);
}
}

function on_mouse_leave(){
m_drag = false;
menufichier.checkstate("up",0,0);
menuedit.checkstate("up",0,0);
menuview.checkstate("up",0,0);
menupb.checkstate("up",0,0);
menulib.checkstate("up",0,0);
menuh.checkstate("up",0,0);
window.Repaint();
}

//EOF

Now strange things happen with this script:
When no code is inserted into the if (menuXXX.checkstate("down",x,y)==ButtonStates.down) { } , the script just behaves normally .
  • With the code sample from MainMenuManager.txt, Menus appear on left-click, but the button is not in its "hover" state.
  • However, i noticed a workaround that i can't understand:
    • right-click on anywhere on the WS panel
    • while the context menu is still opened, click on any menu icon. It stays in its "hover state".
    • as long as you only click on menu icons, The last 2 menus you clicked on keep their "hover" state

I have to admit that I do NOT understand the way you build menus, I juste copied/pasted your sample.

I'd really appreciate if anyone could help me, I'd love to understand the issue here !

Thanks everyone =)

Just a small screenshot of the config (Work in progress : ELplaylist + controls)

WSH Panel Mod

Reply #542
I'm getting such an error almost every time I close foobar:



Foobar doesn't handle it as a crash, so I can't provide crash report, but Windows says it is foo_uie_wsh_panel_mod component that causes it.

Some additional info:
- foobar version - 1.0 final
- wsh panel mod version - 1.2.1

I have 4 wsh panels. All the scripts are executed correctly and there no errors while foobar is running.


WSH Panel Mod

Reply #544
@phoen1x:
Do you mean these buttons are still in "down" state?




PS: WSH Panel Mod 1.2.2 Beta 1 is released, now it's for foobar2000 1.0+ only.
And also note that Beta versions will be expired in 14 days. (Just prompt to user to update).



WSH Panel Mod

Reply #547
@mxmten:
Which scripts you are using, do they invoke something like utils.GetAlbumArtAsync() (this is known and fixed now) ?

WSH Panel Mod

Reply #548
@Joffi
Yes! I had similar crashes with some other components (foo_vis_shpeck, foo_customdb, foo_np_simple, etc). I removed those I don't use and now I have only supposed WSH crashes. Btw, I'm using Win7 x86.

@T.P Wang
I've sent you a PM with all the scripts.

WSH Panel Mod

Reply #549
Case said you should compile the component using the latest SDK.