add class controllerConnection to model link between models and controllers
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1023 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
#include "journalling_object.h"
|
||||
#include "level_object.h"
|
||||
#include "mv_base.h"
|
||||
#include "controller.h"
|
||||
#include "controller_connection.h"
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QObject>
|
||||
@@ -106,26 +106,26 @@ public:
|
||||
|
||||
inline virtual T value( int _frameOffset = 0 ) const
|
||||
{
|
||||
if( m_controller != NULL )
|
||||
if( m_controllerConnection != NULL )
|
||||
{
|
||||
return minValue() + castValue( m_range *
|
||||
m_controller->currentValue( _frameOffset ) );
|
||||
m_controllerConnection->currentValue( _frameOffset ) );
|
||||
}
|
||||
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
inline controller * getController( void ) const
|
||||
inline controllerConnection * getControllerConnection( void ) const
|
||||
{
|
||||
return m_controller;
|
||||
return m_controllerConnection;
|
||||
}
|
||||
|
||||
|
||||
inline void setController( controller * _c )
|
||||
inline void setControllerConnection( controllerConnection * _c )
|
||||
{
|
||||
m_controller = _c;
|
||||
QObject::connect( m_controller, SIGNAL( valueChanged() ),
|
||||
m_controllerConnection = _c;
|
||||
QObject::connect( m_controllerConnection, SIGNAL( valueChanged() ),
|
||||
this, SIGNAL( dataChanged() ) );
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
controller * m_controller;
|
||||
controllerConnection * m_controllerConnection;
|
||||
T m_value;
|
||||
T m_initValue;
|
||||
T m_minValue;
|
||||
|
||||
@@ -45,7 +45,7 @@ automatableModel<T, EDIT_STEP_TYPE>::automatableModel(
|
||||
::model * _parent,
|
||||
bool _default_constructed ) :
|
||||
model( _parent, _default_constructed ),
|
||||
m_controller( NULL ),
|
||||
m_controllerConnection( NULL ),
|
||||
m_value( _val ),
|
||||
m_initValue( _val ),
|
||||
m_minValue( _min ),
|
||||
@@ -301,6 +301,24 @@ void automatableModel<T, EDIT_STEP_TYPE>::saveSettings( QDomDocument & _doc,
|
||||
{
|
||||
_this.setAttribute( _name, value() );
|
||||
}
|
||||
|
||||
if( m_controllerConnection )
|
||||
{
|
||||
QDomElement controller_element;
|
||||
QDomNode node = _this.namedItem( "connection" );
|
||||
if( node.isElement() )
|
||||
{
|
||||
controller_element = node.toElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
controller_element = _doc.createElement( "connection" );
|
||||
_this.appendChild( controller_element );
|
||||
}
|
||||
QDomElement element = _doc.createElement( _name );
|
||||
m_controllerConnection->saveSettings( _doc, element );
|
||||
controller_element.appendChild( element );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -323,6 +341,17 @@ void automatableModel<T, EDIT_STEP_TYPE>::loadSettings(
|
||||
}
|
||||
}
|
||||
|
||||
node = _this.namedItem( "connection" );
|
||||
if( node.isElement() )
|
||||
{
|
||||
node = node.namedItem( _name );
|
||||
if( node.isElement() ) {
|
||||
//m_controllerConnection = new controllerConnection( (controller*)NULL );
|
||||
setControllerConnection( new controllerConnection( (controller*)NULL ) );
|
||||
m_controllerConnection->loadSettings( node.toElement() );
|
||||
}
|
||||
}
|
||||
|
||||
setInitValue( attributeValue( _this.attribute( _name ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ class controller : public model, public journallingObject
|
||||
public:
|
||||
enum ControllerTypes
|
||||
{
|
||||
DummyController,
|
||||
LfoController,
|
||||
/*
|
||||
MidiController,
|
||||
|
||||
99
include/controller_connection.h
Normal file
99
include/controller_connection.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* controller_connection.h - declaration of a controller connect, which
|
||||
* provides a definition of the link between a controller and
|
||||
* model, also handles deferred creation of links while
|
||||
* loading project
|
||||
*
|
||||
* Copyright (c) 2008 Paul Giblock <pgllama/at/gmail.com>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _CONTROLLER_CONNECTION_H
|
||||
#define _CONTROLLER_CONNECTION_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QVector>
|
||||
|
||||
#include "engine.h"
|
||||
#include "controller.h"
|
||||
#include "mv_base.h"
|
||||
#include "journalling_object.h"
|
||||
|
||||
class controllerConnection;
|
||||
|
||||
typedef QVector<controllerConnection *> controllerConnectionVector;
|
||||
|
||||
class controllerConnection : public QObject, public journallingObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
controllerConnection( controller * _controller );
|
||||
controllerConnection( int _controllerId );
|
||||
|
||||
virtual ~controllerConnection();
|
||||
|
||||
inline controller * getController( void )
|
||||
{
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
inline void setController( controller * _controller );
|
||||
|
||||
inline void setController( int _controllerId );
|
||||
|
||||
float currentValue( int _offset )
|
||||
{
|
||||
return m_controller->currentValue( _offset );
|
||||
}
|
||||
|
||||
inline bool isFinalized( void )
|
||||
{
|
||||
return m_controllerId < 0;
|
||||
}
|
||||
|
||||
static void finalizeConnections( void );
|
||||
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _this );
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
virtual QString nodeName( void ) const;
|
||||
|
||||
protected:
|
||||
//virtual controllerDialog * createDialog( QWidget * _parent );
|
||||
|
||||
controller * m_controller;
|
||||
int m_controllerId;
|
||||
|
||||
static controllerConnectionVector s_connections;
|
||||
|
||||
static controller * dummyController();
|
||||
static controller * s_dummyController;
|
||||
|
||||
|
||||
signals:
|
||||
// The value changed while the mixer isn't running (i.e: MIDI CC)
|
||||
void valueChanged( void );
|
||||
|
||||
friend class controllerConnectionDialog;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user