diff --git a/README.md b/README.md index 50902361..7b2338ae 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ incomplete list of things that still have to be done before this can be used: components through message passing proxies - The rest of `IPlugView` - `IEditController2` - - `IPlugFrame` - All other mandatory interfaces - All other optional interfaces - Fully implemented: see [this diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index dcea2046..85839b02 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -348,7 +348,7 @@ bool Vst3Logger::log_request(bool is_host_vst, } bool Vst3Logger::log_request(bool is_host_vst, - const YaPluginFactory::SetHostContext& request) { + const YaPluginFactory::SetHostContext&) { return log_request_base(is_host_vst, [&](auto& message) { message << "IPluginFactory3::setHostContext()"; }); @@ -612,6 +612,18 @@ bool Vst3Logger::log_request(bool is_host_vst, }); } +bool Vst3Logger::log_request(bool is_host_vst, + const YaPlugFrame::ResizeView& request) { + return log_request_base(is_host_vst, [&](auto& message) { + message << request.owner_instance_id + << ": IPlugFrame::resizeView(view = , newSize = " + ")"; + }); +} + void Vst3Logger::log_response(bool is_host_vst, const Ack&) { log_response_base(is_host_vst, [&](auto& message) { message << "ACK"; }); } diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index 9eacc48c..e9f3dc03 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -132,6 +132,7 @@ class Vst3Logger { bool log_request(bool is_host_vst, const YaComponentHandler::RestartComponent&); bool log_request(bool is_host_vst, const YaHostApplication::GetName&); + bool log_request(bool is_host_vst, const YaPlugFrame::ResizeView&); void log_response(bool is_host_vst, const Ack&); void log_response( diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index 1e399523..65222858 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -140,7 +140,8 @@ using CallbackRequest = std::variant; + YaHostApplication::GetName, + YaPlugFrame::ResizeView>; template void serialize(S& s, CallbackRequest& payload) { diff --git a/src/common/serialization/vst3/plug-frame/plug-frame.h b/src/common/serialization/vst3/plug-frame/plug-frame.h index a0ad700e..89504638 100644 --- a/src/common/serialization/vst3/plug-frame/plug-frame.h +++ b/src/common/serialization/vst3/plug-frame/plug-frame.h @@ -61,6 +61,28 @@ class YaPlugFrame : public Steinberg::IPlugFrame { inline bool supported() const { return arguments.supported; } + /** + * Message to pass through a call to `IPlugFrame::resizeView` to the + * `IPlugView` object provided by the host. + * + * XXX: Since we don't support multiple `IPlugView`s right now (as it's not + * used the SDK's current version), we'll just assume that `view` is + * the view stored in `Vst3PluginProxyImpl::plug_view` + */ + struct ResizeView { + using Response = UniversalTResult; + + native_size_t owner_instance_id; + + Steinberg::ViewRect new_size; + + template + void serialize(S& s) { + s.value8b(owner_instance_id); + s.object(new_size); + } + }; + virtual tresult PLUGIN_API resizeView(Steinberg::IPlugView* view, Steinberg::ViewRect* newSize) override = 0; diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.h b/src/plugin/bridges/vst3-impls/plugin-proxy.h index 6d404975..621c0d70 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.h +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.h @@ -17,6 +17,7 @@ #pragma once #include "../vst3.h" +#include "plug-view-proxy.h" class Vst3PluginProxyImpl : public Vst3PluginProxy { public: @@ -133,7 +134,7 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * currently only defines a single type of view so that shouldn't be an * issue */ - Steinberg::IPlugView* last_created_plug_view = nullptr; + Vst3PlugViewProxyImpl* last_created_plug_view = nullptr; /** * The component handler the host passed to us during diff --git a/src/plugin/bridges/vst3.cpp b/src/plugin/bridges/vst3.cpp index 9528fe06..6712019f 100644 --- a/src/plugin/bridges/vst3.cpp +++ b/src/plugin/bridges/vst3.cpp @@ -81,24 +81,6 @@ Vst3PluginBridge::Vst3PluginBridge() [&](const WantsConfiguration&) -> WantsConfiguration::Response { return config; }, - [&](const YaHostApplication::GetName& request) - -> YaHostApplication::GetName::Response { - tresult result; - Steinberg::Vst::String128 name{0}; - if (request.owner_instance_id) { - result = plugin_proxies.at(*request.owner_instance_id) - .get() - .host_application->getName(name); - } else { - result = - plugin_factory->host_application->getName(name); - } - - return YaHostApplication::GetNameResponse{ - .result = result, - .name = tchar_pointer_to_u16string(name), - }; - }, [&](const YaComponentHandler::BeginEdit& request) -> YaComponentHandler::BeginEdit::Response { return plugin_proxies.at(request.owner_instance_id) @@ -124,6 +106,39 @@ Vst3PluginBridge::Vst3PluginBridge() .get() .component_handler->restartComponent(request.flags); }, + [&](const YaHostApplication::GetName& request) + -> YaHostApplication::GetName::Response { + tresult result; + Steinberg::Vst::String128 name{0}; + if (request.owner_instance_id) { + result = plugin_proxies.at(*request.owner_instance_id) + .get() + .host_application->getName(name); + } else { + result = + plugin_factory->host_application->getName(name); + } + + return YaHostApplication::GetNameResponse{ + .result = result, + .name = tchar_pointer_to_u16string(name), + }; + }, + [&](YaPlugFrame::ResizeView& request) + -> YaPlugFrame::ResizeView::Response { + // XXX: As mentioned elsewhere, since VST3 only supports a + // single plug view type at the moment we'll just + // assume that this function is called from the last + // (and only) `IPlugView*` instance returned by the + // plugin. + Vst3PlugViewProxyImpl* plug_view = + plugin_proxies.at(request.owner_instance_id) + .get() + .last_created_plug_view; + + return plug_view->plug_frame->resizeView(plug_view, + &request.new_size); + }, }); }); } diff --git a/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp b/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp index 2d005ffa..484ca189 100644 --- a/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp @@ -40,9 +40,18 @@ Vst3PlugFrameProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { } tresult PLUGIN_API -Vst3PlugFrameProxyImpl::resizeView(Steinberg::IPlugView* view, +Vst3PlugFrameProxyImpl::resizeView(Steinberg::IPlugView* /*view*/, Steinberg::ViewRect* newSize) { - // TODO: Implement - std::cerr << "TODO: IPlugFrame::resizeView()" << std::endl; - return Steinberg::kNotImplemented; + if (newSize) { + // XXX: Since VST3 currently only support a single view type we'll + // assume `view` is the `IPlugView*` returned by the last call to + // `IEditController::createView()` + return bridge.send_message(YaPlugFrame::ResizeView{ + .owner_instance_id = owner_instance_id(), .new_size = *newSize}); + } else { + std::cerr + << "WARNING: Null pointer passed to 'IPlugFrame::resizeView()'" + << std::endl; + return Steinberg::kInvalidArgument; + } }