1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00

Pass project to TrackShifter factory, which LabelTrackShifter will need

This commit is contained in:
Paul Licameli 2020-09-19 21:13:45 -04:00
parent 14dc5af223
commit 637ce894c1
5 changed files with 14 additions and 12 deletions

View File

@ -627,10 +627,10 @@ void DoCursorClipBoundary
}
// This function returns the amount moved. Possibly 0.0.
double DoClipMove
( ViewInfo &viewInfo, Track *track,
double DoClipMove( AudacityProject &project, Track *track,
TrackList &trackList, bool syncLocked, bool right )
{
auto &viewInfo = ViewInfo::Get(project);
auto &selectedRegion = viewInfo.selectedRegion;
if (track) {
@ -642,7 +642,7 @@ double DoClipMove
// Find the first channel that has a clip at time t0
for (auto channel : TrackList::Channels(track) ) {
uShifter = MakeTrackShifter::Call( *track );
uShifter = MakeTrackShifter::Call( *track, project );
if( uShifter->HitTest( t0 ) == TrackShifter::HitTestResult::Miss )
uShifter.reset();
else
@ -653,7 +653,7 @@ double DoClipMove
return 0.0;
auto pShifter = uShifter.get();
state.Init( *track, std::move( uShifter ),
state.Init( project, *track, std::move( uShifter ),
t0, viewInfo, trackList, syncLocked );
auto desiredT0 = viewInfo.OffsetTimeByPixels( t0, ( right ? 1 : -1 ) );
@ -700,7 +700,7 @@ void DoClipLeftOrRight
auto &tracks = TrackList::Get( project );
auto isSyncLocked = settings.IsSyncLocked();
auto amount = DoClipMove( viewInfo, trackFocus.Get(),
auto amount = DoClipMove( project, trackFocus.Get(),
tracks, isSyncLocked, right );
window.ScrollIntoView(selectedRegion.t0());

View File

@ -760,7 +760,7 @@ private:
using MakeNoteTrackShifter = MakeTrackShifter::Override<NoteTrack>;
template<> template<> auto MakeNoteTrackShifter::Implementation() -> Function {
return [](NoteTrack &track) {
return [](NoteTrack &track, AudacityProject&) {
return std::make_unique<NoteTrackShifter>(track);
};
}

View File

@ -1458,7 +1458,7 @@ private:
using MakeWaveTrackShifter = MakeTrackShifter::Override<WaveTrack>;
template<> template<> auto MakeWaveTrackShifter::Implementation() -> Function {
return [](WaveTrack &track) {
return [](WaveTrack &track, AudacityProject&) {
return std::make_unique<WaveTrackShifter>(track);
};
}

View File

@ -252,12 +252,13 @@ bool CoarseTrackShifter::SyncLocks()
}
template<> auto MakeTrackShifter::Implementation() -> Function {
return [](Track &track) {
return [](Track &track, AudacityProject&) {
return std::make_unique<CoarseTrackShifter>(track);
};
}
void ClipMoveState::Init(
AudacityProject &project,
Track &capturedTrack,
std::unique_ptr<TrackShifter> pHit,
double clickTime,
@ -285,7 +286,7 @@ void ClipMoveState::Init(
for ( auto track : trackList.Any() ) {
auto &pShifter = state.shifters[track];
if (!pShifter)
pShifter = MakeTrackShifter::Call( *track );
pShifter = MakeTrackShifter::Call( *track, project );
}
// Analogy of the steps above, but with TrackShifters, follows below
@ -459,7 +460,7 @@ UIHandle::Result TimeShiftHandle::Click
bool captureClips = false;
auto pShifter = MakeTrackShifter::Call( *pTrack );
auto pShifter = MakeTrackShifter::Call( *pTrack, *pProject );
if (!event.ShiftDown()) {
TrackShifter::HitTestParams params{
@ -481,7 +482,7 @@ UIHandle::Result TimeShiftHandle::Click
// As in the default above: just do shifting of one whole track
}
mClipMoveState.Init( *pTrack,
mClipMoveState.Init( *pProject, *pTrack,
captureClips ? std::move( pShifter ) : nullptr,
clickTime,

View File

@ -183,7 +183,7 @@ private:
struct MakeTrackShifterTag;
using MakeTrackShifter = AttachedVirtualFunction<
MakeTrackShifterTag, std::unique_ptr<TrackShifter>, Track>;
MakeTrackShifterTag, std::unique_ptr<TrackShifter>, Track, AudacityProject&>;
class ViewInfo;
@ -192,6 +192,7 @@ struct ClipMoveState {
//! Will associate a TrackShifter with each track in the list
void Init(
AudacityProject &project,
Track &capturedTrack, //<! pHit if not null associates with this track
std::unique_ptr<TrackShifter> pHit, /*!<
If null, only capturedTrack (with any sister channels) shifts, as a whole */