diff --git a/main/src/infrastructure/proto/generated.rs b/main/src/infrastructure/proto/generated.rs index 1a18da8ab..ea84f33f9 100644 --- a/main/src/infrastructure/proto/generated.rs +++ b/main/src/infrastructure/proto/generated.rs @@ -47,7 +47,7 @@ pub mod reply { pub struct CommandRequest { #[prost( oneof = "command_request::Value", - tags = "1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 37, 40, 25, 26, 27, 34, 28, 29, 31, 32, 33, 35, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47" + tags = "1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 37, 40, 25, 26, 27, 34, 28, 29, 31, 32, 33, 35, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48" )] pub value: ::core::option::Option, } @@ -149,6 +149,8 @@ pub mod command_request { TriggerGlobal(super::TriggerGlobalRequest), #[prost(message, tag = "47")] InsertColumns(super::InsertColumnsRequest), + #[prost(message, tag = "48")] + TriggerInstance(super::TriggerInstanceRequest), } } /// Envelope for queries. @@ -483,6 +485,14 @@ pub struct TriggerGlobalRequest { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct TriggerInstanceRequest { + #[prost(uint32, tag = "1")] + pub instance_id: u32, + #[prost(enumeration = "TriggerInstanceAction", tag = "2")] + pub action: i32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct TriggerMatrixRequest { #[prost(uint32, tag = "1")] pub matrix_id: u32, @@ -1517,6 +1527,33 @@ impl MatrixVolumeKind { } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] +pub enum TriggerInstanceAction { + ShowHelgoboxPlugin = 0, +} +impl TriggerInstanceAction { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + TriggerInstanceAction::ShowHelgoboxPlugin => { + "TRIGGER_INSTANCE_ACTION_SHOW_HELGOBOX_PLUGIN" + } + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "TRIGGER_INSTANCE_ACTION_SHOW_HELGOBOX_PLUGIN" => { + Some(Self::ShowHelgoboxPlugin) + } + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] pub enum TriggerMatrixAction { StopAllClips = 0, Undo = 7, @@ -2510,6 +2547,10 @@ pub mod helgobox_service_server { request: tonic::Request, ) -> std::result::Result, tonic::Status>; /// General instance commands + async fn trigger_instance( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; async fn set_instance_settings( &self, request: tonic::Request, @@ -3494,6 +3535,53 @@ pub mod helgobox_service_server { }; Box::pin(fut) } + "/generated.HelgoboxService/TriggerInstance" => { + #[allow(non_camel_case_types)] + struct TriggerInstanceSvc(pub Arc); + impl< + T: HelgoboxService, + > tonic::server::UnaryService + for TriggerInstanceSvc { + type Response = super::Empty; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::trigger_instance(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let inner = inner.0; + let method = TriggerInstanceSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } "/generated.HelgoboxService/SetInstanceSettings" => { #[allow(non_camel_case_types)] struct SetInstanceSettingsSvc(pub Arc); diff --git a/main/src/infrastructure/proto/request_handler.rs b/main/src/infrastructure/proto/request_handler.rs index e5f8208ec..2e3a5bb8a 100644 --- a/main/src/infrastructure/proto/request_handler.rs +++ b/main/src/infrastructure/proto/request_handler.rs @@ -13,8 +13,9 @@ use crate::infrastructure::proto::{ SetRowDataRequest, SetSequenceInfoRequest, SetTrackColorRequest, SetTrackInputMonitoringRequest, SetTrackInputRequest, SetTrackNameRequest, SetTrackPanRequest, SetTrackVolumeRequest, TriggerClipRequest, TriggerColumnRequest, TriggerGlobalAction, - TriggerGlobalRequest, TriggerMatrixRequest, TriggerRowRequest, TriggerSequenceRequest, - TriggerSlotRequest, TriggerTrackRequest, HOST_API_VERSION, + TriggerGlobalRequest, TriggerInstanceAction, TriggerInstanceRequest, TriggerMatrixRequest, + TriggerRowRequest, TriggerSequenceRequest, TriggerSlotRequest, TriggerTrackRequest, + HOST_API_VERSION, }; use anyhow::Context; use base::spawn_in_main_thread; @@ -307,6 +308,20 @@ impl ProtoRequestHandler { } } + pub fn trigger_instance(&self, req: TriggerInstanceRequest) -> Result, Status> { + let action = TriggerInstanceAction::try_from(req.action) + .map_err(|_| Status::invalid_argument("unknown trigger instance action"))?; + self.handle_instance_command(req.instance_id, |instance| match action { + TriggerInstanceAction::ShowHelgoboxPlugin => { + instance + .processor_context() + .containing_fx() + .show_in_floating_window(); + Ok(()) + } + }) + } + pub fn set_matrix_settings( &self, req: SetMatrixSettingsRequest, diff --git a/main/src/infrastructure/proto/service_impl.rs b/main/src/infrastructure/proto/service_impl.rs index 9b94923de..3db355a76 100644 --- a/main/src/infrastructure/proto/service_impl.rs +++ b/main/src/infrastructure/proto/service_impl.rs @@ -28,8 +28,8 @@ use crate::infrastructure::proto::{ SetMatrixTempoRequest, SetMatrixTimeSignatureRequest, SetMatrixVolumeRequest, SetRowDataRequest, SetTrackColorRequest, SetTrackInputMonitoringRequest, SetTrackInputRequest, SetTrackNameRequest, SetTrackPanRequest, SetTrackVolumeRequest, TriggerClipRequest, - TriggerColumnRequest, TriggerGlobalRequest, TriggerMatrixRequest, TriggerRowRequest, - TriggerSlotRequest, TriggerTrackRequest, + TriggerColumnRequest, TriggerGlobalRequest, TriggerInstanceRequest, TriggerMatrixRequest, + TriggerRowRequest, TriggerSlotRequest, TriggerTrackRequest, }; use base::future_util; use futures::{FutureExt, Stream, StreamExt}; @@ -699,6 +699,13 @@ impl helgobox_service_server::HelgoboxService for HelgoboxServiceImpl { self.command_handler.trigger_global(request.into_inner()) } + async fn trigger_instance( + &self, + request: Request, + ) -> Result, Status> { + self.command_handler.trigger_instance(request.into_inner()) + } + async fn insert_columns( &self, request: Request, diff --git a/main/src/infrastructure/ui/app/app_library.rs b/main/src/infrastructure/ui/app/app_library.rs index 99c48f23a..ed55083c3 100644 --- a/main/src/infrastructure/ui/app/app_library.rs +++ b/main/src/infrastructure/ui/app/app_library.rs @@ -553,6 +553,9 @@ fn process_command( TriggerMatrix(req) => { handler.trigger_matrix(req)?; } + TriggerInstance(req) => { + handler.trigger_instance(req)?; + } TriggerGlobal(req) => { handler.trigger_global(req)?; }