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
This commit is contained in:
Nick Mainsbridge 2008-02-03 08:32:18 +00:00
parent 58c2facb6a
commit affdf459a5
2 changed files with 18 additions and 14 deletions

View file

@ -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 {

View file

@ -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;