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:
71
ChangeLog
71
ChangeLog
@@ -1,3 +1,74 @@
|
||||
2008-05-28 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* plugins/organic/organic.cpp:
|
||||
* plugins/lb302/lb302.cpp:
|
||||
* plugins/bass_booster/bass_booster.cpp:
|
||||
* plugins/bass_booster/bassbooster_controls.cpp:
|
||||
* plugins/stereo_matrix/stereomatrix_controls.cpp:
|
||||
* plugins/vibed/nine_button_selector.h:
|
||||
* plugins/vibed/nine_button_selector.cpp:
|
||||
* plugins/vibed/vibed.cpp:
|
||||
* plugins/triple_oscillator/triple_oscillator.cpp:
|
||||
* plugins/audio_file_processor/audio_file_processor.cpp:
|
||||
* plugins/stereo_enhancer/stereoenhancer_controls.cpp:
|
||||
* plugins/sf2_player/sf2_player.cpp:
|
||||
* plugins/kicker/kicker.cpp:
|
||||
* plugins/midi_import/midi_import.cpp:
|
||||
* include/knob.h:
|
||||
* include/automatable_slider.h:
|
||||
* include/lcd_spinbox.h:
|
||||
* include/automatable_model.h:
|
||||
* include/combobox_model.h:
|
||||
* include/automation_pattern.h:
|
||||
* include/note_play_handle.h:
|
||||
* include/detuning_helper.h:
|
||||
* include/group_box.h:
|
||||
* include/automatable_button.h:
|
||||
* include/automatable_model_templates.h:
|
||||
* include/level_object.h:
|
||||
* include/automatable_model_view.h:
|
||||
* include/fader.h:
|
||||
* include/combobox.h:
|
||||
* src/gui/piano_roll.cpp:
|
||||
* src/gui/automatable_model_view.cpp:
|
||||
* src/gui/widgets/combobox.cpp:
|
||||
* src/gui/widgets/knob.cpp:
|
||||
* src/gui/widgets/envelope_and_lfo_view.cpp:
|
||||
* src/gui/widgets/automatable_slider.cpp:
|
||||
* src/gui/widgets/group_box.cpp:
|
||||
* src/gui/widgets/lcd_spinbox.cpp:
|
||||
* src/gui/widgets/volume_knob.cpp:
|
||||
* src/gui/widgets/fader.cpp:
|
||||
* src/gui/widgets/tempo_sync_knob.cpp:
|
||||
* src/gui/widgets/automatable_button.cpp:
|
||||
* src/gui/automation_editor.cpp:
|
||||
* src/tracks/instrument_track.cpp:
|
||||
* src/core/effect_chain.cpp:
|
||||
* src/core/note_play_handle.cpp:
|
||||
* src/core/song.cpp:
|
||||
* src/core/automatable_model.cpp:
|
||||
* src/core/audio/audio_alsa.cpp:
|
||||
* src/core/audio/audio_oss.cpp:
|
||||
* src/core/audio/audio_jack.cpp:
|
||||
* src/core/envelope_and_lfo_parameters.cpp:
|
||||
* src/core/combobox_model.cpp:
|
||||
* src/core/meter_model.cpp:
|
||||
* src/core/instrument_functions.cpp:
|
||||
* src/core/instrument_midi_io.cpp:
|
||||
* src/core/track.cpp:
|
||||
* src/core/ladspa_control.cpp:
|
||||
* src/core/note.cpp:
|
||||
* src/core/piano.cpp:
|
||||
* src/core/surround_area.cpp:
|
||||
* src/core/automation_pattern.cpp:
|
||||
* src/core/lfo_controller.cpp:
|
||||
* Makefile.am:
|
||||
reworked automatableModel (not template-based anymore), removed
|
||||
levelObject, splitted comboBox/comboBoxModel-source-files, began to
|
||||
unify context-menu-creation for controls
|
||||
|
||||
diffstat: 63 files changed, 1145 insertions(+), 1170 deletions(-)
|
||||
|
||||
2008-05-27 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
|
||||
* plugins/sf2_player/sf2_player.cpp:
|
||||
|
||||
10
Makefile.am
10
Makefile.am
@@ -50,6 +50,7 @@ man1_MANS = lmms.1
|
||||
|
||||
lmms_MOC = \
|
||||
./about_dialog.moc \
|
||||
./automatable_model.moc \
|
||||
./automatable_button.moc \
|
||||
./automatable_slider.moc \
|
||||
./automation_editor.moc \
|
||||
@@ -61,8 +62,9 @@ lmms_MOC = \
|
||||
./caption_menu.moc \
|
||||
./instrument_track.moc \
|
||||
./combobox.moc \
|
||||
./combobox_model.moc \
|
||||
./controller.moc \
|
||||
./controller_connection.moc \
|
||||
./controller_connection.moc \
|
||||
./controller_connection_dialog.moc \
|
||||
./controller_dialog.moc \
|
||||
./controller_rack_view.moc \
|
||||
@@ -165,13 +167,15 @@ THIRD_PARTY_CODE=$(LIBSAMPLERATE_SOURCES)
|
||||
|
||||
|
||||
lmms_SOURCES = \
|
||||
$(srcdir)/src/core/automatable_model.cpp \
|
||||
$(srcdir)/src/core/automation_pattern.cpp \
|
||||
$(srcdir)/src/core/base64.cpp \
|
||||
$(srcdir)/src/core/bb_track_container.cpp \
|
||||
$(srcdir)/src/core/clipboard.cpp \
|
||||
$(srcdir)/src/core/combobox_model.cpp \
|
||||
$(srcdir)/src/core/config_mgr.cpp \
|
||||
$(srcdir)/src/core/controller.cpp \
|
||||
$(srcdir)/src/core/controller_connection.cpp \
|
||||
$(srcdir)/src/core/controller_connection.cpp \
|
||||
$(srcdir)/src/core/drumsynth.cpp \
|
||||
$(srcdir)/src/core/effect_chain.cpp \
|
||||
$(srcdir)/src/core/effect.cpp \
|
||||
@@ -227,6 +231,7 @@ lmms_SOURCES = \
|
||||
$(srcdir)/src/core/midi/midi_oss.cpp \
|
||||
$(srcdir)/src/core/midi/midi_port.cpp \
|
||||
$(srcdir)/src/gui/about_dialog.cpp \
|
||||
$(srcdir)/src/gui/automatable_model_view.cpp \
|
||||
$(srcdir)/src/gui/automation_editor.cpp \
|
||||
$(srcdir)/src/gui/bb_editor.cpp \
|
||||
$(srcdir)/src/gui/controller_connection_dialog.cpp \
|
||||
@@ -419,6 +424,7 @@ lmms_SOURCES = \
|
||||
$(srcdir)/include/fade_button.h \
|
||||
$(srcdir)/include/fifo_buffer.h \
|
||||
$(srcdir)/include/combobox.h \
|
||||
$(srcdir)/include/combobox_model.h \
|
||||
$(srcdir)/include/rubberband.h \
|
||||
$(srcdir)/include/base64.h \
|
||||
$(srcdir)/include/journalling_object.h \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
|
||||
#include "audio_file_processor.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "engine.h"
|
||||
#include "song.h"
|
||||
#include "instrument_track.h"
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
|
||||
#include "bass_booster.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
|
||||
#undef SINGLE_SOURCE_COMPILE
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "bassbooster_controls.h"
|
||||
#include "bass_booster.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "knob.h"
|
||||
#include "note_play_handle.h"
|
||||
#include "sweep_oscillator.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
#undef SINGLE_SOURCE_COMPILE
|
||||
#include "embed.cpp"
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "note_play_handle.h"
|
||||
#include "templates.h"
|
||||
#include "audio_port.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
#undef SINGLE_SOURCE_COMPILE
|
||||
#include "embed.cpp"
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "instrument_track.h"
|
||||
#include "pattern.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "level_object.h"
|
||||
#include "instrument.h"
|
||||
#include "debug.h"
|
||||
#include "embed.h"
|
||||
@@ -182,7 +181,7 @@ invalid_format:
|
||||
automationPattern * tap = _tc->tempoAutomationPattern();
|
||||
if( tap != NULL )
|
||||
{
|
||||
tap->object()->setLevel( 120 );
|
||||
tap->object()->setValue( 120 );
|
||||
tap->putValue( 0, 120 );
|
||||
}
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ void organicInstrumentView::modelChanged( void )
|
||||
|
||||
oscillatorObject::oscillatorObject( model * _parent, track * _track ) :
|
||||
model( _parent ),
|
||||
m_waveShape( oscillator::SineWave, 0, oscillator::NumWaveShapes-1, 1, this ),
|
||||
m_waveShape( oscillator::SineWave, 0, oscillator::NumWaveShapes-1, this ),
|
||||
m_oscModel( 0.0f, 0.0f, 5.0f, 1.0f, this ),
|
||||
m_volModel( 100.0f, 0.0f, 100.0f, 1.0f, this ),
|
||||
m_panModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this ),
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "note_play_handle.h"
|
||||
#include "knob.h"
|
||||
#include "song.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
#include "main_window.h"
|
||||
#include "patches_dialog.h"
|
||||
@@ -77,8 +76,8 @@ sf2Instrument::sf2Instrument( instrumentTrack * _instrument_track ) :
|
||||
m_font( NULL ),
|
||||
m_fontId( 0 ),
|
||||
m_filename( "" ),
|
||||
m_bankNum( -1, -1, 999, 1, this ),
|
||||
m_patchNum( -1, -1, 127, 1, this ),
|
||||
m_bankNum( -1, -1, 999, this ),
|
||||
m_patchNum( -1, -1, 127, this ),
|
||||
m_gain( 1.0f, 0.0f, 5.0f, 0.01f, this ),
|
||||
m_reverbOn( 0, this ),
|
||||
m_reverbRoomSize( FLUID_REVERB_DEFAULT_ROOMSIZE, 0, 1.0, 0.01f, this ),
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "stereoenhancer_controls.h"
|
||||
#include "stereo_enhancer.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
|
||||
stereoEnhancerControls::stereoEnhancerControls( stereoEnhancerEffect * _eff ) :
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "stereomatrix_controls.h"
|
||||
#include "stereo_matrix.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
|
||||
stereoMatrixControls::stereoMatrixControls( stereoMatrixEffect * _eff ) :
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "song_editor.h"
|
||||
#include "tooltip.h"
|
||||
#include "volume_knob.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
|
||||
#undef SINGLE_SOURCE_COMPILE
|
||||
@@ -79,9 +78,9 @@ oscillatorObject::oscillatorObject( model * _parent, track * _track ) :
|
||||
m_phaseOffsetModel( 0.0f, 0.0f, 360.0f, 1.0f, this ),
|
||||
m_stereoPhaseDetuningModel( 0.0f, 0.0f, 360.0f, 1.0f, this ),
|
||||
m_waveShapeModel( oscillator::SineWave, 0, oscillator::NumWaveShapes-1,
|
||||
1, this ),
|
||||
this ),
|
||||
m_modulationAlgoModel( oscillator::SignalMix, 0,
|
||||
oscillator::NumModulationAlgos-1, 1, this ),
|
||||
oscillator::NumModulationAlgos-1, this ),
|
||||
m_sampleBuffer( new sampleBuffer ),
|
||||
m_volumeLeft( 0.0f ),
|
||||
m_volumeRight( 0.0f ),
|
||||
|
||||
@@ -53,7 +53,7 @@ nineButtonSelector::nineButtonSelector( QPixmap _button0_on,
|
||||
Uint32 _x, Uint32 _y,
|
||||
QWidget * _parent ):
|
||||
QWidget( _parent ),
|
||||
autoModelView( new nineButtonSelectorModel(0, 8, _default, 1, NULL, TRUE ) )
|
||||
intModelView( new nineButtonSelectorModel(0, 8, _default, NULL, TRUE ) )
|
||||
{
|
||||
setFixedSize( 50, 50 );
|
||||
m_base = QPixmap::grabWidget( _parent, _x, _y );
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
// };
|
||||
|
||||
protected:
|
||||
void FASTCALL setSelected( Uint8 _new_button );
|
||||
void setSelected( Uint8 _new_button );
|
||||
|
||||
public slots:
|
||||
void button0Clicked( void );
|
||||
@@ -93,6 +93,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
typedef nineButtonSelector::autoModel nineButtonSelectorModel;
|
||||
typedef intModel nineButtonSelectorModel;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
#include <QtGui/QWhatsThis>
|
||||
|
||||
#include "vibed.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
#include "engine.h"
|
||||
#include "instrument_track.h"
|
||||
#include "note_play_handle.h"
|
||||
@@ -111,7 +109,7 @@ vibed::vibed( instrumentTrack * instrument_track ) :
|
||||
led = new boolModel( harm==0, this );
|
||||
m_powerButtons.append( led );
|
||||
|
||||
harmonic = new nineButtonSelectorModel( 2, 0, 8, 1, this );
|
||||
harmonic = new nineButtonSelectorModel( 2, 0, 8, this );
|
||||
m_harmonics.append( harmonic );
|
||||
|
||||
graphTmp = new graphModel( -1.0, 1.0, m_sampleLength, this );
|
||||
|
||||
@@ -518,7 +518,7 @@ void audioALSA::setupWidget::saveSettings( void )
|
||||
configManager::inst()->setValue( "audioalsa", "device",
|
||||
m_device->text() );
|
||||
configManager::inst()->setValue( "audioalsa", "channels",
|
||||
QString::number( m_channels->value() ) );
|
||||
QString::number( m_channels->value<int>() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ void audioJACK::setupWidget::saveSettings( void )
|
||||
configManager::inst()->setValue( "audiojack", "clientname",
|
||||
m_clientName->text() );
|
||||
configManager::inst()->setValue( "audiojack", "channels",
|
||||
QString::number( m_channels->value() ) );
|
||||
QString::number( m_channels->value<int>() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ void audioOSS::setupWidget::saveSettings( void )
|
||||
configManager::inst()->setValue( "audiooss", "device",
|
||||
m_device->text() );
|
||||
configManager::inst()->setValue( "audiooss", "channels",
|
||||
QString::number( m_channels->value() ) );
|
||||
QString::number( m_channels->value<int>() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
456
src/core/automatable_model.cpp
Normal file
456
src/core/automatable_model.cpp
Normal file
@@ -0,0 +1,456 @@
|
||||
/*
|
||||
* automatable_model.cpp - some implementations of automatableModel-class
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <Qt/QtXml>
|
||||
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "automation_editor.h"
|
||||
|
||||
|
||||
float automatableModel::__copiedValue = 0;
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableModel::minEps<float>( void )
|
||||
{
|
||||
return( 1.0e-10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
automatableModel::automatableModel( DataType _type,
|
||||
const float _val,
|
||||
const float _min,
|
||||
const float _max,
|
||||
const float _step,
|
||||
::model * _parent,
|
||||
bool _default_constructed ) :
|
||||
model( _parent, _default_constructed ),
|
||||
m_dataType( _type ),
|
||||
m_value( _val ),
|
||||
m_initValue( _val ),
|
||||
m_minValue( _min ),
|
||||
m_maxValue( _max ),
|
||||
m_step( _step ),
|
||||
m_range( _max - _min ),
|
||||
m_journalEntryReady( FALSE ),
|
||||
m_controllerConnection( NULL ),
|
||||
m_automationPattern( NULL ),
|
||||
m_track( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
automatableModel::~automatableModel()
|
||||
{
|
||||
delete m_automationPattern;
|
||||
while( m_linkedModels.empty() == FALSE )
|
||||
{
|
||||
m_linkedModels.last()->unlinkModel( this );
|
||||
m_linkedModels.erase( m_linkedModels.end() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void automatableModel::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, m_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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::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() );
|
||||
setValue( 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( _this.attribute( _name ).toFloat() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::setValue( const float _value )
|
||||
{
|
||||
const float old_val = m_value;
|
||||
|
||||
m_value = fittedValue( _value );
|
||||
if( old_val != m_value )
|
||||
{
|
||||
// add changes to history so user can undo it
|
||||
addJournalEntry( journalEntry( 0, m_value - 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 )
|
||||
{
|
||||
if( value<float>() != (*it)->value<float>() &&
|
||||
(*it)->fittedValue( value<float>() )
|
||||
!= (*it)->value<float>() )
|
||||
{
|
||||
bool journalling = (*it)->testAndSetJournalling(
|
||||
isJournalling() );
|
||||
(*it)->setValue( value<float>() );
|
||||
(*it)->setJournalling( journalling );
|
||||
}
|
||||
}
|
||||
setFirstValue();
|
||||
emit dataChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit dataUnchanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::setRange( const float _min, const float _max,
|
||||
const float _step )
|
||||
{
|
||||
if( ( m_maxValue != _max ) || ( m_minValue != _min ) )
|
||||
{
|
||||
m_minValue = _min;
|
||||
m_maxValue = _max;
|
||||
if( m_minValue > m_maxValue )
|
||||
{
|
||||
qSwap<float>( m_minValue, m_maxValue );
|
||||
}
|
||||
m_range = m_maxValue - m_minValue;
|
||||
setStep( _step );
|
||||
|
||||
// re-adjust value
|
||||
setInitValue( value<float>() );
|
||||
|
||||
emit propertiesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::setStep( const float _step )
|
||||
{
|
||||
if( m_step != _step )
|
||||
{
|
||||
m_step = _step;
|
||||
emit propertiesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float automatableModel::fittedValue( float _value ) const
|
||||
{
|
||||
_value = tLimit<float>( _value, m_minValue, m_maxValue );
|
||||
|
||||
if( m_step != 0 )
|
||||
{
|
||||
_value = roundf( _value / m_step ) * m_step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = m_minValue;
|
||||
}
|
||||
|
||||
// correct rounding error at the border
|
||||
if( tAbs<float>( _value - m_maxValue ) <
|
||||
minEps<float>() * tAbs<float>( m_step ) )
|
||||
{
|
||||
_value = m_maxValue;
|
||||
}
|
||||
|
||||
// correct rounding error if value = 0
|
||||
if( tAbs<float>( _value ) < minEps<float>() * tAbs<float>( m_step ) )
|
||||
{
|
||||
_value = 0;
|
||||
}
|
||||
|
||||
return( _value );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::redoStep( journalEntry & _je )
|
||||
{
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
setValue( value<float>() + _je.data().toDouble() );
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::undoStep( journalEntry & _je )
|
||||
{
|
||||
journalEntry je( _je.actionID(), -_je.data().toDouble() );
|
||||
redoStep( je );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::prepareJournalEntryFromOldVal( void )
|
||||
{
|
||||
m_oldValue = value<float>();
|
||||
saveJournallingState( FALSE );
|
||||
m_journalEntryReady = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::addJournalEntryFromOldToCurVal( void )
|
||||
{
|
||||
if( m_journalEntryReady )
|
||||
{
|
||||
restoreJournallingState();
|
||||
if( value<float>() != m_oldValue )
|
||||
{
|
||||
addJournalEntry( journalEntry( 0, value<float>() -
|
||||
m_oldValue ) );
|
||||
}
|
||||
m_journalEntryReady = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::linkModel( automatableModel * _model )
|
||||
{
|
||||
if( qFind( m_linkedModels.begin(), m_linkedModels.end(), _model )
|
||||
== m_linkedModels.end() )
|
||||
{
|
||||
m_linkedModels.push_back( _model );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::unlinkModel( automatableModel * _model )
|
||||
{
|
||||
if( qFind( m_linkedModels.begin(), m_linkedModels.end(), _model )
|
||||
!= m_linkedModels.end() )
|
||||
{
|
||||
m_linkedModels.erase( qFind( m_linkedModels.begin(),
|
||||
m_linkedModels.end(),
|
||||
_model ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::linkModels( automatableModel * _model1,
|
||||
automatableModel * _model2 )
|
||||
{
|
||||
_model1->linkModel( _model2 );
|
||||
_model2->linkModel( _model1 );
|
||||
|
||||
if( _model1->m_automationPattern != _model2->m_automationPattern )
|
||||
{
|
||||
delete _model2->m_automationPattern;
|
||||
_model2->m_automationPattern = _model1->m_automationPattern;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::unlinkModels( automatableModel * _model1,
|
||||
automatableModel * _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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::initAutomationPattern( void )
|
||||
{
|
||||
m_automationPattern = new automationPattern( NULL, this );
|
||||
}
|
||||
|
||||
automationPattern * automatableModel::getAutomationPattern( void )
|
||||
{
|
||||
if( !m_automationPattern )
|
||||
{
|
||||
m_automationPattern = new automationPattern( m_track, this );
|
||||
setFirstValue();
|
||||
// syncAutomationPattern();
|
||||
}
|
||||
return( m_automationPattern );
|
||||
}
|
||||
|
||||
|
||||
void automatableModel::setFirstValue( void )
|
||||
{
|
||||
if( m_automationPattern && m_automationPattern->updateFirst() )
|
||||
{
|
||||
m_automationPattern->putValue( 0, m_value, FALSE );
|
||||
if( engine::getAutomationEditor() &&
|
||||
engine::getAutomationEditor()->currentPattern()
|
||||
== m_automationPattern )
|
||||
{
|
||||
engine::getAutomationEditor()->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::setInitValue( const float _value )
|
||||
{
|
||||
m_initValue = _value;
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
setValue( _value );
|
||||
if( m_automationPattern )
|
||||
{
|
||||
setFirstValue();
|
||||
}
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void automatableModel::reset( void )
|
||||
{
|
||||
setValue( initValue<float>() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::copyValue( void )
|
||||
{
|
||||
__copiedValue = value<float>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::pasteValue( void )
|
||||
{
|
||||
setValue( __copiedValue );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "automatable_model.moc"
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
|
||||
#include "automation_pattern.h"
|
||||
#include "automation_editor.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "engine.h"
|
||||
#include "level_object.h"
|
||||
#include "note.h"
|
||||
#include "templates.h"
|
||||
#include "track.h"
|
||||
@@ -41,7 +39,8 @@
|
||||
|
||||
|
||||
|
||||
automationPattern::automationPattern( track * _track, levelObject * _object ) :
|
||||
automationPattern::automationPattern( track * _track,
|
||||
automatableModel * _object ) :
|
||||
m_track( _track ),
|
||||
m_object( _object ),
|
||||
m_update_first( TRUE ),
|
||||
@@ -76,7 +75,7 @@ automationPattern::automationPattern( const automationPattern & _pat_to_copy ) :
|
||||
|
||||
|
||||
automationPattern::automationPattern( const automationPattern & _pat_to_copy,
|
||||
levelObject * _object ) :
|
||||
automatableModel * _object ) :
|
||||
m_track( _pat_to_copy.m_track ),
|
||||
m_object( _object ),
|
||||
m_update_first( _pat_to_copy.m_update_first ),
|
||||
@@ -117,17 +116,17 @@ automationPattern::~automationPattern()
|
||||
//TODO: Improve this
|
||||
midiTime automationPattern::length( void ) const
|
||||
{
|
||||
Sint32 max_length = 0;
|
||||
tick max_length = 0;
|
||||
|
||||
for( timeMap::const_iterator it = m_time_map.begin();
|
||||
it != m_time_map.end();
|
||||
++it )
|
||||
{
|
||||
max_length = tMax<Sint32>( max_length, -it.key() );
|
||||
max_length = tMax<tick>( max_length, -it.key() );
|
||||
}
|
||||
if( max_length % DefaultTicksPerTact == 0 )
|
||||
{
|
||||
return( midiTime( tMax<Sint32>( max_length,
|
||||
return( midiTime( tMax<tick>( max_length,
|
||||
DefaultTicksPerTact ) ) );
|
||||
}
|
||||
return( midiTime( tMax( midiTime( max_length ).getTact() + 1, 1 ),
|
||||
@@ -137,7 +136,7 @@ midiTime automationPattern::length( void ) const
|
||||
|
||||
|
||||
|
||||
midiTime automationPattern::putValue( const midiTime & _time, const int _value,
|
||||
midiTime automationPattern::putValue( const midiTime & _time, const float _value,
|
||||
const bool _quant_pos )
|
||||
{
|
||||
midiTime new_time = _quant_pos && engine::getAutomationEditor() ?
|
||||
@@ -171,7 +170,7 @@ void automationPattern::removeValue( const midiTime & _time )
|
||||
if( m_time_map.size() == 1 )
|
||||
{
|
||||
m_dynamic = FALSE;
|
||||
m_object->setLevel( m_time_map[0] );
|
||||
m_object->setValue( m_time_map[0] );
|
||||
if( m_track )
|
||||
{
|
||||
m_track->removeAutomationPattern( this );
|
||||
@@ -196,7 +195,7 @@ void automationPattern::clear( void )
|
||||
|
||||
|
||||
|
||||
int automationPattern::valueAt( const midiTime & _time )
|
||||
float automationPattern::valueAt( const midiTime & _time )
|
||||
{
|
||||
return( m_time_map.lowerBound( -_time ).value() );
|
||||
}
|
||||
@@ -211,8 +210,7 @@ void automationPattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
{
|
||||
QDomElement element = _doc.createElement( "time" );
|
||||
element.setAttribute( "pos", -it.key() );
|
||||
element.setAttribute( "value", m_object->levelToLabel(
|
||||
it.value() ) );
|
||||
element.setAttribute( "value", it.value() );
|
||||
_this.appendChild( element );
|
||||
}
|
||||
}
|
||||
@@ -233,8 +231,7 @@ void automationPattern::loadSettings( const QDomElement & _this )
|
||||
continue;
|
||||
}
|
||||
m_time_map[-element.attribute( "pos" ).toInt()]
|
||||
= m_object->labelToLevel(
|
||||
element.attribute( "value" ) );
|
||||
= element.attribute( "value" ).toFloat();
|
||||
}
|
||||
|
||||
if( !m_dynamic )
|
||||
@@ -281,7 +278,7 @@ void automationPattern::processMidiTime( const midiTime & _time )
|
||||
{
|
||||
if( _time >= 0 )
|
||||
{
|
||||
m_object->setLevel( m_time_map.lowerBound( -_time ).value() );
|
||||
m_object->setValue( m_time_map.lowerBound( -_time ).value() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* level_object.h - declaration of class levelObject
|
||||
* combobox_model.cpp - implementation of comboBoxModel
|
||||
*
|
||||
* Copyright (c) 2006-2008 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -21,48 +21,51 @@
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "combobox_model.h"
|
||||
#include "embed.h"
|
||||
|
||||
|
||||
#ifndef _LEVEL_OBJECT_H
|
||||
#define _LEVEL_OBJECT_H
|
||||
|
||||
#include <QtCore/QString>
|
||||
|
||||
|
||||
class levelObject
|
||||
void comboBoxModel::addItem( const QString & _item, pixmapLoader * _pl )
|
||||
{
|
||||
public:
|
||||
virtual ~levelObject()
|
||||
m_items.push_back( qMakePair( _item, _pl ) );
|
||||
setRange( 0, m_items.size() - 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void comboBoxModel::clear( void )
|
||||
{
|
||||
setRange( 0, 0 );
|
||||
foreach( const item & _i, m_items )
|
||||
{
|
||||
delete _i.second;
|
||||
}
|
||||
m_items.clear();
|
||||
emit propertiesChanged();
|
||||
}
|
||||
|
||||
inline int minLevel( void ) const
|
||||
|
||||
|
||||
|
||||
int comboBoxModel::findText( const QString & _txt ) const
|
||||
{
|
||||
for( QVector<item>::const_iterator it = m_items.begin();
|
||||
it != m_items.end(); ++it )
|
||||
{
|
||||
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 );
|
||||
if( ( *it ).first == _txt )
|
||||
{
|
||||
return( it - m_items.begin() );
|
||||
}
|
||||
}
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
int m_minLevel;
|
||||
int m_maxLevel;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
#include "combobox_model.moc"
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "effect_chain.h"
|
||||
#include "effect.h"
|
||||
#include "engine.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "track.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ envelopeAndLFOParameters::envelopeAndLFOParameters(
|
||||
m_lfoAttackModel( 0.0, 0.0, 1.0, 0.001, this ),
|
||||
m_lfoSpeedModel( 0.1, 0.01, 1.0, 0.0001, 20000.0, this ),
|
||||
m_lfoAmountModel( 0.0, -1.0, 1.0, 0.005, this ),
|
||||
m_lfoWaveModel( SineWave, 0, NumLfoShapes, 1, this ),
|
||||
m_lfoWaveModel( SineWave, 0, NumLfoShapes, this ),
|
||||
m_x100Model( FALSE, this ),
|
||||
m_controlEnvAmountModel( FALSE, this ),
|
||||
m_lfoFrame( 0 ),
|
||||
|
||||
@@ -287,7 +287,7 @@ arpeggiator::arpeggiator( instrumentTrack * _instrument_track ) :
|
||||
m_arpRangeModel( 1.0f, 1.0f, 9.0f, 1.0f, this ),
|
||||
m_arpTimeModel( 100.0f, 25.0f, 2000.0f, 1.0f, 1.0, this ),
|
||||
m_arpGateModel( 100.0f, 1.0f, 200.0f, 1.0f, this ),
|
||||
m_arpDirectionModel( 0, 0, NumArpDirections, intModel::defaultRelStep(), this ),
|
||||
m_arpDirectionModel( 0, 0, NumArpDirections, this ),
|
||||
m_arpModeModel( this )
|
||||
{
|
||||
m_arpEnabledModel.setTrack( _instrument_track );
|
||||
|
||||
@@ -43,11 +43,9 @@ instrumentMidiIO::instrumentMidiIO( instrumentTrack * _instrument_track,
|
||||
m_instrumentTrack( _instrument_track ),
|
||||
m_midiPort( _port ),
|
||||
m_inputChannelModel( m_midiPort->inputChannel() + 1,
|
||||
0, MIDI_CHANNEL_COUNT,
|
||||
intModel::defaultRelStep(), this ),
|
||||
0, MIDI_CHANNEL_COUNT, this ),
|
||||
m_outputChannelModel( m_midiPort->outputChannel() + 1,
|
||||
1, MIDI_CHANNEL_COUNT,
|
||||
intModel::defaultRelStep(), this ),
|
||||
1, MIDI_CHANNEL_COUNT, this ),
|
||||
m_receiveEnabledModel( FALSE, this ),
|
||||
m_sendEnabledModel( FALSE, this ),
|
||||
m_defaultVelocityInEnabledModel( FALSE, this ),
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
|
||||
#include "ladspa_control.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "ladspa_base.h"
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ lfoController::lfoController( model * _parent ) :
|
||||
m_lfoSpeedModel( 0.1, 0.01, 5.0, 0.0001, 20000.0, this ),
|
||||
m_lfoAmountModel( 1.0, -1.0, 1.0, 0.005, this ),
|
||||
m_lfoPhaseModel( 0.0, 0.0, 360.0, 4.0, this ),
|
||||
m_lfoWaveModel( oscillator::SineWave, 0, oscillator::NumWaveShapes, 1, this ),
|
||||
m_lfoWaveModel( oscillator::SineWave, 0, oscillator::NumWaveShapes, this ),
|
||||
m_duration( 1000 ),
|
||||
m_phaseCorrection( 0 ),
|
||||
m_phaseOffset( 0 ),
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
meterModel::meterModel( ::model * _parent, track * _track ) :
|
||||
model( _parent ),
|
||||
m_numeratorModel( 4, 1, 32, 1, this ),
|
||||
m_denominatorModel( 4, 1, 32, 1, this )
|
||||
m_numeratorModel( 4, 1, 32, this ),
|
||||
m_denominatorModel( 4, 1, 32, this )
|
||||
{
|
||||
m_numeratorModel.setTrack( _track );
|
||||
m_denominatorModel.setTrack( _track );
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "note.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "detuning_helper.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
|
||||
#include "note_play_handle.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "config_mgr.h"
|
||||
#include "detuning_helper.h"
|
||||
#include "instrument_sound_shaping.h"
|
||||
@@ -38,21 +37,14 @@
|
||||
|
||||
inline notePlayHandle::baseDetuning::baseDetuning(
|
||||
detuningHelper * _detuning ) :
|
||||
m_detuning( _detuning )
|
||||
m_detuning( _detuning ),
|
||||
m_value( m_detuning->getAutomationPattern()->valueAt( 0 ) )
|
||||
{
|
||||
m_level = m_detuning->getAutomationPattern()->valueAt( 0 );
|
||||
m_value = m_detuning->levelToValue( m_level );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline void notePlayHandle::baseDetuning::setLevel( int _level )
|
||||
{
|
||||
m_level = _level;
|
||||
m_value = m_detuning->levelToValue( m_level );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -462,11 +454,11 @@ void notePlayHandle::processMidiTime( const midiTime & _time )
|
||||
{
|
||||
if( _time >= pos() )
|
||||
{
|
||||
int level = detuning()->getAutomationPattern()->valueAt( _time -
|
||||
float v = detuning()->getAutomationPattern()->valueAt( _time -
|
||||
pos() );
|
||||
if( level != m_base_detuning->level() )
|
||||
if( v != m_base_detuning->value() )
|
||||
{
|
||||
m_base_detuning->setLevel( level );
|
||||
m_base_detuning->setValue( v );
|
||||
updateFrequency();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
|
||||
|
||||
#include "caption_menu.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "embed.h"
|
||||
#include "gui_templates.h"
|
||||
#include "instrument_track.h"
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
|
||||
|
||||
#include "automation_track.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "automation_editor.h"
|
||||
#include "bb_editor.h"
|
||||
#include "bb_track.h"
|
||||
@@ -79,12 +78,11 @@ tick midiTime::s_ticksPerTact = DefaultTicksPerTact;
|
||||
song::song( void ) :
|
||||
trackContainer(),
|
||||
m_automationTrack( track::create( track::AutomationTrack, this ) ),
|
||||
m_tempoModel( DefaultTempo, MinTempo, MaxTempo,
|
||||
intModel::defaultRelStep(), this ),
|
||||
m_tempoModel( DefaultTempo, MinTempo, MaxTempo, this ),
|
||||
m_timeSigModel( this, m_automationTrack ),
|
||||
m_oldTicksPerTact( DefaultTicksPerTact ),
|
||||
m_masterVolumeModel( 100, 0, 200, 1, this ),
|
||||
m_masterPitchModel( 0, -12, 12, 1, this ),
|
||||
m_masterVolumeModel( 100, 0, 200, this ),
|
||||
m_masterPitchModel( 0, -12, 12, this ),
|
||||
m_fileName(),
|
||||
m_oldFileName(),
|
||||
m_modified( FALSE ),
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <Qt/QtXml>
|
||||
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
#include "templates.h"
|
||||
@@ -188,8 +187,8 @@ void surroundArea::mouseReleaseEvent( QMouseEvent * )
|
||||
surroundAreaModel::surroundAreaModel( ::model * _parent, track * _track,
|
||||
bool _default_constructed ) :
|
||||
model( _parent, _default_constructed ),
|
||||
m_posX( 0, -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, 1, _parent ),
|
||||
m_posY( 0, -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, 1, _parent )
|
||||
m_posX( 0, -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, _parent ),
|
||||
m_posY( 0, -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, _parent )
|
||||
{
|
||||
m_posX.setTrack( _track );
|
||||
m_posY.setTrack( _track );
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
#include "automation_pattern.h"
|
||||
#include "automation_track.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "bb_editor.h"
|
||||
#include "bb_track.h"
|
||||
#include "bb_track_container.h"
|
||||
|
||||
75
src/gui/automatable_model_view.cpp
Normal file
75
src/gui/automatable_model_view.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* automatable_model_view.cpp - implementation of 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QMenu>
|
||||
|
||||
|
||||
#include "automatable_model_view.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "embed.h"
|
||||
|
||||
|
||||
void automatableModelView::addDefaultActions( QMenu * _menu )
|
||||
{
|
||||
automatableModel * _model = modelUntyped();
|
||||
|
||||
_menu->addAction( embed::getIconPixmap( "reload" ),
|
||||
automatableModel::tr( "&Reset (%1%2)" ).
|
||||
arg( _model->displayValue(
|
||||
_model->initValue<float>() ) ).
|
||||
arg( m_unit ),
|
||||
_model, SLOT( reset() ) );
|
||||
_menu->addSeparator();
|
||||
_menu->addAction( embed::getIconPixmap( "edit_copy" ),
|
||||
automatableModel::tr( "&Copy value (%1%2)" ).
|
||||
arg( _model->displayValue(
|
||||
_model->value<float>() ) ).
|
||||
arg( m_unit ),
|
||||
_model, SLOT( copyValue() ) );
|
||||
_menu->addAction( embed::getIconPixmap( "edit_paste" ),
|
||||
automatableModel::tr( "&Paste value (%1%2)").
|
||||
arg( _model->displayValue(
|
||||
automatableModel::copiedValue() ) ).
|
||||
arg( m_unit ),
|
||||
_model, SLOT( pasteValue() ) );
|
||||
|
||||
_menu->addSeparator();
|
||||
|
||||
if( !_model->nullTrack() )
|
||||
{
|
||||
_menu->addAction( embed::getIconPixmap( "automation" ),
|
||||
automatableModel::tr( "&Open in automation editor" ),
|
||||
_model->getAutomationPattern(),
|
||||
SLOT( openInAutomationEditor() ) );
|
||||
_menu->addSeparator();
|
||||
}
|
||||
|
||||
_menu->addAction( embed::getIconPixmap( "controller" ),
|
||||
automatableModel::tr( "Connect to controller..." ),
|
||||
dynamic_cast<QObject *>( this ),
|
||||
SLOT( connectToController() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -389,8 +389,8 @@ void automationEditor::setCurrentPattern( automationPattern * _new_pattern )
|
||||
return;
|
||||
}
|
||||
|
||||
m_min_level = m_pattern->object()->minLevel();
|
||||
m_max_level = m_pattern->object()->maxLevel();
|
||||
m_min_level = m_pattern->object()->minValue<float>();
|
||||
m_max_level = m_pattern->object()->maxValue<float>();
|
||||
m_scroll_level = ( m_min_level + m_max_level ) / 2;
|
||||
|
||||
timeMap & time_map = m_pattern->getTimeMap();
|
||||
@@ -1203,7 +1203,7 @@ void automationEditor::paintEvent( QPaintEvent * _pe )
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
const QString & label = m_pattern->object()
|
||||
->levelToLabel( level[i] );
|
||||
->displayValue( level[i] );
|
||||
p.setPen( QColor( 240, 240, 240 ) );
|
||||
p.drawText( 1, y[i] - font_height + 1,
|
||||
VALUES_WIDTH - 10, 2 * font_height,
|
||||
@@ -1232,7 +1232,7 @@ void automationEditor::paintEvent( QPaintEvent * _pe )
|
||||
y -= printable * m_y_delta, level += printable )
|
||||
{
|
||||
const QString & label = m_pattern->object()
|
||||
->levelToLabel( level );
|
||||
->displayValue( level );
|
||||
p.setPen( QColor( 240, 240, 240 ) );
|
||||
p.drawText( 1, y - font_height + 1,
|
||||
VALUES_WIDTH - 10, 2 * font_height,
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "clipboard.h"
|
||||
#include "combobox.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <QtGui/QCursor>
|
||||
#include <QtGui/QMouseEvent>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
|
||||
@@ -41,8 +40,7 @@
|
||||
automatableButton::automatableButton( QWidget * _parent,
|
||||
const QString & _name ) :
|
||||
QPushButton( _parent ),
|
||||
autoModelView( new autoModel( FALSE, FALSE, TRUE,
|
||||
autoModel::defaultRelStep(), NULL, TRUE ) ),
|
||||
boolModelView( new boolModel( FALSE, NULL, TRUE ) ),
|
||||
m_group( NULL )
|
||||
{
|
||||
setAccessibleName( _name );
|
||||
@@ -179,7 +177,7 @@ void automatableButton::toggle( void )
|
||||
automatableButtonGroup::automatableButtonGroup( QWidget * _parent,
|
||||
const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) )
|
||||
intModelView( new intModel( 0, 0, 0, NULL, TRUE ) )
|
||||
{
|
||||
hide();
|
||||
setAccessibleName( _name );
|
||||
@@ -246,7 +244,7 @@ void automatableButtonGroup::modelChanged( void )
|
||||
{
|
||||
connect( model(), SIGNAL( dataChanged() ),
|
||||
this, SLOT( updateButtons() ) );
|
||||
autoModelView::modelChanged();
|
||||
intModelView::modelChanged();
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <QtGui/QCursor>
|
||||
#include <QtGui/QMouseEvent>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
#include "knob.h"
|
||||
@@ -41,7 +40,7 @@
|
||||
|
||||
automatableSlider::automatableSlider( QWidget * _parent, const QString & _name ) :
|
||||
QSlider( _parent ),
|
||||
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
intModelView( new intModel( 0, 0, 0, NULL, TRUE ) ),
|
||||
m_showStatus( FALSE )
|
||||
{
|
||||
setAccessibleName( _name );
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QStyleOptionFrame>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
@@ -51,7 +50,7 @@ const int CB_ARROW_BTN_WIDTH = 20;
|
||||
|
||||
comboBox::comboBox( QWidget * _parent, const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new comboBoxModel ),
|
||||
intModelView( new comboBoxModel ),
|
||||
m_menu( this ),
|
||||
m_pressed( FALSE )
|
||||
{
|
||||
@@ -102,10 +101,7 @@ void comboBox::contextMenuEvent( QContextMenuEvent * _me )
|
||||
}
|
||||
|
||||
captionMenu contextMenu( accessibleName() );
|
||||
contextMenu.addAction( embed::getIconPixmap( "automation" ),
|
||||
tr( "&Open in automation editor" ),
|
||||
model()->getAutomationPattern(),
|
||||
SLOT( openInAutomationEditor() ) );
|
||||
addDefaultActions( &contextMenu );
|
||||
contextMenu.exec( QCursor::pos() );
|
||||
}
|
||||
|
||||
@@ -244,51 +240,6 @@ void comboBox::setItem( QAction * _item )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void comboBoxModel::addItem( const QString & _item, pixmapLoader * _pl )
|
||||
{
|
||||
m_items.push_back( qMakePair( _item, _pl ) );
|
||||
setRange( 0, m_items.size() - 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void comboBoxModel::clear( void )
|
||||
{
|
||||
setRange( 0, 0 );
|
||||
foreach( const item & _i, m_items )
|
||||
{
|
||||
delete _i.second;
|
||||
}
|
||||
m_items.clear();
|
||||
emit propertiesChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int comboBoxModel::findText( const QString & _txt ) const
|
||||
{
|
||||
for( QVector<item>::const_iterator it = m_items.begin();
|
||||
it != m_items.end(); ++it )
|
||||
{
|
||||
if( ( *it ).first == _txt )
|
||||
{
|
||||
return( it - m_items.begin() );
|
||||
}
|
||||
}
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "combobox.moc"
|
||||
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ void envelopeAndLFOView::mousePressEvent( QMouseEvent * _me )
|
||||
if( QRect( ENV_GRAPH_X, ENV_GRAPH_Y, s_envGraph->width(),
|
||||
s_envGraph->height() ).contains( _me->pos() ) == TRUE )
|
||||
{
|
||||
if( m_amountKnob->value() < 1.0f )
|
||||
if( m_amountKnob->value<float>() < 1.0f )
|
||||
{
|
||||
m_amountKnob->setValue( 1.0f );
|
||||
}
|
||||
@@ -373,7 +373,7 @@ void envelopeAndLFOView::mousePressEvent( QMouseEvent * _me )
|
||||
else if( QRect( LFO_GRAPH_X, LFO_GRAPH_Y, s_lfoGraph->width(),
|
||||
s_lfoGraph->height() ).contains( _me->pos() ) == TRUE )
|
||||
{
|
||||
if( m_lfoAmountKnob->value() < 1.0f )
|
||||
if( m_lfoAmountKnob->value<float>() < 1.0f )
|
||||
{
|
||||
m_lfoAmountKnob->setValue( 1.0f );
|
||||
}
|
||||
@@ -438,7 +438,7 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * )
|
||||
|
||||
p.setFont( pointSize<8>( p.font() ) );
|
||||
|
||||
const float gray_amount = 1.0f - fabsf( m_amountKnob->value() );
|
||||
const float gray_amount = 1.0f - fabsf( m_amountKnob->value<float>() );
|
||||
|
||||
p.setPen( QPen( QColor( static_cast<int>( 96 * gray_amount ),
|
||||
static_cast<int>( 255 - 159 * gray_amount ),
|
||||
@@ -451,44 +451,44 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * )
|
||||
const int y_base = ENV_GRAPH_Y + s_envGraph->height() - 3;
|
||||
const int avail_height = s_envGraph->height() - 6;
|
||||
|
||||
int x1 = ENV_GRAPH_X + 2 + static_cast<int>( m_predelayKnob->value() *
|
||||
int x1 = ENV_GRAPH_X + 2 + static_cast<int>( m_predelayKnob->value<float>() *
|
||||
TIME_UNIT_WIDTH );
|
||||
int x2 = x1 + static_cast<int>( m_attackKnob->value() *
|
||||
int x2 = x1 + static_cast<int>( m_attackKnob->value<float>() *
|
||||
TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, y_base, x2, y_base - avail_height );
|
||||
p.fillRect( x1 - 1, y_base - 2, 4, 4, end_points_bg_color );
|
||||
p.fillRect( x1, y_base - 1, 2, 2, end_points_color );
|
||||
x1 = x2;
|
||||
x2 = x1 + static_cast<int>( m_holdKnob->value() * TIME_UNIT_WIDTH );
|
||||
x2 = x1 + static_cast<int>( m_holdKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, y_base - avail_height, x2, y_base - avail_height );
|
||||
p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4,
|
||||
end_points_bg_color );
|
||||
p.fillRect( x1, y_base-1-avail_height, 2, 2, end_points_color );
|
||||
x1 = x2;
|
||||
x2 = x1 + static_cast<int>( ( m_decayKnob->value() *
|
||||
m_sustainKnob->value() ) *
|
||||
x2 = x1 + static_cast<int>( ( m_decayKnob->value<float>() *
|
||||
m_sustainKnob->value<float>() ) *
|
||||
TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, y_base-avail_height, x2, static_cast<int>( y_base -
|
||||
avail_height +
|
||||
m_sustainKnob->value() * avail_height ) );
|
||||
m_sustainKnob->value<float>() * avail_height ) );
|
||||
p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4,
|
||||
end_points_bg_color );
|
||||
p.fillRect( x1, y_base - 1 - avail_height, 2, 2, end_points_color );
|
||||
x1 = x2;
|
||||
x2 = x1 + static_cast<int>( m_releaseKnob->value() * TIME_UNIT_WIDTH );
|
||||
x2 = x1 + static_cast<int>( m_releaseKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, static_cast<int>( y_base - avail_height +
|
||||
m_sustainKnob->value() *
|
||||
m_sustainKnob->value<float>() *
|
||||
avail_height ), x2, y_base );
|
||||
p.fillRect( x1-1, static_cast<int>( y_base - avail_height +
|
||||
m_sustainKnob->value() *
|
||||
m_sustainKnob->value<float>() *
|
||||
avail_height ) - 2, 4, 4,
|
||||
end_points_bg_color );
|
||||
p.fillRect( x1, static_cast<int>( y_base - avail_height +
|
||||
m_sustainKnob->value() *
|
||||
m_sustainKnob->value<float>() *
|
||||
avail_height ) - 1, 2, 2,
|
||||
end_points_color );
|
||||
p.fillRect( x2 - 1, y_base - 2, 4, 4, end_points_bg_color );
|
||||
@@ -503,7 +503,7 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * )
|
||||
const float frames_for_graph = SECS_PER_LFO_OSCILLATION *
|
||||
engine::getMixer()->baseSampleRate() / 10;
|
||||
|
||||
const float lfo_gray_amount = 1.0f - fabsf( m_lfoAmountKnob->value() );
|
||||
const float lfo_gray_amount = 1.0f - fabsf( m_lfoAmountKnob->value<float>() );
|
||||
p.setPen( QPen( QColor( static_cast<int>( 96 * lfo_gray_amount ),
|
||||
static_cast<int>( 255 - 159 * lfo_gray_amount ),
|
||||
static_cast<int>( 128 - 32 *
|
||||
@@ -563,7 +563,7 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * )
|
||||
|
||||
p.setPen( QColor( 255, 192, 0 ) );
|
||||
int ms_per_osc = static_cast<int>( SECS_PER_LFO_OSCILLATION *
|
||||
m_lfoSpeedKnob->value() *
|
||||
m_lfoSpeedKnob->value<float>() *
|
||||
1000.0f );
|
||||
p.drawText( LFO_GRAPH_X + 4, LFO_GRAPH_Y + s_lfoGraph->height() - 6,
|
||||
tr( "ms/LFO:" ) );
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
#include "embed.h"
|
||||
#include "caption_menu.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ QPixmap * groupBox::s_ledBg = NULL;
|
||||
|
||||
groupBox::groupBox( const QString & _caption, QWidget * _parent ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( NULL ),
|
||||
boolModelView( NULL ),
|
||||
m_caption( _caption )
|
||||
{
|
||||
if( s_ledBg == NULL )
|
||||
@@ -63,8 +63,7 @@ groupBox::groupBox( const QString & _caption, QWidget * _parent ) :
|
||||
m_led->setActiveGraphic( embed::getIconPixmap( "led_green" ) );
|
||||
m_led->setInactiveGraphic( embed::getIconPixmap( "led_off" ) );
|
||||
|
||||
setModel( new autoModel( FALSE, FALSE, TRUE,
|
||||
autoModel::defaultRelStep(), NULL, FALSE ) );
|
||||
setModel( new boolModel( FALSE, NULL, FALSE ) );
|
||||
setAutoFillBackground( TRUE );
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "config_mgr.h"
|
||||
#include "embed.h"
|
||||
@@ -59,19 +58,16 @@
|
||||
#include "controller_connection.h"
|
||||
|
||||
|
||||
float knob::s_copiedValue = 0.0f;
|
||||
textFloat * knob::s_textFloat = NULL;
|
||||
|
||||
|
||||
|
||||
knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new knobModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
floatModelView( new knobModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
m_mouseOffset( 0.0f ),
|
||||
m_buttonPressed( FALSE ),
|
||||
m_knobPixmap( NULL ),
|
||||
m_hintTextBeforeValue( "" ),
|
||||
m_hintTextAfterValue( "" ),
|
||||
m_outerColor( NULL ),
|
||||
m_knobNum( _knob_num ),
|
||||
m_label( "" )
|
||||
@@ -111,16 +107,6 @@ knob::~knob()
|
||||
|
||||
|
||||
|
||||
void knob::setHintText( const QString & _txt_before,
|
||||
const QString & _txt_after )
|
||||
{
|
||||
m_hintTextBeforeValue = _txt_before;
|
||||
m_hintTextAfterValue = _txt_after;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void knob::setLabel( const QString & _txt )
|
||||
{
|
||||
m_label = _txt;
|
||||
@@ -396,7 +382,7 @@ float knob::getValue( const QPoint & _p )
|
||||
}
|
||||
if( engine::getMainWindow()->isShiftPressed() )
|
||||
{
|
||||
return( ( _p.y() - m_origMousePos.y() ) * model()->step() );
|
||||
return( ( _p.y() - m_origMousePos.y() ) * model()->step<float>() );
|
||||
}
|
||||
return( ( _p.y() - m_origMousePos.y() ) * pageSize() );
|
||||
}
|
||||
@@ -413,34 +399,7 @@ void knob::contextMenuEvent( QContextMenuEvent * )
|
||||
mouseReleaseEvent( NULL );
|
||||
|
||||
captionMenu contextMenu( accessibleName() );
|
||||
contextMenu.addAction( embed::getIconPixmap( "reload" ),
|
||||
tr( "&Reset (%1%2)" ).
|
||||
arg( model()->initValue() ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( reset() ) );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( embed::getIconPixmap( "edit_copy" ),
|
||||
tr( "&Copy value (%1%2)" ).
|
||||
arg( model()->value() ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( copyValue() ) );
|
||||
contextMenu.addAction( embed::getIconPixmap( "edit_paste" ),
|
||||
tr( "&Paste value (%1%2)"
|
||||
).arg( s_copiedValue ).arg(
|
||||
m_hintTextAfterValue ),
|
||||
this, SLOT( pasteValue() ) );
|
||||
contextMenu.addSeparator();
|
||||
if( !model()->nullTrack() )
|
||||
{
|
||||
contextMenu.addAction( embed::getIconPixmap( "automation" ),
|
||||
tr( "&Open in automation editor" ),
|
||||
model()->getAutomationPattern(),
|
||||
SLOT( openInAutomationEditor() ) );
|
||||
contextMenu.addSeparator();
|
||||
}
|
||||
contextMenu.addAction( embed::getIconPixmap( "controller" ),
|
||||
tr( "Connect to controller..." ), this,
|
||||
SLOT( connectToController() ) );
|
||||
addDefaultActions( &contextMenu );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( embed::getIconPixmap( "help" ), tr( "&Help" ),
|
||||
this, SLOT( displayHelp() ) );
|
||||
@@ -471,7 +430,7 @@ void knob::dropEvent( QDropEvent * _de )
|
||||
else if( type == "link_object" )
|
||||
{
|
||||
knobModel * mod = (knobModel *)( val.toULong() );
|
||||
autoModel::linkModels( model(), mod );
|
||||
automatableModel::linkModels( model(), mod );
|
||||
mod->setValue( model()->value() );
|
||||
}
|
||||
}
|
||||
@@ -503,10 +462,10 @@ void knob::mousePressEvent( QMouseEvent * _me )
|
||||
QApplication::setOverrideCursor( Qt::BlankCursor );
|
||||
}
|
||||
// s_textFloat->reparent( this );
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number(
|
||||
model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
s_textFloat->moveGlobal( this,
|
||||
QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->show();
|
||||
@@ -532,7 +491,7 @@ void knob::mousePressEvent( QMouseEvent * _me )
|
||||
}
|
||||
else if( _me->button() == Qt::MidButton )
|
||||
{
|
||||
reset();
|
||||
model()->reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,9 +512,9 @@ void knob::mouseMoveEvent( QMouseEvent * _me )
|
||||
}
|
||||
}
|
||||
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number( model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
}
|
||||
|
||||
|
||||
@@ -623,9 +582,9 @@ void knob::wheelEvent( QWheelEvent * _we )
|
||||
model()->incValue( inc );
|
||||
|
||||
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number( model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->setVisibilityTimeOut( 1000 );
|
||||
|
||||
@@ -664,12 +623,12 @@ void knob::setPosition( const QPoint & _p )
|
||||
|
||||
|
||||
|
||||
void knob::reset( void )
|
||||
/*void knob::reset( void )
|
||||
{
|
||||
model()->setValue( model()->initValue() );
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number( model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->setVisibilityTimeOut( 1000 );
|
||||
}
|
||||
@@ -688,12 +647,12 @@ void knob::copyValue( void )
|
||||
void knob::pasteValue( void )
|
||||
{
|
||||
model()->setValue( s_copiedValue );
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number( model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->setVisibilityTimeOut( 1000 );
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <QtGui/QFontMetrics>
|
||||
#include <QtGui/QStyleOptionFrameV2>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
#include "gui_templates.h"
|
||||
@@ -45,7 +44,7 @@
|
||||
lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent,
|
||||
const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
intModelView( new intModel( 0, 0, 0, NULL, TRUE ) ),
|
||||
m_label(),
|
||||
m_numDigits( _num_digits ),
|
||||
m_origMousePos()
|
||||
@@ -68,7 +67,7 @@ lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent,
|
||||
lcdSpinBox::lcdSpinBox( int _num_digits, const QString & _lcd_style,
|
||||
QWidget * _parent, const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
intModelView( new intModel( 0, 0, 0, NULL, TRUE ) ),
|
||||
m_label(),
|
||||
m_numDigits( _num_digits ),
|
||||
m_origMousePos()
|
||||
@@ -206,10 +205,8 @@ void lcdSpinBox::update( void )
|
||||
|
||||
void lcdSpinBox::setLabel( const QString & _txt )
|
||||
{
|
||||
int margin = 1;
|
||||
m_label = _txt;
|
||||
|
||||
updateSize();
|
||||
updateSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +286,7 @@ void lcdSpinBox::mouseMoveEvent( QMouseEvent * _me )
|
||||
if( dy > 1 || dy < -1 )
|
||||
{
|
||||
model()->setInitValue( model()->value() -
|
||||
dy / 2 * model()->step() );
|
||||
dy / 2 * model()->step<int>() );
|
||||
emit manualChange();
|
||||
QCursor::setPos( m_origMousePos );
|
||||
}
|
||||
@@ -310,7 +307,7 @@ void lcdSpinBox::wheelEvent( QWheelEvent * _we )
|
||||
{
|
||||
_we->accept();
|
||||
model()->setInitValue( model()->value() +
|
||||
( ( _we->delta() > 0 ) ? 1 : -1 ) * model()->step() );
|
||||
( ( _we->delta() > 0 ) ? 1 : -1 ) * model()->step<int>() );
|
||||
emit manualChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QMdiArea>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "engine.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
@@ -250,23 +249,10 @@ void tempoSyncKnob::modelChanged( void )
|
||||
|
||||
void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * )
|
||||
{
|
||||
mouseReleaseEvent( NULL );
|
||||
|
||||
captionMenu contextMenu( accessibleName() );
|
||||
contextMenu.addAction( embed::getIconPixmap( "reload" ),
|
||||
tr( "&Reset (%1%2)" ).
|
||||
arg( model()->initValue() ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( reset() ) );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( embed::getIconPixmap( "edit_copy" ),
|
||||
tr( "&Copy value (%1%2)" ).
|
||||
arg( value() ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( copyValue() ) );
|
||||
contextMenu.addAction( embed::getIconPixmap( "edit_paste" ),
|
||||
tr( "&Paste value (%1%2)" ).
|
||||
arg( s_copiedValue ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( pasteValue() ) );
|
||||
addDefaultActions( &contextMenu );
|
||||
contextMenu.addSeparator();
|
||||
|
||||
float limit = 60000.0f / ( engine::getSong()->getTempo() *
|
||||
@@ -329,13 +315,6 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * )
|
||||
|
||||
}
|
||||
|
||||
contextMenu.addAction( embed::getIconPixmap( "automation" ),
|
||||
tr( "&Open in automation editor" ),
|
||||
model()->getAutomationPattern(),
|
||||
SLOT( openInAutomationEditor() ) );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( tr( "Connect to MIDI-device" ), this,
|
||||
SLOT( connectToMidiDevice() ) );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( embed::getIconPixmap( "help" ), tr( "&Help" ),
|
||||
this, SLOT( displayHelp() ) );
|
||||
|
||||
@@ -71,7 +71,7 @@ void volumeKnob::mousePressEvent( QMouseEvent * _me )
|
||||
if( configManager::inst()->value( "knobs",
|
||||
"classicalusability").toInt() )
|
||||
{
|
||||
m_mouseOffset = getValue( p ) - value();
|
||||
m_mouseOffset = getValue( p ) - model()->value();
|
||||
}
|
||||
emit sliderPressed();
|
||||
|
||||
@@ -85,14 +85,14 @@ void volumeKnob::mousePressEvent( QMouseEvent * _me )
|
||||
if( configManager::inst()->value( "app", "displaydbv" ).toInt() )
|
||||
{
|
||||
val = QString( " %1 dBV" ).arg(
|
||||
20.0 * log10( value() / 100.0 ),
|
||||
20.0 * log10( model()->value() / 100.0 ),
|
||||
3, 'f', 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
val = QString( " %1%" ).arg( value(), 3, 'f', 0 );
|
||||
val = QString( " %1%" ).arg( model()->value(), 3, 'f', 0 );
|
||||
}
|
||||
s_textFloat->setText( m_hintTextBeforeValue + val );
|
||||
s_textFloat->setText( m_description + val );
|
||||
|
||||
s_textFloat->moveGlobal( this,
|
||||
QPoint( width() + 2, 0 ) );
|
||||
@@ -102,12 +102,12 @@ void volumeKnob::mousePressEvent( QMouseEvent * _me )
|
||||
else if( _me->button() == Qt::LeftButton &&
|
||||
engine::getMainWindow()->isCtrlPressed() == TRUE )
|
||||
{
|
||||
new stringPairDrag( "float_value", QString::number( value() ),
|
||||
new stringPairDrag( "float_value", QString::number( model()->value() ),
|
||||
QPixmap(), this );
|
||||
}
|
||||
else if( _me->button() == Qt::MidButton )
|
||||
{
|
||||
reset();
|
||||
model()->reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ void volumeKnob::mouseMoveEvent( QMouseEvent * _me )
|
||||
{
|
||||
val = QString( " %1%" ).arg( model()->value(), 3, 'f', 0 );
|
||||
}
|
||||
s_textFloat->setText( m_hintTextBeforeValue + val );
|
||||
s_textFloat->setText( m_description + val );
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ void volumeKnob::wheelEvent( QWheelEvent * _we )
|
||||
{
|
||||
val = QString( " %1%" ).arg( model()->value(), 3, 'f', 0 );
|
||||
}
|
||||
s_textFloat->setText( m_hintTextBeforeValue + val );
|
||||
s_textFloat->setText( m_description + val );
|
||||
|
||||
s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->setVisibilityTimeOut( 1000 );
|
||||
|
||||
@@ -108,10 +108,10 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
|
||||
tr( "unnamed_channel" ) ) ),
|
||||
m_audioPort( tr( "unnamed_channel" ), this ),
|
||||
m_notes(),
|
||||
m_baseNoteModel( 0, 0, KeysPerOctave * NumOctaves - 1, 1, this ),
|
||||
m_baseNoteModel( 0, 0, KeysPerOctave * NumOctaves - 1, this ),
|
||||
m_volumeModel( DefaultVolume, MinVolume, MaxVolume, 1.0f, this ),
|
||||
m_panningModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this ),
|
||||
m_effectChannelModel( 0, 0, NumFxChannels, 1, this ),
|
||||
m_effectChannelModel( 0, 0, NumFxChannels, this ),
|
||||
m_instrument( NULL ),
|
||||
m_soundShaping( this ),
|
||||
m_arpeggiator( this ),
|
||||
@@ -1027,7 +1027,7 @@ class fxLineLcdSpinBox : public lcdSpinBox
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent ( QMouseEvent * _me )
|
||||
{
|
||||
engine::getFxMixerView()->setCurrentFxLine( value() );
|
||||
engine::getFxMixerView()->setCurrentFxLine( model()->value() );
|
||||
//engine::getFxMixerView()->raise();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user