Clip.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * TrackConteintObject.h - declaration of Clip 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_CONTENT_OBJECT_H
  25. #define TRACK_CONTENT_OBJECT_H
  26. #include <QColor>
  27. #include "AutomatableModel.h"
  28. #include "lmms_basics.h"
  29. class Track;
  30. class ClipView;
  31. class TrackContainer;
  32. class TrackView;
  33. class LMMS_EXPORT Clip : public Model, public JournallingObject
  34. {
  35. Q_OBJECT
  36. MM_OPERATORS
  37. mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel);
  38. mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel);
  39. public:
  40. Clip( Track * track );
  41. virtual ~Clip();
  42. inline Track * getTrack() const
  43. {
  44. return m_track;
  45. }
  46. inline const QString & name() const
  47. {
  48. return m_name;
  49. }
  50. inline void setName( const QString & name )
  51. {
  52. m_name = name;
  53. emit dataChanged();
  54. }
  55. QString displayName() const override
  56. {
  57. return name();
  58. }
  59. inline const TimePos & startPosition() const
  60. {
  61. return m_startPosition;
  62. }
  63. inline TimePos endPosition() const
  64. {
  65. const int sp = m_startPosition;
  66. return sp + m_length;
  67. }
  68. inline const TimePos & length() const
  69. {
  70. return m_length;
  71. }
  72. inline void setAutoResize( const bool r )
  73. {
  74. m_autoResize = r;
  75. }
  76. inline const bool getAutoResize() const
  77. {
  78. return m_autoResize;
  79. }
  80. QColor color() const
  81. {
  82. return m_color;
  83. }
  84. void setColor( const QColor & c )
  85. {
  86. m_color = c;
  87. }
  88. bool hasColor();
  89. void useCustomClipColor( bool b );
  90. bool usesCustomClipColor()
  91. {
  92. return m_useCustomClipColor;
  93. }
  94. virtual void movePosition( const TimePos & pos );
  95. virtual void changeLength( const TimePos & length );
  96. virtual ClipView * createView( TrackView * tv ) = 0;
  97. inline void selectViewOnCreate( bool select )
  98. {
  99. m_selectViewOnCreate = select;
  100. }
  101. inline bool getSelectViewOnCreate()
  102. {
  103. return m_selectViewOnCreate;
  104. }
  105. /// Returns true if and only if a->startPosition() < b->startPosition()
  106. static bool comparePosition(const Clip* a, const Clip* b);
  107. TimePos startTimeOffset() const;
  108. void setStartTimeOffset( const TimePos &startTimeOffset );
  109. // Will copy the state of a clip to another clip
  110. static void copyStateTo( Clip *src, Clip *dst );
  111. public slots:
  112. void toggleMute();
  113. signals:
  114. void lengthChanged();
  115. void positionChanged();
  116. void destroyedClip();
  117. void colorChanged();
  118. private:
  119. enum Actions
  120. {
  121. NoAction,
  122. Move,
  123. Resize
  124. } ;
  125. Track * m_track;
  126. QString m_name;
  127. TimePos m_startPosition;
  128. TimePos m_length;
  129. TimePos m_startTimeOffset;
  130. BoolModel m_mutedModel;
  131. BoolModel m_soloModel;
  132. bool m_autoResize;
  133. bool m_selectViewOnCreate;
  134. QColor m_color;
  135. bool m_useCustomClipColor;
  136. friend class ClipView;
  137. } ;
  138. #endif