WSH Panel - Button Scipt geht nicht richtig

Begonnen von noxx, 25. Juli 2010, 16:17:29

Vorheriges Thema - Nächstes Thema

noxx

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

tedgo

#1
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

noxx

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);
}


fbuser

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.

tedgo

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.

noxx

danke, kann ich ein beispiel haben?
mir fehlt leider dazu das wissen


gruss

tedgo

Ich häng dir mal mein Global Button Script an und ein Script mit diversen Buttons.

noxx

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) :)

fbuser

var mitte = (window.Width-5*bw)/10 (oder die Alternative) mußt du auch nach on_size() verschieben.

noxx