reworked automatableModel (not template-based anymore), removed levelObject, splitted comboBox/comboBoxModel-source-files, began to unify context-menu-creation for controls
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1031 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -518,7 +518,7 @@ void audioALSA::setupWidget::saveSettings( void )
|
||||
configManager::inst()->setValue( "audioalsa", "device",
|
||||
m_device->text() );
|
||||
configManager::inst()->setValue( "audioalsa", "channels",
|
||||
QString::number( m_channels->value() ) );
|
||||
QString::number( m_channels->value<int>() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ void audioJACK::setupWidget::saveSettings( void )
|
||||
configManager::inst()->setValue( "audiojack", "clientname",
|
||||
m_clientName->text() );
|
||||
configManager::inst()->setValue( "audiojack", "channels",
|
||||
QString::number( m_channels->value() ) );
|
||||
QString::number( m_channels->value<int>() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ void audioOSS::setupWidget::saveSettings( void )
|
||||
configManager::inst()->setValue( "audiooss", "device",
|
||||
m_device->text() );
|
||||
configManager::inst()->setValue( "audiooss", "channels",
|
||||
QString::number( m_channels->value() ) );
|
||||
QString::number( m_channels->value<int>() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
456
src/core/automatable_model.cpp
Normal file
456
src/core/automatable_model.cpp
Normal file
@@ -0,0 +1,456 @@
|
||||
/*
|
||||
* automatable_model.cpp - some implementations of automatableModel-class
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <Qt/QtXml>
|
||||
|
||||
|
||||
#include "automatable_model.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "automation_editor.h"
|
||||
|
||||
|
||||
float automatableModel::__copiedValue = 0;
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
inline float automatableModel::minEps<float>( void )
|
||||
{
|
||||
return( 1.0e-10 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
automatableModel::automatableModel( DataType _type,
|
||||
const float _val,
|
||||
const float _min,
|
||||
const float _max,
|
||||
const float _step,
|
||||
::model * _parent,
|
||||
bool _default_constructed ) :
|
||||
model( _parent, _default_constructed ),
|
||||
m_dataType( _type ),
|
||||
m_value( _val ),
|
||||
m_initValue( _val ),
|
||||
m_minValue( _min ),
|
||||
m_maxValue( _max ),
|
||||
m_step( _step ),
|
||||
m_range( _max - _min ),
|
||||
m_journalEntryReady( FALSE ),
|
||||
m_controllerConnection( NULL ),
|
||||
m_automationPattern( NULL ),
|
||||
m_track( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
automatableModel::~automatableModel()
|
||||
{
|
||||
delete m_automationPattern;
|
||||
while( m_linkedModels.empty() == FALSE )
|
||||
{
|
||||
m_linkedModels.last()->unlinkModel( this );
|
||||
m_linkedModels.erase( m_linkedModels.end() - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void automatableModel::saveSettings( QDomDocument & _doc, QDomElement & _this,
|
||||
const QString & _name )
|
||||
{
|
||||
if( m_automationPattern && m_automationPattern->getTimeMap().size()
|
||||
> 1 )
|
||||
{
|
||||
QDomElement pattern_element;
|
||||
QDomNode node = _this.namedItem(
|
||||
automationPattern::classNodeName() );
|
||||
if( node.isElement() )
|
||||
{
|
||||
pattern_element = node.toElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern_element = _doc.createElement(
|
||||
automationPattern::classNodeName() );
|
||||
_this.appendChild( pattern_element );
|
||||
}
|
||||
QDomElement element = _doc.createElement( _name );
|
||||
m_automationPattern->saveSettings( _doc, element );
|
||||
pattern_element.appendChild( element );
|
||||
}
|
||||
else
|
||||
{
|
||||
_this.setAttribute( _name, m_value );
|
||||
}
|
||||
|
||||
if( m_controllerConnection )
|
||||
{
|
||||
QDomElement controller_element;
|
||||
QDomNode node = _this.namedItem( "connection" );
|
||||
if( node.isElement() )
|
||||
{
|
||||
controller_element = node.toElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
controller_element = _doc.createElement( "connection" );
|
||||
_this.appendChild( controller_element );
|
||||
}
|
||||
QDomElement element = _doc.createElement( _name );
|
||||
m_controllerConnection->saveSettings( _doc, element );
|
||||
controller_element.appendChild( element );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::loadSettings( const QDomElement & _this,
|
||||
const QString & _name )
|
||||
{
|
||||
QDomNode node = _this.namedItem( automationPattern::classNodeName() );
|
||||
if( node.isElement() && getAutomationPattern() )
|
||||
{
|
||||
node = node.namedItem( _name );
|
||||
if( node.isElement() )
|
||||
{
|
||||
m_automationPattern->loadSettings( node.toElement() );
|
||||
setValue( m_automationPattern->valueAt( 0 ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
node = _this.namedItem( "connection" );
|
||||
if( node.isElement() )
|
||||
{
|
||||
node = node.namedItem( _name );
|
||||
if( node.isElement() )
|
||||
{
|
||||
//m_controllerConnection = new controllerConnection( (controller*)NULL );
|
||||
setControllerConnection( new controllerConnection( (controller*)NULL ) );
|
||||
m_controllerConnection->loadSettings( node.toElement() );
|
||||
}
|
||||
}
|
||||
|
||||
setInitValue( _this.attribute( _name ).toFloat() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::setValue( const float _value )
|
||||
{
|
||||
const float old_val = m_value;
|
||||
|
||||
m_value = fittedValue( _value );
|
||||
if( old_val != m_value )
|
||||
{
|
||||
// add changes to history so user can undo it
|
||||
addJournalEntry( journalEntry( 0, m_value - old_val ) );
|
||||
|
||||
// notify linked models
|
||||
|
||||
// doesn't work because of implicit typename T
|
||||
for( autoModelVector::iterator it =
|
||||
m_linkedModels.begin();
|
||||
it != m_linkedModels.end(); ++it )
|
||||
{
|
||||
if( value<float>() != (*it)->value<float>() &&
|
||||
(*it)->fittedValue( value<float>() )
|
||||
!= (*it)->value<float>() )
|
||||
{
|
||||
bool journalling = (*it)->testAndSetJournalling(
|
||||
isJournalling() );
|
||||
(*it)->setValue( value<float>() );
|
||||
(*it)->setJournalling( journalling );
|
||||
}
|
||||
}
|
||||
setFirstValue();
|
||||
emit dataChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
emit dataUnchanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::setRange( const float _min, const float _max,
|
||||
const float _step )
|
||||
{
|
||||
if( ( m_maxValue != _max ) || ( m_minValue != _min ) )
|
||||
{
|
||||
m_minValue = _min;
|
||||
m_maxValue = _max;
|
||||
if( m_minValue > m_maxValue )
|
||||
{
|
||||
qSwap<float>( m_minValue, m_maxValue );
|
||||
}
|
||||
m_range = m_maxValue - m_minValue;
|
||||
setStep( _step );
|
||||
|
||||
// re-adjust value
|
||||
setInitValue( value<float>() );
|
||||
|
||||
emit propertiesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::setStep( const float _step )
|
||||
{
|
||||
if( m_step != _step )
|
||||
{
|
||||
m_step = _step;
|
||||
emit propertiesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float automatableModel::fittedValue( float _value ) const
|
||||
{
|
||||
_value = tLimit<float>( _value, m_minValue, m_maxValue );
|
||||
|
||||
if( m_step != 0 )
|
||||
{
|
||||
_value = roundf( _value / m_step ) * m_step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = m_minValue;
|
||||
}
|
||||
|
||||
// correct rounding error at the border
|
||||
if( tAbs<float>( _value - m_maxValue ) <
|
||||
minEps<float>() * tAbs<float>( m_step ) )
|
||||
{
|
||||
_value = m_maxValue;
|
||||
}
|
||||
|
||||
// correct rounding error if value = 0
|
||||
if( tAbs<float>( _value ) < minEps<float>() * tAbs<float>( m_step ) )
|
||||
{
|
||||
_value = 0;
|
||||
}
|
||||
|
||||
return( _value );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::redoStep( journalEntry & _je )
|
||||
{
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
setValue( value<float>() + _je.data().toDouble() );
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::undoStep( journalEntry & _je )
|
||||
{
|
||||
journalEntry je( _je.actionID(), -_je.data().toDouble() );
|
||||
redoStep( je );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::prepareJournalEntryFromOldVal( void )
|
||||
{
|
||||
m_oldValue = value<float>();
|
||||
saveJournallingState( FALSE );
|
||||
m_journalEntryReady = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::addJournalEntryFromOldToCurVal( void )
|
||||
{
|
||||
if( m_journalEntryReady )
|
||||
{
|
||||
restoreJournallingState();
|
||||
if( value<float>() != m_oldValue )
|
||||
{
|
||||
addJournalEntry( journalEntry( 0, value<float>() -
|
||||
m_oldValue ) );
|
||||
}
|
||||
m_journalEntryReady = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::linkModel( automatableModel * _model )
|
||||
{
|
||||
if( qFind( m_linkedModels.begin(), m_linkedModels.end(), _model )
|
||||
== m_linkedModels.end() )
|
||||
{
|
||||
m_linkedModels.push_back( _model );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::unlinkModel( automatableModel * _model )
|
||||
{
|
||||
if( qFind( m_linkedModels.begin(), m_linkedModels.end(), _model )
|
||||
!= m_linkedModels.end() )
|
||||
{
|
||||
m_linkedModels.erase( qFind( m_linkedModels.begin(),
|
||||
m_linkedModels.end(),
|
||||
_model ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::linkModels( automatableModel * _model1,
|
||||
automatableModel * _model2 )
|
||||
{
|
||||
_model1->linkModel( _model2 );
|
||||
_model2->linkModel( _model1 );
|
||||
|
||||
if( _model1->m_automationPattern != _model2->m_automationPattern )
|
||||
{
|
||||
delete _model2->m_automationPattern;
|
||||
_model2->m_automationPattern = _model1->m_automationPattern;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::unlinkModels( automatableModel * _model1,
|
||||
automatableModel * _model2 )
|
||||
{
|
||||
_model1->unlinkModel( _model2 );
|
||||
_model2->unlinkModel( _model1 );
|
||||
|
||||
if( _model1->m_automationPattern && _model1->m_automationPattern
|
||||
== _model2->m_automationPattern )
|
||||
{
|
||||
_model2->m_automationPattern = new automationPattern(
|
||||
*_model1->m_automationPattern, _model2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::initAutomationPattern( void )
|
||||
{
|
||||
m_automationPattern = new automationPattern( NULL, this );
|
||||
}
|
||||
|
||||
automationPattern * automatableModel::getAutomationPattern( void )
|
||||
{
|
||||
if( !m_automationPattern )
|
||||
{
|
||||
m_automationPattern = new automationPattern( m_track, this );
|
||||
setFirstValue();
|
||||
// syncAutomationPattern();
|
||||
}
|
||||
return( m_automationPattern );
|
||||
}
|
||||
|
||||
|
||||
void automatableModel::setFirstValue( void )
|
||||
{
|
||||
if( m_automationPattern && m_automationPattern->updateFirst() )
|
||||
{
|
||||
m_automationPattern->putValue( 0, m_value, FALSE );
|
||||
if( engine::getAutomationEditor() &&
|
||||
engine::getAutomationEditor()->currentPattern()
|
||||
== m_automationPattern )
|
||||
{
|
||||
engine::getAutomationEditor()->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::setInitValue( const float _value )
|
||||
{
|
||||
m_initValue = _value;
|
||||
bool journalling = testAndSetJournalling( FALSE );
|
||||
setValue( _value );
|
||||
if( m_automationPattern )
|
||||
{
|
||||
setFirstValue();
|
||||
}
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void automatableModel::reset( void )
|
||||
{
|
||||
setValue( initValue<float>() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::copyValue( void )
|
||||
{
|
||||
__copiedValue = value<float>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void automatableModel::pasteValue( void )
|
||||
{
|
||||
setValue( __copiedValue );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "automatable_model.moc"
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
|
||||
#include "automation_pattern.h"
|
||||
#include "automation_editor.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "engine.h"
|
||||
#include "level_object.h"
|
||||
#include "note.h"
|
||||
#include "templates.h"
|
||||
#include "track.h"
|
||||
@@ -41,7 +39,8 @@
|
||||
|
||||
|
||||
|
||||
automationPattern::automationPattern( track * _track, levelObject * _object ) :
|
||||
automationPattern::automationPattern( track * _track,
|
||||
automatableModel * _object ) :
|
||||
m_track( _track ),
|
||||
m_object( _object ),
|
||||
m_update_first( TRUE ),
|
||||
@@ -76,7 +75,7 @@ automationPattern::automationPattern( const automationPattern & _pat_to_copy ) :
|
||||
|
||||
|
||||
automationPattern::automationPattern( const automationPattern & _pat_to_copy,
|
||||
levelObject * _object ) :
|
||||
automatableModel * _object ) :
|
||||
m_track( _pat_to_copy.m_track ),
|
||||
m_object( _object ),
|
||||
m_update_first( _pat_to_copy.m_update_first ),
|
||||
@@ -117,17 +116,17 @@ automationPattern::~automationPattern()
|
||||
//TODO: Improve this
|
||||
midiTime automationPattern::length( void ) const
|
||||
{
|
||||
Sint32 max_length = 0;
|
||||
tick max_length = 0;
|
||||
|
||||
for( timeMap::const_iterator it = m_time_map.begin();
|
||||
it != m_time_map.end();
|
||||
++it )
|
||||
{
|
||||
max_length = tMax<Sint32>( max_length, -it.key() );
|
||||
max_length = tMax<tick>( max_length, -it.key() );
|
||||
}
|
||||
if( max_length % DefaultTicksPerTact == 0 )
|
||||
{
|
||||
return( midiTime( tMax<Sint32>( max_length,
|
||||
return( midiTime( tMax<tick>( max_length,
|
||||
DefaultTicksPerTact ) ) );
|
||||
}
|
||||
return( midiTime( tMax( midiTime( max_length ).getTact() + 1, 1 ),
|
||||
@@ -137,7 +136,7 @@ midiTime automationPattern::length( void ) const
|
||||
|
||||
|
||||
|
||||
midiTime automationPattern::putValue( const midiTime & _time, const int _value,
|
||||
midiTime automationPattern::putValue( const midiTime & _time, const float _value,
|
||||
const bool _quant_pos )
|
||||
{
|
||||
midiTime new_time = _quant_pos && engine::getAutomationEditor() ?
|
||||
@@ -171,7 +170,7 @@ void automationPattern::removeValue( const midiTime & _time )
|
||||
if( m_time_map.size() == 1 )
|
||||
{
|
||||
m_dynamic = FALSE;
|
||||
m_object->setLevel( m_time_map[0] );
|
||||
m_object->setValue( m_time_map[0] );
|
||||
if( m_track )
|
||||
{
|
||||
m_track->removeAutomationPattern( this );
|
||||
@@ -196,7 +195,7 @@ void automationPattern::clear( void )
|
||||
|
||||
|
||||
|
||||
int automationPattern::valueAt( const midiTime & _time )
|
||||
float automationPattern::valueAt( const midiTime & _time )
|
||||
{
|
||||
return( m_time_map.lowerBound( -_time ).value() );
|
||||
}
|
||||
@@ -211,8 +210,7 @@ void automationPattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
{
|
||||
QDomElement element = _doc.createElement( "time" );
|
||||
element.setAttribute( "pos", -it.key() );
|
||||
element.setAttribute( "value", m_object->levelToLabel(
|
||||
it.value() ) );
|
||||
element.setAttribute( "value", it.value() );
|
||||
_this.appendChild( element );
|
||||
}
|
||||
}
|
||||
@@ -233,8 +231,7 @@ void automationPattern::loadSettings( const QDomElement & _this )
|
||||
continue;
|
||||
}
|
||||
m_time_map[-element.attribute( "pos" ).toInt()]
|
||||
= m_object->labelToLevel(
|
||||
element.attribute( "value" ) );
|
||||
= element.attribute( "value" ).toFloat();
|
||||
}
|
||||
|
||||
if( !m_dynamic )
|
||||
@@ -281,7 +278,7 @@ void automationPattern::processMidiTime( const midiTime & _time )
|
||||
{
|
||||
if( _time >= 0 )
|
||||
{
|
||||
m_object->setLevel( m_time_map.lowerBound( -_time ).value() );
|
||||
m_object->setValue( m_time_map.lowerBound( -_time ).value() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
71
src/core/combobox_model.cpp
Normal file
71
src/core/combobox_model.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* combobox_model.cpp - implementation of comboBoxModel
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "combobox_model.h"
|
||||
#include "embed.h"
|
||||
|
||||
|
||||
|
||||
void comboBoxModel::addItem( const QString & _item, pixmapLoader * _pl )
|
||||
{
|
||||
m_items.push_back( qMakePair( _item, _pl ) );
|
||||
setRange( 0, m_items.size() - 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void comboBoxModel::clear( void )
|
||||
{
|
||||
setRange( 0, 0 );
|
||||
foreach( const item & _i, m_items )
|
||||
{
|
||||
delete _i.second;
|
||||
}
|
||||
m_items.clear();
|
||||
emit propertiesChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int comboBoxModel::findText( const QString & _txt ) const
|
||||
{
|
||||
for( QVector<item>::const_iterator it = m_items.begin();
|
||||
it != m_items.end(); ++it )
|
||||
{
|
||||
if( ( *it ).first == _txt )
|
||||
{
|
||||
return( it - m_items.begin() );
|
||||
}
|
||||
}
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "combobox_model.moc"
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "effect_chain.h"
|
||||
#include "effect.h"
|
||||
#include "engine.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "track.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ envelopeAndLFOParameters::envelopeAndLFOParameters(
|
||||
m_lfoAttackModel( 0.0, 0.0, 1.0, 0.001, this ),
|
||||
m_lfoSpeedModel( 0.1, 0.01, 1.0, 0.0001, 20000.0, this ),
|
||||
m_lfoAmountModel( 0.0, -1.0, 1.0, 0.005, this ),
|
||||
m_lfoWaveModel( SineWave, 0, NumLfoShapes, 1, this ),
|
||||
m_lfoWaveModel( SineWave, 0, NumLfoShapes, this ),
|
||||
m_x100Model( FALSE, this ),
|
||||
m_controlEnvAmountModel( FALSE, this ),
|
||||
m_lfoFrame( 0 ),
|
||||
|
||||
@@ -287,7 +287,7 @@ arpeggiator::arpeggiator( instrumentTrack * _instrument_track ) :
|
||||
m_arpRangeModel( 1.0f, 1.0f, 9.0f, 1.0f, this ),
|
||||
m_arpTimeModel( 100.0f, 25.0f, 2000.0f, 1.0f, 1.0, this ),
|
||||
m_arpGateModel( 100.0f, 1.0f, 200.0f, 1.0f, this ),
|
||||
m_arpDirectionModel( 0, 0, NumArpDirections, intModel::defaultRelStep(), this ),
|
||||
m_arpDirectionModel( 0, 0, NumArpDirections, this ),
|
||||
m_arpModeModel( this )
|
||||
{
|
||||
m_arpEnabledModel.setTrack( _instrument_track );
|
||||
|
||||
@@ -43,11 +43,9 @@ instrumentMidiIO::instrumentMidiIO( instrumentTrack * _instrument_track,
|
||||
m_instrumentTrack( _instrument_track ),
|
||||
m_midiPort( _port ),
|
||||
m_inputChannelModel( m_midiPort->inputChannel() + 1,
|
||||
0, MIDI_CHANNEL_COUNT,
|
||||
intModel::defaultRelStep(), this ),
|
||||
0, MIDI_CHANNEL_COUNT, this ),
|
||||
m_outputChannelModel( m_midiPort->outputChannel() + 1,
|
||||
1, MIDI_CHANNEL_COUNT,
|
||||
intModel::defaultRelStep(), this ),
|
||||
1, MIDI_CHANNEL_COUNT, this ),
|
||||
m_receiveEnabledModel( FALSE, this ),
|
||||
m_sendEnabledModel( FALSE, this ),
|
||||
m_defaultVelocityInEnabledModel( FALSE, this ),
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
|
||||
#include "ladspa_control.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "ladspa_base.h"
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ lfoController::lfoController( model * _parent ) :
|
||||
m_lfoSpeedModel( 0.1, 0.01, 5.0, 0.0001, 20000.0, this ),
|
||||
m_lfoAmountModel( 1.0, -1.0, 1.0, 0.005, this ),
|
||||
m_lfoPhaseModel( 0.0, 0.0, 360.0, 4.0, this ),
|
||||
m_lfoWaveModel( oscillator::SineWave, 0, oscillator::NumWaveShapes, 1, this ),
|
||||
m_lfoWaveModel( oscillator::SineWave, 0, oscillator::NumWaveShapes, this ),
|
||||
m_duration( 1000 ),
|
||||
m_phaseCorrection( 0 ),
|
||||
m_phaseOffset( 0 ),
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
meterModel::meterModel( ::model * _parent, track * _track ) :
|
||||
model( _parent ),
|
||||
m_numeratorModel( 4, 1, 32, 1, this ),
|
||||
m_denominatorModel( 4, 1, 32, 1, this )
|
||||
m_numeratorModel( 4, 1, 32, this ),
|
||||
m_denominatorModel( 4, 1, 32, this )
|
||||
{
|
||||
m_numeratorModel.setTrack( _track );
|
||||
m_denominatorModel.setTrack( _track );
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "note.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "detuning_helper.h"
|
||||
#include "templates.h"
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
|
||||
#include "note_play_handle.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "config_mgr.h"
|
||||
#include "detuning_helper.h"
|
||||
#include "instrument_sound_shaping.h"
|
||||
@@ -38,21 +37,14 @@
|
||||
|
||||
inline notePlayHandle::baseDetuning::baseDetuning(
|
||||
detuningHelper * _detuning ) :
|
||||
m_detuning( _detuning )
|
||||
m_detuning( _detuning ),
|
||||
m_value( m_detuning->getAutomationPattern()->valueAt( 0 ) )
|
||||
{
|
||||
m_level = m_detuning->getAutomationPattern()->valueAt( 0 );
|
||||
m_value = m_detuning->levelToValue( m_level );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
inline void notePlayHandle::baseDetuning::setLevel( int _level )
|
||||
{
|
||||
m_level = _level;
|
||||
m_value = m_detuning->levelToValue( m_level );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -462,11 +454,11 @@ void notePlayHandle::processMidiTime( const midiTime & _time )
|
||||
{
|
||||
if( _time >= pos() )
|
||||
{
|
||||
int level = detuning()->getAutomationPattern()->valueAt( _time -
|
||||
float v = detuning()->getAutomationPattern()->valueAt( _time -
|
||||
pos() );
|
||||
if( level != m_base_detuning->level() )
|
||||
if( v != m_base_detuning->value() )
|
||||
{
|
||||
m_base_detuning->setLevel( level );
|
||||
m_base_detuning->setValue( v );
|
||||
updateFrequency();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
|
||||
|
||||
#include "caption_menu.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "embed.h"
|
||||
#include "gui_templates.h"
|
||||
#include "instrument_track.h"
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
|
||||
|
||||
#include "automation_track.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "automation_editor.h"
|
||||
#include "bb_editor.h"
|
||||
#include "bb_track.h"
|
||||
@@ -79,12 +78,11 @@ tick midiTime::s_ticksPerTact = DefaultTicksPerTact;
|
||||
song::song( void ) :
|
||||
trackContainer(),
|
||||
m_automationTrack( track::create( track::AutomationTrack, this ) ),
|
||||
m_tempoModel( DefaultTempo, MinTempo, MaxTempo,
|
||||
intModel::defaultRelStep(), this ),
|
||||
m_tempoModel( DefaultTempo, MinTempo, MaxTempo, this ),
|
||||
m_timeSigModel( this, m_automationTrack ),
|
||||
m_oldTicksPerTact( DefaultTicksPerTact ),
|
||||
m_masterVolumeModel( 100, 0, 200, 1, this ),
|
||||
m_masterPitchModel( 0, -12, 12, 1, this ),
|
||||
m_masterVolumeModel( 100, 0, 200, this ),
|
||||
m_masterPitchModel( 0, -12, 12, this ),
|
||||
m_fileName(),
|
||||
m_oldFileName(),
|
||||
m_modified( FALSE ),
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <Qt/QtXml>
|
||||
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
#include "templates.h"
|
||||
@@ -188,8 +187,8 @@ void surroundArea::mouseReleaseEvent( QMouseEvent * )
|
||||
surroundAreaModel::surroundAreaModel( ::model * _parent, track * _track,
|
||||
bool _default_constructed ) :
|
||||
model( _parent, _default_constructed ),
|
||||
m_posX( 0, -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, 1, _parent ),
|
||||
m_posY( 0, -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, 1, _parent )
|
||||
m_posX( 0, -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, _parent ),
|
||||
m_posY( 0, -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, _parent )
|
||||
{
|
||||
m_posX.setTrack( _track );
|
||||
m_posY.setTrack( _track );
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
#include "automation_pattern.h"
|
||||
#include "automation_track.h"
|
||||
#include "automatable_model_templates.h"
|
||||
#include "bb_editor.h"
|
||||
#include "bb_track.h"
|
||||
#include "bb_track_container.h"
|
||||
|
||||
75
src/gui/automatable_model_view.cpp
Normal file
75
src/gui/automatable_model_view.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* automatable_model_view.cpp - implementation of automatableModelView
|
||||
*
|
||||
* Copyright (c) 2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui/QMenu>
|
||||
|
||||
|
||||
#include "automatable_model_view.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "embed.h"
|
||||
|
||||
|
||||
void automatableModelView::addDefaultActions( QMenu * _menu )
|
||||
{
|
||||
automatableModel * _model = modelUntyped();
|
||||
|
||||
_menu->addAction( embed::getIconPixmap( "reload" ),
|
||||
automatableModel::tr( "&Reset (%1%2)" ).
|
||||
arg( _model->displayValue(
|
||||
_model->initValue<float>() ) ).
|
||||
arg( m_unit ),
|
||||
_model, SLOT( reset() ) );
|
||||
_menu->addSeparator();
|
||||
_menu->addAction( embed::getIconPixmap( "edit_copy" ),
|
||||
automatableModel::tr( "&Copy value (%1%2)" ).
|
||||
arg( _model->displayValue(
|
||||
_model->value<float>() ) ).
|
||||
arg( m_unit ),
|
||||
_model, SLOT( copyValue() ) );
|
||||
_menu->addAction( embed::getIconPixmap( "edit_paste" ),
|
||||
automatableModel::tr( "&Paste value (%1%2)").
|
||||
arg( _model->displayValue(
|
||||
automatableModel::copiedValue() ) ).
|
||||
arg( m_unit ),
|
||||
_model, SLOT( pasteValue() ) );
|
||||
|
||||
_menu->addSeparator();
|
||||
|
||||
if( !_model->nullTrack() )
|
||||
{
|
||||
_menu->addAction( embed::getIconPixmap( "automation" ),
|
||||
automatableModel::tr( "&Open in automation editor" ),
|
||||
_model->getAutomationPattern(),
|
||||
SLOT( openInAutomationEditor() ) );
|
||||
_menu->addSeparator();
|
||||
}
|
||||
|
||||
_menu->addAction( embed::getIconPixmap( "controller" ),
|
||||
automatableModel::tr( "Connect to controller..." ),
|
||||
dynamic_cast<QObject *>( this ),
|
||||
SLOT( connectToController() ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -389,8 +389,8 @@ void automationEditor::setCurrentPattern( automationPattern * _new_pattern )
|
||||
return;
|
||||
}
|
||||
|
||||
m_min_level = m_pattern->object()->minLevel();
|
||||
m_max_level = m_pattern->object()->maxLevel();
|
||||
m_min_level = m_pattern->object()->minValue<float>();
|
||||
m_max_level = m_pattern->object()->maxValue<float>();
|
||||
m_scroll_level = ( m_min_level + m_max_level ) / 2;
|
||||
|
||||
timeMap & time_map = m_pattern->getTimeMap();
|
||||
@@ -1203,7 +1203,7 @@ void automationEditor::paintEvent( QPaintEvent * _pe )
|
||||
for( int i = 0; i < 2; ++i )
|
||||
{
|
||||
const QString & label = m_pattern->object()
|
||||
->levelToLabel( level[i] );
|
||||
->displayValue( level[i] );
|
||||
p.setPen( QColor( 240, 240, 240 ) );
|
||||
p.drawText( 1, y[i] - font_height + 1,
|
||||
VALUES_WIDTH - 10, 2 * font_height,
|
||||
@@ -1232,7 +1232,7 @@ void automationEditor::paintEvent( QPaintEvent * _pe )
|
||||
y -= printable * m_y_delta, level += printable )
|
||||
{
|
||||
const QString & label = m_pattern->object()
|
||||
->levelToLabel( level );
|
||||
->displayValue( level );
|
||||
p.setPen( QColor( 240, 240, 240 ) );
|
||||
p.drawText( 1, y - font_height + 1,
|
||||
VALUES_WIDTH - 10, 2 * font_height,
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "clipboard.h"
|
||||
#include "combobox.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <QtGui/QCursor>
|
||||
#include <QtGui/QMouseEvent>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
|
||||
@@ -41,8 +40,7 @@
|
||||
automatableButton::automatableButton( QWidget * _parent,
|
||||
const QString & _name ) :
|
||||
QPushButton( _parent ),
|
||||
autoModelView( new autoModel( FALSE, FALSE, TRUE,
|
||||
autoModel::defaultRelStep(), NULL, TRUE ) ),
|
||||
boolModelView( new boolModel( FALSE, NULL, TRUE ) ),
|
||||
m_group( NULL )
|
||||
{
|
||||
setAccessibleName( _name );
|
||||
@@ -179,7 +177,7 @@ void automatableButton::toggle( void )
|
||||
automatableButtonGroup::automatableButtonGroup( QWidget * _parent,
|
||||
const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) )
|
||||
intModelView( new intModel( 0, 0, 0, NULL, TRUE ) )
|
||||
{
|
||||
hide();
|
||||
setAccessibleName( _name );
|
||||
@@ -246,7 +244,7 @@ void automatableButtonGroup::modelChanged( void )
|
||||
{
|
||||
connect( model(), SIGNAL( dataChanged() ),
|
||||
this, SLOT( updateButtons() ) );
|
||||
autoModelView::modelChanged();
|
||||
intModelView::modelChanged();
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <QtGui/QCursor>
|
||||
#include <QtGui/QMouseEvent>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
#include "knob.h"
|
||||
@@ -41,7 +40,7 @@
|
||||
|
||||
automatableSlider::automatableSlider( QWidget * _parent, const QString & _name ) :
|
||||
QSlider( _parent ),
|
||||
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
intModelView( new intModel( 0, 0, 0, NULL, TRUE ) ),
|
||||
m_showStatus( FALSE )
|
||||
{
|
||||
setAccessibleName( _name );
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QStyleOptionFrame>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
@@ -51,7 +50,7 @@ const int CB_ARROW_BTN_WIDTH = 20;
|
||||
|
||||
comboBox::comboBox( QWidget * _parent, const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new comboBoxModel ),
|
||||
intModelView( new comboBoxModel ),
|
||||
m_menu( this ),
|
||||
m_pressed( FALSE )
|
||||
{
|
||||
@@ -102,10 +101,7 @@ void comboBox::contextMenuEvent( QContextMenuEvent * _me )
|
||||
}
|
||||
|
||||
captionMenu contextMenu( accessibleName() );
|
||||
contextMenu.addAction( embed::getIconPixmap( "automation" ),
|
||||
tr( "&Open in automation editor" ),
|
||||
model()->getAutomationPattern(),
|
||||
SLOT( openInAutomationEditor() ) );
|
||||
addDefaultActions( &contextMenu );
|
||||
contextMenu.exec( QCursor::pos() );
|
||||
}
|
||||
|
||||
@@ -244,51 +240,6 @@ void comboBox::setItem( QAction * _item )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void comboBoxModel::addItem( const QString & _item, pixmapLoader * _pl )
|
||||
{
|
||||
m_items.push_back( qMakePair( _item, _pl ) );
|
||||
setRange( 0, m_items.size() - 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void comboBoxModel::clear( void )
|
||||
{
|
||||
setRange( 0, 0 );
|
||||
foreach( const item & _i, m_items )
|
||||
{
|
||||
delete _i.second;
|
||||
}
|
||||
m_items.clear();
|
||||
emit propertiesChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int comboBoxModel::findText( const QString & _txt ) const
|
||||
{
|
||||
for( QVector<item>::const_iterator it = m_items.begin();
|
||||
it != m_items.end(); ++it )
|
||||
{
|
||||
if( ( *it ).first == _txt )
|
||||
{
|
||||
return( it - m_items.begin() );
|
||||
}
|
||||
}
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "combobox.moc"
|
||||
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ void envelopeAndLFOView::mousePressEvent( QMouseEvent * _me )
|
||||
if( QRect( ENV_GRAPH_X, ENV_GRAPH_Y, s_envGraph->width(),
|
||||
s_envGraph->height() ).contains( _me->pos() ) == TRUE )
|
||||
{
|
||||
if( m_amountKnob->value() < 1.0f )
|
||||
if( m_amountKnob->value<float>() < 1.0f )
|
||||
{
|
||||
m_amountKnob->setValue( 1.0f );
|
||||
}
|
||||
@@ -373,7 +373,7 @@ void envelopeAndLFOView::mousePressEvent( QMouseEvent * _me )
|
||||
else if( QRect( LFO_GRAPH_X, LFO_GRAPH_Y, s_lfoGraph->width(),
|
||||
s_lfoGraph->height() ).contains( _me->pos() ) == TRUE )
|
||||
{
|
||||
if( m_lfoAmountKnob->value() < 1.0f )
|
||||
if( m_lfoAmountKnob->value<float>() < 1.0f )
|
||||
{
|
||||
m_lfoAmountKnob->setValue( 1.0f );
|
||||
}
|
||||
@@ -438,7 +438,7 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * )
|
||||
|
||||
p.setFont( pointSize<8>( p.font() ) );
|
||||
|
||||
const float gray_amount = 1.0f - fabsf( m_amountKnob->value() );
|
||||
const float gray_amount = 1.0f - fabsf( m_amountKnob->value<float>() );
|
||||
|
||||
p.setPen( QPen( QColor( static_cast<int>( 96 * gray_amount ),
|
||||
static_cast<int>( 255 - 159 * gray_amount ),
|
||||
@@ -451,44 +451,44 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * )
|
||||
const int y_base = ENV_GRAPH_Y + s_envGraph->height() - 3;
|
||||
const int avail_height = s_envGraph->height() - 6;
|
||||
|
||||
int x1 = ENV_GRAPH_X + 2 + static_cast<int>( m_predelayKnob->value() *
|
||||
int x1 = ENV_GRAPH_X + 2 + static_cast<int>( m_predelayKnob->value<float>() *
|
||||
TIME_UNIT_WIDTH );
|
||||
int x2 = x1 + static_cast<int>( m_attackKnob->value() *
|
||||
int x2 = x1 + static_cast<int>( m_attackKnob->value<float>() *
|
||||
TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, y_base, x2, y_base - avail_height );
|
||||
p.fillRect( x1 - 1, y_base - 2, 4, 4, end_points_bg_color );
|
||||
p.fillRect( x1, y_base - 1, 2, 2, end_points_color );
|
||||
x1 = x2;
|
||||
x2 = x1 + static_cast<int>( m_holdKnob->value() * TIME_UNIT_WIDTH );
|
||||
x2 = x1 + static_cast<int>( m_holdKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, y_base - avail_height, x2, y_base - avail_height );
|
||||
p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4,
|
||||
end_points_bg_color );
|
||||
p.fillRect( x1, y_base-1-avail_height, 2, 2, end_points_color );
|
||||
x1 = x2;
|
||||
x2 = x1 + static_cast<int>( ( m_decayKnob->value() *
|
||||
m_sustainKnob->value() ) *
|
||||
x2 = x1 + static_cast<int>( ( m_decayKnob->value<float>() *
|
||||
m_sustainKnob->value<float>() ) *
|
||||
TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, y_base-avail_height, x2, static_cast<int>( y_base -
|
||||
avail_height +
|
||||
m_sustainKnob->value() * avail_height ) );
|
||||
m_sustainKnob->value<float>() * avail_height ) );
|
||||
p.fillRect( x1 - 1, y_base - 2 - avail_height, 4, 4,
|
||||
end_points_bg_color );
|
||||
p.fillRect( x1, y_base - 1 - avail_height, 2, 2, end_points_color );
|
||||
x1 = x2;
|
||||
x2 = x1 + static_cast<int>( m_releaseKnob->value() * TIME_UNIT_WIDTH );
|
||||
x2 = x1 + static_cast<int>( m_releaseKnob->value<float>() * TIME_UNIT_WIDTH );
|
||||
|
||||
p.drawLine( x1, static_cast<int>( y_base - avail_height +
|
||||
m_sustainKnob->value() *
|
||||
m_sustainKnob->value<float>() *
|
||||
avail_height ), x2, y_base );
|
||||
p.fillRect( x1-1, static_cast<int>( y_base - avail_height +
|
||||
m_sustainKnob->value() *
|
||||
m_sustainKnob->value<float>() *
|
||||
avail_height ) - 2, 4, 4,
|
||||
end_points_bg_color );
|
||||
p.fillRect( x1, static_cast<int>( y_base - avail_height +
|
||||
m_sustainKnob->value() *
|
||||
m_sustainKnob->value<float>() *
|
||||
avail_height ) - 1, 2, 2,
|
||||
end_points_color );
|
||||
p.fillRect( x2 - 1, y_base - 2, 4, 4, end_points_bg_color );
|
||||
@@ -503,7 +503,7 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * )
|
||||
const float frames_for_graph = SECS_PER_LFO_OSCILLATION *
|
||||
engine::getMixer()->baseSampleRate() / 10;
|
||||
|
||||
const float lfo_gray_amount = 1.0f - fabsf( m_lfoAmountKnob->value() );
|
||||
const float lfo_gray_amount = 1.0f - fabsf( m_lfoAmountKnob->value<float>() );
|
||||
p.setPen( QPen( QColor( static_cast<int>( 96 * lfo_gray_amount ),
|
||||
static_cast<int>( 255 - 159 * lfo_gray_amount ),
|
||||
static_cast<int>( 128 - 32 *
|
||||
@@ -563,7 +563,7 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * )
|
||||
|
||||
p.setPen( QColor( 255, 192, 0 ) );
|
||||
int ms_per_osc = static_cast<int>( SECS_PER_LFO_OSCILLATION *
|
||||
m_lfoSpeedKnob->value() *
|
||||
m_lfoSpeedKnob->value<float>() *
|
||||
1000.0f );
|
||||
p.drawText( LFO_GRAPH_X + 4, LFO_GRAPH_Y + s_lfoGraph->height() - 6,
|
||||
tr( "ms/LFO:" ) );
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
#include "embed.h"
|
||||
#include "caption_menu.h"
|
||||
#include "automation_pattern.h"
|
||||
#include "automatable_model_templates.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ QPixmap * groupBox::s_ledBg = NULL;
|
||||
|
||||
groupBox::groupBox( const QString & _caption, QWidget * _parent ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( NULL ),
|
||||
boolModelView( NULL ),
|
||||
m_caption( _caption )
|
||||
{
|
||||
if( s_ledBg == NULL )
|
||||
@@ -63,8 +63,7 @@ groupBox::groupBox( const QString & _caption, QWidget * _parent ) :
|
||||
m_led->setActiveGraphic( embed::getIconPixmap( "led_green" ) );
|
||||
m_led->setInactiveGraphic( embed::getIconPixmap( "led_off" ) );
|
||||
|
||||
setModel( new autoModel( FALSE, FALSE, TRUE,
|
||||
autoModel::defaultRelStep(), NULL, FALSE ) );
|
||||
setModel( new boolModel( FALSE, NULL, FALSE ) );
|
||||
setAutoFillBackground( TRUE );
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "config_mgr.h"
|
||||
#include "embed.h"
|
||||
@@ -59,19 +58,16 @@
|
||||
#include "controller_connection.h"
|
||||
|
||||
|
||||
float knob::s_copiedValue = 0.0f;
|
||||
textFloat * knob::s_textFloat = NULL;
|
||||
|
||||
|
||||
|
||||
knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new knobModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
floatModelView( new knobModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
m_mouseOffset( 0.0f ),
|
||||
m_buttonPressed( FALSE ),
|
||||
m_knobPixmap( NULL ),
|
||||
m_hintTextBeforeValue( "" ),
|
||||
m_hintTextAfterValue( "" ),
|
||||
m_outerColor( NULL ),
|
||||
m_knobNum( _knob_num ),
|
||||
m_label( "" )
|
||||
@@ -111,16 +107,6 @@ knob::~knob()
|
||||
|
||||
|
||||
|
||||
void knob::setHintText( const QString & _txt_before,
|
||||
const QString & _txt_after )
|
||||
{
|
||||
m_hintTextBeforeValue = _txt_before;
|
||||
m_hintTextAfterValue = _txt_after;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void knob::setLabel( const QString & _txt )
|
||||
{
|
||||
m_label = _txt;
|
||||
@@ -396,7 +382,7 @@ float knob::getValue( const QPoint & _p )
|
||||
}
|
||||
if( engine::getMainWindow()->isShiftPressed() )
|
||||
{
|
||||
return( ( _p.y() - m_origMousePos.y() ) * model()->step() );
|
||||
return( ( _p.y() - m_origMousePos.y() ) * model()->step<float>() );
|
||||
}
|
||||
return( ( _p.y() - m_origMousePos.y() ) * pageSize() );
|
||||
}
|
||||
@@ -413,34 +399,7 @@ void knob::contextMenuEvent( QContextMenuEvent * )
|
||||
mouseReleaseEvent( NULL );
|
||||
|
||||
captionMenu contextMenu( accessibleName() );
|
||||
contextMenu.addAction( embed::getIconPixmap( "reload" ),
|
||||
tr( "&Reset (%1%2)" ).
|
||||
arg( model()->initValue() ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( reset() ) );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( embed::getIconPixmap( "edit_copy" ),
|
||||
tr( "&Copy value (%1%2)" ).
|
||||
arg( model()->value() ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( copyValue() ) );
|
||||
contextMenu.addAction( embed::getIconPixmap( "edit_paste" ),
|
||||
tr( "&Paste value (%1%2)"
|
||||
).arg( s_copiedValue ).arg(
|
||||
m_hintTextAfterValue ),
|
||||
this, SLOT( pasteValue() ) );
|
||||
contextMenu.addSeparator();
|
||||
if( !model()->nullTrack() )
|
||||
{
|
||||
contextMenu.addAction( embed::getIconPixmap( "automation" ),
|
||||
tr( "&Open in automation editor" ),
|
||||
model()->getAutomationPattern(),
|
||||
SLOT( openInAutomationEditor() ) );
|
||||
contextMenu.addSeparator();
|
||||
}
|
||||
contextMenu.addAction( embed::getIconPixmap( "controller" ),
|
||||
tr( "Connect to controller..." ), this,
|
||||
SLOT( connectToController() ) );
|
||||
addDefaultActions( &contextMenu );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( embed::getIconPixmap( "help" ), tr( "&Help" ),
|
||||
this, SLOT( displayHelp() ) );
|
||||
@@ -471,7 +430,7 @@ void knob::dropEvent( QDropEvent * _de )
|
||||
else if( type == "link_object" )
|
||||
{
|
||||
knobModel * mod = (knobModel *)( val.toULong() );
|
||||
autoModel::linkModels( model(), mod );
|
||||
automatableModel::linkModels( model(), mod );
|
||||
mod->setValue( model()->value() );
|
||||
}
|
||||
}
|
||||
@@ -503,10 +462,10 @@ void knob::mousePressEvent( QMouseEvent * _me )
|
||||
QApplication::setOverrideCursor( Qt::BlankCursor );
|
||||
}
|
||||
// s_textFloat->reparent( this );
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number(
|
||||
model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
s_textFloat->moveGlobal( this,
|
||||
QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->show();
|
||||
@@ -532,7 +491,7 @@ void knob::mousePressEvent( QMouseEvent * _me )
|
||||
}
|
||||
else if( _me->button() == Qt::MidButton )
|
||||
{
|
||||
reset();
|
||||
model()->reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,9 +512,9 @@ void knob::mouseMoveEvent( QMouseEvent * _me )
|
||||
}
|
||||
}
|
||||
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number( model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
}
|
||||
|
||||
|
||||
@@ -623,9 +582,9 @@ void knob::wheelEvent( QWheelEvent * _we )
|
||||
model()->incValue( inc );
|
||||
|
||||
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number( model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->setVisibilityTimeOut( 1000 );
|
||||
|
||||
@@ -664,12 +623,12 @@ void knob::setPosition( const QPoint & _p )
|
||||
|
||||
|
||||
|
||||
void knob::reset( void )
|
||||
/*void knob::reset( void )
|
||||
{
|
||||
model()->setValue( model()->initValue() );
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number( model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->setVisibilityTimeOut( 1000 );
|
||||
}
|
||||
@@ -688,12 +647,12 @@ void knob::copyValue( void )
|
||||
void knob::pasteValue( void )
|
||||
{
|
||||
model()->setValue( s_copiedValue );
|
||||
s_textFloat->setText( m_hintTextBeforeValue +
|
||||
s_textFloat->setText( m_description +
|
||||
QString::number( model()->value() ) +
|
||||
m_hintTextAfterValue );
|
||||
m_unit );
|
||||
s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->setVisibilityTimeOut( 1000 );
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <QtGui/QFontMetrics>
|
||||
#include <QtGui/QStyleOptionFrameV2>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
#include "gui_templates.h"
|
||||
@@ -45,7 +44,7 @@
|
||||
lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent,
|
||||
const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
intModelView( new intModel( 0, 0, 0, NULL, TRUE ) ),
|
||||
m_label(),
|
||||
m_numDigits( _num_digits ),
|
||||
m_origMousePos()
|
||||
@@ -68,7 +67,7 @@ lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent,
|
||||
lcdSpinBox::lcdSpinBox( int _num_digits, const QString & _lcd_style,
|
||||
QWidget * _parent, const QString & _name ) :
|
||||
QWidget( _parent ),
|
||||
autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ),
|
||||
intModelView( new intModel( 0, 0, 0, NULL, TRUE ) ),
|
||||
m_label(),
|
||||
m_numDigits( _num_digits ),
|
||||
m_origMousePos()
|
||||
@@ -206,10 +205,8 @@ void lcdSpinBox::update( void )
|
||||
|
||||
void lcdSpinBox::setLabel( const QString & _txt )
|
||||
{
|
||||
int margin = 1;
|
||||
m_label = _txt;
|
||||
|
||||
updateSize();
|
||||
updateSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +286,7 @@ void lcdSpinBox::mouseMoveEvent( QMouseEvent * _me )
|
||||
if( dy > 1 || dy < -1 )
|
||||
{
|
||||
model()->setInitValue( model()->value() -
|
||||
dy / 2 * model()->step() );
|
||||
dy / 2 * model()->step<int>() );
|
||||
emit manualChange();
|
||||
QCursor::setPos( m_origMousePos );
|
||||
}
|
||||
@@ -310,7 +307,7 @@ void lcdSpinBox::wheelEvent( QWheelEvent * _we )
|
||||
{
|
||||
_we->accept();
|
||||
model()->setInitValue( model()->value() +
|
||||
( ( _we->delta() > 0 ) ? 1 : -1 ) * model()->step() );
|
||||
( ( _we->delta() > 0 ) ? 1 : -1 ) * model()->step<int>() );
|
||||
emit manualChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QMdiArea>
|
||||
|
||||
#include "automatable_model_templates.h"
|
||||
#include "engine.h"
|
||||
#include "caption_menu.h"
|
||||
#include "embed.h"
|
||||
@@ -250,23 +249,10 @@ void tempoSyncKnob::modelChanged( void )
|
||||
|
||||
void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * )
|
||||
{
|
||||
mouseReleaseEvent( NULL );
|
||||
|
||||
captionMenu contextMenu( accessibleName() );
|
||||
contextMenu.addAction( embed::getIconPixmap( "reload" ),
|
||||
tr( "&Reset (%1%2)" ).
|
||||
arg( model()->initValue() ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( reset() ) );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( embed::getIconPixmap( "edit_copy" ),
|
||||
tr( "&Copy value (%1%2)" ).
|
||||
arg( value() ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( copyValue() ) );
|
||||
contextMenu.addAction( embed::getIconPixmap( "edit_paste" ),
|
||||
tr( "&Paste value (%1%2)" ).
|
||||
arg( s_copiedValue ).
|
||||
arg( m_hintTextAfterValue ),
|
||||
this, SLOT( pasteValue() ) );
|
||||
addDefaultActions( &contextMenu );
|
||||
contextMenu.addSeparator();
|
||||
|
||||
float limit = 60000.0f / ( engine::getSong()->getTempo() *
|
||||
@@ -329,13 +315,6 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * )
|
||||
|
||||
}
|
||||
|
||||
contextMenu.addAction( embed::getIconPixmap( "automation" ),
|
||||
tr( "&Open in automation editor" ),
|
||||
model()->getAutomationPattern(),
|
||||
SLOT( openInAutomationEditor() ) );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( tr( "Connect to MIDI-device" ), this,
|
||||
SLOT( connectToMidiDevice() ) );
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction( embed::getIconPixmap( "help" ), tr( "&Help" ),
|
||||
this, SLOT( displayHelp() ) );
|
||||
|
||||
@@ -71,7 +71,7 @@ void volumeKnob::mousePressEvent( QMouseEvent * _me )
|
||||
if( configManager::inst()->value( "knobs",
|
||||
"classicalusability").toInt() )
|
||||
{
|
||||
m_mouseOffset = getValue( p ) - value();
|
||||
m_mouseOffset = getValue( p ) - model()->value();
|
||||
}
|
||||
emit sliderPressed();
|
||||
|
||||
@@ -85,14 +85,14 @@ void volumeKnob::mousePressEvent( QMouseEvent * _me )
|
||||
if( configManager::inst()->value( "app", "displaydbv" ).toInt() )
|
||||
{
|
||||
val = QString( " %1 dBV" ).arg(
|
||||
20.0 * log10( value() / 100.0 ),
|
||||
20.0 * log10( model()->value() / 100.0 ),
|
||||
3, 'f', 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
val = QString( " %1%" ).arg( value(), 3, 'f', 0 );
|
||||
val = QString( " %1%" ).arg( model()->value(), 3, 'f', 0 );
|
||||
}
|
||||
s_textFloat->setText( m_hintTextBeforeValue + val );
|
||||
s_textFloat->setText( m_description + val );
|
||||
|
||||
s_textFloat->moveGlobal( this,
|
||||
QPoint( width() + 2, 0 ) );
|
||||
@@ -102,12 +102,12 @@ void volumeKnob::mousePressEvent( QMouseEvent * _me )
|
||||
else if( _me->button() == Qt::LeftButton &&
|
||||
engine::getMainWindow()->isCtrlPressed() == TRUE )
|
||||
{
|
||||
new stringPairDrag( "float_value", QString::number( value() ),
|
||||
new stringPairDrag( "float_value", QString::number( model()->value() ),
|
||||
QPixmap(), this );
|
||||
}
|
||||
else if( _me->button() == Qt::MidButton )
|
||||
{
|
||||
reset();
|
||||
model()->reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ void volumeKnob::mouseMoveEvent( QMouseEvent * _me )
|
||||
{
|
||||
val = QString( " %1%" ).arg( model()->value(), 3, 'f', 0 );
|
||||
}
|
||||
s_textFloat->setText( m_hintTextBeforeValue + val );
|
||||
s_textFloat->setText( m_description + val );
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ void volumeKnob::wheelEvent( QWheelEvent * _we )
|
||||
{
|
||||
val = QString( " %1%" ).arg( model()->value(), 3, 'f', 0 );
|
||||
}
|
||||
s_textFloat->setText( m_hintTextBeforeValue + val );
|
||||
s_textFloat->setText( m_description + val );
|
||||
|
||||
s_textFloat->moveGlobal( this, QPoint( width() + 2, 0 ) );
|
||||
s_textFloat->setVisibilityTimeOut( 1000 );
|
||||
|
||||
@@ -108,10 +108,10 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
|
||||
tr( "unnamed_channel" ) ) ),
|
||||
m_audioPort( tr( "unnamed_channel" ), this ),
|
||||
m_notes(),
|
||||
m_baseNoteModel( 0, 0, KeysPerOctave * NumOctaves - 1, 1, this ),
|
||||
m_baseNoteModel( 0, 0, KeysPerOctave * NumOctaves - 1, this ),
|
||||
m_volumeModel( DefaultVolume, MinVolume, MaxVolume, 1.0f, this ),
|
||||
m_panningModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this ),
|
||||
m_effectChannelModel( 0, 0, NumFxChannels, 1, this ),
|
||||
m_effectChannelModel( 0, 0, NumFxChannels, this ),
|
||||
m_instrument( NULL ),
|
||||
m_soundShaping( this ),
|
||||
m_arpeggiator( this ),
|
||||
@@ -1027,7 +1027,7 @@ class fxLineLcdSpinBox : public lcdSpinBox
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent ( QMouseEvent * _me )
|
||||
{
|
||||
engine::getFxMixerView()->setCurrentFxLine( value() );
|
||||
engine::getFxMixerView()->setCurrentFxLine( model()->value() );
|
||||
//engine::getFxMixerView()->raise();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user