summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Mueller <github@johannes-mueller.org>2017-07-23 20:07:17 +0200
committerRobin Gareus <robin@gareus.org>2017-07-25 17:39:08 +0200
commit9bfe404b4e9f5bc1bbe11b4ef6fd9778a362d04c (patch)
tree5b586087aa2d7d123d10bc0bdb61ddc76747e7ae
parent681ab5233097dbbf699c9ce6bcc0b76eaa8a59a3 (diff)
Fix #6280 – region (first_frame()==0) selectable with SnapRegionBoundary
Issue #6280 states that when selecting ranges using SnapToRegionBoundary it's not possible to select regions with first_frame() == 0. This is because Playlist::find_next_region() does not consider region boundaries == pos but only > pos. Thus it never considers pos == 0 to be a region boundary. This solution tries to be as little invasive as possible without changing the semantics of PlayList::find_next_region(). Therefore position 0 is added to the region boundary cache if there's a region starting at position 0 in any track.
-rw-r--r--gtk2_ardour/editor_ops.cc27
1 files changed, 21 insertions, 6 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index e23396eb89..f015cc8931 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -721,9 +721,12 @@ Editor::build_region_boundary_cache ()
return;
}
+ bool maybe_first_frame = false;
+
switch (_snap_type) {
case SnapToRegionStart:
interesting_points.push_back (Start);
+ maybe_first_frame = true;
break;
case SnapToRegionEnd:
interesting_points.push_back (End);
@@ -734,6 +737,7 @@ Editor::build_region_boundary_cache ()
case SnapToRegionBoundary:
interesting_points.push_back (Start);
interesting_points.push_back (End);
+ maybe_first_frame = true;
break;
default:
fatal << string_compose (_("build_region_boundary_cache called with snap_type = %1"), _snap_type) << endmsg;
@@ -750,6 +754,17 @@ Editor::build_region_boundary_cache ()
tlist = track_views.filter_to_unique_playlists ();
}
+ if (maybe_first_frame) {
+ TrackViewList::const_iterator i;
+ for (i = tlist.begin(); i != tlist.end(); ++i) {
+ boost::shared_ptr<Playlist> pl = (*i)->playlist();
+ if (pl && pl->count_regions_at (0)) {
+ region_boundary_cache.push_back (0);
+ break;
+ }
+ }
+ }
+
while (pos < _session->current_end_frame() && !at_end) {
framepos_t rpos;
@@ -1771,11 +1786,11 @@ Editor::temporal_zoom_step_scale (bool zoom_out, double scale)
nspp /= 2.0;
}
}
-
+
// ToDo: encapsulate all of this into something like editor::get_session_extents() or editor::leftmost(), rightmost()
{
//ToDo: also incorporate automation regions (in case the session has no audio/midi but is just used for automating plugins or the like)
-
+
//calculate the extents of all regions in every playlist
framecnt_t session_extent_start = 0;
framecnt_t session_extent_end = 0;
@@ -1799,23 +1814,23 @@ Editor::temporal_zoom_step_scale (bool zoom_out, double scale)
}
}
framecnt_t session_extents = session_extent_end - session_extent_start;
-
+
//in a session with no regions, use the start/end markers to set max zoom
framecnt_t const session_length = _session->current_end_frame() - _session->current_start_frame ();
if ( session_length > session_extents )
session_extents = session_length;
-
+
//in a session with no regions or start/end markers, use 2 minutes to set max zoom
framecnt_t const min_length = _session->nominal_frame_rate()*60*2;
if ( min_length > session_extents )
session_extents = min_length;
-
+
//convert to samples-per-pixel and limit our zoom to this value
framecnt_t session_extents_pp = session_extents / _visible_canvas_width;
if (nspp > session_extents_pp)
nspp = session_extents_pp;
}
-
+
temporal_zoom (nspp);
}