Improvements to controllers

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@902 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2008-04-08 08:23:58 +00:00
parent 40879221cf
commit 78f0a045cc
21 changed files with 1699 additions and 16 deletions

View File

@@ -35,11 +35,14 @@
#include "engine.h"
#include "mixer.h"
#include "controller.h"
#include "controller_dialog.h"
unsigned int controller::s_frames = 0;
QVector<controller *> controller::s_controllers;
controller::controller( void )
controller::controller( model * _parent ) :
model( _parent )
{
s_controllers.append( this );
}
@@ -102,6 +105,12 @@ void controller::resetFrameCounter( void )
s_frames = 0;
}
controllerDialog * controller::createDialog( QWidget * _parent )
{
controllerDialog * d = new controllerDialog( this, _parent );
return d;
}
#include "controller.moc"

View File

@@ -30,6 +30,7 @@
#include "bb_editor.h"
#include "bb_track_container.h"
#include "config_mgr.h"
#include "controller_rack_view.h"
#include "fx_mixer.h"
#include "ladspa_2_lmms.h"
#include "main_window.h"
@@ -59,6 +60,7 @@ projectNotes * engine::s_projectNotes = NULL;
projectJournal * engine::s_projectJournal = NULL;
ladspa2LMMS * engine::s_ladspaManager = NULL;
dummyTrackContainer * engine::s_dummyTC = NULL;
controllerRackView * engine::s_controllerRackView = NULL;
QMap<QString, QString> engine::s_sampleExtensions;
@@ -81,6 +83,7 @@ void engine::init( const bool _has_gui )
s_mainWindow = new mainWindow;
s_fxMixerView = new fxMixerView;
s_songEditor = new songEditor( s_song );
s_controllerRackView = new controllerRackView;
s_projectNotes = new projectNotes;
s_bbEditor = new bbEditor( s_bbTrackContainer );
s_pianoRoll = new pianoRoll;

View File

@@ -1055,6 +1055,15 @@ void song::setModified( void )
}
void song::addController( controller * _c )
{
if( _c != NULL && !m_controllers.contains( _c ) )
{
m_controllers.append( _c );
emit dataChanged();
}
}
#include "song.moc"

View File

