I know this is off current discussion but it says : "discussion/help" and I need some help with the following:
1. Panels switching inside Foobar only shows after resizing the main window. Should be immidiate. "Tech" was able to do it right but I dunno how.
2. Fade back transition from hover to normal is not smooth how to fix ?
3. How to tell the button to remain in changeState(2) which is the active state until hitting another button ?
Thanks for helping me out
WSH Panel Code:
// ==PREPROCESSOR==
// @import "%fb2k_path%\skins\foooffice\scripts\Flags.txt"
// @import "%fb2k_path%\skins\foooffice\scripts\Helpers.txt"
// @import "%fb2k_path%\skins\foooffice\scripts\Buttons.txt"
// ==/PREPROCESSOR==
var DT_LEFT = 0x00000000;
var DT_RIGHT = 0x00000002;
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 DT_END_ELLIPSIS = 0x00008000;
var g_timer_started = false;
var g_timer;
var WshShell = new ActiveXObject("WScript.Shell");
var button_font = gdi.font("Calibri", 12, 0);
var gen_font = gdi.font("Calibri", 12, 0);
var codec_font = gdi.font("segoe ui", 14, 0);
var settings_dir = fb.FoobarPath + "skins\\foooffice\\settings\\";
var img_dir = fb.FoobarPath + "skins\\foooffice\\images\\";
var script_dir = fb.FoobarPath + "skins\\foooffice\\scripts\\";
function on_paint(gr) {
Foobar_hWnd = utils.GetHWND("{E7076D1C-A7BF-4f39-B771-BCBE88F2A2A8}");
utils.CreateGlass(Foobar_hWnd, 0, 0, 30, 0)
gr.FillSolidRect(0, 0, ww, 30, 0xFF000000);
for (var i in $buttons) {
$buttons[i].draw(gr);
}
}
function on_size() {
ww = window.Width;
wh = window.Height;
if (ww <= 0 || wh <= 0) return;
$buttons = {
button_1: new Button(5, 5, FILETAB.width / 3, FILETAB.height, FILETAB, function () {
update_option("panel_id",1);
}),
button_2: new Button(60, 5, PLAYINGTAB.width / 3, PLAYINGTAB.height, PLAYINGTAB, function () {
update_option("panel_id",2);
})
}
window.Repaint();
}
function on_mouse_move(x, y) {
buttons_on_mouse_move(x, y);
}
function on_mouse_lbtn_down(x, y) {
buttons_on_lbtn_down(x, y);
}
function on_mouse_lbtn_up(x, y) {
buttons_on_mouse_lbtn_up(x, y);
}
function on_mouse_leave() {
buttons_on_mouse_leave();
}
function on_timer(id) {
button_on_timer(id);
}
function update_option(optname, optvalue) {
var fso, f1, ts, s;
var ForReading = 1;
var ForWriting = 2;
fso = new ActiveXObject("Scripting.FileSystemObject");
ts = fso.OpenTextFile(settings_dir + optname + ".txt", ForReading);
s = ts.ReadLine();
ts.Close();
f1 = fso.MoveFile(settings_dir + optname + "_" + s, settings_dir + optname + "_" + optvalue);
ts = fso.OpenTextFile(settings_dir + optname + ".txt", ForWriting);
ts.WriteLine(optvalue);
ts.Close();
return optvalue;
}
function read_option(optname, initvalue) {
var fso, ts, ts2, s;
var ForReading = 1;
var ForWriting = 2;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (file_exists(settings_dir + optname + ".txt") == true) {
ts = fso.OpenTextFile(settings_dir + optname + ".txt", ForReading);
s = ts.ReadLine();
ts.Close();
return s;
} else {
ts = fso.CreateTextFile(settings_dir + optname + ".txt", ForWriting);
ts.WriteLine(initvalue);
ts.Close();
ts2 = fso.CreateTextFile(settings_dir + optname + "_" + initvalue, ForWriting);
ts2.Close();
return initvalue;
}
}
This is the imported Buttons.txt
var imgPath = fb.FoobarPath + "skins\\foooffice\\images\\";
var FILETAB = gdi.Image(imgPath +"buttons\\tab_file_sprite.png");
var PLAYINGTAB = gdi.Image(imgPath +"buttons\\tab_playing_sprite.png");
var button_timer = false;
var button_timeout;
var button_font = gdi.font("Lucida Sans Unicode", 10, 0);
var g_font = gdi.font("segoe_ui", 14, 0);
var xy = false;
var hbtn;
var dbtn;
function Button(x, y, w, h, o, onclick) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.o = o;
this.onclick = onclick;
this.oldstate = 0;
this.state = 0;
this.opacity = 0;
this.refresh = 0;
this.xy = function (x, y) {
return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
}
// ===================================
this.changeState = function (state) {
if (!button_timer) button_timer = window.CreateTimerInterval(60);
this.oldstate = this.state;
this.state = state;
this.opacity = 0;
this.refresh = 1;
switch (state) {
case 0:
this.step = 35;
window.SetCursor(32512);
break;
case 1:
this.step = 55;
window.SetCursor(32649);
break;
case 2:
this.step = 75;
break;
};
}
// =================================== Image Button
this.draw = function (gr) {
if (this.opacity < 255) gr.DrawImage(this.o, this.x, this.y, this.w, this.h, this.oldstate * this.w, 0, this.w, this.h, 0, 255);
if (this.opacity) gr.DrawImage(this.o, this.x, this.y, this.w, this.h, this.state * this.w, 0, this.w, this.h, 0, this.opacity);
};
// ===================================
this.RefreshOpacity = function () {
if (this.opacity < 255) this.opacity = Math.min(this.opacity + this.step, 255);
else {
this.oldstate = this.state;
this.opacity = 0;
this.refresh = 0;
if (this.opacity == 0) button_timeout = window.CreateTimerTimeout(5000);
}
window.RepaintRect(this.x, this.y, this.w, this.h+2);
};
// ===================================
this.onClick = function () {
this.onclick && this.onclick();
}
}
// ========================================================================== //
buttons_on_mouse_move = function(x, y){
xy = false;
for (var i in $buttons)
if ($buttons[i].xy(x, y)) {
xy = true;
if (hbtn != $buttons[i]) {
if (hbtn) hbtn.changeState(0);
hbtn = $buttons[i];
hbtn.changeState(1);
};
}
if (xy == false) {
if (hbtn) {
hbtn.changeState(0);
hbtn = undefined;
};
}
}
// ========================================================================== //
buttons_on_lbtn_down = function (x, y) {
if (hbtn) {
dbtn = hbtn;
dbtn.changeState(2);
hbtn = undefined;
}
}
// ========================================================================== //
buttons_on_mouse_lbtn_up = function (x, y) {
if (dbtn) {
dbtn.changeState(1);
dbtn.onClick();
dbtn = undefined;
}
}
// ========================================================================== //
buttons_on_mouse_leave = function () {
if (hbtn) {
hbtn.changeState(0);
hbtn = undefined;
}
on_size();
window.Repaint();
}
// ===================================
button_on_timer = function (id) {
if (button_timeout && id == button_timeout.ID) {
if (button_timer) window.KillTimer(button_timer);
button_timer = false;
}
for (var i in $buttons) {
if ($buttons[i].refresh) {
$buttons[i].RefreshOpacity();
}
};
}
Here you can download the pack for use in columnsUI
http://hotfile.com/dl/63610538/4ccaadb/foooffice.zip.html
Wshpanel Pastebin
Buttons.txt Pastebin