Skip to content

Commit

Permalink
Move Engine' GUI code to new GuiApplication class
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-w committed Dec 17, 2014
1 parent eb79701 commit 1ee9340
Show file tree
Hide file tree
Showing 47 changed files with 407 additions and 323 deletions.
2 changes: 1 addition & 1 deletion include/AboutDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class AboutDialog : public QDialog, public Ui::AboutDialog
{
public:
AboutDialog( void );
AboutDialog(QWidget* parent=0);

} ;

Expand Down
53 changes: 2 additions & 51 deletions include/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,42 +97,6 @@ class EXPORT Engine
return s_projectJournal;
}

// GUI
static MainWindow * mainWindow()
{
return s_mainWindow;
}

static FxMixerView * fxMixerView()
{
return s_fxMixerView;
}

static SongEditorWindow* songEditor()
{
return s_songEditor;
}

static BBEditor * getBBEditor()
{
return s_bbEditor;
}

static PianoRollWindow* pianoRoll()
{
return s_pianoRoll;
}

static ProjectNotes * getProjectNotes()
{
return s_projectNotes;
}

static AutomationEditorWindow * automationEditor()
{
return s_automationEditor;
}

static Ladspa2LMMS * getLADSPAManager()
{
return s_ladspaManager;
Expand All @@ -143,11 +107,6 @@ class EXPORT Engine
return s_dummyTC;
}

static ControllerRackView * getControllerRackView()
{
return s_controllerRackView;
}

static float framesPerTick()
{
return s_framesPerTick;
Expand Down Expand Up @@ -182,22 +141,14 @@ class EXPORT Engine
static BBTrackContainer * s_bbTrackContainer;
static ProjectJournal * s_projectJournal;
static DummyTrackContainer * s_dummyTC;
static ControllerRackView * s_controllerRackView;

// GUI
static MainWindow * s_mainWindow;
static FxMixerView * s_fxMixerView;
static SongEditorWindow* s_songEditor;
static AutomationEditorWindow * s_automationEditor;
static BBEditor * s_bbEditor;
static PianoRollWindow* s_pianoRoll;
static ProjectNotes * s_projectNotes;

static Ladspa2LMMS * s_ladspaManager;

static QMap<QString, QString> s_pluginFileHandling;

static void initPluginFileHandling();

friend class GuiApplication;
} ;


Expand Down
71 changes: 71 additions & 0 deletions include/GuiApplication.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* GuiApplication.h
*
* Copyright (c) 2014 Lukas W <lukaswhl/at/gmail.com>
*
* This file is part of LMMS - http://lmms.io
*
* 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 GUIAPPLICATION_H
#define GUIAPPLICATION_H

#include "export.h"

class AutomationEditorWindow;
class BBEditor;
class ControllerRackView;
class FxMixerView;
class MainWindow;
class PianoRollWindow;
class ProjectNotes;
class SongEditorWindow;

class EXPORT GuiApplication
{
public:
explicit GuiApplication();
~GuiApplication();

static GuiApplication* instance();

MainWindow* mainWindow() { return m_mainWindow; }
FxMixerView* fxMixerView() { return m_fxMixerView; }
SongEditorWindow* songEditor() { return m_songEditor; }
BBEditor* getBBEditor() { return m_bbEditor; }
PianoRollWindow* pianoRoll() { return m_pianoRoll; }
ProjectNotes* getProjectNotes() { return m_projectNotes; }
AutomationEditorWindow* automationEditor() { return m_automationEditor; }
ControllerRackView* getControllerRackView() { return m_controllerRackView; }

private:
static GuiApplication* s_instance;

MainWindow* m_mainWindow;
FxMixerView* m_fxMixerView;
SongEditorWindow* m_songEditor;
AutomationEditorWindow* m_automationEditor;
BBEditor* m_bbEditor;
PianoRollWindow* m_pianoRoll;
ProjectNotes* m_projectNotes;
ControllerRackView* m_controllerRackView;
};

#define gui GuiApplication::instance()

#endif // GUIAPPLICATION_H
2 changes: 1 addition & 1 deletion include/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public slots:

QList<QString>* m_errors;

friend class Engine;
friend class GuiApplication;


