Get rid of the ww/wh variables and use panel.w and panel.h instead. Also, your buttons should go inside the on_size function, after panel.size().
I'm having a similar problem. The values of panel.w and panel.h are equal to 0 so they are not useful for my purpose.
I need the values of window.height and window.width to automatically update.
// ==PREPROCESSOR==
// @name "np_basic"
// @author "marc2003"
// @import "%fb2k_profile_path%js_marc2003\js\lodash.min.js"
// @import "%fb2k_profile_path%js_marc2003\js\helpers.js"
// @import "%fb2k_profile_path%js_marc2003\js\panel.js"
// @import "%fb2k_profile_path%js_marc2003\js\thumbs.js"java script:bbc_pop()
// @import "%fb2k_profile_path%js_marc2003\js\text.js"
// @import "%fb2k_profile_path%js_marc2003\js\rating.js"
// ==/PREPROCESSOR==
//the track info section displays 3 lines of title formatted text. you can customise that here/////////////////////////////////////////////
var line1 = {
text: "", //leave this blank
tf: "%title%", //enter any title formatting
font: _.gdiFont("Calibri", 24, 0), //font name, size, style. 1 means bold and 0 is normal.
colour: _.RGB(240, 240, 240), //colour
y: 0 //change this value to move text up or down.
}
var line2 = {
text: "",
tf: "%album artist% - %album%",
font: _.gdiFont("Segoe UI", 16, 0),
colour: _.RGB(240, 240, 240),
y: 40
}
var line3 = {
text: "",
tf: "[%album% ]['('%date%')']",
font: _.gdiFont("Segoe UI", 14, 1),
colour: _.RGB(180, 180, 180),
y: 65
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var panel = new _.panel("np_basic", ["metadb", "remap", "custom_background"]);
var text = new _.text("lastfm_bio", 20, 0, 0, 0);
var thumbs = new _.thumbs();
var panw = window.Width; // panel width
var pan_h = window.Height; // panel height
thumbs.mode = 5;
var bar_h = 80; // height of the title stuff
var buttons = new _.buttons();
var mbuts = 48; // menu button size
buttons.buttons.menu = new _.button( panw - 5 - mbuts, (bar_h - mbuts) / 2, mbuts, mbuts, {normal : "misc\\foobar2000.png"}, function () { _.menu(0, 36); }, "Menu");
var guifx_font = _.gdiFont(guifx.font, 8, 1);
//rating
var r_x = (panw - 28 * 5) / 2; // rating buttons starting x position
var r_y = bar_h + 5; //rating buttons starting y position
var rating = new _.rating(r_x, r_y, 28, _.RGB(128, 128, 128), _.RGB(255, 128, 0));
//playback buttons
var bs = 80; // playback buttons size
var strpnt_x = (panw - bs) / 2; // playback buttons starting x position
var strpnt_y = pan_h - 100; // playback buttons starting y position
buttons.buttons.stop = new _.button(strpnt_x - bs * 3, strpnt_y, bs, bs , {normal : "buttons\\stop.png"}, function () { fb.Stop(); }, "Stop");
buttons.buttons.play = new _.button(strpnt_x, strpnt_y, bs, bs, {normal : !fb.IsPlaying || fb.IsPaused ? "buttons\\play.png" : "buttons\\pause.png"}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "Play" : "Pause");
buttons.buttons.previous = new _.button(strpnt_x - bs * 1.5, strpnt_y, bs, bs, {normal : "buttons\\previous.png"}, function () { fb.Prev(); }, "Previous");
buttons.buttons.next = new _.button(strpnt_x + bs * 1.5 , strpnt_y, bs, bs, {normal : "buttons\\next.png"}, function () { fb.Next(); }, "Next");
buttons.buttons.next1 = new _.button(strpnt_x + bs * 3, strpnt_y, bs, bs, {normal : "buttons\\next.png"}, function () { fb.Next(); }, "Next");
buttons.update = function () {
this.buttons.play = new _.button(bs, 0, bs, bs, {normal : !fb.IsPlaying || fb.IsPaused ? "buttons\\play.png" : "buttons\\pause.png"}, function () { fb.PlayOrPause(); }, !fb.IsPlaying || fb.IsPaused ? "Play" : "Pause");
window.RepaintRect(this.buttons.play.x, this.buttons.play.y, this.buttons.play.w, this.buttons.play.h);
}
panel.item_focus_change();
function on_size() {
panel.size();
thumbs.size();
text.y = _.floor(panel.h * 0.75);
text.w = panel.w - 40
text.h = panel.h - text.y - 5;
text.size();
}
function on_paint(gr) {
panel.colours.text = _.RGB(220, 220, 220);
panel.paint(gr);
thumbs.paint(gr);
gr.FillSolidRect(0, 0, panel.w, bar_h, _.RGBA(0, 0, 0, 196));
gr.GdiDrawText(line1.text, line1.font, line1.colour, 10, line1.y, panel.w - 20, line1.font.Height, LEFT);
gr.GdiDrawText(line2.text, line2.font, line2.colour, 10, line2.y, panel.w - 20, line2.font.Height, LEFT);
//gr.GdiDrawText(line3.text, line3.font, line3.colour, 10, line3.y, panel.w - 20, line3.font.Height, LEFT);
//gr.FillSolidRect(text.x - 15, text.y, text.w + 30, text.h, _.RGBA(0, 0, 0, 156));
text.paint(gr);
buttons.paint(gr);
gr.SetTextRenderingHint(4);
if (fb.StopAfterCurrent)
gr.DrawString("4", guifx_font, _.RGB(196, 30, 35), buttons.buttons.stop.x, buttons.buttons.stop.y + 1, buttons.buttons.stop.w, buttons.buttons.stop.h, SF_CENTRE);
rating.paint(gr);
}
function on_metadb_changed() {
thumbs.metadb_changed();
//text.metadb_changed();
if (panel.metadb) {
line1.text = panel.tf(line1.tf);
line2.text = panel.tf(line2.tf);
line3.text = panel.tf(line3.tf);
}
window.Repaint();
rating.metadb_changed();
}
function on_playlist_stop_after_current_changed() {
window.RepaintRect(buttons.buttons.stop.x, buttons.buttons.stop.y, buttons.buttons.stop.w, buttons.buttons.stop.h);
}
function on_playback_stop() {
buttons.update();
}
function on_playback_pause() {
buttons.update();
}
function on_playback_starting() {
buttons.update();
}
function on_mouse_move(x, y) {
buttons.move(x, y);
rating.move(x, y);
}
function on_mouse_leave() {
buttons.leave();
rating.leave();
}
function on_mouse_lbtn_up(x, y) {
buttons.lbtn_up(x, y);
rating.lbtn_up(x, y);
}
function on_mouse_rbtn_up(x, y) {
return panel.rbtn_up(x, y);
if (buttons.buttons.stop.trace(x, y)) {
var m = window.CreatePopupMenu();
m.AppendMenuItem(MF_STRING, 1, "Stop After Current");
m.CheckMenuItem(1, fb.StopAfterCurrent);
m.AppendMenuSeparator();
m.AppendMenuItem(MF_STRING, 2, "Configure...");
var idx = m.TrackPopupMenu(x, y);
if (idx == 1)
fb.StopAfterCurrent = !fb.StopAfterCurrent;
else if (idx == 2)
window.ShowConfigure();
m.Dispose();
return true;
} else {
return panel.rbtn_up(x, y);
}
}
Sorry if its a bit messy.