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 816014 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WSH Panel Mod

Reply #701
got a window saying this plugin expired, however when I update to latest version and restart foobar2000 I am hit with a bunch of script errors. I am using falstaffs xchange script, so if its something on his end let me know so I can bug him, thanks!

WSH Panel Mod

Reply #702
xchange is fine with v1.3.0, but Safe Mode option is ticked in the latest version of this component, just go to Preferences -> Tools -> WSH Panel Mod, and untick this option, all is fine after a restart of foobar.


WSH Panel Mod

Reply #703
Thanks for this plugin T.P Wang!
Don't you guys think the component needs to be renamed?
1. Because it isn't just a columns ui panel so no UIE
2. I guess that the original wsh panel is no more so no need for mod.
Something like foo_wsh maybe?

WSH Panel Mod

Reply #704
When Layout editing mode is enabled, the context menu doesn't display the layout editing commands. It is therefore difficult to cut/copy/replace the WSH element.

WSH Panel Mod

Reply #705
@Cutter:
Hmmm, since it only happens in the release mode, probably a compiler optimization fault, I'll try to fix it later.

WSH Panel Mod

Reply #706
i noticed if you toggle layout editing mode off and then back on again, you get the proper context menu back. it'll do as a temporary workaround.

WSH Panel Mod

Reply #707
Hmmm, since it only happens in the release mode, probably a compiler optimization fault, I'll try to fix it later.
Isn't it just that you initialize [font= "Courier New"]m_is_edit_mode[/font] to [font= "Courier New"]false[/font] even if the element is being created right now during layout editing, so that the LEM context menu is not accessible during the initial LEM session?
Full-quoting makes you scroll past the same junk over and over.

WSH Panel Mod

Reply #708
Isn't it just that you initialize m_is_edit_mode to false even if the element is being created right now during layout editing, so that the LEM context menu is not accessible during the initial LEM session?


Thanks, that's the point, will be fixed later 

WSH Panel Mod

Reply #709
WSH Panel Mod 1.3.1 is uploaded.

Changelog
Code: [Select]
v1.3.1
- ADD: window.CreateThemeManager() method (and also the IThemeManager interface).
- ADD: SimpleThemedButton.txt sample.
- FIX: When Layout editing mode is enabled, the context menu may not display the layout editing commands.

WSH Panel Mod

Reply #710
WSH Panel Mod 1.3.1 is uploaded.

Changelog
Code: [Select]
v1.3.1
- ADD: window.CreateThemeManager() method (and also the IThemeManager interface).
- ADD: SimpleThemedButton.txt sample.
- FIX: When Layout editing mode is enabled, the context menu may not display the layout editing commands.

Thanks a lot TPWang. I finally have a skinned progress bar!

WSH Panel Mod

Reply #711
How can I assign standart popup menu item to the SimpleThemeButton? Can anybody show me at just one example? I want to redraw original menu with wsh...

Code: [Select]
function RGB(r, g, b) {
    return (0xff000000 | (r << 16) | (g << 8) | (b));
}

ButtonStates = {
    normal: 0,
    hover: 1,
    down: 2,
    hide: 3
}

var DT_TOP = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;

var g_theme = window.CreateThemeManager("Button");
var g_font = gdi.Font("Tahoma", 12);
var g_bkclr = RGB(46, 48, 63);
var ww = window.Width;
var wh = window.Height;
var menuman = fb.CreateMainMenuManager();
var menu = window.CreatePopupMenu();
var ret;

