BBTrack.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * BBTrack.h - class BBTrack, a wrapper for using bbEditor
  3. * (which is a singleton-class) as track
  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 BB_TRACK_H
  26. #define BB_TRACK_H
  27. #include <QtCore/QObject>
  28. #include <QtCore/QMap>
  29. #include <QStaticText>
  30. #include "TrackContentObjectView.h"
  31. #include "Track.h"
  32. #include "TrackView.h"
  33. class TrackLabelButton;
  34. class TrackContainer;
  35. class BBTCO : public TrackContentObject
  36. {
  37. public:
  38. BBTCO( Track * _track );
  39. virtual ~BBTCO() = default;
  40. void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
  41. void loadSettings( const QDomElement & _this ) override;
  42. inline QString nodeName() const override
  43. {
  44. return( "bbtco" );
  45. }
  46. int bbTrackIndex();
  47. TrackContentObjectView * createView( TrackView * _tv ) override;
  48. private:
  49. friend class BBTCOView;
  50. } ;
  51. class BBTCOView : public TrackContentObjectView
  52. {
  53. Q_OBJECT
  54. public:
  55. BBTCOView( TrackContentObject * _tco, TrackView * _tv );
  56. virtual ~BBTCOView() = default;
  57. public slots:
  58. void update() override;
  59. protected slots:
  60. void openInBBEditor();
  61. void resetName();
  62. void changeName();
  63. protected:
  64. void paintEvent( QPaintEvent * pe ) override;
  65. void mouseDoubleClickEvent( QMouseEvent * _me ) override;
  66. void constructContextMenu( QMenu * ) override;
  67. private:
  68. BBTCO * m_bbTCO;
  69. QPixmap m_paintPixmap;
  70. QStaticText m_staticTextName;
  71. } ;
  72. class LMMS_EXPORT BBTrack : public Track
  73. {
  74. Q_OBJECT
  75. public:
  76. BBTrack( TrackContainer* tc );
  77. virtual ~BBTrack();
  78. virtual bool play( const TimePos & _start, const fpp_t _frames,
  79. const f_cnt_t _frame_base, int _tco_num = -1 ) override;
  80. TrackView * createView( TrackContainerView* tcv ) override;
  81. TrackContentObject* createTCO(const TimePos & pos) override;
  82. virtual void saveTrackSpecificSettings( QDomDocument & _doc,
  83. QDomElement & _parent ) override;
  84. void loadTrackSpecificSettings( const QDomElement & _this ) override;
  85. static BBTrack * findBBTrack( int _bb_num );
  86. static void swapBBTracks( Track * _track1, Track * _track2 );
  87. int index()
  88. {
  89. return s_infoMap[this];
  90. }
  91. bool automationDisabled( Track * _track )
  92. {
  93. return( m_disabledTracks.contains( _track ) );
  94. }
  95. void disableAutomation( Track * _track )
  96. {
  97. m_disabledTracks.append( _track );
  98. }
  99. void enableAutomation( Track * _track )
  100. {
  101. m_disabledTracks.removeAll( _track );
  102. }
  103. protected:
  104. inline QString nodeName() const override
  105. {
  106. return( "bbtrack" );
  107. }
  108. private:
  109. QList<Track *> m_disabledTracks;
  110. typedef QMap<BBTrack *, int> infoMap;
  111. static infoMap s_infoMap;
  112. friend class BBTrackView;
  113. } ;
  114. class BBTrackView : public TrackView
  115. {
  116. Q_OBJECT
  117. public:
  118. BBTrackView( BBTrack* bbt, TrackContainerView* tcv );
  119. virtual ~BBTrackView();
  120. bool close() override;
  121. const BBTrack * getBBTrack() const
  122. {
  123. return( m_bbTrack );
  124. }
  125. public slots:
  126. void clickedTrackLabel();
  127. private:
  128. BBTrack * m_bbTrack;
  129. TrackLabelButton * m_trackLabel;
  130. } ;
  131. #endif