diff options
-rw-r--r-- | libs/surfaces/control_protocol/basic_ui.cc | 35 | ||||
-rw-r--r-- | libs/surfaces/control_protocol/control_protocol.cc | 5 | ||||
-rw-r--r-- | libs/surfaces/control_protocol/control_protocol/basic_ui.h | 10 | ||||
-rw-r--r-- | libs/surfaces/control_protocol/control_protocol/control_protocol.h | 5 | ||||
-rw-r--r-- | libs/surfaces/generic_midi/midifunction.cc | 7 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.cc | 64 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.h | 2 | ||||
-rw-r--r-- | libs/surfaces/osc/osc.cc | 3 |
8 files changed, 95 insertions, 36 deletions
diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index dd5e84cfd7..6b22be2abe 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -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 diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc index 8e86692241..f1b2f9f112 100644 --- a/libs/surfaces/control_protocol/control_protocol.cc +++ b/libs/surfaces/control_protocol/control_protocol.cc @@ -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"); diff --git a/libs/surfaces/control_protocol/control_protocol/basic_ui.h b/libs/surfaces/control_protocol/control_protocol/basic_ui.h index 1509602014..c919223e2c 100644 --- a/libs/surfaces/control_protocol/control_protocol/basic_ui.h +++ b/libs/surfaces/control_protocol/control_protocol/basic_ui.h @@ -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(); diff --git a/libs/surfaces/control_protocol/control_protocol/control_protocol.h b/libs/surfaces/control_protocol/control_protocol/control_protocol.h index 53fce840e0..496ba99083 100644 --- a/libs/surfaces/control_protocol/control_protocol/control_protocol.h +++ b/libs/surfaces/control_protocol/control_protocol/control_protocol.h @@ -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. diff --git a/libs/surfaces/generic_midi/midifunction.cc b/libs/surfaces/generic_midi/midifunction.cc index 4b5faa7018..4d2b19fdfd 100644 --- a/libs/surfaces/generic_midi/midifunction.cc +++ b/libs/surfaces/generic_midi/midifunction.cc @@ -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; diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 65489e44e1..222b1177a8 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -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; + } + } } } diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 20a3ff31ca..76da4fe5e8 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -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; diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 9b5cfeb441..ec93311c64 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -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)); } |