function SimpleButton(x, y, w, h, text, fonClick, state) {
    this.state = state ? state : ButtonStates.normal;
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.text = text;
    this.fonClick = fonClick;
   
    this.containXY = function (x, y) {
        return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
    }
   
    this.changeState = function (state) {
        var old = this.state;
        this.state = state;
        return old;
    }

    this.draw = function (gr) {
        if (this.state == ButtonStates.hide) return;
       
        switch (this.state)
        {
        case ButtonStates.normal:
            g_theme.SetPartAndStateId(1, 1);
            break;
           
        case ButtonStates.hover:
            g_theme.SetPartAndStateId(1, 2);
            break;
           
        case ButtonStates.down:
            g_theme.SetPartAndStateId(1, 3);
            break;
           
        case ButtonStates.hide:
            return;
        }

        g_theme.DrawThemeBackground(gr, this.x, this.y, this.w, this.h);
        gr.GdiDrawText(this.text, g_font, RGB(0,0,0), this.x, this.y, this.w, this.h, DT_CENTER| DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
    }

    this.onClick = function () {
        this.fonClick && this.fonClick();
    }
}

function drawAllButtons(gr) {
gr.FillSolidRect(0, 0, ww, wh, g_bkclr);
for (var i in $buttons) {
        $buttons[i].draw(gr);
    }
}

function chooseButton(x, y) {
    for (var i in $buttons) {
        if ($buttons[i].containXY(x, y) && $buttons[i].state != ButtonStates.hide) return $buttons[i];
    }

    return null;
}

$buttons = {
    Console: new SimpleButton(0, 0, 40, 24, "File", function () {
        fb.ShowConsole();
    }),
    Edit: new SimpleButton(40, 0, 40, 24, "Edit", function () {
        window.ShowConfigure();
    }),
    View: new SimpleButton(80, 0, 40, 24, "View", function () {
   


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


 
    }),
    Playback: new SimpleButton(120, 0, 60, 24, "Playback", function () {
        //window.ShowConfigure();
    }),
    Library: new SimpleButton(180, 0, 50, 24, "Library", function () {
        //window.ShowConfigure();
    }),
    Help: new SimpleButton(230, 0, 40, 24, "Help", function () {
        //window.ShowConfigure();
    })
}

var cur_btn = null;
var g_down = false;

// --- APPLICATION START

function on_paint(gr) {
   
    drawAllButtons(gr);
}

function on_mouse_move(x, y) {
    var old = cur_btn;
    cur_btn = chooseButton(x, y);
   
    if (old == cur_btn) {
        if (g_down) return;
    } else if (g_down && cur_btn && cur_btn.state != ButtonStates.down) {
        cur_btn.changeState(ButtonStates.down);
        window.Repaint();
        return;
    }
       
    old && old.changeState(ButtonStates.normal);
    cur_btn && cur_btn.changeState(ButtonStates.hover);
    window.Repaint();
}

function on_mouse_leave() {
    g_down = false;
   
    if (cur_btn) {
        cur_btn.changeState(ButtonStates.normal);
        window.Repaint();
    }
}

function on_mouse_lbtn_down(x, y) {
    g_down = true;
   
    if (cur_btn) {
        cur_btn.changeState(ButtonStates.down);
        window.Repaint();
    }
}

function on_mouse_lbtn_up(x, y) {
    g_down = false;
   
    if (cur_btn) {
        cur_btn.onClick();
        cur_btn.changeState(ButtonStates.hover);
        window.Repaint();
    }
}

// --- APPLICATION END


WSH Panel Mod

Reply #713
That's nice, but I have all that submenu items as buttons. How do I arrange particular submenu to the particular button. For example, pressing on file button open standart foobar file menu with "Open...", "Open Audio CD...", etc. items?

WSH Panel Mod

Reply #714
sorry i didn't pay full attention to your post.

i've updated your script so each button has it's own menu

Code: [Select]
function RGB(r, g, b) {
    return (0xff000000 | (r << 16) | (g << 8) | (b));
}

ButtonStates = {
    normal: 0,
    hover: 1,
    down: 2,
    hide: 3
}

var DT_TOP = 0x00000000;
var DT_CENTER = 0x00000001;
var DT_VCENTER = 0x00000004;
var DT_WORDBREAK = 0x00000010;
var DT_CALCRECT = 0x00000400;
var DT_NOPREFIX = 0x00000800;

var g_theme = window.CreateThemeManager("Button");
var g_font = gdi.Font("Tahoma", 12);
var g_bkclr = RGB(46, 48, 63);
var ww = window.Width;
var wh = window.Height;

function SimpleButton(x, y, w, h, text, fonClick, state) {
    this.state = state ? state : ButtonStates.normal;
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.text = text;
    this.fonClick = fonClick;
   
    this.containXY = function (x, y) {
        return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
    }
   
    this.changeState = function (state) {
        var old = this.state;
        this.state = state;
        return old;
    }

    this.draw = function (gr) {
        if (this.state == ButtonStates.hide) return;
       
        switch (this.state)
        {
        case ButtonStates.normal:
            g_theme.SetPartAndStateId(1, 1);
            break;
           
        case ButtonStates.hover:
            g_theme.SetPartAndStateId(1, 2);
            break;
           
        case ButtonStates.down:
            g_theme.SetPartAndStateId(1, 3);
            break;
           
        case ButtonStates.hide:
            return;
        }

        g_theme.DrawThemeBackground(gr, this.x, this.y, this.w, this.h);
        gr.GdiDrawText(this.text, g_font, RGB(0,0,0), this.x, this.y, this.w, this.h, DT_CENTER| DT_VCENTER | DT_CALCRECT | DT_NOPREFIX);
    }

    this.onClick = function () {
        menu(this.text, this.x, this.h);
    }
}

function drawAllButtons(gr) {
    gr.FillSolidRect(0, 0, ww, wh, g_bkclr);
    for (var i in $buttons) {
        $buttons[i].draw(gr);
    }
}

function chooseButton(x, y) {
    for (var i in $buttons) {
        if ($buttons[i].containXY(x, y) && $buttons[i].state != ButtonStates.hide) return $buttons[i];
    }

    return null;
}

$buttons = {
    Console: new SimpleButton(0, 0, 40, 24, "File"),
    Edit: new SimpleButton(40, 0, 40, 24, "Edit"),
    View: new SimpleButton(80, 0, 40, 24, "View"),
    Playback: new SimpleButton(120, 0, 60, 24, "Playback"),
    Library: new SimpleButton(180, 0, 50, 24, "Library"),
    Help: new SimpleButton(230, 0, 40, 24, "Help")
}

var cur_btn = null;
var g_down = false;

// --- APPLICATION START

function on_paint(gr) {
   
    drawAllButtons(gr);
}

function on_mouse_move(x, y) {
    var old = cur_btn;
    cur_btn = chooseButton(x, y);
   
    if (old == cur_btn) {
        if (g_down) return;
    } else if (g_down && cur_btn && cur_btn.state != ButtonStates.down) {
        cur_btn.changeState(ButtonStates.down);
        window.Repaint();
        return;
    }
       
    old && old.changeState(ButtonStates.normal);
    cur_btn && cur_btn.changeState(ButtonStates.hover);
    window.Repaint();
}

function on_mouse_leave() {
    g_down = false;
   
    if (cur_btn) {
        cur_btn.changeState(ButtonStates.normal);
        window.Repaint();
    }
}

function on_mouse_lbtn_down(x, y) {
    g_down = true;
   
    if (cur_btn) {
        cur_btn.changeState(ButtonStates.down);
        window.Repaint();
    }
}

function on_mouse_lbtn_up(x, y) {
    g_down = false;
   
    if (cur_btn) {
        cur_btn.onClick();
        cur_btn.changeState(ButtonStates.hover);
        window.Repaint();
    }
}

function menu(name, x, y) {
    var menuman = fb.CreateMainMenuManager();
var menu = window.CreatePopupMenu();
var ret;
menuman.Init(name);
menuman.BuildMenu(menu, 1, 300);
ret = menu.TrackPopupMenu(x, y);
if (ret > 0) menuman.ExecuteByID(ret - 1);
menuman.Dispose();
menu.Dispose();
}

the behaviour of the hover/down/normal images is a bit odd though and i don't know how to fix that.





WSH Panel Mod

Reply #715
Thanks, marc2003! I think i have an idea how get this thing fixed! All U have to do is to add old.changeState(ButtonStates.normal); in that function:

Code: [Select]
function on_mouse_move(x, y) {
var old = cur_btn;
cur_btn = chooseButton(x, y);

if (old == cur_btn) {
if (g_down) return;
} else if (g_down && cur_btn && cur_btn.state != ButtonStates.down) {
old.changeState(ButtonStates.normal);
cur_btn.changeState(ButtonStates.down);
window.Repaint();
return;
}

WSH Panel Mod

Reply #716
Hey T.P Wang, I first wanted to say "thank you" for this fantastic component.  I've been using foobar2000 for about a year now, but confined myself to the DUI (no Facets for CUI).  Ever since you've released a DUI version of this component, it's felt like entirely new worlds have opened up for me.  Almost half of my new setup consists of WSH Panels.  So, thank you.

Now, I have a feature request.  I'm not sure if this is possible, but here goes:  Currently, the commands "fb.RunContextCommand" and "fb.RunContextCommandWithMetadb" exist to run commands on the context menu.  The latest version of foobar2000 allows for users to hide certain context menu commands, and show them when shift+right-clicking a track.  However, WSH Panel Mod only lets us run commands that are not hidden.  Is it possible to modify this command so that it runs context menu commands whether they are hidden or not? 

This would be particularly useful for those of us who use marc2003's Last.fm script with the customdb component.  Customdb adds a very large number of commands to the "Legacy Commands" submenu, essentially flooding it.  I have to scroll through this submenu before I can even see a single useful command.  Thanks for your consideration.

WSH Panel Mod

Reply #717
Hellow,I have this script,
Quote
new Button(0, 22, 60, 14, {normal: imgPath + "AddOnAlone.png", hover: imgPath + "AddOnAloneMH.png"}, function(){fb.ShowConsole();}),

that call Console
I want to call Equalizer instead of Console.
How is rightly?Maybe something like  function(){fb.ShowEqualizer(),but this don't work.
Please help me!

 

WSH Panel Mod

Reply #718
This should do it:

function(){fb.RunMainMenuCommand("View/Equalizer");}


WSH Panel Mod

Reply #720
I found a possible bug: If I use the enter key to show a pop-up menu I hear a windows sound (bell).

This is the most simple code to show this behaviour:
Code: [Select]
var list = ["test 1", "test 2", "test 3", "test 4", "test 5", "test 6", "test 7", "test 8", "test 9", "test 10"];

function on_key_down(vkey) {
    if (vkey == 13) {
        var popupmenu = window.CreatePopupMenu();
        for (var i in list) {
            popupmenu.AppendMenuItem(0, parseInt(i) + 1, this.list[i]);
        }
        var menuret = popupmenu.TrackPopupMenu(0, 0);
        popupmenu.Dispose();
    }
}


I am using Foobar2000 v1.0 and WSH Panel Mod v1.3.1 in Windows 7 x64

WSH Panel Mod

Reply #721
^It works in CUI.
I'll add a new callback on_key_up() as a workaround (you won't get some keys in on_key_down() in DUI).

WSH Panel Mod

Reply #722
^It works in CUI.
I'll add a new callback on_key_up() as a workaround (you won't get some keys in on_key_down() in DUI).


I had this problem in CUI (never tried it in DUI). With keys one doesn't get, you mean for example the tab key?

WSH Panel Mod

Reply #723
hello, friends

I'm trying to create button, which indicates and switches state of "Library/Playback Statistics/Monitor playing Tracks" menu without menu creation. I use "MainMenuManager" sample but can't get "Playback Statistics" submenu.

Code: [Select]
function on_item_focus_change() {
var _context = fb.CreateMainMenuManager();
var _basemenu = window.CreatePopupMenu();
var _child = window.CreatePopupMenu();
var ret;

// Please start index at 1, NOT 0
_basemenu.AppendMenuItem(MF_STRING, 1, "item1");
_basemenu.AppendMenuItem(MF_STRING, 2, "item2");
_basemenu.AppendMenuItem(MF_STRING | MF_POPUP, _child.ID, "Playback Statistics");

_context.Init("Library/Playback Statistics");
_context.BuildMenu(_child, 3, -1);

}


_context.Init("Library/Playback Statistics"); - causes error.

What I shall do to get this submenu? Can anybody give me some examples, pls?

WSH Panel Mod

Reply #724
I am having problems with wsh mod panels not updating in DUI when import theme (.fth) files (XP SP3). The problem occurs when the wsh mod panels are in the same place in the theme files. The code from the original panel and not the newly imported panel continues to be displayed. It seems as if the new panel is not recognised as new.

This can simply be demonstrated as follows. Create a new DUI layout that contains just one panel that is a wsh mod panel. Import your Volbar.txt sample code into the wsh mod panel. Export the created theme and name it volbar.fth. Next change the code in the wsh mod panel by importing your Glow Text Sample.txt. Export the new theme and name it glow.fth. Now import the volbar.txt theme file. The glow text continues to be displayed whereas the volbar should be displayed. Although right clicking the panel, selecting configure and then OK will result in the correct display, this is not ideal especially when there are many wsh mod panels in the theme files.