8000 Context menus for widgets · Issue #462 · 4ms/metamodule · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Context menus for widgets #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
danngreen opened this issue Feb 10, 2025 · 1 comment
Open

Context menus for widgets #462

danngreen opened this issue Feb 10, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@danngreen
Copy link
Member

Would be nice to support context menus for widgets. In v2.0 we have support for the ModuleWidget menu only.

Some of these menus are attached to knobs, buttons, etc, so the menu could go in that param's page (under the Mapping stuff perhaps?)

But some non-interactive widgets have menus, like the screen in SickoSampler. So we'd need to scan for menu items as widgets are added. Perhaps we allow anything with a menu to be selected on the module, and the side pane shows the menu if it has one.

@danngreen
Copy link
Member Author

An example from SickoPlayer:

void onButton(const event::Button &e) override {
	if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT && (e.mods & RACK_MOD_MASK) == 0) {
		createContextMenu();
		e.consume(this);
	}
}

The createContextMenu() function calls the rack helper createMenu() which constructs a new rack::ui::Menu. In VCV this new menu is immediately added to the APP->scene at the cursor position.

So we would need to call onButton() or maybe some other variations (onDragEnd?) with the correct "right-click" event flags.
Then for

One issue is relating the widget to the element.
Proposal:

  • When parsing widgets on module registration, for each drawable_widget, add a DynamicGraphicDisplay element. Add the light_id of that element to the drawable_widget list (so it's a list of std::pair<Widget*, unsigned> or something).
  • In the ModuleView roller, show the Dyn elements
  • When clicking on one, do a dynamic cast to see if it's a rack plugin module. If so, get the ModuleWidget, and from that get the list of drawable widgets, and scan that for a matching light_id.
  • If found, add an LVGL button to the side pane which does a "Right-click" on the element. Not sure how to word it to indicate that this might not do anything..."Click element"?

For current API (dev-12)

  • When clicking that button, if it calls createMenu(), then the Menu constructor will be called. In Menu(), check a global state to see if we're in a element-view context (as opposed to creating the ModuleWidget menu). If so, then give the created Menu* to our GUI thread, which will take ownership.

For next API (dev-13)

  • Modify the createMenu() in helpers.hpp to register the new Menu* with our GUI context

@danngreen danngreen added the enhancement New feature or request label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant
0