diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 3b10d655e6..031262c41e 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -233,8 +233,8 @@ Editor::Editor () session = 0; - selection = new Selection; - cut_buffer = new Selection; + selection = new Selection (this); + cut_buffer = new Selection (this); selection->TimeChanged.connect (mem_fun(*this, &Editor::time_selection_changed)); selection->TracksChanged.connect (mem_fun(*this, &Editor::track_selection_changed)); @@ -2766,9 +2766,9 @@ Editor::map_transport_state () /* UNDO/REDO */ -Editor::State::State () +Editor::State::State (PublicEditor const * e) { - selection = new Selection; + selection = new Selection (e); } Editor::State::~State () @@ -2779,7 +2779,7 @@ Editor::State::~State () UndoAction Editor::get_memento () const { - State *state = new State; + State *state = new State (this); store_state (*state); return bind (mem_fun (*(const_cast(this)), &Editor::restore_state), state); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 2367f5a325..976ad68188 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -437,12 +437,12 @@ class Editor : public PublicEditor void sort_track_selection (); void get_relevant_tracks (std::set& relevant_tracks); - void get_equivalent_regions (RegionView* rv, std::vector&); - void mapover_tracks (sigc::slot sl, TimeAxisView*); + void get_equivalent_regions (RegionView* rv, std::vector&) const; + void mapover_tracks (sigc::slot sl, TimeAxisView*) const; /* functions to be passed to mapover_tracks(), possibly with sigc::bind()-supplied arguments */ - void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, vector*); + void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, vector*) const; void mapped_use_new_playlist (RouteTimeAxisView&, uint32_t); void mapped_use_copy_playlist (RouteTimeAxisView&, uint32_t); void mapped_clear_playlist (RouteTimeAxisView&, uint32_t); @@ -1681,10 +1681,10 @@ class Editor : public PublicEditor struct State { Selection* selection; - double frames_per_unit; + double frames_per_unit; - State(); - ~State(); + State (PublicEditor const * e); + ~State (); }; void store_state (State&) const; diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 304c2aae82..910534690e 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -293,7 +293,7 @@ Editor::get_relevant_tracks (set& relevant_tracks) */ void -Editor::mapover_tracks (slot sl, TimeAxisView* basis) +Editor::mapover_tracks (slot sl, TimeAxisView* basis) const { RouteTimeAxisView* route_basis = dynamic_cast (basis); if (route_basis == 0) { @@ -312,7 +312,7 @@ Editor::mapover_tracks (slot sl, TimeAxisVie if (group && group->is_active()) { /* the basis is a member of an active edit group; find other members */ - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) { RouteTimeAxisView* v = dynamic_cast (*i); if (v && v->route()->edit_group() == group) { tracks.insert (v); @@ -328,7 +328,7 @@ Editor::mapover_tracks (slot sl, TimeAxisVie } void -Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t ignored, RegionView* basis, vector* all_equivs) +Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t ignored, RegionView* basis, vector* all_equivs) const { boost::shared_ptr pl; vector > results; @@ -357,7 +357,7 @@ Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t ignored, } void -Editor::get_equivalent_regions (RegionView* basis, vector& equivalent_regions) +Editor::get_equivalent_regions (RegionView* basis, vector& equivalent_regions) const { mapover_tracks (bind (mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions), &basis->get_trackview()); @@ -437,9 +437,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, case Selection::Set: if (!clicked_regionview->get_selected()) { - - get_equivalent_regions (clicked_regionview, all_equivalent_regions); - selection->set (all_equivalent_regions); + selection->set (clicked_regionview); commit = true; } else { /* no commit necessary: clicked on an already selected region */ @@ -782,26 +780,6 @@ Editor::select_all_within (nframes_t start, nframes_t end, double top, double bo return false; } - /* `touched' may contain some regions; if so, we need to add equivalent - regions from any edit groups */ - - list to_add; - - for (list::iterator i = touched.begin(); i != touched.end(); ++i) { - RegionView* r = dynamic_cast (*i); - if (r) { - vector e; - get_equivalent_regions (r, e); - for (vector::iterator j = e.begin(); j != e.end(); ++j) { - to_add.push_back (*j); - } - } - } - - for (list::iterator i = to_add.begin(); i != to_add.end(); ++i) { - touched.push_back (*i); - } - if (!touched_tracks.empty()) { switch (op) { diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index a47f5b88d8..871ec0fb9c 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -262,6 +262,8 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway virtual TimeAxisView* get_named_time_axis(const std::string & name) = 0; #endif + virtual void get_equivalent_regions (RegionView* rv, std::vector&) const = 0; + sigc::signal ZoomFocusChanged; sigc::signal ZoomChanged; sigc::signal Resized; diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index b9c44bea13..f0037588a0 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -29,6 +29,7 @@ #include "selection_templates.h" #include "time_axis_view.h" #include "automation_time_axis.h" +#include "public_editor.h" #include "i18n.h" @@ -290,6 +291,7 @@ Selection::add (RegionView* r) { if (find (regions.begin(), regions.end(), r) == regions.end()) { regions.add (r); + select_edit_group_regions (); add (&r->get_trackview()); RegionsChanged (); } @@ -310,6 +312,7 @@ Selection::add (vector& v) } if (changed) { + select_edit_group_regions (); RegionsChanged (); } } @@ -679,3 +682,21 @@ Selection::add (vector& autos) PointsChanged (); } + +void +Selection::select_edit_group_regions () +{ + std::set regions_to_add; + + for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) { + vector e; + editor->get_equivalent_regions (*i, e); + for (vector::iterator j = e.begin(); j != e.end(); ++j) { + regions_to_add.insert(*j); + } + } + + for (std::set::iterator i = regions_to_add.begin(); i != regions_to_add.end(); ++i) { + add (*i); + } +} diff --git a/gtk2_ardour/selection.h b/gtk2_ardour/selection.h index a8f298434a..5e9bc04759 100644 --- a/gtk2_ardour/selection.h +++ b/gtk2_ardour/selection.h @@ -36,6 +36,7 @@ class TimeAxisView; class RegionView; class Selectable; +class PublicEditor; namespace ARDOUR { class Region; @@ -71,8 +72,7 @@ class Selection : public sigc::trackable PlaylistSelection playlists; PointSelection points; - Selection() { - next_time_id = 0; + Selection (PublicEditor const * e) : editor (e), next_time_id (0) { clear(); } @@ -149,7 +149,10 @@ class Selection : public sigc::trackable void foreach_regionview (void (RegionView::*method)(void)); template void foreach_region (void (ARDOUR::Region::*method)(A), A arg); + void select_edit_group_regions (); + private: + PublicEditor const * editor; uint32_t next_time_id; void add (std::vector&);