Audacity 3.2.0
Clipboard.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Clipboard.cpp
6
7*//*******************************************************************/
8
9#include "Clipboard.h"
10#include "BasicUI.h"
11#include "Track.h"
12
14: mTracks { TrackList::Create( nullptr ) }
15{
16}
17
18Clipboard::~Clipboard() = default;
19
21{
22 std::swap( mTracks, other.mTracks );
23 std::swap( mProject, other.mProject );
24 std::swap( mT0, other.mT0 );
25 std::swap( mT1, other.mT1 );
26}
27
29{
30 static Clipboard instance;
31 return instance;
32}
33
34//static
36{
37 return *mTracks;
38}
39
41{
42 mT0 = 0.0;
43 mT1 = 0.0;
44 mProject.reset();
45 mTracks->Clear();
46
47 if (this == &Get())
48 // Delayed message at idle time
49 // Don't need to capture a weak pointer to the global object
50 BasicUI::CallAfter([this]{ Publish({}); });
51}
52
53void Clipboard::Assign( TrackList && newContents,
54 double t0, double t1, const std::weak_ptr<AudacityProject> &pProject )
55{
56 newContents.Swap( *mTracks );
57 newContents.Clear();
58
59 mT0 = t0;
60 mT1 = t1;
61 mProject = pProject;
62
63 if (this == &Get())
64 // Delayed message at idle time
65 // Don't need to capture a weak pointer to the global object
66 BasicUI::CallAfter([this]{ Publish({}); });
67}
68
70{
72}
73
75{
76 Get().Swap(mTempClipboard);
77}
Toolkit-neutral facade for basic user interface services.
declares abstract base class Track, TrackList, and iterators over TrackList
void Assign(TrackList &&newContents, double t0, double t1, const std::weak_ptr< AudacityProject > &pProject)
Definition: Clipboard.cpp:53
static Clipboard & Get()
Definition: Clipboard.cpp:28
std::shared_ptr< TrackList > mTracks
Definition: Clipboard.h:57
std::weak_ptr< AudacityProject > mProject
Definition: Clipboard.h:58
void Swap(Clipboard &other)
Definition: Clipboard.cpp:20
void Clear()
Definition: Clipboard.cpp:40
const TrackList & GetTracks() const
Definition: Clipboard.cpp:35
double mT0
Definition: Clipboard.h:59
double mT1
Definition: Clipboard.h:60
CallbackReturn Publish(const ClipboardChangeMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1338
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:206
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:752
Clipboard mTempClipboard
Definition: Clipboard.h:68