summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2007-10-07 15:51:14 +0000
committerCarl Hetherington <carl@carlh.net>2007-10-07 15:51:14 +0000
commit3f38e6b7f56ad85891d3669e0f1c58e6124b07f6 (patch)
tree49040369362473ad830907cbd524667d39d1703c /gtk2_ardour
parent49763a55c9bcbff2cb7844f36df777bbfadab172 (diff)
Re-work edit group selection in line with suggestions from Paul.
git-svn-id: svn://localhost/ardour2/trunk@2529 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc10
-rw-r--r--gtk2_ardour/editor.h12
-rw-r--r--gtk2_ardour/editor_selection.cc32
-rw-r--r--gtk2_ardour/public_editor.h2
-rw-r--r--gtk2_ardour/selection.cc21
-rw-r--r--gtk2_ardour/selection.h7
6 files changed, 44 insertions, 40 deletions
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<Editor*>(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<RouteTimeAxisView*>& relevant_tracks);
- void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&);
- void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*);
+ void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&) const;
+ void mapover_tracks (sigc::slot<void,RouteTimeAxisView&,uint32_t> 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<RegionView*>*);
+ void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, vector<RegionView*>*) 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<RouteTimeAxisView*>& relevant_tracks)
*/
void
-Editor::mapover_tracks (slot<void, RouteTimeAxisView&, uint32_t> sl, TimeAxisView* basis)
+Editor::mapover_tracks (slot<void, RouteTimeAxisView&, uint32_t> sl, TimeAxisView* basis) const
{
RouteTimeAxisView* route_basis = dynamic_cast<RouteTimeAxisView*> (basis);
if (route_basis == 0) {
@@ -312,7 +312,7 @@ Editor::mapover_tracks (slot<void, RouteTimeAxisView&, uint32_t> 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<RouteTimeAxisView*> (*i);
if (v && v->route()->edit_group() == group) {
tracks.insert (v);
@@ -328,7 +328,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)
+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;
@@ -357,7 +357,7 @@ Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t ignored,
}
void
-Editor::get_equivalent_regions (RegionView* basis, vector<RegionView*>& equivalent_regions)
+Editor::get_equivalent_regions (RegionView* basis, vector<RegionView*>& 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<Selectable*> to_add;
-
- for (list<Selectable*>::iterator i = touched.begin(); i != touched.end(); ++i) {
- RegionView* r = dynamic_cast<RegionView*> (*i);
- if (r) {
- vector<RegionView*> e;
- get_equivalent_regions (r, e);
- for (vector<RegionView*>::iterator j = e.begin(); j != e.end(); ++j) {
- to_add.push_back (*j);
- }
- }
- }
-
- for (list<Selectable*>::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<RegionView*>&) const = 0;
+
sigc::signal<void> ZoomFocusChanged;
sigc::signal<void> ZoomChanged;
sigc::signal<void> 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<RegionView*>& v)
}
if (changed) {
+ select_edit_group_regions ();
RegionsChanged ();
}
}
@@ -679,3 +682,21 @@ Selection::add (vector<AutomationSelectable*>& autos)
PointsChanged ();
}
+
+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);
+ }
+}
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<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;
void add (std::vector<AutomationSelectable*>&);