Help - Search - Members - Calendar
Full Version: Panels UI Windowsize button
Hydrogenaudio Forums > Hosted Forums > foobar2000 > 3rd Party Plugins - (fb2k)
misterhektik
I'm trying to make a button that will toggle full/compact display in my layout. This is the code I have:

QUOTE
// PerTrack
$ifequal($getpvar(ShowFull),1,
$button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,C:\Program Files\foobar2000\images\buttonsmilk\7view.png,C:\Program Files\foobar2000\images\buttonsmilk\7view_hot.png,'WINDOWSIZE:350:700:LEFT:TOP',)
$setpvar(ShowFull,0)
,
$button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,C:\Program Files\foobar2000\images\buttonsmilk\7view.png,C:\Program Files\foobar2000\images\buttonsmilk\7view_hot.png,'WINDOWSIZE:350:408:LEFT:TOP',)
$setpvar(ShowFull,1)
)


The button only works twice. For example, I will play a song, hit the button, and it will resize the window. Hit it again, and it goes back to the previous side. After that, nothing. I have to switch track for the button to work again. Is there any way to have it work all the time? I tried putting it in Global, Background, PerSecond, nothing seems to work. Appreciate the help
shakey_snake
I don't think the WINDOWSIZE command needs the single quote wrap-treatment (although I can't think why that would negitively effect it)

So, I would try it without.

EDIT: try using relative paths, as well.
misterhektik
I removed the single quotes, still no go.

Also removed C:\etc, nothing biggrin.gif
misterhektik
This is the entire code, if it helps. I should state that a lot of this code was found using the search button on these forums biggrin.gif

CODE
// Background
$setpvar(C0,47-57-67)
$setpvar(C1,92-114-137)
$setpvar(C2,229-233-242)
$setpvar(C3,190-202-218)
$setpvar(C4,222-227-231)
$setpvar(C5,255-255-255)
$setpvar(C6,177-182-188)
$setpvar(C7,82-110-131)
$setpvar(C8,224-232-234)
$setpvar(C9,146-159-167)
$setpvar(C10,231-235-238)
$setpvar(ShowFull,0)

$drawrect(0,0,%_width%,%_height%,brushcolor-$getpvar(C0) pencolor-null)

// PerTrack
$panel(Art,Album Art,0,0,%_width%,325,)
$puts(yOffset,325)
$panel(Playing,Track Display,0,$get(yOffset),%_width%,60,)
$puts(yOffset,385)

$panel(Playlist,Single Column Playlist,0,$get(yOffset),%_width%,$sub(%_height%,$add($get(yOffset),23)),)

$button($div($sub(%_width%,190),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\1stop.png,images\buttonsmilk\1stop_hot.png,Playback/Stop,)
$button($div($sub(%_width%,133),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\2pause.png,images\buttonsmilk\2pause_hot.png,Playback/Pause,)
$button($div($sub(%_width%,76),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\3play.png,images\buttonsmilk\3play_hot.png,Playback/Play,)
$button($div($sub(%_width%,19),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\4previous.png,images\buttonsmilk\4previous_hot.png,Playback/Previous,)
$button($div($sub(%_width%,-38),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\5next.png,images\buttonsmilk\5next_hot.png,Playback/Next,)
$button($div($sub(%_width%,-95),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\6random.png,images\buttonsmilk\6random.png,Playback/Random,)
$ifequal($getpvar(ShowFull),1,
    $setpvar(ShowFull,0)
    $button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,WINDOWSIZE:325:700:LEFT:TOP,)
    ,
    $setpvar(ShowFull,1)
    $button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,WINDOWSIZE:325:408:LEFT:TOP,)
)
noorotic
CODE
$ifequal($getpvar(ShowFull),1,
    $setpvar(ShowFull,0)
    $button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,WINDOWSIZE:325:700:LEFT:TOP,)
    ,
    $setpvar(ShowFull,1)
    $button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,WINDOWSIZE:325:408:LEFT:TOP,)
)


I'm not sure, and haven't tested, but I think the problem may be that the button needs to be unconditional. If I were coding it, I'd start the line with:

CODE
$button(,,,,,,/images...,/images....,WINDOWSIZE:325:$ifequal($getpvar(FullShow),1,700,408):LEFT:TOP,)

... and stack another button for toggling the PVAR, maybe. Although it may be possible to just toggle it as a second command after the 'ifequal'.

Not sure that will work, but it is something to try. I can see/guess that your PVAR is getting toggled each time the track changes, without the button having been pressed, for one thing. That is:
CODE
$setpvar(ShowFull,bool)

I believe is getting executed each time the track changes.

Hope that helps.

misterhektik
@noorotic

I changed the conditional to this

CODE
$button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,WINDOWSIZE:325:$ifequal($getpvar(ShowFull),1,700,408):LEFT:TOP,)
$button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,$ifequal($getpvar(ShowFull),1,$setpvar(ShowFull,0),$setpvar(ShowFull,1)):LEFT:TOP,)


However, I still get the same results. Is there a better place to put $setpvar(ShowFull,1) ? I have it in Background, and I've tried putting it in Global but that didn't work either. Maybe I should put the button somewhere other than PerTrack.

Anyways, thanks for your input.
Purple Monkey
You want:

CODE
$button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,WINDOWSIZE:325:$ifequal($getpvar(ShowFull),1,700,408):LEFT:TOP,)
$button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,$ifequal($getpvar(ShowFull),1,'PVAR:SET:ShowFull:0','PVAR:SET:ShowFull:1'),)
misterhektik
Purple Monkey, that broke it even more biggrin.gif Before that code, it would switch twice before having to change track for it to work again. After that code, it only switches once and that's it.
Yotsuya
Have you tried something like this?
CODE
$button($div($add(%_width%,152),2),$sub(%_height%,23),0,0,25,25,,,
PVAR:SET:ShowFull:$ifgreater($getpvar(ShowFull),0,0,1),)

