2 * pattern.h - declaration of class pattern, which contains all informations
5 * Copyright (c) 2004-2011 Tobias Doerffel <tobydox/at/users.sourceforge.net>
7 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
29 #include <QtCore/QVector>
30 #include <QtGui/QWidget>
31 #include <QtGui/QDialog>
32 #include <QtCore/QThread>
33 #include <QtGui/QPixmap>
44 class InstrumentTrack
;
45 class patternFreezeThread
;
50 class EXPORT pattern
: public trackContentObject
60 pattern( InstrumentTrack
* _instrument_track
);
61 pattern( const pattern
& _pat_to_copy
);
67 virtual midiTime
length() const;
68 midiTime
beatPatternLength() const;
71 note
* addNote( const note
& _new_note
, const bool _quant_pos
= true );
73 void removeNote( const note
* _note_to_del
);
75 note
* rearrangeNote( const note
* _note_to_proc
,
76 const bool _quant_pos
= true );
77 void rearrangeAllNotes();
80 inline const NoteVector
& notes() const
85 void setStep( int _step
, bool _enabled
);
88 inline PatternTypes
type() const
92 void setType( PatternTypes _new_pattern_type
);
96 // functions which are part of freezing-feature
97 inline bool isFreezing() const
102 inline bool isFrozen() const
104 return m_frozenPattern
!= NULL
;
107 sampleBuffer
*frozenPattern()
109 return m_frozenPattern
;
112 // settings-management
113 virtual void saveSettings( QDomDocument
& _doc
, QDomElement
& _parent
);
114 virtual void loadSettings( const QDomElement
& _this
);
115 inline virtual QString
nodeName() const
120 inline InstrumentTrack
* instrumentTrack() const
122 return m_instrumentTrack
;
128 void addSteps( int _n
);
129 void removeSteps( int _n
);
131 virtual trackContentObjectView
* createView( trackView
* _tv
);
134 using Model::dataChanged
;
138 void ensureBeatNotes();
139 void updateBBTrack();
147 void changeTimeSignature();
151 InstrumentTrack
* m_instrumentTrack
;
153 PatternTypes m_patternType
;
160 sampleBuffer
* m_frozenPattern
;
162 volatile bool m_freezeAborted
;
165 friend class patternView
;
166 friend class patternFreezeThread
;
172 class patternView
: public trackContentObjectView
176 patternView( pattern
* _pattern
, trackView
* _parent
);
177 virtual ~patternView();
181 virtual void update();
185 void openInPianoRoll();
190 void addSteps( QAction
* _item
);
191 void removeSteps( QAction
* _item
);
195 virtual void constructContextMenu( QMenu
* );
196 virtual void mouseDoubleClickEvent( QMouseEvent
* _me
);
197 virtual void mousePressEvent( QMouseEvent
* _me
);
198 virtual void paintEvent( QPaintEvent
* _pe
);
199 virtual void resizeEvent( QResizeEvent
* _re
)
201 m_needsUpdate
= true;
202 trackContentObjectView::resizeEvent( _re
);
204 virtual void wheelEvent( QWheelEvent
* _we
);
208 static QPixmap
* s_stepBtnOn
;
209 static QPixmap
* s_stepBtnOverlay
;
210 static QPixmap
* s_stepBtnOff
;
211 static QPixmap
* s_stepBtnOffLight
;
212 static QPixmap
* s_frozen
;
215 QPixmap m_paintPixmap
;
223 // TODO: move to own header-files
227 class patternFreezeStatusDialog
: public QDialog
231 patternFreezeStatusDialog( QThread
* _thread
);
232 virtual ~patternFreezeStatusDialog();
234 void setProgress( int _p
);
238 void closeEvent( QCloseEvent
* _ce
);
242 void cancelBtnClicked();
243 void updateProgress();
247 QProgressBar
* m_progressBar
;
248 QPushButton
* m_cancelBtn
;
250 QThread
* m_freezeThread
;
264 class patternFreezeThread
: public QThread
267 patternFreezeThread( pattern
* _pattern
);
268 virtual ~patternFreezeThread();
277 patternFreezeStatusDialog
* m_statusDlg
;