question on colourful menu items

Actually I just want to give some colour to those squares somehow. Is it possible at all?

menu->addChild(new MenuSeparator);
menu->addChild(createBoolPtrMenuItem("■ Sync to mother", "", &module->indexMumSync));
menu->addChild(createBoolPtrMenuItem("■ Choked by left", "", &module->indexChoke));
menu->addChild(createBoolPtrMenuItem("■ Loop pattern", "", &module->indexLoop));

It must be possible - the port context menus have color to help with cable management. Have a look at the VCV source code to see how it is handled there. Maybe that can get you started.

Use ColorDotMenuItem, introduced in Rack 2.4.

6 Likes

Didn’t know about that new menu class. I guess I need to read the Release notes more carefully :-).

Previous to 2.4 I implemented a menu-driven color picker with swatches in pachde One Copper and related modules. These are free open source for anyone interested, of course.

1 Like

Hmmm… I see. So something like this?

    menu->addChild(createSubmenuItem("ColorDotMenuItem", "",
        [=](Menu* submenu) {
            ColorDotMenuItem* dotItem = new ColorDotMenuItem;
            dotItem->text = "Example Dot"; 
            dotItem->color = nvgRGB(0, 255, 0);  // Green
            dotItem->doAction(true); 
            submenu->addChild(dotItem);  
        }
    ));

You can draw anything your heart desires in a menu item. It’s just a widget you can subclass

Here for instance is how I make the multi color auto connector menu items in surge and airwin and so forth

2 Likes

I was about to say the same thing! Q: Can I make a foo look like a bar? A: yes.

1 Like