From da7d7f950233f109f82f7e7ea5c62f81ef3d7bbb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 6 Jul 2016 13:37:30 -0400 Subject: [PATCH] many changes associated with rationalizing selection flow --- gtk2_ardour/axis_view.cc | 16 ++++ gtk2_ardour/axis_view.h | 9 +- gtk2_ardour/editor.cc | 45 ++++++++-- gtk2_ardour/editor.h | 3 +- gtk2_ardour/editor_canvas_events.cc | 4 +- gtk2_ardour/editor_drag.cc | 18 ++-- gtk2_ardour/editor_mixer.cc | 14 ++- gtk2_ardour/editor_routes.cc | 2 +- gtk2_ardour/meter_strip.cc | 1 + gtk2_ardour/meter_strip.h | 2 + gtk2_ardour/mixer_actor.cc | 108 ++++++++++++----------- gtk2_ardour/mixer_actor.h | 4 +- gtk2_ardour/mixer_group_tabs.cc | 4 +- gtk2_ardour/mixer_strip.cc | 4 +- gtk2_ardour/mixer_strip.h | 4 +- gtk2_ardour/mixer_ui.cc | 60 ++++++++----- gtk2_ardour/mixer_ui.h | 5 +- gtk2_ardour/port_group.cc | 2 +- gtk2_ardour/public_editor.h | 3 +- gtk2_ardour/route_processor_selection.cc | 45 +++++----- gtk2_ardour/route_processor_selection.h | 12 +-- gtk2_ardour/route_time_axis.cc | 12 --- gtk2_ardour/route_time_axis.h | 5 +- gtk2_ardour/route_ui.cc | 34 ++----- gtk2_ardour/route_ui.h | 7 +- gtk2_ardour/route_ui_selection.h | 4 +- gtk2_ardour/selectable.h | 2 - gtk2_ardour/selection.cc | 3 + gtk2_ardour/time_axis_view.cc | 11 ++- gtk2_ardour/time_axis_view.h | 8 +- gtk2_ardour/track_selection.cc | 4 +- gtk2_ardour/vca_master_strip.cc | 13 +++ gtk2_ardour/vca_master_strip.h | 3 + 33 files changed, 272 insertions(+), 199 deletions(-) diff --git a/gtk2_ardour/axis_view.cc b/gtk2_ardour/axis_view.cc index 25a1907295..d877687039 100644 --- a/gtk2_ardour/axis_view.cc +++ b/gtk2_ardour/axis_view.cc @@ -97,3 +97,19 @@ AxisView::gui_object_state() { return *ARDOUR_UI::instance()->gui_object_state; } + +void +AxisView::set_selected (bool yn) +{ + if (selected() == yn) { + return; + } + + Selectable::set_selected (yn); + + boost::shared_ptr s = stripable (); + + if (s) { + s->presentation_info().set_selected (yn); + } +} diff --git a/gtk2_ardour/axis_view.h b/gtk2_ardour/axis_view.h index bc16aed06b..2a7c378197 100644 --- a/gtk2_ardour/axis_view.h +++ b/gtk2_ardour/axis_view.h @@ -37,10 +37,13 @@ namespace ARDOUR { class Session; + class Stripable; + class PresentationInfo; } /** - * AxisView defines the abstract base class for time-axis trackviews and routes. + * AxisView defines the abstract base class for horizontal and vertical + * presentations of Stripables. * */ class AxisView : public virtual PBD::ScopedConnectionList, public virtual ARDOUR::SessionHandlePtr, public virtual Selectable @@ -53,6 +56,8 @@ class AxisView : public virtual PBD::ScopedConnectionList, public virtual ARDOUR sigc::signal Hiding; + virtual boost::shared_ptr stripable() const = 0; + virtual std::string state_id() const = 0; /* for now, we always return properties in string form. */ @@ -72,6 +77,8 @@ class AxisView : public virtual PBD::ScopedConnectionList, public virtual ARDOUR property_hashtable.clear (); } + void set_selected (bool yn); + virtual bool marked_for_display () const; virtual bool set_marked_for_display (bool); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 146a4e7e44..20547e8e18 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -805,6 +805,12 @@ Editor::Editor () ControlProtocol::VerticalZoomInSelected.connect (*this, invalidator (*this), boost::bind (&Editor::control_vertical_zoom_in_selected, this), gui_context()); ControlProtocol::VerticalZoomOutSelected.connect (*this, invalidator (*this), boost::bind (&Editor::control_vertical_zoom_out_selected, this), gui_context()); + ControlProtocol::AddStripableToSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Add), gui_context()); + ControlProtocol::RemoveStripableFromSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Toggle), gui_context()); + ControlProtocol::SetStripableSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Set), gui_context()); + ControlProtocol::ToggleStripableSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_select, this, _1, Selection::Toggle), gui_context()); + ControlProtocol::ClearStripableSelection.connect (*this, invalidator (*this), boost::bind (&Editor::control_unselect, this), gui_context()); + BasicUI::AccessAction.connect (*this, invalidator (*this), boost::bind (&Editor::access_action, this, _1, _2), gui_context()); /* handle escape */ @@ -1006,6 +1012,30 @@ Editor::control_unselect () selection->clear_tracks (); } +void +Editor::control_select (boost::shared_ptr s, Selection::Operation op) +{ + TimeAxisView* tav = axis_view_from_stripable (s); + + if (tav) { + switch (op) { + case Selection::Add: + selection->add (tav); + break; + case Selection::Toggle: + selection->toggle (tav); + break; + case Selection::Extend: + break; + case Selection::Set: + selection->set (tav); + break; + } + } else { + selection->clear_tracks (); + } +} + void Editor::control_step_tracks_up () { @@ -5155,16 +5185,13 @@ Editor::region_view_removed () _summary->set_background_dirty (); } -RouteTimeAxisView* -Editor::axis_view_from_route (boost::shared_ptr r) const +TimeAxisView* +Editor::axis_view_from_stripable (boost::shared_ptr s) const { - TrackViewList::const_iterator j = track_views.begin (); - while (j != track_views.end()) { - RouteTimeAxisView* rtv = dynamic_cast (*j); - if (rtv && rtv->route() == r) { - return rtv; + for (TrackViewList::const_iterator j = track_views.begin (); j != track_views.end(); ++j) { + if ((*j)->stripable() == s) { + return *j; } - ++j; } return 0; @@ -5177,7 +5204,7 @@ Editor::axis_views_from_routes (boost::shared_ptr r) const TrackViewList t; for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { - TimeAxisView* tv = axis_view_from_route (*i); + TimeAxisView* tv = axis_view_from_stripable (*i); if (tv) { t.push_back (tv); } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index ee97886f9c..8bbc7fee2b 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1091,6 +1091,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void control_step_tracks_down (); void control_view (uint32_t); void control_scroll (float); + void control_select (boost::shared_ptr, Selection::Operation); void control_unselect (); void access_action (std::string,std::string); bool deferred_control_scroll (framepos_t); @@ -1132,7 +1133,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD /* track views */ TrackViewList track_views; std::pair trackview_by_y_position (double, bool trackview_relative_offset = true) const; - RouteTimeAxisView* axis_view_from_route (boost::shared_ptr) const; + TimeAxisView* axis_view_from_stripable (boost::shared_ptr) const; TrackViewList get_tracks_for_range_action () const; diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 0c31135e98..c26e4b96dc 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -1281,14 +1281,14 @@ Editor::drop_regions (const Glib::RefPtr& /*context*/, } list > audio_tracks; audio_tracks = session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order); - rtav = axis_view_from_route (audio_tracks.front()); + rtav = dynamic_cast (axis_view_from_stripable (audio_tracks.front())); } else if (boost::dynamic_pointer_cast (region)) { ChanCount one_midi_port (DataType::MIDI, 1); list > midi_tracks; midi_tracks = session()->new_midi_track (one_midi_port, one_midi_port, boost::shared_ptr(), (ARDOUR::Plugin::PresetRecord*) 0, (ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order); - rtav = axis_view_from_route (midi_tracks.front()); + rtav = dynamic_cast (axis_view_from_stripable (midi_tracks.front())); } else { return; } diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index d2fd96e685..c5e72fb778 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -527,7 +527,7 @@ Drag::add_midi_region (MidiTimeAxisView* view, bool commit) struct PresentationInfoTimeAxisViewSorter { bool operator() (TimeAxisView* a, TimeAxisView* b) { - return a->presentation_info().order() < b->presentation_info().order(); + return a->stripable()->presentation_info().order() < b->stripable()->presentation_info().order(); } }; @@ -1395,22 +1395,22 @@ RegionMoveDrag::create_destination_time_axis (boost::shared_ptr region, output_chan = _editor->session()->master_out()->n_inputs().n_audio(); } audio_tracks = _editor->session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order); - RouteTimeAxisView* rtav = _editor->axis_view_from_route (audio_tracks.front()); - if (rtav) { - rtav->set_height (original->current_height()); + TimeAxisView* tav =_editor->axis_view_from_stripable (audio_tracks.front()); + if (tav) { + tav->set_height (original->current_height()); } - return rtav; + return dynamic_cast(tav); } else { ChanCount one_midi_port (DataType::MIDI, 1); list > midi_tracks; midi_tracks = _editor->session()->new_midi_track (one_midi_port, one_midi_port, boost::shared_ptr(), (ARDOUR::Plugin::PresetRecord*) 0, (ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order); - RouteTimeAxisView* rtav = _editor->axis_view_from_route (midi_tracks.front()); - if (rtav) { - rtav->set_height (original->current_height()); + TimeAxisView* tav = _editor->axis_view_from_stripable (midi_tracks.front()); + if (tav) { + tav->set_height (original->current_height()); } - return rtav; + return dynamic_cast (tav); } } catch (...) { error << _("Could not create new track after region placed in the drop zone") << endmsg; diff --git a/gtk2_ardour/editor_mixer.cc b/gtk2_ardour/editor_mixer.cc index 67b33a6c87..029f6d966d 100644 --- a/gtk2_ardour/editor_mixer.cc +++ b/gtk2_ardour/editor_mixer.cc @@ -30,6 +30,8 @@ #include "ardour/rc_configuration.h" +#include "control_protocol/control_protocol.h" + #include "actions.h" #include "ardour_ui.h" #include "audio_time_axis.h" @@ -225,7 +227,11 @@ Editor::set_selected_mixer_strip (TimeAxisView& view) } } - _session->set_editor_mixer (route); + /* Typically this is set by changing the TAV selection but if for any + reason we decide to show a different strip for some reason, make + sure that control surfaces can find it. + */ + ARDOUR::ControlProtocol::set_first_selected_stripable (route); Glib::RefPtr act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer")); @@ -295,12 +301,12 @@ Editor::follow_mixer_selection () _following_mixer_selection = true; selection->block_tracks_changed (true); - RouteUISelection& s (Mixer_UI::instance()->selection().routes); + AxisViewSelection& s (Mixer_UI::instance()->selection().axes); selection->clear_tracks (); - for (RouteUISelection::iterator i = s.begin(); i != s.end(); ++i) { - TimeAxisView* tav = get_route_view_by_route_id ((*i)->route()->id()); + for (AxisViewSelection::iterator i = s.begin(); i != s.end(); ++i) { + TimeAxisView* tav = axis_view_from_stripable ((*i)->stripable()); if (tav) { selection->add (tav); } diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc index 9c827c1412..e46fcfee5a 100644 --- a/gtk2_ardour/editor_routes.cc +++ b/gtk2_ardour/editor_routes.cc @@ -1802,7 +1802,7 @@ EditorRoutes::show_tracks_with_regions_at_playhead () set show; for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { - TimeAxisView* tav = _editor->axis_view_from_route (*i); + TimeAxisView* tav = _editor->axis_view_from_stripable (*i); if (tav) { show.insert (tav); } diff --git a/gtk2_ardour/meter_strip.cc b/gtk2_ardour/meter_strip.cc index 1e1fd8f84a..3ab26d92bc 100644 --- a/gtk2_ardour/meter_strip.cc +++ b/gtk2_ardour/meter_strip.cc @@ -977,3 +977,4 @@ MeterStrip::color () const { return RouteUI::route_color (); } + diff --git a/gtk2_ardour/meter_strip.h b/gtk2_ardour/meter_strip.h index 00a2c4089d..0e7232537d 100644 --- a/gtk2_ardour/meter_strip.h +++ b/gtk2_ardour/meter_strip.h @@ -53,6 +53,8 @@ class MeterStrip : public Gtk::VBox, public AxisView, public RouteUI std::string name() const; Gdk::Color color () const; + boost::shared_ptr stripable() const { return RouteUI::stripable(); } + void set_session (ARDOUR::Session* s); void fast_update (); boost::shared_ptr route() { return _route; } diff --git a/gtk2_ardour/mixer_actor.cc b/gtk2_ardour/mixer_actor.cc index 41b2c87f5f..c0beee805f 100644 --- a/gtk2_ardour/mixer_actor.cc +++ b/gtk2_ardour/mixer_actor.cc @@ -92,57 +92,57 @@ MixerActor::load_bindings () void MixerActor::solo_action () { - GdkEventButton ev; + set_axis_targets_for_operation (); - ev.type = GDK_BUTTON_PRESS; - ev.button = 1; - ev.state = 0; - - set_route_targets_for_operation (); - - BOOST_FOREACH(RouteUI* r, _route_targets) { - r->solo_press (&ev); + BOOST_FOREACH(AxisView* r, _axis_targets) { + boost::shared_ptr s = r->stripable(); + if (s) { + boost::shared_ptr ac = s->solo_control(); + if (ac) { + ac->set_value (!ac->get_value(), Controllable::UseGroup); + } + } } } void MixerActor::mute_action () { - GdkEventButton ev; + set_axis_targets_for_operation (); - ev.type = GDK_BUTTON_PRESS; - ev.button = 1; - ev.state = 0; - - set_route_targets_for_operation (); - - BOOST_FOREACH(RouteUI* r, _route_targets) { - r->mute_press (&ev); + BOOST_FOREACH(AxisView* r, _axis_targets) { + boost::shared_ptr s = r->stripable(); + if (s) { + boost::shared_ptr ac = s->mute_control(); + if (ac) { + ac->set_value (!ac->get_value(), Controllable::UseGroup); + } + } } } void MixerActor::rec_enable_action () { - GdkEventButton ev; + set_axis_targets_for_operation (); - ev.type = GDK_BUTTON_PRESS; - ev.button = 1; - ev.state = 0; - - set_route_targets_for_operation (); - - BOOST_FOREACH(RouteUI* r, _route_targets) { - r->rec_enable_press (&ev); + BOOST_FOREACH(AxisView* r, _axis_targets) { + boost::shared_ptr s = r->stripable(); + if (s) { + boost::shared_ptr ac = s->rec_enable_control(); + if (ac) { + ac->set_value (!ac->get_value(), Controllable::UseGroup); + } + } } } void MixerActor::step_gain_up_action () { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->step_gain_up (); @@ -153,9 +153,9 @@ MixerActor::step_gain_up_action () void MixerActor::step_gain_down_action () { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->step_gain_down (); @@ -166,13 +166,15 @@ MixerActor::step_gain_down_action () void MixerActor::unity_gain_action () { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); -printf("setting gain to unity (?)"); - BOOST_FOREACH(RouteUI* r, _route_targets) { - boost::shared_ptr rp = r->route(); - if (rp) { - rp->gain_control()->set_value (1.0, Controllable::NoGroup); + BOOST_FOREACH(AxisView* r, _axis_targets) { + boost::shared_ptr s = r->stripable(); + if (s) { + boost::shared_ptr ac = s->gain_control(); + if (ac) { + ac->set_value (1.0, Controllable::UseGroup); + } } } } @@ -180,9 +182,9 @@ printf("setting gain to unity (?)"); void MixerActor::copy_processors () { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->copy_processors (); @@ -192,9 +194,9 @@ MixerActor::copy_processors () void MixerActor::cut_processors () { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->cut_processors (); @@ -204,9 +206,9 @@ MixerActor::cut_processors () void MixerActor::paste_processors () { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->paste_processors (); @@ -216,9 +218,9 @@ MixerActor::paste_processors () void MixerActor::select_all_processors () { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->select_all_processors (); @@ -228,9 +230,9 @@ MixerActor::select_all_processors () void MixerActor::toggle_processors () { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->toggle_processors (); @@ -240,9 +242,9 @@ MixerActor::toggle_processors () void MixerActor::ab_plugins () { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->ab_plugins (); @@ -253,9 +255,9 @@ MixerActor::ab_plugins () void MixerActor::vca_assign (boost::shared_ptr vca) { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); #if 0 - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->vca_assign (vca); @@ -267,9 +269,9 @@ MixerActor::vca_assign (boost::shared_ptr vca) void MixerActor::vca_unassign (boost::shared_ptr vca) { - set_route_targets_for_operation (); + set_axis_targets_for_operation (); #if 0 - BOOST_FOREACH(RouteUI* r, _route_targets) { + BOOST_FOREACH(AxisView* r, _axis_targets) { MixerStrip* ms = dynamic_cast (r); if (ms) { ms->vca_unassign (vca); diff --git a/gtk2_ardour/mixer_actor.h b/gtk2_ardour/mixer_actor.h index 16b450133d..a2f4522afb 100644 --- a/gtk2_ardour/mixer_actor.h +++ b/gtk2_ardour/mixer_actor.h @@ -48,9 +48,9 @@ class MixerActor : virtual public sigc::trackable protected: Gtkmm2ext::ActionMap myactions; RouteProcessorSelection _selection; - RouteUISelection _route_targets; + AxisViewSelection _axis_targets; - virtual void set_route_targets_for_operation () = 0; + virtual void set_axis_targets_for_operation () = 0; void vca_assign (boost::shared_ptr); void vca_unassign (boost::shared_ptr); diff --git a/gtk2_ardour/mixer_group_tabs.cc b/gtk2_ardour/mixer_group_tabs.cc index 373e5eee1a..25dbae4484 100644 --- a/gtk2_ardour/mixer_group_tabs.cc +++ b/gtk2_ardour/mixer_group_tabs.cc @@ -186,8 +186,8 @@ RouteList MixerGroupTabs::selected_routes () const { RouteList rl; - BOOST_FOREACH (RouteUI* r, _mixer->selection().routes) { - boost::shared_ptr rp = r->route(); + BOOST_FOREACH (AxisView* r, _mixer->selection().axes) { + boost::shared_ptr rp = boost::dynamic_pointer_cast (r->stripable()); if (rp) { rl.push_back (rp); } diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index d7007184a7..77b203e7fb 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -1719,8 +1719,10 @@ MixerStrip::list_route_operations () } void -MixerStrip::show_selected () +MixerStrip::set_selected (bool yn) { + AxisView::set_selected (yn); + if (selected()) { global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT); global_frame.set_name ("MixerStripSelectedFrame"); diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index 0d815c4b3e..c1c1726902 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -88,6 +88,8 @@ class MixerStrip : public AxisView, public RouteUI, public Gtk::EventBox bool marked_for_display () const; bool set_marked_for_display (bool); + boost::shared_ptr stripable() const { return RouteUI::stripable(); } + void set_width_enum (Width, void* owner); Width get_width_enum () const { return _width; } void* width_owner () const { return _width_owner; } @@ -138,7 +140,7 @@ class MixerStrip : public AxisView, public RouteUI, public Gtk::EventBox void toggle_processors (); void ab_plugins (); - void show_selected (); + void set_selected (bool yn); static MixerStrip* entered_mixer_strip() { return _entered_mixer_strip; } diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index ca0320eb6f..af621daae3 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -816,11 +816,11 @@ Mixer_UI::follow_editor_selection () _selection.clear_routes (); for (TrackViewList::iterator i = s.begin(); i != s.end(); ++i) { - RouteTimeAxisView* rtav = dynamic_cast (*i); - if (rtav) { - MixerStrip* ms = strip_by_route (rtav->route()); - if (ms) { - _selection.add (ms); + TimeAxisView* tav = dynamic_cast (*i); + if (tav) { + AxisView* axis = axis_by_stripable (tav->stripable()); + if (axis) { + _selection.add (axis); } } } @@ -831,9 +831,9 @@ Mixer_UI::follow_editor_selection () MixerStrip* -Mixer_UI::strip_by_route (boost::shared_ptr r) +Mixer_UI::strip_by_route (boost::shared_ptr r) const { - for (list::iterator i = strips.begin(); i != strips.end(); ++i) { + for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { if ((*i)->route() == r) { return (*i); } @@ -842,6 +842,18 @@ Mixer_UI::strip_by_route (boost::shared_ptr r) return 0; } +AxisView* +Mixer_UI::axis_by_stripable (boost::shared_ptr s) const +{ + for (list::const_iterator i = strips.begin(); i != strips.end(); ++i) { + if ((*i)->stripable() == s) { + return (*i); + } + } + + return 0; +} + bool Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) { @@ -850,7 +862,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) /* primary-click: toggle selection state of strip */ if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { _selection.remove (strip); - } else if (_selection.routes.size() > 1) { + } else if (_selection.axes.size() > 1) { /* de-select others */ _selection.set (strip); } @@ -2220,12 +2232,12 @@ Mixer_UI::strip_by_x (int x) } void -Mixer_UI::set_route_targets_for_operation () +Mixer_UI::set_axis_targets_for_operation () { - _route_targets.clear (); + _axis_targets.clear (); if (!_selection.empty()) { - _route_targets = _selection.routes; + _axis_targets = _selection.axes; return; } @@ -2251,13 +2263,13 @@ Mixer_UI::toggle_midi_input_active (bool flip_others) boost::shared_ptr rl (new RouteList); bool onoff = false; - set_route_targets_for_operation (); + set_axis_targets_for_operation (); - for (RouteUISelection::iterator r = _route_targets.begin(); r != _route_targets.end(); ++r) { - boost::shared_ptr mt = (*r)->midi_track(); + for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) { + boost::shared_ptr mt = boost::dynamic_pointer_cast ((*r)->stripable()); if (mt) { - rl->push_back ((*r)->route()); + rl->push_back (mt); onoff = !mt->input_active(); } } @@ -2458,7 +2470,7 @@ Mixer_UI::popup_note_context_menu (GdkEventButton *ev) Gtk::Menu* m = manage (new Menu); MenuList& items = m->items (); - if (_selection.routes.empty()) { + if (_selection.axes.empty()) { items.push_back (MenuElem (_("No Track/Bus is selected."))); } else { items.push_back (MenuElem (_("Add at the top"), @@ -2575,17 +2587,23 @@ Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* col void Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos) { - if (!_session || _selection.routes.empty()) { + if (!_session || _selection.axes.empty()) { return; } PluginInfoPtr pip = ppp->_pip; - for (RouteUISelection::iterator i = _selection.routes.begin(); i != _selection.routes.end(); ++i) { - boost::shared_ptr rt = (*i)->route(); - if (!rt) { continue; } + for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) { + boost::shared_ptr rt = boost::dynamic_pointer_cast ((*i)->stripable()); + + if (!rt) { + continue; + } PluginPtr p = pip->load (*_session); - if (!p) { continue; } + + if (!p) { + continue; + } if (ppp->_preset.valid) { p->load_preset (ppp->_preset); diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index 6dc8cd2c84..70a0e630b7 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -121,7 +121,7 @@ class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, p sigc::signal1 > show_vca_change; protected: - void set_route_targets_for_operation (); + void set_axis_targets_for_operation (); private: Mixer_UI (); @@ -177,7 +177,8 @@ class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, p void add_masters (ARDOUR::VCAList&); void remove_master (VCAMasterStrip*); - MixerStrip* strip_by_route (boost::shared_ptr); + MixerStrip* strip_by_route (boost::shared_ptr) const; + AxisView* axis_by_stripable (boost::shared_ptr) const; void hide_all_strips (bool with_select); void unselect_all_strips(); diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index 5b9db5daf8..2691b46a7b 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -381,7 +381,7 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp */ for (list::iterator i = route_ios.begin(); i != route_ios.end(); ++i) { - TimeAxisView* tv = PublicEditor::instance().axis_view_from_route (i->route); + TimeAxisView* tv = PublicEditor::instance().axis_view_from_stripable (i->route); /* Work out which group to put these IOs' bundles in */ boost::shared_ptr g; diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 836f849018..e562e1cb37 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -57,6 +57,7 @@ namespace ARDOUR { class RouteGroup; class Trimmable; class Movable; + class Stripable; } namespace Gtk { @@ -371,7 +372,7 @@ class PublicEditor : public Gtkmm2ext::Tabbable { virtual ArdourCanvas::GtkCanvasViewport* get_track_canvas() const = 0; - virtual TimeAxisView* axis_view_from_route (boost::shared_ptr) const = 0; + virtual TimeAxisView* axis_view_from_stripable (boost::shared_ptr) const = 0; virtual void set_current_trimmable (boost::shared_ptr) = 0; virtual void set_current_movable (boost::shared_ptr) = 0; diff --git a/gtk2_ardour/route_processor_selection.cc b/gtk2_ardour/route_processor_selection.cc index 30943e22d0..ed993fdc86 100644 --- a/gtk2_ardour/route_processor_selection.cc +++ b/gtk2_ardour/route_processor_selection.cc @@ -42,7 +42,7 @@ RouteProcessorSelection::operator= (const RouteProcessorSelection& other) { if (&other != this) { processors = other.processors; - routes = other.routes; + axes = other.axes; } return *this; } @@ -51,7 +51,7 @@ bool operator== (const RouteProcessorSelection& a, const RouteProcessorSelection& b) { // XXX MUST TEST PROCESSORS SOMEHOW - return a.routes == b.routes; + return a.axes == b.axes; } void @@ -71,10 +71,10 @@ RouteProcessorSelection::clear_processors () void RouteProcessorSelection::clear_routes () { - for (RouteUISelection::iterator i = routes.begin(); i != routes.end(); ++i) { + for (AxisViewSelection::iterator i = axes.begin(); i != axes.end(); ++i) { (*i)->set_selected (false); } - routes.clear (); + axes.clear (); drop_connections (); if (!_no_route_change_signal) { RoutesChanged (); @@ -98,34 +98,33 @@ RouteProcessorSelection::set (XMLNode* node) } void -RouteProcessorSelection::add (RouteUI* r) +RouteProcessorSelection::add (AxisView* r) { - if (find (routes.begin(), routes.end(), r) == routes.end()) { - if (routes.insert (r).second) { - r->set_selected (true); + if (axes.insert (r).second) { - MixerStrip* ms = dynamic_cast (r); + r->set_selected (true); - if (ms) { - ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1), gui_context()); - } + MixerStrip* ms = dynamic_cast (r); - if (!_no_route_change_signal) { - RoutesChanged(); - } + if (ms) { + ms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&RouteProcessorSelection::remove, this, _1), gui_context()); + } + + if (!_no_route_change_signal) { + RoutesChanged(); } } } void -RouteProcessorSelection::remove (RouteUI* r) +RouteProcessorSelection::remove (AxisView* r) { ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r); - RouteUISelection::iterator i; - if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) { + AxisViewSelection::iterator i; + if ((i = find (axes.begin(), axes.end(), r)) != axes.end()) { (*i)->set_selected (false); - routes.erase (i); + axes.erase (i); if (!_no_route_change_signal) { RoutesChanged (); } @@ -133,22 +132,22 @@ RouteProcessorSelection::remove (RouteUI* r) } void -RouteProcessorSelection::set (RouteUI* r) +RouteProcessorSelection::set (AxisView* r) { clear_routes (); add (r); } bool -RouteProcessorSelection::selected (RouteUI* r) +RouteProcessorSelection::selected (AxisView* r) { - return find (routes.begin(), routes.end(), r) != routes.end(); + return find (axes.begin(), axes.end(), r) != axes.end(); } bool RouteProcessorSelection::empty () { - return processors.empty () && routes.empty (); + return processors.empty () && axes.empty (); } void diff --git a/gtk2_ardour/route_processor_selection.h b/gtk2_ardour/route_processor_selection.h index 3f8bb1a08c..6c037d7bd9 100644 --- a/gtk2_ardour/route_processor_selection.h +++ b/gtk2_ardour/route_processor_selection.h @@ -30,7 +30,7 @@ class RouteProcessorSelection : public PBD::ScopedConnectionList, public sigc::t { public: ProcessorSelection processors; - RouteUISelection routes; + AxisViewSelection axes; RouteProcessorSelection(); @@ -47,17 +47,17 @@ class RouteProcessorSelection : public PBD::ScopedConnectionList, public sigc::t void set (XMLNode* node); void add (XMLNode* node); - void set (RouteUI*); - void add (RouteUI*); - void remove (RouteUI*); + void set (AxisView*); + void add (AxisView*); + void remove (AxisView*); void clear_processors (); void clear_routes (); - bool selected (RouteUI*); + bool selected (AxisView*); private: - void removed (RouteUI*); + void removed (AxisView*); bool _no_route_change_signal; }; diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index d3b28bd042..7b73f36532 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -2921,18 +2921,6 @@ RouteTimeAxisView::remove_child (boost::shared_ptr c) } } -PresentationInfo const & -RouteTimeAxisView::presentation_info () const -{ - return _route->presentation_info(); -} - -boost::shared_ptr -RouteTimeAxisView::stripable () const -{ - return _route; -} - Gdk::Color RouteTimeAxisView::color () const { diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index e24bd638a6..3af3f1e08e 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -83,10 +83,9 @@ public: bool marked_for_display () const; bool set_marked_for_display (bool); - void set_route (boost::shared_ptr); + boost::shared_ptr stripable() const { return RouteUI::stripable(); } - boost::shared_ptr stripable() const; - ARDOUR::PresentationInfo const & presentation_info () const; + void set_route (boost::shared_ptr); void show_selection (TimeSelection&); void set_button_names (); diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 7ecb4f2031..5b6217af4a 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -2144,33 +2144,6 @@ RouteUI::route_gui_changed (PropertyChange const& what_changed) route_color_changed (); } } - - if (what_changed.contains (Properties::selected)) { - show_selected (); - } -} - -void -RouteUI::set_selected (bool yn) -{ - Selectable::set_selected (yn); - if (_route) { - _route->presentation_info().set_selected (yn); - } -} - -bool -RouteUI::selected () const -{ - /* XXX not sure if this is a wise design. Probably don't really want - * the cached _selected value from Selectable. - */ - - if (!_route) { - return _selected; - } - - return _route->presentation_info().selected(); } void @@ -2365,3 +2338,10 @@ RouteUI::mark_hidden (bool yn) } return false; } + +boost::shared_ptr +RouteUI::stripable () const +{ + return _route; +} + diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index ecd4ed520d..e05db7f677 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -74,13 +74,15 @@ class RoutePinWindowProxy : public WM::ProxyBase PBD::ScopedConnection going_away_connection; }; -class RouteUI : public virtual ARDOUR::SessionHandlePtr, public virtual Selectable, public virtual PBD::ScopedConnectionList +class RouteUI : public virtual ARDOUR::SessionHandlePtr, public virtual PBD::ScopedConnectionList, public virtual Selectable, public virtual sigc::trackable { public: RouteUI (ARDOUR::Session*); virtual ~RouteUI(); + boost::shared_ptr stripable() const; + virtual void set_route (boost::shared_ptr); virtual void set_button_names () = 0; @@ -106,9 +108,6 @@ class RouteUI : public virtual ARDOUR::SessionHandlePtr, public virtual Selectab Gdk::Color route_color () const; void choose_color (); - bool selected () const; - void set_selected (bool); - bool ignore_toggle; bool wait_for_release; bool multiple_mute_change; diff --git a/gtk2_ardour/route_ui_selection.h b/gtk2_ardour/route_ui_selection.h index b26e1c6f54..03935aab7b 100644 --- a/gtk2_ardour/route_ui_selection.h +++ b/gtk2_ardour/route_ui_selection.h @@ -23,8 +23,8 @@ #include -class RouteUI; +class AxisView; -struct RouteUISelection : std::set {}; +struct AxisViewSelection : std::set {}; #endif /* __ardour_gtk_route_ui_selection_h__ */ diff --git a/gtk2_ardour/selectable.h b/gtk2_ardour/selectable.h index c22a1b54f6..2ffac87929 100644 --- a/gtk2_ardour/selectable.h +++ b/gtk2_ardour/selectable.h @@ -41,8 +41,6 @@ class Selectable : public virtual sigc::trackable return _selected; } - virtual void show_selected() {} - protected: bool _selected; }; diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index fefca3d1ec..feb7b3b1a5 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -26,6 +26,8 @@ #include "ardour/playlist.h" #include "ardour/rc_configuration.h" +#include "control_protocol/control_protocol.h" + #include "audio_region_view.h" #include "debug.h" #include "gui_thread.h" @@ -637,6 +639,7 @@ Selection::remove (TimeAxisView* track) if ((i = find (tracks.begin(), tracks.end(), track)) != tracks.end()) { track->set_selected (false); tracks.erase (i); + if (!_no_tracks_changed) { TracksChanged(); } diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index de8c17f456..6a2d80e0eb 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -742,9 +742,15 @@ TimeAxisView::popup_display_menu (guint32 when) } void -TimeAxisView::show_selected () +TimeAxisView::set_selected (bool yn) { - if (selected()) { + if (yn == selected()) { + return; + } + + Selectable::set_selected (yn); + + if (_selected) { time_axis_frame.set_shadow_type (Gtk::SHADOW_IN); time_axis_frame.set_name ("MixerStripSelectedFrame"); controls_ebox.set_name (controls_base_selected_name); @@ -770,6 +776,7 @@ TimeAxisView::show_selected () } time_axis_frame.show(); + } void diff --git a/gtk2_ardour/time_axis_view.h b/gtk2_ardour/time_axis_view.h index 1920d668a7..aed4576f20 100644 --- a/gtk2_ardour/time_axis_view.h +++ b/gtk2_ardour/time_axis_view.h @@ -105,9 +105,6 @@ class TimeAxisView : public virtual AxisView static void setup_sizes (); - virtual boost::shared_ptr stripable() const = 0; - virtual ARDOUR::PresentationInfo const & presentation_info () const = 0; - /** @return index of this TimeAxisView within its parent */ int order () const { return _order; } @@ -139,6 +136,8 @@ class TimeAxisView : public virtual AxisView /** @return true if hidden, otherwise false */ bool hidden () const { return _hidden; } + void set_selected (bool); + virtual bool selectable() const { return true; } /** @@ -306,9 +305,6 @@ class TimeAxisView : public virtual AxisView void build_size_menu (); - protected: - void show_selected (); - private: Gtk::VBox* control_parent; int _order; diff --git a/gtk2_ardour/track_selection.cc b/gtk2_ardour/track_selection.cc index 92efbd4863..6937eb623d 100644 --- a/gtk2_ardour/track_selection.cc +++ b/gtk2_ardour/track_selection.cc @@ -18,7 +18,10 @@ */ #include + #include "ardour/route_group.h" +#include "control_protocol/control_protocol.h" + #include "track_selection.h" #include "time_axis_view.h" #include "public_editor.h" @@ -57,4 +60,3 @@ TrackSelection::add (TrackViewList const & t) return added; } - diff --git a/gtk2_ardour/vca_master_strip.cc b/gtk2_ardour/vca_master_strip.cc index c0ade152af..3ea00b1a47 100644 --- a/gtk2_ardour/vca_master_strip.cc +++ b/gtk2_ardour/vca_master_strip.cc @@ -510,3 +510,16 @@ VCAMasterStrip::set_marked_for_display (bool yn) } return false; } + +PresentationInfo const & +VCAMasterStrip::presentation_info () const +{ + return _vca->presentation_info(); +} + +boost::shared_ptr +VCAMasterStrip::stripable () const +{ + return _vca; +} + diff --git a/gtk2_ardour/vca_master_strip.h b/gtk2_ardour/vca_master_strip.h index bca74fded0..ea8ee52f6d 100644 --- a/gtk2_ardour/vca_master_strip.h +++ b/gtk2_ardour/vca_master_strip.h @@ -42,6 +42,9 @@ class VCAMasterStrip : public AxisView, public Gtk::EventBox VCAMasterStrip (ARDOUR::Session*, boost::shared_ptr); ~VCAMasterStrip (); + boost::shared_ptr stripable() const; + ARDOUR::PresentationInfo const & presentation_info () const; + std::string name() const; Gdk::Color color () const; std::string state_id() const;