lmms
Cross-platform music production software
Loading...
Searching...
No Matches
Clip.h
Go to the documentation of this file.
1/*
2 * TrackConteintObject.h - declaration of Clip class
3 *
4 * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_CLIP_H
26#define LMMS_CLIP_H
27
28#include <optional>
29
30#include <QColor>
31
32#include "AutomatableModel.h"
33
34
35namespace lmms
36{
37
38class Track;
39
40namespace gui
41{
42
43class ClipView;
44class TrackView;
45
46} // namespace gui
47
48
49class LMMS_EXPORT Clip : public Model, public JournallingObject
50{
51 Q_OBJECT
52 mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel);
53 mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel);
54public:
57 Clip(Track* track);
58 ~Clip() override;
59
60 inline Track * getTrack() const
61 {
62 return m_track;
63 }
64
65 inline const QString & name() const
66 {
67 return m_name;
68 }
69
70 inline void setName( const QString & name )
71 {
72 m_name = name;
73 emit dataChanged();
74 }
75
76 QString displayName() const override
77 {
78 return name();
79 }
80
81
82 inline const TimePos & startPosition() const
83 {
84 return m_startPosition;
85 }
86
87 inline TimePos endPosition() const
88 {
89 const int sp = m_startPosition;
90 return sp + m_length;
91 }
92
93 inline const TimePos & length() const
94 {
95 return m_length;
96 }
97
98
99 bool hasTrackContainer() const;
100
101 bool isInPattern() const;
102
103 bool manuallyResizable() const;
104
108 void setAutoResize(const bool r) { m_autoResize = r; }
109
110 bool getAutoResize() const
111 {
112 return m_autoResize;
113 }
114
115 auto color() const -> const std::optional<QColor>& { return m_color; }
116 void setColor(const std::optional<QColor>& color);
117
123 virtual void movePosition(const TimePos& pos);
124
130 virtual void changeLength(const TimePos& length);
131 virtual void updateLength() {};
132
134
135 inline void selectViewOnCreate( bool select )
136 {
137 m_selectViewOnCreate = select;
138 }
139
141 {
143 }
144
146 static bool comparePosition(const Clip* a, const Clip* b);
147
148 TimePos startTimeOffset() const;
149 virtual void setStartTimeOffset(const TimePos& startTimeOffset);
150
152 static void copyStateTo(Clip* src, Clip* dst);
153
156 virtual Clip* clone() = 0;
157
158public slots:
159 void toggleMute();
160
161signals:
166
167protected:
168
171 Clip(const Clip& other);
172
173private:
175 QString m_name;
176
180
183 bool m_autoResize = true;
184
186
187 std::optional<QColor> m_color;
188
189 friend class ClipView;
190};
191
192
193} // namespace lmms
194
195#endif // LMMS_CLIP_H
Definition AutomatableModel.h:502
Definition Clip.h:50
virtual Clip * clone()=0
Creates a copy of this clip.
friend class ClipView
Definition Clip.h:189
mapPropertyFromModel(bool, isMuted, setMuted, m_mutedModel)
TimePos m_startTimeOffset
Definition Clip.h:179
void toggleMute()
Mutes this Clip.
Definition Clip.cpp:154
BoolModel m_mutedModel
Definition Clip.h:181
QString m_name
Definition Clip.h:175
virtual gui::ClipView * createView(gui::TrackView *tv)=0
virtual void updateLength()
Definition Clip.h:131
void selectViewOnCreate(bool select)
Definition Clip.h:135
std::optional< QColor > m_color
Definition Clip.h:187
QString displayName() const override
Definition Clip.h:76
const QString & name() const
Definition Clip.h:65
void positionChanged()
void colorChanged()
bool m_autoResize
Definition Clip.h:183
const TimePos & startPosition() const
Definition Clip.h:82
auto color() const -> const std::optional< QColor > &
Definition Clip.h:115
void destroyedClip()
bool getSelectViewOnCreate()
Definition Clip.h:140
TimePos endPosition() const
Definition Clip.h:87
Track * m_track
Definition Clip.h:174
bool getAutoResize() const
Definition Clip.h:110
Track * getTrack() const
Definition Clip.h:60
bool m_selectViewOnCreate
Definition Clip.h:185
BoolModel m_soloModel
Definition Clip.h:182
Clip(Track *track)
Creates a new clip for the given track track.
Definition Clip.cpp:41
mapPropertyFromModel(bool, isSolo, setSolo, m_soloModel)
const TimePos & length() const
Definition Clip.h:93
TimePos m_startPosition
Definition Clip.h:177
void lengthChanged()
TimePos m_length
Definition Clip.h:178
void setAutoResize(const bool r)
Set whether a clip has been resized yet by the user or the knife tool.
Definition Clip.h:108
void setName(const QString &name)
Definition Clip.h:70
JournallingObject()
Definition JournallingObject.cpp:36
void dataChanged()
Model(Model *parent, QString displayName=QString(), bool defaultConstructed=false)
Definition Model.cpp:30
Definition TimePos.h:68
Base-class for all tracks.
Definition Track.h:67
Definition ClipView.h:52
Definition TrackView.h:60
Definition AudioPortAudio.cpp:209
Definition RemotePluginBase.cpp:34