1 /* 2 * SongEditor.h - declaration of class SongEditor, a window where you can 3 * setup your songs 4 * 5 * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net> 6 * 7 * This file is part of LMMS - https://lmms.io 8 * 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. 13 * 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. 18 * 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. 23 * 24 */ 25 26 27 #ifndef SONG_EDITOR_H 28 #define SONG_EDITOR_H 29 30 #include <QVector> 31 32 #include "Editor.h" 33 #include "TrackContainerView.h" 34 35 class QLabel; 36 class QScrollBar; 37 38 class AutomatableSlider; 39 class ComboBox; 40 class ComboBoxModel; 41 class LcdSpinBox; 42 class MeterDialog; 43 class Song; 44 class TextFloat; 45 class TimeLineWidget; 46 47 class positionLine : public QWidget 48 { 49 public: 50 positionLine( QWidget * parent ); 51 52 private: 53 virtual void paintEvent( QPaintEvent * pe ); 54 55 } ; 56 57 58 class SongEditor : public TrackContainerView 59 { 60 Q_OBJECT 61 public: 62 enum EditMode 63 { 64 DrawMode, 65 SelectMode 66 }; 67 68 SongEditor( Song * song ); 69 ~SongEditor(); 70 71 void saveSettings( QDomDocument& doc, QDomElement& element ); 72 void loadSettings( const QDomElement& element ); 73 74 ComboBoxModel *zoomingModel() const; 75 76 public slots: 77 void scrolled( int new_pos ); 78 void selectRegionFromPixels(int xStart, int xEnd); 79 void stopSelectRegion(); 80 void updateRubberband(); 81 82 void setEditMode( EditMode mode ); 83 void setEditModeDraw(); 84 void setEditModeSelect(); 85 86 void updatePosition( const MidiTime & t ); 87 void updatePositionLine(); 88 89 protected: 90 virtual void closeEvent( QCloseEvent * ce ); 91 virtual void mousePressEvent(QMouseEvent * me); 92 virtual void mouseMoveEvent(QMouseEvent * me); 93 virtual void mouseReleaseEvent(QMouseEvent * me); 94 95 private slots: 96 void setHighQuality( bool ); 97 98 void setMasterVolume( int new_val ); 99 void showMasterVolumeFloat(); 100 void updateMasterVolumeFloat( int new_val ); 101 void hideMasterVolumeFloat(); 102 103 void setMasterPitch( int new_val ); 104 void showMasterPitchFloat(); 105 void updateMasterPitchFloat( int new_val ); 106 void hideMasterPitchFloat(); 107 108 void updateScrollBar(int len); 109 110 void zoomingChanged(); 111 112 private: 113 virtual void keyPressEvent( QKeyEvent * ke ); 114 virtual void wheelEvent( QWheelEvent * we ); 115 116 virtual bool allowRubberband() const; 117 118 int trackIndexFromSelectionPoint(int yPos); 119 int indexOfTrackView(const TrackView* tv); 120 121 122 Song * m_song; 123 124 QScrollBar * m_leftRightScroll; 125 126 LcdSpinBox * m_tempoSpinBox; 127 128 TimeLineWidget * m_timeLine; 129 130 MeterDialog * m_timeSigDisplay; 131 AutomatableSlider * m_masterVolumeSlider; 132 AutomatableSlider * m_masterPitchSlider; 133 134 TextFloat * m_mvsStatus; 135 TextFloat * m_mpsStatus; 136 137 positionLine * m_positionLine; 138 139 ComboBoxModel* m_zoomingModel; 140 141 static const QVector<double> m_zoomLevels; 142 143 bool m_scrollBack; 144 bool m_smoothScroll; 145 146 EditMode m_mode; 147 QPoint m_origin; 148 QPoint m_scrollPos; 149 QPoint m_mousePos; 150 int m_rubberBandStartTrackview; 151 MidiTime m_rubberbandStartMidipos; 152 int m_currentZoomingValue; 153 int m_trackHeadWidth; 154 bool m_selectRegion; 155 156 friend class SongEditorWindow; 157 158 } ; 159 160 161 162 163 class SongEditorWindow : public Editor 164 { 165 Q_OBJECT 166 public: 167 SongEditorWindow( Song* song ); 168 169 QSize sizeHint() const; 170 171 SongEditor* m_editor; 172 173 protected: 174 virtual void resizeEvent( QResizeEvent * event ); 175 virtual void changeEvent( QEvent * ); 176 177 protected slots: 178 void play(); 179 void record(); 180 void recordAccompany(); 181 void stop(); 182 183 void adjustUiAfterProjectLoad(); 184 185 signals: 186 void playTriggered(); 187 void resized(); 188 189 private: 190 QAction* m_addBBTrackAction; 191 QAction* m_addSampleTrackAction; 192 QAction* m_addAutomationTrackAction; 193 194 QAction* m_drawModeAction; 195 QAction* m_selectModeAction; 196 197 ComboBox * m_zoomingComboBox; 198 }; 199 200 #endif 201