diff --git a/ChangeLog b/ChangeLog index 8e4a5029c..f57b06de8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,17 @@ 2006-08-16 Danny McRae + * src/widgets/tempo_sync_knob.cpp: + changed context menu to only display possible note length + options based on the knob's max value + + * include/ladspa_effect.h: + * src/core/ladspa_effect.cpp: + - added a new port data type TIME for port names containing + "(ms)", "(S)", or "(Seconds)" + - converts units to milliseconds for TIME ports + + * src/widgets/ladspa_control.cpp: + use a tempoSyncKnob for TIME ports + * src/widgets/automatable_button.cpp: remove toggled signal sent from method toggle--it's also sent from setValue, and the double signal was wreaking havoc with diff --git a/src/widgets/ladspa_control.cpp b/src/widgets/ladspa_control.cpp index 7c9383d15..8a15cf72c 100644 --- a/src/widgets/ladspa_control.cpp +++ b/src/widgets/ladspa_control.cpp @@ -41,6 +41,7 @@ #include "ladspa_control.h" #include "ladspa_effect.h" #include "tooltip.h" +#include "tempo_sync_knob.h" ladspaControl::ladspaControl( QWidget * _parent, @@ -125,7 +126,33 @@ ladspaControl::ladspaControl( QWidget * _parent, m_knob->setLabel( m_port->name ); m_knob->setRange( m_port->min, m_port->max, ( m_port->max - - m_port->min ) / 400.0f ); + m_port->min ) / 400.0f ); + m_knob->setInitValue( m_port->def ); + m_knob->setHintText( tr( "Value:" ) + " ", "" ); +#ifdef QT4 + m_knob->setWhatsThis( +#else + QWhatsThis::add( m_knob, +#endif + tr( "Sorry, no help available." ) ); + setFixedSize( m_knob->width(), m_knob->height() ); + if( _link ) + { + m_layout->addWidget( m_knob ); + setFixedSize( m_link->width() + + m_knob->width(), + m_knob->height() ); + } + break; + case TIME: + m_knob = new tempoSyncKnob( knobBright_26, this, + m_port->name, eng(), m_track); + connect( m_knob, SIGNAL( valueChanged( float ) ), + this, SLOT( knobChange( float ) ) ); + m_knob->setLabel( m_port->name ); + m_knob->setRange( m_port->min, m_port->max, + ( m_port->max - + m_port->min ) / 400.0f ); m_knob->setInitValue( m_port->def ); m_knob->setHintText( tr( "Value:" ) + " ", "" ); #ifdef QT4 @@ -169,11 +196,10 @@ LADSPA_Data ladspaControl::getValue( void ) m_toggle->isChecked() ); break; case INTEGER: - value = static_cast( m_knob->value() ); - break; case FLOAT: + case TIME: value = static_cast( m_knob->value() ); - break; + break; default: printf( "ladspaControl::getValue BAD BAD BAD\n" ); break; @@ -196,6 +222,7 @@ void ladspaControl::setValue( LADSPA_Data _value ) m_knob->setValue( static_cast( _value ) ); break; case FLOAT: + case TIME: m_knob->setValue( static_cast( _value ) ); break; default: @@ -222,6 +249,7 @@ void FASTCALL ladspaControl::saveSettings( QDomDocument & _doc, break; case INTEGER: case FLOAT: + case TIME: m_knob->saveSettings( _doc, _this, _name ); break; default: @@ -246,6 +274,7 @@ void FASTCALL ladspaControl::loadSettings( const QDomElement & _this, break; case INTEGER: case FLOAT: + case TIME: m_knob->loadSettings( _this, _name ); break; default: @@ -266,6 +295,7 @@ void FASTCALL ladspaControl::linkControls( ladspaControl * _control ) break; case INTEGER: case FLOAT: + case TIME: knob::linkObjects( m_knob, _control->getKnob() ); break; default: @@ -301,6 +331,7 @@ void FASTCALL ladspaControl::unlinkControls( ladspaControl * _control ) break; case INTEGER: case FLOAT: + case TIME: knob::unlinkObjects( m_knob, _control->getKnob() ); break; default: diff --git a/src/widgets/tempo_sync_knob.cpp b/src/widgets/tempo_sync_knob.cpp index a4673a27f..f1575c3eb 100644 --- a/src/widgets/tempo_sync_knob.cpp +++ b/src/widgets/tempo_sync_knob.cpp @@ -105,66 +105,110 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) m_hintTextAfterValue ), this, SLOT( pasteValue() ) ); contextMenu.addSeparator(); + + float limit = 60000.0f / ( eng()->getSongEditor()->getTempo() * + m_scale ); + #ifdef QT4 QMenu * syncMenu = contextMenu.addMenu( m_tempoSyncIcon, - m_tempoSyncDescription ); +#else + QMenu * syncMenu = new QMenu( this ); +#endif + if( limit / 8.0f <= maxValue() ) + { +#ifdef QT4 connect( syncMenu, SIGNAL( triggered( QAction * ) ), this, SLOT( setTempoSync( QAction * ) ) ); syncMenu->addAction( embed::getIconPixmap( "note_none" ), tr( "No Sync" ) )->setData( (int) NO_SYNC ); - syncMenu->addAction( embed::getIconPixmap( "note_double_whole" ), + if( limit / 0.125f <= maxValue() ) + { + syncMenu->addAction( embed::getIconPixmap( "note_double_whole" ), tr( "Eight beats" ) )->setData( (int) DOUBLE_WHOLE_NOTE ); - syncMenu->addAction( embed::getIconPixmap( "note_whole" ), + } + if( limit / 0.25f <= maxValue() ) + { + syncMenu->addAction( embed::getIconPixmap( "note_whole" ), tr( "Whole note" ) )->setData( (int) WHOLE_NOTE ); - syncMenu->addAction( embed::getIconPixmap( "note_half" ), + } + if( limit / 0.5f <= maxValue() ) + { + syncMenu->addAction( embed::getIconPixmap( "note_half" ), tr( "Half note" ) )->setData( (int) HALF_NOTE ); - syncMenu->addAction( embed::getIconPixmap( "note_quarter" ), + } + if( limit <= maxValue() ) + { + syncMenu->addAction( embed::getIconPixmap( "note_quarter" ), tr( "Quarter note" ) )->setData( (int) QUARTER_NOTE ); - syncMenu->addAction( embed::getIconPixmap( "note_eighth" ), + } + if( limit / 2.0f <= maxValue() ) + { + syncMenu->addAction( embed::getIconPixmap( "note_eighth" ), tr( "8th note" ) )->setData( (int) EIGHTH_NOTE ); - syncMenu->addAction( embed::getIconPixmap( "note_sixteenth" ), + } + if( limit / 4.0f <= maxValue() ) + { + syncMenu->addAction( embed::getIconPixmap( "note_sixteenth" ), tr( "16th note" ) )->setData( (int) SIXTEENTH_NOTE ); + } syncMenu->addAction( embed::getIconPixmap( "note_thirtysecond" ), tr( "32nd note" ) )->setData( (int) THIRTYSECOND_NOTE ); #else - QMenu * syncMenu = new QMenu( this ); int menuId; menuId = syncMenu->addAction( embed::getIconPixmap( "note_none" ), tr( "No Sync" ), this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) NO_SYNC ); - menuId = syncMenu->addAction( embed::getIconPixmap( + if( limit / 0.125f <= maxValue() ) + { + menuId = syncMenu->addAction( embed::getIconPixmap( "note_double_whole" ), tr( "Eight beats" ), this, SLOT( setTempoSync( int ) ) ); - syncMenu->setItemParameter( menuId, ( int ) DOUBLE_WHOLE_NOTE ); - menuId = syncMenu->addAction( embed::getIconPixmap( "note_whole" ), + syncMenu->setItemParameter( menuId, ( int ) DOUBLE_WHOLE_NOTE ); + } + if( limit / 0.25f <= maxValue() ) + { + menuId = syncMenu->addAction( embed::getIconPixmap( "note_whole" ), tr( "Whole note" ), this, SLOT( setTempoSync( int ) ) ); - syncMenu->setItemParameter( menuId, ( int ) WHOLE_NOTE ); - menuId = syncMenu->addAction( embed::getIconPixmap( "note_half" ), + syncMenu->setItemParameter( menuId, ( int ) WHOLE_NOTE ); + } + if( limit / 0.5f <= maxValue() ) + { + menuId = syncMenu->addAction( embed::getIconPixmap( "note_half" ), tr( "Half note" ), this, SLOT( setTempoSync( int ) ) ); - syncMenu->setItemParameter( menuId, ( int ) HALF_NOTE ); - menuId = syncMenu->addAction( embed::getIconPixmap( "note_quarter" ), + syncMenu->setItemParameter( menuId, ( int ) HALF_NOTE ); + } + if( limit <= maxValue() ) + { + menuId = syncMenu->addAction( embed::getIconPixmap( "note_quarter" ), tr( "Quarter note" ), this, SLOT( setTempoSync( int ) ) ); - syncMenu->setItemParameter( menuId, ( int ) QUARTER_NOTE ); - menuId = syncMenu->addAction( embed::getIconPixmap( "note_eighth" ), + syncMenu->setItemParameter( menuId, ( int ) QUARTER_NOTE ); + } + if( limit / 2.0f <= maxValue() ) + { + menuId = syncMenu->addAction( embed::getIconPixmap( "note_eighth" ), tr( "8th note" ), this, SLOT( setTempoSync( int ) ) ); - syncMenu->setItemParameter( menuId, ( int ) EIGHTH_NOTE ); - menuId = syncMenu->addAction( embed::getIconPixmap( "note_sixteenth" ), + syncMenu->setItemParameter( menuId, ( int ) EIGHTH_NOTE ); + } + if( limit / 4.0f <= maxValue() ) + { + menuId = syncMenu->addAction( embed::getIconPixmap( "note_sixteenth" ), tr( "16th note" ), this, SLOT( setTempoSync( int ) ) ); - syncMenu->setItemParameter( menuId, ( int ) SIXTEENTH_NOTE ); + syncMenu->setItemParameter( menuId, ( int ) SIXTEENTH_NOTE ); + } menuId = syncMenu->addAction( embed::getIconPixmap( "note_thirtysecond" ), tr( "32nd note" ), @@ -176,6 +220,7 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) #endif contextMenu.addSeparator(); + } contextMenu.addAction( embed::getIconPixmap( "automation" ), tr( "&Open in automation editor" ),