Implement the rest of the GUI events

The GUI is still not updating though.
This commit is contained in:
Robbert van der Helm
2020-03-19 00:58:03 +01:00
parent 168568ed51
commit eebfceff56
6 changed files with 134 additions and 84 deletions
+6
View File
@@ -217,6 +217,7 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
return &events.as_c_events();
},
[&](WantsChunkBuffer&) -> void* { return string_buffer.data(); },
[&](const WantsVstRect&) -> void* { return string_buffer.data(); },
[&](const WantsVstTimeInfo&) -> void* { return nullptr; },
[&](WantsString&) -> void* { return string_buffer.data(); }},
event.payload);
@@ -264,6 +265,11 @@ void passthrough_event(boost::asio::local::stream_protocol::socket& socket,
return std::string(*static_cast<char**>(data),
return_value);
},
[&](WantsVstRect&) -> EventResposnePayload {
// The plugin has written a pointer to a VstRect struct
// into the data poitner
return **static_cast<VstRect**>(data);
},
[&](WantsVstTimeInfo&) -> EventResposnePayload {
// Not sure why the VST API has twenty different ways of
// returning structs, but in this case the value returned
+6
View File
@@ -175,6 +175,7 @@ void Logger::log_event(bool is_dispatch,
[&](const WantsChunkBuffer&) {
message << "<writable_buffer>";
},
[&](const WantsVstRect&) { message << "<writable_buffer>"; },
[&](const WantsVstTimeInfo&) { message << "<nullptr>"; },
[&](const WantsString&) { message << "<writable_string>"; }},
payload);
@@ -210,6 +211,11 @@ void Logger::log_event_response(bool is_dispatch,
}
},
[&](const AEffect&) { message << ", <AEffect_object>"; },
[&](const VstRect& rect) {
message << ", {l: " << rect.left << ", t: " << rect.top
<< ", r: " << rect.right
<< ", b: " << rect.bottom << "}";
},
[&](const VstTimeInfo&) { message << ", <time_info>"; }},
payload);
+20 -4
View File
@@ -83,6 +83,14 @@ void serialize(S& s, AEffect& plugin) {
s.value4b(plugin.version);
}
template <typename S>
void serialize(S& s, VstRect& rect) {
s.value2b(rect.top);
s.value2b(rect.left);
s.value2b(rect.right);
s.value2b(rect.bottom);
}
template <typename S>
void serialize(S& s, VstTimeInfo& time_info) {
s.value8b(time_info.samplePos);
@@ -152,9 +160,15 @@ class alignas(16) DynamicVstEvents {
*/
struct WantsChunkBuffer {};
/**
* Marker struct to indicate that the event handler will write a pointer to a
* `VstRect` struct into the void pointer.
*/
struct WantsVstRect {};
/**
* Marker struct to indicate that the event handler will return a pointer to a
* `VstTiemInfo` struct that should be returned transfered.
* `VstTimeInfo` struct that should be returned transfered.
*/
struct WantsVstTimeInfo {};
@@ -198,6 +212,7 @@ using EventPayload = std::variant<std::nullptr_t,
AEffect,
DynamicVstEvents,
WantsChunkBuffer,
WantsVstRect,
WantsVstTimeInfo,
WantsString>;
@@ -218,8 +233,8 @@ void serialize(S& s, EventPayload& payload) {
events.events, max_midi_events,
[](S& s, VstEvent& event) { s.container1b(event.dump); });
},
[](S&, WantsChunkBuffer&) {}, [](S&, WantsVstTimeInfo&) {},
[](S&, WantsString&) {}});
[](S&, WantsChunkBuffer&) {}, [](S&, WantsVstRect&) {},
[](S&, WantsVstTimeInfo&) {}, [](S&, WantsString&) {}});
}
/**
@@ -275,7 +290,7 @@ struct Event {
* - An X11 window pointer for the editor window.
*/
using EventResposnePayload =
std::variant<std::monostate, std::string, AEffect, VstTimeInfo>;
std::variant<std::monostate, std::string, AEffect, VstRect, VstTimeInfo>;
template <typename S>
void serialize(S& s, EventResposnePayload& payload) {
@@ -289,6 +304,7 @@ void serialize(S& s, EventResposnePayload& payload) {
s.text1b(string, binary_buffer_size);
},
[](S& s, AEffect& effect) { s.object(effect); },
[](S& s, VstRect& rect) { s.object(rect); },
[](S& s, VstTimeInfo& time_info) { s.object(time_info); }});
}