Audacity 3.2.0
|
#include <PendingTracks.h>
Public Types | |
using | Updater = std::function< void(Track &dest, const Track &src)> |
Public Types inherited from Observer::Publisher< TrackListEvent > | |
using | message_type = TrackListEvent |
using | CallbackReturn = std::conditional_t< true, void, bool > |
using | Callback = std::function< CallbackReturn(const TrackListEvent &) > |
Type of functions that can be connected to the Publisher. More... | |
Public Member Functions | |
PendingTracks (AudacityProject &project) | |
PendingTracks (const PendingTracks &)=delete | |
PendingTracks & | operator= (const PendingTracks &)=delete |
~PendingTracks () | |
void | RegisterPendingNewTracks (TrackList &&list) |
Channel & | SubstitutePendingChangedChannel (Channel &channel) const |
const Channel & | SubstitutePendingChangedChannel (const Channel &channel) const |
Track & | SubstitutePendingChangedTrack (Track &track) const |
const Track & | SubstitutePendingChangedTrack (const Track &track) const |
const Channel & | SubstituteOriginalChannel (const Channel &channel) const |
const Track & | SubstituteOriginalTrack (const Track &track) const |
Track * | RegisterPendingChangedTrack (Updater updater, Track *src) |
Start a deferred update of the project. More... | |
void | UpdatePendingTracks () |
void | ClearPendingTracks (std::vector< std::shared_ptr< Track > > *pAdded=nullptr) |
Forget pending track additions and changes;. More... | |
bool | ApplyPendingTracks () |
Change the state of the project. More... | |
bool | HasPendingTracks () const |
Public Member Functions inherited from ClientData::Base | |
virtual | ~Base () |
Public Member Functions inherited from Observer::Publisher< TrackListEvent > | |
Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={}) | |
Constructor supporting type-erased custom allocation/deletion. More... | |
Publisher (Publisher &&)=default | |
Publisher & | operator= (Publisher &&)=default |
Subscription | Subscribe (Callback callback) |
Connect a callback to the Publisher; later-connected are called earlier. More... | |
Subscription | Subscribe (Object &obj, Return(Object::*callback)(Args...)) |
Overload of Subscribe takes an object and pointer-to-member-function. More... | |
Static Public Member Functions | |
static PendingTracks & | Get (AudacityProject &project) |
static const PendingTracks & | Get (const AudacityProject &project) |
Private Member Functions | |
std::pair< Track *, Channel * > | DoSubstitutePendingChangedChannel (Track &track, size_t channelIndex) const |
std::pair< const Track *, const Channel * > | DoSubstituteOriginalChannel (const Track &track, size_t channelIndex) const |
Private Attributes | |
TrackList & | mTracks |
Observer::Subscription | mTrackListSubscription |
std::vector< Updater > | mUpdaters |
std::shared_ptr< TrackList > | mPendingUpdates |
Additional Inherited Members | |
Static Public Attributes inherited from Observer::Publisher< TrackListEvent > | |
static constexpr bool | notifies_all |
Protected Member Functions inherited from Observer::Publisher< TrackListEvent > | |
CallbackReturn | Publish (const TrackListEvent &message) |
Send a message to connected callbacks. More... | |
Definition at line 23 of file PendingTracks.h.
using PendingTracks::Updater = std::function<void(Track &dest, const Track &src)> |
The tracks supplied to this function will have the same number of channels
Definition at line 67 of file PendingTracks.h.
|
explicit |
Definition at line 31 of file PendingTracks.cpp.
References TrackListEvent::ADDITION, TrackListEvent::DELETION, TrackListEvent::PERMUTED, Observer::Publisher< TrackListEvent >::Publish(), TrackListEvent::RESIZING, and UpdatePendingTracks().
|
delete |
|
default |
bool PendingTracks::ApplyPendingTracks | ( | ) |
Change the state of the project.
Strong guarantee for project state in case of exceptions. Will always clear the pending updates. Return true if the state of the track list really did change.
Definition at line 227 of file PendingTracks.cpp.
References TrackList::Add(), TrackList::begin(), ClearPendingTracks(), TrackList::end(), TrackList::FindById(), TrackList::GetOwner(), TrackList::Insert(), mPendingUpdates, mTracks, mUpdaters, TrackList::ReplaceOne(), TrackList::Temporary(), and UpdatePendingTracks().
Referenced by ProjectAudioManager::OnCommitRecording().
void PendingTracks::ClearPendingTracks | ( | std::vector< std::shared_ptr< Track > > * | pAdded = nullptr | ) |
Forget pending track additions and changes;.
if requested, give back the pending added tracks, as channel groups, stored in the vector at their original positions in iteration order and nulls corresponding with non-added tracks in original iteration order; no trailing nulls
Definition at line 197 of file PendingTracks.cpp.
References TrackList::Any(), details::end(), mPendingUpdates, mTracks, mUpdaters, and TrackList::Remove().
Referenced by ApplyPendingTracks(), ProjectAudioManager::CancelRecording(), and AudacityApp::OnExceptionInMainLoop().
|
private |
Definition at line 116 of file PendingTracks.cpp.
References TrackList::begin(), TrackList::end(), details::end(), Track::GetId(), id, mPendingUpdates, mTracks, and size.
Referenced by SubstituteOriginalChannel(), and SubstituteOriginalTrack().
|
private |
Definition at line 59 of file PendingTracks.cpp.
References details::end(), Track::GetId(), id, mPendingUpdates, and size.
Referenced by SubstitutePendingChangedChannel(), and SubstitutePendingChangedTrack().
|
static |
Definition at line 21 of file PendingTracks.cpp.
References project, and sPendingTracksKey.
Referenced by ProjectAudioManager::CancelRecording(), anonymous_namespace{UndoTracks.cpp}::TrackListRestorer::CanUndoOrRedo(), CloseButtonHandle::CommitChanges(), ProjectAudioManager::DoRecord(), TrackPanel::DrawTracks(), Get(), CommonChannelView::GetMinimizedHeight(), NoteTrackAffordanceControls::HitTest(), WaveTrackAffordanceControls::HitTest(), SyncLock::IsSyncLockSelected(), MixerBoard::MixerBoard(), ProjectAudioManager::OnCommitRecording(), AudacityApp::OnExceptionInMainLoop(), TrackPanel::ProcessUIHandleResult(), RealtimeEffectPanel::RealtimeEffectPanel(), TrackPanel::TrackPanel(), anonymous_namespace{ChannelView.cpp}::TrackPositioner::TrackPositioner(), Viewport::UpdateScrollbarsForTracks(), and ProjectFileIO::WriteXML().
|
static |
Definition at line 26 of file PendingTracks.cpp.
References Get(), and project.
bool PendingTracks::HasPendingTracks | ( | ) | const |
Definition at line 289 of file PendingTracks.cpp.
References TrackList::begin(), TrackList::end(), details::end(), mPendingUpdates, and mTracks.
Referenced by anonymous_namespace{UndoTracks.cpp}::TrackListRestorer::CanUndoOrRedo().
|
delete |
Start a deferred update of the project.
The return value is a duplicate of the given track. While ApplyPendingTracks or ClearPendingTracks is not yet called, there may be other direct changes to the project that push undo history. Meanwhile the returned object can accumulate other changes for a deferred push, and temporarily shadow the actual project track for display purposes. The Updater function, if not null, merges state (from the actual project into the pending track) which is not meant to be overridden by the accumulated pending changes. Pending track will have the same TrackId as the actual. Pending changed tracks will not occur in iterations.
Definition at line 168 of file PendingTracks.cpp.
References Track::Duplicate(), mPendingUpdates, mUpdaters, Track::DuplicateOptions::ShallowCopyAttachments(), and updater.
void PendingTracks::RegisterPendingNewTracks | ( | TrackList && | list | ) |
Like RegisterPendingChangedTrack, but for a list of new tracks, not a replacement track.
Caller supplies the list, and there are no updates. Pending tracks will have an unassigned TrackId. Pending new tracks WILL occur in iterations, always after actual tracks, and in the sequence that they were added. They can be distinguished from actual tracks because they have default TrackId.
Definition at line 53 of file PendingTracks.cpp.
References TrackList::Append(), and mTracks.
If the channel is in a pending changed track, return the corresponding original; else return the channel
Definition at line 150 of file PendingTracks.cpp.
References _, DoSubstituteOriginalChannel(), Channel::GetChannelGroup(), and Channel::GetChannelIndex().
Referenced by CommonChannelView::GetMinimizedHeight().
If the track is a pending changed track, return the corresponding original; else return the track
Definition at line 162 of file PendingTracks.cpp.
References _, and DoSubstituteOriginalChannel().
Referenced by SyncLock::IsSyncLockSelected().
Find anything registered with TrackList::RegisterPendingChangedTrack and not yet cleared or applied; if no such exists, return the given channel
Definition at line 87 of file PendingTracks.cpp.
References _, DoSubstitutePendingChangedChannel(), Channel::GetChannelGroup(), and Channel::GetChannelIndex().
Referenced by SubstitutePendingChangedChannel().
Definition at line 98 of file PendingTracks.cpp.
References SubstitutePendingChangedChannel().
Definition at line 109 of file PendingTracks.cpp.
References SubstitutePendingChangedTrack().
Find anything registered with TrackList::RegisterPendingChangedTrack and not yet cleared or applied; if no such exists, return the given track
Definition at line 103 of file PendingTracks.cpp.
References _, and DoSubstitutePendingChangedChannel().
Referenced by CloseButtonHandle::CommitChanges(), NoteTrackAffordanceControls::HitTest(), WaveTrackAffordanceControls::HitTest(), and SubstitutePendingChangedTrack().
void PendingTracks::UpdatePendingTracks | ( | ) |
Invoke the updaters of pending tracks. Pass any exceptions from the updater functions.
Definition at line 178 of file PendingTracks.cpp.
References TrackList::FindById(), mPendingUpdates, mTracks, mUpdaters, anonymous_namespace{LogWindow.cpp}::pUpdater, and updater.
Referenced by ApplyPendingTracks(), PendingTracks(), and TrackPanel::ProcessUIHandleResult().
|
private |
Definition at line 123 of file PendingTracks.h.
Referenced by ApplyPendingTracks(), ClearPendingTracks(), DoSubstituteOriginalChannel(), DoSubstitutePendingChangedChannel(), HasPendingTracks(), RegisterPendingChangedTrack(), and UpdatePendingTracks().
|
private |
Definition at line 121 of file PendingTracks.h.
|
private |
Definition at line 120 of file PendingTracks.h.
Referenced by ApplyPendingTracks(), ClearPendingTracks(), DoSubstituteOriginalChannel(), HasPendingTracks(), RegisterPendingNewTracks(), and UpdatePendingTracks().
|
private |
Definition at line 122 of file PendingTracks.h.
Referenced by ApplyPendingTracks(), ClearPendingTracks(), RegisterPendingChangedTrack(), and UpdatePendingTracks().