IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
ELPlaylist: combined collapse/expand all groups button, was: "Code question from a noob"
glenngulda
post Jul 29 2014, 01:24
Post #1





Group: Members
Posts: 6
Joined: 29-July 14
Member No.: 116820



Hello, I'd like to combine the Collapse / Expand All Groups buttons so that they toggle, like the play pause buttons. How would I have to change the code?

$if($or($not(%ps_isplaying%),%ps_ispause%),
$imagebutton($sub(100,-105),0,,,$get(skin_path)\play.png,$get(skin_path)\play_h.png,COMMAND:Playback/Play or Pause),
$imagebutton($sub(100,-105),0,,,$get(skin_path)\pause.png,$get(skin_path)\pause_h.png,COMMAND:Playback/Play or Pause))
$imagebutton($sub(%_width%,180),3,18,18,images/collapse.png,images/collapse_over.png,COMMAND:'View/ELPlaylist/Collapse All Groups',,)
$imagebutton($sub(%_width%,202),3,18,18,images/expand.png,images/expand_over.png,COMMAND:'View/ELPlaylist/Expand All Groups',,)

Go to the top of the page
+Quote Post
WilB
post Jul 29 2014, 11:26
Post #2





Group: Members
Posts: 313
Joined: 20-July 06
Member No.: 33113



You probably need to set a global variable that toggles. I tested a variant of that below and it worked for me, but my image paths were different to yours - so if the below doesn't work check the code carefully.

CODE
$init_ps_global(EXP,0)

$imagebutton($sub(%_width%,180),3,18,18,images/$ifequal(%EXP%,0,collapse,expand).png,images/$ifequal(%EXP%,0,collapse,expand)_over.png,SETGLOBAL:EXP:$ifequal(%EXP%,0,1,0);COMMAND:View/ELPlaylist/$ifequal(%EXP%,0,Collapse,Expand) All Groups,,)



Go to the top of the page
+Quote Post
glenngulda
post Jul 29 2014, 17:22
Post #3





Group: Members
Posts: 6
Joined: 29-July 14
Member No.: 116820



Thanks. It almost works, the problem is that the buttons only change at the end of a song, not immediately after clicking.
Go to the top of the page
+Quote Post
WilB
post Jul 29 2014, 18:28
Post #4





Group: Members
Posts: 313
Joined: 20-July 06
Member No.: 33113



Yeah; I copied your code as a basis and it lacks the normal ";REFRESH" command that I had included in my tests.

CODE
$imagebutton($sub(%_width%,180),3,18,18,images/$ifequal(%EXP%,0,collapse,expand).png,images/$ifequal(%EXP%,0,collapse,expand)_over.png,SETGLOBAL:EXP:$ifequal(%EXP%,0,1,0);COMMAND:View/ELPlaylist/$ifequal(%EXP%,0,Collapse,Expand) All Groups;REFRESH,,)


If that doesn't work try adding 1 or both of the following two commands in the below (experiment to see which is needed; %pp% acts as refreshall - usually most useful as one way of forcing code to run in other panels with complex layouts - whereas refresh just runs code in the panel stack splitter in which it is located).


CODE
$init_ps_global(EXP,0)
                
    $set_ps_global(pp,$if(%ps_ispause%,COMMAND:Playback/Play;COMMAND:Playback/Pause,$if(%ps_isplaying%,COMMAND:Playback/Pause;COMMAND:Playback/Play,COMMAND:Playback/Play;COMMAND:Playback/Pause)))
          
    $imagebutton($sub(%_width%,180),3,18,18,images/$ifequal(%EXP%,0,collapse,expand).png,images/$ifequal(%EXP%,0,collapse,expand)_over.png,%pp%;SETGLOBAL:EXP:$ifequal(%EXP%,0,1,0);COMMAND:View/ELPlaylist/$ifequal(%EXP%,0,Collapse,Expand) All Groups;COMMAND:View/ELPlaylist/Redraw;REFRESH,,)


This post has been edited by WilB: Jul 29 2014, 18:55
Go to the top of the page
+Quote Post
glenngulda
post Jul 30 2014, 01:56
Post #5





Group: Members
Posts: 6
Joined: 29-July 14
Member No.: 116820



That works, thanks. Everything is perfect now, haha!

This post has been edited by glenngulda: Jul 30 2014, 01:56
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd October 2014 - 05:38