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

@@ -1,3 +1,47 @@
* include/engine.h:
* src/core/engine.cpp:
add static accessor to the controller rack. I'm sure this won't be it's
own MDISubWindow very long..
* include/controller.h:
* src/gui/widgets/knob.cpp:
* src/core/controller.cpp:
add gui accesssor and split off LFO
* include/song.h:
* src/core/song.cpp:
make song the model for user-created controllers
* src/gui/song_editor.cpp:
added icon. Was going to add controller rack as a QSplitter but found
this would take too much time right now
* src/gui/widgets/visualization_widget.cpp:
drop back from 40 to an arbitrary 24fps
* include/lfo_controller_dialog.h:
* include/lfo_controller.h:
* src/gui/lfo_controller_dialog.cpp:
- add beginnings of an LFO controller and dialog
- don't mind the unoptimized code, it will be fixed
* include/controller_view.h:
* include/controller_rack_view.h:
* src/gui/widgets/controller_view.cpp:
* src/gui/widgets/controller_rack_view.cpp:
* data/themes/default/controller_bg.png:
The beginning of the controller rack and controller items. This is an
absolute bare minimum interface at the moment. Also ulta-buggy.
* include/controller_connection_dialog.h:
* src/gui/controller_connection_dialog.cpp:
This is the connection dialog. Will allow users to create and modify
connections between a controller and model. The lineEdit will be for
editing a mapping function to scale, offset, trig-ify, etc.
* Makefile.am:
add controller related files
2008-04-07 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* src/gui/effect_select_dialog.cpp:

View File

