Update default context menu for controllers

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1058 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2008-06-02 22:26:39 +00:00
parent ecb2f0d943
commit fc0e68d7b2
8 changed files with 155 additions and 43 deletions

View File

@@ -5,6 +5,22 @@
* src/gui/main_window.cpp:
Support loading of sf2 files from the sidebar sample browser
* include/knob.h:
* include/automatable_model_view.h:
* src/gui/automatable_model_view.cpp:
* src/gui/widgets/knob.cpp:
* Makefile.am:
- move context menu stuff to automatableModelView
- add automatableModelViewSlots for slots we may wish to call from AMV
* include/midi_controller.h:
code style
* src/core/midi/midi_controller.cpp:
name midiControllers after their channel/controller
2008-06-02 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* src/core/mixer.cpp:

View File

@@ -51,6 +51,7 @@ man1_MANS = lmms.1
lmms_MOC = \
./about_dialog.moc \
./automatable_model.moc \
./automatable_model_view.moc \
./automatable_button.moc \
./automatable_slider.moc \
./automation_editor.moc \

View File

@@ -81,18 +81,37 @@ public:
}
protected:
void addDefaultActions( QMenu * _menu );
QString m_description;
QString m_unit;
} ;
class automatableModelViewSlots : public QObject
{
Q_OBJECT
public:
automatableModelViewSlots(
automatableModelView * _amv,
QObject * _parent );
public slots:
void execConnectionDialog( void );
void removeConnection( void );
protected:
automatableModelView * amv;
} ;
#define generateTypedModelView(type) \
class EXPORT type##ModelView : public automatableModelView \
{\

View File

@@ -100,7 +100,6 @@ public:
public slots:
virtual void enterValue( void );
void connectToMidiDevice( void );
void connectToController( void );
void displayHelp( void );
void friendlyUpdate( void );

View File

@@ -49,6 +49,8 @@ public:
return "MIDI Controller";
}
virtual void processInEvent( const midiEvent & _me,
const midiTime & _time,
bool _lock = TRUE );

View File

@@ -79,6 +79,9 @@ float midiController::value( int _offset )
void midiController::updateMidiPort( void )
{
m_midiPort->setInputChannel( m_midiChannel.value() - 1 );
setName( QString("MIDI ch%1 ctrl%2").
arg( m_midiChannel.value() ).
arg( m_midiController.value() ) );
}
@@ -95,7 +98,7 @@ void midiController::processInEvent( const midiEvent & _me,
bytes = _me.m_data.m_bytes;
controllerNum = _me.m_data.m_bytes[0] & 0x7F;
if( m_midiController.value() == controllerNum + 1 &&
if( m_midiController.value() == controllerNum + 1 &&
( m_midiChannel.value() == _me.m_channel + 1 ||
m_midiChannel.value() == 0 ) )
{

View File

@@ -28,13 +28,20 @@
#include "automatable_model_view.h"
#include "automation_pattern.h"
#include "controller_connection_dialog.h"
#include "controller_connection.h"
#include "embed.h"
void automatableModelView::addDefaultActions( QMenu * _menu )
{
automatableModel * _model = modelUntyped();
automatableModelViewSlots * amvSlots =
new automatableModelViewSlots( this, _menu );
_menu->addAction( embed::getIconPixmap( "reload" ),
automatableModel::tr( "&Reset (%1%2)" ).
arg( _model->displayValue(
@@ -66,10 +73,108 @@ void automatableModelView::addDefaultActions( QMenu * _menu )
_menu->addSeparator();
}
_menu->addAction( embed::getIconPixmap( "controller" ),
automatableModel::tr( "Connect to controller..." ),
dynamic_cast<QObject *>( this ),
SLOT( connectToController() ) );
QString controllerTxt;
if( _model->getControllerConnection() )
{
controller * cont = _model->getControllerConnection()->getController();
if( cont )
{
controllerTxt = automatableModel::tr("Connected to %1").
arg( cont->name() );
}
else
{
controllerTxt = automatableModel::tr("Connected to controller");
}
QMenu * contMenu = _menu->addMenu( embed::getIconPixmap( "controller" ),
controllerTxt );
contMenu->addAction( embed::getIconPixmap( "controller" ),
automatableModel::tr("Edit connection..."),
amvSlots,
SLOT( execConnectionDialog() ) );
contMenu->addAction( embed::getIconPixmap( "cancel" ),
automatableModel::tr("Remove connection"),
amvSlots,
SLOT( removeConnection() ) );
}
else
{
_menu->addAction( embed::getIconPixmap( "controller" ),
automatableModel::tr("Connect to controller..."),
amvSlots,
SLOT( execConnectionDialog() ) );
}
}
automatableModelViewSlots::automatableModelViewSlots(
automatableModelView * _amv,
QObject * _parent ) :
QObject(),
amv( _amv )
{
QObject::connect( _parent, SIGNAL( destroyed() ),
this, SLOT( deleteLater() ),
Qt::QueuedConnection );
}
void automatableModelViewSlots::execConnectionDialog( void )
{
// TODO[pg]: Display a dialog with list of controllers currently in the song
// in addition to any system MIDI controllers
automatableModel * m = amv->modelUntyped();
controllerConnectionDialog * d = new controllerConnectionDialog(
(QWidget*)engine::getMainWindow(),
m->getControllerConnection() );
d->exec();
// Actually chose something
if (d->chosenController() != NULL )
{
// Update
if( m->getControllerConnection() )
{
m->getControllerConnection()->
setController( d->chosenController() );
}
// New
else
{
m->setControllerConnection(
new controllerConnection( d->chosenController() ) );
}
}
// no controller, so delete existing connection
else
{
removeConnection();
}
delete d;
}
void automatableModelViewSlots::removeConnection( void )
{
automatableModel * m = amv->modelUntyped();
if( m->getControllerConnection() )
{
delete m->getControllerConnection();
m->setControllerConnection( NULL );
}
}
#include "automatable_model_view.moc"

View File

@@ -54,8 +54,6 @@
#include "templates.h"
#include "text_float.h"
#include "song.h"
#include "controller_connection_dialog.h"
#include "controller_connection.h"
textFloat * knob::s_textFloat = NULL;
@@ -686,39 +684,6 @@ void knob::connectToMidiDevice( void )
}
void knob::connectToController( void )
{
// TODO[pg]: Display a dialog with list of controllers currently in the song
// in addition to any system MIDI controllers
controllerConnectionDialog * d = new controllerConnectionDialog(
engine::getMainWindow(),
model()->getControllerConnection() );
d->exec();
if (d->chosenController() != NULL )
{
if( model()->getControllerConnection() )
{
model()->getControllerConnection()->
setController( d->chosenController() );
}
else
{
model()->setControllerConnection(
new controllerConnection( d->chosenController() ) );
}
}
else if( model()->getControllerConnection() )
{
delete model()->getControllerConnection();
model()->setControllerConnection( NULL );
}
delete d;
}
void knob::friendlyUpdate( void )
@@ -730,6 +695,8 @@ void knob::friendlyUpdate( void )
}
void knob::doConnections( void )
{
if( model() != NULL )