reworked automatableModel (not template-based anymore), removed levelObject, splitted comboBox/comboBoxModel-source-files, began to unify context-menu-creation for controls
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1031 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <QtGui/QPushButton>
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "automatable_model_view.h"
|
||||
|
||||
|
||||
class automatableButtonGroup;
|
||||
|
||||
@@ -29,18 +29,17 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "journalling_object.h"
|
||||
#include "level_object.h"
|
||||
#include "mv_base.h"
|
||||
#include "controller_connection.h"
|
||||
#include "automation_pattern.h"
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
|
||||
|
||||
class automationPattern;
|
||||
class track;
|
||||
|
||||
|
||||
// simple way to map a property of a view to a model
|
||||
#define mapPropertyFromModelPtr(type,getfunc,setfunc,modelname) \
|
||||
public: \
|
||||
@@ -67,132 +66,35 @@ class track;
|
||||
}
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE = T>
|
||||
class automatableModel : public model, public journallingObject,
|
||||
public levelObject
|
||||
{
|
||||
public:
|
||||
typedef automatableModel<T, EDIT_STEP_TYPE> autoModel;
|
||||
|
||||
automatableModel( const T _val = 0,
|
||||
const T _min = 0,
|
||||
const T _max = 0,
|
||||
const T _step = defaultRelStep(),
|
||||
class automatableModel : public model, public journallingObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum DataType
|
||||
{
|
||||
Float,
|
||||
Integer,
|
||||
Bool
|
||||
} ;
|
||||
|
||||
automatableModel( DataType _type,
|
||||
const float _val = 0,
|
||||
const float _min = 0,
|
||||
const float _max = 0,
|
||||
const float _step = 0,
|
||||
::model * _parent = NULL,
|
||||
bool _default_constructed = FALSE );
|
||||
|
||||
virtual ~automatableModel();
|
||||
|
||||
static inline T minRelStep( void )
|
||||
|
||||
static inline float copiedValue( void )
|
||||
{
|
||||
return( 1 );
|
||||
return( __copiedValue );
|
||||
}
|
||||
|
||||
static inline T defaultRelStep( void )
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
static inline T minEps( void )
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
template<class V>
|
||||
static inline T castValue( V _v )
|
||||
{
|
||||
return( static_cast<T>( _v ) );
|
||||
}
|
||||
|
||||
inline virtual T value( int _frameOffset = 0 ) const
|
||||
{
|
||||
if( m_controllerConnection != NULL )
|
||||
{
|
||||
return minValue() + castValue( m_range *
|
||||
m_controllerConnection->currentValue( _frameOffset ) );
|
||||
}
|
||||
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
inline controllerConnection * getControllerConnection( void ) const
|
||||
{
|
||||
return m_controllerConnection;
|
||||
}
|
||||
|
||||
|
||||
inline void setControllerConnection( controllerConnection * _c )
|
||||
{
|
||||
m_controllerConnection = _c;
|
||||
QObject::connect( m_controllerConnection, SIGNAL( valueChanged() ),
|
||||
this, SIGNAL( dataChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
inline virtual T initValue( void ) const
|
||||
{
|
||||
return( m_initValue );
|
||||
}
|
||||
|
||||
inline virtual T minValue( void ) const
|
||||
{
|
||||
return( m_minValue );
|
||||
}
|
||||
|
||||
inline virtual T maxValue( void ) const
|
||||
{
|
||||
return( m_maxValue );
|
||||
}
|
||||
|
||||
inline virtual T step( void ) const
|
||||
{
|
||||
return( m_step );
|
||||
}
|
||||
|
||||
inline int curLevel( void ) const
|
||||
{
|
||||
return( m_curLevel );
|
||||
}
|
||||
|
||||
T fittedValue( T _value ) const;
|
||||
|
||||
inline T levelToValue( int _level ) const
|
||||
{
|
||||
return( fittedValue( _level * m_step ) );
|
||||
}
|
||||
|
||||
virtual void setInitValue( const T _value );
|
||||
|
||||
virtual void setValue( const T _value );
|
||||
|
||||
inline virtual void incValue( int _steps )
|
||||
{
|
||||
setValue( m_value + _steps * m_step );
|
||||
}
|
||||
|
||||
virtual void setRange( const T _min, const T _max,
|
||||
const T _step = defaultRelStep() );
|
||||
|
||||
virtual void setStep( const T _step );
|
||||
|
||||
static void linkModels( autoModel * _model1, autoModel * _model2 );
|
||||
|
||||
static void unlinkModels( autoModel * _model1, autoModel * _model2 );
|
||||
|
||||
virtual void FASTCALL saveSettings( QDomDocument & _doc,
|
||||
QDomElement & _this,
|
||||
const QString & _name = "value" );
|
||||
|
||||
virtual void FASTCALL loadSettings( const QDomElement & _this,
|
||||
const QString & _name = "value" );
|
||||
|
||||
virtual QString nodeName( void ) const
|
||||
{
|
||||
return( "automatablemodel" );
|
||||
}
|
||||
|
||||
inline automationPattern * getAutomationPattern( void );
|
||||
automationPattern * getAutomationPattern( void );
|
||||
|
||||
inline void setTrack( track * _track )
|
||||
{
|
||||
@@ -204,144 +106,263 @@ public:
|
||||
return( m_track == NULL );
|
||||
}
|
||||
|
||||
void initAutomationPattern( void )
|
||||
void initAutomationPattern( void );
|
||||
|
||||
inline controllerConnection * getControllerConnection( void ) const
|
||||
{
|
||||
m_automationPattern = new automationPattern( NULL, this );
|
||||
return m_controllerConnection;
|
||||
}
|
||||
|
||||
|
||||
inline void setControllerConnection( controllerConnection * _c )
|
||||
{
|
||||
m_controllerConnection = _c;
|
||||
QObject::connect( m_controllerConnection,
|
||||
SIGNAL( valueChanged() ),
|
||||
this, SIGNAL( dataChanged() ) );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
static inline T minEps( void )
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static inline T castValue( const float _v )
|
||||
{
|
||||
return( static_cast<T>( _v ) );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T value( int _frameOffset = 0 ) const
|
||||
{
|
||||
if( m_controllerConnection != NULL )
|
||||
{
|
||||
return minValue<T>() +
|
||||
castValue<T>( m_range *
|
||||
m_controllerConnection->currentValue(
|
||||
_frameOffset ) );
|
||||
}
|
||||
|
||||
return castValue<T>( m_value );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T initValue( void ) const
|
||||
{
|
||||
return castValue<T>( m_initValue );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T minValue( void ) const
|
||||
{
|
||||
return castValue<T>( m_minValue );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T maxValue( void ) const
|
||||
{
|
||||
return castValue<T>( m_maxValue );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T step( void ) const
|
||||
{
|
||||
return castValue<T>( m_step );
|
||||
}
|
||||
|
||||
|
||||
// template<class T>
|
||||
void setInitValue( const float _value );
|
||||
|
||||
// template<class T>
|
||||
void setValue( const float _value );
|
||||
|
||||
inline void incValue( int _steps )
|
||||
{
|
||||
setValue( m_value + _steps * m_step );
|
||||
}
|
||||
|
||||
// template<class T>
|
||||
void setRange( const float _min, const float _max,
|
||||
const float _step = 1 );
|
||||
|
||||
// template<class T>
|
||||
void setStep( const float _step );
|
||||
|
||||
static void linkModels( automatableModel * _m1,
|
||||
automatableModel * _m2 );
|
||||
static void unlinkModels( automatableModel * _m1,
|
||||
automatableModel * _m2 );
|
||||
|
||||
virtual void saveSettings( QDomDocument & _doc,
|
||||
QDomElement & _this,
|
||||
const QString & _name = "value" );
|
||||
|
||||
virtual void loadSettings( const QDomElement & _this,
|
||||
const QString & _name = "value" );
|
||||
|
||||
virtual QString nodeName( void ) const
|
||||
{
|
||||
return( "automatablemodel" );
|
||||
}
|
||||
|
||||
void prepareJournalEntryFromOldVal( void );
|
||||
|
||||
void addJournalEntryFromOldToCurVal( void );
|
||||
|
||||
void syncAutomationPattern( void );
|
||||
|
||||
|
||||
QString displayValue( const float _val ) const
|
||||
{
|
||||
switch( m_dataType )
|
||||
{
|
||||
case Float: return( QString::number(
|
||||
castValue<float>( _val ) ) );
|
||||
case Integer: return( QString::number(
|
||||
castValue<int>( _val ) ) );
|
||||
case Bool: return( QString::number(
|
||||
castValue<bool>( _val ) ) );
|
||||
}
|
||||
return( "0" );
|
||||
}
|
||||
|
||||
/* int labelToLevel( QString _label ) const
|
||||
{
|
||||
switch( m_dataType )
|
||||
{
|
||||
case Float: return( level<float>(
|
||||
stringToValue<float>( _label ) ) );
|
||||
case Integer: return( level<int>(
|
||||
stringToValue<int>( _label ) ) );
|
||||
case Bool: return( level<bool>(
|
||||
stringToValue<bool>( _label ) ) );
|
||||
}
|
||||
return( 0 );
|
||||
}*/
|
||||
|
||||
virtual QString displayName( void ) const
|
||||
{
|
||||
return( QString::null );
|
||||
}
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void reset( void );
|
||||
virtual void copyValue( void );
|
||||
virtual void pasteValue( void );
|
||||
|
||||
|
||||
protected:
|
||||
void setFirstValue( void );
|
||||
virtual void redoStep( journalEntry & _je );
|
||||
|
||||
virtual void undoStep( journalEntry & _je );
|
||||
|
||||
inline void setFirstValue( void );
|
||||
float fittedValue( float _value ) const;
|
||||
|
||||
|
||||
private:
|
||||
controllerConnection * m_controllerConnection;
|
||||
T m_value;
|
||||
T m_initValue;
|
||||
T m_minValue;
|
||||
T m_maxValue;
|
||||
T m_range;
|
||||
T m_step;
|
||||
int m_curLevel;
|
||||
DataType m_dataType;
|
||||
float m_value;
|
||||
float m_initValue;
|
||||
float m_minValue;
|
||||
float m_maxValue;
|
||||
float m_step;
|
||||
float m_range;
|
||||
|
||||
// most objects will need this temporarily
|
||||
float m_oldValue;
|
||||
bool m_journalEntryReady;
|
||||
|
||||
typedef QVector<automatableModel *> autoModelVector;
|
||||
autoModelVector m_linkedModels;
|
||||
|
||||
void linkModel( automatableModel * _model );
|
||||
|
||||
void unlinkModel( automatableModel * _model );
|
||||
|
||||
|
||||
|
||||
|
||||
controllerConnection * m_controllerConnection;
|
||||
QPointer<automationPattern> m_automationPattern;
|
||||
track * m_track;
|
||||
|
||||
// most objects will need this temporarily
|
||||
T m_oldValue;
|
||||
bool m_journalEntryReady;
|
||||
|
||||
typedef QVector<autoModel *> autoModelVector;
|
||||
autoModelVector m_linkedModels;
|
||||
|
||||
inline void linkModel( autoModel * _model );
|
||||
|
||||
inline void unlinkModel( autoModel * _model );
|
||||
|
||||
static T attributeValue( QString _value );
|
||||
|
||||
inline void syncAutomationPattern( void );
|
||||
|
||||
void setLevel( int _level );
|
||||
|
||||
inline int level( T _value ) const
|
||||
{
|
||||
return( (int)roundf( _value / (float)m_step ) );
|
||||
}
|
||||
|
||||
QString levelToLabel( int _level ) const
|
||||
{
|
||||
return( QString::number( levelToValue( _level ) ) );
|
||||
}
|
||||
|
||||
int labelToLevel( QString _label )
|
||||
{
|
||||
return( level( attributeValue( _label ) ) );
|
||||
}
|
||||
/*
|
||||
public slots:
|
||||
|
||||
void changeData( void )
|
||||
{
|
||||
emit dataChanged();
|
||||
}
|
||||
*/
|
||||
static float __copiedValue;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#define defaultTypedMethods(type) \
|
||||
inline type value( int _frameOffset = 0 ) const \
|
||||
{ \
|
||||
return( automatableModel::value<type>( _frameOffset ) );\
|
||||
} \
|
||||
\
|
||||
inline type minValue( void ) const \
|
||||
{ \
|
||||
return( automatableModel::minValue<type>() ); \
|
||||
} \
|
||||
\
|
||||
inline type maxValue( void ) const \
|
||||
{ \
|
||||
return( automatableModel::maxValue<type>() ); \
|
||||
} \
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE = T>
|
||||
class automatableModelView : public modelView
|
||||
|
||||
// some typed automatableModel-definitions
|
||||
|
||||
class floatModel : public automatableModel
|
||||
{
|
||||
public:
|
||||
typedef automatableModel<T, EDIT_STEP_TYPE> autoModel;
|
||||
typedef automatableModelView<T, EDIT_STEP_TYPE> autoModelView;
|
||||
|
||||
automatableModelView( ::model * _model ) :
|
||||
modelView( _model )
|
||||
floatModel( float _val = 0, float _min = 0, float _max = 0,
|
||||
float _step = 0, ::model * _parent = NULL,
|
||||
bool _default_constructed = FALSE ) :
|
||||
automatableModel( Float, _val, _min, _max, _step,
|
||||
_parent, _default_constructed )
|
||||
{
|
||||
}
|
||||
|
||||
// some basic functions for convenience
|
||||
autoModel * model( void )
|
||||
{
|
||||
return( castModel<autoModel>() );
|
||||
}
|
||||
|
||||
const autoModel * model( void ) const
|
||||
{
|
||||
return( castModel<autoModel>() );
|
||||
}
|
||||
|
||||
inline virtual T value( void ) const
|
||||
{
|
||||
return( model() ? model()->value() : 0 );
|
||||
}
|
||||
|
||||
inline virtual void setValue( const T _value )
|
||||
{
|
||||
if( model() )
|
||||
{
|
||||
model()->setValue( _value );
|
||||
}
|
||||
}
|
||||
defaultTypedMethods(float);
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
class intModel : public automatableModel
|
||||
{
|
||||
public:
|
||||
intModel( int _val = 0, int _min = 0, int _max = 0,
|
||||
::model * _parent = NULL,
|
||||
bool _default_constructed = FALSE ) :
|
||||
automatableModel( Integer, _val, _min, _max, 1,
|
||||
_parent, _default_constructed )
|
||||
{
|
||||
}
|
||||
|
||||
#define generateModelPrimitive(type,type2) \
|
||||
typedef automatableModel<type,type2> type##Model; \
|
||||
typedef automatableModelView<type,type2> type##ModelView; \
|
||||
defaultTypedMethods(int);
|
||||
|
||||
// some model-primitives
|
||||
} ;
|
||||
|
||||
generateModelPrimitive(float,float);
|
||||
generateModelPrimitive(int,int);
|
||||
|
||||
class boolModel : public automatableModel<bool, signed char>
|
||||
class boolModel : public automatableModel
|
||||
{
|
||||
public:
|
||||
boolModel( const bool _val = FALSE,
|
||||
::model * _parent = NULL,
|
||||
bool _default_constructed = FALSE ) :
|
||||
autoModel( _val, FALSE, TRUE, defaultRelStep(), _parent,
|
||||
_default_constructed )
|
||||
automatableModel( Bool, _val, FALSE, TRUE, 1,
|
||||
_parent, _default_constructed )
|
||||
{
|
||||
}
|
||||
|
||||
} ;
|
||||
defaultTypedMethods(bool);
|
||||
|
||||
typedef automatableModelView<bool, signed char> boolModelView;
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,573 +0,0 @@
|
||||
/*
|
||||
* automatable_model_templates.h - definition of automatableModel templates
|
||||
*
|
||||
* Copyright (c) 2007-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* 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 _AUTOMATABLE_MODEL_TEMPLATES_H
|
||||
#define _AUTOMATABLE_MODEL_TEMPLATES_H
|
||||
|
||||
#include <QtXml/QDomElement>
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "automation_editor.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "engine.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
automatableModel<T, EDIT_STEP_TYPE>::automatableModel(
|
||||
const T _val,
|
||||
const T _min,
|
||||
const T _max,
|
||||
const T _step,
|
||||
::model * _parent,
|
||||
bool _default_constructed ) :
|
||||
model( _parent, _default_constructed ),
|
||||
m_controllerConnection( NULL ),
|
||||
m_value( _val ),
|
||||
m_initValue( _val ),
|
||||
m_minValue( _min ),
|
||||
m_maxValue( _max ),
|
||||
m_range( _max-_min ),
|
||||
m_step( _step ),
|
||||
m_automationPattern( NULL ),
|
||||
m_track( NULL ),
|
||||
m_journalEntryReady( FALSE )
|
||||
{
|
||||
m_curLevel = level( _val );
|
||||
m_minLevel = level( _min );
|
||||
m_maxLevel = level( _max );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
automatableModel<T, EDIT_STEP_TYPE>::~automatableModel()
|
||||
{
|
||||
delete m_automationPattern;
|
||||
while( m_linkedModels.empty() == FALSE )
|
||||
{
|
||||
m_linkedModels.last()->unlinkModel( this );
|
||||
m_linkedModels.erase( m_linkedModels.end() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
T automatableModel<T, EDIT_STEP_TYPE>::fittedValue( T _value ) const
|
||||
{
|
||||
_value = tLimit<T>( _value, minValue(), maxValue() );
|
||||
|
||||
if( m_step != 0 )
|
||||
{
|
||||
_value = static_cast<T>( roundf( _value / (float)step() )
|
||||
* step() );
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = minValue();
|
||||
}
|
||||
|
||||
// correct rounding error at the border
|
||||
if( tAbs<T>( _value - maxValue() ) < minEps() * tAbs<T>( step() ) )
|
||||
{
|
||||
_value = maxValue();
|
||||
}
|
||||
|
||||
// correct rounding error if value = 0
|
||||
if( tAbs<T>( _value ) < minEps() * tAbs<T>( step() ) )
|
||||
{
|
||||
_value = 0;
|
||||
}
|
||||
|
||||
return( _value );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::setInitValue( const T _value )
|
||||
{
|
||||
m_initValue = _value;
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
setValue( _value );
|
||||
if( m_automationPattern )
|
||||
{
|
||||
setFirstValue();
|
||||
}
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::setValue( const T _value )
|
||||
{
|
||||
const T old_val = m_value;
|
||||
|
||||
m_value = fittedValue( _value );
|
||||
if( old_val != m_value )
|
||||
{
|
||||
m_curLevel = level( m_value );
|
||||
|
||||
// add changes to history so user can undo it
|
||||
addJournalEntry( journalEntry( 0,
|
||||
static_cast<EDIT_STEP_TYPE>( m_value ) -
|
||||
static_cast<EDIT_STEP_TYPE>( old_val ) ) );
|
||||
|
||||
// notify linked models
|
||||
|
||||
// doesn't work because of implicit typename T
|
||||
// for( autoModelVector::iterator it =
|
||||
// m_linkedModels.begin();
|
||||
// it != m_linkedModels.end(); ++it )
|
||||
for( int i = 0; i < m_linkedModels.size(); ++i )
|
||||
{
|
||||
autoModel * it = m_linkedModels[i];
|
||||
if( value() != it->value() && it->fittedValue( value() )
|
||||
!= it->value() )
|
||||
{
|
||||
bool journalling = it->testAndSetJournalling(
|
||||
isJournalling() );
|
||||
it->setValue( value() );
|
||||
it->setJournalling( journalling );
|
||||
}
|
||||
}
|
||||
setFirstValue();
|
||||
emit dataChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit dataUnchanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::setRange( const T _min, const T _max,
|
||||
const T _step )
|
||||
{
|
||||
if( ( m_maxValue != _max ) || ( m_minValue != _min ) )
|
||||
{
|
||||
m_minValue = _min;
|
||||
m_maxValue = _max;
|
||||
if( m_minValue > m_maxValue )
|
||||
{
|
||||
qSwap<T>( m_minValue, m_maxValue );
|
||||
}
|
||||
m_range = m_maxValue - m_minValue;
|
||||
setStep( _step );
|
||||
// re-adjust value
|
||||
autoModel::setInitValue( value() );
|
||||
|
||||
emit propertiesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::setStep( const T _step )
|
||||
{
|
||||
/*
|
||||
const T intv = maxValue() - minValue();
|
||||
|
||||
if( _step == 0 )
|
||||
{
|
||||
m_step = intv * defaultRelStep();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( intv > 0 ) && ( _step < 0 ) || ( intv < 0 ) &&
|
||||
( _step > 0 ) )
|
||||
{
|
||||
m_step = -_step;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_step = _step;
|
||||
}
|
||||
if( tAbs<T>( m_step ) < tAbs<T>( minRelStep() * intv ) )
|
||||
{
|
||||
m_step = minRelStep() * intv;
|
||||
}
|
||||
}*/
|
||||
if( m_step != _step )
|
||||
{
|
||||
m_step = _step;
|
||||
m_curLevel = level( m_value );
|
||||
m_minLevel = level( m_minValue );
|
||||
m_maxLevel = level( m_maxValue );
|
||||
|
||||
emit propertiesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::linkModels( autoModel * _model1,
|
||||
autoModel * _model2 )
|
||||
{
|
||||
_model1->linkModel( _model2 );
|
||||
_model2->linkModel( _model1 );
|
||||
|
||||
if( _model1->m_automationPattern != _model2->m_automationPattern )
|
||||
{
|
||||
delete _model2->m_automationPattern;
|
||||
_model2->m_automationPattern = _model1->m_automationPattern;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::unlinkModels( autoModel * _model1,
|
||||
autoModel * _model2 )
|
||||
{
|
||||
_model1->unlinkModel( _model2 );
|
||||
_model2->unlinkModel( _model1 );
|
||||
|
||||
if( _model1->m_automationPattern && _model1->m_automationPattern
|
||||
== _model2->m_automationPattern )
|
||||
{
|
||||
_model2->m_automationPattern = new automationPattern(
|
||||
*_model1->m_automationPattern, _model2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::saveSettings( QDomDocument & _doc,
|
||||
QDomElement & _this,
|
||||
const QString & _name )
|
||||
{
|
||||
if( m_automationPattern && m_automationPattern->getTimeMap().size()
|
||||
> 1 )
|
||||
{
|
||||
QDomElement pattern_element;
|
||||
QDomNode node = _this.namedItem(
|
||||
automationPattern::classNodeName() );
|
||||
if( node.isElement() )
|
||||
{
|
||||
pattern_element = node.toElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern_element = _doc.createElement(
|
||||
automationPattern::classNodeName() );
|
||||
_this.appendChild( pattern_element );
|
||||
}
|
||||
QDomElement element = _doc.createElement( _name );
|
||||
m_automationPattern->saveSettings( _doc, element );
|
||||
pattern_element.appendChild( element );
|
||||
}
|
||||
else
|
||||
{
|
||||
_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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::loadSettings(
|
||||
const QDomElement & _this,
|
||||
const QString & _name )
|
||||
{
|
||||
QDomNode node = _this.namedItem( automationPattern::classNodeName() );
|
||||
if( node.isElement() && getAutomationPattern() )
|
||||
{
|
||||
node = node.namedItem( _name );
|
||||
if( node.isElement() )
|
||||
{
|
||||
m_automationPattern->loadSettings( node.toElement() );
|
||||
setLevel( m_automationPattern->valueAt( 0 ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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 ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
automationPattern * automatableModel<T, EDIT_STEP_TYPE>::getAutomationPattern(
|
||||
void )
|
||||
{
|
||||
if( !m_automationPattern )
|
||||
{
|
||||
m_automationPattern = new automationPattern( m_track, this );
|
||||
setFirstValue();
|
||||
syncAutomationPattern();
|
||||
}
|
||||
return( m_automationPattern );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::redoStep( journalEntry & _je )
|
||||
{
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
setValue( static_cast<T>( value() + static_cast<EDIT_STEP_TYPE>(
|
||||
_je.data().toDouble() ) ) );
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::undoStep( journalEntry & _je )
|
||||
{
|
||||
journalEntry je( _je.actionID(),
|
||||
static_cast<EDIT_STEP_TYPE>( -_je.data().toDouble() ) );
|
||||
redoStep( je );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::prepareJournalEntryFromOldVal( void )
|
||||
{
|
||||
m_oldValue = value();
|
||||
saveJournallingState( FALSE );
|
||||
m_journalEntryReady = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::addJournalEntryFromOldToCurVal(
|
||||
void )
|
||||
{
|
||||
if( m_journalEntryReady )
|
||||
{
|
||||
restoreJournallingState();
|
||||
if( value() != m_oldValue )
|
||||
{
|
||||
addJournalEntry( journalEntry( 0, value() -
|
||||
m_oldValue ) );
|
||||
}
|
||||
m_journalEntryReady = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::setFirstValue( void )
|
||||
{
|
||||
if( m_automationPattern && m_automationPattern->updateFirst() )
|
||||
{
|
||||
m_automationPattern->putValue( 0, m_curLevel, FALSE );
|
||||
if( engine::getAutomationEditor() &&
|
||||
engine::getAutomationEditor()->currentPattern()
|
||||
== m_automationPattern )
|
||||
{
|
||||
engine::getAutomationEditor()->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::linkModel( autoModel * _model )
|
||||
{
|
||||
if( qFind( m_linkedModels.begin(), m_linkedModels.end(), _model )
|
||||
== m_linkedModels.end() )
|
||||
{
|
||||
m_linkedModels.push_back( _model );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::unlinkModel( autoModel * _model )
|
||||
{
|
||||
if( qFind( m_linkedModels.begin(), m_linkedModels.end(), _model )
|
||||
!= m_linkedModels.end() )
|
||||
{
|
||||
m_linkedModels.erase( qFind( m_linkedModels.begin(),
|
||||
m_linkedModels.end(),
|
||||
_model ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::syncAutomationPattern( void )
|
||||
{
|
||||
for( int i = 0; i < m_linkedModels.size(); ++i )
|
||||
{
|
||||
autoModel * it = m_linkedModels[i];
|
||||
if( m_automationPattern != it->m_automationPattern )
|
||||
{
|
||||
it->m_automationPattern = m_automationPattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<typename T, typename EDIT_STEP_TYPE>
|
||||
void automatableModel<T, EDIT_STEP_TYPE>::setLevel( int _level )
|
||||
{
|
||||
if( m_curLevel == _level )
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
m_automationPattern->setUpdateFirst( FALSE );
|
||||
setValue( _level * m_step );
|
||||
m_automationPattern->setUpdateFirst( TRUE );
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableModel<float>::minRelStep( void )
|
||||
{
|
||||
return( 1.0e-10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableModel<float>::defaultRelStep( void )
|
||||
{
|
||||
return( 1.0e-2 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableModel<float>::minEps( void )
|
||||
{
|
||||
return( 1.0e-10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableModel<float>::attributeValue( QString _value )
|
||||
{
|
||||
return( _value.toFloat() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline int automatableModel<int>::attributeValue( QString _value )
|
||||
{
|
||||
return( _value.toInt() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline bool automatableModel<bool>::attributeValue( QString _value )
|
||||
{
|
||||
return( static_cast<bool>( _value.toInt() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline bool automatableModel<bool, signed char>::attributeValue(
|
||||
QString _value )
|
||||
{
|
||||
return( static_cast<bool>( _value.toInt() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
123
include/automatable_model_view.h
Normal file
123
include/automatable_model_view.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* automatable_model_view.h - class automatableModelView
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* 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 _AUTOMATABLE_MODEL_VIEW_H
|
||||
#define _AUTOMATABLE_MODEL_VIEW_H
|
||||
|
||||
#include "mv_base.h"
|
||||
#include "automatable_model.h"
|
||||
|
||||
|
||||
class QMenu;
|
||||
|
||||
|
||||
|
||||
class automatableModelView : public modelView
|
||||
{
|
||||
public:
|
||||
automatableModelView( ::model * _model ) :
|
||||
modelView( _model ),
|
||||
m_description( QString::null ),
|
||||
m_unit( QString::null )
|
||||
{
|
||||
}
|
||||
|
||||
// some basic functions for convenience
|
||||
automatableModel * modelUntyped( void )
|
||||
{
|
||||
return( castModel<automatableModel>() );
|
||||
}
|
||||
|
||||
const automatableModel * modelUntyped( void ) const
|
||||
{
|
||||
return( castModel<automatableModel>() );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T value( void ) const
|
||||
{
|
||||
return( modelUntyped() ? modelUntyped()->value<T>() : 0 );
|
||||
}
|
||||
|
||||
inline void setValue( const float _value )
|
||||
{
|
||||
if( modelUntyped() )
|
||||
{
|
||||
modelUntyped()->setValue( _value );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void setDescription( const QString & _desc )
|
||||
{
|
||||
m_description = _desc;
|
||||
}
|
||||
|
||||
inline void setUnit( const QString & _unit )
|
||||
{
|
||||
m_unit = _unit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
void addDefaultActions( QMenu * _menu );
|
||||
|
||||
|
||||
QString m_description;
|
||||
QString m_unit;
|
||||
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#define generateTypedModelView(type) \
|
||||
class type##ModelView : public automatableModelView \
|
||||
{\
|
||||
public:\
|
||||
type##ModelView( ::model * _model ) :\
|
||||
automatableModelView( _model )\
|
||||
{\
|
||||
}\
|
||||
\
|
||||
type##Model * model( void )\
|
||||
{\
|
||||
return( castModel<type##Model>() );\
|
||||
}\
|
||||
\
|
||||
const type##Model * model( void ) const\
|
||||
{\
|
||||
return( castModel<type##Model>() );\
|
||||
}\
|
||||
} ;
|
||||
|
||||
|
||||
generateTypedModelView(float);
|
||||
generateTypedModelView(int);
|
||||
generateTypedModelView(bool);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* automatable_slider.h - class automatableSlider, a QSlider with automation
|
||||
*
|
||||
* Copyright (c) 2006-2007 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
|
||||
* Copyright (c) 2006-2008 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -29,30 +29,17 @@
|
||||
#include <QtGui/QSlider>
|
||||
#include <QtXml/QDomElement>
|
||||
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "automatable_model_view.h"
|
||||
|
||||
|
||||
|
||||
class automatableSlider : public QSlider, public automatableModelView<int>
|
||||
class automatableSlider : public QSlider, public intModelView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
automatableSlider( QWidget * _parent, const QString & _name );
|
||||
virtual ~automatableSlider();
|
||||
|
||||
/* virtual void setRange( int _min, int _max );
|
||||
virtual void setValue( int _value );
|
||||
virtual void setInitValue( int _value );
|
||||
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _this,
|
||||
const QString & _name );
|
||||
virtual void loadSettings( const QDomElement & _this,
|
||||
const QString & _name );
|
||||
|
||||
int logicValue( void );
|
||||
void clearAutomationValues( void );*/
|
||||
|
||||
bool showStatus( void )
|
||||
{
|
||||
return( m_showStatus );
|
||||
@@ -85,7 +72,7 @@ private slots:
|
||||
} ;
|
||||
|
||||
|
||||
typedef automatableSlider::autoModel sliderModel;
|
||||
typedef intModel sliderModel;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* automation_pattern.h - declaration of class automationPattern, which contains
|
||||
* all information about an automation pattern
|
||||
*
|
||||
* Copyright (c) 2006-2007 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
|
||||
* Copyright (c) 2006-2008 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -32,46 +32,44 @@
|
||||
#include "journalling_object.h"
|
||||
|
||||
|
||||
class levelObject;
|
||||
class automatableModel;
|
||||
class midiTime;
|
||||
class track;
|
||||
|
||||
|
||||
|
||||
|
||||
class automationPattern : public QObject, public journallingObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef QMap<int, int> timeMap;
|
||||
typedef QMap<int, float> timeMap;
|
||||
|
||||
automationPattern( track * _track, levelObject * _object );
|
||||
automationPattern( track * _track, automatableModel * _object );
|
||||
automationPattern( const automationPattern & _pat_to_copy );
|
||||
automationPattern( const automationPattern & _pat_to_copy,
|
||||
levelObject * _object );
|
||||
automatableModel * _object );
|
||||
virtual ~automationPattern();
|
||||
|
||||
|
||||
virtual midiTime length( void ) const;
|
||||
|
||||
midiTime FASTCALL putValue( const midiTime & _time, const int _value,
|
||||
midiTime putValue( const midiTime & _time, const float _value,
|
||||
const bool _quant_pos = TRUE );
|
||||
|
||||
void FASTCALL removeValue( const midiTime & _time );
|
||||
void removeValue( const midiTime & _time );
|
||||
|
||||
inline timeMap & getTimeMap( void )
|
||||
{
|
||||
return( m_time_map );
|
||||
}
|
||||
|
||||
int FASTCALL valueAt( const midiTime & _time );
|
||||
float valueAt( const midiTime & _time );
|
||||
|
||||
const QString name( void );
|
||||
|
||||
// settings-management
|
||||
virtual void FASTCALL saveSettings( QDomDocument & _doc,
|
||||
QDomElement & _parent );
|
||||
virtual void FASTCALL loadSettings( const QDomElement & _this );
|
||||
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
|
||||
virtual void loadSettings( const QDomElement & _this );
|
||||
|
||||
static inline const QString classNodeName( void )
|
||||
{
|
||||
@@ -88,12 +86,12 @@ public:
|
||||
return( m_track );
|
||||
}
|
||||
|
||||
inline const levelObject * object( void ) const
|
||||
inline const automatableModel * object( void ) const
|
||||
{
|
||||
return( m_object );
|
||||
}
|
||||
|
||||
inline levelObject * object( void )
|
||||
inline automatableModel * object( void )
|
||||
{
|
||||
return( m_object );
|
||||
}
|
||||
@@ -123,7 +121,7 @@ public slots:
|
||||
|
||||
private:
|
||||
track * m_track;
|
||||
levelObject * m_object;
|
||||
automatableModel * m_object;
|
||||
timeMap m_time_map;
|
||||
bool m_update_first;
|
||||
bool m_dynamic;
|
||||
|
||||
@@ -26,65 +26,11 @@
|
||||
#ifndef _COMBOBOX_H
|
||||
#define _COMBOBOX_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtCore/QPair>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "templates.h"
|
||||
|
||||
class pixmapLoader;
|
||||
|
||||
|
||||
class comboBoxModel : public intModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
comboBoxModel( ::model * _parent = NULL ) :
|
||||
automatableModel<int>( 0, 0, 0, defaultRelStep(), _parent )
|
||||
{
|
||||
}
|
||||
|
||||
void addItem( const QString & _item, pixmapLoader * _loader = NULL );
|
||||
|
||||
void clear( void );
|
||||
|
||||
int findText( const QString & _txt ) const;
|
||||
|
||||
inline const QString & currentText( void ) const
|
||||
{
|
||||
return( m_items[value()].first );
|
||||
}
|
||||
|
||||
inline const pixmapLoader * currentData( void ) const
|
||||
{
|
||||
return( m_items[value()].second );
|
||||
}
|
||||
|
||||
inline const QString & itemText( int _i ) const
|
||||
{
|
||||
return( m_items[tLimit<int>( _i, minValue(), maxValue() )].
|
||||
first );
|
||||
}
|
||||
|
||||
inline const pixmapLoader * itemPixmap( int _i ) const
|
||||
{
|
||||
return( m_items[tLimit<int>( _i, minValue(), maxValue() )].
|
||||
second );
|
||||
}
|
||||
|
||||
inline int size( void ) const
|
||||
{
|
||||
return( m_items.size() );
|
||||
}
|
||||
|
||||
private:
|
||||
typedef QPair<QString, pixmapLoader *> item;
|
||||
|
||||
QVector<item> m_items;
|
||||
|
||||
} ;
|
||||
#include "combobox_model.h"
|
||||
#include "automatable_model_view.h"
|
||||
|
||||
|
||||
|
||||
|
||||
88
include/combobox_model.h
Normal file
88
include/combobox_model.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* combobox_model.h - class comboBoxModel
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* 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 _COMBOBOX_MODEL_H
|
||||
#define _COMBOBOX_MODEL_H
|
||||
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QPair>
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "templates.h"
|
||||
|
||||
class pixmapLoader;
|
||||
|
||||
|
||||
class comboBoxModel : public intModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
comboBoxModel( ::model * _parent = NULL ) :
|
||||
intModel( 0, 0, 0, _parent )
|
||||
{
|
||||
}
|
||||
|
||||
void addItem( const QString & _item, pixmapLoader * _loader = NULL );
|
||||
|
||||
void clear( void );
|
||||
|
||||
int findText( const QString & _txt ) const;
|
||||
|
||||
inline const QString & currentText( void ) const
|
||||
{
|
||||
return( m_items[value()].first );
|
||||
}
|
||||
|
||||
inline const pixmapLoader * currentData( void ) const
|
||||
{
|
||||
return( m_items[value()].second );
|
||||
}
|
||||
|
||||
inline const QString & itemText( int _i ) const
|
||||
{
|
||||
return( m_items[tLimit<int>( _i, minValue(), maxValue() )].
|
||||
first );
|
||||
}
|
||||
|
||||
inline const pixmapLoader * itemPixmap( int _i ) const
|
||||
{
|
||||
return( m_items[tLimit<int>( _i, minValue(), maxValue() )].
|
||||
second );
|
||||
}
|
||||
|
||||
inline int size( void ) const
|
||||
{
|
||||
return( m_items.size() );
|
||||
}
|
||||
|
||||
private:
|
||||
typedef QPair<QString, pixmapLoader *> item;
|
||||
|
||||
QVector<item> m_items;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -36,7 +36,8 @@ class detuningHelper : public floatModel, public sharedObject
|
||||
{
|
||||
public:
|
||||
detuningHelper( void ) :
|
||||
autoModel( NULL )
|
||||
floatModel(),
|
||||
sharedObject()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QPixmap>
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "automatable_model_view.h"
|
||||
|
||||
|
||||
class fader : public QWidget, public floatModelView
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "automatable_model_view.h"
|
||||
#include "pixmap_button.h"
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
} ;
|
||||
|
||||
|
||||
typedef groupBox::autoModel groupBoxModel;
|
||||
typedef boolModel groupBoxModel;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* This file is based on the knob-widget of the Qwt Widget Library by
|
||||
* Josef Wilgen
|
||||
*
|
||||
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtCore/QPoint>
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "automatable_model_view.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
@@ -58,17 +58,21 @@ class knob : public QWidget, public floatModelView
|
||||
|
||||
Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth)
|
||||
|
||||
// Unfortunately, the gradient syntax doesn't create our gradient correctly
|
||||
// so we need to do this:
|
||||
// Unfortunately, the gradient syntax doesn't create our gradient
|
||||
// correctly so we need to do this:
|
||||
Q_PROPERTY(QColor outerColor READ outerColor WRITE setOuterColor)
|
||||
|
||||
public:
|
||||
knob( int _knob_num, QWidget * _parent, const QString & _name );
|
||||
virtual ~knob();
|
||||
|
||||
|
||||
void setHintText( const QString & _txt_before,
|
||||
const QString & _txt_after );
|
||||
// TODO: remove
|
||||
inline void setHintText( const QString & _txt_before,
|
||||
const QString & _txt_after )
|
||||
{
|
||||
setDescription( _txt_before );
|
||||
setUnit( _txt_after );
|
||||
}
|
||||
void setLabel( const QString & _txt );
|
||||
|
||||
void setTotalAngle( float _angle );
|
||||
@@ -92,10 +96,8 @@ public:
|
||||
QColor outerColor( void ) const;
|
||||
void setOuterColor( const QColor & _c );
|
||||
|
||||
|
||||
public slots:
|
||||
void reset( void );
|
||||
void copyValue( void );
|
||||
void pasteValue( void );
|
||||
virtual void enterValue( void );
|
||||
void connectToMidiDevice( void );
|
||||
void connectToController( void );
|
||||
@@ -110,7 +112,6 @@ signals:
|
||||
|
||||
|
||||
protected:
|
||||
static float s_copiedValue;
|
||||
static textFloat * s_textFloat;
|
||||
|
||||
float m_mouseOffset;
|
||||
@@ -118,8 +119,6 @@ protected:
|
||||
bool m_buttonPressed;
|
||||
|
||||
QPixmap * m_knobPixmap;
|
||||
QString m_hintTextBeforeValue;
|
||||
QString m_hintTextAfterValue;
|
||||
|
||||
// Styled knob stuff, could break out
|
||||
QPointF m_centerPoint;
|
||||
@@ -143,14 +142,15 @@ protected:
|
||||
|
||||
float getValue( const QPoint & _p );
|
||||
|
||||
QLineF calculateLine( const QPointF & _mid, float _radius, float _innerRadius = 1) const;
|
||||
QLineF calculateLine( const QPointF & _mid, float _radius,
|
||||
float _innerRadius = 1) const;
|
||||
|
||||
private:
|
||||
inline float pageSize( void ) const
|
||||
{
|
||||
return( tMax<float>( ( model()->maxValue() -
|
||||
model()->minValue() ) / 100.0f,
|
||||
model()->step() ) );
|
||||
modelUntyped()->step<float>() ) );
|
||||
}
|
||||
|
||||
virtual void doConnections( void );
|
||||
@@ -168,6 +168,6 @@ private:
|
||||
} ;
|
||||
|
||||
|
||||
typedef knob::autoModel knobModel;
|
||||
typedef floatModel knobModel;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* lcd_spinbox.h - class lcdSpinBox, an improved QLCDNumber
|
||||
*
|
||||
* Copyright (c) 2005-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -29,13 +29,13 @@
|
||||
#include <QtCore/QMap>
|
||||
#include <QtGui/QLCDNumber>
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "automatable_model_view.h"
|
||||
|
||||
|
||||
class QLabel;
|
||||
|
||||
|
||||
class lcdSpinBox : public QWidget, public automatableModelView<int>
|
||||
class lcdSpinBox : public QWidget, public intModelView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -102,6 +102,6 @@ signals:
|
||||
|
||||
} ;
|
||||
|
||||
typedef lcdSpinBox::autoModel lcdSpinBoxModel;
|
||||
typedef intModel lcdSpinBoxModel;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* level_object.h - declaration of class levelObject
|
||||
*
|
||||
* Copyright (c) 2006-2008 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
|
||||
*
|
||||
* 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 _LEVEL_OBJECT_H
|
||||
#define _LEVEL_OBJECT_H
|
||||
|
||||
#include <QtCore/QString>
|
||||
|
||||
|
||||
class levelObject
|
||||
{
|
||||
public:
|
||||
virtual ~levelObject()
|
||||
{
|
||||
}
|
||||
|
||||
inline int minLevel( void ) const
|
||||
{
|
||||
return( m_minLevel );
|
||||
}
|
||||
|
||||
inline int maxLevel( void ) const
|
||||
{
|
||||
return( m_maxLevel );
|
||||
}
|
||||
|
||||
virtual void setLevel( int _level ) = 0;
|
||||
|
||||
virtual QString levelToLabel( int _level ) const = 0;
|
||||
virtual int labelToLevel( QString _label ) = 0;
|
||||
|
||||
virtual QString displayName( void ) const
|
||||
{
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
int m_minLevel;
|
||||
int m_maxLevel;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -270,23 +270,20 @@ private:
|
||||
public:
|
||||
baseDetuning( detuningHelper * _detuning );
|
||||
|
||||
int level( void )
|
||||
void setValue( float _val )
|
||||
{
|
||||
return( m_level );
|
||||
m_value = _val;
|
||||
}
|
||||
|
||||
void setLevel( int _level );
|
||||
|
||||
float value( void )
|
||||
float value( void ) const
|
||||
{
|
||||
return( m_value );
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
int m_level;
|
||||
float m_value;
|
||||
detuningHelper * m_detuning;
|
||||
float m_value;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user