From 034db5fb1cc4d71bfa0e1c005733115df68fdefd Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 13 Dec 2009 19:09:52 +0000 Subject: [PATCH] Apply Select property of route groups at the Selection object level. Accordingly simplify code related to selecting tracks. Add a TrackViewList object rather than "abusing" TrackSelection in lots of places. git-svn-id: svn://localhost/ardour2/branches/3.0@6358 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 84 ++++++++------------------ gtk2_ardour/editor.h | 17 +++--- gtk2_ardour/editor_drag.cc | 4 +- gtk2_ardour/editor_group_tabs.cc | 4 +- gtk2_ardour/editor_ops.cc | 20 +++---- gtk2_ardour/editor_route_groups.cc | 10 ++-- gtk2_ardour/editor_selection.cc | 94 +++++++++++------------------- gtk2_ardour/editor_summary.cc | 4 +- gtk2_ardour/public_editor.h | 6 +- gtk2_ardour/route_time_axis.cc | 18 ++---- gtk2_ardour/selection.cc | 28 ++++----- gtk2_ardour/selection.h | 10 ++-- gtk2_ardour/time_axis_view.cc | 61 +++++++++---------- gtk2_ardour/track_selection.cc | 52 ++++++++++++----- gtk2_ardour/track_selection.h | 18 +++--- gtk2_ardour/wscript | 1 + libs/ardour/ardour/route_group.h | 1 - 17 files changed, 192 insertions(+), 240 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 41f5cc4a58..9ca44992c4 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -3572,43 +3572,6 @@ Editor::mouse_select_button_release (GdkEventButton* ev) return true; } -Editor::TrackViewList * -Editor::get_valid_views (TimeAxisView* track, RouteGroup* group) -{ - TrackViewList::iterator i; - - TrackViewList* v = new TrackViewList; - - if (track == 0 && group == 0) { - - /* all views */ - - for (i = track_views.begin(); i != track_views.end (); ++i) { - v->push_back (*i); - } - - } else if ((track != 0 && group == 0) || (track != 0 && group != 0 && !group->active_property (RouteGroup::Select))) { - - /* just the view for this track - */ - - v->push_back (track); - - } else { - - /* views for all tracks in the route group */ - - for (i = track_views.begin(); i != track_views.end (); ++i) { - - if (group == 0 || ((*i)->route_group() == group && group->active_property (RouteGroup::Select))) { - v->push_back (*i); - } - } - } - - return v; -} - void Editor::set_zoom_focus (ZoomFocus f) { @@ -4268,7 +4231,7 @@ Editor::post_zoom () if (mouse_mode == MouseRange && selection->time.start () != selection->time.end_frame ()) { if (!selection->tracks.empty()) { - for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { (*i)->reshow_selection (selection->time); } } else { @@ -4412,7 +4375,7 @@ struct EditorOrderTimeAxisSorter { }; void -Editor::sort_track_selection (TrackSelection* sel) +Editor::sort_track_selection (TrackViewList* sel) { EditorOrderTimeAxisSorter cmp; @@ -4532,9 +4495,9 @@ Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd) * @param ts Tracks to look on; if this is empty, all tracks are examined. */ void -Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const +Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackViewList& ts) const { - const TrackSelection* tracks; + const TrackViewList* tracks; if (ts.empty()) { tracks = &track_views; @@ -4542,7 +4505,7 @@ Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelec tracks = &ts; } - for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) { + for (TrackViewList::const_iterator t = tracks->begin(); t != tracks->end(); ++t) { RouteTimeAxisView* rtv = dynamic_cast(*t); if (rtv) { boost::shared_ptr ds; @@ -4567,9 +4530,9 @@ Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelec } void -Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const +Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackViewList& ts) const { - const TrackSelection* tracks; + const TrackViewList* tracks; if (ts.empty()) { tracks = &track_views; @@ -4577,7 +4540,7 @@ Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSe tracks = &ts; } - for (TrackSelection::const_iterator t = tracks->begin(); t != tracks->end(); ++t) { + for (TrackViewList::const_iterator t = tracks->begin(); t != tracks->end(); ++t) { RouteTimeAxisView* rtv = dynamic_cast(*t); if (rtv) { boost::shared_ptr ds; @@ -4624,22 +4587,25 @@ Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered, bool al if (allow_edit_position) { - TrackSelection tracks = selection->tracks; + TrackViewList tracks = selection->tracks; /* tracks is currently the set of selected tracks; add any other tracks that * have regions that are in the same edit-activated route group as one of * our regions */ for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) { - RouteGroup* g = (*i)->get_time_axis_view().route_group (); - if (g && g->active_property (RouteGroup::Edit)) { - tracks.add (axis_views_from_routes (g->route_list())); - } + RouteGroup* g = (*i)->get_time_axis_view().route_group (); + if (g && g->active_property (RouteGroup::Edit)) { + tracks.add (axis_views_from_routes (g->route_list())); + } + } - /* now find regions that are at the edit position on those tracks */ - nframes64_t const where = get_preferred_edit_position (); - get_regions_at (rs, where, tracks); + if (!tracks.empty()) { + /* now find regions that are at the edit position on those tracks */ + nframes64_t const where = get_preferred_edit_position (); + get_regions_at (rs, where, tracks); + } } } @@ -4750,7 +4716,7 @@ Editor::add_to_idle_resize (TimeAxisView* view, int32_t h) min_resulting = min (min_resulting, int32_t (_pending_resize_view->current_height()) + _pending_resize_amount); if (selection->tracks.contains (_pending_resize_view)) { - for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { min_resulting = min (min_resulting, int32_t ((*i)->current_height()) + _pending_resize_amount); } } @@ -4774,7 +4740,7 @@ Editor::idle_resize () if (dynamic_cast (_pending_resize_view) == 0 && selection->tracks.contains (_pending_resize_view)) { - for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { if (*i != _pending_resize_view) { (*i)->idle_resize ((*i)->current_height() + _pending_resize_amount); } @@ -4824,10 +4790,10 @@ Editor::axis_view_from_route (boost::shared_ptr r) const } -TrackSelection +TrackViewList Editor::axis_views_from_routes (boost::shared_ptr r) const { - TrackSelection t; + TrackViewList t; for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { TimeAxisView* tv = axis_view_from_route (*i); @@ -4949,7 +4915,7 @@ Editor::hide_track_in_display (TimeAxisView& tv, bool /*temponly*/) bool Editor::sync_track_view_list_and_routes () { - track_views = TrackSelection (_routes->views ()); + track_views = TrackViewList (_routes->views ()); _summary->set_dirty (); _group_tabs->set_dirty (); @@ -4984,7 +4950,7 @@ Editor::get_route_view_by_id (PBD::ID& id) void Editor::fit_route_group (RouteGroup *g) { - TrackSelection ts = axis_views_from_routes (g->route_list ()); + TrackViewList ts = axis_views_from_routes (g->route_list ()); fit_tracks (ts); } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 928a43ce86..36895bf784 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -121,7 +121,6 @@ class TempoLines; class TimeAxisView; class TimeFXDialog; class TimeSelection; -class TrackSelection; class EditorGroupTabs; class EditorRoutes; class EditorRouteGroups; @@ -330,7 +329,6 @@ class Editor : public PublicEditor void copy_playlists (TimeAxisView* v); void clear_playlists (TimeAxisView* v); - TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0); void get_onscreen_tracks (TrackViewList&); Width editor_mixer_strip_width; @@ -433,6 +431,8 @@ class Editor : public PublicEditor void center_screen (nframes64_t); + TrackViewList axis_views_from_routes (boost::shared_ptr) const; + protected: void map_transport_state (); void map_position_change (nframes64_t); @@ -560,10 +560,8 @@ class Editor : public PublicEditor CrossfadeView* clicked_crossfadeview; ControlPoint* clicked_control_point; - void sort_track_selection (TrackSelection* sel = 0); + void sort_track_selection (TrackViewList* sel = 0); - void get_relevant_tracks (std::set& relevant_tracks) const; - void get_equivalent_tracks (RouteTimeAxisView*, std::set &, ARDOUR::RouteGroup::Property) const; void get_equivalent_regions (RegionView* rv, std::vector &, ARDOUR::RouteGroup::Property) const; RegionSelection get_equivalent_regions (RegionSelection &, ARDOUR::RouteGroup::Property) const; void mapover_tracks (sigc::slot sl, TimeAxisView*, ARDOUR::RouteGroup::Property) const; @@ -951,9 +949,8 @@ class Editor : public PublicEditor TrackViewList track_views; std::pair trackview_by_y_position (double); TimeAxisView* axis_view_from_route (boost::shared_ptr) const; - TrackSelection axis_views_from_routes (boost::shared_ptr) const; - TrackSelection get_tracks_for_range_action () const; + TrackViewList get_tracks_for_range_action () const; static Gdk::Cursor* cross_hair_cursor; static Gdk::Cursor* trimmer_cursor; @@ -1953,8 +1950,8 @@ public: bool get_edit_op_range (nframes64_t& start, nframes64_t& end) const; - void get_regions_at (RegionSelection&, nframes64_t where, const TrackSelection& ts) const; - void get_regions_after (RegionSelection&, nframes64_t where, const TrackSelection& ts) const; + void get_regions_at (RegionSelection&, nframes64_t where, const TrackViewList& ts) const; + void get_regions_after (RegionSelection&, nframes64_t where, const TrackViewList& ts) const; void get_regions_for_action (RegionSelection&, bool allow_entered = false, bool allow_edit_position = true); @@ -1974,7 +1971,7 @@ public: BundleManager* _bundle_manager; GlobalPortMatrixWindow* _global_port_matrix[ARDOUR::DataType::num_types]; - void fit_tracks (TrackSelection &); + void fit_tracks (TrackViewList &); void fit_selected_tracks (); void set_track_height (uint32_t h); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index a78ee144d2..0e9b62aeb4 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -274,7 +274,7 @@ RegionMotionDrag::get_time_axis_view_summary () /* get a bitmask representing the visible tracks */ - for (Editor::TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { + for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { RouteTimeAxisView* rtv = dynamic_cast (*i); TimeAxisView::Children children_list; @@ -1516,7 +1516,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) bool obey_snap = !Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier()); /* snap modifier works differently here.. - its' current state has to be passed to the + its current state has to be passed to the various trim functions in order to work properly */ diff --git a/gtk2_ardour/editor_group_tabs.cc b/gtk2_ardour/editor_group_tabs.cc index 7776254833..8e7e303399 100644 --- a/gtk2_ardour/editor_group_tabs.cc +++ b/gtk2_ardour/editor_group_tabs.cc @@ -43,7 +43,7 @@ EditorGroupTabs::compute_tabs () const tab.group = 0; int32_t y = 0; - for (Editor::TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { + for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { if ((*i)->marked_for_display() == false) { continue; @@ -118,7 +118,7 @@ EditorGroupTabs::routes_for_tab (Tab const * t) const RouteList routes; int32_t y = 0; - for (Editor::TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { + for (TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { if ((*i)->marked_for_display() == false) { continue; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index ae4942c169..be9538df68 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -2661,7 +2661,7 @@ Editor::region_from_selection () nframes64_t start = selection->time[clicked_selection].start; nframes64_t end = selection->time[clicked_selection].end; - TrackSelection tracks = get_tracks_for_range_action (); + TrackViewList tracks = get_tracks_for_range_action (); nframes64_t selection_cnt = end - start + 1; @@ -2762,10 +2762,10 @@ add_if_covered (RegionView* rv, const AudioRange* ar, RegionSelection* rs) * - all tracks * @return tracks. */ -TrackSelection +TrackViewList Editor::get_tracks_for_range_action () const { - TrackSelection t; + TrackViewList t; if (selection->tracks.empty()) { @@ -2801,7 +2801,7 @@ Editor::separate_regions_between (const TimeSelection& ts) boost::shared_ptr playlist; RegionSelection new_selection; - TrackSelection tmptracks = get_tracks_for_range_action (); + TrackViewList tmptracks = get_tracks_for_range_action (); sort_track_selection (&tmptracks); for (TrackSelection::iterator i = tmptracks.begin(); i != tmptracks.end(); ++i) { @@ -2965,7 +2965,7 @@ Editor::crop_region_to (nframes64_t start, nframes64_t end) { vector > playlists; boost::shared_ptr playlist; - TrackSelection* ts; + TrackViewList* ts; if (selection->tracks.empty()) { ts = &track_views; @@ -4230,8 +4230,8 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs) void Editor::cut_copy_ranges (CutCopyOp op) { - TrackSelection* ts; - TrackSelection entered; + TrackViewList* ts; + TrackViewList entered; if (selection->tracks.empty()) { if (!entered_track) { @@ -4289,8 +4289,8 @@ Editor::paste_internal (nframes64_t position, float times) begin_reversible_command (_("paste")); - TrackSelection ts; - TrackSelection::iterator i; + TrackViewList ts; + TrackViewList::iterator i; size_t nth; /* get everything in the correct order */ @@ -6380,7 +6380,7 @@ Editor::fit_selected_tracks () } void -Editor::fit_tracks (TrackSelection & tracks) +Editor::fit_tracks (TrackViewList & tracks) { if (tracks.empty()) { return; diff --git a/gtk2_ardour/editor_route_groups.cc b/gtk2_ardour/editor_route_groups.cc index 16bba4955b..10edec8682 100644 --- a/gtk2_ardour/editor_route_groups.cc +++ b/gtk2_ardour/editor_route_groups.cc @@ -306,7 +306,7 @@ EditorRouteGroups::new_from_rec_enabled () { RouteList rl; - for (Editor::TrackViewList::const_iterator i = _editor->get_track_views().begin(); i != _editor->get_track_views().end(); ++i) { + for (TrackViewList::const_iterator i = _editor->get_track_views().begin(); i != _editor->get_track_views().end(); ++i) { RouteTimeAxisView* rtv = dynamic_cast (*i); if (rtv && rtv->route()->record_enabled()) { rl.push_back (rtv->route()); @@ -325,7 +325,7 @@ EditorRouteGroups::new_from_soloed () { RouteList rl; - for (Editor::TrackViewList::const_iterator i = _editor->get_track_views().begin(); i != _editor->get_track_views().end(); ++i) { + for (TrackViewList::const_iterator i = _editor->get_track_views().begin(); i != _editor->get_track_views().end(); ++i) { RouteTimeAxisView* rtv = dynamic_cast (*i); if (rtv && !rtv->route()->is_master() && rtv->route()->soloed()) { rl.push_back (rtv->route()); @@ -520,13 +520,13 @@ EditorRouteGroups::row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel } if ((*iter)[_columns.is_visible]) { - for (Editor::TrackViewList::const_iterator j = _editor->get_track_views().begin(); j != _editor->get_track_views().end(); ++j) { + for (TrackViewList::const_iterator j = _editor->get_track_views().begin(); j != _editor->get_track_views().end(); ++j) { if ((*j)->route_group() == group) { _editor->_routes->show_track_in_display (**j); } } } else { - for (Editor::TrackViewList::const_iterator j = _editor->get_track_views().begin(); j != _editor->get_track_views().end(); ++j) { + for (TrackViewList::const_iterator j = _editor->get_track_views().begin(); j != _editor->get_track_views().end(); ++j) { if ((*j)->route_group() == group) { _editor->hide_track_in_display (**j); } @@ -688,7 +688,7 @@ EditorRouteGroups::collect (RouteGroup* g) int const N = routes->size (); RouteList::iterator i = routes->begin (); - Editor::TrackViewList::const_iterator j = _editor->get_track_views().begin(); + TrackViewList::const_iterator j = _editor->get_track_views().begin(); int diff = 0; int coll = -1; diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 27f4fe6c69..8852271f11 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -262,48 +262,6 @@ Editor::get_onscreen_tracks (TrackViewList& tvl) } } -/** Given a track, find any other tracks that are in the same active route group with a given property. - * @param basis Base track. - * @param equivs Filled with the base track and the found tracks. - * @param prop Property to look for in route groups. - */ - -void -Editor::get_equivalent_tracks (RouteTimeAxisView* basis, set & equivs, RouteGroup::Property prop) const -{ - equivs.insert (basis); - - RouteGroup* group = basis->route()->route_group(); - if (group && group->active_property (prop)) { - - /* the basis is a member of an active route group, with the appropriate - properties; find other members */ - - for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) { - RouteTimeAxisView* v = dynamic_cast (*i); - if (v && v->route()->route_group() == group) { - equivs.insert (v); - } - } - } -} - -/** Find tracks that are selected, and also those that are in the same `selection'-enabled route - * group as one that is selected. - * @param relevant_tracks set to add tracks to. - */ - -void -Editor::get_relevant_tracks (set& relevant_tracks) const -{ - for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) { - RouteTimeAxisView* rtv = dynamic_cast (*ti); - if (rtv) { - get_equivalent_tracks (rtv, relevant_tracks, RouteGroup::Select); - } - } -} - /** Call a slot for a given `basis' track and also for any track that is in the same * active route group with a particular set of properties. * @@ -321,7 +279,21 @@ Editor::mapover_tracks (sigc::slot sl, TimeA } set tracks; - get_equivalent_tracks (route_basis, tracks, prop); + tracks.insert (route_basis); + + RouteGroup* group = route_basis->route()->route_group(); + if (group && group->active_property (prop)) { + + /* the basis is a member of an active route group, with the appropriate + properties; find other members */ + + for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) { + RouteTimeAxisView* v = dynamic_cast (*i); + if (v && v->route()->route_group() == group) { + tracks.insert (v); + } + } + } /* call the slots */ uint32_t const sz = tracks.size (); @@ -490,8 +462,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, /* add all the equivalent regions, but only on button press */ - - if (!all_equivalent_regions.empty()) { commit = true; } @@ -611,16 +581,23 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, /* 2. find all the tracks we should select in */ set relevant_tracks; - set already_in_selection; - get_relevant_tracks (relevant_tracks); + for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + RouteTimeAxisView* r = dynamic_cast (*i); + if (r) { + relevant_tracks.insert (r); + } + } + + set already_in_selection; if (relevant_tracks.empty()) { - /* no relevant tracks -> no tracks selected .. thus .. if - the regionview we're in isn't selected (i.e. we're - about to extend to it), then find all tracks between - the this one and any selected ones. + /* no tracks selected .. thus .. if the + regionview we're in isn't selected + (i.e. we're about to extend to it), then + find all tracks between the this one and + any selected ones. */ if (!selection->selected (entered_regionview)) { @@ -654,7 +631,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, if (result.second) { /* newly added to already_in_selection */ - int d = artv->route()->order_key ("editor"); d -= key; @@ -709,8 +685,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, one that was clicked. */ - get_relevant_tracks (relevant_tracks); - for (set::iterator t = relevant_tracks.begin(); t != relevant_tracks.end(); ++t) { (*t)->get_selectables (first_frame, last_frame, -1.0, -1.0, results); } @@ -1116,7 +1090,7 @@ Editor::select_all_selectables_using_time_selection () return; } - TrackSelection* ts; + TrackViewList* ts; if (selection->tracks.empty()) { ts = &track_views; @@ -1148,7 +1122,7 @@ Editor::select_all_selectables_using_punch() } - TrackSelection* ts; + TrackViewList* ts; if (selection->tracks.empty()) { ts = &track_views; @@ -1179,7 +1153,7 @@ Editor::select_all_selectables_using_loop() } - TrackSelection* ts; + TrackViewList* ts; if (selection->tracks.empty()) { ts = &track_views; @@ -1221,7 +1195,7 @@ Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after) } - TrackSelection* ts; + TrackViewList* ts; if (selection->tracks.empty()) { ts = &track_views; @@ -1261,7 +1235,7 @@ Editor::select_all_selectables_using_edit (bool after) } - TrackSelection* ts; + TrackViewList* ts; if (selection->tracks.empty()) { ts = &track_views; @@ -1290,7 +1264,7 @@ Editor::select_all_selectables_between (bool /*within*/) return; } - TrackSelection* ts; + TrackViewList* ts; if (selection->tracks.empty()) { ts = &track_views; diff --git a/gtk2_ardour/editor_summary.cc b/gtk2_ardour/editor_summary.cc index 9fc0b1119f..d257889682 100644 --- a/gtk2_ardour/editor_summary.cc +++ b/gtk2_ardour/editor_summary.cc @@ -143,7 +143,7 @@ EditorSummary::render (cairo_t* cr) int h = 0; int max_height = 0; - for (PublicEditor::TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { + for (TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { int const t = (*i)->effective_height (); h += t; max_height = max (max_height, t); @@ -163,7 +163,7 @@ EditorSummary::render (cairo_t* cr) /* render regions */ double y = 0; - for (PublicEditor::TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { + for (TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) { StreamView* s = (*i)->view (); if (s) { diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index e520e30a89..8b4684f539 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -88,8 +88,6 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway PublicEditor (); virtual ~PublicEditor (); - typedef TrackSelection TrackViewList; - /** @return Singleton PublicEditor instance */ static PublicEditor& instance () { return *_instance; } @@ -244,7 +242,6 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway virtual double get_physical_screen_width() const = 0; virtual void ensure_float (Gtk::Window&) = 0; virtual void show_window () = 0; - virtual TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0) = 0; virtual nframes64_t leftmost_position() const = 0; virtual nframes64_t current_page_frames() const = 0; virtual void temporal_zoom_step (bool coarser) = 0; @@ -353,6 +350,9 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway virtual void center_screen (nframes64_t) = 0; + virtual TrackViewList axis_views_from_routes (boost::shared_ptr) const = 0; + virtual TrackViewList const & get_track_views () = 0; + /// Singleton instance, set up by Editor::Editor() static PublicEditor* _instance; diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 34eff4636b..1f75bec50d 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1176,33 +1176,23 @@ RouteTimeAxisView::selection_click (GdkEventButton* ev) return; } - PublicEditor::TrackViewList* tracks = _editor.get_valid_views (this, _route->route_group()); - switch (ArdourKeyboard::selection_type (ev->state)) { case Selection::Toggle: - _editor.get_selection().toggle (*tracks); + _editor.get_selection().toggle (this); break; case Selection::Set: - _editor.get_selection().set (*tracks); + _editor.get_selection().set (this); break; case Selection::Extend: - if (tracks->size() > 1) { - /* add each one, do not "extend" */ - _editor.get_selection().add (*tracks); - } else { - /* extend to the single track */ - _editor.extend_selection_to_track (*tracks->front()); - } + _editor.extend_selection_to_track (*this); break; case Selection::Add: - _editor.get_selection().add (*tracks); + _editor.get_selection().add (this); break; } - - delete tracks; } void diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index 78fb785d11..1a0b1305c7 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -197,9 +197,9 @@ Selection::toggle (boost::shared_ptr pl) } void -Selection::toggle (const list& track_list) +Selection::toggle (const TrackViewList& track_list) { - for (list::const_iterator i = track_list.begin(); i != track_list.end(); ++i) { + for (TrackViewList::const_iterator i = track_list.begin(); i != track_list.end(); ++i) { toggle ((*i)); } } @@ -334,9 +334,9 @@ Selection::add (const list >& pllist) } void -Selection::add (const list& track_list) +Selection::add (const TrackViewList& track_list) { - list added = tracks.add (track_list); + TrackViewList added = tracks.add (track_list); for (list::const_iterator i = added.begin(); i != added.end(); ++i) { void (Selection::*pmf)(TimeAxisView*) = &Selection::remove; @@ -351,12 +351,9 @@ Selection::add (const list& track_list) void Selection::add (TimeAxisView* track) { - if (find (tracks.begin(), tracks.end(), track) == tracks.end()) { - void (Selection::*pmf)(TimeAxisView*) = &Selection::remove; - track->GoingAway.connect (sigc::bind (sigc::mem_fun (*this, pmf), track)); - tracks.push_back (track); - TracksChanged(); - } + TrackViewList tr; + tr.push_back (track); + add (tr); } void @@ -516,15 +513,14 @@ Selection::remove (TimeAxisView* track) } void -Selection::remove (const list& track_list) +Selection::remove (const TrackViewList& track_list) { bool changed = false; - for (list::const_iterator i = track_list.begin(); i != track_list.end(); ++i) { + for (TrackViewList::const_iterator i = track_list.begin(); i != track_list.end(); ++i) { - list::iterator x; - - if ((x = find (tracks.begin(), tracks.end(), (*i))) != tracks.end()) { + TrackViewList::iterator x = find (tracks.begin(), tracks.end(), *i); + if (x != tracks.end()) { tracks.erase (x); changed = true; } @@ -669,7 +665,7 @@ Selection::set (TimeAxisView* track) } void -Selection::set (const list& track_list) +Selection::set (const TrackViewList& track_list) { clear_tracks (); add (track_list); diff --git a/gtk2_ardour/selection.h b/gtk2_ardour/selection.h index 4e5f684af9..279b8df59b 100644 --- a/gtk2_ardour/selection.h +++ b/gtk2_ardour/selection.h @@ -82,7 +82,7 @@ class Selection : public sigc::trackable MidiRegionSelection midi_regions; MidiNoteSelection midi_notes; - Selection (PublicEditor const * e) : editor (e), next_time_id (0) { + Selection (PublicEditor const * e) : tracks (e), editor (e), next_time_id (0) { clear(); } @@ -112,7 +112,7 @@ class Selection : public sigc::trackable void toggle (std::list&); void set (TimeAxisView*); - void set (const std::list&); + void set (const TrackViewList&); void set (const MidiNoteSelection&); void set (RegionView*, bool also_clear_tracks = true); void set (MidiRegionView*); @@ -126,7 +126,7 @@ class Selection : public sigc::trackable void set (const RegionSelection&); void toggle (TimeAxisView*); - void toggle (const std::list&); + void toggle (const TrackViewList&); void toggle (const MidiNoteSelection&); void toggle (RegionView*); void toggle (MidiRegionView*); @@ -140,7 +140,7 @@ class Selection : public sigc::trackable void toggle (Marker*); void add (TimeAxisView*); - void add (const std::list&); + void add (const TrackViewList&); void add (const MidiNoteSelection&); void add (RegionView*); void add (MidiRegionView*); @@ -154,7 +154,7 @@ class Selection : public sigc::trackable void add (const std::list&); void add (const RegionSelection&); void remove (TimeAxisView*); - void remove (const std::list&); + void remove (const TrackViewList&); void remove (const MidiNoteSelection&); void remove (RegionView*); void remove (MidiRegionView*); diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index e5cd0c71bc..51dfb81ec0 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -424,8 +424,7 @@ TimeAxisView::set_height(uint32_t h) bool TimeAxisView::name_entry_key_release (GdkEventKey* ev) { - PublicEditor::TrackViewList *allviews = 0; - PublicEditor::TrackViewList::iterator i; + TrackViewList::iterator i; switch (ev->keyval) { case GDK_Escape: @@ -440,38 +439,40 @@ TimeAxisView::name_entry_key_release (GdkEventKey* ev) */ case GDK_ISO_Left_Tab: case GDK_Tab: + { name_entry_changed (); - allviews = _editor.get_valid_views (0); - if (allviews != 0) { - i = find (allviews->begin(), allviews->end(), this); - if (ev->keyval == GDK_Tab) { - if (i != allviews->end()) { - do { - if (++i == allviews->end()) { return true; } - } while((*i)->hidden()); - } - } else { - if (i != allviews->begin()) { - do { - if (i == allviews->begin()) { - return true; - } - --i; - } while ((*i)->hidden()); - } + TrackViewList const & allviews = _editor.get_track_views (); + TrackViewList::const_iterator i = find (allviews.begin(), allviews.end(), this); + if (ev->keyval == GDK_Tab) { + if (i != allviews.end()) { + do { + if (++i == allviews.end()) { + return true; + } + } while((*i)->hidden()); } - - - /* resize to show editable name display */ - - if ((*i)->current_height() <= hSmaller) { - (*i)->set_height (hSmaller); + } else { + if (i != allviews.begin()) { + do { + if (i == allviews.begin()) { + return true; + } + --i; + } while ((*i)->hidden()); } - - (*i)->name_entry.grab_focus(); } - return true; - + + + /* resize to show editable name display */ + + if ((*i)->current_height() <= hSmaller) { + (*i)->set_height (hSmaller); + } + + (*i)->name_entry.grab_focus(); + } + return true; + case GDK_Up: case GDK_Down: name_entry_changed (); diff --git a/gtk2_ardour/track_selection.cc b/gtk2_ardour/track_selection.cc index d9c7f02e19..9aa29bdb6d 100755 --- a/gtk2_ardour/track_selection.cc +++ b/gtk2_ardour/track_selection.cc @@ -1,31 +1,57 @@ +/* + Copyright (C) 2000-2009 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + #include +#include "ardour/route_group.h" #include "track_selection.h" +#include "time_axis_view.h" +#include "public_editor.h" using namespace std; -TrackSelection::TrackSelection (list const &t) - : list (t) +TrackSelection::TrackSelection (PublicEditor const * e, TrackViewList const &t) + : TrackViewList (t) + , _editor (e) { } -list -TrackSelection::add (list const & t) +TrackViewList +TrackSelection::add (TrackViewList const & t) { - list added; + TrackViewList added = TrackViewList::add (t); for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) { - if (!contains (*i)) { - added.push_back (*i); - push_back (*i); + + /* select anything in the same select-enabled route group */ + ARDOUR::RouteGroup* rg = (*i)->route_group (); + if (rg && rg->property (ARDOUR::RouteGroup::Select)) { + TrackViewList tr = _editor->axis_views_from_routes (rg->route_list ()); + for (TrackViewList::iterator j = tr.begin(); j != tr.end(); ++j) { + if (!contains (*j)) { + added.push_back (*j); + push_back (*j); + } + } } } return added; } -bool -TrackSelection::contains (TimeAxisView const * t) const -{ - return find (begin(), end(), t) != end(); -} diff --git a/gtk2_ardour/track_selection.h b/gtk2_ardour/track_selection.h index 38032d6de3..d39101f981 100644 --- a/gtk2_ardour/track_selection.h +++ b/gtk2_ardour/track_selection.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 Paul Davis + Copyright (C) 2000-2009 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,18 +20,20 @@ #ifndef __ardour_gtk_track_selection_h__ #define __ardour_gtk_track_selection_h__ -#include +#include "track_view_list.h" -class TimeAxisView; +class PublicEditor; -class TrackSelection : public std::list +class TrackSelection : public TrackViewList { public: - TrackSelection () {} + TrackSelection (PublicEditor const * e) : _editor (e) {} + TrackSelection (PublicEditor const *, TrackViewList const &); + + TrackViewList add (TrackViewList const &); - TrackSelection (std::list const &); - std::list add (std::list const &); - bool contains (TimeAxisView const *) const; +private: + PublicEditor const * _editor; }; #endif /* __ardour_gtk_track_selection_h__ */ diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 2807511937..6a3caef427 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -192,6 +192,7 @@ gtk2_ardour_sources = [ 'time_fx_dialog.cc', 'time_selection.cc', 'track_selection.cc', + 'track_view_list.cc', 'ui_config.cc', 'utils.cc', 'version.cc', diff --git a/libs/ardour/ardour/route_group.h b/libs/ardour/ardour/route_group.h index 996e8fee2f..bec9a7e8a9 100644 --- a/libs/ardour/ardour/route_group.h +++ b/libs/ardour/ardour/route_group.h @@ -125,7 +125,6 @@ public: void destroy_subgroup (); boost::shared_ptr route_list() { return routes; } - boost::shared_ptr route_list (Property forProperty); sigc::signal changed; sigc::signal FlagsChanged;