@@ -0,0 +1,314 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* controller_connection_dialog.cpp -
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail.com>
*
* 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/QLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include "controller_connection_dialog.h"
#include "lcd_spinbox.h"
#include "combobox.h"
#include "group_box.h"
#include "song.h"
#include "gui_templates.h"
#include "embed.h"
controllerConnectionDialog::controllerConnectionDialog( QWidget * _parent
) :
QDialog( _parent ),
m_controller( NULL )
{
setWindowIcon( embed::getIconPixmap( "setup_audio" ) );
setWindowTitle( tr( "Connection Settings" ) );
setModal( TRUE );
QVBoxLayout * vlayout = new QVBoxLayout( this );
vlayout->setSpacing( 10 );
vlayout->setMargin( 10 );
m_midiGroupBox = new groupBox( tr( "MIDI CONTROLLER" ), this );
m_midiGroupBox->setGeometry( 2, 2, 240, 64 );
m_userGroupBox = new groupBox( tr( "USER CONTROLLER" ), this );
m_userGroupBox->setGeometry( 2, 70, 240, 64 );
m_mappingFunction = new QLineEdit( this );
m_mappingFunction->setGeometry( 2, 140, 240, 16 );
m_mappingFunction->setText( "input" );
QWidget * buttons = new QWidget( this );
buttons->setGeometry( 2, 160, 240, 32 );
resize( 256, 196 );
m_userController = new comboBox( m_userGroupBox, "Controller" );
m_userController->setGeometry( 10, 20, 200, 22 );
for( int i = 0; i < engine::getSong()->controllers().size(); ++i )
{
controller * c = engine::getSong()->controllers().at( i );
m_userController->model()->addItem( c->publicName() );
}
QHBoxLayout * btn_layout = new QHBoxLayout( buttons );
btn_layout->setSpacing( 0 );
btn_layout->setMargin( 0 );
QPushButton * select_btn = new QPushButton(
embed::getIconPixmap( "add" ),
tr( "OK" ), buttons );
connect( select_btn, SIGNAL( clicked() ),
this, SLOT( selectController() ) );
QPushButton * cancel_btn = new QPushButton(
embed::getIconPixmap( "cancel" ),
tr( "Cancel" ), buttons );
//connect( cancel_btn, SIGNAL( clicked() ),
// this, SLOT( reject() ) );
btn_layout->addStretch();
btn_layout->addSpacing( 10 );
btn_layout->addWidget( select_btn );
/* btn_layout->addSpacing( 10 );
btn_layout->addWidget( ports_btn );*/
btn_layout->addSpacing( 10 );
btn_layout->addWidget( cancel_btn );
btn_layout->addSpacing( 10 );
show();
}
controllerConnectionDialog::~controllerConnectionDialog()
{
}
/*
void effectSelectDialog::setSelection( const effectKey & _selection )
{
m_currentSelection = _selection;
}
*/
void controllerConnectionDialog::selectController( void )
{
if( m_userController->model()->value() >= 0 ) {
m_controller = engine::getSong()->controllers().at(
m_userController->model()->value() );
}
accept();
}
/*
effectListWidget::effectListWidget( QWidget * _parent ) :
QWidget( _parent ),
m_sourceModel(),
m_model(),
m_descriptionWidget( NULL )
{
plugin::getDescriptorsOfAvailPlugins( m_pluginDescriptors );
for( QVector<plugin::descriptor>::iterator it =
m_pluginDescriptors.begin();
it != m_pluginDescriptors.end(); ++it )
{
if( it->type != plugin::Effect )
{
continue;
}
if( it->sub_plugin_features )
{
it->sub_plugin_features->listSubPluginKeys(
// as iterators are always stated to be not
// equal with pointers, we dereference the
// iterator and take the address of the item,
// so we're on the safe side and the compiler
// likely will reduce that to just "it"
&( *it ),
m_effectKeys );
}
else
{
m_effectKeys << effectKey( &( *it ), it->name );
}
}
QStringList plugin_names;
for( effectKeyList::const_iterator it = m_effectKeys.begin();
it != m_effectKeys.end(); ++it )
{
plugin_names += QString( ( *it ).desc->public_name ) +
( ( ( *it ).desc->sub_plugin_features != NULL ) ?
": " + ( *it ).name
:
"" );
}
int row = 0;
for( QStringList::iterator it = plugin_names.begin();
it != plugin_names.end(); ++it )
{
m_sourceModel.setItem( row, 0, new QStandardItem( *it ) );
++row;
}
m_model.setSourceModel( &m_sourceModel );
m_model.setFilterCaseSensitivity( Qt::CaseInsensitive );
m_filterEdit = new QLineEdit( this );
connect( m_filterEdit, SIGNAL( textChanged( const QString & ) ),
&m_model, SLOT( setFilterRegExp( const QString & ) ) );
m_pluginList = new QListView( this );
m_pluginList->setModel( &m_model );
QItemSelectionModel * sm = new QItemSelectionModel( &m_model );
m_pluginList->setSelectionModel( sm );
m_pluginList->setSelectionBehavior( QAbstractItemView::SelectRows );
m_pluginList->setSelectionMode( QAbstractItemView::SingleSelection );
m_pluginList->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
connect( sm, SIGNAL( currentRowChanged( const QModelIndex &,
const QModelIndex & ) ),
SLOT( rowChanged( const QModelIndex &,
const QModelIndex & ) ) );
connect( m_pluginList, SIGNAL( doubleClicked( const QModelIndex & ) ),
SLOT( onDoubleClicked( const QModelIndex & ) ) );
QGroupBox * groupbox = new QGroupBox( tr( "Description" ), this );
groupbox->setFixedHeight( 200 );
QVBoxLayout * gbl = new QVBoxLayout( groupbox );
gbl->setMargin( 0 );
gbl->setSpacing( 10 );
m_scrollArea = new QScrollArea( groupbox );
m_scrollArea->setFrameStyle( 0 );
gbl->addWidget( m_scrollArea );
QVBoxLayout * vboxl = new QVBoxLayout( this );
vboxl->setMargin( 0 );
vboxl->setSpacing( 10 );
vboxl->addWidget( m_filterEdit );
vboxl->addWidget( m_pluginList );
vboxl->addWidget( groupbox );
if( m_sourceModel.rowCount() > 0 )
{
// m_pluginList->setCurrentRow( 0 );
//rowChanged( 0 );
}
}
effectListWidget::~effectListWidget()
{
}
void effectListWidget::rowChanged( const QModelIndex & _idx,
const QModelIndex & )
{
delete m_descriptionWidget;
m_descriptionWidget = NULL;
m_currentSelection = m_effectKeys[_idx.row()];
if( m_currentSelection.desc &&
m_currentSelection.desc->sub_plugin_features )
{
m_descriptionWidget = new QWidget;
QVBoxLayout * l = new QVBoxLayout( m_descriptionWidget );
l->setMargin( 4 );
l->setSpacing( 0 );
m_scrollArea->setWidget( m_descriptionWidget );
m_currentSelection.desc->sub_plugin_features->
fillDescriptionWidget( m_descriptionWidget,
&m_currentSelection );
foreach( QWidget * w,
m_descriptionWidget->findChildren<QWidget *>() )
{
if( w->parent() == m_descriptionWidget )
{
l->addWidget( w );
}
}
l->setSizeConstraint( QLayout::SetFixedSize );
m_descriptionWidget->show();
}
emit( highlighted( m_currentSelection ) );
}
void effectListWidget::onDoubleClicked( const QModelIndex & )
{
emit( doubleClicked( m_currentSelection ) );
}
void effectListWidget::onAddButtonReleased()
{
emit( addPlugin( m_currentSelection ) );
}
void effectListWidget::resizeEvent( QResizeEvent * )
{
//m_descriptionWidget->setFixedWidth( width() - 40 );
}
*/
#include "controller_connection_dialog.moc"
#endif

