First of all, i have no idea how foobar scripting works, i tried to copy & paste from other skins, always ends in trial & error.
\user-components\foo_uie_wsh_panel_mod\samples\MainMenuManager All-In-One.txt
Above sample is 99% fine, the only problem is that whereever you click in the panel (blank space), the menu pops out. What i want is to have a clickable button with the following image (don't know why imagebam made it .jpg, it's actually a .png), meaning only a click on the image/button pops out the menu...
Workaround is to use WSH Panel Mod within a Panel Stack Splitter (imagebutton) and adjusting the size, but i'm not fond of this idea.
Anyone with the skills to help me out? btw is it possible to port above script to Panel Stack Splitter?
I changed your script , so you can set your button image. Menu pops up -only on button left click.
Your buttons must be located in '[foobar main folder]\image'
Buttons must be named: menu1.png, menu2.png.
Edit this 295 line, to set 'button position' and 'image path':
//Button position
var top_margin = 5;
var left_margin = 5;
var image_path0 = window.GetProperty("Button Path", fb.ProfilePath + "image");
var image_path = (image_path0 + "\\");
Paste this script:
// vi:set ft=javascript ff=dos ts=4 sts=4 sw=4 et:
// ==PREPROCESSOR==
// @name "MainMenuManager All-In-One"
// @author "YBStone"
// Modded by T.P Wang
// ==/PREPROCESSOR==
// Flags, used by Menu
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 on_mouse_rbtn_up(x, y) {
up(x, y);
return true;
}
function up(x, y) {
var basemenu = window.CreatePopupMenu();
var contextman = fb.CreateContextMenuManager();
contextman.InitNowPlaying();
var child1 = window.CreatePopupMenu(); //File
var child2 = window.CreatePopupMenu(); //Edit
var child3 = window.CreatePopupMenu(); //View
var child4 = window.CreatePopupMenu(); //Playback
var child5 = window.CreatePopupMenu(); //Library
var child6 = window.CreatePopupMenu(); //Help
var child7 = window.CreatePopupMenu(); //Now playing
var menuman1 = fb.CreateMainMenuManager();
var menuman2 = fb.CreateMainMenuManager();
var menuman3 = fb.CreateMainMenuManager();
var menuman4 = fb.CreateMainMenuManager();
var menuman5 = fb.CreateMainMenuManager();
var menuman6 = fb.CreateMainMenuManager();
child1.AppendTo(basemenu, MF_STRING, "File");
child2.AppendTo(basemenu, MF_STRING, "Edit");
child3.AppendTo(basemenu, MF_STRING, "View");
child4.AppendTo(basemenu, MF_STRING, "Playback");
child5.AppendTo(basemenu, MF_STRING, "Library");
child6.AppendTo(basemenu, MF_STRING, "Help");
child7.AppendTo(basemenu, MF_STRING, "Now Playing");
menuman1.Init("file");
menuman2.Init("edit");
menuman3.Init("View");
menuman4.Init("playback");
menuman5.Init("library");
menuman6.Init("help");
menuman1.BuildMenu(child1, 1, 200);
menuman2.BuildMenu(child2, 201, 200);
menuman3.BuildMenu(child3, 401, 200);
menuman4.BuildMenu(child4, 601, 300);
menuman5.BuildMenu(child5, 901, 300);
menuman6.BuildMenu(child6, 1201, 100);
contextman.InitNowPlaying();
contextman.BuildMenu(child7, 1301, -1);
ret = 0;
ret = basemenu.TrackPopupMenu(x, y);
// fb.trace(ret);
switch (true) {
case(ret >= 1 && ret < 201):
menuman1.ExecuteByID(ret - 1);
break;
case (ret >= 201 && ret < 401):
menuman2.ExecuteByID(ret - 201);
break;
case (ret >= 401 && ret < 601):
menuman3.ExecuteByID(ret - 401);
break;
case (ret >= 601 && ret < 901):
menuman4.ExecuteByID(ret - 601);
break;
case (ret >= 901 && ret < 1201):
menuman5.ExecuteByID(ret - 901);
break;
case (ret >= 1201 && ret < 1301):
menuman6.ExecuteByID(ret - 1201);
break;
case (ret >= 1301):
contextman.ExecuteByID(ret - 1301);
break;
}
basemenu.Dispose();
contextman.Dispose();
menuman1.Dispose();
menuman2.Dispose();
menuman3.Dispose();
menuman4.Dispose();
menuman5.Dispose();
menuman6.Dispose();
}
//Buttons---------------------------------------------------
var Buttons;
var g_tooltip = window.CreateTooltip();
var g_down = false;
var btn_down = null;
var cur_btn = null;
ButtonStates = {
normal: 0,
hover: 1,
down: 2
}
function Button(x, y, w, h, img_src, func, tiptext) {
this.left = x;
this.top = y;
this.w = w;
this.h = h;
this.right = x + w;
this.bottom = y + h;
this.func = func;
this.tiptext = tiptext;
this.state = ButtonStates.normal;
this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
this.img = this.img_normal;
this.alterImage = function(img_src) {
this.img_normal = img_src && img_src.normal ? gdi.Image(img_src.normal) : null;
this.img_hover = img_src && img_src.hover ? gdi.Image(img_src.hover) : this.img_normal;
this.img_down = img_src && img_src.down ? gdi.Image(img_src.down) : this.img_hover;
this.changeState(this.state);
}
this.traceMouse = function (x, y) {
var b = (this.left < x) && (x < this.right) && (this.top < y) && (y < this.bottom);
if (b)
g_down ? this.changeState(ButtonStates.down) : this.changeState(ButtonStates.hover);
else
this.changeState(ButtonStates.normal);
return b;
}
this.changeState = function (newstate) {
if (newstate != this.state)
window.RepaintRect(this.left, this.top, this.w, this.h);
this.state = newstate;
switch (this.state)
{
case ButtonStates.normal:
this.img = this.img_normal;
break;
case ButtonStates.hover:
this.img = this.img_hover;
break;
case ButtonStates.down:
this.img = this.img_down;
break;
default:
this.img = null;
}
}
this.draw = function (gr) {
this.img && gr.DrawImage(this.img, this.left, this.top, this.w, this.h, 0, 0, this.w, this.h);
}
this.onClick = function () {
this.func && this.func(x,y);
}
this.onMouseIn = function() {
g_tooltip.Text = this.tiptext;
g_tooltip.Activate();
}
this.onMouseOut = function() {
g_tooltip.Deactivate();
}
}
function buttonsDraw(gr) {
for (i in Buttons) {
Buttons[i].draw(gr);
}
}
function buttonsTraceMouse(x, y) {
var btn = null;
for (i in Buttons) {
if (Buttons[i].traceMouse(x, y) && !btn)
btn = Buttons[i];
}
return btn;
}
function on_mouse_move(x, y) {
var btn = buttonsTraceMouse(x, y);
if (btn != cur_btn) {
cur_btn && cur_btn.onMouseOut();
btn && btn.onMouseIn();
}
cur_btn = btn;
}
function on_mouse_lbtn_down(x, y) {
g_down = true;
btn_down = cur_btn;
if (cur_btn) {
cur_btn.changeState(ButtonStates.down);
}
}
function on_mouse_lbtn_up(x, y) {
if (cur_btn) {
cur_btn.changeState(ButtonStates.hover);
if( btn_down == cur_btn )
cur_btn.onClick(x, y);
}
g_down = false;
}
function on_mouse_leave() {
if (cur_btn) {
cur_btn.changeState(ButtonStates.normal);
}
}
function on_size() {
ww = window.Width;
wh = window.Height;
window.Repaint();
}
//Background
this.dui = window.InstanceType;
function on_paint(gr) {
if (this.dui) {
col = window.GetColorDUI(1);
gr.FillSolidRect(0, 0, ww, wh, col);
}
else
{
col = window.GetColorCUI(3);
}
buttonsDraw(gr);
}
function RGB(r,g,b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}
function on_colors_changed() {
window.Repaint();
}
//Init Buttons--------------------------------------------
//Custom colour
var custom = RGB(255,255,255);
//Button width
var bw = 24;
//Button height
var bh = 20;
//Button position
var top_margin = 5;
var left_margin = 5;
var image_path0 = window.GetProperty("Button Path", fb.ProfilePath + "image");
var image_path = (image_path0 + "\\");
//These 2 lines of code lock the panel size.
//window.MinWidth = window.MaxWidth = 24;
//window.MinHeight = window.MaxHeight = 20;
Buttons = {
but1: new Button(left_margin,top_margin,bw,bh, {normal: image_path + "menu1.png", hover: image_path + "menu2.png"}, function(){
up(24, 17);
}, "Menu")
}
function on_mouse_rbtn_up(x, y) {
return true;
}