From fc0abe1ba6e5e7f1c21c10a0ea33845468f55022 Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Tue, 23 Apr 2024 19:47:01 +0200 Subject: [PATCH] App: Make transport actions affect correct project tab --- main/src/infrastructure/proto/generated.rs | 75 ++++++++++--------- .../proto/initial_playtime_events.rs | 2 +- .../infrastructure/proto/request_handler.rs | 67 +++++++++-------- playtime-clip-engine | 2 +- 4 files changed, 77 insertions(+), 69 deletions(-) diff --git a/main/src/infrastructure/proto/generated.rs b/main/src/infrastructure/proto/generated.rs index 09cacf6ab..2094fce9a 100644 --- a/main/src/infrastructure/proto/generated.rs +++ b/main/src/infrastructure/proto/generated.rs @@ -1623,6 +1623,12 @@ impl MatrixVolumeKind { #[repr(i32)] pub enum TriggerInstanceAction { ShowHelgoboxPlugin = 0, + ArrangementTogglePlayStop = 1, + ArrangementPlay = 2, + ArrangementStop = 3, + ArrangementPause = 4, + ArrangementStartRecording = 5, + ArrangementStopRecording = 6, } impl TriggerInstanceAction { /// String value of the enum field names used in the ProtoBuf definition. @@ -1634,6 +1640,24 @@ impl TriggerInstanceAction { TriggerInstanceAction::ShowHelgoboxPlugin => { "TRIGGER_INSTANCE_ACTION_SHOW_HELGOBOX_PLUGIN" } + TriggerInstanceAction::ArrangementTogglePlayStop => { + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_TOGGLE_PLAY_STOP" + } + TriggerInstanceAction::ArrangementPlay => { + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_PLAY" + } + TriggerInstanceAction::ArrangementStop => { + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_STOP" + } + TriggerInstanceAction::ArrangementPause => { + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_PAUSE" + } + TriggerInstanceAction::ArrangementStartRecording => { + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_START_RECORDING" + } + TriggerInstanceAction::ArrangementStopRecording => { + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_STOP_RECORDING" + } } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -1642,6 +1666,18 @@ impl TriggerInstanceAction { "TRIGGER_INSTANCE_ACTION_SHOW_HELGOBOX_PLUGIN" => { Some(Self::ShowHelgoboxPlugin) } + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_TOGGLE_PLAY_STOP" => { + Some(Self::ArrangementTogglePlayStop) + } + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_PLAY" => Some(Self::ArrangementPlay), + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_STOP" => Some(Self::ArrangementStop), + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_PAUSE" => Some(Self::ArrangementPause), + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_START_RECORDING" => { + Some(Self::ArrangementStartRecording) + } + "TRIGGER_INSTANCE_ACTION_ARRANGEMENT_STOP_RECORDING" => { + Some(Self::ArrangementStopRecording) + } _ => None, } } @@ -1832,12 +1868,7 @@ impl TriggerMatrixAction { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum TriggerGlobalAction { - ArrangementTogglePlayStop = 0, - ArrangementPlay = 2, - ArrangementStop = 3, - ArrangementPause = 4, - ArrangementStartRecording = 5, - ArrangementStopRecording = 6, + Placeholder = 0, } impl TriggerGlobalAction { /// String value of the enum field names used in the ProtoBuf definition. @@ -1846,41 +1877,13 @@ impl TriggerGlobalAction { /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - TriggerGlobalAction::ArrangementTogglePlayStop => { - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_TOGGLE_PLAY_STOP" - } - TriggerGlobalAction::ArrangementPlay => { - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_PLAY" - } - TriggerGlobalAction::ArrangementStop => { - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_STOP" - } - TriggerGlobalAction::ArrangementPause => { - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_PAUSE" - } - TriggerGlobalAction::ArrangementStartRecording => { - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_START_RECORDING" - } - TriggerGlobalAction::ArrangementStopRecording => { - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_STOP_RECORDING" - } + TriggerGlobalAction::Placeholder => "TRIGGER_GLOBAL_ACTION_PLACEHOLDER", } } /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_TOGGLE_PLAY_STOP" => { - Some(Self::ArrangementTogglePlayStop) - } - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_PLAY" => Some(Self::ArrangementPlay), - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_STOP" => Some(Self::ArrangementStop), - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_PAUSE" => Some(Self::ArrangementPause), - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_START_RECORDING" => { - Some(Self::ArrangementStartRecording) - } - "TRIGGER_GLOBAL_ACTION_ARRANGEMENT_STOP_RECORDING" => { - Some(Self::ArrangementStopRecording) - } + "TRIGGER_GLOBAL_ACTION_PLACEHOLDER" => Some(Self::Placeholder), _ => None, } } diff --git a/main/src/infrastructure/proto/initial_playtime_events.rs b/main/src/infrastructure/proto/initial_playtime_events.rs index f1ae6b049..7bb4409c6 100644 --- a/main/src/infrastructure/proto/initial_playtime_events.rs +++ b/main/src/infrastructure/proto/initial_playtime_events.rs @@ -42,7 +42,7 @@ pub fn create_initial_matrix_updates(matrix: Option<&Matrix>) -> Vec Result, Status> { let action = TriggerGlobalAction::try_from(req.action) .map_err(|_| Status::invalid_argument("unknown trigger global action"))?; - let project = Reaper::get().current_project(); match action { - TriggerGlobalAction::ArrangementTogglePlayStop => { - if project.is_playing() { - project.stop(); - } else { - project.play(); - } - } - TriggerGlobalAction::ArrangementPlay => { - project.play(); - } - TriggerGlobalAction::ArrangementStop => { - project.stop(); - } - TriggerGlobalAction::ArrangementPause => { - project.pause(); - } - TriggerGlobalAction::ArrangementStartRecording => { - Reaper::get().enable_record_in_current_project(); - } - TriggerGlobalAction::ArrangementStopRecording => { - Reaper::get().disable_record_in_current_project(); - } + TriggerGlobalAction::Placeholder => {} } Ok(Response::new(Empty {})) } @@ -327,14 +305,41 @@ 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(()) + self.handle_instance_command(req.instance_id, |instance| { + let project = instance.processor_context().project().or_current_project(); + match action { + TriggerInstanceAction::ShowHelgoboxPlugin => { + instance + .processor_context() + .containing_fx() + .show_in_floating_window(); + } + TriggerInstanceAction::ArrangementTogglePlayStop => { + if project.is_playing() { + project.stop(); + } else { + project.play(); + } + } + TriggerInstanceAction::ArrangementPlay => { + project.play(); + } + TriggerInstanceAction::ArrangementStop => { + project.stop(); + } + TriggerInstanceAction::ArrangementPause => { + project.pause(); + } + TriggerInstanceAction::ArrangementStartRecording => { + // Recording not supported per project + Reaper::get().enable_record_in_current_project(); + } + TriggerInstanceAction::ArrangementStopRecording => { + // Recording not supported per project + Reaper::get().disable_record_in_current_project(); + } } + Ok(()) }) } diff --git a/playtime-clip-engine b/playtime-clip-engine index 339ff54d5..ddf874b4c 160000 --- a/playtime-clip-engine +++ b/playtime-clip-engine @@ -1 +1 @@ -Subproject commit 339ff54d55acc9064a3ca666e57df5abad4045e7 +Subproject commit ddf874b4c3a97bcdc3136156edf1bf466f109741