View File

@@ -0,0 +1,271 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* controller_dialog.cpp - per-controller-specific view for changing a
* controller's settings
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail.com>
*
* 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/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QMdiArea>
#include <QtGui/QMdiSubWindow>
#include <QtGui/QPainter>
#include "caption_menu.h"
#include "gui_templates.h"
#include "embed.h"
#include "engine.h"
#include "led_checkbox.h"
#include "main_window.h"
#include "tooltip.h"
#include "lfo_controller.h"
#include "controller_dialog.h"
#include "mv_base.h"
#include "knob.h"
#include "tempo_sync_knob.h"
#include "pixmap_button.h"
const int ENV_KNOBS_LBL_Y = 0;
const int KNOB_X_SPACING = 32;
const int LFO_GRAPH_X = 6;
const int LFO_GRAPH_Y = ENV_KNOBS_LBL_Y+14;
const int LFO_KNOB_Y = LFO_GRAPH_Y-2;
const int LFO_PREDELAY_KNOB_X = LFO_GRAPH_X + 10;
const int LFO_ATTACK_KNOB_X = LFO_PREDELAY_KNOB_X+KNOB_X_SPACING;
const int LFO_SPEED_KNOB_X = LFO_ATTACK_KNOB_X+KNOB_X_SPACING;
const int LFO_AMOUNT_KNOB_X = LFO_SPEED_KNOB_X+KNOB_X_SPACING;
const int LFO_SHAPES_X = LFO_GRAPH_X;//PREDELAY_KNOB_X;
const int LFO_SHAPES_Y = LFO_GRAPH_Y + 50;
lfoControllerDialog::lfoControllerDialog( controller * _model, QWidget * _parent ) :
controllerDialog( _model, _parent )
{
setFixedSize( 256, 64 );
toolTip::add( this, tr( "Poor lonely controller" ) );
m_lfoAttackKnob = new knob( knobBright_26, this,
tr( "LFO-attack-time" ) );
m_lfoAttackKnob->setLabel( tr( "ATT" ) );
m_lfoAttackKnob->move( LFO_ATTACK_KNOB_X, LFO_KNOB_Y );
m_lfoAttackKnob->setHintText( tr( "LFO-attack:" ) + " ", "" );
m_lfoAttackKnob->setWhatsThis(
tr( "Use this knob for setting attack-time of the current LFO. "
"The bigger this value the longer the LFO needs to "
"increase its amplitude to maximum." ) );
m_lfoSpeedKnob = new tempoSyncKnob( knobBright_26, this,
tr( "LFO-speed" ) );
m_lfoSpeedKnob->setLabel( tr( "SPD" ) );
m_lfoSpeedKnob->move( LFO_SPEED_KNOB_X, LFO_KNOB_Y );
m_lfoSpeedKnob->setHintText( tr( "LFO-speed:" ) + " ", "" );
m_lfoSpeedKnob->setWhatsThis(
tr( "Use this knob for setting speed of the current LFO. The "
"bigger this value the faster the LFO oscillates and "
"the faster will be your effect." ) );
m_lfoAmountKnob = new knob( knobBright_26, this,
tr( "LFO-modulation-amount" ) );
m_lfoAmountKnob->setLabel( tr( "AMT" ) );
m_lfoAmountKnob->move( LFO_AMOUNT_KNOB_X, LFO_KNOB_Y );
m_lfoAmountKnob->setHintText( tr( "Modulation amount:" ) + " ", "" );
m_lfoAmountKnob->setWhatsThis(
tr( "Use this knob for setting modulation amount of the "
"current LFO. The bigger this value the more the "
"selected size (e.g. volume or cutoff-frequency) will "
"be influenced by this LFO." ) );
pixmapButton * sin_lfo_btn = new pixmapButton( this, NULL );
sin_lfo_btn->move( LFO_SHAPES_X, LFO_SHAPES_Y );
sin_lfo_btn->setActiveGraphic( embed::getIconPixmap(
"sin_wave_active" ) );
sin_lfo_btn->setInactiveGraphic( embed::getIconPixmap(
"sin_wave_inactive" ) );
sin_lfo_btn->setWhatsThis(
tr( "Click here if you want a sine-wave for current "
"oscillator." ) );
pixmapButton * triangle_lfo_btn = new pixmapButton( this, NULL );
triangle_lfo_btn->move( LFO_SHAPES_X+15, LFO_SHAPES_Y );
triangle_lfo_btn->setActiveGraphic( embed::getIconPixmap(
"triangle_wave_active" ) );
triangle_lfo_btn->setInactiveGraphic( embed::getIconPixmap(
"triangle_wave_inactive" ) );
triangle_lfo_btn->setWhatsThis(
tr( "Click here if you want a triangle-wave for current "
"oscillator." ) );
pixmapButton * saw_lfo_btn = new pixmapButton( this, NULL );
saw_lfo_btn->move( LFO_SHAPES_X+30, LFO_SHAPES_Y );
saw_lfo_btn->setActiveGraphic( embed::getIconPixmap(
"saw_wave_active" ) );
saw_lfo_btn->setInactiveGraphic( embed::getIconPixmap(
"saw_wave_inactive" ) );
saw_lfo_btn->setWhatsThis(
tr( "Click here if you want a saw-wave for current "
"oscillator." ) );
pixmapButton * sqr_lfo_btn = new pixmapButton( this, NULL );
sqr_lfo_btn->move( LFO_SHAPES_X+45, LFO_SHAPES_Y );
sqr_lfo_btn->setActiveGraphic( embed::getIconPixmap(
"square_wave_active" ) );
sqr_lfo_btn->setInactiveGraphic( embed::getIconPixmap(
"square_wave_inactive" ) );
sqr_lfo_btn->setWhatsThis(
tr( "Click here if you want a square-wave for current "
"oscillator." ) );
m_userLfoBtn = new pixmapButton( this, NULL );
m_userLfoBtn->move( LFO_SHAPES_X+60, LFO_SHAPES_Y );
m_userLfoBtn->setActiveGraphic( embed::getIconPixmap(
"usr_wave_active" ) );
m_userLfoBtn->setInactiveGraphic( embed::getIconPixmap(
"usr_wave_inactive" ) );
m_userLfoBtn->setWhatsThis(
tr( "Click here if you want a user-defined wave for current "
"oscillator. Afterwards drag an according sample-"
"file into LFO-graph." ) );
connect( m_userLfoBtn, SIGNAL( toggled( bool ) ),
this, SLOT( lfoUserWaveChanged() ) );
m_lfoWaveBtnGrp = new automatableButtonGroup( this,
tr( "LFO wave shape" ) );
m_lfoWaveBtnGrp->addButton( sin_lfo_btn );
m_lfoWaveBtnGrp->addButton( triangle_lfo_btn );
m_lfoWaveBtnGrp->addButton( saw_lfo_btn );
m_lfoWaveBtnGrp->addButton( sqr_lfo_btn );
m_lfoWaveBtnGrp->addButton( m_userLfoBtn );
/*
if( getEffect()->getControls()->getControlCount() > 0 )
{
QPushButton * ctls_btn = new QPushButton( tr( "Controls" ),
this );
QFont f = ctls_btn->font();
ctls_btn->setFont( pointSize<7>( f ) );
ctls_btn->setGeometry( 140, 14, 50, 20 );
connect( ctls_btn, SIGNAL( clicked() ),
this, SLOT( editControls() ) );
}
m_controlView = getEffect()->getControls()->createView();
m_subWindow = engine::getMainWindow()->workspace()->addSubWindow(
m_controlView );
connect( m_controlView, SIGNAL( closed() ),
this, SLOT( closeEffects() ) );
m_subWindow->hide();
*/
setModel( _model );
}
lfoControllerDialog::~lfoControllerDialog()
{
//delete m_subWindow;
}
/*
void effectView::displayHelp( void )
{
QWhatsThis::showText( mapToGlobal( rect().bottomRight() ),
whatsThis() );
}
void effectView::closeEffects( void )
{
m_subWindow->hide();
m_show = TRUE;
}
*/
void lfoControllerDialog::contextMenuEvent( QContextMenuEvent * )
{
/*
QPointer<captionMenu> contextMenu = new captionMenu(
getEffect()->publicName() );
contextMenu->addAction( embed::getIconPixmap( "arp_up_on" ),
tr( "Move &up" ),
this, SLOT( moveUp() ) );
contextMenu->addAction( embed::getIconPixmap( "arp_down_on" ),
tr( "Move &down" ),
this, SLOT( moveDown() ) );
contextMenu->addSeparator();
contextMenu->addAction( embed::getIconPixmap( "cancel" ),
tr( "&Remove this plugin" ),
this, SLOT( deletePlugin() ) );
contextMenu->addSeparator();
contextMenu->addAction( embed::getIconPixmap( "help" ),
tr( "&Help" ),
this, SLOT( displayHelp() ) );
contextMenu->exec( QCursor::pos() );
delete contextMenu;
*/
}
void lfoControllerDialog::paintEvent( QPaintEvent * )
{
QPainter p( this );
p.setPen( QColor( 128, 64, 0 ) );
p.drawLine(0,0,40,40);
}
void lfoControllerDialog::modelChanged( void )
{
m_lfo = castModel<lfoController>();
m_lfoAttackKnob->setModel( &m_lfo->m_lfoAttackModel );
m_lfoSpeedKnob->setModel( &m_lfo->m_lfoSpeedModel );
m_lfoAmountKnob->setModel( &m_lfo->m_lfoAmountModel );
m_lfoWaveBtnGrp->setModel( &m_lfo->m_lfoWaveModel );
}
#endif

