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