$button($div($add(%_width%,152),2),$sub(%_height%,23),0,0,25,25,
/images\buttonsmilk\7view.png,/images\buttonsmilk\7view_hot.png,
WINDOWSIZE:400:$ifgreater($getpvar(ShowFull),0,408,700),)
misterhektik
Getting the same result I got with Purple Monkey's code. One thing I noticed is that the tooltip over the button says "PVAR:SET:ShowFull:1" and it doesn't seem to change when I press the button.
Yotsuya
Well let's break down your problem because I can put the following code in a track display panel and the button both resizes my foobar and sets a pvar (that is displayed)::
CODE
// Background
$drawrect(0,0,0,0,brushcolor-255-255-255 pencolor-null)

// PerTrack
$button(10,10,0,0,25,25,,,PVAR:SET:ShowFull:$ifgreater($getpvar(ShowFull),0,0,1),)
$button(10,10,0,0,25,25,/images\leokennis\prev.png,/images\leokennis\prev_down.png,
WINDOWSIZE:400:$ifgreater($getpvar(ShowFull),0,400,800),)

// PerSecond
$getpvar(ShowFull)

The tooltip displayed is the last button added to the stack which in this case is WINDOWSIZE.

Can you add a temporary track display panel for testing and build your code piece by piece? Can you confirm if the PVAR is being set or not? How are you marking up your code with refresh headers?
misterhektik
Here is my code

This is in the PanelsUI Layout
CODE
// Global
$setpvar(ShowFull,0)

$setpvar(C0,47-57-67)
$setpvar(C1,92-114-137)
$setpvar(C2,229-233-242)
$setpvar(C3,190-202-218)
$setpvar(C4,222-227-231)
$setpvar(C5,255-255-255)
$setpvar(C6,177-182-188)
$setpvar(C7,82-110-131)
$setpvar(C8,224-232-234)
$setpvar(C9,146-159-167)
$setpvar(C10,231-235-238)

// Background
$drawrect(0,0,%_width%,%_height%,brushcolor-$getpvar(C0) pencolor-null)

// PerTrack
$panel(Art,Album Art,0,0,%_width%,325,)
$puts(yOffset,325)
$panel(Playing,Track Display,0,$get(yOffset),%_width%,60,)
$puts(yOffset,385)
$panel(Playlist,Single Column Playlist,0,$get(yOffset),%_width%,$sub(%_height%,$add($get(yOffset),23)),)
$panel(Buttons,Track Display,0,$sub(%_height%,23),%_width%,23,)


And this is in the Buttons Track Display
CODE
// Background
$drawrect(0,0,%_width%,%_height%,brushcolor-$getpvar(C0) pencolor-null)

// PerTrack
$button($div($sub(%_width%,190),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\1stop.png,images\buttonsmilk\1stop_hot.png,Playback/Stop,)
$button($div($sub(%_width%,133),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\2pause.png,images\buttonsmilk\2pause_hot.png,Playback/Pause,)
$button($div($sub(%_width%,76),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\3play.png,images\buttonsmilk\3play_hot.png,Playback/Play,)
$button($div($sub(%_width%,19),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\4previous.png,images\buttonsmilk\4previous_hot.png,Playback/Previous,)
$button($div($sub(%_width%,-38),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\5next.png,images\buttonsmilk\5next_hot.png,Playback/Next,)
$button($div($sub(%_width%,-95),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\6random.png,images\buttonsmilk\6random.png,Playback/Random,)

$button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,PVAR:SET:ShowFull:$ifgreater($getpvar(ShowFull),0,0,1),)
$button($div($sub(%_width%,-152),2), $sub(%_height%,23), 0, 0, 25, 25,images\buttonsmilk\7view.png,images\buttonsmilk\7view_hot.png,WINDOWSIZE:325:$ifgreater($getpvar(ShowFull),0,700,408):LEFT:TOP,)

// PerSecond
$getpvar(ShowFull)


I'm still getting the same problems, except now there is a green "0" where the buttons are. I don't know much about customizing foobar, so you'll have to explain this "marking up your code with refresh headers" laugh.gif

Purple Monkey
Try changing:
CODE
// Global
$setpvar(ShowFull,0)

to:
CODE
// Global
$if(
    $not($getpvar(ShowFull)),
    $setpvar(ShowFull,0)
)

I think it might be re-setting the pvar to 0 on every run.
misterhektik
QUOTE(Purple Monkey @ Apr 9 2007, 19:11) *

Try changing:
CODE
// Global
$setpvar(ShowFull,0)

to:
CODE
// Global
$if(
    $not($getpvar(ShowFull)),
    $setpvar(ShowFull,0)
)

I think it might be re-setting the pvar to 0 on every run.

Works! Thanks a lot biggrin.gif Also thanks to everyone's input, taught me a lot.

-edit-
One weird thing I just noticed is that there is a green text next to my buttons that shows the value of ShowFull. Don't know how that happened
-edit2-
Ok, never mind, it was the $getpvar(ShowFull) I had in // PerSecond. Erased and all is good.
Yotsuya
Using $setpvar() under // Global is a bit redundant. PVARs are global by nature, you can set them anywhere. If you are only using the variable in the same panel then you should use $puts()/$get() instead of $setpvar()/$getpvar().

Also, I see no real need to declare the pvar as 0. The code you are using can handle the case of nonexistant or improperly set pvars.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.