use session stripable selection API
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 4 Jul 2016 16:45:29 +0000 (12:45 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 4 Jul 2016 16:45:53 +0000 (12:45 -0400)
and remove old ControlProtocol signals to talk to GUI etc.

libs/surfaces/control_protocol/basic_ui.cc
libs/surfaces/control_protocol/control_protocol.cc
libs/surfaces/control_protocol/control_protocol/basic_ui.h
libs/surfaces/control_protocol/control_protocol/control_protocol.h
libs/surfaces/generic_midi/midifunction.cc
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mackie_control_protocol.h
libs/surfaces/osc/osc.cc

index dd5e84cfd757366ecd5c44e26c691238ef76eaa8..6b22be2abe931ad60f0a8b2ab878b3fbb9abfd44 100644 (file)
@@ -495,6 +495,41 @@ BasicUI::sample_to_timecode (framepos_t sample, Timecode::Time& timecode, bool u
        session->sample_to_timecode (sample, *((Timecode::Time*)&timecode), use_offset, use_subframes);
 }
 
+void
+BasicUI::toggle_selection (PresentationInfo::order_t o, PresentationInfo::Flag flags)
+{
+       boost::shared_ptr<Stripable> s = session->get_remote_nth_stripable (o, flags);
+
+       if (s) {
+               s->presentation_info().set_selected (!s->presentation_info().selected());
+       }
+}
+
+void
+BasicUI::clear_stripable_selection ()
+{
+       session->clear_stripable_selection ();
+}
+
+void
+BasicUI::toggle_stripable_selection (boost::shared_ptr<Stripable> s)
+{
+       session->toggle_stripable_selection (s);
+}
+
+void
+BasicUI::add_stripable_selection (boost::shared_ptr<Stripable> s)
+{
+       session->add_stripable_selection (s);
+}
+
+void
+BasicUI::set_stripable_selection (boost::shared_ptr<Stripable> s)
+{
+       session->set_stripable_selection (s);
+}
+
+
 #if 0
 this stuff is waiting to go in so that all UIs can offer complex solo/mute functionality
 
index 8e866922419f303fec0cafbf2407e46fb77ed23f..f1b2f9f112b97f9cf3a434df2e5d520066a3cf6c 100644 (file)
@@ -50,11 +50,6 @@ PBD::Signal0<void>          ControlProtocol::StepTracksDown;
 PBD::Signal0<void>          ControlProtocol::StepTracksUp;
 
 PBD::Signal1<void,StripableNotificationListPtr> ControlProtocol::StripableSelectionChanged;
-PBD::Signal1<void,uint64_t> ControlProtocol::AddStripableSelection;
-PBD::Signal1<void,uint64_t> ControlProtocol::SetStripableSelection;
-PBD::Signal1<void,uint64_t> ControlProtocol::ToggleStripableSelection;
-PBD::Signal0<void>          ControlProtocol::ClearStripableSelection;
-
 
 const std::string ControlProtocol::state_node_name ("Protocol");
 
index 15096020142f8d048754444915384c690085ddec..c919223e2cc0ab8ca06ad916650992802e072734 100644 (file)
@@ -27,6 +27,7 @@
 #include "pbd/signals.h"
 
 #include "ardour/types.h"
+#include "ardour/presentation_info.h"
 
 #include "timecode/time.h"
 
@@ -35,6 +36,7 @@
 namespace ARDOUR {
        class Session;
        class SessionEvent;
+       class Stripable;
 }
 
 class LIBCONTROLCP_API BasicUI {
@@ -44,7 +46,13 @@ class LIBCONTROLCP_API BasicUI {
 
        void add_marker (const std::string& = std::string());
        void remove_marker_at_playhead ();
-       
+
+       void clear_stripable_selection ();
+       void toggle_stripable_selection (boost::shared_ptr<ARDOUR::Stripable>);
+       void add_stripable_selection (boost::shared_ptr<ARDOUR::Stripable>);
+       void set_stripable_selection (boost::shared_ptr<ARDOUR::Stripable>);
+       void toggle_selection (ARDOUR::PresentationInfo::order_t, ARDOUR::PresentationInfo::Flag);
+
 //     void mark_in();
 //     void mark_out();
 
index 53fce840e0c75739ffe44ddf2281f82d9a2ecdd6..496ba990837f85490b35c1f2b4271f0a9c5d3e22 100644 (file)
@@ -78,11 +78,6 @@ class LIBCONTROLCP_API ControlProtocol : public PBD::Stateful, public PBD::Scope
        static PBD::Signal0<void> StepTracksDown;
        static PBD::Signal0<void> StepTracksUp;
 
-       static PBD::Signal1<void,uint64_t> AddStripableSelection;
-       static PBD::Signal1<void,uint64_t> SetStripableSelection;
-       static PBD::Signal1<void,uint64_t> ToggleStripableSelection;
-       static PBD::Signal0<void>          ClearStripableSelection;
-
        /* signals that one UI (e.g. the GUI) can emit to get all other UI's to
           respond. Typically this will always be GUI->"others" - the GUI pays
           no attention to these signals.
index 4b5faa7018667745748232f3b13eaf6c3a3df959..4d2b19fdfd9d563194fe6ddd52d010af110d2eaf 100644 (file)
@@ -165,14 +165,9 @@ MIDIFunction::execute ()
 
        case Select:
                if (!_argument.empty()) {
-                       /* this uses only the numerical orderpart of a
-                          PresentionInfo, because it only sets the lower 32
-                          bits of a 64 bit value. This will be interpreted
-                          as a request to select only Routes.
-                       */
                        uint32_t rid;
                        sscanf (_argument.c_str(), "%d", &rid);
-                       _ui->SetStripableSelection (rid);
+                       _ui->toggle_selection (rid, ARDOUR::PresentationInfo::Flag (ARDOUR::PresentationInfo::Route|ARDOUR::PresentationInfo::VCA));
                        DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SetRouteSelection = %1\n", rid));
                }
                break;
index 65489e44e10150cd190409a10d35ca70fab9be48..222b1177a849ce8c730404183a9e66046e79ab7b 100644 (file)
@@ -2039,21 +2039,24 @@ MackieControlProtocol::select_range ()
                return;
        }
 
-       cerr << "Main modifier state = " << hex << main_modifier_state() << dec << endl;
+       if (stripables.size() == 1 && _last_selected_stripables.size() == 1 && stripables.front()->presentation_info().selected()) {
+               /* cancel selection for one and only selected stripable */
+               session->toggle_stripable_selection (stripables.front());
+       } else {
 
-       for (StripableList::iterator s = stripables.begin(); s != stripables.end(); ++s) {
+               for (StripableList::iterator s = stripables.begin(); s != stripables.end(); ++s) {
 
-               if (main_modifier_state() == MODIFIER_CONTROL) {
-                       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("toggle selection of %1 (%2)\n", (*s)->name(), (*s)->presentation_info().order()));
-                       cerr << "Toggle selection\n";
-                       ToggleStripableSelection ((*s)->presentation_info ().order());
-               } else {
-                       if (s == stripables.begin()) {
-                               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("set selection of %1 (%2)\n", (*s)->name(), (*s)->presentation_info().order()));
-                               SetStripableSelection ((*s)->presentation_info().order());
+                       if (main_modifier_state() == MODIFIER_CONTROL) {
+                               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("toggle selection of %1 (%2)\n", (*s)->name(), (*s)->presentation_info().order()));
+                               session->toggle_stripable_selection (*s);
                        } else {
-                               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("add to selection %1 (%2)\n", (*s)->name(), (*s)->presentation_info().order()));
-                               AddStripableSelection ((*s)->presentation_info().order());
+                               if (s == stripables.begin()) {
+                                       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("set selection of %1 (%2)\n", (*s)->name(), (*s)->presentation_info().order()));
+                                       session->set_stripable_selection (*s);
+                       } else {
+                                       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("add to selection %1 (%2)\n", (*s)->name(), (*s)->presentation_info().order()));
+                                       session->add_stripable_selection (*s);
+                               }
                        }
                }
        }
