Hello Cabbage Forum,
My apologies if I am repeating an old topic, I did look around for a solution. I have been working with Cabbage for a few months at this point and usually I can figure out or find the answer to my questions but I am finally stumped.
I am trying to change widget bounds for different layout options (i.e. layout1 and layout2), triggered by 2 buttons (“layout_1_button”, “layout_2_button”) without changing the value of the sliders. The value of each slider is unchanged when moved, but the slider looks like it has returned to default value. I have tried setting the value of the widget after moving, but it does not affect the position of the slider. It is good that moving the widget bounds does not change its value, but it would be nice if the position of the slider reflected its true value after the move. Here is an example of what I have:
<Cabbage>
form caption("Untitled") size(1200, 720), guiMode("queue") pluginId("def1")
label bounds(0, 0, 600, 30), channel("layout_1_label"), text("Layout 1"), fontSize(14), fontColour(175, 195, 255), corners(0), colour(50, 70, 150)
button bounds(0, 0, 599, 30), channel("layout_1_button"), text(""), colour:0(90, 90, 140, 0), colour:1(50, 60, 80, 0), latched(0), presetIgnore(1)
label bounds(601, 0, 599, 30), channel("layout_2_label") text("Layout 2"), fontSize(14), fontColour(175, 195, 255), corners(0), colour(50, 70, 90), presetIgnore(1)
button bounds(600, 0, 600, 30), channel("layout_2_button"), text(""), colour:0(90, 90, 140, 0), colour:1(50, 60, 80, 0), latched(0), presetIgnore(1)
hslider bounds(464, 370, 500, 50), channel("dry_signal"), range(0, 1, 1, 1, 0.01), text("'Dry' Signal"), trackerColour(99, 126, 171), outlineColour(0, 0, 0, 50), colour(27, 55, 102), textColour(175, 195, 255)
hslider bounds(466, 450, 500, 50), channel("reverb"), range(0, 1, 0.5, 1, 0.01), text("Reverb"), trackerColour(99, 126, 171), outlineColour(0, 0, 0, 50), colour(27, 55, 102), textColour(175, 195, 255)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d
</CsOptions>
<CsInstruments>
ksmps = 100
nchnls = 2
0dbfs = 1
gkLayout init 1
instr SelectLayoutListener
kLayout1Button, kTrigger1 cabbageGetValue "layout_1_button"
kLayout2Button, kTrigger2 cabbageGetValue "layout_2_button"
if kLayout1Button + kTrigger1 > 1 then
gkLayout = 1
elseif kLayout2Button + kTrigger2 > 1 then
gkLayout = 2
endif
if kLayout1Button + kTrigger1 > 1 || kLayout2Button + kTrigger2 > 1 then
event("i", "SetLayoutButtonColors", 0, 0, gkLayout)
event("i", "SetHorizSlidersLayout", 0, 0, gkLayout)
endif
endin
instr SetLayoutButtonColors
iLayout = p4
if iLayout == 1 then
cabbageSet "layout_1_label", "colour:0", 50, 70, 150
cabbageSet "layout_2_label", "colour:0", 50, 70, 90
elseif iLayout == 2 then
cabbageSet "layout_1_label", "colour:0", 50, 70, 90
cabbageSet "layout_2_label", "colour:0", 50, 70, 150
endif
endin
instr SetHorizSlidersLayout
iLayout = p4
if iLayout == 1 then
cabbageSet "dry_signal", "bounds", 464, 370, 500, 50
cabbageSet "reverb", "bounds", 466, 450, 500, 50
iDryValue cabbageGetValue "dry_signal"
iReverbValue cabbageGetValue "reverb"
print iDryValue
print iReverbValue
elseif iLayout == 2 then
cabbageSet "dry_signal", "bounds", 163, 380, 380, 50
cabbageSet "reverb", "bounds", 165, 460, 380, 50
iDryValue cabbageGetValue "dry_signal"
iReverbValue cabbageGetValue "reverb"
endif
endin
</CsInstruments>
<CsScore>
i "SelectLayoutListener" 0 1000
</CsScore>
</CsoundSynthesizer>