MixerLine.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * MixerLine.h - Mixer line widget
  3. *
  4. * Copyright (c) 2009 Andrew Kelley <superjoe30/at/gmail/dot/com>
  5. * Copyright (c) 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 MIXER_LINE_H
  26. #define MIXER_LINE_H
  27. #include <QColorDialog>
  28. #include <QGraphicsView>
  29. #include <QLineEdit>
  30. #include <QWidget>
  31. #include "ColorChooser.h"
  32. #include "Knob.h"
  33. #include "LcdWidget.h"
  34. #include "SendButtonIndicator.h"
  35. class MixerView;
  36. class SendButtonIndicator;
  37. class MixerLine : public QWidget
  38. {
  39. Q_OBJECT
  40. public:
  41. Q_PROPERTY( QBrush backgroundActive READ backgroundActive WRITE setBackgroundActive )
  42. Q_PROPERTY( QColor strokeOuterActive READ strokeOuterActive WRITE setStrokeOuterActive )
  43. Q_PROPERTY( QColor strokeOuterInactive READ strokeOuterInactive WRITE setStrokeOuterInactive )
  44. Q_PROPERTY( QColor strokeInnerActive READ strokeInnerActive WRITE setStrokeInnerActive )
  45. Q_PROPERTY( QColor strokeInnerInactive READ strokeInnerInactive WRITE setStrokeInnerInactive )
  46. MixerLine( QWidget * _parent, MixerView * _mv, int _channelIndex);
  47. ~MixerLine();
  48. void paintEvent( QPaintEvent * ) override;
  49. void mousePressEvent( QMouseEvent * ) override;
  50. void mouseDoubleClickEvent( QMouseEvent * ) override;
  51. void contextMenuEvent( QContextMenuEvent * ) override;
  52. inline int channelIndex() { return m_channelIndex; }
  53. void setChannelIndex(int index);
  54. Knob * m_sendKnob;
  55. SendButtonIndicator * m_sendBtn;
  56. QBrush backgroundActive() const;
  57. void setBackgroundActive( const QBrush & c );
  58. QColor strokeOuterActive() const;
  59. void setStrokeOuterActive( const QColor & c );
  60. QColor strokeOuterInactive() const;
  61. void setStrokeOuterInactive( const QColor & c );
  62. QColor strokeInnerActive() const;
  63. void setStrokeInnerActive( const QColor & c );
  64. QColor strokeInnerInactive() const;
  65. void setStrokeInnerInactive( const QColor & c );
  66. static const int MixerLineHeight;
  67. bool eventFilter (QObject *dist, QEvent *event) override;
  68. private:
  69. void drawMixerLine( QPainter* p, const MixerLine *mixerLine, bool isActive, bool sendToThis, bool receiveFromThis );
  70. QString elideName( const QString & name );
  71. MixerView * m_mv;
  72. LcdWidget* m_lcd;
  73. int m_channelIndex;
  74. QBrush m_backgroundActive;
  75. QColor m_strokeOuterActive;
  76. QColor m_strokeOuterInactive;
  77. QColor m_strokeInnerActive;
  78. QColor m_strokeInnerInactive;
  79. static QPixmap * s_sendBgArrow;
  80. static QPixmap * s_receiveBgArrow;
  81. bool m_inRename;
  82. QLineEdit * m_renameLineEdit;
  83. QGraphicsView * m_view;
  84. public slots:
  85. void renameChannel();
  86. void resetColor();
  87. void selectColor();
  88. void randomizeColor();
  89. private slots:
  90. void renameFinished();
  91. void removeChannel();
  92. void removeUnusedChannels();
  93. void moveChannelLeft();
  94. void moveChannelRight();
  95. };
  96. #endif // MIXERLINE_H