SongEditor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. #ifndef SONG_EDITOR_H
  26. #define SONG_EDITOR_H
  27. #include <QVector>
  28. #include "ActionGroup.h"
  29. #include "Editor.h"
  30. #include "TrackContainerView.h"
  31. class QLabel;
  32. class QScrollBar;
  33. class AutomatableSlider;
  34. class ComboBox;
  35. class ComboBoxModel;
  36. class LcdSpinBox;
  37. class MeterDialog;
  38. class Song;
  39. class TextFloat;
  40. class TimeLineWidget;
  41. class positionLine : public QWidget
  42. {
  43. public:
  44. positionLine( QWidget * parent );
  45. private:
  46. void paintEvent( QPaintEvent * pe ) override;
  47. } ;
  48. class SongEditor : public TrackContainerView
  49. {
  50. Q_OBJECT
  51. public:
  52. enum EditMode
  53. {
  54. DrawMode,
  55. SelectMode
  56. };
  57. SongEditor( Song * song );
  58. ~SongEditor();
  59. void saveSettings( QDomDocument& doc, QDomElement& element ) override;
  60. void loadSettings( const QDomElement& element ) override;
  61. ComboBoxModel *zoomingModel() const;
  62. ComboBoxModel *snappingModel() const;
  63. float getSnapSize() const;
  64. QString getSnapSizeString() const;
  65. public slots:
  66. void scrolled( int new_pos );
  67. void selectRegionFromPixels(int xStart, int xEnd);
  68. void stopSelectRegion();
  69. void updateRubberband();
  70. void setEditMode( EditMode mode );
  71. void setEditModeDraw();
  72. void setEditModeSelect();
  73. void toggleProportionalSnap();
  74. void updatePosition( const MidiTime & t );
  75. void updatePositionLine();
  76. void selectAllTcos( bool select );
  77. protected:
  78. void closeEvent( QCloseEvent * ce ) override;
  79. void mousePressEvent(QMouseEvent * me) override;
  80. void mouseMoveEvent(QMouseEvent * me) override;
  81. void mouseReleaseEvent(QMouseEvent * me) override;
  82. private slots:
  83. void setHighQuality( bool );
  84. void setMasterVolume( int new_val );
  85. void showMasterVolumeFloat();
  86. void updateMasterVolumeFloat( int new_val );
  87. void hideMasterVolumeFloat();
  88. void setMasterPitch( int new_val );
  89. void showMasterPitchFloat();
  90. void updateMasterPitchFloat( int new_val );
  91. void hideMasterPitchFloat();
  92. void updateScrollBar(int len);
  93. void zoomingChanged();
  94. private:
  95. void keyPressEvent( QKeyEvent * ke ) override;
  96. void wheelEvent( QWheelEvent * we ) override;
  97. bool allowRubberband() const override;
  98. int trackIndexFromSelectionPoint(int yPos);
  99. int indexOfTrackView(const TrackView* tv);
  100. Song * m_song;
  101. QScrollBar * m_leftRightScroll;
  102. LcdSpinBox * m_tempoSpinBox;
  103. TimeLineWidget * m_timeLine;
  104. MeterDialog * m_timeSigDisplay;
  105. AutomatableSlider * m_masterVolumeSlider;
  106. AutomatableSlider * m_masterPitchSlider;
  107. TextFloat * m_mvsStatus;
  108. TextFloat * m_mpsStatus;
  109. positionLine * m_positionLine;
  110. ComboBoxModel* m_zoomingModel;
  111. ComboBoxModel* m_snappingModel;
  112. bool m_proportionalSnap;
  113. static const QVector<double> m_zoomLevels;
  114. bool m_scrollBack;
  115. bool m_smoothScroll;
  116. EditMode m_mode;
  117. EditMode m_ctrlMode; // mode they were in before they hit ctrl
  118. QPoint m_origin;
  119. QPoint m_scrollPos;
  120. QPoint m_mousePos;
  121. int m_rubberBandStartTrackview;
  122. MidiTime m_rubberbandStartMidipos;
  123. int m_currentZoomingValue;
  124. int m_trackHeadWidth;
  125. bool m_selectRegion;
  126. friend class SongEditorWindow;
  127. } ;
  128. class SongEditorWindow : public Editor
  129. {
  130. Q_OBJECT
  131. public:
  132. SongEditorWindow( Song* song );
  133. QSize sizeHint() const override;
  134. SongEditor* m_editor;
  135. protected:
  136. void resizeEvent( QResizeEvent * event ) override;
  137. void changeEvent( QEvent * ) override;
  138. protected slots:
  139. void play() override;
  140. void record() override;
  141. void recordAccompany() override;
  142. void stop() override;
  143. void lostFocus();
  144. void adjustUiAfterProjectLoad();
  145. void updateSnapLabel();
  146. signals:
  147. void playTriggered();
  148. void resized();
  149. private:
  150. void keyPressEvent( QKeyEvent * ke ) override;
  151. void keyReleaseEvent( QKeyEvent * ke ) override;
  152. QAction* m_addBBTrackAction;
  153. QAction* m_addSampleTrackAction;
  154. QAction* m_addAutomationTrackAction;
  155. QAction* m_setProportionalSnapAction;
  156. ActionGroup * m_editModeGroup;
  157. QAction* m_drawModeAction;
  158. QAction* m_selectModeAction;
  159. QAction* m_crtlAction;
  160. ComboBox * m_zoomingComboBox;
  161. ComboBox * m_snappingComboBox;
  162. QLabel* m_snapSizeLabel;
  163. };
  164. #endif