@@ -60,6 +60,10 @@ lmms_MOC = \
./combobox.moc \
./config_mgr.moc \
./controller.moc \
./controller_connection_dialog.moc \
./controller_dialog.moc \
./controller_rack_view.moc \
./controller_view.moc \
./cpuload_widget.moc \
./effect_control_dialog.moc \
./effect_label.moc \
@@ -85,6 +89,7 @@ lmms_MOC = \
./ladspa_control_view.moc \
./lcd_spinbox.moc \
./led_checkbox.moc \
./lfo_controller.moc \
./main_window.moc \
./mixer.moc \
./mv_base.moc \
@@ -173,6 +178,7 @@ lmms_SOURCES = \
$(srcdir)/src/core/ladspa_2_lmms.cpp \
$(srcdir)/src/core/ladspa_manager.cpp \
$(srcdir)/src/core/ladspa_control.cpp \
$(srcdir)/src/core/lfo_controller.cpp \
$(srcdir)/src/core/main.cpp \
$(srcdir)/src/core/mixer.cpp \
$(srcdir)/src/core/mmp.cpp \
@@ -212,11 +218,13 @@ lmms_SOURCES = \
$(srcdir)/src/gui/about_dialog.cpp \
$(srcdir)/src/gui/automation_editor.cpp \
$(srcdir)/src/gui/bb_editor.cpp \
$(srcdir)/src/gui/controller_connection_dialog.cpp \
$(srcdir)/src/gui/effect_control_dialog.cpp \
$(srcdir)/src/gui/effect_select_dialog.cpp \
$(srcdir)/src/gui/embed.cpp \
$(srcdir)/src/gui/export_project_dialog.cpp \
$(srcdir)/src/gui/file_browser.cpp \
$(srcdir)/src/gui/lfo_controller_dialog.cpp \
$(srcdir)/src/gui/lmms_style.cpp \
$(srcdir)/src/gui/main_window.cpp \
$(srcdir)/src/gui/piano_roll.cpp \
@@ -229,6 +237,8 @@ lmms_SOURCES = \
$(srcdir)/src/gui/widgets/automatable_slider.cpp \
$(srcdir)/src/gui/widgets/caption_menu.cpp \
$(srcdir)/src/gui/widgets/combobox.cpp \
$(srcdir)/src/gui/widgets/controller_rack_view.cpp \
$(srcdir)/src/gui/widgets/controller_view.cpp \
$(srcdir)/src/gui/widgets/cpuload_widget.cpp \
$(srcdir)/src/gui/widgets/effect_label.cpp \
$(srcdir)/src/gui/widgets/effect_rack_view.cpp \
@@ -422,9 +432,13 @@ lmms_SOURCES = \
$(srcdir)/include/ladspa_control_view.h \
$(srcdir)/include/ladspa_base.h \
$(srcdir)/include/controller.h \
$(srcdir)/include/controller_rack_view.h \
$(srcdir)/include/controller_view.h \
$(srcdir)/include/controller_dialog.h \
$(srcdir)/include/controller_connection_dialog.h \
$(srcdir)/include/lfo_controller.h \
$(THIRD_PARTY_CODE)
# $(srcdir)/src/tracks/sample_track.cpp
EXTRA_DIST = $(lmms_EMBEDDED_RESOURCES) lmms.1

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -32,13 +32,18 @@
#include "engine.h"
#include "mixer.h"
#include "mv_base.h"
class controllerDialog;
class controller;
class controller : public QObject
typedef QVector<controller *> controllerVector;
class controller : public model
{
Q_OBJECT
public:
controller( void );
controller( model * _parent );
virtual ~controller();
@@ -54,6 +59,10 @@ public:
m_sampleExact = _exact;
}
virtual QString publicName() const
{
return "Dummy Controller";
}
static int runningFrames();
static float runningTime();
@@ -61,7 +70,8 @@ public:
static void triggerFrameCounter( void );
static void resetFrameCounter( void );
private:
public slots:
virtual controllerDialog * createDialog( QWidget * _parent );
protected:
@@ -72,12 +82,11 @@ protected:
bool m_sampleExact;
static QVector<controller *> s_controllers;
static controllerVector s_controllers;
static unsigned int s_frames;
/*
QString publicName();
slots:
void trigger();
@@ -90,6 +99,7 @@ signals:
// Allow all attached models to unlink
void destroying( void );
friend class controllerDialog;
};
#endif

View File

@@ -0,0 +1,125 @@
/*
* controller_connection_dialog.h -
*
* 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.
*
*/
#ifndef _CONTROLLER_CONNECTION_DIALOG_H
#define _CONTROLLER_CONNECTION_DIALOG_H
#include <QtGui/QDialog>
#include <QtGui/QSortFilterProxyModel>
#include <QtGui/QStandardItemModel>
#include "controller.h"
#include "automatable_model.h"
class QLineEdit;
class QListView;
class QScrollArea;
class groupBox;
class lcdSpinBox;
class comboBox;
class controllerConnectionDialog : public QDialog
{
Q_OBJECT
public:
controllerConnectionDialog( QWidget * _parent);
virtual ~controllerConnectionDialog();
controller * chosenController( void )
{
return m_controller;
}
public slots:
// void setSelection( const effectKey & _selection );
void selectController( void );
private:
// effectKey m_currentSelection;
//
groupBox * m_midiGroupBox;
lcdSpinBox * m_midiChannel;
lcdSpinBox * m_midiController;
groupBox * m_userGroupBox;
comboBox * m_userController;
QLineEdit * m_mappingFunction;
controller * m_controller;
} ;
/*
class effectListWidget : public QWidget
{
Q_OBJECT
public:
effectListWidget( QWidget * _parent );
virtual ~effectListWidget();
inline effectKey getSelected( void )
{
return( m_currentSelection );
}
signals:
void highlighted( const effectKey & _key );
void addPlugin( const effectKey & _key );
void doubleClicked( const effectKey & _key );
protected:
virtual void resizeEvent( QResizeEvent * );
protected slots:
void rowChanged( const QModelIndex &, const QModelIndex & );
void onAddButtonReleased( void );
void onDoubleClicked( const QModelIndex & );
private:
QVector<plugin::descriptor> m_pluginDescriptors;
effectKeyList m_effectKeys;
effectKey m_currentSelection;
QLineEdit * m_filterEdit;
QListView * m_pluginList;
QStandardItemModel m_sourceModel;
QSortFilterProxyModel m_model;
QScrollArea * m_scrollArea;
QWidget * m_descriptionWidget;
} ;
*/
#endif

