TrackContainer.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * TrackContainer.h - base-class for all track-containers like Song-Editor,
  3. * Pattern Editor...
  4. *
  5. * Copyright (c) 2004-2009 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 TRACK_CONTAINER_H
  26. #define TRACK_CONTAINER_H
  27. #include <QtCore/QReadWriteLock>
  28. #include "Track.h"
  29. #include "JournallingObject.h"
  30. class AutomationClip;
  31. class InstrumentTrack;
  32. class TrackContainerView;
  33. class LMMS_EXPORT TrackContainer : public Model, public JournallingObject
  34. {
  35. Q_OBJECT
  36. public:
  37. typedef QVector<Track *> TrackList;
  38. enum TrackContainerTypes
  39. {
  40. PatternContainer,
  41. SongContainer
  42. } ;
  43. TrackContainer();
  44. virtual ~TrackContainer();
  45. void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
  46. void loadSettings( const QDomElement & _this ) override;
  47. virtual AutomationClip * tempoAutomationClip()
  48. {
  49. return nullptr;
  50. }
  51. int countTracks( Track::TrackTypes _tt = Track::NumTrackTypes ) const;
  52. void addTrack( Track * _track );
  53. void removeTrack( Track * _track );
  54. virtual void updateAfterTrackAdd();
  55. void clearAllTracks();
  56. const TrackList & tracks() const
  57. {
  58. return m_tracks;
  59. }
  60. bool isEmpty() const;
  61. static const QString classNodeName()
  62. {
  63. return "trackcontainer";
  64. }
  65. inline void setType( TrackContainerTypes newType )
  66. {
  67. m_TrackContainerType = newType;
  68. }
  69. inline TrackContainerTypes type() const
  70. {
  71. return m_TrackContainerType;
  72. }
  73. virtual AutomatedValueMap automatedValuesAt(TimePos time, int clipNum = -1) const;
  74. signals:
  75. void trackAdded( Track * _track );
  76. protected:
  77. static AutomatedValueMap automatedValuesFromTracks(const TrackList &tracks, TimePos timeStart, int clipNum = -1);
  78. mutable QReadWriteLock m_tracksMutex;
  79. private:
  80. TrackList m_tracks;
  81. TrackContainerTypes m_TrackContainerType;
  82. friend class TrackContainerView;
  83. friend class Track;
  84. } ;
  85. #endif