2 * automation_editor.h - declaration of class automationEditor which is a window
3 * where you can edit dynamic values in an easy way
5 * Copyright (c) 2006-2008 Javier Serrano Polo <jasp00/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.
26 #ifndef _AUTOMATION_EDITOR_H
27 #define _AUTOMATION_EDITOR_H
29 #include <QtCore/QMutex>
30 #include <QtGui/QWidget>
32 #include "lmms_basics.h"
33 #include "JournallingObject.h"
34 #include "midi_time.h"
35 #include "automation_pattern.h"
36 #include "ComboBoxModel.h"
49 class automationEditor
: public QWidget
, public JournallingObject
53 void setCurrentPattern( automationPattern
* _new_pattern
);
55 inline const automationPattern
* currentPattern() const
60 inline bool validPattern() const
62 return( m_pattern
!= NULL
);
65 int quantization() const;
68 virtual void saveSettings( QDomDocument
& _doc
, QDomElement
& _parent
);
69 virtual void loadSettings( const QDomElement
& _this
);
70 inline virtual QString
nodeName() const
72 return( "automationeditor" );
78 void updateAfterPatternChange();
82 typedef automationPattern::timeMap timeMap
;
84 virtual void closeEvent( QCloseEvent
* _ce
);
85 virtual void keyPressEvent( QKeyEvent
* _ke
);
86 virtual void leaveEvent( QEvent
* _e
);
87 virtual void mousePressEvent( QMouseEvent
* _me
);
88 virtual void mouseReleaseEvent( QMouseEvent
* _me
);
89 virtual void mouseMoveEvent( QMouseEvent
* _me
);
90 virtual void paintEvent( QPaintEvent
* _pe
);
91 virtual void resizeEvent( QResizeEvent
* _re
);
92 virtual void wheelEvent( QWheelEvent
* _we
);
94 float getLevel( int _y
);
95 static inline void drawValueRect( QPainter
& _p
, int _x
, int _y
,
96 int _width
, int _height
,
97 const bool _is_selected
);
98 void removeSelection();
100 void getSelectedValues( timeMap
& _selected_values
);
102 void drawLine( int x0
, float y0
, int x1
, float y1
);
108 void horScrolled( int _new_pos
);
109 void verScrolled( int _new_pos
);
111 void drawButtonToggled();
112 void eraseButtonToggled();
113 void selectButtonToggled();
114 void moveButtonToggled();
116 void copySelectedValues();
117 void cutSelectedValues();
119 void deleteSelectedValues();
121 void updatePosition( const midiTime
& _t
);
123 void zoomingXChanged();
124 void zoomingYChanged();
146 static const int INITIAL_WIDTH
= 740;
147 static const int INITIAL_HEIGHT
= 480;
149 static const int SCROLLBAR_SIZE
= 16;
150 static const int TOP_MARGIN
= 48;
152 static const int DEFAULT_Y_DELTA
= 6;
153 static const int DEFAULT_STEPS_PER_TACT
= 16;
154 static const int DEFAULT_PPT
= 12 * DEFAULT_STEPS_PER_TACT
;
156 static const int VALUES_WIDTH
= 64;
159 automationEditor( const automationEditor
& );
160 virtual ~automationEditor();
163 static QPixmap
* s_toolDraw
;
164 static QPixmap
* s_toolErase
;
165 static QPixmap
* s_toolSelect
;
166 static QPixmap
* s_toolMove
;
171 toolButton
* m_playButton
;
172 toolButton
* m_stopButton
;
174 toolButton
* m_drawButton
;
175 toolButton
* m_eraseButton
;
176 toolButton
* m_selectButton
;
177 toolButton
* m_moveButton
;
179 toolButton
* m_cutButton
;
180 toolButton
* m_copyButton
;
181 toolButton
* m_pasteButton
;
183 comboBox
* m_zoomingXComboBox
;
184 comboBox
* m_zoomingYComboBox
;
185 comboBox
* m_quantizeComboBox
;
187 ComboBoxModel m_zoomingXModel
;
188 ComboBoxModel m_zoomingYModel
;
189 ComboBoxModel m_quantizeModel
;
191 QMutex m_patternMutex
;
192 automationPattern
* m_pattern
;
200 void updateTopBottomLevels();
202 QScrollBar
* m_leftRightScroll
;
203 QScrollBar
* m_topBottomScroll
;
205 midiTime m_currentPosition
;
209 tick_t m_selectStartTick
;
210 tick_t m_selectedTick
;
211 float m_selectStartLevel
;
212 float m_selectedLevels
;
214 float m_moveStartLevel
;
215 tick_t m_moveStartTick
;
218 float m_drawLastLevel
;
219 tick_t m_drawLastTick
;
225 timeMap m_valuesToCopy
;
226 timeMap m_selValuesForMove
;
229 editModes m_editMode
;
232 timeLine
* m_timeLine
;
235 void drawCross( QPainter
& _p
);
244 void currentPatternChanged();
245 void positionChanged( const midiTime
& );