View File

@@ -237,11 +237,11 @@ songEditor::songEditor( song * _song ) :
// fill own tool-bar
m_playButton = new toolButton( embed::getIconPixmap( "play" ),
m_playButton = new toolButton( embed::getIconPixmap( "play", 24, 24 ),
tr( "Play song (Space)" ),
m_s, SLOT( play() ), m_toolBar );
m_stopButton = new toolButton( embed::getIconPixmap( "stop" ),
m_stopButton = new toolButton( embed::getIconPixmap( "stop", 24, 24 ),
tr( "Stop song (Space)" ),
m_s, SLOT( stop() ), m_toolBar );
@@ -252,13 +252,13 @@ songEditor::songEditor( song * _song ) :
m_toolBar );
m_addSampleTrackButton = new toolButton( embed::getIconPixmap(
"add_sample_track" ),
"add_sample_track", 24, 24 ),
tr( "Add sample-track" ),
m_s, SLOT( addSampleTrack() ),
m_toolBar );
m_addControllerButton = new toolButton( embed::getIconPixmap(
"add_controller" ),
"add_controller", 24, 24 ),
tr( "Add controller" ),
m_s, SLOT( addSampleTrack() ),
m_toolBar );

View File

@@ -0,0 +1,277 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* controller_rack_view.cpp - view for song's controllers
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail.com>
*
* 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/QApplication>
#include <QtGui/QLayout>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include <QtGui/QVBoxLayout>
#include <QtGui/QMdiArea>
#include "song.h"
//#include "effect_view.h"
#include "main_window.h"
#include "group_box.h"
#include "controller_rack_view.h"
#include "controller_view.h"
#include "lfo_controller.h"
controllerRackView::controllerRackView( ) :
QWidget(),
modelView( NULL )
{
setFixedSize( 250, 250 );
m_scrollArea = new QScrollArea( this );
m_scrollArea->setFixedSize( 230, 184 );
m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
m_scrollArea->setPalette( QApplication::palette( m_scrollArea ) );
m_scrollArea->move( 6, 22 );
m_addButton = new QPushButton( this/*, "Add Effect"*/ );
m_addButton->setText( tr( "Add" ) );
m_addButton->move( 75, 210 );
connect( m_addButton, SIGNAL( clicked( void ) ),
this, SLOT( addController( void ) ) );
connect( engine::getSong(), SIGNAL( dataChanged( void ) ),
this, SLOT( update( void ) ) );
QWidget * w = new QWidget();
m_scrollArea->setWidget( w );
m_lastY = 0;
setModel( engine::getSong() );
if( engine::getMainWindow()->workspace() != NULL )
{
engine::getMainWindow()->workspace()->addSubWindow( this );
parentWidget()->setAttribute( Qt::WA_DeleteOnClose, FALSE );
}
}
controllerRackView::~controllerRackView()
{
clear();
}
void controllerRackView::clear( void )
{
/* for( QVector<effectView *>::iterator it = m_controllerViews.begin();
it != m_controllerViews.end(); ++it )
{
delete *it;
}
m_controllerViews.clear();*/
}
/*
void controllerRackView::moveUp( controllerView * _view )
{
fxChain()->moveUp( _view->getEffect() );
if( _view != m_effectViews.first() )
{
int i = 0;
for( QVector<controllerView *>::iterator it =
m_effectViews.begin();
it != m_effectViews.end(); it++, i++ )
{
if( *it == _view )
{
break;
}
}
effectView * temp = m_effectViews[ i - 1 ];
m_effectViews[i - 1] = _view;
m_effectViews[i] = temp;
update();
}
}*/
/*
void controllerRackView::moveDown( effectView * _view )
{
if( _view != m_effectViews.last() )
{
// moving next effect up is the same
moveUp( *( qFind( m_effectViews.begin(), m_effectViews.end(),
_view ) + 1 ) );
}
}*/
/*
void controllerRackView::deletePlugin( effectView * _view )
{
effect * e = _view->getEffect();
m_effectViews.erase( qFind( m_effectViews.begin(), m_effectViews.end(),
_view ) );
delete _view;
fxChain()->m_effects.erase( qFind( fxChain()->m_effects.begin(),
fxChain()->m_effects.end(),
e ) );
delete e;
update();
}
*/
void controllerRackView::update( void )
{
QWidget * w = m_scrollArea->widget();
song * s = engine::getSong();
// QVector<bool> view_map( fxChain()->m_effects.size(), FALSE );
printf("rack view update %d\n", s->m_controllers.size());
setUpdatesEnabled( false );
int i = 0;
for( i = 0; i < m_controllerViews.size(); ++i )
{
delete m_controllerViews[i];
}
m_controllerViews.clear();
for( i = 0; i < s->m_controllers.size(); ++i )
{
controllerView * v = new controllerView( s->m_controllers[i], w );
m_controllerViews.append( v );
v->move( 0, i*20 );
v->show();
}
w->setFixedSize( 210, i*20 );
/*
for( QVector<effect *>::iterator it = fxChain()->m_effects.begin();
it != fxChain()->m_effects.end(); ++it )
{
int i = 0;
for( QVector<effectView *>::iterator vit =
m_effectViews.begin();
vit != m_effectViews.end(); ++vit, ++i )
{
if( ( *vit )->getEffect() == *it )
{
view_map[i] = TRUE;
break;
}
}
if( i >= m_effectViews.size() )
{
effectView * view = new effectView( *it, w );
connect( view, SIGNAL( moveUp( effectView * ) ),
this, SLOT( moveUp( effectView * ) ) );
connect( view, SIGNAL( moveDown( effectView * ) ),
this, SLOT( moveDown( effectView * ) ) );
connect( view, SIGNAL( deletePlugin( effectView * ) ),
this, SLOT( deletePlugin( effectView * ) ) );
view->show();
m_effectViews.append( view );
view_map[i] = TRUE;
}
}
int i = m_lastY = 0;
for( QVector<effectView *>::iterator it = m_effectViews.begin();
it != m_effectViews.end(); )
{
if( i < view_map.size() && i < m_effectViews.size() &&
view_map[i] == FALSE )
{
delete m_effectViews[i];
m_effectViews.erase( it );
}
else
{
( *it )->move( 0, m_lastY );
m_lastY += ( *it )->height();
++it;
++i;
}
}
w->setFixedSize( 210, m_lastY );
*/
setUpdatesEnabled( true );
QWidget::update();
}
void controllerRackView::addController( void )
{
// TODO: Eventually let the user pick from available controller types
/*
effectSelectDialog esd( this );
esd.exec();
if( esd.result() == QDialog::Rejected )
{
return;
}
*/
engine::getSong()->addController( new lfoController( engine::getSong() ) );
update();
}
/*
void effectRackView::modelChanged( void )
{
clear();
m_effectsGroupBox->setModel( &fxChain()->m_enabledModel );
update();
}
*/
#include "controller_rack_view.moc"
#endif

