FiroLFO
(Firo Lightfog)
February 16, 2024, 11:00am
1
I’m interested in coming up with some general purpose menu options to enter a float number in the context menu. I think I’ve seen this in some existing modules but I can’t remember which ones. I even found an old thread about the same topic but the link seems to be outdated.
So in short I’d like to have my
createEnterFloatText(text,ptr)
createEnterFloatSlider(text,ptr)
beside the already available API items:
createMenuLabel(text)
createMenuItem(text, rightText, disabled, rightIcon)
createCheckMenuItem(text, checked, disabled)
createBoolMenuItem(text, value, disabled)
createBoolPtrMenuItem(text, ptr, disabled)
createSubmenuItem(text, menu)
createIndexSubmenuItem(text, labels, getter, setter, disabled, alwaysConsume)
createIndexPtrSubmenuItem(text, labels, ptr)
Any hint or example would be appreciated!
baconpaul
(Paul)
February 16, 2024, 12:22pm
2
The airwin selector menu has typeahead search across the collection.
rightJ->box.pos = {0, 0};
rightJ->box.size = box.size;
rightJ->box.size.x = asz;
rightJ->box.pos.x = box.size.x - asz - 2;
rightJ->box.pos.y += downShift;
rightJ->box.size.y -= downShift;
rightJ->setup();
addChild(rightJ);
}
struct SearchField : rack::ui::TextField
{
rack::WeakPtr<rack::ui::Menu> menu{nullptr};
rack::WeakPtr<AWSelector> selector{nullptr};
std::string lastText{};
void step() override
{
if (text != lastText)
{
if (selector)
selector->resetMenuForSearch(text, menu);
That’s how I did it.
Not much different to implement the things you are talking about
1 Like
FiroLFO
(Firo Lightfog)
February 16, 2024, 1:58pm
3
Thank you, the Airwindows search field is a good way to start for me.
Another example I found is Basically that has a nice title entry field in the menu. And I also see @dan.tilley used sliders in the Purferator menu but that source code is nowhere to be found.
Sorry, my plugin is closed source.
However, the Stoermelder Glue
module has sliders in the context menu that you can crib from:
ThemedModuleWidget<GlueModule>::appendContextMenu(menu);
struct DefaultAppearanceMenuItem : MenuItem {
GlueModule* module;
DefaultAppearanceMenuItem() {
rightText = RIGHT_ARROW;
}
Menu* createChildMenu() override {
Menu* menu = new Menu;
struct SizeSlider : ui::Slider {
struct SizeQuantity : Quantity {
GlueModule* module;
SizeQuantity(GlueModule* module) {
this->module = module;
}
void setValue(float value) override {
module->defaultSize = math::clamp(value, LABEL_SIZE_MIN, LABEL_SIZE_MAX);
}
float getValue() override {
return module->defaultSize;
1 Like
Squinky
February 16, 2024, 3:21pm
5
For that matter VCV itself has sliders in the View menu.
Surge has sliders in the vco menu. Look at vco.cpp
1 Like
But the answer is “menu items are just widgets and you can do whatever you want in them”. Like the color selector for auto connect in surge aw etc
pachde
(Paul Dempsey)
February 16, 2024, 5:48pm
8
You can also look how Rack itself provides the floating point text entry for parameter knob right click menu.
1 Like