From affdf459a546237cca750a2a8d7a409556017d5c Mon Sep 17 00:00:00 2001 From: Nick Mainsbridge Date: Sun, 3 Feb 2008 08:32:18 +0000 Subject: [PATCH] Fix reversed bounds check in Region::adjust_to_sync (), regions with a sync point snap to the sync point again. git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2997 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_mouse.cc | 22 +++++++++++++--------- libs/ardour/region.cc | 10 +++++----- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index bcc00739ed..b293a28696 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -3297,23 +3297,27 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event) nframes_t sync_frame; nframes_t sync_offset; int32_t sync_dir; - + pending_region_position = drag_info.current_pointer_frame - drag_info.pointer_frame_offset; sync_offset = rv->region()->sync_offset (sync_dir); - sync_frame = rv->region()->adjust_to_sync (pending_region_position); - /* we snap if the snap modifier is not enabled. + /* we don't handle a sync point that lies before zero. */ + if (sync_dir > 0 || (sync_dir < 0 && pending_region_position >= sync_offset)) { + sync_frame = pending_region_position + (sync_dir*sync_offset); + + /* we snap if the snap modifier is not enabled. + */ - if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) { - snap_to (sync_frame); - } + if (!Keyboard::modifier_state_contains (event->button.state, Keyboard::snap_modifier())) { + snap_to (sync_frame); + } - if (sync_frame - sync_offset <= sync_frame) { - pending_region_position = sync_frame - (sync_dir*sync_offset); + pending_region_position = rv->region()->adjust_to_sync (sync_frame); + } else { - pending_region_position = 0; + pending_region_position = drag_info.last_frame_position; } } else { diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 6bbc4329eb..0819704bcf 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -764,15 +764,15 @@ Region::adjust_to_sync (nframes_t pos) // cerr << "adjusting pos = " << pos << " to sync at " << _sync_position << " offset = " << offset << " with dir = " << sync_dir << endl; if (sync_dir > 0) { - if (max_frames - pos > offset) { - pos -= offset; - } - } else { if (pos > offset) { - pos += offset; + pos -= offset; } else { pos = 0; } + } else { + if (max_frames - pos > offset) { + pos += offset; + } } return pos;