private slots:
Expand Down
7 changes: 4 additions & 3 deletions plugins/MidiImport/MidiImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "ConfigManager.h"
#include "Pattern.h"
#include "Instrument.h"
#include "GuiApplication.h"
#include "MainWindow.h"
#include "MidiTime.h"
#include "debug.h"
Expand Down Expand Up @@ -99,7 +100,7 @@ bool MidiImport::tryImport( TrackContainer* tc )
if( Engine::hasGUI() &&
ConfigManager::inst()->defaultSoundfont().isEmpty() )
{
QMessageBox::information( Engine::mainWindow(),
QMessageBox::information( gui->mainWindow(),
tr( "Setup incomplete" ),
tr( "You do not have set up a default soundfont in "
"the settings dialog (Edit->Settings). "
Expand All @@ -111,7 +112,7 @@ bool MidiImport::tryImport( TrackContainer* tc )
#else
if( Engine::hasGUI() )
{
QMessageBox::information( Engine::mainWindow(),
QMessageBox::information( gui->mainWindow(),
tr( "Setup incomplete" ),
tr( "You did not compile LMMS with support for "
"SoundFont2 player, which is used to add default "
Expand Down Expand Up @@ -268,7 +269,7 @@ bool MidiImport::readSMF( TrackContainer* tc )

const int preTrackSteps = 2;
QProgressDialog pd( TrackContainer::tr( "Importing MIDI-file..." ),
TrackContainer::tr( "Cancel" ), 0, preTrackSteps, Engine::mainWindow() );
TrackContainer::tr( "Cancel" ), 0, preTrackSteps, gui->mainWindow() );
pd.setWindowTitle( TrackContainer::tr( "Please wait..." ) );
pd.setWindowModality(Qt::WindowModal);
pd.setMinimumDuration( 0 );
Expand Down
3 changes: 2 additions & 1 deletion plugins/SpectrumAnalyzer/SpectrumAnalyzerControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "SpectrumAnalyzer.h"
#include "MainWindow.h"
#include "GuiApplication.h"
#include "LedCheckbox.h"
#include "embed.h"

Expand Down Expand Up @@ -59,7 +60,7 @@ class SpectrumView : public QWidget
m_background( PLUGIN_NAME::getIconPixmap( "spectrum_background" ).toImage() )
{
setFixedSize( 249, 151 );
connect( Engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) );
connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) );
setAttribute( Qt::WA_OpaquePaintEvent, true );
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/VstEffect/VstEffectControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "VstEffect.h"

#include "MainWindow.h"
#include "GuiApplication.h"
#include <QMdiArea>
#include <QApplication>

Expand Down Expand Up @@ -309,7 +310,7 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls *
m_vi->m_scrollArea = new QScrollArea( widget );
l = new QGridLayout( widget );

m_vi->m_subWindow = Engine::mainWindow()->workspace()->addSubWindow(new QMdiSubWindow, Qt::SubWindow |
m_vi->m_subWindow = gui->mainWindow()->workspace()->addSubWindow(new QMdiSubWindow, Qt::SubWindow |
Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
m_vi->m_subWindow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
m_vi->m_subWindow->setFixedSize( 960, 300);
Expand Down
5 changes: 3 additions & 2 deletions plugins/flp_import/FlpImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "FxMixer.h"
#include "FxMixerView.h"
#include "GroupBox.h"
#include "GuiApplication.h"
#include "Instrument.h"
#include "InstrumentTrack.h"
#include "EnvelopeAndLfoParameters.h"
Expand Down Expand Up @@ -1418,15 +1419,15 @@ else
{
Engine::fxMixer()->createChannel();
}
Engine::fxMixerView()->refreshDisplay();
gui->fxMixerView()->refreshDisplay();

// set global parameters
Engine::getSong()->setMasterVolume( p.mainVolume );
Engine::getSong()->setMasterPitch( p.mainPitch );
Engine::getSong()->setTempo( p.tempo );

// set project notes
Engine::getProjectNotes()->setText( p.projectNotes );
gui->getProjectNotes()->setText( p.projectNotes );


progressDialog.setMaximum( p.maxPatterns + p.channels.size() +
Expand Down
3 changes: 2 additions & 1 deletion plugins/vestige/vestige.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "InstrumentTrack.h"
#include "VstPlugin.h"
#include "MainWindow.h"
#include "GuiApplication.h"
#include "PixmapButton.h"
#include "StringPairDrag.h"
#include "TextFloat.h"
Expand Down Expand Up @@ -873,7 +874,7 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume
widget = new QWidget(this);
l = new QGridLayout( this );

m_vi->m_subWindow = Engine::mainWindow()->workspace()->addSubWindow(new QMdiSubWindow, Qt::SubWindow |
m_vi->m_subWindow = gui->mainWindow()->workspace()->addSubWindow(new QMdiSubWindow, Qt::SubWindow |
Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
m_vi->m_subWindow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::MinimumExpanding );
m_vi->m_subWindow->setFixedWidth( 960 );
Expand Down
6 changes: 3 additions & 3 deletions plugins/vst_base/VstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#endif

#include "ConfigManager.h"
#include "Engine.h"
#include "GuiApplication.h"
#include "MainWindow.h"
#include "Song.h"
#include "templates.h"
Expand Down Expand Up @@ -188,7 +188,7 @@ void VstPlugin::tryLoad( const QString &remoteVstPluginExecutable )
{
target->setFixedSize( m_pluginGeometry );
vstSubWin * sw = new vstSubWin(
Engine::mainWindow()->workspace() );
gui->mainWindow()->workspace() );
sw->setWidget( helper );
helper->setWindowTitle( name() );
m_pluginWidget = helper;
Expand Down Expand Up @@ -237,7 +237,7 @@ void VstPlugin::showEditor( QWidget * _parent, bool isEffect )
if( _parent == NULL )
{
vstSubWin * sw = new vstSubWin(
Engine::mainWindow()->workspace() );
gui->mainWindow()->workspace() );
if( isEffect )
{
sw->setAttribute( Qt::WA_TranslucentBackground );
Expand Down
39 changes: 0 additions & 39 deletions src/core/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,17 @@


#include "Engine.h"
#include "AutomationEditor.h"
#include "BBEditor.h"
#include "BBTrackContainer.h"
#include "ConfigManager.h"
#include "ControllerRackView.h"
#include "FxMixer.h"
#include "FxMixerView.h"
#include "InstrumentTrack.h"
#include "Ladspa2LMMS.h"
#include "MainWindow.h"
#include "Mixer.h"
#include "Pattern.h"
#include "PianoRoll.h"
#include "PresetPreviewPlayHandle.h"
#include "ProjectJournal.h"
#include "ProjectNotes.h"
#include "Plugin.h"
#include "SongEditor.h"
#include "Song.h"
#include "BandLimitedWave.h"

Expand All @@ -51,19 +44,11 @@ bool Engine::s_suppressMessages = false;
float Engine::s_framesPerTick;
Mixer* Engine::s_mixer = NULL;
FxMixer * Engine::s_fxMixer = NULL;
FxMixerView * Engine::s_fxMixerView = NULL;
MainWindow * Engine::s_mainWindow = NULL;
BBTrackContainer * Engine::s_bbTrackContainer = NULL;
Song * Engine::s_song = NULL;
SongEditorWindow* Engine::s_songEditor = NULL;
AutomationEditorWindow * Engine::s_automationEditor = NULL;
BBEditor * Engine::s_bbEditor = NULL;
PianoRollWindow* Engine::s_pianoRoll = NULL;
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_pluginFileHandling;


Expand All @@ -90,20 +75,6 @@ void Engine::init( const bool _has_gui )

s_mixer->initDevices();

if( s_hasGUI )
{
s_mainWindow = new MainWindow;
s_songEditor = new SongEditorWindow( s_song );
s_fxMixerView = new FxMixerView;
s_controllerRackView = new ControllerRackView;
s_projectNotes = new ProjectNotes;
s_bbEditor = new BBEditor( s_bbTrackContainer );
s_pianoRoll = new PianoRollWindow();
s_automationEditor = new AutomationEditorWindow;

s_mainWindow->finalize();
}

PresetPreviewPlayHandle::init();
s_dummyTC = new DummyTrackContainer;

Expand All @@ -118,15 +89,7 @@ void Engine::destroy()
s_projectJournal->stopAllJournalling();
s_mixer->stopProcessing();

deleteHelper( &s_projectNotes );
deleteHelper( &s_songEditor );
deleteHelper( &s_bbEditor );
deleteHelper( &s_pianoRoll );
deleteHelper( &s_automationEditor );
deleteHelper( &s_fxMixerView );

PresetPreviewPlayHandle::cleanup();
InstrumentTrackView::cleanupWindowCache();

s_song->clearProject();

Expand All @@ -141,8 +104,6 @@ void Engine::destroy()
//delete ConfigManager::inst();
deleteHelper( &s_projectJournal );

s_mainWindow = NULL;

deleteHelper( &s_song );

delete ConfigManager::inst();
Expand Down
Loading

0 comments on commit 1ee9340

Please sign in to comment.