@@ -2384,12 +2387,41 @@ MackieControlProtocol::is_mapped (boost::shared_ptr<Stripable> r) const
 }
 
 void
-MackieControlProtocol::update_selected (boost::shared_ptr<Stripable> s, bool selected)
+MackieControlProtocol::update_selected (boost::shared_ptr<Stripable> s, bool became_selected)
 {
-       if (selected) {
-               _last_selected_stripables.insert (boost::weak_ptr<Stripable> (s));
+       if (became_selected) {
+
+               if (selected (s)) {
+                       /* already selected .. mmmm */
+                       cerr << "stripable " << s->name() << " already marked as selected\n";
+                       return;
+               }
+
+               _last_selected_stripables.push_back (boost::weak_ptr<Stripable> (s));
+
+               check_fader_automation_state ();
+
+               /* It is possible that first_selected_route() may return null if we
+                * are no longer displaying/mapping that route. In that case,
+                * we will exit subview mode. If first_selected_route() is
+                * null, and subview mode is not None, then the first call to
+                * set_subview_mode() will fail, and we will reset to None.
+                */
+
+               if (set_subview_mode (_subview_mode, first_selected_stripable())) {
+                       set_subview_mode (None, boost::shared_ptr<Stripable>());
+               }
+
        } else {
-               _last_selected_stripables.erase (boost::weak_ptr<Stripable> (s));
+
+               for (Selection::iterator i = _last_selected_stripables.begin(); i != _last_selected_stripables.end(); ++i) {
+                       boost::shared_ptr<ARDOUR::Stripable> ss = (*i).lock();
+
+                       if (ss == s) {
+                               _last_selected_stripables.erase (i);
+                               break;
+                       }
+               }
        }
 }
 
index 20a3ff31ca969c98aa42fb3dcae2107239935ae0..76da4fe5e8d43e352f3dce8de468f8a8a9539c9d 100644 (file)
@@ -335,7 +335,7 @@ class MackieControlProtocol
        bool                      needs_ipmidi_restart;
        bool                     _metering_active;
        bool                     _initialized;
-       typedef std::set<boost::weak_ptr<ARDOUR::Stripable> > Selection;
+       typedef std::vector<boost::weak_ptr<ARDOUR::Stripable> > Selection;
        Selection                _last_selected_stripables;
        XMLNode*                 configuration_state;
        int                      state_version;
index 9b5cfeb4411b5b0e6af449b3c13b5db0d6f0b96b..ec93311c640e21ba812553be4f03cce9381c4ad5 100644 (file)
@@ -2094,8 +2094,7 @@ OSC::strip_gui_select (int ssid, int yn, lo_message msg)
        sur->expand_enable = false;
        boost::shared_ptr<Stripable> s = get_strip (ssid, lo_message_get_source (msg));
        if (s) {
-               SetStripableSelection (s->presentation_info().order() + 1);
-               //s->presentation_info().set_selected(true);
+               s->presentation_info().set_selected (!s->presentation_info().selected());
        } else {
                route_send_fail ("select", ssid, 0, lo_message_get_source (msg));
        }