Implement IPlugFrame::resizeView()

The base IPlugFrame only contains this single function.
This commit is contained in:
Robbert van der Helm
2020-12-22 15:09:33 +01:00
parent 3bc3409929
commit 656f6d3f6c
8 changed files with 86 additions and 26 deletions
-1
View File
@@ -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
+13 -1
View File
@@ -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(<FUnknown*>)";
});
@@ -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 = <IPlugView*>, newSize = "
"<ViewRect* with left = "
<< request.new_size.left << ", top = " << request.new_size.top
<< ", right = " << request.new_size.right
<< ", bottom = " << request.new_size.bottom << ">)";
});
}
void Vst3Logger::log_response(bool is_host_vst, const Ack&) {
log_response_base(is_host_vst, [&](auto& message) { message << "ACK"; });
}
+1
View File
@@ -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(
+2 -1
View File
@@ -140,7 +140,8 @@ using CallbackRequest = std::variant<WantsConfiguration,
YaComponentHandler::PerformEdit,
YaComponentHandler::EndEdit,
YaComponentHandler::RestartComponent,
YaHostApplication::GetName>;
YaHostApplication::GetName,
YaPlugFrame::ResizeView>;
template <typename S>
void serialize(S& s, CallbackRequest& payload) {
@@ -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 <typename S>
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;
+2 -1
View File
@@ -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
+33 -18
View File
@@ -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);
},
});
});
}
@@ -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;
}
}