improved VST GUI embedding (closes #2167745)

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1780 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-10-19 16:20:38 +00:00
parent 0d6eeafaba
commit 04053f53fb
4 changed files with 75 additions and 45 deletions

View File

@@ -1,3 +1,14 @@
2008-10-19 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/vst_base/vst_plugin.h:
* plugins/vst_base/vst_plugin.cpp:
* plugins/vst_effect/vst_effect_control_dialog.cpp:
improved VST GUI embedding (closes #2167745)
* src/gui/track_container_view.cpp:
do not call method on deleted trackView but fetch pointer to track
before deleting trackView (fixes crash when removing a track)
2008-10-18 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* src/gui/widgets/track_label_button.cpp:

View File

@@ -28,6 +28,7 @@
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QLocale>
#include <QtGui/QCloseEvent>
#include <QtGui/QMdiArea>
#include <QtGui/QMdiSubWindow>
#ifdef LMMS_BUILD_LINUX
@@ -50,6 +51,30 @@
#include "templates.h"
class vstSubWin : public QMdiSubWindow
{
public:
vstSubWin( QWidget * _parent ) :
QMdiSubWindow( _parent )
{
setAttribute( Qt::WA_DeleteOnClose, false );
}
virtual ~vstSubWin()
{
}
virtual void closeEvent( QCloseEvent * e )
{
// ignore close-events - for some reason otherwise the VST GUI
// remains hidden when re-opening
hide();
e->ignore();
}
} ;
vstPlugin::vstPlugin( const QString & _plugin ) :
QObject(),
@@ -116,8 +141,9 @@ vstPlugin::vstPlugin( const QString & _plugin ) :
if( m_pluginWindowID )
{
target->setFixedSize( m_pluginGeometry );
engine::getMainWindow()->workspace()->addSubWindow( helper )
->setAttribute( Qt::WA_DeleteOnClose, FALSE );
vstSubWin * sw = new vstSubWin(
engine::getMainWindow()->workspace() );
sw->setWidget( helper );
helper->setWindowTitle( name() );
m_pluginWidget = helper;
}
@@ -133,32 +159,25 @@ vstPlugin::vstPlugin( const QString & _plugin ) :
vstPlugin::~vstPlugin()
{
if( m_pluginWidget != NULL &&
m_pluginWidget->parentWidget() != NULL &&
dynamic_cast<QMdiSubWindow *>(
m_pluginWidget->parentWidget() ) != NULL )
{
delete m_pluginWidget->parentWidget();
}
delete pluginWidget();
}
QWidget * vstPlugin::showEditor( QWidget * _parent )
void vstPlugin::showEditor( QWidget * _parent )
{
if( m_pluginWidget != NULL )
QWidget * w = pluginWidget();
if( w )
{
if( m_pluginWidget->parentWidget() )
{
m_pluginWidget->parentWidget()->show();
}
return( m_pluginWidget );
w->show();
return;
}
#ifdef LMMS_BUILD_LINUX
if( m_pluginWindowID == 0 )
{
return( NULL );
return;
}
m_pluginWidget = new QWidget( _parent );
@@ -166,23 +185,18 @@ QWidget * vstPlugin::showEditor( QWidget * _parent )
m_pluginWidget->setWindowTitle( name() );
if( _parent == NULL )
{
engine::getMainWindow()->workspace()->addSubWindow(
m_pluginWidget )
->setAttribute( Qt::WA_DeleteOnClose, FALSE );
vstSubWin * sw = new vstSubWin(
engine::getMainWindow()->workspace() );
sw->setWidget( m_pluginWidget );
}
QX11EmbedContainer * xe = new QX11EmbedContainer( m_pluginWidget );
xe->embedClient( m_pluginWindowID );
xe->setFixedSize( m_pluginGeometry );
//xe->setAutoDelete( FALSE );
xe->show();
#endif
m_pluginWidget->show();
showUI();
return( m_pluginWidget );
}
@@ -190,12 +204,10 @@ QWidget * vstPlugin::showEditor( QWidget * _parent )
void vstPlugin::hideEditor( void )
{
if( m_pluginWidget )
m_pluginWidget->hide();
return;
if( m_pluginWidget != NULL && m_pluginWidget->parentWidget() )
QWidget * w = pluginWidget();
if( w )
{
m_pluginWidget->parentWidget()->hide();
w->hide();
}
}
@@ -208,18 +220,19 @@ void vstPlugin::loadSettings( const QDomElement & _this )
{
if( _this.attribute( "guivisible" ).toInt() )
{
pluginWidget()->show();
showEditor();
}
else
{
pluginWidget()->hide();
hideEditor();
}
}
const Sint32 num_params = _this.attribute( "numparams" ).toInt();
const int num_params = _this.attribute( "numparams" ).toInt();
if( num_params > 0 )
{
QMap<QString, QString> dump;
for( Sint32 i = 0; i < num_params; ++i )
for( int i = 0; i < num_params; ++i )
{
const QString key = "param" +
QString::number( i );
@@ -278,7 +291,7 @@ const QMap<QString, QString> & vstPlugin::parameterDump( void )
waitForMessage( IdVstParameterDump );
unlock();
return( m_parameterDump );
return m_parameterDump;
}

View File

@@ -47,27 +47,27 @@ public:
virtual bool processMessage( const message & _m );
QWidget * showEditor( QWidget * _parent = NULL );
void showEditor( QWidget * _parent = NULL );
void hideEditor( void );
inline const QString & name( void ) const
{
return( m_name );
return m_name;
}
inline Sint32 version( void ) const
{
return( m_version );
return m_version;
}
inline const QString & vendorString( void ) const
{
return( m_vendorString );
return m_vendorString;
}
inline const QString & productString( void ) const
{
return( m_productString );
return m_productString;
}
const QMap<QString, QString> & parameterDump( void );
@@ -76,8 +76,14 @@ public:
inline QWidget * pluginWidget( void )
{
return( m_pluginWidget != NULL ?
m_pluginWidget->parentWidget() : NULL );
if( m_pluginWidget )
{
if( m_pluginWidget->parentWidget() )
{
return m_pluginWidget->parentWidget();
}
}
return m_pluginWidget;
}
virtual void loadSettings( const QDomElement & _this );
@@ -85,7 +91,7 @@ public:
inline virtual QString nodeName( void ) const
{
return( "vstplugin" );
return "vstplugin";
}

View File

@@ -35,10 +35,10 @@ vstEffectControlDialog::vstEffectControlDialog( vstEffectControls * _ctl ) :
effectControlDialog( _ctl )
{
QVBoxLayout * l = new QVBoxLayout( this );
QWidget * w = _ctl->m_effect->m_plugin->showEditor( this );
_ctl->m_effect->m_plugin->showEditor( this );
QWidget * w = _ctl->m_effect->m_plugin->pluginWidget();
if( w )
{
w->show();
l->addWidget( w );
}
}