View File

@@ -0,0 +1,87 @@
/*
* controller_rack_view.h - 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.
*
*/
#ifndef _CONTROLLER_RACK_VIEW_H
#define _CONTROLLER_RACK_VIEW_H
#include <QtGui/QWidget>
#include "types.h"
#include "mv_base.h"
class QPushButton;
class QScrollArea;
class QVBoxLayout;
class controllerView;
class controllerRackView : public QWidget, public modelView
{
Q_OBJECT
public:
controllerRackView();
virtual ~controllerRackView();
void clear( void );
public slots:
//void moveUp( effectView * _view );
//void moveDown( effectView * _view );
//void deletePlugin( effectView * _view );
private slots:
virtual void update( void );
void addController( void );
private:
/*virtual void modelChanged( void );
inline effectChain * fxChain( void )
{
return( castModel<effectChain>() );
}
inline const effectChain * fxChain( void ) const
{
return( castModel<effectChain>() );
}
*/
QVector<controllerView *> m_controllerViews;
QVBoxLayout * m_mainLayout;
//groupBox * m_effectsGroupBox;
QScrollArea * m_scrollArea;
QPushButton * m_addButton;
Uint32 m_lastY;
} ;
#endif

92
include/controller_view.h Normal file
View File

@@ -0,0 +1,92 @@
/*
* controller_view.h - view-component for an control
*
* 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.
*
*/
#ifndef _CONTROLLER_VIEW_H
#define _CONTROLLER_VIEW_H
#include <QtGui/QWidget>
#include "automatable_model.h"
#include "controller.h"
#include "mv_base.h"
class QGroupBox;
class QLabel;
class QPushButton;
class QMdiSubWindow;
//class controllerControlDialog;
//class knob;
class ledCheckBox;
//class tempoSyncKnob;
//class track;
class controllerView : public QWidget, public modelView
{
Q_OBJECT
public:
controllerView( controller * _controller, QWidget * _parent );
virtual ~controllerView();
/*
inline effect * getEffect( void )
{
return( castModel<effect>() );
}
inline const effect * getEffect( void ) const
{
return( castModel<effect>() );
}
*/
public slots:
void editControls( void );
//void deletePlugin( void );
//void displayHelp( void );
//void closeEffects( void );
signals:
//void moveUp( effectView * _plugin );
//void moveDown( effectView * _plugin );
//void deletePlugin( effectView * _plugin );
protected:
virtual void contextMenuEvent( QContextMenuEvent * _me );
virtual void paintEvent( QPaintEvent * _pe );
virtual void modelChanged( void );
private:
QPixmap m_bg;
ledCheckBox * m_bypass;
QMdiSubWindow * m_subWindow;
controllerDialog * m_controllerDlg;
bool m_show;
} ;
#endif

View File

