Move the VST3 context menu target implementation

So it can also be used on the Wine side in a bit.
This commit is contained in:
Robbert van der Helm
2022-01-03 14:12:25 +01:00
parent b60139ce77
commit 0e3aba1870
4 changed files with 26 additions and 48 deletions
@@ -0,0 +1,57 @@
// yabridge: a Wine VST bridge
// Copyright (C) 2020-2022 Robbert van der Helm
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include "../vst3/context-menu-target.h"
/**
* 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.
*/
template <typename Bridge>
class YaContextMenuTargetImpl : public YaContextMenuTarget {
public:
YaContextMenuTargetImpl(Bridge& bridge, ConstructArgs&& args) noexcept
: YaContextMenuTarget(std::move(args)), bridge_(bridge) {}
/**
* We'll override the query interface to log queries for interfaces we do
* not (yet) support.
*/
tresult PLUGIN_API queryInterface(const Steinberg::TUID _iid,
void** obj) override {
const tresult result = YaContextMenuTarget::queryInterface(_iid, obj);
bridge_.logger_.log_query_interface(
"In IContextMenuTarget::queryInterface()", result,
Steinberg::FUID::fromTUID(_iid));
return result;
}
// 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});
}
private:
Bridge& bridge_;
};