foobar2000 auf Deutsch

foobar2000 => Plugins => Thema gestartet von: noxx in 25. Juli 2010, 16:17:29

Titel: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: noxx in 25. Juli 2010, 16:17:29
Hallo,

ich habe ein Problem mit folgendem Scipt:


// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\common.js"
// @import "%fb2k_path%scripts\tooltip_buttons.js"
// ==/PREPROCESSOR==


var bw = 30;
var bh = 30;
var top_margin = 10;
var left_margin = 0;
var mitte = (window.Width-5*bw)/10


var panel_id = window.GetProperty("panel_id", window.id);
var custom_background_file = settings_path + panel_id + "buttons_background";
var custom_background = read(custom_background_file);


Buttons = {
but1: new Button((mitte*1) ,top_margin,bw,bh, {normal: images_path + "stop_green.png", hover: images_path + "stop_green_hover.png"}, function(){fb.Stop();}, "Stop"),
but2: new Button((mitte*3) +bw,top_margin,bw,bh, {normal: images_path + "pause_green.png", hover: images_path + "pause_green_hover.png"}, function(){fb.Pause();}, "Pause"),
but3: new Button((mitte*5) +bw*2,top_margin,bw,bh, {normal: images_path + "play_green.png", hover: images_path + "play_green_hover.png"}, function(){fb.Play();}, "Play"),
but4: new Button((mitte*7) +bw*3,top_margin,bw,bh, {normal: images_path + "prev_green.png", hover: images_path + "prev_green_hover.png"}, function(){fb.Prev();}, "Previous"),
but5: new Button((mitte*9) +bw*4,top_margin,bw,bh, {normal: images_path + "next_green.png", hover: images_path + "next_green_hover.png"}, function(){fb.Next();}, "Next")
   
}


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

function on_mouse_rbtn_up(x, y) {
buttons_menu(x,y);
return true;
}

function on_paint(gr) {
buttons_background(gr);
buttonsDraw(gr);
}


Wenn ich Foobar starte, sind die Buttons alle auf einer Stelle. Ich muss
erst das Script nochmal aufrufen (Rechte MT und Configure...) und dann
bestätigen, dann wirds richtig gezeigt.
Aber beim nächsten Start wieder das gleiche Problem.

Hat da einer eine Idee?

Gruss
Titel: Re: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: tedgo in 25. Juli 2010, 16:31:42
Erstelle als erste Variablen (falls diese nicht schon in der common.js erstellt wurden):
var ww=0, wh=0;

Und ändere deine Variable:
var mitte = (ww-5*bw)/10
Titel: Re: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: noxx in 25. Juli 2010, 17:15:29
hallo,

danke erstmal. geht aber leider nicht, jetzt sind die buttons immer links....

varibalen waren schon in der common.js

gruss


// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\common.js"
// @import "%fb2k_path%scripts\tooltip_buttons.js"
// ==/PREPROCESSOR==


var bw = 30;
var bh = 30;
var top_margin = 10;
var left_margin = 0;
var mitte = (ww-5*bw)/10


var panel_id = window.GetProperty("panel_id", window.id);
var custom_background_file = settings_path + panel_id + "buttons_background";
var custom_background = read(custom_background_file);


Buttons = {
but1: new Button((mitte*1) ,top_margin,bw,bh, {normal: images_path + "stop_green.png", hover: images_path + "stop_green_hover.png"}, function(){fb.Stop();}, "Stop"),
but2: new Button((mitte*3) +bw,top_margin,bw,bh, {normal: images_path + "pause_green.png", hover: images_path + "pause_green_hover.png"}, function(){fb.Pause();}, "Pause"),
but3: new Button((mitte*5) +bw*2,top_margin,bw,bh, {normal: images_path + "play_green.png", hover: images_path + "play_green_hover.png"}, function(){fb.Play();}, "Play"),
but4: new Button((mitte*7) +bw*3,top_margin,bw,bh, {normal: images_path + "prev_green.png", hover: images_path + "prev_green_hover.png"}, function(){fb.Prev();}, "Previous"),
but5: new Button((mitte*9) +bw*4,top_margin,bw,bh, {normal: images_path + "next_green.png", hover: images_path + "next_green_hover.png"}, function(){fb.Next();}, "Next")
   
}


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

