tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_CollectionClip.cpp
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
14CollectionClip::CollectionClip (Track& t)
15 : TrackItem (t.edit, {}, Type::collection),
16 track (&t)
17{
18}
19
20CollectionClip::~CollectionClip()
21{
22 notifyListenersOfDeletion();
23}
24
25void CollectionClip::addClip (Clip* clip)
26{
27 if (! dragging)
28 {
29 jassert (clip != nullptr);
30 jassert (! clips.contains (clip));
31 jassert (! isGroupCollection() || (clip->getTrack() == nullptr || clip->getTrack() == getTrack()));
32
33 if (clip != nullptr)
34 clips.addIfNotAlreadyThere (clip);
35 }
36}
37
38void CollectionClip::removeClip (Clip* clip)
39{
40 if (! dragging)
41 while (clips.contains (clip))
42 clips.removeObject (clip);
43}
44
45bool CollectionClip::removeClip (EditItemID clipID)
46{
47 if (! dragging)
48 {
49 for (auto& c : clips)
50 {
51 if (c->itemID == clipID)
52 {
53 clips.removeObject (c);
54 return true;
55 }
56 }
57 }
58
59 return false;
60}
61
62bool CollectionClip::moveToTrack (Track& newTrack)
63{
64 auto to = dynamic_cast<ClipTrack*> (&newTrack);
65 auto from = dynamic_cast<ClipTrack*> (track);
66
67 if (to == nullptr || dynamic_cast<AudioTrack*> (to) == nullptr)
68 return false;
69
70 if (track != to && from != nullptr)
71 {
72 if (! to->isFrozen (Track::anyFreeze))
73 {
74 CollectionClip::Ptr refHolder (this);
75
76 from->removeCollectionClip (this);
77 track = to;
78 to->addCollectionClip (this);
79 }
80 }
81
82 return true;
83}
84
85FolderTrack* CollectionClip::getFolderTrack() const noexcept
86{
87 return dynamic_cast<FolderTrack*> (track);
88}
89
90void CollectionClip::updateStartAndEnd()
91{
92 if (! clips.isEmpty())
93 range = findUnionOfEditTimeRanges (clips);
94}
95
96juce::String CollectionClip::getName() const
97{
98 return TRANS("Collection Clip");
99}
100
101}} // namespace tracktion { inline namespace engine
#define TRANS(stringLiteral)
#define jassert(expression)
TimeRange findUnionOfEditTimeRanges(const ArrayType &items)
Returns the the time range that covers all the given TrackItems.