View File

@@ -0,0 +1,211 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* controller_view.cpp - view-component for an controller
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail.com>
*
* 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 "controller_view.h"
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QMdiArea>
#include <QtGui/QMdiSubWindow>
#include <QtGui/QPainter>
#include "caption_menu.h"
#include "controller_dialog.h"
#include "gui_templates.h"
#include "embed.h"
#include "engine.h"
#include "led_checkbox.h"
#include "main_window.h"
#include "tooltip.h"
#include "mv_base.h"
controllerView::controllerView( controller * _model, QWidget * _parent ) :
modelView( _model ),
QWidget( _parent ),
m_bg( embed::getIconPixmap( "controller_bg" ) ),
m_show( TRUE ),
m_subWindow( NULL ),
m_controllerDlg( NULL )
{
setFixedSize( 210, 20 );
setAttribute( Qt::WA_OpaquePaintEvent, TRUE );
m_bypass = new ledCheckBox( "", this, tr( "Turn the controller off" ) );
m_bypass->move( 3, 3 );
m_bypass->setWhatsThis( tr( "Toggles the controller on or off." ) );
toolTip::add( m_bypass, tr( "On/Off" ) );
QPushButton * ctls_btn = new QPushButton( tr( "Controls" ),
this );
QFont f = ctls_btn->font();
ctls_btn->setFont( pointSize<7>( f ) );
ctls_btn->setGeometry( 140, 2, 50, 14 );
connect( ctls_btn, SIGNAL( clicked() ),
this, SLOT( editControls() ) );
//m_subWindow = new QMdiSubWindow( getMainWindow()->workspace() );
//m_subWindow->hide();
/*
if( getEffect()->getControls()->getControlCount() > 0 )
{
QPushButton * ctls_btn = new QPushButton( tr( "Controls" ),
this );
QFont f = ctls_btn->font();
ctls_btn->setFont( pointSize<7>( f ) );
ctls_btn->setGeometry( 140, 14, 50, 20 );
connect( ctls_btn, SIGNAL( clicked() ),
this, SLOT( editControls() ) );
}
m_controlView = getEffect()->getControls()->createView();
connect( m_controlView, SIGNAL( closed() ),
this, SLOT( closeEffects() ) );
*/
setModel( _model );
}
controllerView::~controllerView()
{
//delete m_subWindow;
}
void controllerView::editControls( void )
{
/*if( m_show )
{
m_subWindow->show();
m_subWindow->raise();
m_show = FALSE;
}
else
{
m_subWindow->hide();
m_show = TRUE;
}*/
//engine::getMainWindow()->workspace()->addSubWindow( NULL );
controller * c = castModel<controller>();
if( m_controllerDlg == NULL )
m_controllerDlg = c->createDialog( NULL );
m_subWindow = engine::getMainWindow()->workspace()->addSubWindow( m_controllerDlg );
m_subWindow->show();
m_subWindow->raise();
}
/*
void effectView::displayHelp( void )
{
QWhatsThis::showText( mapToGlobal( rect().bottomRight() ),
whatsThis() );
}
void effectView::closeEffects( void )
{
m_subWindow->hide();
m_show = TRUE;
}
*/
void controllerView::contextMenuEvent( QContextMenuEvent * )
{
/*
QPointer<captionMenu> contextMenu = new captionMenu(
getEffect()->publicName() );
contextMenu->addAction( embed::getIconPixmap( "arp_up_on" ),
tr( "Move &up" ),
this, SLOT( moveUp() ) );
contextMenu->addAction( embed::getIconPixmap( "arp_down_on" ),
tr( "Move &down" ),
this, SLOT( moveDown() ) );
contextMenu->addSeparator();
contextMenu->addAction( embed::getIconPixmap( "cancel" ),
tr( "&Remove this plugin" ),
this, SLOT( deletePlugin() ) );
contextMenu->addSeparator();
contextMenu->addAction( embed::getIconPixmap( "help" ),
tr( "&Help" ),
this, SLOT( displayHelp() ) );
contextMenu->exec( QCursor::pos() );
delete contextMenu;
*/
}
void controllerView::paintEvent( QPaintEvent * )
{
QPainter p( this );
p.drawPixmap( 0, 0, m_bg );
QFont f = pointSizeF( font(), 7.5f );
f.setBold( TRUE );
p.setFont( f );
p.setPen( QColor( 64, 64, 64 ) );
p.drawLine(0,0,20,20);
p.drawText( 6, 55, castModel<controller>()->publicName() );
p.setPen( Qt::white );
p.drawText( 5, 54, castModel<controller>()->publicName() );
}
void controllerView::modelChanged( void )
{
/*
m_bypass->setModel( &getEffect()->m_enabledModel );
m_wetDry->setModel( &getEffect()->m_wetDryModel );
m_autoQuit->setModel( &getEffect()->m_autoQuitModel );
m_gate->setModel( &getEffect()->m_gateModel );
*/
}
#include "controller_view.moc"
#endif

View File

@@ -54,8 +54,8 @@
#include "string_pair_drag.h"
#include "templates.h"
#include "text_float.h"
#include "song.h"
#include "controller_connection_dialog.h"
float knob::s_copiedValue = 0.0f;
@@ -580,10 +580,18 @@ 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() );
controller * c = new controller();
d->exec();
if (d->chosenController() != NULL )
{
model()->setController( d->chosenController() );
}
delete d;
model()->setController( c );
}

View File

@@ -37,7 +37,7 @@
#include "tooltip.h"
const int UPDATE_TIME = 1000 / 40; // 40 fps
const int UPDATE_TIME = 1000 / 25; // 40 fps