diff --git a/ChangeLog b/ChangeLog index aea66154c..6b3be70a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,74 @@ +2008-05-28 Tobias Doerffel + + * 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 * plugins/sf2_player/sf2_player.cpp: diff --git a/Makefile.am b/Makefile.am index d6e5e231b..2de6f5f09 100644 --- a/Makefile.am +++ b/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 \ diff --git a/include/automatable_button.h b/include/automatable_button.h index 3aabe36c0..261c4f262 100644 --- a/include/automatable_button.h +++ b/include/automatable_button.h @@ -28,7 +28,7 @@ #include -#include "automatable_model.h" +#include "automatable_model_view.h" class automatableButtonGroup; diff --git a/include/automatable_model.h b/include/automatable_model.h index 1a61bdaf5..3107e4262 100644 --- a/include/automatable_model.h +++ b/include/automatable_model.h @@ -29,18 +29,17 @@ #include #include "journalling_object.h" -#include "level_object.h" #include "mv_base.h" #include "controller_connection.h" +#include "automation_pattern.h" #include #include - -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 -class automatableModel : public model, public journallingObject, - public levelObject -{ -public: - typedef automatableModel 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 - static inline T castValue( V _v ) - { - return( static_cast( _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 + static inline T minEps( void ) + { + return( 1 ); + } + + template + static inline T castValue( const float _v ) + { + return( static_cast( _v ) ); + } + + template + inline T value( int _frameOffset = 0 ) const + { + if( m_controllerConnection != NULL ) + { + return minValue() + + castValue( m_range * + m_controllerConnection->currentValue( + _frameOffset ) ); + } + + return castValue( m_value ); + } + + + template + inline T initValue( void ) const + { + return castValue( m_initValue ); + } + + template + inline T minValue( void ) const + { + return castValue( m_minValue ); + } + + template + inline T maxValue( void ) const + { + return castValue( m_maxValue ); + } + + template + inline T step( void ) const + { + return castValue( m_step ); + } + + +// template + void setInitValue( const float _value ); + +// template + void setValue( const float _value ); + + inline void incValue( int _steps ) + { + setValue( m_value + _steps * m_step ); + } + +// template + void setRange( const float _min, const float _max, + const float _step = 1 ); + +// template + 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( _val ) ) ); + case Integer: return( QString::number( + castValue( _val ) ) ); + case Bool: return( QString::number( + castValue( _val ) ) ); + } + return( "0" ); + } + +/* int labelToLevel( QString _label ) const + { + switch( m_dataType ) + { + case Float: return( level( + stringToValue( _label ) ) ); + case Integer: return( level( + stringToValue( _label ) ) ); + case Bool: return( level( + stringToValue( _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 autoModelVector; + autoModelVector m_linkedModels; + + void linkModel( automatableModel * _model ); + + void unlinkModel( automatableModel * _model ); + + + + + controllerConnection * m_controllerConnection; QPointer m_automationPattern; track * m_track; - // most objects will need this temporarily - T m_oldValue; - bool m_journalEntryReady; - typedef QVector 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( _frameOffset ) );\ + } \ + \ + inline type minValue( void ) const \ + { \ + return( automatableModel::minValue() ); \ + } \ + \ + inline type maxValue( void ) const \ + { \ + return( automatableModel::maxValue() ); \ + } \ -template -class automatableModelView : public modelView + +// some typed automatableModel-definitions + +class floatModel : public automatableModel { public: - typedef automatableModel autoModel; - typedef automatableModelView 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() ); - } - - const autoModel * model( void ) const - { - return( castModel() ); - } - - 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##Model; \ - typedef automatableModelView type##ModelView; \ + defaultTypedMethods(int); -// some model-primitives +} ; -generateModelPrimitive(float,float); -generateModelPrimitive(int,int); -class boolModel : public automatableModel +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 boolModelView; +} ; #endif diff --git a/include/automatable_model_templates.h b/include/automatable_model_templates.h deleted file mode 100644 index 174ebf4ea..000000000 --- a/include/automatable_model_templates.h +++ /dev/null @@ -1,573 +0,0 @@ -/* - * automatable_model_templates.h - definition of automatableModel templates - * - * Copyright (c) 2007-2008 Tobias Doerffel - * - * 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 - -#include "automatable_model.h" -#include "automation_editor.h" -#include "automation_pattern.h" -#include "engine.h" -#include "templates.h" - - - -template -automatableModel::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 -automatableModel::~automatableModel() -{ - delete m_automationPattern; - while( m_linkedModels.empty() == FALSE ) - { - m_linkedModels.last()->unlinkModel( this ); - m_linkedModels.erase( m_linkedModels.end() - 1 ); - } -} - - - - -template -T automatableModel::fittedValue( T _value ) const -{ - _value = tLimit( _value, minValue(), maxValue() ); - - if( m_step != 0 ) - { - _value = static_cast( roundf( _value / (float)step() ) - * step() ); - } - else - { - _value = minValue(); - } - - // correct rounding error at the border - if( tAbs( _value - maxValue() ) < minEps() * tAbs( step() ) ) - { - _value = maxValue(); - } - - // correct rounding error if value = 0 - if( tAbs( _value ) < minEps() * tAbs( step() ) ) - { - _value = 0; - } - - return( _value ); -} - - - - -template -void automatableModel::setInitValue( const T _value ) -{ - m_initValue = _value; - bool journalling = testAndSetJournalling( FALSE ); - setValue( _value ); - if( m_automationPattern ) - { - setFirstValue(); - } - setJournalling( journalling ); -} - - - - -template -void automatableModel::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( m_value ) - - static_cast( 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 -void automatableModel::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( m_minValue, m_maxValue ); - } - m_range = m_maxValue - m_minValue; - setStep( _step ); - // re-adjust value - autoModel::setInitValue( value() ); - - emit propertiesChanged(); - } -} - - - - -template -void automatableModel::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( m_step ) < tAbs( 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 -void automatableModel::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 -void automatableModel::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 -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, 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 -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() ); - 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 -automationPattern * automatableModel::getAutomationPattern( - void ) -{ - if( !m_automationPattern ) - { - m_automationPattern = new automationPattern( m_track, this ); - setFirstValue(); - syncAutomationPattern(); - } - return( m_automationPattern ); -} - - - - -template -void automatableModel::redoStep( journalEntry & _je ) -{ - bool journalling = testAndSetJournalling( FALSE ); - setValue( static_cast( value() + static_cast( - _je.data().toDouble() ) ) ); - setJournalling( journalling ); -} - - - - -template -void automatableModel::undoStep( journalEntry & _je ) -{ - journalEntry je( _je.actionID(), - static_cast( -_je.data().toDouble() ) ); - redoStep( je ); -} - - - - -template -void automatableModel::prepareJournalEntryFromOldVal( void ) -{ - m_oldValue = value(); - saveJournallingState( FALSE ); - m_journalEntryReady = TRUE; -} - - - - -template -void automatableModel::addJournalEntryFromOldToCurVal( - void ) -{ - if( m_journalEntryReady ) - { - restoreJournallingState(); - if( value() != m_oldValue ) - { - addJournalEntry( journalEntry( 0, value() - - m_oldValue ) ); - } - m_journalEntryReady = FALSE; - } -} - - - - -template -void automatableModel::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 -void automatableModel::linkModel( autoModel * _model ) -{ - if( qFind( m_linkedModels.begin(), m_linkedModels.end(), _model ) - == m_linkedModels.end() ) - { - m_linkedModels.push_back( _model ); - } -} - - - - -template -void automatableModel::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 -void automatableModel::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 -void automatableModel::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::minRelStep( void ) -{ - return( 1.0e-10 ); -} - - - - -template<> -inline float automatableModel::defaultRelStep( void ) -{ - return( 1.0e-2 ); -} - - - - -template<> -inline float automatableModel::minEps( void ) -{ - return( 1.0e-10 ); -} - - - - -template<> -inline float automatableModel::attributeValue( QString _value ) -{ - return( _value.toFloat() ); -} - - - - -template<> -inline int automatableModel::attributeValue( QString _value ) -{ - return( _value.toInt() ); -} - - - - -template<> -inline bool automatableModel::attributeValue( QString _value ) -{ - return( static_cast( _value.toInt() ) ); -} - - - -template<> -inline bool automatableModel::attributeValue( - QString _value ) -{ - return( static_cast( _value.toInt() ) ); -} - - - - -#endif - diff --git a/include/automatable_model_view.h b/include/automatable_model_view.h new file mode 100644 index 000000000..1e35aa127 --- /dev/null +++ b/include/automatable_model_view.h @@ -0,0 +1,123 @@ +/* + * automatable_model_view.h - class automatableModelView + * + * Copyright (c) 2008 Tobias Doerffel + * + * 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() ); + } + + const automatableModel * modelUntyped( void ) const + { + return( castModel() ); + } + + template + inline T value( void ) const + { + return( modelUntyped() ? modelUntyped()->value() : 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() );\ + }\ +\ + const type##Model * model( void ) const\ + {\ + return( castModel() );\ + }\ +} ; + + +generateTypedModelView(float); +generateTypedModelView(int); +generateTypedModelView(bool); + + +#endif + diff --git a/include/automatable_slider.h b/include/automatable_slider.h index 2d719d17c..ba6a404ff 100644 --- a/include/automatable_slider.h +++ b/include/automatable_slider.h @@ -1,7 +1,7 @@ /* * automatable_slider.h - class automatableSlider, a QSlider with automation * - * Copyright (c) 2006-2007 Javier Serrano Polo + * Copyright (c) 2006-2008 Javier Serrano Polo * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -29,30 +29,17 @@ #include #include - -#include "automatable_model.h" +#include "automatable_model_view.h" -class automatableSlider : public QSlider, public automatableModelView +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 diff --git a/include/automation_pattern.h b/include/automation_pattern.h index 232896345..36d4fa47b 100644 --- a/include/automation_pattern.h +++ b/include/automation_pattern.h @@ -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 + * Copyright (c) 2006-2008 Javier Serrano Polo * * 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 timeMap; + typedef QMap 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; diff --git a/include/combobox.h b/include/combobox.h index 5e26f77f6..444a0a6a8 100644 --- a/include/combobox.h +++ b/include/combobox.h @@ -26,65 +26,11 @@ #ifndef _COMBOBOX_H #define _COMBOBOX_H -#include -#include #include -#include +#include -#include "automatable_model.h" -#include "templates.h" - -class pixmapLoader; - - -class comboBoxModel : public intModel -{ - Q_OBJECT -public: - comboBoxModel( ::model * _parent = NULL ) : - automatableModel( 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( _i, minValue(), maxValue() )]. - first ); - } - - inline const pixmapLoader * itemPixmap( int _i ) const - { - return( m_items[tLimit( _i, minValue(), maxValue() )]. - second ); - } - - inline int size( void ) const - { - return( m_items.size() ); - } - -private: - typedef QPair item; - - QVector m_items; - -} ; +#include "combobox_model.h" +#include "automatable_model_view.h" diff --git a/include/combobox_model.h b/include/combobox_model.h new file mode 100644 index 000000000..0cab7f8f6 --- /dev/null +++ b/include/combobox_model.h @@ -0,0 +1,88 @@ +/* + * combobox_model.h - class comboBoxModel + * + * Copyright (c) 2008 Tobias Doerffel + * + * 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 +#include + +#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( _i, minValue(), maxValue() )]. + first ); + } + + inline const pixmapLoader * itemPixmap( int _i ) const + { + return( m_items[tLimit( _i, minValue(), maxValue() )]. + second ); + } + + inline int size( void ) const + { + return( m_items.size() ); + } + +private: + typedef QPair item; + + QVector m_items; + +} ; + + +#endif diff --git a/include/detuning_helper.h b/include/detuning_helper.h index 21fb79104..01a0afae2 100644 --- a/include/detuning_helper.h +++ b/include/detuning_helper.h @@ -36,7 +36,8 @@ class detuningHelper : public floatModel, public sharedObject { public: detuningHelper( void ) : - autoModel( NULL ) + floatModel(), + sharedObject() { } diff --git a/include/fader.h b/include/fader.h index 3e2234abd..f6a6aefaa 100644 --- a/include/fader.h +++ b/include/fader.h @@ -51,7 +51,7 @@ #include #include -#include "automatable_model.h" +#include "automatable_model_view.h" class fader : public QWidget, public floatModelView diff --git a/include/group_box.h b/include/group_box.h index cc3534105..6b2146d91 100644 --- a/include/group_box.h +++ b/include/group_box.h @@ -28,7 +28,7 @@ #include -#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 diff --git a/include/knob.h b/include/knob.h index 230ebca91..dbff099c8 100644 --- a/include/knob.h +++ b/include/knob.h @@ -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 + * Copyright (c) 2004-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -32,7 +32,7 @@ #include #include -#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( ( model()->maxValue() - model()->minValue() ) / 100.0f, - model()->step() ) ); + modelUntyped()->step() ) ); } virtual void doConnections( void ); @@ -168,6 +168,6 @@ private: } ; -typedef knob::autoModel knobModel; +typedef floatModel knobModel; #endif diff --git a/include/lcd_spinbox.h b/include/lcd_spinbox.h index a2fb0c9b0..774445202 100644 --- a/include/lcd_spinbox.h +++ b/include/lcd_spinbox.h @@ -1,7 +1,7 @@ /* * lcd_spinbox.h - class lcdSpinBox, an improved QLCDNumber * - * Copyright (c) 2005-2007 Tobias Doerffel + * Copyright (c) 2005-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -29,13 +29,13 @@ #include #include -#include "automatable_model.h" +#include "automatable_model_view.h" class QLabel; -class lcdSpinBox : public QWidget, public automatableModelView +class lcdSpinBox : public QWidget, public intModelView { Q_OBJECT public: @@ -102,6 +102,6 @@ signals: } ; -typedef lcdSpinBox::autoModel lcdSpinBoxModel; +typedef intModel lcdSpinBoxModel; #endif diff --git a/include/note_play_handle.h b/include/note_play_handle.h index 29d308c63..9670a83e0 100644 --- a/include/note_play_handle.h +++ b/include/note_play_handle.h @@ -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; } ; diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index bcea162a3..aeea79e26 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -31,7 +31,6 @@ #include "audio_file_processor.h" -#include "automatable_model_templates.h" #include "engine.h" #include "song.h" #include "instrument_track.h" diff --git a/plugins/bass_booster/bass_booster.cpp b/plugins/bass_booster/bass_booster.cpp index 981ca9401..cb9c21ff9 100644 --- a/plugins/bass_booster/bass_booster.cpp +++ b/plugins/bass_booster/bass_booster.cpp @@ -24,7 +24,6 @@ #include "bass_booster.h" -#include "automatable_model_templates.h" #undef SINGLE_SOURCE_COMPILE diff --git a/plugins/bass_booster/bassbooster_controls.cpp b/plugins/bass_booster/bassbooster_controls.cpp index 1abc1525e..bcce55b15 100644 --- a/plugins/bass_booster/bassbooster_controls.cpp +++ b/plugins/bass_booster/bassbooster_controls.cpp @@ -25,7 +25,6 @@ #include "bassbooster_controls.h" #include "bass_booster.h" -#include "automatable_model_templates.h" diff --git a/plugins/kicker/kicker.cpp b/plugins/kicker/kicker.cpp index 4b1f12cfe..194df9193 100644 --- a/plugins/kicker/kicker.cpp +++ b/plugins/kicker/kicker.cpp @@ -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" diff --git a/plugins/lb302/lb302.cpp b/plugins/lb302/lb302.cpp index fae319a9f..315f53217 100644 --- a/plugins/lb302/lb302.cpp +++ b/plugins/lb302/lb302.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" diff --git a/plugins/midi_import/midi_import.cpp b/plugins/midi_import/midi_import.cpp index cb4f0dc90..5ff0aedab 100644 --- a/plugins/midi_import/midi_import.cpp +++ b/plugins/midi_import/midi_import.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 ); } diff --git a/plugins/organic/organic.cpp b/plugins/organic/organic.cpp index c2f7abaf1..9974749f6 100644 --- a/plugins/organic/organic.cpp +++ b/plugins/organic/organic.cpp @@ -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 ), diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index 2c836a7a1..b7ab64a11 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -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 ), diff --git a/plugins/stereo_enhancer/stereoenhancer_controls.cpp b/plugins/stereo_enhancer/stereoenhancer_controls.cpp index 452c33000..0d75dc2f2 100644 --- a/plugins/stereo_enhancer/stereoenhancer_controls.cpp +++ b/plugins/stereo_enhancer/stereoenhancer_controls.cpp @@ -24,7 +24,6 @@ #include "stereoenhancer_controls.h" #include "stereo_enhancer.h" -#include "automatable_model_templates.h" stereoEnhancerControls::stereoEnhancerControls( stereoEnhancerEffect * _eff ) : diff --git a/plugins/stereo_matrix/stereomatrix_controls.cpp b/plugins/stereo_matrix/stereomatrix_controls.cpp index a0f1cc7bd..df8347695 100644 --- a/plugins/stereo_matrix/stereomatrix_controls.cpp +++ b/plugins/stereo_matrix/stereomatrix_controls.cpp @@ -24,7 +24,6 @@ #include "stereomatrix_controls.h" #include "stereo_matrix.h" -#include "automatable_model_templates.h" stereoMatrixControls::stereoMatrixControls( stereoMatrixEffect * _eff ) : diff --git a/plugins/triple_oscillator/triple_oscillator.cpp b/plugins/triple_oscillator/triple_oscillator.cpp index 487edd2e6..c44896e2b 100644 --- a/plugins/triple_oscillator/triple_oscillator.cpp +++ b/plugins/triple_oscillator/triple_oscillator.cpp @@ -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 ), diff --git a/plugins/vibed/nine_button_selector.cpp b/plugins/vibed/nine_button_selector.cpp index 55b5dcb82..92a135354 100644 --- a/plugins/vibed/nine_button_selector.cpp +++ b/plugins/vibed/nine_button_selector.cpp @@ -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 ); diff --git a/plugins/vibed/nine_button_selector.h b/plugins/vibed/nine_button_selector.h index 8db59273e..2084f804b 100644 --- a/plugins/vibed/nine_button_selector.h +++ b/plugins/vibed/nine_button_selector.h @@ -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 diff --git a/plugins/vibed/vibed.cpp b/plugins/vibed/vibed.cpp index 8a16434c0..c187e3132 100644 --- a/plugins/vibed/vibed.cpp +++ b/plugins/vibed/vibed.cpp @@ -28,8 +28,6 @@ #include #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 ); diff --git a/src/core/audio/audio_alsa.cpp b/src/core/audio/audio_alsa.cpp index a36478146..1f1862c8e 100644 --- a/src/core/audio/audio_alsa.cpp +++ b/src/core/audio/audio_alsa.cpp @@ -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() ) ); } diff --git a/src/core/audio/audio_jack.cpp b/src/core/audio/audio_jack.cpp index cda58541d..f98016c96 100644 --- a/src/core/audio/audio_jack.cpp +++ b/src/core/audio/audio_jack.cpp @@ -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() ) ); } diff --git a/src/core/audio/audio_oss.cpp b/src/core/audio/audio_oss.cpp index 3ed20abf1..e97751dfb 100644 --- a/src/core/audio/audio_oss.cpp +++ b/src/core/audio/audio_oss.cpp @@ -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() ) ); } diff --git a/src/core/automatable_model.cpp b/src/core/automatable_model.cpp new file mode 100644 index 000000000..40f3fda90 --- /dev/null +++ b/src/core/automatable_model.cpp @@ -0,0 +1,456 @@ +/* + * automatable_model.cpp - some implementations of automatableModel-class + * + * Copyright (c) 2008 Tobias Doerffel + * + * 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 + + +#include "automatable_model.h" +#include "automation_pattern.h" +#include "automation_editor.h" + + +float automatableModel::__copiedValue = 0; + + + +template<> +inline float automatableModel::minEps( 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() != (*it)->value() && + (*it)->fittedValue( value() ) + != (*it)->value() ) + { + bool journalling = (*it)->testAndSetJournalling( + isJournalling() ); + (*it)->setValue( value() ); + (*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( m_minValue, m_maxValue ); + } + m_range = m_maxValue - m_minValue; + setStep( _step ); + + // re-adjust value + setInitValue( value() ); + + 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( _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( _value - m_maxValue ) < + minEps() * tAbs( m_step ) ) + { + _value = m_maxValue; + } + + // correct rounding error if value = 0 + if( tAbs( _value ) < minEps() * tAbs( m_step ) ) + { + _value = 0; + } + + return( _value ); +} + + + + + +void automatableModel::redoStep( journalEntry & _je ) +{ + bool journalling = testAndSetJournalling( FALSE ); + setValue( value() + _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(); + saveJournallingState( FALSE ); + m_journalEntryReady = TRUE; +} + + + + +void automatableModel::addJournalEntryFromOldToCurVal( void ) +{ + if( m_journalEntryReady ) + { + restoreJournallingState(); + if( value() != m_oldValue ) + { + addJournalEntry( journalEntry( 0, value() - + 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() ); +} + + + + +void automatableModel::copyValue( void ) +{ + __copiedValue = value(); +} + + + + +void automatableModel::pasteValue( void ) +{ + setValue( __copiedValue ); +} + + + + +#include "automatable_model.moc" + diff --git a/src/core/automation_pattern.cpp b/src/core/automation_pattern.cpp index 4305b873c..dccca526a 100644 --- a/src/core/automation_pattern.cpp +++ b/src/core/automation_pattern.cpp @@ -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( max_length, -it.key() ); + max_length = tMax( max_length, -it.key() ); } if( max_length % DefaultTicksPerTact == 0 ) { - return( midiTime( tMax( max_length, + return( midiTime( tMax( 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() ); } } diff --git a/include/level_object.h b/src/core/combobox_model.cpp similarity index 52% rename from include/level_object.h rename to src/core/combobox_model.cpp index 6b9844177..f5f5b8eab 100644 --- a/include/level_object.h +++ b/src/core/combobox_model.cpp @@ -1,7 +1,7 @@ /* - * level_object.h - declaration of class levelObject + * combobox_model.cpp - implementation of comboBoxModel * - * Copyright (c) 2006-2008 Javier Serrano Polo + * Copyright (c) 2008 Tobias Doerffel * * 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 - - -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::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" diff --git a/src/core/effect_chain.cpp b/src/core/effect_chain.cpp index 1f3e10781..6b6a3b0a2 100644 --- a/src/core/effect_chain.cpp +++ b/src/core/effect_chain.cpp @@ -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" diff --git a/src/core/envelope_and_lfo_parameters.cpp b/src/core/envelope_and_lfo_parameters.cpp index bf0990657..013b04e8f 100644 --- a/src/core/envelope_and_lfo_parameters.cpp +++ b/src/core/envelope_and_lfo_parameters.cpp @@ -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 ), diff --git a/src/core/instrument_functions.cpp b/src/core/instrument_functions.cpp index e551d3b89..ab0986c15 100644 --- a/src/core/instrument_functions.cpp +++ b/src/core/instrument_functions.cpp @@ -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 ); diff --git a/src/core/instrument_midi_io.cpp b/src/core/instrument_midi_io.cpp index d13b56c6f..c6bcc76ab 100644 --- a/src/core/instrument_midi_io.cpp +++ b/src/core/instrument_midi_io.cpp @@ -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 ), diff --git a/src/core/ladspa_control.cpp b/src/core/ladspa_control.cpp index 2e711ea47..4e8b0831d 100644 --- a/src/core/ladspa_control.cpp +++ b/src/core/ladspa_control.cpp @@ -24,7 +24,6 @@ #include "ladspa_control.h" -#include "automatable_model_templates.h" #include "ladspa_base.h" diff --git a/src/core/lfo_controller.cpp b/src/core/lfo_controller.cpp index 3241b5b07..823262cf2 100644 --- a/src/core/lfo_controller.cpp +++ b/src/core/lfo_controller.cpp @@ -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 ), diff --git a/src/core/meter_model.cpp b/src/core/meter_model.cpp index 66eed0b69..e997ec2ff 100644 --- a/src/core/meter_model.cpp +++ b/src/core/meter_model.cpp @@ -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 ); diff --git a/src/core/note.cpp b/src/core/note.cpp index 461944f9d..605997e7f 100644 --- a/src/core/note.cpp +++ b/src/core/note.cpp @@ -30,7 +30,6 @@ #include #include "note.h" -#include "automatable_model_templates.h" #include "detuning_helper.h" #include "templates.h" diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index ec6b18e06..5839773ce 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -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(); } } diff --git a/src/core/piano.cpp b/src/core/piano.cpp index 6ea414246..e883d7ac3 100644 --- a/src/core/piano.cpp +++ b/src/core/piano.cpp @@ -36,7 +36,6 @@ #include "caption_menu.h" -#include "automatable_model_templates.h" #include "embed.h" #include "gui_templates.h" #include "instrument_track.h" diff --git a/src/core/song.cpp b/src/core/song.cpp index 79eaa53df..6926ac0e2 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -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 ), diff --git a/src/core/surround_area.cpp b/src/core/surround_area.cpp index e2a22fe6f..67d42a967 100644 --- a/src/core/surround_area.cpp +++ b/src/core/surround_area.cpp @@ -35,7 +35,6 @@ #include -#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 ); diff --git a/src/core/track.cpp b/src/core/track.cpp index bd0bde669..f2065d354 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -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" diff --git a/src/gui/automatable_model_view.cpp b/src/gui/automatable_model_view.cpp new file mode 100644 index 000000000..b8fdb7b45 --- /dev/null +++ b/src/gui/automatable_model_view.cpp @@ -0,0 +1,75 @@ +/* + * automatable_model_view.cpp - implementation of automatableModelView + * + * Copyright (c) 2008 Tobias Doerffel + * + * 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 + + +#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() ) ). + 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() ) ). + 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( this ), + SLOT( connectToController() ) ); +} + + diff --git a/src/gui/automation_editor.cpp b/src/gui/automation_editor.cpp index 798a8807a..3e81ccd93 100644 --- a/src/gui/automation_editor.cpp +++ b/src/gui/automation_editor.cpp @@ -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(); + m_max_level = m_pattern->object()->maxValue(); 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, diff --git a/src/gui/piano_roll.cpp b/src/gui/piano_roll.cpp index a0c982de1..7e827f5a7 100644 --- a/src/gui/piano_roll.cpp +++ b/src/gui/piano_roll.cpp @@ -48,7 +48,6 @@ #include -#include "automatable_model_templates.h" #include "clipboard.h" #include "combobox.h" #include "debug.h" diff --git a/src/gui/widgets/automatable_button.cpp b/src/gui/widgets/automatable_button.cpp index 4962f5d43..bac81e00d 100644 --- a/src/gui/widgets/automatable_button.cpp +++ b/src/gui/widgets/automatable_button.cpp @@ -31,7 +31,6 @@ #include #include -#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(); } diff --git a/src/gui/widgets/automatable_slider.cpp b/src/gui/widgets/automatable_slider.cpp index b98dfcf8d..1165f31f6 100644 --- a/src/gui/widgets/automatable_slider.cpp +++ b/src/gui/widgets/automatable_slider.cpp @@ -31,7 +31,6 @@ #include #include -#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 ); diff --git a/src/gui/widgets/combobox.cpp b/src/gui/widgets/combobox.cpp index 83cb5e2e7..fb39f00eb 100644 --- a/src/gui/widgets/combobox.cpp +++ b/src/gui/widgets/combobox.cpp @@ -35,7 +35,6 @@ #include #include -#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::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" diff --git a/src/gui/widgets/envelope_and_lfo_view.cpp b/src/gui/widgets/envelope_and_lfo_view.cpp index 5b1e51ef6..bafebeda7 100644 --- a/src/gui/widgets/envelope_and_lfo_view.cpp +++ b/src/gui/widgets/envelope_and_lfo_view.cpp @@ -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() < 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() < 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() ); p.setPen( QPen( QColor( static_cast( 96 * gray_amount ), static_cast( 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( m_predelayKnob->value() * + int x1 = ENV_GRAPH_X + 2 + static_cast( m_predelayKnob->value() * TIME_UNIT_WIDTH ); - int x2 = x1 + static_cast( m_attackKnob->value() * + int x2 = x1 + static_cast( m_attackKnob->value() * 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( m_holdKnob->value() * TIME_UNIT_WIDTH ); + x2 = x1 + static_cast( m_holdKnob->value() * 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( ( m_decayKnob->value() * - m_sustainKnob->value() ) * + x2 = x1 + static_cast( ( m_decayKnob->value() * + m_sustainKnob->value() ) * TIME_UNIT_WIDTH ); p.drawLine( x1, y_base-avail_height, x2, static_cast( y_base - avail_height + - m_sustainKnob->value() * avail_height ) ); + m_sustainKnob->value() * 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( m_releaseKnob->value() * TIME_UNIT_WIDTH ); + x2 = x1 + static_cast( m_releaseKnob->value() * TIME_UNIT_WIDTH ); p.drawLine( x1, static_cast( y_base - avail_height + - m_sustainKnob->value() * + m_sustainKnob->value() * avail_height ), x2, y_base ); p.fillRect( x1-1, static_cast( y_base - avail_height + - m_sustainKnob->value() * + m_sustainKnob->value() * avail_height ) - 2, 4, 4, end_points_bg_color ); p.fillRect( x1, static_cast( y_base - avail_height + - m_sustainKnob->value() * + m_sustainKnob->value() * 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() ); p.setPen( QPen( QColor( static_cast( 96 * lfo_gray_amount ), static_cast( 255 - 159 * lfo_gray_amount ), static_cast( 128 - 32 * @@ -563,7 +563,7 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * ) p.setPen( QColor( 255, 192, 0 ) ); int ms_per_osc = static_cast( SECS_PER_LFO_OSCILLATION * - m_lfoSpeedKnob->value() * + m_lfoSpeedKnob->value() * 1000.0f ); p.drawText( LFO_GRAPH_X + 4, LFO_GRAPH_Y + s_lfoGraph->height() - 6, tr( "ms/LFO:" ) ); diff --git a/src/gui/widgets/fader.cpp b/src/gui/widgets/fader.cpp index 940deaf60..c0b21ee71 100644 --- a/src/gui/widgets/fader.cpp +++ b/src/gui/widgets/fader.cpp @@ -53,7 +53,6 @@ #include "embed.h" #include "caption_menu.h" #include "automation_pattern.h" -#include "automatable_model_templates.h" diff --git a/src/gui/widgets/group_box.cpp b/src/gui/widgets/group_box.cpp index d81d31880..357706ec4 100644 --- a/src/gui/widgets/group_box.cpp +++ b/src/gui/widgets/group_box.cpp @@ -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 ); } diff --git a/src/gui/widgets/knob.cpp b/src/gui/widgets/knob.cpp index 137eb4f19..396a028df 100644 --- a/src/gui/widgets/knob.cpp +++ b/src/gui/widgets/knob.cpp @@ -44,7 +44,6 @@ #include -#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() ); } 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 ); -} +}*/ diff --git a/src/gui/widgets/lcd_spinbox.cpp b/src/gui/widgets/lcd_spinbox.cpp index d939ec486..47b893bc2 100644 --- a/src/gui/widgets/lcd_spinbox.cpp +++ b/src/gui/widgets/lcd_spinbox.cpp @@ -35,7 +35,6 @@ #include #include -#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() ); 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() ); emit manualChange(); } diff --git a/src/gui/widgets/tempo_sync_knob.cpp b/src/gui/widgets/tempo_sync_knob.cpp index 23d2896f0..9badfa218 100644 --- a/src/gui/widgets/tempo_sync_knob.cpp +++ b/src/gui/widgets/tempo_sync_knob.cpp @@ -31,7 +31,6 @@ #include #include -#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() ) ); diff --git a/src/gui/widgets/volume_knob.cpp b/src/gui/widgets/volume_knob.cpp index cf310a67b..bbb639791 100644 --- a/src/gui/widgets/volume_knob.cpp +++ b/src/gui/widgets/volume_knob.cpp @@ -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 ); diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index f30dfd8f1..5039495d8 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -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(); } };