Mercurial > hg > svgui
comparison layer/RegionLayer.cpp @ 414:fc19435ac0f5
* Improve snap policy for selecting regions
author | Chris Cannam |
---|---|
date | Mon, 22 Sep 2008 12:20:34 +0000 |
parents | f71752646f97 |
children | 31f222929319 |
comparison
equal
deleted
inserted
replaced
413:f71752646f97 | 414:fc19435ac0f5 |
---|---|
340 return text; | 340 return text; |
341 } | 341 } |
342 | 342 |
343 bool | 343 bool |
344 RegionLayer::snapToFeatureFrame(View *v, int &frame, | 344 RegionLayer::snapToFeatureFrame(View *v, int &frame, |
345 size_t &resolution, | 345 size_t &resolution, |
346 SnapType snap) const | 346 SnapType snap) const |
347 { | 347 { |
348 if (!m_model) { | 348 if (!m_model) { |
349 return Layer::snapToFeatureFrame(v, frame, resolution, snap); | 349 return Layer::snapToFeatureFrame(v, frame, resolution, snap); |
350 } | 350 } |
351 | 351 |
367 for (RegionModel::PointList::const_iterator i = points.begin(); | 367 for (RegionModel::PointList::const_iterator i = points.begin(); |
368 i != points.end(); ++i) { | 368 i != points.end(); ++i) { |
369 | 369 |
370 if (snap == SnapRight) { | 370 if (snap == SnapRight) { |
371 | 371 |
372 if (i->frame > frame) { | 372 // The best frame to snap to is the end frame of whichever |
373 snapped = i->frame; | 373 // feature we would have snapped to the start frame of if |
374 found = true; | 374 // we had been snapping left. |
375 break; | 375 |
376 } | 376 if (i->frame <= frame) { |
377 if (i->frame + i->duration > frame) { | |
378 snapped = i->frame + i->duration; | |
379 found = true; // don't break, as the next may be better | |
380 } | |
381 } else { | |
382 if (!found) { | |
383 snapped = i->frame; | |
384 found = true; | |
385 } | |
386 break; | |
387 } | |
377 | 388 |
378 } else if (snap == SnapLeft) { | 389 } else if (snap == SnapLeft) { |
379 | 390 |
380 if (i->frame <= frame) { | 391 if (i->frame <= frame) { |
381 snapped = i->frame; | 392 snapped = i->frame; |