LMMS
Loading...
Searching...
No Matches
ClipView.h
Go to the documentation of this file.
1/*
2 * ClipView.h - declaration of ClipView 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_GUI_CLIP_VIEW_H
26#define LMMS_GUI_CLIP_VIEW_H
27
28#include <optional>
29
30#include <QVector>
31
32#include "ModelView.h"
33#include "Rubberband.h"
34#include "Clip.h"
35
36
37class QMenu;
38
39namespace lmms
40{
41
42class DataFile;
43
44namespace gui
45{
46
47class TextFloat;
48class TrackView;
49
50
51class ClipView : public selectableObject, public ModelView
52{
53 Q_OBJECT
54
55// theming qproperties
66
67public:
68 const static int BORDER_WIDTH = 2;
69
70 ClipView( Clip * clip, TrackView * tv );
72
73 bool fixedClips();
74
75 inline Clip * getClip()
76 {
77 return m_clip;
78 }
79
81 {
82 return m_trackView;
83 }
84
85 // qproperty access func
86 QColor mutedColor() const;
87 QColor mutedBackgroundColor() const;
88 QColor selectedColor() const;
89 QColor selectedBlendColor() const;
90 QColor textColor() const;
91 QColor textBackgroundColor() const;
92 QColor textShadowColor() const;
93 QColor patternClipBackground() const;
94 QColor markerColor() const;
95 bool gradient() const;
96 void setMutedColor( const QColor & c );
97 void setMutedBackgroundColor( const QColor & c );
98 void setSelectedColor( const QColor & c );
99 void setSelectedBlendColor(const QColor& c);
100 void setTextColor( const QColor & c );
101 void setTextBackgroundColor( const QColor & c );
102 void setTextShadowColor( const QColor & c );
103 void setPatternClipBackground(const QColor& c);
104 void setGradient( const bool & b );
105 void setMarkerColor(const QColor& c);
106
107 // access needsUpdate member variable
108 bool needsUpdate();
109 void setNeedsUpdate( bool b );
110
111 // Method to get a QVector of Clips to be affected by a context menu action
112 QVector<ClipView *> getClickedClips();
113
114 // Methods to remove, copy, cut, paste and mute a QVector of Clip views
115 void copy( QVector<ClipView *> clipvs );
116 void cut( QVector<ClipView *> clipvs );
117 void paste();
118 // remove and toggleMute are static because they don't depend
119 // being called from a particular Clip view, but can be called anywhere as long
120 // as a valid Clip view list is given, while copy/cut require an instance for
121 // some metadata to be written to the clipboard.
122 static void remove( QVector<ClipView *> clipvs );
123 static void toggleMute( QVector<ClipView *> clipvs );
124
126
128 QColor getBlendedSelectedColor(QColor baseColor);
129
133 QColor getColor(QColor baseColor, bool ignoreMuted = false, bool ignoreEmpty = false, bool ignoreSelected = false);
134
138 QColor getColorForDisplay(QColor defaultColor);
139
140 void inline setMarkerPos(int x) { m_markerPos = x; }
141 void inline setMarkerEnabled(bool e) { m_marker = e; }
142
143public slots:
144 virtual bool close();
145 void remove();
146 void update() override;
147
148 void selectColor();
149 void randomizeColor();
150 void resetColor();
151
152protected:
161
165
166 bool m_marker = false;
167 int m_markerPos = 0;
168
169 virtual void constructContextMenu( QMenu * )
170 {
171 }
172
173 void contextMenuEvent( QContextMenuEvent * cme ) override;
175 void dragEnterEvent( QDragEnterEvent * dee ) override;
176 void dropEvent( QDropEvent * de ) override;
177 void mousePressEvent( QMouseEvent * me ) override;
178 void mouseMoveEvent( QMouseEvent * me ) override;
179 void mouseReleaseEvent( QMouseEvent * me ) override;
180 void resizeEvent( QResizeEvent * re ) override
181 {
182 m_needsUpdate = true;
183 selectableObject::resizeEvent( re );
184 }
185
186 bool unquantizedModHeld( QMouseEvent * me );
188
189 float pixelsPerBar() const;
190
191
192 DataFile createClipDataFiles(const QVector<ClipView *> & clips) const;
193
194 virtual void paintTextLabel(QString const & text, QPainter & painter);
195
196 auto hasCustomColor() const -> bool;
197
198protected slots:
199 void updateLength();
200 void updatePosition();
201
202
203private:
215
217
222 QVector<TimePos> m_initialOffsets;
223
225
226// qproperty fields
238
240 inline void setInitialPos( QPoint pos )
241 {
242 m_initialMousePos = pos;
243 m_initialMouseGlobalPos = mapToGlobal( pos );
244 m_initialClipPos = m_clip->startPosition();
246 }
247 void setInitialOffsets();
248
249 bool mouseMovedDistance( QMouseEvent * me, int distance );
250 TimePos draggedClipPos( QMouseEvent * me );
251 int knifeMarkerPos( QMouseEvent * me );
252 void setColor(const std::optional<QColor>& color);
253
259 int resizeGripWidth() const;
260
262 virtual bool isResizableBeforeStart() { return true; };
268 bool splitClip(const TimePos pos);
274 virtual bool destructiveSplitClip(const TimePos pos)
275 {
276 return splitClip(pos);
277 }
278 void updateCursor(QMouseEvent * me);
279} ;
280
281
282} // namespace gui
283
284} // namespace lmms
285
286#endif // LMMS_GUI_CLIP_VIEW_H
#define READ(addr)
Definition Ay_Cpu.cpp:92
#define WRITE(addr, data)
Definition Ay_Cpu.cpp:93
#define copy(x)
Definition ADnoteParameters.cpp:1011
#define override
Definition DistrhoDefines.h:73
Definition Clip.h:50
Definition DataFile.h:44
Definition TimePos.h:68
TrackView * getTrackView()
Definition ClipView.h:80
void setTextBackgroundColor(const QColor &c)
Definition ClipView.cpp:241
ContextMenuAction
Definition ClipView.h:154
@ Mute
Definition ClipView.h:159
@ Remove
Definition ClipView.h:155
@ Paste
Definition ClipView.h:158
@ Copy
Definition ClipView.h:157
@ Cut
Definition ClipView.h:156
void setMutedBackgroundColor(const QColor &c)
Definition ClipView.cpp:230
QVector< ClipView * > getClickedClips()
Definition ClipView.cpp:1190
void setPatternClipBackground(const QColor &c)
Definition ClipView.cpp:249
DataFile createClipDataFiles(const QVector< ClipView * > &clips) const
Create a DataFile suitable for copying multiple clips.
Definition ClipView.cpp:531
void setGradient(const bool &b)
Definition ClipView.cpp:252
float pixelsPerBar() const
How many pixels a bar takes for this ClipView.
Definition ClipView.cpp:1287
QColor mutedColor
Definition ClipView.h:56
void resizeEvent(QResizeEvent *re) override
Definition ClipView.h:180
int knifeMarkerPos(QMouseEvent *me)
Definition ClipView.cpp:1376
void dropEvent(QDropEvent *de) override
Handle something being dropped on this ClipObjectView.
Definition ClipView.cpp:451
QColor m_mutedColor
Definition ClipView.h:227
QColor m_textShadowColor
Definition ClipView.h:233
bool m_marker
Definition ClipView.h:166
bool m_needsUpdate
Definition ClipView.h:239
void updatePosition()
Updates a ClipView's position.
Definition ClipView.cpp:344
void toggleSelectedAutoResize()
Definition ClipView.cpp:1270
bool needsUpdate()
Definition ClipView.cpp:259
QColor m_textBackgroundColor
Definition ClipView.h:232
virtual bool isResizableBeforeStart()
Returns whether the user can left-resize this clip so that the start of the clip bounds is before the...
Definition ClipView.h:262
void mousePressEvent(QMouseEvent *me) override
Handle a mouse press on this ClipView.
Definition ClipView.cpp:627
void paste()
Definition ClipView.cpp:1244
void setInitialOffsets()
Save the offsets between all selected tracks and a clicked track.
Definition ClipView.cpp:1294
bool unquantizedModHeld(QMouseEvent *me)
Definition ClipView.cpp:1329
virtual bool close()
Close a ClipView.
Definition ClipView.cpp:271
void dragEnterEvent(QDragEnterEvent *dee) override
Change the ClipView's display when something being dragged enters it.
Definition ClipView.cpp:423
static const int BORDER_WIDTH
Definition ClipView.h:68
QPoint m_initialMouseGlobalPos
Definition ClipView.h:221
void setTextColor(const QColor &c)
Definition ClipView.cpp:238
void cut(QVector< ClipView * > clipvs)
Definition ClipView.cpp:1235
void setNeedsUpdate(bool b)
Definition ClipView.cpp:261
bool fixedClips()
Does this ClipView have a fixed Clip?
Definition ClipView.cpp:186
QColor m_mutedBackgroundColor
Definition ClipView.h:228
void setTextShadowColor(const QColor &c)
Definition ClipView.cpp:246
QVector< TimePos > m_initialOffsets
Definition ClipView.h:222
TimePos draggedClipPos(QMouseEvent *me)
Calculate the new position of a dragged Clip from a mouse event.
Definition ClipView.cpp:1342
QColor getBlendedSelectedColor(QColor baseColor)
Blend the selected "color mask" into a specific color.
Definition ClipView.cpp:1414
void setInitialPos(QPoint pos)
Definition ClipView.h:240
void contextMenuAction(ContextMenuAction action)
Definition ClipView.cpp:1165
void selectColor()
Definition ClipView.cpp:352
bool mouseMovedDistance(QMouseEvent *me, int distance)
Detect whether the mouse moved more than n pixels on screen.
Definition ClipView.cpp:1319
ClipView(Clip *clip, TrackView *tv)
Create a new ClipView.
Definition ClipView.cpp:82
QColor m_textColor
Definition ClipView.h:231
void remove()
Removes a ClipView from its track view.
Definition ClipView.cpp:287
void setMarkerPos(int x)
Definition ClipView.h:140
QColor m_selectedBlendColor
Definition ClipView.h:230
int m_markerPos
Definition ClipView.h:167
QPoint m_initialMousePos
Definition ClipView.h:220
TimePos m_initialClipPos
Definition ClipView.h:163
QColor getColorForDisplay(QColor defaultColor)
Calculate the "final" primary color for this clip.
Definition ClipView.cpp:1443
bool splitClip(const TimePos pos)
Definition ClipView.cpp:1454
Clip * getClip()
Definition ClipView.h:75
void resetColor()
Definition ClipView.cpp:366
void setColor(const std::optional< QColor > &color)
Change color of all selected clips.
Definition ClipView.cpp:375
static TextFloat * s_textFloat
Definition ClipView.h:216
void setSelectedColor(const QColor &c)
Definition ClipView.cpp:233
QColor getColor(QColor baseColor, bool ignoreMuted=false, bool ignoreEmpty=false, bool ignoreSelected=false)
Calculate the "final" version of a specific color.
Definition ClipView.cpp:1429
QColor markerColor
Definition ClipView.h:65
QColor m_selectedColor
Definition ClipView.h:229
bool gradient
Definition ClipView.h:64
bool m_gradient
Definition ClipView.h:235
void setMutedColor(const QColor &c)
CSS theming qproperty access method.
Definition ClipView.cpp:227
TimePos quantizeSplitPos(TimePos)
Definition ClipView.cpp:1398
bool m_keyDPressed
Definition ClipView.h:236
QColor textShadowColor
Definition ClipView.h:62
int resizeGripWidth() const
Definition ClipView.cpp:407
Clip * m_clip
Definition ClipView.h:218
QColor m_patternClipBackground
Definition ClipView.h:234
TimePos m_initialClipEnd
Definition ClipView.h:164
QColor textColor
Definition ClipView.h:60
Action
Definition ClipView.h:205
@ ToggleSelected
Definition ClipView.h:213
@ MoveSelection
Definition ClipView.h:208
@ Move
Definition ClipView.h:207
@ Split
Definition ClipView.h:211
@ Resize
Definition ClipView.h:209
@ ResizeLeft
Definition ClipView.h:210
@ CopySelection
Definition ClipView.h:212
void contextMenuEvent(QContextMenuEvent *cme) override
Set up the context menu for this ClipView.
Definition ClipView.cpp:1083
QColor selectedBlendColor
Definition ClipView.h:58
void setMarkerColor(const QColor &c)
Definition ClipView.cpp:255
QColor selectedColor
Definition ClipView.h:59
void mouseMoveEvent(QMouseEvent *me) override
Handle a mouse movement (drag) on this ClipView.
Definition ClipView.cpp:805
TextFloat * m_hint
Definition ClipView.h:224
void mouseReleaseEvent(QMouseEvent *me) override
Handle a mouse release on this ClipView.
Definition ClipView.cpp:1034
auto hasCustomColor() const -> bool
Definition ClipView.cpp:1449
QColor m_markerColor
Definition ClipView.h:237
Action m_action
Definition ClipView.h:219
void randomizeColor()
Definition ClipView.cpp:361
QColor patternClipBackground
Definition ClipView.h:63
void updateLength()
Updates a ClipView's length.
Definition ClipView.cpp:319
void update() override
Update a ClipView.
Definition ClipView.cpp:167
QColor mutedBackgroundColor
Definition ClipView.h:57
virtual bool destructiveSplitClip(const TimePos pos)
Definition ClipView.h:274
TrackView * m_trackView
Definition ClipView.h:162
virtual void constructContextMenu(QMenu *)
Definition ClipView.h:169
virtual void paintTextLabel(QString const &text, QPainter &painter)
Definition ClipView.cpp:578
static void toggleMute(QVector< ClipView * > clipvs)
Definition ClipView.cpp:1261
void setMarkerEnabled(bool e)
Definition ClipView.h:141
void updateCursor(QMouseEvent *me)
Definition ClipView.cpp:500
void setSelectedBlendColor(const QColor &c)
Definition ClipView.cpp:236
QColor textBackgroundColor
Definition ClipView.h:61
ModelView(Model *model, QWidget *widget)
Definition ModelView.cpp:33
Definition TextFloat.h:38
Definition TrackView.h:60
selectableObject(QWidget *_parent)
Definition Rubberband.h:40
* e
Definition inflate.c:1404
unsigned x[BMAX+1]
Definition inflate.c:1586
Definition AudioPortAudio.cpp:209
Definition AudioAlsa.cpp:35
const char * text
Definition swell-functions.h:167
return c
Definition crypt.c:175
b
Definition crypt.c:628
static ZCONST char Far None[]
Definition unzip.c:380
#define const
Definition zconf.h:137