Cabbage Logo
Back to Cabbage Site

Nesting macros issue?

I want to do something like the following:

;define a color
#define COLOUR1 (125, 125, 125, 255)

;define a macro that uses that colour
#define REC_BUTTON text("Rec", "Rec") colour:0($COLOUR1) colour:1(200, 0, 0, 200) fontColour:0(200, 0, 0, 255) fontColour:1(255, 255, 255, 255) corners(10) outlineColour(0, 0, 0, 50) outlineThickness(1) 

;define buttons that use these as inputs
button bounds(114, 110, 50, 40) channel("overdub1"), $REC_BUTTON 
button bounds(214, 110, 50, 40) channel("overdub2"), $REC_BUTTON 

I can’t get it to work correctly. The goal is to be able to easily change COLOUR1 and have it impact globally, but the nesting seems to cause an issue. Any tips?

Thanks!

Unfortunately you can’t nest macros in that way.

Why not just make COLOUR1 a complete identifier and append its macro expansion on the end of the button line?

#define COLOUR1 colour:0(125, 125, 125, 255)

;define a macro that uses that colour
#define REC_BUTTON text("Rec", "Rec") colour:0(0,0,0) colour:1(200, 0, 0, 200) fontColour:0(200, 0, 0, 255) fontColour:1(255, 255, 255, 255) corners(10) outlineColour(0, 0, 0, 50) outlineThickness(1)

;define buttons that use these as inputs
button bounds(114, 110, 50, 40) channel("overdub1"), $REC_BUTTON, $COLOUR1
button bounds(214, 110, 50, 40) channel("overdub2"), $REC_BUTTON, $COLOUR1

If Cabbage encounters repeats of the same identifier, it uses the last one so the colour definition in REC_BUTTON functions like a default which can be overridden.

1 Like

Thanks for the suggestion. I’m using the same colour across different types of widgets (buttons, sliders, etc.), but that’s probably the best option given the constraints.

Bryan