diff options
author | Carl Hetherington <carl@carlh.net> | 2009-06-25 20:58:32 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2009-06-25 20:58:32 +0000 |
commit | 498afeb63edeb8a5ce0103296ffda4216d64186d (patch) | |
tree | 1af722a4075a7df05a67c580a8e5c3d0fe09f1a6 | |
parent | 8e7a5d77414a40550a28d61abf6eeb1e89a1ec25 (diff) |
Various adjustments to make more operations respect the Edit property on route groups.
git-svn-id: svn://localhost/ardour2/branches/3.0@5273 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/editor.cc | 56 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 12 | ||||
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 10 | ||||
-rw-r--r-- | gtk2_ardour/editor_drag.h | 5 | ||||
-rw-r--r-- | gtk2_ardour/editor_mouse.cc | 30 | ||||
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 12 | ||||
-rw-r--r-- | gtk2_ardour/editor_selection.cc | 121 | ||||
-rw-r--r-- | gtk2_ardour/public_editor.h | 4 | ||||
-rw-r--r-- | gtk2_ardour/selection.cc | 19 | ||||
-rw-r--r-- | gtk2_ardour/selection.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/route_group.h | 2 |
11 files changed, 124 insertions, 149 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index d8cc3e524f..3a2239a755 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -4485,7 +4485,7 @@ Editor::restore_editing_space () /** * Make new playlists for a given track and also any others that belong - * to the same active edit group. + * to the same active route group with the `edit' property. * @param v Track. */ @@ -4495,13 +4495,13 @@ Editor::new_playlists (TimeAxisView* v) begin_reversible_command (_("new playlists")); vector<boost::shared_ptr<ARDOUR::Playlist> > playlists; session->get_playlists(playlists); - mapover_tracks ( bind(mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v ); + mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_new_playlist), playlists), v, RouteGroup::Edit); commit_reversible_command (); } /** * Use a copy of the current playlist for a given track and also any others that belong - * to the same active edit group. + * to the same active route group with the `edit' property. * @param v Track. */ @@ -4511,13 +4511,12 @@ Editor::copy_playlists (TimeAxisView* v) begin_reversible_command (_("copy playlists")); vector<boost::shared_ptr<ARDOUR::Playlist> > playlists; session->get_playlists(playlists); - mapover_tracks ( bind(mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v ); + mapover_tracks (bind (mem_fun (*this, &Editor::mapped_use_copy_playlist), playlists), v, RouteGroup::Edit); commit_reversible_command (); } -/** - * Clear the current playlist for a given track and also any others that belong - * to the same active edit group. +/** Clear the current playlist for a given track and also any others that belong + * to the same active route group with the `edit' property. * @param v Track. */ @@ -4527,7 +4526,7 @@ Editor::clear_playlists (TimeAxisView* v) begin_reversible_command (_("clear playlists")); vector<boost::shared_ptr<ARDOUR::Playlist> > playlists; session->get_playlists(playlists); - mapover_tracks ( mem_fun (*this, &Editor::mapped_clear_playlist), v ); + mapover_tracks (mem_fun (*this, &Editor::mapped_clear_playlist), v, RouteGroup::Edit); commit_reversible_command (); } @@ -5065,42 +5064,25 @@ Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSe void Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered) { - if (selection->regions.empty()) { - - /* no regions selected; get all regions at the edit point across: - - tracks in the region's route's edit group, if it has the edit property - - selected tracks - */ + rs = selection->regions; - if (entered_regionview) { - - rs.add (entered_regionview); - - TrackSelection tracks = selection->tracks; - - RouteGroup* g = entered_regionview->get_time_axis_view().route_group (); - if (g && g->active_property (RouteGroup::Edit)) { - tracks.add (axis_views_from_routes (g->route_list())); - } + if (allow_entered && entered_regionview) { + rs.add (entered_regionview); + } - nframes64_t const where = get_preferred_edit_position (); - get_regions_at (rs, where, tracks); - } - - } else { - - /* use the selected regions */ + TrackSelection tracks = selection->tracks; - rs = selection->regions; + RegionSelection to_map = rs; - /* if the entered regionview wasn't selected and we allow this sort of thing, - then add it. - */ + for (RegionSelection::iterator i = to_map.begin (); i != to_map.end(); ++i) { - if (allow_entered && entered_regionview && !selection->selected (entered_regionview)) { - rs.add (entered_regionview); + 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())); } + nframes64_t const where = get_preferred_edit_position (); + get_regions_at (rs, where, tracks); } } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index a174a21ca4..990f6f2136 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -53,6 +53,7 @@ #include "ardour/audioregion.h" #include "ardour/track.h" #include "ardour/types.h" +#include "ardour/route_group.h" #include "audio_clock.h" #include "gtk-custom-ruler.h" @@ -533,13 +534,15 @@ class Editor : public PublicEditor void sort_track_selection (TrackSelection* sel = 0); - void get_relevant_tracks (std::set<RouteTimeAxisView*>& relevant_tracks); - void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&) const; - void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*) const; + void get_relevant_tracks (std::set<RouteTimeAxisView*>& relevant_tracks) const; + void get_equivalent_tracks (RouteTimeAxisView*, std::set<RouteTimeAxisView*> &, ARDOUR::RouteGroup::Property) const; + void get_equivalent_regions (RegionView* rv, std::vector<RegionView*> &, ARDOUR::RouteGroup::Property) const; + RegionSelection get_equivalent_regions (RegionSelection &, ARDOUR::RouteGroup::Property) const; + void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, ARDOUR::RouteGroup::Property) const; /* functions to be passed to mapover_tracks(), possibly with sigc::bind()-supplied arguments */ - void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, std::vector<RegionView*>*) const; + void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView *, std::vector<RegionView*>*) const; void mapped_use_new_playlist (RouteTimeAxisView&, uint32_t, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &); void mapped_use_copy_playlist (RouteTimeAxisView&, uint32_t, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &); void mapped_clear_playlist (RouteTimeAxisView&, uint32_t); @@ -1145,7 +1148,6 @@ class Editor : public PublicEditor void lower_region (); void lower_region_to_bottom (); void split_region (); - void split_region_at (nframes64_t); void split_regions_at (nframes64_t, RegionSelection&); void split_region_at_transients (); void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 982f003c88..b1176d33e3 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -145,8 +145,6 @@ Drag::end_grab (GdkEvent* event) _editor->hide_verbose_canvas_cursor(); - update_selection (); - _ending = false; return _had_movement; @@ -253,14 +251,6 @@ RegionDrag::region_going_away (RegionView* v) _views.remove (v); } -void -RegionDrag::update_selection () -{ - list<Selectable*> s; - copy (_views.begin(), _views.end(), back_inserter (s)); - _editor->selection->set (s); -} - RegionMotionDrag::RegionMotionDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, list<RegionView*> const & v, bool b) : RegionDrag (e, i, p, v), _dest_trackview (0), diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 651f2becdd..b01ba78709 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -114,9 +114,6 @@ public: return true; } - /** Called when a subclass should update the editor's selection following a drag */ - virtual void update_selection () {} - protected: nframes64_t adjusted_current_frame (GdkEvent *) const; @@ -155,8 +152,6 @@ public: RegionDrag (Editor *, ArdourCanvas::Item *, RegionView *, std::list<RegionView*> const &); virtual ~RegionDrag () {} - void update_selection (); - protected: RegionView* _primary; ///< the view that was clicked on (or whatever) to start the drag diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index e9705f5e02..e132d794ed 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -820,16 +820,22 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp switch (item_type) { case FadeInHandleItem: + { assert (_drag == 0); - _drag = new FadeInDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), selection->regions); + RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit); + _drag = new FadeInDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), s); _drag->start_grab (event); return true; + } case FadeOutHandleItem: + { assert (_drag == 0); - _drag = new FadeOutDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), selection->regions); + RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit); + _drag = new FadeOutDrag (this, item, reinterpret_cast<RegionView*> (item->get_data("regionview")), s); _drag->start_grab (event); return true; + } case RegionItem: if (Keyboard::modifier_state_contains (event->button.state, Keyboard::CopyModifier)) { @@ -842,19 +848,25 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp break; case RegionViewNameHighlight: + { assert (_drag == 0); - _drag = new TrimDrag (this, item, clicked_regionview, selection->regions.by_layer()); + RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit); + _drag = new TrimDrag (this, item, clicked_regionview, s.by_layer()); _drag->start_grab (event); return true; break; + } case RegionViewName: + { /* rename happens on edit clicks */ assert (_drag == 0); - _drag = new TrimDrag (this, clicked_regionview->get_name_highlight(), clicked_regionview, selection->regions.by_layer()); + RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit); + _drag = new TrimDrag (this, clicked_regionview->get_name_highlight(), clicked_regionview, s.by_layer()); _drag->start_grab (event); return true; break; + } case ControlPointItem: assert (_drag == 0); @@ -2542,7 +2554,8 @@ Editor::start_region_grab (ArdourCanvas::Item* item, GdkEvent* event, RegionView if (Config->get_edit_mode() == Splice) { _drag = new RegionSpliceDrag (this, item, region_view, selection->regions.by_layer()); } else { - _drag = new RegionMoveDrag (this, item, region_view, selection->regions.by_layer(), false, false); + RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit); + _drag = new RegionMoveDrag (this, item, region_view, s.by_layer(), false, false); } _drag->start_grab (event); @@ -2560,7 +2573,9 @@ Editor::start_region_copy_grab (ArdourCanvas::Item* item, GdkEvent* event, Regio assert (_drag == 0); _region_motion_group->raise_to_top (); - _drag = new RegionMoveDrag (this, item, region_view, selection->regions.by_layer(), false, true); + + RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit); + _drag = new RegionMoveDrag (this, item, region_view, s.by_layer(), false, true); _drag->start_grab(event); } @@ -2574,7 +2589,8 @@ Editor::start_region_brush_grab (ArdourCanvas::Item* item, GdkEvent* event, Regi return; } - _drag = new RegionMoveDrag (this, item, region_view, selection->regions.by_layer(), true, false); + RegionSelection s = get_equivalent_regions (selection->regions, RouteGroup::Edit); + _drag = new RegionMoveDrag (this, item, region_view, s.by_layer(), true, false); _drag->start_grab (event); begin_reversible_command (_("Drag region brush")); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index d60e4aa199..61a103ead0 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -111,16 +111,10 @@ Editor::redo (uint32_t n) void Editor::split_region () { - split_region_at (get_preferred_edit_position()); -} - -void -Editor::split_region_at (nframes64_t where) -{ RegionSelection rs; - get_regions_for_action (rs); - split_regions_at (where, selection->regions); + get_regions_for_action (rs, true); + split_regions_at (get_preferred_edit_position (), selection->regions); } void @@ -5413,7 +5407,7 @@ Editor::split () { RegionSelection rs; - get_regions_for_action (rs); + get_regions_for_action (rs, true); nframes64_t where = get_preferred_edit_position(); diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index bb9a392c9c..7c70400e39 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -261,76 +261,66 @@ 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_relevant_tracks (set<RouteTimeAxisView*>& relevant_tracks) +Editor::get_equivalent_tracks (RouteTimeAxisView* basis, set<RouteTimeAxisView*> & equivs, RouteGroup::Property prop) const { - /* step one: get all selected tracks and all tracks in the relevant edit groups */ - - for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) { + equivs.insert (basis); - RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(*ti); + RouteGroup* group = basis->route()->route_group(); + if (group && group->active_property (prop)) { - if (!rtv) { - continue; + /* 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<RouteTimeAxisView*> (*i); + if (v && v->route()->route_group() == group) { + equivs.insert (v); + } } + } +} - RouteGroup* group = rtv->route()->route_group(); - - if (group && group->is_active()) { - - /* active group for this track, loop over all tracks and get every member of the group */ +/** 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. + */ - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - - RouteTimeAxisView* trtv; - - if ((trtv = dynamic_cast<RouteTimeAxisView*> (*i)) != 0) { - - if (trtv->route()->route_group() == group) { - relevant_tracks.insert (trtv); - } - } - } - } else { - relevant_tracks.insert (rtv); +void +Editor::get_relevant_tracks (set<RouteTimeAxisView*>& relevant_tracks) const +{ + for (TrackSelection::iterator ti = selection->tracks.begin(); ti != selection->tracks.end(); ++ti) { + RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*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 the `select' property. +/** 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. + * * @param sl Slot to call. * @param basis Basis track. + * @param prop Properties that active edit groups must share to be included in the map. */ void -Editor::mapover_tracks (slot<void, RouteTimeAxisView&, uint32_t> sl, TimeAxisView* basis) const +Editor::mapover_tracks (slot<void, RouteTimeAxisView&, uint32_t> sl, TimeAxisView* basis, RouteGroup::Property prop) const { RouteTimeAxisView* route_basis = dynamic_cast<RouteTimeAxisView*> (basis); if (route_basis == 0) { return; } - - /* work out the tracks that we will call the slot for; use - a set here as it will disallow possible duplicates of the - basis track */ + set<RouteTimeAxisView*> tracks; - - /* always call for the basis */ - tracks.insert (route_basis); - - RouteGroup* group = route_basis->route()->route_group(); - if (group && group->active_property (RouteGroup::Select)) { - - /* the basis is a member of an active edit group; find other members */ - for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) { - RouteTimeAxisView* v = dynamic_cast<RouteTimeAxisView*> (*i); - if (v && v->route()->route_group() == group) { - tracks.insert (v); - } - } - } + get_equivalent_tracks (route_basis, tracks, prop); /* call the slots */ uint32_t const sz = tracks.size (); @@ -340,7 +330,7 @@ Editor::mapover_tracks (slot<void, RouteTimeAxisView&, uint32_t> sl, TimeAxisVie } void -Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t ignored, RegionView* basis, vector<RegionView*>* all_equivs) const +Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t ignored, RegionView * basis, vector<RegionView*>* all_equivs) const { boost::shared_ptr<Playlist> pl; vector<boost::shared_ptr<Region> > results; @@ -369,15 +359,40 @@ Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t ignored, } void -Editor::get_equivalent_regions (RegionView* basis, vector<RegionView*>& equivalent_regions) const +Editor::get_equivalent_regions (RegionView* basis, vector<RegionView*>& equivalent_regions, RouteGroup::Property prop) const { - mapover_tracks (bind (mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions), &basis->get_trackview()); + mapover_tracks (bind (mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions), &basis->get_trackview(), prop); /* add clicked regionview since we skipped all other regions in the same track as the one it was in */ equivalent_regions.push_back (basis); } +RegionSelection +Editor::get_equivalent_regions (RegionSelection & basis, RouteGroup::Property prop) const +{ + RegionSelection equivalent; + + for (RegionSelection::const_iterator i = basis.begin(); i != basis.end(); ++i) { + + vector<RegionView*> eq; + + mapover_tracks ( + bind (mem_fun (*this, &Editor::mapped_get_equivalent_regions), *i, &eq), + &(*i)->get_trackview(), prop + ); + + for (vector<RegionView*>::iterator j = eq.begin(); j != eq.end(); ++j) { + equivalent.add (*j); + } + + equivalent.add (*i); + } + + return equivalent; +} + + int Editor::get_regionview_count_from_region_list (boost::shared_ptr<Region> region) { @@ -467,7 +482,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, if (press) { if (selection->selected (clicked_routeview)) { - get_equivalent_regions (clicked_regionview, all_equivalent_regions); + get_equivalent_regions (clicked_regionview, all_equivalent_regions, RouteGroup::Select); } else { all_equivalent_regions.push_back (clicked_regionview); } @@ -487,7 +502,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, case Selection::Set: if (!selection->selected (clicked_regionview)) { - get_equivalent_regions (clicked_regionview, all_equivalent_regions); + get_equivalent_regions (clicked_regionview, all_equivalent_regions, RouteGroup::Select); selection->set (all_equivalent_regions); commit = true; } else { diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index dbb845274c..6e020beb77 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -30,6 +30,8 @@ #include <jack/types.h> #include <sigc++/signal.h> +#include "ardour/route_group.h" + #include "pbd/statefuldestructible.h" #include "editing.h" @@ -273,7 +275,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway virtual RouteTimeAxisView* get_route_view_by_id (PBD::ID& id) = 0; - virtual void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&) const = 0; + virtual void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&, ARDOUR::RouteGroup::Property) const = 0; sigc::signal<void> ZoomFocusChanged; sigc::signal<void> ZoomChanged; diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index f1580fc07a..2eafcf220c 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -333,7 +333,6 @@ Selection::add (const RegionSelection& rs) } if (changed) { - select_edit_group_regions (); RegionsChanged (); } } @@ -743,24 +742,6 @@ Selection::add (vector<AutomationSelectable*>& autos) } void -Selection::select_edit_group_regions () -{ - std::set<RegionView*> regions_to_add; - - for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) { - vector<RegionView*> e; - editor->get_equivalent_regions (*i, e); - for (vector<RegionView*>::iterator j = e.begin(); j != e.end(); ++j) { - regions_to_add.insert(*j); - } - } - - for (std::set<RegionView*>::iterator i = regions_to_add.begin(); i != regions_to_add.end(); ++i) { - add (*i); - } -} - -void Selection::set (Marker* m) { clear_markers (); diff --git a/gtk2_ardour/selection.h b/gtk2_ardour/selection.h index f0af31eafe..6107e2970a 100644 --- a/gtk2_ardour/selection.h +++ b/gtk2_ardour/selection.h @@ -165,8 +165,6 @@ class Selection : public sigc::trackable void foreach_regionview (void (RegionView::*method)(void)); template<class A> void foreach_region (void (ARDOUR::Region::*method)(A), A arg); - void select_edit_group_regions (); - private: PublicEditor const * editor; uint32_t next_time_id; diff --git a/libs/ardour/ardour/route_group.h b/libs/ardour/ardour/route_group.h index a038551244..2ea7b95208 100644 --- a/libs/ardour/ardour/route_group.h +++ b/libs/ardour/ardour/route_group.h @@ -73,7 +73,7 @@ public: void set_hidden (bool yn, void *src); bool property (Property p) const { - return ((_properties & p) != 0); + return ((_properties & p) == p); } bool active_property (Property p) const { |