From 0cbcf44e3ece62cf9cf2313b69f2b40a70b1d245 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 6 Jan 2021 17:33:21 +0100 Subject: [PATCH] Add stubs for an IContextMenu implementation --- meson.build | 1 + src/common/serialization/vst3.h | 1 + .../bridges/vst3-impls/context-menu-proxy.cpp | 83 +++++++++++++++++++ .../bridges/vst3-impls/context-menu-proxy.h | 56 +++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 src/wine-host/bridges/vst3-impls/context-menu-proxy.cpp create mode 100644 src/wine-host/bridges/vst3-impls/context-menu-proxy.h diff --git a/meson.build b/meson.build index 02c6204d..92c6ff0c 100644 --- a/meson.build +++ b/meson.build @@ -201,6 +201,7 @@ if with_vst3 'src/common/serialization/vst3/process-data.cpp', 'src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp', 'src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp', + 'src/wine-host/bridges/vst3-impls/context-menu-proxy.cpp', 'src/wine-host/bridges/vst3-impls/host-context-proxy.cpp', 'src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp', 'src/wine-host/bridges/vst3.cpp', diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index bfed88a4..daf75285 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -25,6 +25,7 @@ #include "common.h" #include "vst3/component-handler-proxy.h" #include "vst3/connection-point-proxy.h" +#include "vst3/context-menu-proxy.h" #include "vst3/host-context-proxy.h" #include "vst3/plug-frame-proxy.h" #include "vst3/plug-view-proxy.h" diff --git a/src/wine-host/bridges/vst3-impls/context-menu-proxy.cpp b/src/wine-host/bridges/vst3-impls/context-menu-proxy.cpp new file mode 100644 index 00000000..55489bfe --- /dev/null +++ b/src/wine-host/bridges/vst3-impls/context-menu-proxy.cpp @@ -0,0 +1,83 @@ +// yabridge: a Wine VST bridge +// Copyright (C) 2020-2021 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 . + +#include "context-menu-proxy.h" + +#include + +Vst3ContextMenuProxyImpl::Vst3ContextMenuProxyImpl( + Vst3Bridge& bridge, + Vst3ContextMenuProxy::ConstructArgs&& args) + : Vst3ContextMenuProxy(std::move(args)), bridge(bridge) {} + +Vst3ContextMenuProxyImpl::~Vst3ContextMenuProxyImpl() { + // Also drop the context menu smart pointer on plugin side when this gets + // dropped + // TODO: Uncomment when we implement this + // bridge.send_message( + // Vst3ContextMenuProxy::Destruct{.owner_instance_id = + // owner_instance_id(), + // .context_menu_id = + // context_menu_id()}); +} + +tresult PLUGIN_API +Vst3ContextMenuProxyImpl::queryInterface(const Steinberg::TUID _iid, + void** obj) { + const tresult result = Vst3ContextMenuProxy::queryInterface(_iid, obj); + bridge.logger.log_query_interface("In IContextMenu::queryInterface()", + result, Steinberg::FUID::fromTUID(_iid)); + + return result; +} + +int32 PLUGIN_API Vst3ContextMenuProxyImpl::getItemCount() { + // TODO: Implement + std::cerr << "TODO: IContextMenu::getItemCount()" << std::endl; + return Steinberg::kNotImplemented; +} + +tresult PLUGIN_API Vst3ContextMenuProxyImpl::getItem( + int32 index, + Steinberg::Vst::IContextMenuItem& item /*out*/, + Steinberg::Vst::IContextMenuTarget** target /*out*/) { + // TODO: Implement + std::cerr << "TODO: IContextMenu::getItem()" << std::endl; + return Steinberg::kNotImplemented; +} + +tresult PLUGIN_API +Vst3ContextMenuProxyImpl::addItem(const Steinberg::Vst::IContextMenuItem& item, + Steinberg::Vst::IContextMenuTarget* target) { + // TODO: Implement + std::cerr << "TODO: IContextMenu::addItem()" << std::endl; + return Steinberg::kNotImplemented; +} + +tresult PLUGIN_API Vst3ContextMenuProxyImpl::removeItem( + const Item& item, + Steinberg::Vst::IContextMenuTarget* target) { + // TODO: Implement + std::cerr << "TODO: IContextMenu::removeItem()" << std::endl; + return Steinberg::kNotImplemented; +} + +tresult PLUGIN_API Vst3ContextMenuProxyImpl::popup(Steinberg::UCoord x, + Steinberg::UCoord y) { + // TODO: Implement + std::cerr << "TODO: IContextMenu::popup()" << std::endl; + return Steinberg::kNotImplemented; +} diff --git a/src/wine-host/bridges/vst3-impls/context-menu-proxy.h b/src/wine-host/bridges/vst3-impls/context-menu-proxy.h new file mode 100644 index 00000000..4d2fc6c0 --- /dev/null +++ b/src/wine-host/bridges/vst3-impls/context-menu-proxy.h @@ -0,0 +1,56 @@ +// yabridge: a Wine VST bridge +// Copyright (C) 2020-2021 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 . + +#pragma once + +#include "../vst3.h" + +class Vst3ContextMenuProxyImpl : public Vst3ContextMenuProxy { + public: + Vst3ContextMenuProxyImpl(Vst3Bridge& bridge, + Vst3ContextMenuProxy::ConstructArgs&& args); + + /** + * When the reference count reaches zero and this destructor is called, + * we'll send a request to plugin to destroy the corresponding object. + */ + ~Vst3ContextMenuProxyImpl(); + + /** + * 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; + + // From `IContextMenu` + virtual int32 PLUGIN_API getItemCount() override = 0; + virtual tresult PLUGIN_API + getItem(int32 index, + Steinberg::Vst::IContextMenuItem& item /*out*/, + Steinberg::Vst::IContextMenuTarget** target /*out*/) override = 0; + virtual tresult PLUGIN_API + addItem(const Steinberg::Vst::IContextMenuItem& item, + Steinberg::Vst::IContextMenuTarget* target) override = 0; + virtual tresult PLUGIN_API + removeItem(const Item& item, + Steinberg::Vst::IContextMenuTarget* target) override = 0; + virtual tresult PLUGIN_API popup(Steinberg::UCoord x, + Steinberg::UCoord y) override = 0; + + private: + Vst3Bridge& bridge; +};