ControllerConnection.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * ControllerConnection.h - declaration of a controller connect, which
  3. * provides a definition of the link between a controller and
  4. * model, also handles deferred creation of links while
  5. * loading project
  6. *
  7. * Copyright (c) 2008 Paul Giblock <pgllama/at/gmail.com>
  8. * Copyright (c) 2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  9. *
  10. * This file is part of LMMS - https://lmms.io
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 2 of the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public
  23. * License along with this program (see COPYING); if not, write to the
  24. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  25. * Boston, MA 02110-1301 USA.
  26. *
  27. */
  28. #ifndef CONTROLLER_CONNECTION_H
  29. #define CONTROLLER_CONNECTION_H
  30. #include <QtCore/QObject>
  31. #include <QtCore/QVector>
  32. #include "Controller.h"
  33. #include "JournallingObject.h"
  34. #include "ValueBuffer.h"
  35. class ControllerConnection;
  36. typedef QVector<ControllerConnection *> ControllerConnectionVector;
  37. class LMMS_EXPORT ControllerConnection : public QObject, public JournallingObject
  38. {
  39. Q_OBJECT
  40. public:
  41. ControllerConnection( Controller * _controller );
  42. ControllerConnection( int _controllerId );
  43. virtual ~ControllerConnection();
  44. inline Controller * getController()
  45. {
  46. return m_controller;
  47. }
  48. void setController( Controller * _controller );
  49. inline void setController( int _controllerId );
  50. float currentValue( int _offset )
  51. {
  52. return m_controller->currentValue( _offset );
  53. }
  54. ValueBuffer * valueBuffer()
  55. {
  56. return m_controller->valueBuffer();
  57. }
  58. inline void setTargetName( const QString & _name );
  59. inline QString targetName() const
  60. {
  61. return m_targetName;
  62. }
  63. inline bool isFinalized()
  64. {
  65. return m_controllerId < 0;
  66. }
  67. static void finalizeConnections();
  68. void saveSettings( QDomDocument & _doc, QDomElement & _this ) override;
  69. void loadSettings( const QDomElement & _this ) override;
  70. static inline const QString classNodeName()
  71. {
  72. return "connection";
  73. }
  74. QString nodeName() const override
  75. {
  76. return classNodeName();
  77. }
  78. public slots:
  79. void deleteConnection();
  80. protected:
  81. //virtual controllerDialog * createDialog( QWidget * _parent );
  82. Controller * m_controller;
  83. QString m_targetName;
  84. int m_controllerId;
  85. bool m_ownsController;
  86. static ControllerConnectionVector s_connections;
  87. signals:
  88. // The value changed while the mixer isn't running (i.e: MIDI CC)
  89. void valueChanged();
  90. friend class ControllerConnectionDialog;
  91. };
  92. #endif