Proxy host context menu items for VST3 plugins

This wasn't implemented yet because no plugin tried using the interface
in this way before this, but Surge XT incorporates the host's context
menu items into their own (much more elaborate) context menu. To
accommodate this, we now copy over all of the host's prepopulated
context menu items to the Wine plugin host, and calling the targets
associated with any of those items will cause the target on the
associated context menu item on the host to be called.

This is slightly more complicated than what would otherwise be necessary
because Bitwig does not assign tags to their context menu items and
instead always uses 0.
This commit is contained in:
Robbert van der Helm
2022-01-03 17:04:00 +01:00
parent 89cd1e9ee3
commit c625deadef
16 changed files with 219 additions and 107 deletions
@@ -22,6 +22,9 @@
* This implementation used to live in `src/plugin/bridges/vst3-impls`, but
* since plugins can also call context menu items added by the host this is
* needed on both sides.
*
* NOTE: Bitwig does not actually set the tags here, so host menu items need to
* be identified through their item ID, not through the tag.
*/
template <typename Bridge>
class YaContextMenuTargetImpl : public YaContextMenuTarget {
@@ -45,11 +48,16 @@ class YaContextMenuTargetImpl : public YaContextMenuTarget {
// From `IContextMenuTarget`
tresult PLUGIN_API executeMenuItem(int32 tag) override {
return bridge_.send_message(YaContextMenuTarget::ExecuteMenuItem{
.owner_instance_id = owner_instance_id(),
.context_menu_id = context_menu_id(),
.target_tag = target_tag(),
.tag = tag});
// NOTE: This requires mutual recursion, because REAPER will call
// `getState()` whle the context menu is open, and `getState()`
// also has to be handled from the GUI thread
return bridge_.send_mutually_recursive_message(
YaContextMenuTarget::ExecuteMenuItem{
.owner_instance_id = owner_instance_id(),
.context_menu_id = context_menu_id(),
.item_id = item_id(),
.target_tag = target_tag(),
.tag = tag});
}
private: