Cabbage Logo
Back to Cabbage Site

toFront()?

I was trying to make use of the toFront() identifier. I was hoping that the following would alternate bringing the red and blue circles to the front, so any advice on how to get this working would be very much appreciated.

<Cabbage>
form caption("Untitled") size(700, 200), guiMode("queue"), pluginId("def1")
image bounds(200,50,100,100), channel("red"), colour("red"), shape("ellipse")
image bounds(250,50,100,100), channel("blue"), colour("blue"), shape("ellipse")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -dm0
</CsOptions>
<CsInstruments>
0dbfs = 1

instr 1
schedkwhen metro:k(1,0  ),0,0,2,0,0
schedkwhen metro:k(1,0.5),0,0,3,0,0
endin

instr 2
print p1
cabbageSet "red","toFront"
endin

instr 3
print p1
cabbageSet "blue","toFront"
endin

</CsInstruments>
<CsScore>
i 1 0 z
</CsScore>
</CsoundSynthesizer>

Hi Iain. Sorry for the delay in getting back to you. Looks like a forgotten identifier. I’ll fix this tomorrow if I get a chance.

This is fixed now Iain. :+1:

1 Like

Thanks, Rory. This seems to work fine now.

On a related topic, should moveBehind(widgetName) be the converse of this, with widgetName being the channel name of the widget the messaged widget should move behind?

The following seems to work once, i.e.: blue moves behind red, then red moves behind blue, but that’s it, whereas is should continue toggling.

<Cabbage>
form caption("Untitled") size(700, 200), guiMode("queue"), pluginId("def1")
image bounds(200,50,100,100), channel("red"), colour("red"), shape("ellipse")
image bounds(250,50,100,100), channel("blue"), colour("blue"), shape("ellipse")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -dm0
</CsOptions>
<CsInstruments>
0dbfs = 1

instr 1
schedkwhen metro:k(1,0  ),0,0,2,0,0
schedkwhen metro:k(1,0.5),0,0,3,0,0
endin

instr 2
print p1
cabbageSet "blue","moveBehind","red"
endin

instr 3
print p1
cabbageSet "red","moveBehind","blue"
endin

</CsInstruments>
<CsScore>
i 1 0 z
</CsScore>
</CsoundSynthesizer>

I think the issue here is that the identifier listeners in Cabbage all listen for changes. In this case, moveBehind is not changing from red or blue, for channels blue and red. I’m looking for a way to fix it, toFront() works because I fool it into thinking something has updated.

To be honest, toFront() is probably sufficient - and a useful addition, I just thought I’d test out the other.

It’s fixed now at any rate. I just used the same approach I took with toFront() :+1:

1 Like