@@ -46,6 +46,7 @@ class projectNotes;
class song;
class songEditor;
class ladspa2LMMS;
class controllerRackView;
class engine
@@ -131,6 +132,11 @@ public:
return( s_dummyTC );
}
static controllerRackView * getControllerRackView( void )
{
return( s_controllerRackView );
}
static float framesPerTact64th( void )
{
return( s_framesPerTact64th );
@@ -154,6 +160,7 @@ private:
static bbTrackContainer * s_bbTrackContainer;
static projectJournal * s_projectJournal;
static dummyTrackContainer * s_dummyTC;
static controllerRackView * s_controllerRackView;
// GUI
static mainWindow * s_mainWindow;

128
include/lfo_controller.h Normal file
View File

@@ -0,0 +1,128 @@
/*
* lfo_controller.h - A LFO-based controller
* 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.
*
*/
#ifndef _LFO_CONTROLLER_H
#define _LFO_CONTROLLER_H
#include <QtGui/QWidget>
#include "mv_base.h"
#include "automatable_model.h"
#include "controller.h"
#include "controller_dialog.h"
#include "tempo_sync_knob.h"
class automatableButtonGroup;
class knob;
class tempoSyncKnob;
class pixmapButton;
class oscillator;
class lfoController : public controller
{
Q_OBJECT
public:
lfoController( model * _parent );
virtual ~lfoController();
virtual QString publicName() const
{
return "LFO Controller";
}
enum LfoShapes
{
SineWave,
TriangleWave,
SawWave,
SquareWave,
UserDefinedWave,
NumLfoShapes
} ;
public slots:
virtual controllerDialog * createDialog( QWidget * _parent );
protected:
// The internal per-controller get-value function
virtual float value( int _offset );
/*
slots:
void trigger();
*/
floatModel m_lfoAttackModel;
tempoSyncKnobModel m_lfoSpeedModel;
floatModel m_lfoAmountModel;
intModel m_lfoWaveModel;
int m_duration;
int m_phaseCorrection;
friend class lfoControllerDialog;
};
class lfoControllerDialog : public controllerDialog
{
Q_OBJECT
public:
lfoControllerDialog( controller * _controller, QWidget * _parent );
virtual ~lfoControllerDialog();
public slots:
//void editControls( void );
//void deletePlugin( void );
//void displayHelp( void );
//void closeEffects( void );
signals:
protected:
virtual void contextMenuEvent( QContextMenuEvent * _me );
virtual void paintEvent( QPaintEvent * _pe );
virtual void modelChanged( void );
lfoController * m_lfo;
knob * m_lfoAttackKnob;
tempoSyncKnob * m_lfoSpeedKnob;
knob * m_lfoAmountKnob;
pixmapButton * m_userLfoBtn;
automatableButtonGroup * m_lfoWaveBtnGrp;
} ;
#endif

View File

@@ -0,0 +1,60 @@
/*
* controller_dialog.h - 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.
*
*/
#ifndef _LFO_CONTROLLER_H
#define _LFO_CONTROLLER_H
#include <QtGui/QWidget>
#include "automatable_model.h"
#include "controller.h"
#include "controller_dialog.h"
#include "mv_base.h"
class lfoControllerDialog : public controllerDialog
{
Q_OBJECT
public:
lfoControllerDialog( controller * _controller, QWidget * _parent );
virtual ~lfoControllerDialog();
public slots:
//void editControls( void );
//void deletePlugin( void );
//void displayHelp( void );
//void closeEffects( void );
signals:
protected:
virtual void contextMenuEvent( QContextMenuEvent * _me );
virtual void paintEvent( QPaintEvent * _pe );
virtual void modelChanged( void );
} ;
#endif

View File

@@ -26,10 +26,13 @@
#ifndef _SONG_H
#define _SONG_H
#include <QtCore/QVector>
#include "track_container.h"
#include "automatable_model.h"
#include "automatable_slider.h"
#include "lcd_spinbox.h"
#include "controller.h"
class pattern;
@@ -165,6 +168,14 @@ public:
return( FALSE );
}
void addController( controller * _c );
// QT will implicitly share the Vector I believe..
controllerVector controllers( void ) const
{
return m_controllers;
}
public slots:
void play( void );
@@ -229,6 +240,8 @@ private:
sliderModel m_masterVolumeModel;
sliderModel m_masterPitchModel;
controllerVector m_controllers;
QString m_fileName;
QString m_oldFileName;
@@ -264,6 +277,7 @@ private:
friend class engine;
friend class songEditor;
friend class controllerRackView;
signals:
void tempoChanged( bpm_t _new_bpm );

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