TrackContentWidget.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * TrackContentWidget.h - declaration of TrackContentWidget 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_WIDGET_H
  25. #define TRACK_CONTENT_WIDGET_H
  26. #include <QWidget>
  27. #include "JournallingObject.h"
  28. #include "TimePos.h"
  29. class QMimeData;
  30. class Track;
  31. class ClipView;
  32. class TrackView;
  33. class TrackContentWidget : public QWidget, public JournallingObject
  34. {
  35. Q_OBJECT
  36. // qproperties for track background gradients
  37. Q_PROPERTY( QBrush darkerColor READ darkerColor WRITE setDarkerColor )
  38. Q_PROPERTY( QBrush lighterColor READ lighterColor WRITE setLighterColor )
  39. Q_PROPERTY( QBrush gridColor READ gridColor WRITE setGridColor )
  40. Q_PROPERTY( QBrush embossColor READ embossColor WRITE setEmbossColor )
  41. public:
  42. TrackContentWidget( TrackView * parent );
  43. virtual ~TrackContentWidget();
  44. /*! \brief Updates the background tile pixmap. */
  45. void updateBackground();
  46. void addClipView( ClipView * clipv );
  47. void removeClipView( ClipView * clipv );
  48. void removeClipView( int clipNum )
  49. {
  50. if( clipNum >= 0 && clipNum < m_clipViews.size() )
  51. {
  52. removeClipView( m_clipViews[clipNum] );
  53. }
  54. }
  55. bool canPasteSelection( TimePos clipPos, const QDropEvent *de );
  56. bool canPasteSelection( TimePos clipPos, const QMimeData *md, bool allowSameBar = false );
  57. bool pasteSelection( TimePos clipPos, QDropEvent * de );
  58. bool pasteSelection( TimePos clipPos, const QMimeData * md, bool skipSafetyCheck = false );
  59. TimePos endPosition( const TimePos & posStart );
  60. // qproperty access methods
  61. QBrush darkerColor() const;
  62. QBrush lighterColor() const;
  63. QBrush gridColor() const;
  64. QBrush embossColor() const;
  65. void setDarkerColor( const QBrush & c );
  66. void setLighterColor( const QBrush & c );
  67. void setGridColor( const QBrush & c );
  68. void setEmbossColor( const QBrush & c);
  69. public slots:
  70. void update();
  71. void changePosition( const TimePos & newPos = TimePos( -1 ) );
  72. protected:
  73. enum ContextMenuAction
  74. {
  75. Paste
  76. };
  77. void contextMenuEvent( QContextMenuEvent * cme ) override;
  78. void contextMenuAction( QContextMenuEvent * cme, ContextMenuAction action );
  79. void dragEnterEvent( QDragEnterEvent * dee ) override;
  80. void dropEvent( QDropEvent * de ) override;
  81. void mousePressEvent( QMouseEvent * me ) override;
  82. void mouseReleaseEvent( QMouseEvent * me ) override;
  83. void paintEvent( QPaintEvent * pe ) override;
  84. void resizeEvent( QResizeEvent * re ) override;
  85. QString nodeName() const override
  86. {
  87. return "trackcontentwidget";
  88. }
  89. void saveSettings( QDomDocument& doc, QDomElement& element ) override
  90. {
  91. Q_UNUSED(doc)
  92. Q_UNUSED(element)
  93. }
  94. void loadSettings( const QDomElement& element ) override
  95. {
  96. Q_UNUSED(element)
  97. }
  98. private:
  99. Track * getTrack();
  100. TimePos getPosition( int mouseX );
  101. TrackView * m_trackView;
  102. typedef QVector<ClipView *> clipViewVector;
  103. clipViewVector m_clipViews;
  104. QPixmap m_background;
  105. // qproperty fields
  106. QBrush m_darkerColor;
  107. QBrush m_lighterColor;
  108. QBrush m_gridColor;
  109. QBrush m_embossColor;
  110. } ;
  111. #endif