Mercurial > hg > svgui
changeset 414:fc19435ac0f5
* Improve snap policy for selecting regions
author | Chris Cannam |
---|---|
date | Mon, 22 Sep 2008 12:20:34 +0000 |
parents | f71752646f97 |
children | 31f222929319 |
files | layer/RegionLayer.cpp |
diffstat | 1 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/RegionLayer.cpp Fri Sep 19 14:05:34 2008 +0000 +++ b/layer/RegionLayer.cpp Mon Sep 22 12:20:34 2008 +0000 @@ -342,8 +342,8 @@ bool RegionLayer::snapToFeatureFrame(View *v, int &frame, - size_t &resolution, - SnapType snap) const + size_t &resolution, + SnapType snap) const { if (!m_model) { return Layer::snapToFeatureFrame(v, frame, resolution, snap); @@ -369,11 +369,22 @@ if (snap == SnapRight) { - if (i->frame > frame) { - snapped = i->frame; - found = true; - break; - } + // The best frame to snap to is the end frame of whichever + // feature we would have snapped to the start frame of if + // we had been snapping left. + + if (i->frame <= frame) { + if (i->frame + i->duration > frame) { + snapped = i->frame + i->duration; + found = true; // don't break, as the next may be better + } + } else { + if (!found) { + snapped = i->frame; + found = true; + } + break; + } } else if (snap == SnapLeft) {