TrackView.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * TrackView.h - declaration of TrackView class
  3. *
  4. * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef TRACK_VIEW_H
  25. #define TRACK_VIEW_H
  26. #include <QWidget>
  27. #include "JournallingObject.h"
  28. #include "ModelView.h"
  29. #include "TrackContentWidget.h"
  30. #include "TrackOperationsWidget.h"
  31. class QMenu;
  32. class FadeButton;
  33. class Track;
  34. class TrackContainerView;
  35. class Clip;
  36. const int DEFAULT_SETTINGS_WIDGET_WIDTH = 224;
  37. const int TRACK_OP_WIDTH = 78;
  38. // This shaves 150-ish pixels off track buttons,
  39. // ruled from config: ui.compacttrackbuttons
  40. const int DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT = 96;
  41. const int TRACK_OP_WIDTH_COMPACT = 62;
  42. const int CLIP_BORDER_WIDTH = 2;
  43. class TrackView : public QWidget, public ModelView, public JournallingObject
  44. {
  45. Q_OBJECT
  46. public:
  47. TrackView( Track * _track, TrackContainerView* tcv );
  48. virtual ~TrackView();
  49. inline const Track * getTrack() const
  50. {
  51. return m_track;
  52. }
  53. inline Track * getTrack()
  54. {
  55. return m_track;
  56. }
  57. inline TrackContainerView* trackContainerView()
  58. {
  59. return m_trackContainerView;
  60. }
  61. inline TrackOperationsWidget * getTrackOperationsWidget()
  62. {
  63. return &m_trackOperationsWidget;
  64. }
  65. inline QWidget * getTrackSettingsWidget()
  66. {
  67. return &m_trackSettingsWidget;
  68. }
  69. inline TrackContentWidget * getTrackContentWidget()
  70. {
  71. return &m_trackContentWidget;
  72. }
  73. bool isMovingTrack() const
  74. {
  75. return m_action == MoveTrack;
  76. }
  77. virtual void update();
  78. // Create a menu for assigning/creating channels for this track
  79. // Currently instrument track and sample track supports it
  80. virtual QMenu * createMixerMenu(QString title, QString newMixerLabel);
  81. public slots:
  82. virtual bool close();
  83. protected:
  84. void modelChanged() override;
  85. void saveSettings( QDomDocument& doc, QDomElement& element ) override
  86. {
  87. Q_UNUSED(doc)
  88. Q_UNUSED(element)
  89. }
  90. void loadSettings( const QDomElement& element ) override
  91. {
  92. Q_UNUSED(element)
  93. }
  94. QString nodeName() const override
  95. {
  96. return "trackview";
  97. }
  98. void dragEnterEvent( QDragEnterEvent * dee ) override;
  99. void dropEvent( QDropEvent * de ) override;
  100. void mousePressEvent( QMouseEvent * me ) override;
  101. void mouseMoveEvent( QMouseEvent * me ) override;
  102. void mouseReleaseEvent( QMouseEvent * me ) override;
  103. void paintEvent( QPaintEvent * pe ) override;
  104. void resizeEvent( QResizeEvent * re ) override;
  105. private:
  106. enum Actions
  107. {
  108. NoAction,
  109. MoveTrack,
  110. ResizeTrack
  111. } ;
  112. Track * m_track;
  113. TrackContainerView * m_trackContainerView;
  114. TrackOperationsWidget m_trackOperationsWidget;
  115. QWidget m_trackSettingsWidget;
  116. TrackContentWidget m_trackContentWidget;
  117. Actions m_action;
  118. virtual FadeButton * getActivityIndicator()
  119. {
  120. return nullptr;
  121. }
  122. void setIndicatorMute(FadeButton* indicator, bool muted);
  123. friend class TrackLabelButton;
  124. private slots:
  125. void createClipView( Clip * clip );
  126. void muteChanged();
  127. } ;
  128. #endif