summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-10-23 22:28:27 +0000
committerCarl Hetherington <carl@carlh.net>2009-10-23 22:28:27 +0000
commit1f2a518ee20a9e011f75fa2d961fd14f018445c0 (patch)
tree2c7eb00fd61312d1159928347c9b69abe723a681 /gtk2_ardour
parentd2a11c8c02614c9cd9248fa17945923535110c98 (diff)
Clean up and simplify code to find marks before and after a position, and hence improve snap to markers so that both start and end positions of a range marker are taken into account.
git-svn-id: svn://localhost/ardour2/branches/3.0@5897 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc44
-rw-r--r--gtk2_ardour/editor_drag.cc5
-rw-r--r--gtk2_ardour/editor_markers.cc4
3 files changed, 18 insertions, 35 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 6d55327e45..72997a9ad0 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -2566,8 +2566,8 @@ Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
void
Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
{
- Location* before = 0;
- Location* after = 0;
+ nframes64_t before;
+ nframes64_t after;
const nframes64_t one_second = session->frame_rate();
const nframes64_t one_minute = session->frame_rate() * 60;
@@ -2682,39 +2682,21 @@ Editor::snap_to_internal (nframes64_t& start, int32_t direction, bool for_mark)
return;
}
- before = session->locations()->first_location_before (start);
- after = session->locations()->first_location_after (start);
+ session->locations()->marks_either_side (start, before, after);
- if (direction < 0) {
- if (before) {
- start = before->start();
+ if (before == max_frames) {
+ start = after;
+ } else if (after == max_frames) {
+ start = before;
+ } else if (before != max_frames && after != max_frames) {
+ /* have before and after */
+ if ((start - before) < (after - start)) {
+ start = before;
} else {
- start = 0;
- }
- } else if (direction > 0) {
- if (after) {
- start = after->start();
- } else {
- start = session->current_end_frame();
- }
- } else {
- if (before) {
- if (after) {
- /* find nearest of the two */
- if ((start - before->start()) < (after->start() - start)) {
- start = before->start();
- } else {
- start = after->start();
- }
- } else {
- start = before->start();
- }
- } else if (after) {
- start = after->start();
- } else {
- /* relax */
+ start = after;
}
}
+
break;
case SnapToRegionStart:
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index e6e944bc3b..81f210a901 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -3238,14 +3238,13 @@ RangeMarkerBarDrag::finished (GdkEvent* event, bool movement_occurred)
nframes64_t start;
nframes64_t end;
- start = _editor->session->locations()->first_mark_before (_grab_frame);
- end = _editor->session->locations()->first_mark_after (_grab_frame);
+ _editor->session->locations()->marks_either_side (_grab_frame, start, end);
if (end == max_frames) {
end = _editor->session->current_end_frame ();
}
- if (start == 0) {
+ if (start == max_frames) {
start = _editor->session->current_start_frame ();
}
diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc
index b95c29ee42..7bd09379d8 100644
--- a/gtk2_ardour/editor_markers.cc
+++ b/gtk2_ardour/editor_markers.cc
@@ -827,7 +827,9 @@ Editor::marker_menu_range_to_next ()
return;
}
- nframes_t end = session->locations()->first_mark_after (marker->position());
+ nframes64_t start;
+ nframes64_t end;
+ session->locations()->marks_either_side (marker->position(), start, end);
if (end != max_frames) {
string range_name = l->name();