Cabbage Logo
Back to Cabbage Site

Toggling Plants not showing up on initialization

This is on the latest build and Win 10. When you first launch the plugin it’s blank, but you can click the toggle to get it working. I’m not sure if you want me to post these here or on Github?

Thanks Slappz, I’ll take a look. I’m happy for you report these issues here as they will get my attention quicker than the github issues tracker.

As far as I can tell, this is expected behaviour. I always get confused by this, but Csound will pass through all k-tests on its init pass. If you put a prints Smessage in the if block you’ll see visible(0) for sliders3.

A cleaner way of doing it would be to use a second instrument to controls the updating of the plants visibility. I’ll update the examples.

<Cabbage>
form size(400, 200), caption("Toggling Plants"), pluginid("TgPl"), guirefresh(10)
button bounds(12, 12, 60, 25), channel("but1"), text("Toggle", "Toggle")

groupbox bounds(80, 10, 200, 160), text("White Sliders"), visible(0), identchannel("sliders1"){
hslider bounds(0, 30, 200, 30), channel("hslider1"), range(0, 100, 55), colour("white")
hslider bounds(0, 60, 200, 30), channel("hslider2"), range(0, 100, 23), colour("white")
hslider bounds(0, 90, 200, 30), channel("hslider3"), range(0, 100, 45), colour("white")
hslider bounds(0, 120, 200, 30), channel("hslider4"), range(0, 100, 56), colour("white")
}

groupbox bounds(80, 10, 200, 160), text("Red Sliders"), visible(0), identchannel("sliders2"){
hslider bounds(0, 30, 200, 30), channel("hslider5"), range(0, 100, 25), colour("red")
hslider bounds(0, 60, 200, 30), channel("hslider6"), range(0, 100, 63), colour("red")
hslider bounds(0, 90, 200, 30), channel("hslider7"), range(0, 100, 15), colour("red")
hslider bounds(0, 120, 200, 30), channel("hslider8"), range(0, 100, 16), colour("red")
}

groupbox bounds(80, 10, 200, 160), text("Yellow Sliders"), visible(1), identchannel("sliders3"){
hslider bounds(0, 30, 200, 30), channel("hslider9"), range(0, 100, 5), colour("yellow")
hslider bounds(0, 60, 200, 30), channel("hslider10"), range(0, 100, 63), colour("yellow")
hslider bounds(0, 90, 200, 30), channel("hslider11"), range(0, 100, 25), colour("yellow")
hslider bounds(0, 120, 200, 30), channel("hslider12"), range(0, 100, 96), colour("yellow")
}

</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs=1

instr 1
	kCnt init 1
	kTrig changed chnget:k("but1") 

	if kTrig==1 then
	    event "i", 2, 0, 1, kCnt
	    kCnt = (kCnt>2 ? 1 : kCnt+1)
	endif
	
endin


instr 2
        Smessage sprintfk "visible(%d)", p4==1 ? 1 : 0
		chnset Smessage, "sliders1"
		Smessage sprintfk "visible(%d)", p4==2 ? 1 : 0
		chnset Smessage, "sliders2"
		Smessage sprintfk "visible(%d)", p4==3 ? 1 : 0
		chnset Smessage, "sliders3"
endin

</CsInstruments>  
<CsScore>
f1 0 2048 10 1 
i1 0 1000
</CsScore>
</CsoundSynthesizer>

For what it’s worth, I would encourage people to use the tofront method. The ToggleToFront.csd example works fine for me here. Can you try that too?

Yes, I thought we discussed this earlier? I checked again and it does work and also show the initial screen.