function on_mouse_rbtn_up(x, y) {
buttons_menu(x,y);
return true;
}

function on_paint(gr) {
buttons_background(gr);
buttonsDraw(gr);
}

Titel: Re: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: fbuser in 25. Juli 2010, 17:49:48
Das Problem der ursprünglichen Zeile:

var mitte = (window.Width-5*bw)/10

ist, daß window.Width erst mit dem ersten Aufruf von on_size() einen brauchbaren Wert bekommt. Dein Problem kannst du nur lösen, in dem du erst in on_size() deine Buttons positionierst.
Titel: Re: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: tedgo in 25. Juli 2010, 18:18:19
Du kannst deine Buttons auch gleich in on_size erstellen.
Ist zwar nicht so sauber, bei gerade mal 5 Buttons ist das aber kein sonderliches Problem.

Ich habe in meinem Button-Konstruktor ein "ChangePos" und erstelle meine Buttons normal im Script, positioniere sie allerdings über ChangePos in on_size.
Titel: Re: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: noxx in 25. Juli 2010, 18:22:26
danke, kann ich ein beispiel haben?
mir fehlt leider dazu das wissen


gruss
Titel: Re: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: tedgo in 25. Juli 2010, 18:29:23
Ich häng dir mal mein Global Button Script an und ein Script mit diversen Buttons.
Titel: Re: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: noxx in 25. Juli 2010, 18:44:34
habs mal so probiert, klappt aber auch nicht....

// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\common.js"
// @import "%fb2k_path%scripts\tooltip_buttons.js"
// ==/PREPROCESSOR==


var bw = 30;
var bh = 30;
var top_margin = 10;
var left_margin = 0;
var mitte = (window.Width-5*bw)/10  // alternative var mitte = (ww-5*bw)/10         geht auch nicht.


var panel_id = window.GetProperty("panel_id", window.id);
var custom_background_file = settings_path + panel_id + "buttons_background";
var custom_background = read(custom_background_file);



function on_size() {
ww = window.Width;
wh = window.Height;
   
    Buttons = {
but1: new Button((mitte*1) ,top_margin,bw,bh, {normal: images_path + "stop_green.png", hover: images_path + "stop_green_hover.png"}, function(){fb.Stop();}, "Stop"),
but2: new Button((mitte*3) +bw,top_margin,bw,bh, {normal: images_path + "pause_green.png", hover: images_path + "pause_green_hover.png"}, function(){fb.Pause();}, "Pause"),
but3: new Button((mitte*5) +bw*2,top_margin,bw,bh, {normal: images_path + "play_green.png", hover: images_path + "play_green_hover.png"}, function(){fb.Play();}, "Play"),
but4: new Button((mitte*7) +bw*3,top_margin,bw,bh, {normal: images_path + "prev_green.png", hover: images_path + "prev_green_hover.png"}, function(){fb.Prev();}, "Previous"),
but5: new Button((mitte*9) +bw*4,top_margin,bw,bh, {normal: images_path + "next_green.png", hover: images_path + "next_green_hover.png"}, function(){fb.Next();}, "Next")
   
    }
}





function on_mouse_rbtn_up(x, y) {
buttons_menu(x,y);
return true;
}

function on_paint(gr) {
buttons_background(gr);
buttonsDraw(gr);
}



gruss

@tedgo: danke, sieht aber recht komplex aus (für mich) :)
Titel: Re: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: fbuser in 25. Juli 2010, 19:18:03
var mitte = (window.Width-5*bw)/10 (oder die Alternative) mußt du auch nach on_size() verschieben.
Titel: Re: WSH Panel - Button Scipt geht nicht richtig
Beitrag von: noxx in 25. Juli 2010, 19:35:26
danke ;) nun gehts

:top: