Cabbage Logo
Back to Cabbage Site

New Cabbage widget opcodes

Yes, could potentially work assuming one doesn’t fall asleep on a big comfortable button :wink:

I don’t think this is correct though.

You’re right, it sends a one while pressed, but in this case it’s Ok if it keeps sending values while it is 1, as they are the correct values? Maybe you can explain why the example I posted won’t work, tbh, I’m a little lost on what you are trying to do :laughing:

Please try the cases 1-3 by just changing iCase. I hope you can then see what I am after. I hope I am not abusing your educational patience with my minor issues here.

Another minor one:
cabbageSet kTrig, SChannel, "colour:0(255, 100, 0, 255)"
works but not
cabbageSet kTrig, SChannel, "colour:0", 255, 100, 0, 255
I can leave with the string, but is there a way to send values to “colour:0”?

Now I see your point. Finally! Sorry it took so long. Case three should work. And the last post should also work. I’ll take a look and try to get that sorted. Thanks for persevering with it!

All should work as expected now. Here’s the instrument I’m using to test:

SVGTest.csd (1.3 KB)

And the relevant code. Note that I changed from non-latched to latched to prevent double triggers on a press and release.

instr 1
    kFrq cabbageGet "Frq"
    kX2, kX2Trig cabbageGetValue "X2"
    kX05, kX05Trig cabbageGetValue "X05"
    cabbageSetValue "Frq", kFrq * 2, kX2Trig
    cabbageSetValue "Frq", kFrq * .5, kX05Trig
    
    cabbageSet kX2Trig, "myButton", "colour:0", 255, 100, 0, 255
    
endin

Fantastic! All works… actually better then expected :smiley:
Thank you so much! So happy cooking with fresh cabbage :yum:

1 Like

So, I’m wondering, was one who has only used the old way for a short time, I was wondering if it is as simple as replacing “chnget/set” with their Cabbage equivalent? I’m sure there’s other things I will learn as I go, but can I just start off with replacing the new calls for the old?

Also, I like being able to encapsulate chucks of the gui code within a group object or an image, mostly so I can show and hide them as a group. So, is there anyway to use “cabbageCreate” to add widgets to groups?

If you’re going to use cabbageCreate, you don’t really need groups. You can just manage the components from the Csound side.

Making one call to hide/show everything is much more reliable than a bunch to hide and show and all of them… I’m pretty sure I’ll stick with creating them in Cabbage…

This is true. I will see about adding the use of groups with cabbageCreate. That would be nice.

You can now use the parent() identifier to specify which widget is another’s widget’s parent, for example:

<Cabbage>
form caption("Untitled") size(400, 300), guiMode("queue"), colour(58, 110, 182), pluginId("def1")
button bounds(180, 30, 80, 40), channel("toggle"), value(1)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>

ksmps = 32
nchnls = 2
0dbfs = 1

instr 1
    cabbageCreate "image bounds(0, 0, 100, 100), channel(\"image1\")"
    cabbageCreate "rslider bounds(10, 10, 100, 100), channel(\"slider1\"), parent(\"image1\")"
    kToggle, kTrig cabbageGetValue "toggle"
    cabbageSet kTrig, "image1", "visible", kToggle
endin

We got this feature for free as parent() was already used by Cabbage, but until now it was only ever used internally. I’ve only tested briefly, but it seems to work nicely.

This is awesome, Rory! My project will be creating lots of rows and columns of widgets. I could also see the possibility now of building plugins that can implement their own orchestras (within the knowledge of the user), we can create scores on the fly, and now we can build the gui in real-time.

Why do we need Cabbage again?

1 Like

I’m trying to access rslider limits (min, max) with cabbageGet. While kArray[] cabbageGet "slider", "bounds" works, kArray[] cabbageGet "slider", "range" doesn’t. Is it possible and which identifier should be used?

Ah, try ‘min’, or ‘max’. I don’t think I added support for array output from range. I can do so, but not till later today.

No hurry!

Neither “min” nor “max” get anything (at i- or k-rate). Getting the range would be very useful, e.g. for randomization.

btw. it seems that one has to specify cabbageGetValue:i(...) when reading at init time only. On the other hand chnget() seems to work without the rate specifier (at least for the init pass). It makes sense to use “:i”, so it seems confusing on the Csound side rather then on the Cabbage side. Maybe you have a comment on this? Thanks!

I think chnget defaults to i-time. so you don’t have to use the identifier. But I always recommend using the rate specifier regardless as it’s make things easier to read.

Correct that combobox items names cannot be altered using cabbageSet?

cabbageSet "SynthMode2", {{ items("FM","AM") }}

This only works for combobox that are set to channelType(“string”), i.e, they are not automatable. A combobox is like a slider, in that its range cannot be modified without breaking the host.

got it. ok, i think i can work with that… thanks.

I thought I had this with strget/set. Sorry the String type widgets always trip me up… is there a way to get an index still or store the string somehow to compare it to an ivar?