Use Editor superclass in AutomationEditor

Split AutomationEditor -> AutomationEditor + AutomationEditorWindow
This commit is contained in:
Lukas W
2014-12-07 12:48:49 +01:00
parent c6ee614012
commit 02006f9855
8 changed files with 533 additions and 567 deletions

View File

@@ -29,6 +29,8 @@
#include <QtCore/QMutex>
#include <QWidget>
#include "Editor.h"
#include "lmms_basics.h"
#include "JournallingObject.h"
#include "MidiTime.h"
@@ -36,7 +38,6 @@
#include "ComboBoxModel.h"
#include "Knob.h"
class QPainter;
class QPixmap;
class QScrollBar;
@@ -47,6 +48,7 @@ class Timeline;
class ToolButton;
class AutomationEditor : public QWidget, public JournallingObject
{
Q_OBJECT
@@ -69,16 +71,13 @@ public:
int quantization() const;
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
inline virtual QString nodeName() const
QString nodeName() const
{
return( "automationeditor" );
return "automationeditor";
}
void setPauseIcon( bool pause );
// qproperty access methods
QColor gridColor() const;
QBrush graphColor() const;
@@ -89,6 +88,14 @@ public:
void setVertexColor( const QColor & c );
void setScaleColor( const QBrush & c );
enum editModes
{
DRAW,
ERASE,
SELECT,
MOVE
};
public slots:
void update();
void updateAfterPatternChange();
@@ -97,7 +104,6 @@ public slots:
protected:
typedef AutomationPattern::timeMap timeMap;
virtual void closeEvent( QCloseEvent * _ce );
virtual void keyPressEvent( QKeyEvent * _ke );
virtual void leaveEvent( QEvent * _e );
virtual void mousePressEvent( QMouseEvent * _me );
@@ -117,7 +123,6 @@ protected:
void getSelectedValues( timeMap & _selected_values );
void drawLine( int x0, float y0, int x1, float y1 );
void disableTensionKnob();
protected slots:
void play();
@@ -126,15 +131,14 @@ protected slots:
void horScrolled( int _new_pos );
void verScrolled( int _new_pos );
void drawButtonToggled();
void eraseButtonToggled();
void selectButtonToggled();
void moveButtonToggled();
void setEditMode(AutomationEditor::editModes mode);
void setEditMode(int mode);
void discreteButtonToggled();
void linearButtonToggled();
void cubicHermiteButtonToggled();
void tensionChanged();
void setProgressionType(AutomationPattern::ProgressionTypes type);
void setProgressionDiscrete();
void setProgressionLinear();
void setProgressionHermite();
void setTension();
void copySelectedValues();
void cutSelectedValues();
@@ -149,14 +153,6 @@ protected slots:
private:
enum editModes
{
DRAW,
ERASE,
SELECT,
MOVE
} ;
enum actions
{
NONE,
@@ -166,11 +162,8 @@ private:
} ;
// some constants...
static const int INITIAL_WIDTH = 860;
static const int INITIAL_HEIGHT = 480;
static const int SCROLLBAR_SIZE = 16;
static const int TOP_MARGIN = 48;
static const int TOP_MARGIN = 16;
static const int DEFAULT_Y_DELTA = 6;
static const int DEFAULT_STEPS_PER_TACT = 16;
@@ -182,41 +175,17 @@ private:
AutomationEditor( const AutomationEditor & );
virtual ~AutomationEditor();
static QPixmap * s_toolDraw;
static QPixmap * s_toolErase;
static QPixmap * s_toolSelect;
static QPixmap * s_toolMove;
QWidget * m_toolBar;
ToolButton * m_playButton;
ToolButton * m_stopButton;
ToolButton * m_drawButton;
ToolButton * m_eraseButton;
ToolButton * m_selectButton;
ToolButton * m_moveButton;
ToolButton * m_discreteButton;
ToolButton * m_linearButton;
ToolButton * m_cubicHermiteButton;
Knob * m_tensionKnob;
FloatModel * m_tensionModel;
ToolButton * m_cutButton;
ToolButton * m_copyButton;
ToolButton * m_pasteButton;
ComboBox * m_zoomingXComboBox;
ComboBox * m_zoomingYComboBox;
ComboBox * m_quantizeComboBox;
ComboBoxModel m_zoomingXModel;
ComboBoxModel m_zoomingYModel;
ComboBoxModel m_quantizeModel;
FloatModel * m_tensionModel;
QMutex m_patternMutex;
AutomationPattern * m_pattern;
float m_minLevel;
@@ -270,14 +239,64 @@ private:
QColor m_vertexColor;
QBrush m_scaleColor;
friend class Engine;
//friend class Engine;
friend class AutomationEditorWindow;
signals:
void currentPatternChanged();
void positionChanged( const MidiTime & );
} ;
class AutomationEditorWindow : public Editor
{
Q_OBJECT
static const int INITIAL_WIDTH = 860;
static const int INITIAL_HEIGHT = 480;
public:
AutomationEditorWindow();
~AutomationEditorWindow();
void setCurrentPattern(AutomationPattern* pattern);
const AutomationPattern* currentPattern();
int quantization() const;
AutomationEditor* m_editor;
virtual void closeEvent( QCloseEvent * _ce );
signals:
void currentPatternChanged();
protected slots:
void play();
void stop();
private:
QAbstractButton * m_drawButton;
QAbstractButton * m_eraseButton;
QAbstractButton * m_selectButton;
QAbstractButton * m_moveButton;
ToolButton * m_discreteButton;
ToolButton * m_linearButton;
ToolButton * m_cubicHermiteButton;
Knob * m_tensionKnob;
ToolButton * m_cutButton;
ToolButton * m_copyButton;
ToolButton * m_pasteButton;
ComboBox * m_zoomingXComboBox;
ComboBox * m_zoomingYComboBox;
ComboBox * m_quantizeComboBox;
friend class Engine;
};
#endif

