mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-03 07:33:49 +01:00
Enable snapping to selection/edit cursor
Makes item snap to selection start and end points. Also makes items snap to edit cursor, which follows selection start point. Signed-off-by: akleja <storspov@gmail.com> Reference-to: https://github.com/tenacityteam/tenacity/pull/387
This commit is contained in:
@@ -77,6 +77,9 @@ void SnapManager::Reinit()
|
|||||||
int snapTo = settings.GetSnapTo();
|
int snapTo = settings.GetSnapTo();
|
||||||
double rate = settings.GetRate();
|
double rate = settings.GetRate();
|
||||||
auto format = settings.GetSelectionFormat();
|
auto format = settings.GetSelectionFormat();
|
||||||
|
auto &viewInfo = ViewInfo::Get( *mProject );
|
||||||
|
const double t0 = viewInfo.selectedRegion.t0();
|
||||||
|
const double t1 = viewInfo.selectedRegion.t1();
|
||||||
|
|
||||||
// No need to reinit if these are still the same
|
// No need to reinit if these are still the same
|
||||||
if (snapTo == mSnapTo && rate == mRate && format == mFormat)
|
if (snapTo == mSnapTo && rate == mRate && format == mFormat)
|
||||||
@@ -105,6 +108,10 @@ void SnapManager::Reinit()
|
|||||||
// Add a SnapPoint at t=0
|
// Add a SnapPoint at t=0
|
||||||
mSnapPoints.push_back(SnapPoint{});
|
mSnapPoints.push_back(SnapPoint{});
|
||||||
|
|
||||||
|
// Add SnapPoints for selection start and end
|
||||||
|
mSnapPoints.push_back(SnapPoint{ t0 });
|
||||||
|
if (t0 != t1) mSnapPoints.push_back(SnapPoint{ t1 });
|
||||||
|
|
||||||
// Adjust and filter the candidate points
|
// Adjust and filter the candidate points
|
||||||
for (const auto &candidate : mCandidates)
|
for (const auto &candidate : mCandidates)
|
||||||
CondListAdd( candidate.t, candidate.track );
|
CondListAdd( candidate.t, candidate.track );
|
||||||
|
|||||||
Reference in New Issue
Block a user