diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-06-20 13:47:45 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-27 14:59:30 -0500 |
commit | 67620c353ff94dcaf8ee0f8cf003110535071a90 (patch) | |
tree | 9ede27bd4f2691950eb2d7e3ba8a1809d465fd27 /libs/surfaces/push2 | |
parent | 3669096c0520df2452f9f67683204ebf02d8920d (diff) |
push2: connect first selected track to pad port (and disconnect).
Provisional. Lots of (fun) work to do here
Diffstat (limited to 'libs/surfaces/push2')
-rw-r--r-- | libs/surfaces/push2/push2.cc | 35 | ||||
-rw-r--r-- | libs/surfaces/push2/push2.h | 2 |
2 files changed, 37 insertions, 0 deletions
diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index c8ea3ceb4f..f1d37b246c 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -36,6 +36,8 @@ #include "ardour/debug.h" #include "ardour/filesystem_paths.h" #include "ardour/midiport_manager.h" +#include "ardour/midi_track.h" +#include "ardour/midi_port.h" #include "ardour/session.h" #include "ardour/tempo.h" @@ -1092,10 +1094,43 @@ void Push2::stripable_property_change (PropertyChange const& what_changed, int which) { if (what_changed.contains (Properties::selected)) { + if (!stripable[which]) { + return; + } + /* cancel string, which will cause a redraw on the next update * cycle. The redraw will reflect selected status */ + mid_layout[which]->set_text (string()); + + if (stripable[which]->presentation_info().selected()) { + + boost::shared_ptr<MidiPort> pad_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_in)->shadow_port(); + boost::shared_ptr<Stripable> current_first_selection = first_selected_stripable.lock(); + boost::shared_ptr<MidiTrack> mtrack; + + mtrack = boost::dynamic_pointer_cast<MidiTrack> (current_first_selection); + + /* disconnect from pad port, if appropriate */ + if (mtrack && pad_port) { + cerr << "Disconnect pads from " << mtrack->name() << endl; + mtrack->input()->disconnect (mtrack->input()->nth(0), pad_port->name(), this); + } + + first_selected_stripable = boost::weak_ptr<Stripable> (stripable[which]); + + /* now connect the pad port to this (newly) selected midi + * track, if indeed it is + */ + + mtrack = boost::dynamic_pointer_cast<MidiTrack> (stripable[which]); + + if (mtrack && pad_port) { + cerr << "Reconnect pads to " << mtrack->name() << endl; + mtrack->input()->connect (mtrack->input()->nth (0), pad_port->name(), this); + } + } } } diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index cc2ff018c4..dab96260c6 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -450,6 +450,8 @@ class Push2 : public ARDOUR::ControlProtocol void switch_bank (uint32_t base); bool pad_filter (ARDOUR::MidiBuffer& in, ARDOUR::MidiBuffer& out) const; + + boost::weak_ptr<ARDOUR::Stripable> first_selected_stripable; }; |