View File

@@ -39,7 +39,7 @@ class Editor : public QMainWindow
{
Q_OBJECT
public:
void setPlaying(bool playing=true);
void setPauseIcon(bool displayPauseIcon=true);
signals:

View File

@@ -33,7 +33,7 @@
#include "export.h"
class AutomationEditor;
class AutomationEditorWindow;
class BBEditor;
class BBTrackContainer;
class DummyTrackContainer;
@@ -128,7 +128,7 @@ public:
return s_projectNotes;
}
static AutomationEditor * automationEditor()
static AutomationEditorWindow * automationEditor()
{
return s_automationEditor;
}
@@ -188,7 +188,7 @@ private:
static MainWindow * s_mainWindow;
static FxMixerView * s_fxMixerView;
static SongEditor* s_songEditor;
static AutomationEditor * s_automationEditor;
static AutomationEditorWindow * s_automationEditor;
static BBEditor * s_bbEditor;
static PianoRoll* s_pianoRoll;
static ProjectNotes * s_projectNotes;

View File

@@ -56,7 +56,7 @@ MainWindow * Engine::s_mainWindow = NULL;
BBTrackContainer * Engine::s_bbTrackContainer = NULL;
Song * Engine::s_song = NULL;
SongEditor* Engine::s_songEditor = NULL;
AutomationEditor * Engine::s_automationEditor = NULL;
AutomationEditorWindow * Engine::s_automationEditor = NULL;
BBEditor * Engine::s_bbEditor = NULL;
PianoRoll* Engine::s_pianoRoll = NULL;
ProjectNotes * Engine::s_projectNotes = NULL;
@@ -99,7 +99,7 @@ void Engine::init( const bool _has_gui )
s_projectNotes = new ProjectNotes;
s_bbEditor = new BBEditor( s_bbTrackContainer );
s_pianoRoll = new PianoRoll;
s_automationEditor = new AutomationEditor;
s_automationEditor = new AutomationEditorWindow;
s_mainWindow->finalize();
}

View File

@@ -958,9 +958,9 @@ void Song::loadProject( const QString & _file_name )
{
Engine::pianoRoll()->restoreState( node.toElement() );
}
else if( node.nodeName() == Engine::automationEditor()->nodeName() )
else if( node.nodeName() == Engine::automationEditor()->m_editor->nodeName() )
{
Engine::automationEditor()->restoreState( node.toElement() );
Engine::automationEditor()->m_editor->restoreState( node.toElement() );
}
else if( node.nodeName() == Engine::getProjectNotes()->nodeName() )
{
@@ -1027,7 +1027,7 @@ bool Song::saveProjectFile( const QString & _filename )
{
Engine::getControllerRackView()->saveState( dataFile, dataFile.content() );
Engine::pianoRoll()->saveState( dataFile, dataFile.content() );
Engine::automationEditor()->saveState( dataFile, dataFile.content() );
Engine::automationEditor()->m_editor->saveState( dataFile, dataFile.content() );
Engine::getProjectNotes()->SerializingObject::saveState( dataFile, dataFile.content() );
m_playPos[Mode_PlaySong].m_timeLine->saveState( dataFile, dataFile.content() );
}

File diff suppressed because it is too large Load Diff

View File

@@ -125,7 +125,7 @@ void AutomationPatternView::disconnectObject( QAction * _a )
//If automation editor is opened, update its display after disconnection
if( Engine::automationEditor() )
{
Engine::automationEditor()->updateAfterPatternChange();
Engine::automationEditor()->m_editor->updateAfterPatternChange();
}
//if there is no more connection connected to the AutomationPattern

View File

@@ -30,13 +30,13 @@
#include <QToolBar>
void Editor::setPlaying(bool playing)
void Editor::setPauseIcon(bool displayPauseIcon)
{
// If we're playing, show a pause icon
if (playing)
m_playButton->setIcon(embed::getIconPixmap("play"));
else
if (displayPauseIcon)
m_playButton->setIcon(embed::getIconPixmap("pause"));
else
m_playButton->setIcon(embed::getIconPixmap("play"));
}
Editor::Editor(bool record) :