summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_ops.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-07-21 19:55:12 +0000
committerCarl Hetherington <carl@carlh.net>2009-07-21 19:55:12 +0000
commit45564fa469148cf9e9e5af2ecaa43394cd92a341 (patch)
tree13636514e25f795d85dc4eda76197f88a09270d6 /gtk2_ardour/editor_ops.cc
parent965ffc3950c70dcf8fda8aa6b64666ee14b61bca (diff)
Clean up range menu a bit. Make a couple of range actions happen to all tracks if no tracks nor regions are selected. Stop involvement of the edit point in those same actions as it doesn't seem to make much sense.
git-svn-id: svn://localhost/ardour2/branches/3.0@5407 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_ops.cc')
-rw-r--r--gtk2_ardour/editor_ops.cc53
1 files changed, 35 insertions, 18 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 1ab7d74645..55382bbaca 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -2693,9 +2693,11 @@ 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 ();
+
nframes64_t selection_cnt = end - start + 1;
- for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
+ for (TrackSelection::iterator i = tracks.begin(); i != tracks.end(); ++i) {
boost::shared_ptr<Region> current;
boost::shared_ptr<Playlist> pl;
nframes64_t internal_start;
@@ -2786,41 +2788,52 @@ add_if_covered (RegionView* rv, const AudioRange* ar, RegionSelection* rs)
}
}
-void
-Editor::separate_regions_between (const TimeSelection& ts)
+/** Return either:
+ * - selected tracks, or if there are none...
+ * - tracks containing selected regions, or if there are none...
+ * - all tracks
+ * @return tracks.
+ */
+TrackSelection
+Editor::get_tracks_for_range_action () const
{
- bool in_command = false;
- boost::shared_ptr<Playlist> playlist;
- RegionSelection new_selection;
- TrackSelection tmptracks;
-
+ TrackSelection t;
+
if (selection->tracks.empty()) {
/* use tracks with selected regions */
- RegionSelection rs;
-
- get_regions_for_action (rs);
+ RegionSelection rs = selection->regions;
for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
TimeAxisView* tv = &(*i)->get_time_axis_view();
- if (find (tmptracks.begin(), tmptracks.end(), tv) == tmptracks.end()) {
- tmptracks.push_back (tv);
+ if (!t.contains (tv)) {
+ t.push_back (tv);
}
}
- if (tmptracks.empty()) {
- /* no regions selected: do nothing */
- return;
+ if (t.empty()) {
+ /* no regions and no tracks: use all tracks */
+ t = track_views;
}
} else {
- tmptracks = selection->tracks;
-
+ t = selection->tracks;
}
+ return t;
+}
+
+void
+Editor::separate_regions_between (const TimeSelection& ts)
+{
+ bool in_command = false;
+ boost::shared_ptr<Playlist> playlist;
+ RegionSelection new_selection;
+
+ TrackSelection tmptracks = get_tracks_for_range_action ();
sort_track_selection (&tmptracks);
for (TrackSelection::iterator i = tmptracks.begin(); i != tmptracks.end(); ++i) {
@@ -2895,6 +2908,10 @@ Editor::separate_regions_between (const TimeSelection& ts)
}
}
+/** Take tracks from get_tracks_for_range_action and cut any regions
+ * on those tracks so that the tracks are empty over the time
+ * selection.
+ */
void
Editor::separate_region_from_selection ()
{