Split up a ConstructArgs from YaContextMenuTarget

So we can send this as a payload when the plugin adds a context menu
item.
This commit is contained in:
Robbert van der Helm
2021-01-06 23:20:37 +01:00
parent 75284cea0b
commit c1576658d6
4 changed files with 47 additions and 29 deletions
@@ -16,12 +16,16 @@
#include "context-menu-target.h"
YaContextMenuTarget::YaContextMenuTarget(native_size_t owner_instance_id,
native_size_t context_menu_id,
int32 tag)
YaContextMenuTarget::ConstructArgs::ConstructArgs(
native_size_t owner_instance_id,
native_size_t context_menu_id,
int32 tag)
: owner_instance_id(owner_instance_id),
context_menu_id(context_menu_id),
tag(tag){FUNKNOWN_CTOR}
tag(tag) {}
YaContextMenuTarget::YaContextMenuTarget(const ConstructArgs&& args)
: arguments(std::move(args)){FUNKNOWN_CTOR}
YaContextMenuTarget::~YaContextMenuTarget() {
FUNKNOWN_DTOR
@@ -32,19 +32,44 @@
*/
class YaContextMenuTarget : public Steinberg::Vst::IContextMenuTarget {
public:
/**
* These are the arguments for constructing a
* `YaContextMenuTargetImpl`.
*/
struct ConstructArgs {
ConstructArgs();
/**
* Read from an existing object. We will try to mimic this object, so
* we'll support any interfaces this object also supports.
*
* @param owner_instance_id The object instance that this target's
* context menu belongs to.
* @param context_menu_id The unique ID of the context menu requested by
* `owwner_instance_id`.
* @param tag The tag of the menu item this target belongs to.
*/
ConstructArgs(native_size_t owner_instance_id,
native_size_t context_menu_id,
int32 tag);
native_size_t owner_instance_id;
native_size_t context_menu_id;
int32 tag;
template <typename S>
void serialize(S& s) {
s.value8b(owner_instance_id);
s.value8b(context_menu_id);
s.value4b(tag);
}
};
/**
* Create context menu target that when called, calls the corresponding
* context menu target provided by the object.
*
* @param owner_instance_id The object instance that this target's context
* menu belongs to.
* @param context_menu_id The unique ID of the context menu requested by
* `owwner_instance_id`.
* @param tag The tag of the menu item this target belongs to.
*/
YaContextMenuTarget(native_size_t owner_instance_id,
native_size_t context_menu_id,
int32 tag);
YaContextMenuTarget(const ConstructArgs&& args);
~YaContextMenuTarget();
@@ -53,9 +78,7 @@ class YaContextMenuTarget : public Steinberg::Vst::IContextMenuTarget {
virtual tresult PLUGIN_API executeMenuItem(int32 tag) override = 0;
protected:
native_size_t owner_instance_id;
native_size_t context_menu_id;
int32 tag;
ConstructArgs arguments;
};
#pragma GCC diagnostic pop