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
65
66public:
67 const static int BORDER_WIDTH = 2;
68
69 ClipView( Clip * clip, TrackView * tv );
71
72 bool fixedClips();
73
74 inline Clip * getClip()
75 {
76 return m_clip;
77 }
78
80 {
81 return m_trackView;
82 }
83
84 // qproperty access func
85 QColor mutedColor() const;
86 QColor mutedBackgroundColor() const;
87 QColor selectedColor() const;
88 QColor textColor() const;
89 QColor textBackgroundColor() const;
90 QColor textShadowColor() const;
91 QColor patternClipBackground() const;
92 QColor markerColor() const;
93 bool gradient() const;
94 void setMutedColor( const QColor & c );
95 void setMutedBackgroundColor( const QColor & c );
96 void setSelectedColor( const QColor & c );
97 void setTextColor( const QColor & c );
98 void setTextBackgroundColor( const QColor & c );
99 void setTextShadowColor( const QColor & c );
100 void setPatternClipBackground(const QColor& c);
101 void setGradient( const bool & b );
102 void setMarkerColor(const QColor& c);
103
104 // access needsUpdate member variable
105 bool needsUpdate();
106 void setNeedsUpdate( bool b );
107
108 // Method to get a QVector of Clips to be affected by a context menu action
109 QVector<ClipView *> getClickedClips();
110
111 // Methods to remove, copy, cut, paste and mute a QVector of Clip views
112 void copy( QVector<ClipView *> clipvs );
113 void cut( QVector<ClipView *> clipvs );
114 void paste();
115 // remove and toggleMute are static because they don't depend
116 // being called from a particular Clip view, but can be called anywhere as long
117 // as a valid Clip view list is given, while copy/cut require an instance for
118 // some metadata to be written to the clipboard.
119 static void remove( QVector<ClipView *> clipvs );
120 static void toggleMute( QVector<ClipView *> clipvs );
121
123
124 QColor getColorForDisplay( QColor );
125
126 void inline setMarkerPos(int x) { m_markerPos = x; }
127 void inline setMarkerEnabled(bool e) { m_marker = e; }
128
129public slots:
130 virtual bool close();
131 void remove();
132 void update() override;
133
134 void selectColor();
135 void randomizeColor();
136 void resetColor();
137
138protected:
147
151
152 bool m_marker = false;
153 int m_markerPos = 0;
154
155 virtual void constructContextMenu( QMenu * )
156 {
157 }
158
159 void contextMenuEvent( QContextMenuEvent * cme ) override;
161 void dragEnterEvent( QDragEnterEvent * dee ) override;
162 void dropEvent( QDropEvent * de ) override;
163 void mousePressEvent( QMouseEvent * me ) override;
164 void mouseMoveEvent( QMouseEvent * me ) override;
165 void mouseReleaseEvent( QMouseEvent * me ) override;
166 void resizeEvent( QResizeEvent * re ) override
167 {
168 m_needsUpdate = true;
169 selectableObject::resizeEvent( re );
170 }
171
172 bool unquantizedModHeld( QMouseEvent * me );
174
175 float pixelsPerBar();
176
177
178 DataFile createClipDataFiles(const QVector<ClipView *> & clips) const;
179
180 virtual void paintTextLabel(QString const & text, QPainter & painter);
181
182 auto hasCustomColor() const -> bool;
183
184protected slots:
185 void updateLength();
186 void updatePosition();
187
188
189private:
201
203
208 QVector<TimePos> m_initialOffsets;
209
211
212// qproperty fields
222
224 inline void setInitialPos( QPoint pos )
225 {
226 m_initialMousePos = pos;
227 m_initialMouseGlobalPos = mapToGlobal( pos );
228 m_initialClipPos = m_clip->startPosition();
230 }
231 void setInitialOffsets();
232
233 bool mouseMovedDistance( QMouseEvent * me, int distance );
234 TimePos draggedClipPos( QMouseEvent * me );
235 int knifeMarkerPos( QMouseEvent * me );
236 void setColor(const std::optional<QColor>& color);
237
239 virtual bool isResizableBeforeStart() { return true; };
245 bool splitClip(const TimePos pos);
251 virtual bool destructiveSplitClip(const TimePos pos)
252 {
253 return splitClip(pos);
254 }
255 void updateCursor(QMouseEvent * me);
256} ;
257
258
259} // namespace gui
260
261} // namespace lmms
262
263#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:79
void setTextBackgroundColor(const QColor &c)
Definition ClipView.cpp:235
ContextMenuAction
Definition ClipView.h:140
@ Mute
Definition ClipView.h:145
@ Remove
Definition ClipView.h:141
@ Paste
Definition ClipView.h:144
@ Copy
Definition ClipView.h:143
@ Cut
Definition ClipView.h:142
void setMutedBackgroundColor(const QColor &c)
Definition ClipView.cpp:226
QVector< ClipView * > getClickedClips()
Definition ClipView.cpp:1161
void setPatternClipBackground(const QColor &c)
Definition ClipView.cpp:243
DataFile createClipDataFiles(const QVector< ClipView * > &clips) const
Create a DataFile suitable for copying multiple clips.
Definition ClipView.cpp:516
void setGradient(const bool &b)
Definition ClipView.cpp:246
QColor mutedColor
Definition ClipView.h:56
void resizeEvent(QResizeEvent *re) override
Definition ClipView.h:166
int knifeMarkerPos(QMouseEvent *me)
Definition ClipView.cpp:1347
void dropEvent(QDropEvent *de) override
Handle something being dropped on this ClipObjectView.
Definition ClipView.cpp:436
QColor m_mutedColor
Definition ClipView.h:213
QColor m_textShadowColor
Definition ClipView.h:218
bool m_marker
Definition ClipView.h:152
bool m_needsUpdate
Definition ClipView.h:223
void updatePosition()
Updates a ClipView's position.
Definition ClipView.cpp:338
void toggleSelectedAutoResize()
Definition ClipView.cpp:1241
bool needsUpdate()
Definition ClipView.cpp:253
QColor m_textBackgroundColor
Definition ClipView.h:217
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:239
void mousePressEvent(QMouseEvent *me) override
Handle a mouse press on this ClipView.
Definition ClipView.cpp:611
void paste()
Definition ClipView.cpp:1215
void setInitialOffsets()
Save the offsets between all selected tracks and a clicked track.
Definition ClipView.cpp:1265
bool unquantizedModHeld(QMouseEvent *me)
Definition ClipView.cpp:1300
virtual bool close()
Close a ClipView.
Definition ClipView.cpp:265
void dragEnterEvent(QDragEnterEvent *dee) override
Change the ClipView's display when something being dragged enters it.
Definition ClipView.cpp:408
static const int BORDER_WIDTH
Definition ClipView.h:67
QPoint m_initialMouseGlobalPos
Definition ClipView.h:207
void setTextColor(const QColor &c)
Definition ClipView.cpp:232
void cut(QVector< ClipView * > clipvs)
Definition ClipView.cpp:1206
void setNeedsUpdate(bool b)
Definition ClipView.cpp:255
bool fixedClips()
Does this ClipView have a fixed Clip?
Definition ClipView.cpp:184
QColor m_mutedBackgroundColor
Definition ClipView.h:214
void setTextShadowColor(const QColor &c)
Definition ClipView.cpp:240
QVector< TimePos > m_initialOffsets
Definition ClipView.h:208
QColor getColorForDisplay(QColor)
Definition ClipView.cpp:1389
TimePos draggedClipPos(QMouseEvent *me)
Calculate the new position of a dragged Clip from a mouse event.
Definition ClipView.cpp:1313
void setInitialPos(QPoint pos)
Definition ClipView.h:224
void contextMenuAction(ContextMenuAction action)
Definition ClipView.cpp:1136
void selectColor()
Definition ClipView.cpp:346
bool mouseMovedDistance(QMouseEvent *me, int distance)
Detect whether the mouse moved more than n pixels on screen.
Definition ClipView.cpp:1290
ClipView(Clip *clip, TrackView *tv)
Create a new ClipView.
Definition ClipView.cpp:80
QColor m_textColor
Definition ClipView.h:216
void remove()
Removes a ClipView from its track view.
Definition ClipView.cpp:281
void setMarkerPos(int x)
Definition ClipView.h:126
int m_markerPos
Definition ClipView.h:153
QPoint m_initialMousePos
Definition ClipView.h:206
TimePos m_initialClipPos
Definition ClipView.h:149
bool splitClip(const TimePos pos)
Definition ClipView.cpp:1432
Clip * getClip()
Definition ClipView.h:74
void resetColor()
Definition ClipView.cpp:360
void setColor(const std::optional< QColor > &color)
Change color of all selected clips.
Definition ClipView.cpp:369
static TextFloat * s_textFloat
Definition ClipView.h:202
void setSelectedColor(const QColor &c)
Definition ClipView.cpp:229
QColor markerColor
Definition ClipView.h:64
QColor m_selectedColor
Definition ClipView.h:215
bool gradient
Definition ClipView.h:63
bool m_gradient
Definition ClipView.h:220
void setMutedColor(const QColor &c)
CSS theming qproperty access method.
Definition ClipView.cpp:223
TimePos quantizeSplitPos(TimePos)
Definition ClipView.cpp:1369
QColor textShadowColor
Definition ClipView.h:61
Clip * m_clip
Definition ClipView.h:204
QColor m_patternClipBackground
Definition ClipView.h:219
TimePos m_initialClipEnd
Definition ClipView.h:150
QColor textColor
Definition ClipView.h:59
Action
Definition ClipView.h:191
@ ToggleSelected
Definition ClipView.h:199
@ MoveSelection
Definition ClipView.h:194
@ Move
Definition ClipView.h:193
@ Split
Definition ClipView.h:197
@ Resize
Definition ClipView.h:195
@ ResizeLeft
Definition ClipView.h:196
@ CopySelection
Definition ClipView.h:198
void contextMenuEvent(QContextMenuEvent *cme) override
Set up the context menu for this ClipView.
Definition ClipView.cpp:1060
void setMarkerColor(const QColor &c)
Definition ClipView.cpp:249
QColor selectedColor
Definition ClipView.h:58
void mouseMoveEvent(QMouseEvent *me) override
Handle a mouse movement (drag) on this ClipView.
Definition ClipView.cpp:782
TextFloat * m_hint
Definition ClipView.h:210
void mouseReleaseEvent(QMouseEvent *me) override
Handle a mouse release on this ClipView.
Definition ClipView.cpp:1011
auto hasCustomColor() const -> bool
Definition ClipView.cpp:1427
QColor m_markerColor
Definition ClipView.h:221
Action m_action
Definition ClipView.h:205
void randomizeColor()
Definition ClipView.cpp:355
QColor patternClipBackground
Definition ClipView.h:62
void updateLength()
Updates a ClipView's length.
Definition ClipView.cpp:313
void update() override
Update a ClipView.
Definition ClipView.cpp:165
QColor mutedBackgroundColor
Definition ClipView.h:57
virtual bool destructiveSplitClip(const TimePos pos)
Definition ClipView.h:251
TrackView * m_trackView
Definition ClipView.h:148
virtual void constructContextMenu(QMenu *)
Definition ClipView.h:155
virtual void paintTextLabel(QString const &text, QPainter &painter)
Definition ClipView.cpp:563
static void toggleMute(QVector< ClipView * > clipvs)
Definition ClipView.cpp:1232
void setMarkerEnabled(bool e)
Definition ClipView.h:127
float pixelsPerBar()
How many pixels a bar takes for this ClipView.
Definition ClipView.cpp:1258
void updateCursor(QMouseEvent *me)
Definition ClipView.cpp:485
QColor textBackgroundColor
Definition ClipView.h:60
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:223
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