From 33b7c38e421fbab2dee54af31d975542142454ab Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 5 Jun 2022 15:03:23 -0600 Subject: [PATCH] control protocols: add API to control selection by RID --- .../control_protocol/control_protocol.cc | 36 +++++++++++++++++++ .../control_protocol/control_protocol.h | 5 +++ 2 files changed, 41 insertions(+) diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc index e6ba0c5d0d..864ed0b1d2 100644 --- a/libs/surfaces/control_protocol/control_protocol.cc +++ b/libs/surfaces/control_protocol/control_protocol.cc @@ -383,6 +383,42 @@ ControlProtocol::remove_stripable_from_selection (boost::shared_ptrselection().remove (s, boost::shared_ptr()); } +void +ControlProtocol::add_rid_to_selection (int rid) +{ + boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::MixerStripables); + if (s) { + session->selection().add (s, boost::shared_ptr()); + } +} + +void +ControlProtocol::set_rid_selection (int rid) +{ + boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::MixerStripables); + if (s) { + session->selection().select_stripable_and_maybe_group (s, true, true, 0); + } +} + +void +ControlProtocol::toggle_rid_selection (int rid) +{ + boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::MixerStripables); + if (s) { + session->selection().toggle (s, boost::shared_ptr()); + } +} + +void +ControlProtocol::remove_rid_from_selection (int rid) +{ + boost::shared_ptr s = session->get_remote_nth_stripable (rid, PresentationInfo::MixerStripables); + if (s) { + session->selection().remove (s, boost::shared_ptr()); + } +} + void ControlProtocol::clear_stripable_selection () { diff --git a/libs/surfaces/control_protocol/control_protocol/control_protocol.h b/libs/surfaces/control_protocol/control_protocol/control_protocol.h index 5a94ee7bc5..4d219c0c34 100644 --- a/libs/surfaces/control_protocol/control_protocol/control_protocol.h +++ b/libs/surfaces/control_protocol/control_protocol/control_protocol.h @@ -89,6 +89,11 @@ public: void remove_stripable_from_selection (boost::shared_ptr); void clear_stripable_selection (); + void add_rid_to_selection (int rid); + void set_rid_selection (int rid); + void toggle_rid_selection (int rid); + void remove_rid_from_selection (int rid); + boost::shared_ptr first_selected_stripable () const; /* the model here is as follows: