mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
Eliminate some uses of ClipMoveState::capturedClip
This commit is contained in:
parent
4f159a7629
commit
5591e1da0a
@ -479,6 +479,23 @@ void ClipMoveState::Init(
|
||||
}
|
||||
}
|
||||
|
||||
const TrackInterval *ClipMoveState::CapturedInterval() const
|
||||
{
|
||||
auto pTrack = mCapturedTrack.get();
|
||||
if ( pTrack ) {
|
||||
auto iter = shifters.find( pTrack );
|
||||
if ( iter != shifters.end() ) {
|
||||
auto &pShifter = iter->second;
|
||||
if ( pShifter ) {
|
||||
auto &intervals = pShifter->MovingIntervals();
|
||||
if ( !intervals.empty() )
|
||||
return &intervals[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
double ClipMoveState::DoSlideHorizontal(
|
||||
double desiredSlideAmount, TrackList &trackList )
|
||||
{
|
||||
@ -629,10 +646,10 @@ UIHandle::Result TimeShiftHandle::Click
|
||||
kPixelTolerance);
|
||||
mClipMoveState.snapLeft = -1;
|
||||
mClipMoveState.snapRight = -1;
|
||||
mSnapPreferRightEdge =
|
||||
mClipMoveState.capturedClip &&
|
||||
(fabs(clickTime - mClipMoveState.capturedClip->GetEndTime()) <
|
||||
fabs(clickTime - mClipMoveState.capturedClip->GetStartTime()));
|
||||
auto pInterval = mClipMoveState.CapturedInterval();
|
||||
mSnapPreferRightEdge = pInterval &&
|
||||
(fabs(clickTime - pInterval->End()) <
|
||||
fabs(clickTime - pInterval->Start()));
|
||||
|
||||
return RefreshNone;
|
||||
}
|
||||
@ -661,11 +678,10 @@ namespace {
|
||||
|
||||
// Adjust desiredSlideAmount using SnapManager
|
||||
if (pSnapManager) {
|
||||
if (state.capturedClip) {
|
||||
clipLeft = state.capturedClip->GetStartTime()
|
||||
+ desiredSlideAmount;
|
||||
clipRight = state.capturedClip->GetEndTime()
|
||||
+ desiredSlideAmount;
|
||||
auto pInterval = state.CapturedInterval();
|
||||
if (pInterval) {
|
||||
clipLeft = pInterval->Start() + desiredSlideAmount;
|
||||
clipRight = pInterval->End() + desiredSlideAmount;
|
||||
}
|
||||
else {
|
||||
clipLeft = capturedTrack.GetStartTime() + desiredSlideAmount;
|
||||
|
@ -141,6 +141,10 @@ struct ClipMoveState {
|
||||
const ViewInfo &viewInfo,
|
||||
TrackList &trackList, bool syncLocked );
|
||||
|
||||
//! Return pointer to the first fixed interval of the captured track, if there is one
|
||||
/*! Pointer may be invalidated by operations on the associated TrackShifter */
|
||||
const TrackInterval *CapturedInterval() const;
|
||||
|
||||
/*! @return actual slide amount, maybe adjusted toward zero from desired */
|
||||
double DoSlideHorizontal( double desiredSlideAmount, TrackList &trackList );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user