From 44b52ebd99b614dcc28cc4da284ac583dcbdc216 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Sun, 7 Dec 2014 11:53:20 +0100 Subject: [PATCH 01/32] Add Editor superclass Provides a toolbar with play, record and stop buttons. --- include/Editor.h | 65 +++++++++++++++++++++++++++++++++++++++ src/gui/Editor.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 include/Editor.h create mode 100644 src/gui/Editor.cpp diff --git a/include/Editor.h b/include/Editor.h new file mode 100644 index 000000000..0416f0369 --- /dev/null +++ b/include/Editor.h @@ -0,0 +1,65 @@ +/* + * Editor.h - declaration of Editor class + * + * Copyright (c) 2014 Lukas W + * + * 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 EDITOR_COMMON_H +#define EDITOR_COMMON_H + +#include +#include + +#include "Timeline.h" +#include "ToolButton.h" + +/// \brief Superclass for editors with a toolbar. +/// +/// Those editors include the Song Editor, the Automation Editor, +/// B&B Editor, Piano Roll. +class Editor : public QMainWindow +{ + Q_OBJECT +public: + void setPlaying(bool playing=true); + +signals: + +protected: + /// \brief Constructor. + /// + /// \param record If set true, the editor's toolbar will contain record + /// buttons in addition to the play and stop buttons. + Editor(bool record = false); + virtual ~Editor(); + + + QToolBar* m_toolBar; + + QAbstractButton* m_playButton; + QAbstractButton* m_recordButton; + QAbstractButton* m_recordAccompanyButton; + QAbstractButton* m_stopButton; +private: +}; + + +#endif diff --git a/src/gui/Editor.cpp b/src/gui/Editor.cpp new file mode 100644 index 000000000..8f0e80da2 --- /dev/null +++ b/src/gui/Editor.cpp @@ -0,0 +1,76 @@ +/* + * Editor.cpp - implementation of Editor class + * + * Copyright (c) 2014 Lukas W + * + * 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. + * + */ + +#include "Editor.h" + +#include "embed.h" + +#include +#include + + +void Editor::setPlaying(bool playing) +{ + // If we're playing, show a pause icon + if (playing) + m_playButton->setIcon(embed::getIconPixmap("play")); + else + m_playButton->setIcon(embed::getIconPixmap("pause")); +} + +Editor::Editor(bool record) : + m_toolBar(new QToolBar(this)), + m_playButton(nullptr), + m_recordButton(nullptr), + m_recordAccompanyButton(nullptr), + m_stopButton(nullptr) +{ + auto addButton = [this](const char* pixmap_name, QString text, QString objectName) { + ToolButton* button = new ToolButton(embed::getIconPixmap(pixmap_name), text); + button->setObjectName(objectName); + m_toolBar->addWidget(button); + return button; + }; + + // Set up play button + m_playButton = addButton("play", tr("Play (Space)"), "playButton"); + + // Set up record buttons if wanted + if (record) + { + m_recordButton= addButton("record", tr("Record"), "recordButton"); + m_recordAccompanyButton = addButton("record_accompany", tr("Record while playing"), "recordAccompanyButton"); + } + + // Set up stop button + m_stopButton = addButton("stop", tr("Stop (Space)"), "stopButton"); + + // Add toolbar to window + addToolBar(Qt::TopToolBarArea, m_toolBar); +} + +Editor::~Editor() +{ + +} From c6ee6140120967f00b05d4144cfdf17e4e723a7c Mon Sep 17 00:00:00 2001 From: Lukas W Date: Sun, 7 Dec 2014 11:53:32 +0100 Subject: [PATCH 02/32] Clean up ToolButton class --- include/ToolButton.h | 44 ++++------------------------ src/gui/widgets/ToolButton.cpp | 52 +--------------------------------- 2 files changed, 7 insertions(+), 89 deletions(-) diff --git a/include/ToolButton.h b/include/ToolButton.h index 7e1183e14..27365d69d 100644 --- a/include/ToolButton.h +++ b/include/ToolButton.h @@ -34,48 +34,16 @@ class ToolButton : public QToolButton { Q_OBJECT public: - ToolButton( const QPixmap & _pixmap, const QString & _tooltip, - QObject * _receiver, const char * _slot, - QWidget * _parent ); + ToolButton(const QPixmap & _pixmap, const QString & _tooltip, + QObject * _receiver=nullptr, const char * _slot=nullptr, + QWidget * _parent=nullptr); - inline ToolButton( QWidget * _parent ) : - QToolButton( _parent ), - m_colorStandard( s_stdColor ), - m_colorHighlighted( s_hlColor ) - { - // setup colors - leaveEvent( NULL ); - } + inline ToolButton(QWidget * _parent) : + QToolButton(_parent) + { } virtual ~ToolButton(); - inline void setStandardColor( const QColor & _color ) - { - m_colorStandard = _color; - } - - inline void setHighlightedColor( const QColor & _color ) - { - m_colorHighlighted = _color; - } - - -protected: - virtual void enterEvent( QEvent * _ev ); - virtual void leaveEvent( QEvent * _ev ); - - -private slots: - void toggledBool( bool _on ); - - -private: - static const QColor s_stdColor; - static const QColor s_hlColor; - - QColor m_colorStandard; - QColor m_colorHighlighted; - } ; #endif diff --git a/src/gui/widgets/ToolButton.cpp b/src/gui/widgets/ToolButton.cpp index d2031abc6..20e601868 100644 --- a/src/gui/widgets/ToolButton.cpp +++ b/src/gui/widgets/ToolButton.cpp @@ -27,24 +27,12 @@ #include "ToolTip.h" -const QColor ToolButton::s_stdColor = QColor( 216, 216, 216 ); -const QColor ToolButton::s_hlColor = QColor( 240, 240, 240 ); - - - ToolButton::ToolButton( const QPixmap & _pixmap, const QString & _tooltip, QObject * _receiver, const char * _slot, QWidget * _parent ) : - QToolButton( _parent ), - m_colorStandard( s_stdColor ), - m_colorHighlighted( s_hlColor ) + QToolButton( _parent ) { setAutoFillBackground( false ); - QPalette pal = palette(); - pal.setColor( backgroundRole(), m_colorStandard ); - pal.setColor( QPalette::Window, m_colorStandard ); - pal.setColor( QPalette::Button, m_colorStandard ); - setPalette( pal ); if( _receiver != NULL && _slot != NULL ) { @@ -53,9 +41,6 @@ ToolButton::ToolButton( const QPixmap & _pixmap, const QString & _tooltip, ToolTip::add( this, _tooltip ); setFixedSize( 30, 30 ); setIcon( _pixmap ); - leaveEvent( NULL ); - connect( this, SIGNAL( toggled( bool ) ), this, - SLOT( toggledBool( bool ) ) ); } @@ -68,40 +53,5 @@ ToolButton::~ToolButton() -void ToolButton::enterEvent( QEvent * ) -{ - QPalette pal = palette(); - pal.setColor( backgroundRole(), m_colorHighlighted ); - pal.setColor( QPalette::Window, m_colorHighlighted ); - pal.setColor( QPalette::Button, m_colorHighlighted ); - setPalette( pal ); -} - - - - -void ToolButton::leaveEvent( QEvent * ) -{ - QPalette pal = palette(); - pal.setColor( backgroundRole(), m_colorStandard ); - pal.setColor( QPalette::Window, m_colorStandard ); - pal.setColor( QPalette::Button, m_colorStandard ); - setPalette( pal ); -} - - - - -void ToolButton::toggledBool( bool _on ) -{ - if( _on == true ) - { - emit( clicked() ); - } -} - - - - From 02006f98557526add0dc8f555b9b7cd68ab2fb41 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Sun, 7 Dec 2014 12:48:49 +0100 Subject: [PATCH 03/32] Use Editor superclass in AutomationEditor Split AutomationEditor -> AutomationEditor + AutomationEditorWindow --- include/AutomationEditor.h | 131 +++-- include/Editor.h | 2 +- include/Engine.h | 6 +- src/core/Engine.cpp | 4 +- src/core/Song.cpp | 6 +- src/gui/AutomationEditor.cpp | 941 ++++++++++++++---------------- src/gui/AutomationPatternView.cpp | 2 +- src/gui/Editor.cpp | 8 +- 8 files changed, 533 insertions(+), 567 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 83b0a022b..856b6177e 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -29,6 +29,8 @@ #include #include +#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 diff --git a/include/Editor.h b/include/Editor.h index 0416f0369..ccc4af494 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -39,7 +39,7 @@ class Editor : public QMainWindow { Q_OBJECT public: - void setPlaying(bool playing=true); + void setPauseIcon(bool displayPauseIcon=true); signals: diff --git a/include/Engine.h b/include/Engine.h index b7839f817..827d72e65 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -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; diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index 67a6a669f..a921fde56 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -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(); } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index ce686e79f..cd1a642e1 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -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() ); } diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index f47d8165b..a80b118d8 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #ifndef __USE_XOPEN @@ -107,6 +108,43 @@ AutomationEditor::AutomationEditor() : Qt::QueuedConnection ); connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ), this, SLOT( update() ) ); + + setAttribute( Qt::WA_OpaquePaintEvent, true ); + + m_tensionModel = new FloatModel(1.0, 0.0, 1.0, 0.01); + connect( m_tensionModel, SIGNAL( dataChanged() ), + this, SLOT( setTension() ) ); + + for( int i = 0; i < 7; ++i ) + { + m_quantizeModel.addItem( "1/" + QString::number( 1 << i ) ); + } + m_quantizeModel.setValue( m_quantizeModel.findText( "1/16" ) ); + + // add time-line + m_timeLine = new Timeline( VALUES_WIDTH, 0, m_ppt, + Engine::getSong()->getPlayPos( + Song::Mode_PlayAutomationPattern ), + m_currentPosition, this ); + connect( this, SIGNAL( positionChanged( const MidiTime & ) ), + m_timeLine, SLOT( updatePosition( const MidiTime & ) ) ); + connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ), + this, SLOT( updatePosition( const MidiTime & ) ) ); + + removeSelection(); + + // init scrollbars + m_leftRightScroll = new QScrollBar( Qt::Horizontal, this ); + m_leftRightScroll->setSingleStep( 1 ); + connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ), this, + SLOT( horScrolled( int ) ) ); + + m_topBottomScroll = new QScrollBar( Qt::Vertical, this ); + m_topBottomScroll->setSingleStep( 1 ); + m_topBottomScroll->setPageStep( 20 ); + connect( m_topBottomScroll, SIGNAL( valueChanged( int ) ), this, + SLOT( verScrolled( int ) ) ); + // init pixmaps if( s_toolDraw == NULL ) { @@ -129,324 +167,9 @@ AutomationEditor::AutomationEditor() : "edit_move" ) ); } - setAttribute( Qt::WA_OpaquePaintEvent, true ); - - // add time-line - m_timeLine = new Timeline( VALUES_WIDTH, 32, m_ppt, - Engine::getSong()->getPlayPos( - Song::Mode_PlayAutomationPattern ), - m_currentPosition, this ); - connect( this, SIGNAL( positionChanged( const MidiTime & ) ), - m_timeLine, SLOT( updatePosition( const MidiTime & ) ) ); - connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ), - this, SLOT( updatePosition( const MidiTime & ) ) ); - - - m_toolBar = new QWidget( this ); - m_toolBar->setFixedHeight( 32 ); - m_toolBar->move( 0, 0 ); - m_toolBar->setAutoFillBackground( true ); - QPalette pal; - pal.setBrush( m_toolBar->backgroundRole(), - embed::getIconPixmap( "toolbar_bg" ) ); - m_toolBar->setPalette( pal ); - - QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar ); - tb_layout->setMargin( 0 ); - tb_layout->setSpacing( 0 ); - - - // init control-buttons at the top - - m_playButton = new ToolButton( embed::getIconPixmap( "play" ), - tr( "Play/pause current pattern (Space)" ), - this, SLOT( play() ), m_toolBar ); - - - m_stopButton = new ToolButton( embed::getIconPixmap( "stop" ), - tr( "Stop playing of current pattern (Space)" ), - this, SLOT( stop() ), m_toolBar ); - - m_playButton->setObjectName( "playButton" ); - m_stopButton->setObjectName( "stopButton" ); - - m_playButton->setWhatsThis( - tr( "Click here if you want to play the current pattern. " - "This is useful while editing it. The pattern is " - "automatically looped when the end is reached." ) ); - m_stopButton->setWhatsThis( - tr( "Click here if you want to stop playing of the " - "current pattern." ) ); - - removeSelection(); - - // init scrollbars - m_leftRightScroll = new QScrollBar( Qt::Horizontal, this ); - m_leftRightScroll->setSingleStep( 1 ); - connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ), this, - SLOT( horScrolled( int ) ) ); - - m_topBottomScroll = new QScrollBar( Qt::Vertical, this ); - m_topBottomScroll->setSingleStep( 1 ); - m_topBottomScroll->setPageStep( 20 ); - connect( m_topBottomScroll, SIGNAL( valueChanged( int ) ), this, - SLOT( verScrolled( int ) ) ); - - // init edit-buttons at the top - m_drawButton = new ToolButton( embed::getIconPixmap( "edit_draw" ), - tr( "Draw mode (Shift+D)" ), - this, SLOT( drawButtonToggled() ), - m_toolBar ); - m_drawButton->setCheckable( true ); - m_drawButton->setChecked( true ); - - m_eraseButton = new ToolButton( embed::getIconPixmap( "edit_erase" ), - tr( "Erase mode (Shift+E)" ), - this, SLOT( eraseButtonToggled() ), - m_toolBar ); - m_eraseButton->setCheckable( true ); - - //TODO: m_selectButton and m_moveButton are broken. - /*m_selectButton = new toolButton( embed::getIconPixmap( - "edit_select" ), - tr( "Select mode (Shift+S)" ), - this, SLOT( selectButtonToggled() ), - m_toolBar ); - m_selectButton->setCheckable( true ); - - m_moveButton = new toolButton( embed::getIconPixmap( "edit_move" ), - tr( "Move selection mode (Shift+M)" ), - this, SLOT( moveButtonToggled() ), - m_toolBar ); - m_moveButton->setCheckable( true );*/ - - QButtonGroup * tool_button_group = new QButtonGroup( this ); - tool_button_group->addButton( m_drawButton ); - tool_button_group->addButton( m_eraseButton ); - //tool_button_group->addButton( m_selectButton ); - //tool_button_group->addButton( m_moveButton ); - tool_button_group->setExclusive( true ); - - m_drawButton->setWhatsThis( - tr( "Click here and draw-mode will be activated. In this " - "mode you can add and move single values. This " - "is the default mode which is used most of the time. " - "You can also press 'Shift+D' on your keyboard to " - "activate this mode." ) ); - m_eraseButton->setWhatsThis( - tr( "Click here and erase-mode will be activated. In this " - "mode you can erase single values. You can also press " - "'Shift+E' on your keyboard to activate this mode." ) ); - /*m_selectButton->setWhatsThis( - tr( "Click here and select-mode will be activated. In this " - "mode you can select values. This is necessary " - "if you want to cut, copy, paste, delete, or move " - "values. You can also press 'Shift+S' on your keyboard " - "to activate this mode." ) ); - m_moveButton->setWhatsThis( - tr( "If you click here, move-mode will be activated. In this " - "mode you can move the values you selected in select-" - "mode. You can also press 'Shift+M' on your keyboard " - "to activate this mode." ) );*/ - - m_discreteButton = new ToolButton( embed::getIconPixmap( - "progression_discrete" ), - tr( "Discrete progression" ), - this, SLOT( discreteButtonToggled() ), - m_toolBar ); - m_discreteButton->setCheckable( true ); - m_discreteButton->setChecked( true ); - - m_linearButton = new ToolButton( embed::getIconPixmap( - "progression_linear" ), - tr( "Linear progression" ), - this, SLOT( linearButtonToggled() ), - m_toolBar ); - m_linearButton->setCheckable( true ); - - m_cubicHermiteButton = new ToolButton( embed::getIconPixmap( - "progression_cubic_hermite" ), - tr( "Cubic Hermite progression" ), - this, SLOT( - cubicHermiteButtonToggled() ), - m_toolBar ); - m_cubicHermiteButton->setCheckable( true ); - - // setup tension-stuff - m_tensionKnob = new Knob( knobSmall_17, this, "Tension" ); - m_tensionModel = new FloatModel(1.0, 0.0, 1.0, 0.01); - connect( m_tensionModel, SIGNAL( dataChanged() ), - this, SLOT( tensionChanged() ) ); - - QLabel * tension_lbl = new QLabel( m_toolBar ); - tension_lbl->setText( tr("Tension: ") ); - - tool_button_group = new QButtonGroup( this ); - tool_button_group->addButton( m_discreteButton ); - tool_button_group->addButton( m_linearButton ); - tool_button_group->addButton( m_cubicHermiteButton ); - tool_button_group->setExclusive( true ); - - m_discreteButton->setWhatsThis( - tr( "Click here to choose discrete progressions for this " - "automation pattern. The value of the connected " - "object will remain constant between control points " - "and be set immediately to the new value when each " - "control point is reached." ) ); - m_linearButton->setWhatsThis( - tr( "Click here to choose linear progressions for this " - "automation pattern. The value of the connected " - "object will change at a steady rate over time " - "between control points to reach the correct value at " - "each control point without a sudden change." ) ); - m_cubicHermiteButton->setWhatsThis( - tr( "Click here to choose cubic hermite progressions for this " - "automation pattern. The value of the connected " - "object will change in a smooth curve and ease in to " - "the peaks and valleys." ) ); - - m_cutButton = new ToolButton( embed::getIconPixmap( "edit_cut" ), - tr( "Cut selected values (Ctrl+X)" ), - this, SLOT( cutSelectedValues() ), - m_toolBar ); - - m_copyButton = new ToolButton( embed::getIconPixmap( "edit_copy" ), - tr( "Copy selected values (Ctrl+C)" ), - this, SLOT( copySelectedValues() ), - m_toolBar ); - - m_pasteButton = new ToolButton( embed::getIconPixmap( "edit_paste" ), - tr( "Paste values from clipboard " - "(Ctrl+V)" ), - this, SLOT( pasteValues() ), - m_toolBar ); - - m_cutButton->setWhatsThis( - tr( "Click here and selected values will be cut into the " - "clipboard. You can paste them anywhere in any pattern " - "by clicking on the paste button." ) ); - m_copyButton->setWhatsThis( - tr( "Click here and selected values will be copied into " - "the clipboard. You can paste them anywhere in any " - "pattern by clicking on the paste button." ) ); - m_pasteButton->setWhatsThis( - tr( "Click here and the values from the clipboard will be " - "pasted at the first visible measure." ) ); - - - // setup zooming-stuff - QLabel * zoom_x_lbl = new QLabel( m_toolBar ); - zoom_x_lbl->setPixmap( embed::getIconPixmap( "zoom_x" ) ); - - m_zoomingXComboBox = new ComboBox( m_toolBar ); - m_zoomingXComboBox->setFixedSize( 80, 22 ); - - for( int i = 0; i < 6; ++i ) - { - m_zoomingXModel.addItem( QString::number( 25 << i ) + "%" ); - } - m_zoomingXModel.setValue( m_zoomingXModel.findText( "100%" ) ); - - m_zoomingXComboBox->setModel( &m_zoomingXModel ); - - connect( &m_zoomingXModel, SIGNAL( dataChanged() ), - this, SLOT( zoomingXChanged() ) ); - - - QLabel * zoom_y_lbl = new QLabel( m_toolBar ); - zoom_y_lbl->setPixmap( embed::getIconPixmap( "zoom_y" ) ); - - m_zoomingYComboBox = new ComboBox( m_toolBar ); - m_zoomingYComboBox->setFixedSize( 80, 22 ); - - m_zoomingYModel.addItem( "Auto" ); - for( int i = 0; i < 7; ++i ) - { - m_zoomingYModel.addItem( QString::number( 25 << i ) + "%" ); - } - m_zoomingYModel.setValue( m_zoomingYModel.findText( "Auto" ) ); - - m_zoomingYComboBox->setModel( &m_zoomingYModel ); - - connect( &m_zoomingYModel, SIGNAL( dataChanged() ), - this, SLOT( zoomingYChanged() ) ); - - - // setup quantize-stuff - QLabel * quantize_lbl = new QLabel( m_toolBar ); - quantize_lbl->setPixmap( embed::getIconPixmap( "quantize" ) ); - - m_quantizeComboBox = new ComboBox( m_toolBar ); - m_quantizeComboBox->setFixedSize( 60, 22 ); - - for( int i = 0; i < 7; ++i ) - { - m_quantizeModel.addItem( "1/" + QString::number( 1 << i ) ); - } - m_quantizeModel.setValue( m_quantizeModel.findText( "1/16" ) ); - - m_quantizeComboBox->setModel( &m_quantizeModel ); - - - tb_layout->addSpacing( 5 ); - tb_layout->addWidget( m_playButton ); - tb_layout->addWidget( m_stopButton ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( m_drawButton ); - tb_layout->addWidget( m_eraseButton ); - //tb_layout->addWidget( m_selectButton ); - //tb_layout->addWidget( m_moveButton ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( m_discreteButton ); - tb_layout->addWidget( m_linearButton ); - tb_layout->addWidget( m_cubicHermiteButton ); - tb_layout->addSpacing( 5 ); - tb_layout->addWidget( tension_lbl ); - tb_layout->addSpacing( 5 ); - tb_layout->addWidget( m_tensionKnob ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( m_cutButton ); - tb_layout->addWidget( m_copyButton ); - tb_layout->addWidget( m_pasteButton ); - tb_layout->addSpacing( 10 ); - m_timeLine->addToolButtons( m_toolBar ); - tb_layout->addSpacing( 15 ); - tb_layout->addWidget( zoom_x_lbl ); - tb_layout->addSpacing( 4 ); - tb_layout->addWidget( m_zoomingXComboBox ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( zoom_y_lbl ); - tb_layout->addSpacing( 4 ); - tb_layout->addWidget( m_zoomingYComboBox ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( quantize_lbl ); - tb_layout->addSpacing( 4 ); - tb_layout->addWidget( m_quantizeComboBox ); - tb_layout->addStretch(); - - // setup our actual window - setFocusPolicy( Qt::StrongFocus ); - setFocus(); - setWindowIcon( embed::getIconPixmap( "automation" ) ); setCurrentPattern( NULL ); setMouseTracking( true ); - - setMinimumSize( tb_layout->minimumSize().width(), 128 ); - - // add us to workspace - if( Engine::mainWindow()->workspace() ) - { - Engine::mainWindow()->workspace()->addSubWindow( this ); - parentWidget()->resize( INITIAL_WIDTH, INITIAL_HEIGHT ); - parentWidget()->move( 5, 5 ); - parentWidget()->hide(); - } - else - { - resize( INITIAL_WIDTH, INITIAL_HEIGHT ); - hide(); - } } @@ -492,19 +215,6 @@ void AutomationEditor::loadSettings( const QDomElement & _this ) - -void AutomationEditor::setPauseIcon( bool pause ) -{ - if( pause == true ) - { - m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); - } - else - { - m_playButton->setIcon( embed::getIconPixmap( "play" ) ); - } -} - // qproperty access methods QColor AutomationEditor::gridColor() const @@ -541,27 +251,6 @@ void AutomationEditor::updateAfterPatternChange() return; } - if( m_pattern->progressionType() == - AutomationPattern::DiscreteProgression && - !m_discreteButton->isChecked() ) - { - m_discreteButton->setChecked( true ); - } - - if( m_pattern->progressionType() == - AutomationPattern::LinearProgression && - !m_linearButton->isChecked() ) - { - m_linearButton->setChecked( true ); - } - - if( m_pattern->progressionType() == - AutomationPattern::CubicHermiteProgression && - !m_cubicHermiteButton->isChecked() ) - { - m_cubicHermiteButton->setChecked( true ); - } - m_minLevel = m_pattern->firstObject()->minValue(); m_maxLevel = m_pattern->firstObject()->maxValue(); m_step = m_pattern->firstObject()->step(); @@ -605,23 +294,6 @@ void AutomationEditor::removeSelection() -void AutomationEditor::closeEvent( QCloseEvent * _ce ) -{ - QApplication::restoreOverrideCursor(); - if( parentWidget() ) - { - parentWidget()->hide(); - } - else - { - hide(); - } - _ce->ignore(); -} - - - - void AutomationEditor::keyPressEvent( QKeyEvent * _ke ) { switch( _ke->key() ) @@ -685,44 +357,12 @@ void AutomationEditor::keyPressEvent( QKeyEvent * _ke ) update(); _ke->accept(); } - break;*/ - - case Qt::Key_D: - if( _ke->modifiers() & Qt::ShiftModifier ) - { - m_drawButton->setChecked( true ); - _ke->accept(); - } break; - case Qt::Key_E: - if( _ke->modifiers() & Qt::ShiftModifier ) - { - m_eraseButton->setChecked( true ); - _ke->accept(); - } - break; - //TODO: m_selectButton and m_moveButton are broken. - /*case Qt::Key_S: - if( _ke->modifiers() & Qt::ShiftModifier ) - { - m_selectButton->setChecked( true ); - _ke->accept(); - } - break; - - case Qt::Key_M: - if( _ke->modifiers() & Qt::ShiftModifier ) - { - m_moveButton->setChecked( true ); - _ke->accept(); - } - break;*/ - case Qt::Key_Delete: deleteSelectedValues(); _ke->accept(); - break; + break;*/ case Qt::Key_Space: if( Engine::getSong()->isPlaying() ) @@ -812,14 +452,6 @@ void AutomationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 ) -void AutomationEditor::disableTensionKnob() -{ - m_tensionKnob->setEnabled( false ); -} - - - - void AutomationEditor::mousePressEvent( QMouseEvent * _me ) { QMutexLocker m( &m_patternMutex ); @@ -941,7 +573,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) { // when clicking right in select-move, we // switch to move-mode - m_moveButton->setChecked( true ); + //m_moveButton->setChecked( true ); } else if( _me->button() == Qt::LeftButton && m_editMode == MOVE ) @@ -961,7 +593,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) { // when clicking right in select-move, we // switch to draw-mode - m_drawButton->setChecked( true ); + //m_drawButton->setChecked( true ); } update(); @@ -1822,7 +1454,6 @@ void AutomationEditor::resizeEvent( QResizeEvent * ) Engine::getSong()->getPlayPos( Song::Mode_PlayAutomationPattern ).m_timeLine->setFixedWidth( width() ); } - m_toolBar->setFixedWidth( width() ); updateTopBottomLevels(); update(); @@ -1960,8 +1591,6 @@ void AutomationEditor::play() Engine::getSong()->togglePause(); } } - - setPauseIcon( Engine::getSong()->isPlaying() ); } @@ -2009,102 +1638,69 @@ void AutomationEditor::verScrolled( int _new_pos ) -void AutomationEditor::drawButtonToggled() +void AutomationEditor::setEditMode(AutomationEditor::editModes mode) { - m_editMode = DRAW; - removeSelection(); - update(); -} + if (m_editMode == mode) + return; - - - -void AutomationEditor::eraseButtonToggled() -{ - m_editMode = ERASE; - removeSelection(); - update(); -} - - - - -void AutomationEditor::selectButtonToggled() -{ - m_editMode = SELECT; - removeSelection(); - update(); -} - - - - -void AutomationEditor::moveButtonToggled() -{ - m_editMode = MOVE; - m_selValuesForMove.clear(); - getSelectedValues( m_selValuesForMove ); - update(); -} - - - - -void AutomationEditor::discreteButtonToggled() -{ - if ( validPattern() ) + m_editMode = mode; + switch (mode) { - QMutexLocker m( &m_patternMutex ); - disableTensionKnob(); - m_pattern->setProgressionType( - AutomationPattern::DiscreteProgression ); + case DRAW: + case ERASE: + case SELECT: + removeSelection(); + break; + case MOVE: + m_selValuesForMove.clear(); + getSelectedValues(m_selValuesForMove); + } + update(); +} + + + +void AutomationEditor::setEditMode(int mode) +{ + setEditMode((AutomationEditor::editModes) mode); +} + + + + +void AutomationEditor::setProgressionType(AutomationPattern::ProgressionTypes type) +{ + if (validPattern()) + { + QMutexLocker m(&m_patternMutex); + m_pattern->setProgressionType(type); Engine::getSong()->setModified(); update(); } } - - -void AutomationEditor::linearButtonToggled() +void AutomationEditor::setProgressionDiscrete() { - if ( validPattern() ) - { - QMutexLocker m( &m_patternMutex ); - disableTensionKnob(); - m_pattern->setProgressionType( - AutomationPattern::LinearProgression ); - Engine::getSong()->setModified(); - update(); - } + setProgressionType(AutomationPattern::DiscreteProgression); +} + + +void AutomationEditor::setProgressionLinear() +{ + setProgressionType(AutomationPattern::LinearProgression); +} + + +void AutomationEditor::setProgressionHermite() +{ + setProgressionType(AutomationPattern::CubicHermiteProgression); } -void AutomationEditor::cubicHermiteButtonToggled() -{ - if ( validPattern() ) - { - m_tensionKnob->setModel( m_tensionModel ); - m_tensionKnob->setEnabled( true ); - ToolTip::add( m_tensionKnob, tr( "Tension value for spline" ) ); - m_tensionKnob->setWhatsThis( - tr( "A higher tension value may make a smoother curve " - "but overshoot some values. A low tension " - "value will cause the slope of the curve to " - "level off at each control point." ) ); - m_pattern->setProgressionType( - AutomationPattern::CubicHermiteProgression ); - Engine::getSong()->setModified(); - update(); - } -} - - - - -void AutomationEditor::tensionChanged() +void AutomationEditor::setTension() { m_pattern->setTension( QString::number( m_tensionModel->value() ) ); update(); @@ -2366,10 +1962,7 @@ void AutomationEditor::zoomingYChanged() int AutomationEditor::quantization() const { - return( DefaultTicksPerTact / - m_quantizeComboBox->model()->currentText().right( - m_quantizeComboBox->model()->currentText().length() - - 2 ).toInt() ); + return DefaultTicksPerTact / (1 << m_quantizeModel.value()); } @@ -2425,3 +2018,357 @@ void AutomationEditor::updateTopBottomLevels() + + +AutomationEditorWindow::AutomationEditorWindow() : + Editor(), + m_editor(new AutomationEditor()) +{ + setCentralWidget(m_editor); + + + + // Play/stop buttons + m_playButton->setToolTip(tr( "Play/pause current pattern (Space)" )); + m_playButton->setWhatsThis( + tr( "Click here if you want to play the current pattern. " + "This is useful while editing it. The pattern is " + "automatically looped when the end is reached." ) ); + + m_stopButton->setToolTip(tr("Stop playing of current pattern (Space)")); + m_stopButton->setWhatsThis( + tr( "Click here if you want to stop playing of the " + "current pattern." ) ); + + // Set up signals) + connect(m_playButton, SIGNAL(clicked()), this, SLOT(play())); + connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop())); + + + // Edit mode buttons + + m_drawButton = new ToolButton(embed::getIconPixmap( "edit_draw" ), + tr( "Draw mode (Shift+D)" )); + m_drawButton->setCheckable( true ); + m_drawButton->setChecked( true ); + m_drawButton->setShortcut(Qt::SHIFT | Qt::Key_D); + + m_eraseButton = new ToolButton( embed::getIconPixmap( "edit_erase" ), + tr( "Erase mode (Shift+E)" )); + m_eraseButton->setCheckable( true ); + m_eraseButton->setShortcut(Qt::SHIFT | Qt::Key_E); + + //TODO: m_selectButton and m_moveButton are broken. + /*m_selectButton = new ToolButton( embed::getIconPixmap( + "edit_select" ), + tr( "Select mode (Shift+S)" ), + this, SLOT( selectButtonToggled() ), + m_toolBar ); + m_selectButton->setCheckable( true ); + + m_moveButton = new ToolButton( embed::getIconPixmap( "edit_move" ), + tr( "Move selection mode (Shift+M)" ), + this, SLOT( moveButtonToggled() ), + m_toolBar ); + m_moveButton->setCheckable( true );*/ + + QSignalMapper* signalmapper = new QSignalMapper(this); + signalmapper->setMapping(m_drawButton, AutomationEditor::DRAW); + signalmapper->setMapping(m_eraseButton, AutomationEditor::ERASE); +// signalmapper->setMapping(m_selectButton, AutomationEditor::SELECT); +// signalmapper->setMapping(m_moveButton, AutomationEditor::MOVE); + + connect(m_drawButton, SIGNAL(clicked()), signalmapper, SLOT(map())); + connect(m_eraseButton, SIGNAL(clicked()), signalmapper, SLOT(map())); +// connect(m_selectButton, SIGNAL(triggered()), signalmapper, SLOT(map())); +// connect(m_moveButton, SIGNAL(triggered()), signalmapper, SLOT(map())); + + connect(signalmapper, SIGNAL(mapped(int)), m_editor, SLOT(setEditMode(int))); + + QButtonGroup * tool_button_group = new QButtonGroup(); + tool_button_group->addButton( m_drawButton ); + tool_button_group->addButton( m_eraseButton ); + //tool_button_group->addButton( m_selectButton ); + //tool_button_group->addButton( m_moveButton ); + tool_button_group->setExclusive( true ); + + m_drawButton->setWhatsThis( + tr( "Click here and draw-mode will be activated. In this " + "mode you can add and move single values. This " + "is the default mode which is used most of the time. " + "You can also press 'Shift+D' on your keyboard to " + "activate this mode." ) ); + m_eraseButton->setWhatsThis( + tr( "Click here and erase-mode will be activated. In this " + "mode you can erase single values. You can also press " + "'Shift+E' on your keyboard to activate this mode." ) ); + /*m_selectButton->setWhatsThis( + tr( "Click here and select-mode will be activated. In this " + "mode you can select values. This is necessary " + "if you want to cut, copy, paste, delete, or move " + "values. You can also press 'Shift+S' on your keyboard " + "to activate this mode." ) ); + m_moveButton->setWhatsThis( + tr( "If you click here, move-mode will be activated. In this " + "mode you can move the values you selected in select-" + "mode. You can also press 'Shift+M' on your keyboard " + "to activate this mode." ) );*/ + + + + // Progression type buttons + + m_discreteButton = new ToolButton( embed::getIconPixmap( + "progression_discrete" ), + tr( "Discrete progression" ), + m_editor, SLOT( setProgressionDiscrete() ), + m_toolBar ); + m_discreteButton->setCheckable( true ); + m_discreteButton->setChecked( true ); + + m_linearButton = new ToolButton( embed::getIconPixmap( + "progression_linear" ), + tr( "Linear progression" ), + m_editor, SLOT( setProgressionLinear() ), + m_toolBar ); + m_linearButton->setCheckable( true ); + + m_cubicHermiteButton = new ToolButton( embed::getIconPixmap( + "progression_cubic_hermite" ), + tr( "Cubic Hermite progression" ), + m_editor, SLOT( + setProgressionHermite() ), + m_toolBar ); + m_cubicHermiteButton->setCheckable( true ); + + // setup tension-stuff + m_tensionKnob = new Knob( knobSmall_17, this, "Tension" ); + + tool_button_group = new QButtonGroup( this ); + tool_button_group->addButton( m_discreteButton ); + tool_button_group->addButton( m_linearButton ); + tool_button_group->addButton( m_cubicHermiteButton ); + tool_button_group->setExclusive( true ); + + m_discreteButton->setWhatsThis( + tr( "Click here to choose discrete progressions for this " + "automation pattern. The value of the connected " + "object will remain constant between control points " + "and be set immediately to the new value when each " + "control point is reached." ) ); + m_linearButton->setWhatsThis( + tr( "Click here to choose linear progressions for this " + "automation pattern. The value of the connected " + "object will change at a steady rate over time " + "between control points to reach the correct value at " + "each control point without a sudden change." ) ); + m_cubicHermiteButton->setWhatsThis( + tr( "Click here to choose cubic hermite progressions for this " + "automation pattern. The value of the connected " + "object will change in a smooth curve and ease in to " + "the peaks and valleys." ) ); + + + + // Copy paste buttons + + m_cutButton = new ToolButton( embed::getIconPixmap( "edit_cut" ), + tr( "Cut selected values (Ctrl+X)" ), + m_editor, SLOT( cutSelectedValues() ), + m_toolBar ); + + m_copyButton = new ToolButton( embed::getIconPixmap( "edit_copy" ), + tr( "Copy selected values (Ctrl+C)" ), + m_editor, SLOT( copySelectedValues() ), + m_toolBar ); + + m_pasteButton = new ToolButton( embed::getIconPixmap( "edit_paste" ), + tr( "Paste values from clipboard " + "(Ctrl+V)" ), + m_editor, SLOT( pasteValues() ), + m_toolBar ); + + m_cutButton->setWhatsThis( + tr( "Click here and selected values will be cut into the " + "clipboard. You can paste them anywhere in any pattern " + "by clicking on the paste button." ) ); + m_copyButton->setWhatsThis( + tr( "Click here and selected values will be copied into " + "the clipboard. You can paste them anywhere in any " + "pattern by clicking on the paste button." ) ); + m_pasteButton->setWhatsThis( + tr( "Click here and the values from the clipboard will be " + "pasted at the first visible measure." ) ); + + + + // Zoom controls + + QLabel * zoom_x_label = new QLabel( m_toolBar ); + zoom_x_label->setPixmap( embed::getIconPixmap( "zoom_x" ) ); + + m_zoomingXComboBox = new ComboBox( m_toolBar ); + m_zoomingXComboBox->setFixedSize( 80, 22 ); + + for( int i = 0; i < 6; ++i ) + { + m_editor->m_zoomingXModel.addItem( QString::number( 25 << i ) + "%" ); + } + m_editor->m_zoomingXModel.setValue( m_editor->m_zoomingXModel.findText( "100%" ) ); + + m_zoomingXComboBox->setModel( &m_editor->m_zoomingXModel ); + + connect( &m_editor->m_zoomingXModel, SIGNAL( dataChanged() ), + m_editor, SLOT( zoomingXChanged() ) ); + + + QLabel * zoom_y_label = new QLabel( m_toolBar ); + zoom_y_label->setPixmap( embed::getIconPixmap( "zoom_y" ) ); + + m_zoomingYComboBox = new ComboBox( m_toolBar ); + m_zoomingYComboBox->setFixedSize( 80, 22 ); + + m_editor->m_zoomingYModel.addItem( "Auto" ); + for( int i = 0; i < 7; ++i ) + { + m_editor->m_zoomingYModel.addItem( QString::number( 25 << i ) + "%" ); + } + m_editor->m_zoomingYModel.setValue( m_editor->m_zoomingYModel.findText( "Auto" ) ); + + m_zoomingYComboBox->setModel( &m_editor->m_zoomingYModel ); + + connect( &m_editor->m_zoomingYModel, SIGNAL( dataChanged() ), + m_editor, SLOT( zoomingYChanged() ) ); + + + + // Quantization controls + + QLabel * quantize_lbl = new QLabel( m_toolBar ); + quantize_lbl->setPixmap( embed::getIconPixmap( "quantize" ) ); + + m_quantizeComboBox = new ComboBox( m_toolBar ); + m_quantizeComboBox->setFixedSize( 60, 22 ); + + m_quantizeComboBox->setModel( &m_editor->m_quantizeModel ); + + + m_toolBar->addSeparator();; + m_toolBar->addWidget( m_drawButton ); + m_toolBar->addWidget( m_eraseButton ); + //m_toolBar->addWidget( m_selectButton ); + //m_toolBar->addWidget( m_moveButton ); + m_toolBar->addSeparator(); + m_toolBar->addWidget( m_discreteButton ); + m_toolBar->addWidget( m_linearButton ); + m_toolBar->addWidget( m_cubicHermiteButton ); + m_toolBar->addSeparator(); + m_toolBar->addWidget( new QLabel( tr("Tension: "), m_toolBar )); + m_toolBar->addWidget( m_tensionKnob ); + m_toolBar->addSeparator(); + m_toolBar->addWidget( m_cutButton ); + m_toolBar->addWidget( m_copyButton ); + m_toolBar->addWidget( m_pasteButton ); + m_toolBar->addSeparator(); + QWidget* timeLineButtons = new QWidget(); + timeLineButtons->setFixedHeight(m_cutButton->height()); + timeLineButtons->move(0,0); + QLayout* l = new QHBoxLayout( timeLineButtons ); + l->setSpacing(0); l->setMargin(0); + m_editor->m_timeLine->addToolButtons(timeLineButtons); + m_toolBar->addWidget(timeLineButtons); + m_toolBar->addSeparator(); + m_toolBar->addWidget( zoom_x_label ); + m_toolBar->addWidget( m_zoomingXComboBox ); + m_toolBar->addSeparator(); + m_toolBar->addWidget( zoom_y_label ); + m_toolBar->addWidget( m_zoomingYComboBox ); + m_toolBar->addSeparator(); + m_toolBar->addWidget( quantize_lbl ); + m_toolBar->addWidget( m_quantizeComboBox ); + + // Setup our actual window + setFocusPolicy( Qt::StrongFocus ); + setFocus(); + setWindowIcon( embed::getIconPixmap( "automation" ) ); + + // Add us to workspace + if( Engine::mainWindow()->workspace() ) + { + Engine::mainWindow()->workspace()->addSubWindow( this ); + parentWidget()->resize( INITIAL_WIDTH, INITIAL_HEIGHT ); + parentWidget()->move( 5, 5 ); + parentWidget()->hide(); + } + else + { + resize( INITIAL_WIDTH, INITIAL_HEIGHT ); + hide(); + } +} + + +AutomationEditorWindow::~AutomationEditorWindow() +{ +} + + +void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern) +{ + m_editor->setCurrentPattern(pattern); + + if (pattern == nullptr) + return; + + switch(m_editor->m_pattern->progressionType()) + { + case AutomationPattern::DiscreteProgression: + m_discreteButton->setChecked(true); + break; + case AutomationPattern::LinearProgression: + m_linearButton->setChecked(true); + break; + case AutomationPattern::CubicHermiteProgression: + m_cubicHermiteButton->setChecked(true); + break; + } + + emit currentPatternChanged(); +} + + +const AutomationPattern* AutomationEditorWindow::currentPattern() +{ + return m_editor->currentPattern(); +} + + +int AutomationEditorWindow::quantization() const +{ + return m_editor->quantization(); +} + +void AutomationEditorWindow::closeEvent(QCloseEvent* _ce) +{ + QApplication::restoreOverrideCursor(); + if( parentWidget() ) + { + parentWidget()->hide(); + } + else + { + hide(); + } + _ce->ignore(); +} + +void AutomationEditorWindow::play() +{ + m_editor->play(); + setPauseIcon(Engine::getSong()->isPlaying()); +} + +void AutomationEditorWindow::stop() +{ + m_editor->stop(); +} diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 17fbb559f..fba27ceb1 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -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 diff --git a/src/gui/Editor.cpp b/src/gui/Editor.cpp index 8f0e80da2..e292ced1b 100644 --- a/src/gui/Editor.cpp +++ b/src/gui/Editor.cpp @@ -30,13 +30,13 @@ #include -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) : From 3e9cc61042d753ba73d0e0786ae7ecb618e68b18 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Sun, 7 Dec 2014 17:37:22 +0100 Subject: [PATCH 04/32] SongEditor: Use Editor superclass --- include/Engine.h | 6 +- include/SongEditor.h | 44 ++++-- src/core/Engine.cpp | 4 +- src/core/Song.cpp | 2 +- src/gui/SongEditor.cpp | 307 +++++++++++++++++++---------------------- src/tracks/BBTrack.cpp | 2 +- 6 files changed, 184 insertions(+), 181 deletions(-) diff --git a/include/Engine.h b/include/Engine.h index 827d72e65..fb5ad0b5f 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -45,7 +45,7 @@ class Mixer; class PianoRoll; class ProjectNotes; class Song; -class SongEditor; +class SongEditorWindow; class Ladspa2LMMS; class ControllerRackView; @@ -108,7 +108,7 @@ public: return s_fxMixerView; } - static SongEditor* songEditor() + static SongEditorWindow* songEditor() { return s_songEditor; } @@ -187,7 +187,7 @@ private: // GUI static MainWindow * s_mainWindow; static FxMixerView * s_fxMixerView; - static SongEditor* s_songEditor; + static SongEditorWindow* s_songEditor; static AutomationEditorWindow * s_automationEditor; static BBEditor * s_bbEditor; static PianoRoll* s_pianoRoll; diff --git a/include/SongEditor.h b/include/SongEditor.h index bb40155eb..b51b22e1c 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -27,6 +27,7 @@ #ifndef SONG_EDITOR_H #define SONG_EDITOR_H +#include "Editor.h" #include "TrackContainerView.h" class QLabel; @@ -34,6 +35,7 @@ class QScrollBar; class AutomatableSlider; class ComboBox; +class ComboBoxModel; class LcdSpinBox; class MeterDialog; class Song; @@ -56,6 +58,12 @@ class SongEditor : public TrackContainerView { Q_OBJECT public: + enum Mode + { + DrawMode, + EditMode + }; + SongEditor( Song * _song ); virtual ~SongEditor(); @@ -65,6 +73,10 @@ public: public slots: void scrolled( int _new_pos ); + void setMode(Mode mode); + void setModeDraw(); + void setModeEdit(); + private slots: void setHighQuality( bool ); @@ -119,6 +131,28 @@ private: TextFloat * m_mvsStatus; TextFloat * m_mpsStatus; + positionLine * m_positionLine; + + ComboBoxModel* m_zoomingModel; + + bool m_scrollBack; + bool m_smoothScroll; + + Mode m_mode; + + friend class SongEditorWindow; + +} ; + +class SongEditorWindow : public Editor +{ + Q_OBJECT +public: + SongEditorWindow(Song* song); + + SongEditor* m_editor; + +private: ToolButton * m_addBBTrackButton; ToolButton * m_addSampleTrackButton; ToolButton * m_addAutomationTrackButton; @@ -127,14 +161,6 @@ private: ToolButton * m_editModeButton; ComboBox * m_zoomingComboBox; - - positionLine * m_positionLine; - - bool m_scrollBack; - bool m_smoothScroll; - -} ; - - +}; #endif diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index a921fde56..a9d4a65a9 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -55,7 +55,7 @@ FxMixerView * Engine::s_fxMixerView = NULL; MainWindow * Engine::s_mainWindow = NULL; BBTrackContainer * Engine::s_bbTrackContainer = NULL; Song * Engine::s_song = NULL; -SongEditor* Engine::s_songEditor = NULL; +SongEditorWindow* Engine::s_songEditor = NULL; AutomationEditorWindow * Engine::s_automationEditor = NULL; BBEditor * Engine::s_bbEditor = NULL; PianoRoll* Engine::s_pianoRoll = NULL; @@ -93,7 +93,7 @@ void Engine::init( const bool _has_gui ) if( s_hasGUI ) { s_mainWindow = new MainWindow; - s_songEditor = new SongEditor( s_song ); + s_songEditor = new SongEditorWindow( s_song ); s_fxMixerView = new FxMixerView; s_controllerRackView = new ControllerRackView; s_projectNotes = new ProjectNotes; diff --git a/src/core/Song.cpp b/src/core/Song.cpp index cd1a642e1..dc19a3d65 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -733,7 +733,7 @@ void Song::clearProject() } if( Engine::songEditor() ) { - Engine::songEditor()->clearAllTracks(); + Engine::songEditor()->m_editor->clearAllTracks(); } if( Engine::fxMixerView() ) { diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index bb477be56..c7a47d55f 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -77,15 +77,11 @@ void positionLine::paintEvent( QPaintEvent * _pe ) SongEditor::SongEditor( Song * _song ) : TrackContainerView( _song ), m_song( _song ), + m_zoomingModel(new ComboBoxModel()), m_scrollBack( false ), - m_smoothScroll( ConfigManager::inst()->value( "ui", "smoothscroll" ).toInt() ) + m_smoothScroll( ConfigManager::inst()->value( "ui", "smoothscroll" ).toInt() ), + m_mode(DrawMode) { - setWindowTitle( tr( "Song-Editor" ) ); - setWindowIcon( embed::getIconPixmap( "songeditor" ) ); - - setFocusPolicy( Qt::StrongFocus ); - setFocus(); - // create time-line int widgetTotal = ConfigManager::inst()->value( "ui", "compacttrackbuttons" ).toInt()==1 ? @@ -103,6 +99,8 @@ SongEditor::SongEditor( Song * _song ) : m_positionLine = new positionLine( this ); + static_cast( layout() )->insertWidget( 1, m_timeLine ); + // let's get notified when loading a project connect( m_song, SIGNAL( projectLoaded() ), @@ -229,154 +227,7 @@ SongEditor::SongEditor( Song * _song ) : Engine::mainWindow()->addWidgetToToolBar( vc_w ); - - // create own toolbar - m_toolBar = new QWidget( this ); - m_toolBar->setFixedHeight( 32 ); - m_toolBar->setAutoFillBackground( true ); - QPalette pal; - pal.setBrush( m_toolBar->backgroundRole(), - embed::getIconPixmap( "toolbar_bg" ) ); - m_toolBar->setPalette( pal ); - - static_cast( layout() )->insertWidget( 0, m_toolBar ); - static_cast( layout() )->insertWidget( 1, m_timeLine ); - - QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar ); - tb_layout->setMargin( 0 ); - tb_layout->setSpacing( 0 ); - - - // fill own tool-bar - m_playButton = new ToolButton( embed::getIconPixmap( "play" ), - tr( "Play song (Space)" ), - this, SLOT( play() ), m_toolBar ); - m_playButton->setObjectName( "playButton" ); - - m_recordButton = new ToolButton( embed::getIconPixmap( "record" ), - tr( "Record samples from Audio-device" ), - this, SLOT( record() ), m_toolBar ); - m_recordButton->setObjectName( "recordButton" ); - - m_recordAccompanyButton = new ToolButton( - embed::getIconPixmap( "record_accompany" ), - tr( "Record samples from Audio-device while playing " - "song or BB track" ), - this, SLOT( recordAccompany() ), m_toolBar ); - m_recordAccompanyButton->setObjectName( "recordAccompanyButton" ); - - // FIXME: disable record button while it is not implemented - m_recordButton->setDisabled( true ); - - // disable record buttons if capturing is not supported - if( !Engine::mixer()->audioDev()->supportsCapture() ) - { - m_recordButton->setDisabled( true ); - m_recordAccompanyButton->setDisabled( true ); - } - - m_stopButton = new ToolButton( embed::getIconPixmap( "stop" ), - tr( "Stop song (Space)" ), - this, SLOT( stop() ), m_toolBar ); - m_stopButton->setObjectName( "stopButton" ); - - m_addBBTrackButton = new ToolButton( embed::getIconPixmap( - "add_bb_track" ), - tr( "Add beat/bassline" ), - m_song, SLOT( addBBTrack() ), - m_toolBar ); - - m_addSampleTrackButton = new ToolButton( embed::getIconPixmap( - "add_sample_track" ), - tr( "Add sample-track" ), - m_song, SLOT( addSampleTrack() ), - m_toolBar ); - - m_addAutomationTrackButton = new ToolButton( embed::getIconPixmap( - "add_automation" ), - tr( "Add automation-track" ), - m_song, SLOT( addAutomationTrack() ), - m_toolBar ); - - m_drawModeButton = new ToolButton( embed::getIconPixmap( - "edit_draw" ), - tr( "Draw mode" ), - NULL, NULL, m_toolBar ); - m_drawModeButton->setCheckable( true ); - m_drawModeButton->setChecked( true ); - - m_editModeButton = new ToolButton( embed::getIconPixmap( - "edit_select" ), - tr( "Edit mode (select and move)" ), - NULL, NULL, m_toolBar ); - m_editModeButton->setCheckable( true ); - - QButtonGroup * tool_button_group = new QButtonGroup( this ); - tool_button_group->addButton( m_drawModeButton ); - tool_button_group->addButton( m_editModeButton ); - tool_button_group->setExclusive( true ); - -#if 0 -#warning TODO - QWhatsThis::add( m_playButton, tr( "Click here, if you want to play " - "your whole song. Playing will " - "be started at the " - "song-position-marker (green). " - "You can also move it while " - "playing." ) ); - QWhatsThis::add( m_stopButton, tr ( "Click here, if you want to stop " - "playing of your song. The " - "song-position-marker will be " - "set to the start of your song." - ) ); -/* QWhatsThis::add( m_insertBarButton, tr( "If you click here, a " - "bar will " - "be inserted at the " - "current bar." ) ); - QWhatsThis::add( m_removeBarButton, tr( "If you click here, the " - "current bar will be " - "removed." ) );*/ -#endif - - - QLabel * zoom_lbl = new QLabel( m_toolBar ); - zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) ); - - // setup zooming-stuff - m_zoomingComboBox = new ComboBox( m_toolBar ); - m_zoomingComboBox->setFixedSize( 80, 22 ); - m_zoomingComboBox->move( 580, 4 ); - for( int i = 0; i < 7; ++i ) - { - m_zoomingComboBox->model()->addItem( - QString::number( 25 << i ) + "%" ); - } - m_zoomingComboBox->model()->setInitValue( - m_zoomingComboBox->model()->findText( "100%" ) ); - connect( m_zoomingComboBox->model(), SIGNAL( dataChanged() ), - this, SLOT( zoomingChanged() ) ); - - - tb_layout->addSpacing( 5 ); - tb_layout->addWidget( m_playButton ); - tb_layout->addWidget( m_recordButton ); - tb_layout->addWidget( m_recordAccompanyButton ); - tb_layout->addWidget( m_stopButton ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( m_addBBTrackButton ); - tb_layout->addWidget( m_addSampleTrackButton ); - tb_layout->addWidget( m_addAutomationTrackButton ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( m_drawModeButton ); - tb_layout->addWidget( m_editModeButton ); - tb_layout->addSpacing( 10 ); - m_timeLine->addToolButtons( m_toolBar ); - tb_layout->addSpacing( 15 ); - tb_layout->addWidget( zoom_lbl ); - tb_layout->addSpacing( 5 ); - tb_layout->addWidget( m_zoomingComboBox ); - tb_layout->addStretch(); - + static_cast( layout() )->insertWidget( 0, m_timeLine ); m_leftRightScroll = new QScrollBar( Qt::Horizontal, this ); m_leftRightScroll->setMinimum( 0 ); @@ -389,12 +240,16 @@ SongEditor::SongEditor( Song * _song ) : connect( m_song, SIGNAL( lengthChanged( int ) ), this, SLOT( updateScrollBar( int ) ) ); - - Engine::mainWindow()->workspace()->addSubWindow( this ); - parentWidget()->setAttribute( Qt::WA_DeleteOnClose, false ); - parentWidget()->resize( 600, 300 ); - parentWidget()->move( 5, 5 ); - parentWidget()->show(); + // Set up zooming model + for( int i = 0; i < 7; ++i ) + { + m_zoomingModel->addItem( + QString::number( 25 << i ) + "%" ); + } + m_zoomingModel->setInitValue( + m_zoomingModel->findText( "100%" ) ); + connect( m_zoomingModel, SIGNAL( dataChanged() ), + this, SLOT( zoomingChanged() ) ); } @@ -426,6 +281,24 @@ void SongEditor::scrolled( int _new_pos ) +void SongEditor::setMode(Mode mode) +{ + m_mode = mode; +} + +void SongEditor::setModeDraw() +{ + setMode(DrawMode); +} + +void SongEditor::setModeEdit() +{ + setMode(EditMode); +} + + + + void SongEditor::setPauseIcon( bool pause ) { if( pause == true ) @@ -549,8 +422,8 @@ void SongEditor::wheelEvent( QWheelEvent * _we ) setPixelsPerTact( (int) pixelsPerTact() / 2 ); } // update combobox with zooming-factor - m_zoomingComboBox->model()->setValue( - m_zoomingComboBox->model()->findText( + m_zoomingModel->setValue( + m_zoomingModel->findText( QString::number( static_cast( pixelsPerTact() * 100 / DEFAULT_PIXELS_PER_TACT ) ) + @@ -759,7 +632,7 @@ void SongEditor::updatePosition( const MidiTime & _t ) void SongEditor::zoomingChanged() { - const QString & zfac = m_zoomingComboBox->model()->currentText(); + const QString & zfac = m_zoomingModel->currentText(); setPixelsPerTact( zfac.left( zfac.length() - 1 ).toInt() * DEFAULT_PIXELS_PER_TACT / 100 ); m_song->m_playPos[Song::Mode_PlaySong].m_timeLine-> @@ -788,5 +661,109 @@ void SongEditor::adjustUiAfterProjectLoad() bool SongEditor::allowRubberband() const { - return( m_editModeButton->isChecked() ); + return m_mode == EditMode; +} + + +SongEditorWindow::SongEditorWindow(Song* song) : + Editor(Engine::mixer()->audioDev()->supportsCapture()), + m_editor(new SongEditor(song)) +{ + setWindowTitle( tr( "Song-Editor" ) ); + setWindowIcon( embed::getIconPixmap( "songeditor" ) ); + + setFocusPolicy( Qt::StrongFocus ); + setFocus(); + + setCentralWidget(m_editor); + + // Set up buttons + m_playButton->setToolTip(tr("Play song (Space)")); + connect(m_playButton, SIGNAL(clicked()), m_editor, SLOT(play())); + + if (m_recordButton && m_recordAccompanyButton) + { + m_recordButton->setToolTip(tr("Record samples from Audio-device")); + connect(m_recordButton, SIGNAL(clicked()), m_editor, SLOT(record())); + + m_recordAccompanyButton->setToolTip(tr( "Record samples from Audio-device while playing song or BB track")); + connect(m_recordAccompanyButton, SIGNAL(clicked()), m_editor, SLOT(recordAccompany())); + } + + m_stopButton->setToolTip(tr( "Stop song (Space)" )); + connect(m_stopButton, SIGNAL(clicked()), m_editor, SLOT(stop())); + + m_addBBTrackButton = new ToolButton( + embed::getIconPixmap("add_bb_track"), + tr("Add beat/bassline"), + m_editor->m_song, SLOT(addBBTrack())); + + m_addSampleTrackButton = new ToolButton( + embed::getIconPixmap("add_sample_track" ), + tr( "Add sample-track"), + m_editor->m_song, SLOT(addSampleTrack())); + + m_addAutomationTrackButton = new ToolButton( + embed::getIconPixmap("add_automation" ), + tr( "Add automation-track"), + m_editor->m_song, SLOT(addAutomationTrack())); + + m_drawModeButton = new ToolButton(embed::getIconPixmap("edit_draw"), + tr("Draw mode"), m_editor, SLOT(setModeDraw())); + m_drawModeButton->setCheckable(true); + m_drawModeButton->setChecked(true); + + m_editModeButton = new ToolButton(embed::getIconPixmap("edit_select"), + tr("Edit mode (select and move)"), + m_editor, SLOT(setModeEdit())); + m_editModeButton->setCheckable(true); + + QButtonGroup * tool_button_group = new QButtonGroup(this); + tool_button_group->addButton(m_drawModeButton); + tool_button_group->addButton(m_editModeButton); + tool_button_group->setExclusive(true); + + m_playButton->setWhatsThis( + tr("Click here, if you want to play your whole song. " + "Playing will be started at the song-position-marker (green). " + "You can also move it while playing.")); + m_stopButton->setWhatsThis( + tr("Click here, if you want to stop playing of your song. " + "The song-position-marker will be set to the start of your song.")); + + + QLabel * zoom_lbl = new QLabel( m_toolBar ); + zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) ); + + // setup zooming-stuff + m_zoomingComboBox = new ComboBox( m_toolBar ); + m_zoomingComboBox->setFixedSize( 80, 22 ); + m_zoomingComboBox->move( 580, 4 ); + m_zoomingComboBox->setModel(m_editor->m_zoomingModel); + + + m_toolBar->addSeparator(); + m_toolBar->addWidget( m_addBBTrackButton ); + m_toolBar->addWidget( m_addSampleTrackButton ); + m_toolBar->addWidget( m_addAutomationTrackButton ); + m_toolBar->addSeparator(); + m_toolBar->addWidget( m_drawModeButton ); + m_toolBar->addWidget( m_editModeButton ); + + QWidget* timeLineButtons = new QWidget(); + timeLineButtons->setFixedHeight(m_toolBar->height()); + timeLineButtons->move(0,0); + QLayout* l = new QHBoxLayout( timeLineButtons ); + l->setSpacing(0); l->setMargin(0); + m_editor->m_timeLine->addToolButtons(timeLineButtons); + + m_toolBar->addSeparator(); + m_toolBar->addWidget( zoom_lbl ); + m_toolBar->addWidget( m_zoomingComboBox ); + + Engine::mainWindow()->workspace()->addSubWindow( this ); + parentWidget()->setAttribute( Qt::WA_DeleteOnClose, false ); + parentWidget()->resize( 600, 300 ); + parentWidget()->move( 5, 5 ); + parentWidget()->show(); } diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index 5a76d56a0..f30d59bbe 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.cpp @@ -310,7 +310,7 @@ void BBTCOView::changeColor() if( isSelected() ) { QVector selected = - Engine::songEditor()->selectedObjects(); + Engine::songEditor()->m_editor->selectedObjects(); for( QVector::iterator it = selected.begin(); it != selected.end(); ++it ) From 86f2c866b6749e5e7eb5c9e8ea110e1c624a77aa Mon Sep 17 00:00:00 2001 From: Lukas W Date: Sun, 7 Dec 2014 18:50:40 +0100 Subject: [PATCH 05/32] Move play, record and stop signals to superclass --- include/Editor.h | 6 ++ include/SongEditor.h | 22 +++----- src/gui/AutomationEditor.cpp | 5 -- src/gui/Editor.cpp | 30 +++++++++- src/gui/SongEditor.cpp | 105 +++++++++++------------------------ 5 files changed, 74 insertions(+), 94 deletions(-) diff --git a/include/Editor.h b/include/Editor.h index ccc4af494..0b4fa96bb 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -41,6 +41,12 @@ class Editor : public QMainWindow public: void setPauseIcon(bool displayPauseIcon=true); +protected slots: + virtual void play(); + virtual void record(); + virtual void recordAccompany(); + virtual void stop(); + signals: protected: diff --git a/include/SongEditor.h b/include/SongEditor.h index b51b22e1c..3fff287a9 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -65,10 +65,7 @@ public: }; SongEditor( Song * _song ); - virtual ~SongEditor(); - - void setPauseIcon( bool pause ); - + ~SongEditor(); public slots: void scrolled( int _new_pos ); @@ -81,11 +78,6 @@ public slots: private slots: void setHighQuality( bool ); - void play(); - void record(); - void recordAccompany(); - void stop(); - void masterVolumeChanged( int _new_val ); void masterVolumePressed(); void masterVolumeMoved( int _new_val ); @@ -114,12 +106,6 @@ private: QScrollBar * m_leftRightScroll; - QWidget * m_toolBar; - - ToolButton * m_playButton; - ToolButton * m_recordButton; - ToolButton * m_recordAccompanyButton; - ToolButton * m_stopButton; LcdSpinBox * m_tempoSpinBox; Timeline * m_timeLine; @@ -152,6 +138,12 @@ public: SongEditor* m_editor; +protected slots: + void play(); + void record(); + void recordAccompany(); + void stop(); + private: ToolButton * m_addBBTrackButton; ToolButton * m_addSampleTrackButton; diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index a80b118d8..491b16eb0 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -2040,11 +2040,6 @@ AutomationEditorWindow::AutomationEditorWindow() : tr( "Click here if you want to stop playing of the " "current pattern." ) ); - // Set up signals) - connect(m_playButton, SIGNAL(clicked()), this, SLOT(play())); - connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop())); - - // Edit mode buttons m_drawButton = new ToolButton(embed::getIconPixmap( "edit_draw" ), diff --git a/src/gui/Editor.cpp b/src/gui/Editor.cpp index e292ced1b..e8b40a091 100644 --- a/src/gui/Editor.cpp +++ b/src/gui/Editor.cpp @@ -39,6 +39,22 @@ void Editor::setPauseIcon(bool displayPauseIcon) m_playButton->setIcon(embed::getIconPixmap("play")); } +void Editor::play() +{ +} + +void Editor::record() +{ +} + +void Editor::recordAccompany() +{ +} + +void Editor::stop() +{ +} + Editor::Editor(bool record) : m_toolBar(new QToolBar(this)), m_playButton(nullptr), @@ -46,6 +62,8 @@ Editor::Editor(bool record) : m_recordAccompanyButton(nullptr), m_stopButton(nullptr) { + m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu); + auto addButton = [this](const char* pixmap_name, QString text, QString objectName) { ToolButton* button = new ToolButton(embed::getIconPixmap(pixmap_name), text); button->setObjectName(objectName); @@ -55,11 +73,12 @@ Editor::Editor(bool record) : // Set up play button m_playButton = addButton("play", tr("Play (Space)"), "playButton"); + m_playButton->setShortcut(Qt::Key_Space); // Set up record buttons if wanted if (record) { - m_recordButton= addButton("record", tr("Record"), "recordButton"); + m_recordButton = addButton("record", tr("Record"), "recordButton"); m_recordAccompanyButton = addButton("record_accompany", tr("Record while playing"), "recordAccompanyButton"); } @@ -68,6 +87,15 @@ Editor::Editor(bool record) : // Add toolbar to window addToolBar(Qt::TopToolBarArea, m_toolBar); + + // Set up connections + connect(m_playButton, SIGNAL(clicked()), this, SLOT(play())); + if (record) + { + connect(m_recordButton, SIGNAL(clicked()), this, SLOT(record())); + connect(m_recordAccompanyButton, SIGNAL(clicked()), this, SLOT(recordAccompany())); + } + connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop())); } Editor::~Editor() diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index c7a47d55f..cf7f9973c 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -299,61 +299,6 @@ void SongEditor::setModeEdit() -void SongEditor::setPauseIcon( bool pause ) -{ - if( pause == true ) - { - m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); - } - else - { - m_playButton->setIcon( embed::getIconPixmap( "play" ) ); - } -} - - - - -void SongEditor::play() -{ - if( Engine::getSong()->playMode() != Song::Mode_PlaySong ) - { - Engine::getSong()->playSong(); - } - else - { - Engine::getSong()->togglePause(); - } -} - - - - -void SongEditor::record() -{ - m_song->record(); -} - - - - -void SongEditor::recordAccompany() -{ - m_song->playAndRecord(); -} - - - - -void SongEditor::stop() -{ - m_song->stop(); - Engine::pianoRoll()->stopRecording(); -} - - - - void SongEditor::keyPressEvent( QKeyEvent * _ke ) { if( /*_ke->modifiers() & Qt::ShiftModifier*/ @@ -384,17 +329,6 @@ void SongEditor::keyPressEvent( QKeyEvent * _ke ) m_song->setPlayPos( t, Song::Mode_PlaySong ); } } - else if( _ke->key() == Qt::Key_Space ) - { - if( m_song->isPlaying() ) - { - stop(); - } - else - { - play(); - } - } else if( _ke->key() == Qt::Key_Home ) { m_song->setPlayPos( 0, Song::Mode_PlaySong ); @@ -679,19 +613,12 @@ SongEditorWindow::SongEditorWindow(Song* song) : // Set up buttons m_playButton->setToolTip(tr("Play song (Space)")); - connect(m_playButton, SIGNAL(clicked()), m_editor, SLOT(play())); - if (m_recordButton && m_recordAccompanyButton) { m_recordButton->setToolTip(tr("Record samples from Audio-device")); - connect(m_recordButton, SIGNAL(clicked()), m_editor, SLOT(record())); - m_recordAccompanyButton->setToolTip(tr( "Record samples from Audio-device while playing song or BB track")); - connect(m_recordAccompanyButton, SIGNAL(clicked()), m_editor, SLOT(recordAccompany())); } - m_stopButton->setToolTip(tr( "Stop song (Space)" )); - connect(m_stopButton, SIGNAL(clicked()), m_editor, SLOT(stop())); m_addBBTrackButton = new ToolButton( embed::getIconPixmap("add_bb_track"), @@ -767,3 +694,35 @@ SongEditorWindow::SongEditorWindow(Song* song) : parentWidget()->move( 5, 5 ); parentWidget()->show(); } + + +void SongEditorWindow::play() +{ + if( Engine::getSong()->playMode() != Song::Mode_PlaySong ) + { + Engine::getSong()->playSong(); + } + else + { + Engine::getSong()->togglePause(); + } +} + + +void SongEditorWindow::record() +{ + m_editor->m_song->record(); +} + + +void SongEditorWindow::recordAccompany() +{ + m_editor->m_song->playAndRecord(); +} + + +void SongEditorWindow::stop() +{ + m_editor->m_song->stop(); + Engine::pianoRoll()->stopRecording(); +} From d8db8948a80513106572a87d5d7437c6fa7d9355 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 14:47:58 +0100 Subject: [PATCH 06/32] Editor: Don't delete on close --- include/AutomationEditor.h | 2 -- src/core/AutomationPattern.cpp | 1 + src/gui/AutomationEditor.cpp | 16 ---------------- src/gui/Editor.cpp | 7 +++++++ src/gui/SongEditor.cpp | 2 -- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 856b6177e..8105e63c6 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -267,8 +267,6 @@ public: AutomationEditor* m_editor; - virtual void closeEvent( QCloseEvent * _ce ); - signals: void currentPatternChanged(); diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 9164e733d..76b185d42 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -690,6 +690,7 @@ void AutomationPattern::openInAutomationEditor() { Engine::automationEditor()->setCurrentPattern( this ); Engine::automationEditor()->parentWidget()->show(); + Engine::automationEditor()->show(); Engine::automationEditor()->setFocus(); } diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index 491b16eb0..132ad1b11 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -2290,9 +2290,7 @@ AutomationEditorWindow::AutomationEditorWindow() : // Add us to workspace if( Engine::mainWindow()->workspace() ) { - Engine::mainWindow()->workspace()->addSubWindow( this ); parentWidget()->resize( INITIAL_WIDTH, INITIAL_HEIGHT ); - parentWidget()->move( 5, 5 ); parentWidget()->hide(); } else @@ -2343,20 +2341,6 @@ int AutomationEditorWindow::quantization() const return m_editor->quantization(); } -void AutomationEditorWindow::closeEvent(QCloseEvent* _ce) -{ - QApplication::restoreOverrideCursor(); - if( parentWidget() ) - { - parentWidget()->hide(); - } - else - { - hide(); - } - _ce->ignore(); -} - void AutomationEditorWindow::play() { m_editor->play(); diff --git a/src/gui/Editor.cpp b/src/gui/Editor.cpp index e8b40a091..57042b623 100644 --- a/src/gui/Editor.cpp +++ b/src/gui/Editor.cpp @@ -24,8 +24,10 @@ #include "Editor.h" +#include "MainWindow.h" #include "embed.h" +#include #include #include @@ -96,6 +98,11 @@ Editor::Editor(bool record) : connect(m_recordAccompanyButton, SIGNAL(clicked()), this, SLOT(recordAccompany())); } connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop())); + + + // Add editor to main window + Engine::mainWindow()->workspace()->addSubWindow(this); + parentWidget()->setAttribute(Qt::WA_DeleteOnClose, false); } Editor::~Editor() diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index cf7f9973c..ee020cb07 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -688,8 +688,6 @@ SongEditorWindow::SongEditorWindow(Song* song) : m_toolBar->addWidget( zoom_lbl ); m_toolBar->addWidget( m_zoomingComboBox ); - Engine::mainWindow()->workspace()->addSubWindow( this ); - parentWidget()->setAttribute( Qt::WA_DeleteOnClose, false ); parentWidget()->resize( 600, 300 ); parentWidget()->move( 5, 5 ); parentWidget()->show(); From ec9158cda9f85a97b4830a1520aec6fc4d0ff0f9 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 16:48:10 +0100 Subject: [PATCH 07/32] PianoRoll: Use Editor superclass --- include/Engine.h | 6 +- include/PianoRoll.h | 95 +++--- src/core/Engine.cpp | 4 +- src/gui/PianoRoll.cpp | 719 ++++++++++++++++++++--------------------- src/gui/SongEditor.cpp | 6 +- src/tracks/Pattern.cpp | 1 + 6 files changed, 416 insertions(+), 415 deletions(-) diff --git a/include/Engine.h b/include/Engine.h index fb5ad0b5f..509e668af 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -42,7 +42,7 @@ class FxMixerView; class ProjectJournal; class MainWindow; class Mixer; -class PianoRoll; +class PianoRollWindow; class ProjectNotes; class Song; class SongEditorWindow; @@ -118,7 +118,7 @@ public: return s_bbEditor; } - static PianoRoll* pianoRoll() + static PianoRollWindow* pianoRoll() { return s_pianoRoll; } @@ -190,7 +190,7 @@ private: static SongEditorWindow* s_songEditor; static AutomationEditorWindow * s_automationEditor; static BBEditor * s_bbEditor; - static PianoRoll* s_pianoRoll; + static PianoRollWindow* s_pianoRoll; static ProjectNotes * s_projectNotes; static Ladspa2LMMS * s_ladspaManager; diff --git a/include/PianoRoll.h b/include/PianoRoll.h index bd27bda2e..1d7cd1146 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -30,6 +30,7 @@ #include #include +#include "Editor.h" #include "ComboBoxModel.h" #include "SerializingObject.h" #include "Note.h" @@ -50,7 +51,7 @@ class Pattern; class Timeline; class ToolButton; -class PianoRoll : public QWidget, public SerializingObject +class PianoRoll : public QWidget { Q_OBJECT Q_PROPERTY( QColor gridColor READ gridColor WRITE setGridColor ) @@ -86,17 +87,6 @@ public: Song::PlayModes desiredPlayModeForAccompany() const; int quantization() const; - - - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - - inline virtual QString nodeName() const - { - return "pianoroll"; - } - - void setPauseIcon( bool pause ); // qproperty acces functions QColor gridColor() const; @@ -109,7 +99,6 @@ public: void setBarColor( const QColor & _c ); protected: - virtual void closeEvent( QCloseEvent * _ce ); virtual void keyPressEvent( QKeyEvent * _ke ); virtual void keyReleaseEvent( QKeyEvent * _ke ); virtual void leaveEvent( QEvent * _e ); @@ -264,28 +253,6 @@ private: static TextFloat * s_textFloat; - QWidget * m_toolBar; - - ToolButton * m_playButton; - ToolButton * m_recordButton; - ToolButton * m_recordAccompanyButton; - ToolButton * m_stopButton; - - ToolButton * m_drawButton; - ToolButton * m_eraseButton; - ToolButton * m_selectButton; - ToolButton * m_detuneButton; - - ToolButton * m_cutButton; - ToolButton * m_copyButton; - ToolButton * m_pasteButton; - - ComboBox * m_zoomingComboBox; - ComboBox * m_quantizeComboBox; - ComboBox * m_noteLenComboBox; - ComboBox * m_scaleComboBox; - ComboBox * m_chordComboBox; - ComboBoxModel m_zoomingModel; ComboBoxModel m_quantizeModel; ComboBoxModel m_noteLenModel; @@ -293,7 +260,6 @@ private: ComboBoxModel m_chordModel; - Pattern* m_pattern; QScrollBar * m_leftRightScroll; QScrollBar * m_topBottomScroll; @@ -367,6 +333,7 @@ private: bool m_startedWithShift; friend class Engine; + friend class PianoRollWindow; // qproperty fields QColor m_gridColor; @@ -380,5 +347,61 @@ signals: } ; +class PianoRollWindow : public Editor, SerializingObject +{ + Q_OBJECT +public: + PianoRollWindow(); + + const Pattern* currentPattern() const; + void setCurrentPattern(Pattern* pattern); + + int quantization() const; + + void play(); + void stop(); + void record(); + void recordAccompany(); + void stopRecording(); + + bool isRecording() const; + + /*! \brief Resets settings to default when e.g. creating a new project */ + void reset(); + + using SerializingObject::saveState; + using SerializingObject::restoreState; + virtual void saveSettings(QDomDocument & doc, QDomElement & de ); + virtual void loadSettings( const QDomElement & de ); + + inline virtual QString nodeName() const + { + return "pianoroll"; + } + +signals: + void currentPatternChanged(); + +private: + PianoRoll* m_editor; + + ToolButton * m_drawButton; + ToolButton * m_eraseButton; + ToolButton * m_selectButton; + ToolButton * m_detuneButton; + + ToolButton * m_cutButton; + ToolButton * m_copyButton; + ToolButton * m_pasteButton; + + ComboBox * m_zoomingComboBox; + ComboBox * m_quantizeComboBox; + ComboBox * m_noteLenComboBox; + ComboBox * m_scaleComboBox; + ComboBox * m_chordComboBox; + +}; + + #endif diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index a9d4a65a9..e2ce7ded9 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -58,7 +58,7 @@ Song * Engine::s_song = NULL; SongEditorWindow* Engine::s_songEditor = NULL; AutomationEditorWindow * Engine::s_automationEditor = NULL; BBEditor * Engine::s_bbEditor = NULL; -PianoRoll* Engine::s_pianoRoll = NULL; +PianoRollWindow* Engine::s_pianoRoll = NULL; ProjectNotes * Engine::s_projectNotes = NULL; ProjectJournal * Engine::s_projectJournal = NULL; Ladspa2LMMS * Engine::s_ladspaManager = NULL; @@ -98,7 +98,7 @@ void Engine::init( const bool _has_gui ) s_controllerRackView = new ControllerRackView; s_projectNotes = new ProjectNotes; s_bbEditor = new BBEditor( s_bbTrackContainer ); - s_pianoRoll = new PianoRoll; + s_pianoRoll = new PianoRollWindow(); s_automationEditor = new AutomationEditorWindow; s_mainWindow->finalize(); diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index 56bc5b6a0..6b2d5da03 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -95,7 +95,7 @@ const int NOTE_EDIT_RESIZE_BAR = 6; const int NOTE_EDIT_MIN_HEIGHT = 50; const int KEY_AREA_MIN_HEIGHT = 100; const int PR_BOTTOM_MARGIN = SCROLLBAR_SIZE; -const int PR_TOP_MARGIN = 48; +const int PR_TOP_MARGIN = 16; const int PR_RIGHT_MARGIN = SCROLLBAR_SIZE; @@ -291,7 +291,7 @@ PianoRoll::PianoRoll() : setAttribute( Qt::WA_OpaquePaintEvent, true ); // add time-line - m_timeLine = new Timeline( WHITE_KEY_WIDTH, 32, m_ppt, + m_timeLine = new Timeline( WHITE_KEY_WIDTH, 0, m_ppt, Engine::getSong()->getPlayPos( Song::Mode_PlayPattern ), m_currentPosition, this ); @@ -311,64 +311,6 @@ PianoRoll::PianoRoll() : this, SLOT( updatePositionAccompany( const MidiTime & ) ) );*/ - - m_toolBar = new QWidget( this ); - m_toolBar->setFixedHeight( 32 ); - m_toolBar->move( 0, 0 ); - m_toolBar->setAutoFillBackground( true ); - QPalette pal; - pal.setBrush( m_toolBar->backgroundRole(), - embed::getIconPixmap( "toolbar_bg" ) ); - m_toolBar->setPalette( pal ); - - QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar ); - tb_layout->setMargin( 0 ); - tb_layout->setSpacing( 0 ); - - - // init control-buttons at the top - - m_playButton = new ToolButton( embed::getIconPixmap( "play" ), - tr( "Play/pause current pattern (Space)" ), - this, SLOT( play() ), m_toolBar ); - - m_recordButton = new ToolButton( embed::getIconPixmap( "record" ), - tr( "Record notes from MIDI-device/channel-piano" ), - this, SLOT( record() ), m_toolBar ); - m_recordAccompanyButton = new ToolButton( - embed::getIconPixmap( "record_accompany" ), - tr( "Record notes from MIDI-device/channel-piano while playing song or BB track" ), - this, SLOT( recordAccompany() ), m_toolBar ); - - m_stopButton = new ToolButton( embed::getIconPixmap( "stop" ), - tr( "Stop playing of current pattern (Space)" ), - this, SLOT( stop() ), m_toolBar ); - - m_playButton->setObjectName( "playButton" ); - m_stopButton->setObjectName( "stopButton" ); - m_recordButton->setObjectName( "recordButton" ); - m_recordAccompanyButton->setObjectName( "recordAccompanyButton" ); - - m_playButton->setWhatsThis( - tr( "Click here to play the current pattern. " - "This is useful while editing it. The pattern is " - "automatically looped when its end is reached." ) ); - m_recordButton->setWhatsThis( - tr( "Click here to record notes from a MIDI-" - "device or the virtual test-piano of the according " - "channel-window to the current pattern. When recording " - "all notes you play will be written to this pattern " - "and you can play and edit them afterwards." ) ); - m_recordAccompanyButton->setWhatsThis( - tr( "Click here to record notes from a MIDI-" - "device or the virtual test-piano of the according " - "channel-window to the current pattern. When recording " - "all notes you play will be written to this pattern " - "and you will hear the song or BB track in the background." ) ); - m_stopButton->setWhatsThis( - tr( "Click here to stop playback of current pattern." ) ); - - removeSelection(); // init scrollbars @@ -383,94 +325,6 @@ PianoRoll::PianoRoll() : connect( m_topBottomScroll, SIGNAL( valueChanged( int ) ), this, SLOT( verScrolled( int ) ) ); - // init edit-buttons at the top - m_drawButton = new ToolButton( embed::getIconPixmap( "edit_draw" ), - tr( "Draw mode (Shift+D)" ), - this, SLOT( drawButtonToggled() ), - m_toolBar ); - m_drawButton->setCheckable( true ); - m_drawButton->setChecked( true ); - - m_eraseButton = new ToolButton( embed::getIconPixmap( "edit_erase" ), - tr( "Erase mode (Shift+E)" ), - this, SLOT( eraseButtonToggled() ), - m_toolBar ); - m_eraseButton->setCheckable( true ); - - m_selectButton = new ToolButton( embed::getIconPixmap( - "edit_select" ), - tr( "Select mode (Shift+S)" ), - this, SLOT( selectButtonToggled() ), - m_toolBar ); - m_selectButton->setCheckable( true ); - - m_detuneButton = new ToolButton( embed::getIconPixmap( "automation"), - tr( "Detune mode (Shift+T)" ), - this, SLOT( detuneButtonToggled() ), - m_toolBar ); - m_detuneButton->setCheckable( true ); - - QButtonGroup * tool_button_group = new QButtonGroup( this ); - tool_button_group->addButton( m_drawButton ); - tool_button_group->addButton( m_eraseButton ); - tool_button_group->addButton( m_selectButton ); - tool_button_group->addButton( m_detuneButton ); - tool_button_group->setExclusive( true ); - - m_drawButton->setWhatsThis( - tr( "Click here and draw mode will be activated. In this " - "mode you can add, resize and move notes. This " - "is the default mode which is used most of the time. " - "You can also press 'Shift+D' on your keyboard to " - "activate this mode. In this mode, hold Ctrl to " - "temporarily go into select mode." ) ); - m_eraseButton->setWhatsThis( - tr( "Click here and erase mode will be activated. In this " - "mode you can erase notes. You can also press " - "'Shift+E' on your keyboard to activate this mode." ) ); - m_selectButton->setWhatsThis( - tr( "Click here and select mode will be activated. " - "In this mode you can select notes. Alternatively, " - "you can hold Ctrl in draw mode to temporarily use " - "select mode." ) ); - m_detuneButton->setWhatsThis( - tr( "Click here and detune mode will be activated. " - "In this mode you can click a note to open its " - "automation detuning. You can utilize this to slide " - "notes from one to another. You can also press " - "'Shift+T' on your keyboard to activate this mode." ) ); - - m_cutButton = new ToolButton( embed::getIconPixmap( "edit_cut" ), - tr( "Cut selected notes (Ctrl+X)" ), - this, SLOT( cutSelectedNotes() ), - m_toolBar ); - - m_copyButton = new ToolButton( embed::getIconPixmap( "edit_copy" ), - tr( "Copy selected notes (Ctrl+C)" ), - this, SLOT( copySelectedNotes() ), - m_toolBar ); - - m_pasteButton = new ToolButton( embed::getIconPixmap( "edit_paste" ), - tr( "Paste notes from clipboard " - "(Ctrl+V)" ), - this, SLOT( pasteNotes() ), - m_toolBar ); - - m_cutButton->setWhatsThis( - tr( "Click here and the selected notes will be cut into the " - "clipboard. You can paste them anywhere in any pattern " - "by clicking on the paste button." ) ); - m_copyButton->setWhatsThis( - tr( "Click here and the selected notes will be copied into the " - "clipboard. You can paste them anywhere in any pattern " - "by clicking on the paste button." ) ); - m_pasteButton->setWhatsThis( - tr( "Click here and the notes from the clipboard will be " - "pasted at the first visible measure." ) ); - - QLabel * zoom_lbl = new QLabel( m_toolBar ); - zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) ); - // setup zooming-stuff for( int i = 0; i < 6; ++i ) { @@ -479,14 +333,8 @@ PianoRoll::PianoRoll() : m_zoomingModel.setValue( m_zoomingModel.findText( "100%" ) ); connect( &m_zoomingModel, SIGNAL( dataChanged() ), this, SLOT( zoomingChanged() ) ); - m_zoomingComboBox = new ComboBox( m_toolBar ); - m_zoomingComboBox->setModel( &m_zoomingModel ); - m_zoomingComboBox->setFixedSize( 64, 22 ); - - // setup quantize-stuff - QLabel * quantize_lbl = new QLabel( m_toolBar ); - quantize_lbl->setPixmap( embed::getIconPixmap( "quantize" ) ); + // Set up quantization model m_quantizeModel.addItem( tr( "Note lock" ) ); for( int i = 0; i <= NUM_EVEN_LENGTHS; ++i ) { @@ -498,17 +346,11 @@ PianoRoll::PianoRoll() : } m_quantizeModel.addItem( "1/192" ); m_quantizeModel.setValue( m_quantizeModel.findText( "1/16" ) ); - m_quantizeComboBox = new ComboBox( m_toolBar ); - m_quantizeComboBox->setModel( &m_quantizeModel ); - m_quantizeComboBox->setFixedSize( 64, 22 ); + connect( &m_quantizeModel, SIGNAL( dataChanged() ), this, SLOT( quantizeChanged() ) ); - - // setup note-len-stuff - QLabel * note_len_lbl = new QLabel( m_toolBar ); - note_len_lbl->setPixmap( embed::getIconPixmap( "note" ) ); - + // Set up note length model m_noteLenModel.addItem( tr( "Last note" ), new PixmapLoader( "edit_draw" ) ); const QString pixmaps[] = { "whole", "half", "quarter", "eighth", @@ -527,20 +369,15 @@ PianoRoll::PianoRoll() : new PixmapLoader( "note_" + pixmaps[i+NUM_EVEN_LENGTHS] ) ); } m_noteLenModel.setValue( 0 ); - m_noteLenComboBox = new ComboBox( m_toolBar ); - m_noteLenComboBox->setModel( &m_noteLenModel ); - m_noteLenComboBox->setFixedSize( 105, 22 ); + // Note length change can cause a redraw if Q is set to lock connect( &m_noteLenModel, SIGNAL( dataChanged() ), this, SLOT( quantizeChanged() ) ); + // Set up scale model const InstrumentFunctionNoteStacking::ChordTable & chord_table = InstrumentFunctionNoteStacking::ChordTable::getInstance(); - // setup scale-stuff - QLabel * scale_lbl = new QLabel( m_toolBar ); - scale_lbl->setPixmap( embed::getIconPixmap( "scale" ) ); - m_scaleModel.addItem( tr("No scale") ); for( int i = 0; i < chord_table.size(); ++i ) { @@ -551,18 +388,11 @@ PianoRoll::PianoRoll() : } m_scaleModel.setValue( 0 ); - m_scaleComboBox = new ComboBox( m_toolBar ); - m_scaleComboBox->setModel( &m_scaleModel ); - m_scaleComboBox->setFixedSize( 105, 22 ); // change can update m_semiToneMarkerMenu connect( &m_scaleModel, SIGNAL( dataChanged() ), - this, SLOT( updateSemiToneMarkerMenu() ) ); - - - // setup chord-stuff - QLabel * chord_lbl = new QLabel( m_toolBar ); - chord_lbl->setPixmap( embed::getIconPixmap( "chord" ) ); + this, SLOT( updateSemiToneMarkerMenu() ) ); + // Set up chord model m_chordModel.addItem( tr("No chord") ); for( int i = 0; i < chord_table.size(); ++i ) { @@ -573,126 +403,17 @@ PianoRoll::PianoRoll() : } m_chordModel.setValue( 0 ); - m_chordComboBox = new ComboBox( m_toolBar ); - m_chordComboBox->setModel( &m_chordModel ); - m_chordComboBox->setFixedSize( 105, 22 ); + // change can update m_semiToneMarkerMenu connect( &m_chordModel, SIGNAL( dataChanged() ), this, SLOT( updateSemiToneMarkerMenu() ) ); - - tb_layout->addSpacing( 4 ); - tb_layout->addWidget( m_playButton ); - tb_layout->addWidget( m_recordButton ); - tb_layout->addWidget( m_recordAccompanyButton ); - tb_layout->addWidget( m_stopButton ); - tb_layout->addSpacing( 7 ); - tb_layout->addWidget( m_drawButton ); - tb_layout->addWidget( m_eraseButton ); - tb_layout->addWidget( m_selectButton ); - tb_layout->addWidget( m_detuneButton ); - tb_layout->addSpacing( 7 ); - tb_layout->addWidget( m_cutButton ); - tb_layout->addWidget( m_copyButton ); - tb_layout->addWidget( m_pasteButton ); - tb_layout->addSpacing( 7 ); - m_timeLine->addToolButtons( m_toolBar ); - tb_layout->addSpacing( 7 ); - tb_layout->addWidget( zoom_lbl ); - tb_layout->addSpacing( 4 ); - tb_layout->addWidget( m_zoomingComboBox ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( quantize_lbl ); - tb_layout->addSpacing( 4 ); - tb_layout->addWidget( m_quantizeComboBox ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( note_len_lbl ); - tb_layout->addSpacing( 4 ); - tb_layout->addWidget( m_noteLenComboBox ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( scale_lbl ); - tb_layout->addSpacing( 4 ); - tb_layout->addWidget( m_scaleComboBox ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( chord_lbl ); - tb_layout->addSpacing( 4 ); - tb_layout->addWidget( m_chordComboBox ); - tb_layout->addStretch(); - - m_zoomingComboBox->setWhatsThis( - tr( - "This controls the magnification of an axis. " - "It can be helpful to choose magnification for a specific " - "task. For ordinary editing, the magnification should be " - "fitted to your smallest notes. " - ) ); - - m_quantizeComboBox->setWhatsThis( - tr( - "The 'Q' stands for quantization, and controls the grid size " - "notes and control points snap to. " - "With smaller quantization values, you can draw shorter notes " - "in Piano Roll, and more exact control points in the " - "Automation Editor." - - ) ); - - m_noteLenComboBox->setWhatsThis( - tr( - "This lets you select the length of new notes. " - "'Last Note' means that LMMS will use the note length of " - "the note you last edited" - ) ); - - m_scaleComboBox->setWhatsThis( - tr( - "The feature is directly connected to the context-menu " - "on the virtual keyboard, to the left in Piano Roll. " - "After you have chosen the scale you want " - "in this drop-down menu, " - "you can right click on a desired key in the virtual keyboard, " - "and then choose 'Mark current Scale'. " - "LMMS will highlight all notes that belongs to the chosen scale, " - "and in the key you have selected!" - ) ); - - - m_chordComboBox->setWhatsThis( - tr( - "Let you select a chord which LMMS then can draw or highlight." - "You can find the most common chords in this drop-down menu. " - "After you have selected a chord, click anywhere to place the chord, and right " - "click on the virtual keyboard to open context menu and highlight the chord. " - "To return to single note placement, you need to choose 'No chord' " - "in this drop-down menu." - ) ); - - // setup our actual window setFocusPolicy( Qt::StrongFocus ); setFocus(); - setWindowIcon( embed::getIconPixmap( "piano" ) ); - setCurrentPattern( NULL ); - setMouseTracking( true ); - setMinimumSize( tb_layout->minimumSize().width(), 160 ); - - // add us to workspace - if( Engine::mainWindow()->workspace() ) - { - Engine::mainWindow()->workspace()->addSubWindow( this ); - parentWidget()->setMinimumSize( tb_layout->minimumSize().width()+10, 200 ); - parentWidget()->resize( tb_layout->minimumSize().width()+10, - INITIAL_PIANOROLL_HEIGHT ); - parentWidget()->move( 5, 5 ); - - parentWidget()->hide(); - } - else - { - resize( tb_layout->minimumSize().width(), INITIAL_PIANOROLL_HEIGHT ); - hide(); - } + connect( &m_scaleModel, SIGNAL( dataChanged() ), + this, SLOT( updateSemiToneMarkerMenu() ) ); connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ), this, SLOT( update() ) ); @@ -873,34 +594,6 @@ void PianoRoll::hidePattern( Pattern* pattern ) -void PianoRoll::saveSettings( QDomDocument & _doc, QDomElement & _this ) -{ - MainWindow::saveWidgetState( this, _this ); -} - - - - -void PianoRoll::loadSettings( const QDomElement & _this ) -{ - MainWindow::restoreWidgetState( this, _this ); -} - - - - -void PianoRoll::setPauseIcon( bool pause ) -{ - if( pause == true ) - { - m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); - } - else - { - m_playButton->setIcon( embed::getIconPixmap( "play" ) ); - } -} - /** \brief qproperty access implementation */ @@ -1100,23 +793,6 @@ void PianoRoll::clearSelectedNotes() -void PianoRoll::closeEvent( QCloseEvent * _ce ) -{ - QApplication::restoreOverrideCursor(); - if( parentWidget() ) - { - parentWidget()->hide(); - } - else - { - hide(); - } - _ce->ignore(); -} - - - - void PianoRoll::shiftSemiTone( int amount ) // shift notes by amount semitones { bool useAllNotes = ! isSelection(); @@ -1390,38 +1066,6 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) } break; - case Qt::Key_D: - if( event->modifiers() & Qt::ShiftModifier ) - { - event->accept(); - m_drawButton->setChecked( true ); - } - break; - - case Qt::Key_E: - if( event->modifiers() & Qt::ShiftModifier ) - { - event->accept(); - m_eraseButton->setChecked( true ); - } - break; - - case Qt::Key_S: - if( event->modifiers() & Qt::ShiftModifier ) - { - event->accept(); - m_selectButton->setChecked( true ); - } - break; - - case Qt::Key_T: - if( event->modifiers() & Qt::ShiftModifier ) - { - event->accept(); - m_detuneButton->setChecked( true ); - } - break; - case Qt::Key_Delete: deleteSelectedNotes(); event->accept(); @@ -3484,7 +3128,7 @@ void PianoRoll::resizeEvent( QResizeEvent * ) Engine::getSong()->getPlayPos( Song::Mode_PlayPattern ).m_timeLine->setFixedWidth( width() ); - m_toolBar->setFixedWidth( width() ); + update(); } @@ -4085,8 +3729,6 @@ void PianoRoll::pasteNotes() // we only have to do the following lines if we pasted at // least one note... Engine::getSong()->setModified(); - m_ctrlMode = ModeDraw; - m_drawButton->setChecked( true ); update(); Engine::songEditor()->update(); } @@ -4328,3 +3970,338 @@ Note * PianoRoll::noteUnderMouse() + + +PianoRollWindow::PianoRollWindow() : + Editor(true), + m_editor(new PianoRoll()) +{ + setCentralWidget(m_editor); + + m_playButton->setToolTip(tr("Play/pause current pattern (Space)")); + m_recordButton->setToolTip(tr("Record notes from MIDI-device/channel-piano")); + m_recordAccompanyButton->setToolTip(tr("Record notes from MIDI-device/channel-piano while playing song or BB track")); + m_stopButton->setToolTip(tr("Stop playing of current pattern (Space)")); + + m_playButton->setWhatsThis( + tr( "Click here to play the current pattern. " + "This is useful while editing it. The pattern is " + "automatically looped when its end is reached." ) ); + m_recordButton->setWhatsThis( + tr( "Click here to record notes from a MIDI-" + "device or the virtual test-piano of the according " + "channel-window to the current pattern. When recording " + "all notes you play will be written to this pattern " + "and you can play and edit them afterwards." ) ); + m_recordAccompanyButton->setWhatsThis( + tr( "Click here to record notes from a MIDI-" + "device or the virtual test-piano of the according " + "channel-window to the current pattern. When recording " + "all notes you play will be written to this pattern " + "and you will hear the song or BB track in the background." ) ); + m_stopButton->setWhatsThis( + tr( "Click here to stop playback of current pattern." ) ); + + // init edit-buttons at the top + m_drawButton = new ToolButton( embed::getIconPixmap( "edit_draw" ), + tr( "Draw mode (Shift+D)" ), + m_editor, SLOT( drawButtonToggled() ), + m_toolBar ); + m_drawButton->setShortcut(Qt::SHIFT | Qt::Key_D); + m_drawButton->setCheckable( true ); + m_drawButton->setChecked( true ); + + m_eraseButton = new ToolButton( embed::getIconPixmap( "edit_erase" ), + tr( "Erase mode (Shift+E)" ), + m_editor, SLOT( eraseButtonToggled() ), + m_toolBar ); + m_eraseButton->setShortcut(Qt::SHIFT | Qt::Key_E); + m_eraseButton->setCheckable( true ); + + m_selectButton = new ToolButton( embed::getIconPixmap( + "edit_select" ), + tr( "Select mode (Shift+S)" ), + m_editor, SLOT( selectButtonToggled() ), + m_toolBar ); + m_selectButton->setShortcut(Qt::SHIFT | Qt::Key_S); + m_selectButton->setCheckable( true ); + + m_detuneButton = new ToolButton( embed::getIconPixmap( "automation"), + tr( "Detune mode (Shift+T)" ), + m_editor, SLOT( detuneButtonToggled() ), + m_toolBar ); + m_detuneButton->setShortcut(Qt::SHIFT | Qt::Key_T); + m_detuneButton->setCheckable( true ); + + QButtonGroup * tool_button_group = new QButtonGroup( this ); + tool_button_group->addButton( m_drawButton ); + tool_button_group->addButton( m_eraseButton ); + tool_button_group->addButton( m_selectButton ); + tool_button_group->addButton( m_detuneButton ); + tool_button_group->setExclusive( true ); + + m_drawButton->setWhatsThis( + tr( "Click here and draw mode will be activated. In this " + "mode you can add, resize and move notes. This " + "is the default mode which is used most of the time. " + "You can also press 'Shift+D' on your keyboard to " + "activate this mode. In this mode, hold Ctrl to " + "temporarily go into select mode." ) ); + m_eraseButton->setWhatsThis( + tr( "Click here and erase mode will be activated. In this " + "mode you can erase notes. You can also press " + "'Shift+E' on your keyboard to activate this mode." ) ); + m_selectButton->setWhatsThis( + tr( "Click here and select mode will be activated. " + "In this mode you can select notes. Alternatively, " + "you can hold Ctrl in draw mode to temporarily use " + "select mode." ) ); + m_detuneButton->setWhatsThis( + tr( "Click here and detune mode will be activated. " + "In this mode you can click a note to open its " + "automation detuning. You can utilize this to slide " + "notes from one to another. You can also press " + "'Shift+T' on your keyboard to activate this mode." ) ); + + m_cutButton = new ToolButton( embed::getIconPixmap( "edit_cut" ), + tr( "Cut selected notes (Ctrl+X)" ), + m_editor, SLOT( cutSelectedNotes() ), + m_toolBar ); + + m_copyButton = new ToolButton( embed::getIconPixmap( "edit_copy" ), + tr( "Copy selected notes (Ctrl+C)" ), + m_editor, SLOT( copySelectedNotes() ), + m_toolBar ); + + m_pasteButton = new ToolButton( embed::getIconPixmap( "edit_paste" ), + tr( "Paste notes from clipboard " + "(Ctrl+V)" ), + m_editor, SLOT( pasteNotes() ), + m_toolBar ); + + m_cutButton->setWhatsThis( + tr( "Click here and the selected notes will be cut into the " + "clipboard. You can paste them anywhere in any pattern " + "by clicking on the paste button." ) ); + m_copyButton->setWhatsThis( + tr( "Click here and the selected notes will be copied into the " + "clipboard. You can paste them anywhere in any pattern " + "by clicking on the paste button." ) ); + m_pasteButton->setWhatsThis( + tr( "Click here and the notes from the clipboard will be " + "pasted at the first visible measure." ) ); + + QLabel * zoom_lbl = new QLabel( m_toolBar ); + zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) ); + + m_zoomingComboBox = new ComboBox( m_toolBar ); + m_zoomingComboBox->setModel( &m_editor->m_zoomingModel ); + m_zoomingComboBox->setFixedSize( 64, 22 ); + + // setup quantize-stuff + QLabel * quantize_lbl = new QLabel( m_toolBar ); + quantize_lbl->setPixmap( embed::getIconPixmap( "quantize" ) ); + + m_quantizeComboBox = new ComboBox( m_toolBar ); + m_quantizeComboBox->setModel( &m_editor->m_quantizeModel ); + m_quantizeComboBox->setFixedSize( 64, 22 ); + + + // setup note-len-stuff + QLabel * note_len_lbl = new QLabel( m_toolBar ); + note_len_lbl->setPixmap( embed::getIconPixmap( "note" ) ); + + + m_noteLenComboBox = new ComboBox( m_toolBar ); + m_noteLenComboBox->setModel( &m_editor->m_noteLenModel ); + m_noteLenComboBox->setFixedSize( 105, 22 ); + + // setup scale-stuff + QLabel * scale_lbl = new QLabel( m_toolBar ); + scale_lbl->setPixmap( embed::getIconPixmap( "scale" ) ); + + m_scaleComboBox = new ComboBox( m_toolBar ); + m_scaleComboBox->setModel( &m_editor->m_scaleModel ); + m_scaleComboBox->setFixedSize( 105, 22 ); + + // setup chord-stuff + QLabel * chord_lbl = new QLabel( m_toolBar ); + chord_lbl->setPixmap( embed::getIconPixmap( "chord" ) ); + + m_chordComboBox = new ComboBox( m_toolBar ); + m_chordComboBox->setModel( &m_editor->m_chordModel ); + m_chordComboBox->setFixedSize( 105, 22 ); + + + m_toolBar->addSeparator(); + m_toolBar->addWidget( m_drawButton ); + m_toolBar->addWidget( m_eraseButton ); + m_toolBar->addWidget( m_selectButton ); + m_toolBar->addWidget( m_detuneButton ); + + m_toolBar->addSeparator(); + m_toolBar->addWidget( m_cutButton ); + m_toolBar->addWidget( m_copyButton ); + m_toolBar->addWidget( m_pasteButton ); + + m_toolBar->addSeparator(); + QWidget* timeLineButtons = new QWidget(); + timeLineButtons->setFixedHeight(m_toolBar->height()); + timeLineButtons->move(0,0); + QLayout* l = new QHBoxLayout( timeLineButtons ); + l->setSpacing(0); l->setMargin(0); + m_editor->m_timeLine->addToolButtons(timeLineButtons); + m_toolBar->addWidget(timeLineButtons); + + m_toolBar->addSeparator(); + m_toolBar->addWidget( zoom_lbl ); + m_toolBar->addWidget( m_zoomingComboBox ); + + m_toolBar->addSeparator(); + m_toolBar->addWidget( quantize_lbl ); + m_toolBar->addWidget( m_quantizeComboBox ); + + m_toolBar->addSeparator(); + m_toolBar->addWidget( note_len_lbl ); + m_toolBar->addWidget( m_noteLenComboBox ); + + m_toolBar->addSeparator(); + m_toolBar->addWidget( scale_lbl ); + m_toolBar->addWidget( m_scaleComboBox ); + + m_toolBar->addSeparator(); + m_toolBar->addWidget( chord_lbl ); + m_toolBar->addWidget( m_chordComboBox ); + + m_zoomingComboBox->setWhatsThis( + tr( + "This controls the magnification of an axis. " + "It can be helpful to choose magnification for a specific " + "task. For ordinary editing, the magnification should be " + "fitted to your smallest notes. " + ) ); + + m_quantizeComboBox->setWhatsThis( + tr( + "The 'Q' stands for quantization, and controls the grid size " + "notes and control points snap to. " + "With smaller quantization values, you can draw shorter notes " + "in Piano Roll, and more exact control points in the " + "Automation Editor." + + ) ); + + m_noteLenComboBox->setWhatsThis( + tr( + "This lets you select the length of new notes. " + "'Last Note' means that LMMS will use the note length of " + "the note you last edited" + ) ); + + m_scaleComboBox->setWhatsThis( + tr( + "The feature is directly connected to the context-menu " + "on the virtual keyboard, to the left in Piano Roll. " + "After you have chosen the scale you want " + "in this drop-down menu, " + "you can right click on a desired key in the virtual keyboard, " + "and then choose 'Mark current Scale'. " + "LMMS will highlight all notes that belongs to the chosen scale, " + "and in the key you have selected!" + ) ); + + + m_chordComboBox->setWhatsThis( + tr( + "Let you select a chord which LMMS then can draw or highlight." + "You can find the most common chords in this drop-down menu. " + "After you have selected a chord, click anywhere to place the chord, and right " + "click on the virtual keyboard to open context menu and highlight the chord. " + "To return to single note placement, you need to choose 'No chord' " + "in this drop-down menu." + ) ); + + + // setup our actual window + setFocusPolicy( Qt::StrongFocus ); + setFocus(); + setWindowIcon( embed::getIconPixmap( "piano" ) ); + setCurrentPattern( NULL ); + + if( Engine::mainWindow()->workspace() ) + { + parentWidget()->resize(m_toolBar->sizeHint().width()+10, INITIAL_PIANOROLL_HEIGHT); + parentWidget()->move( 5, 5 ); + parentWidget()->hide(); + } + else + { + resize( m_toolBar->sizeHint().width()+10, INITIAL_PIANOROLL_HEIGHT ); + hide(); + } + + // Connections + connect(m_editor, SIGNAL(currentPatternChanged()), this, SIGNAL(currentPatternChanged())); +} + +const Pattern*PianoRollWindow::currentPattern() const +{ + return m_editor->currentPattern(); +} + +void PianoRollWindow::setCurrentPattern(Pattern* pattern) +{ + m_editor->setCurrentPattern(pattern); +} + +bool PianoRollWindow::isRecording() const +{ + return m_editor->isRecording(); +} + +int PianoRollWindow::quantization() const +{ + return m_editor->quantization(); +} + +void PianoRollWindow::play() +{ + m_editor->play(); +} + +void PianoRollWindow::stop() +{ + m_editor->stop(); +} + +void PianoRollWindow::record() +{ + m_editor->record(); +} + +void PianoRollWindow::recordAccompany() +{ + m_editor->recordAccompany(); +} + +void PianoRollWindow::stopRecording() +{ + m_editor->stopRecording(); +} + +void PianoRollWindow::reset() +{ + m_editor->reset(); +} + + +void PianoRollWindow::saveSettings(QDomDocument & doc, QDomElement & de) +{ + MainWindow::saveWidgetState(this, de); +} + + +void PianoRollWindow::loadSettings(const QDomElement & de) +{ + MainWindow::restoreWidgetState(this, de); +} diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index ee020cb07..33e2e8131 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -250,6 +250,9 @@ SongEditor::SongEditor( Song * _song ) : m_zoomingModel->findText( "100%" ) ); connect( m_zoomingModel, SIGNAL( dataChanged() ), this, SLOT( zoomingChanged() ) ); + + setFocusPolicy( Qt::StrongFocus ); + setFocus(); } @@ -606,9 +609,6 @@ SongEditorWindow::SongEditorWindow(Song* song) : setWindowTitle( tr( "Song-Editor" ) ); setWindowIcon( embed::getIconPixmap( "songeditor" ) ); - setFocusPolicy( Qt::StrongFocus ); - setFocus(); - setCentralWidget(m_editor); // Set up buttons diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index 5306b2185..f53c57713 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -670,6 +670,7 @@ void PatternView::openInPianoRoll() { Engine::pianoRoll()->setCurrentPattern( m_pat ); Engine::pianoRoll()->parentWidget()->show(); + Engine::pianoRoll()->show(); Engine::pianoRoll()->setFocus(); } From e9d841dec134b6b38774443af0716ef56ec0f825 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 16:53:31 +0100 Subject: [PATCH 08/32] Migrate Timeline::addToolButtons to QToolBar --- include/Timeline.h | 3 ++- src/core/Timeline.cpp | 10 +++++----- src/gui/AutomationEditor.cpp | 8 +------- src/gui/PianoRoll.cpp | 8 +------- src/gui/SongEditor.cpp | 10 ++-------- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/include/Timeline.h b/include/Timeline.h index 78dc00ddc..47f93d4b6 100644 --- a/include/Timeline.h +++ b/include/Timeline.h @@ -32,6 +32,7 @@ class QPixmap; +class QToolBar; class NStateButton; class TextFloat; @@ -111,7 +112,7 @@ public: update(); } - void addToolButtons( QWidget * _tool_bar ); + void addToolButtons(QToolBar* _tool_bar ); virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); diff --git a/src/core/Timeline.cpp b/src/core/Timeline.cpp index d30682d79..c4c39d7bd 100644 --- a/src/core/Timeline.cpp +++ b/src/core/Timeline.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "Timeline.h" @@ -121,7 +122,7 @@ Timeline::~Timeline() -void Timeline::addToolButtons( QWidget * _tool_bar ) +void Timeline::addToolButtons( QToolBar * _tool_bar ) { NStateButton * autoScroll = new NStateButton( _tool_bar ); autoScroll->setGeneralToolTip( tr( "Enable/disable auto-scrolling" ) ); @@ -152,10 +153,9 @@ void Timeline::addToolButtons( QWidget * _tool_bar ) connect( behaviourAtStop, SIGNAL( changedState( int ) ), this, SLOT( toggleBehaviourAtStop( int ) ) ); - QBoxLayout * layout = dynamic_cast( _tool_bar->layout() ); - layout->addWidget( autoScroll ); - layout->addWidget( loopPoints ); - layout->addWidget( behaviourAtStop ); + _tool_bar->addWidget( autoScroll ); + _tool_bar->addWidget( loopPoints ); + _tool_bar->addWidget( behaviourAtStop ); } diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index 132ad1b11..46ef53f1b 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -2265,13 +2265,7 @@ AutomationEditorWindow::AutomationEditorWindow() : m_toolBar->addWidget( m_copyButton ); m_toolBar->addWidget( m_pasteButton ); m_toolBar->addSeparator(); - QWidget* timeLineButtons = new QWidget(); - timeLineButtons->setFixedHeight(m_cutButton->height()); - timeLineButtons->move(0,0); - QLayout* l = new QHBoxLayout( timeLineButtons ); - l->setSpacing(0); l->setMargin(0); - m_editor->m_timeLine->addToolButtons(timeLineButtons); - m_toolBar->addWidget(timeLineButtons); + m_editor->m_timeLine->addToolButtons(m_toolBar); m_toolBar->addSeparator(); m_toolBar->addWidget( zoom_x_label ); m_toolBar->addWidget( m_zoomingXComboBox ); diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index 6b2d5da03..b6f8e737d 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -4145,13 +4145,7 @@ PianoRollWindow::PianoRollWindow() : m_toolBar->addWidget( m_pasteButton ); m_toolBar->addSeparator(); - QWidget* timeLineButtons = new QWidget(); - timeLineButtons->setFixedHeight(m_toolBar->height()); - timeLineButtons->move(0,0); - QLayout* l = new QHBoxLayout( timeLineButtons ); - l->setSpacing(0); l->setMargin(0); - m_editor->m_timeLine->addToolButtons(timeLineButtons); - m_toolBar->addWidget(timeLineButtons); + m_editor->m_timeLine->addToolButtons(m_toolBar); m_toolBar->addSeparator(); m_toolBar->addWidget( zoom_lbl ); diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index 33e2e8131..43f218957 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -676,14 +676,8 @@ SongEditorWindow::SongEditorWindow(Song* song) : m_toolBar->addSeparator(); m_toolBar->addWidget( m_drawModeButton ); m_toolBar->addWidget( m_editModeButton ); - - QWidget* timeLineButtons = new QWidget(); - timeLineButtons->setFixedHeight(m_toolBar->height()); - timeLineButtons->move(0,0); - QLayout* l = new QHBoxLayout( timeLineButtons ); - l->setSpacing(0); l->setMargin(0); - m_editor->m_timeLine->addToolButtons(timeLineButtons); - + m_toolBar->addSeparator(); + m_editor->m_timeLine->addToolButtons(m_toolBar); m_toolBar->addSeparator(); m_toolBar->addWidget( zoom_lbl ); m_toolBar->addWidget( m_zoomingComboBox ); From 4b275693b6af977d9e4cdfbc746a432e52abb591 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 17:12:38 +0100 Subject: [PATCH 09/32] ToolBar css fixes --- data/themes/default/style.css | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/data/themes/default/style.css b/data/themes/default/style.css index a95abb793..03d9212fa 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -378,9 +378,17 @@ QWidget#mainToolbar { QToolBar { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #98a2a7, stop:1 #5b646f); + border: none; + padding: 1px; + spacing: 0; } -QToolButton, ToolButton { +QToolBar::separator { + border: none; + width: 5px; +} + +QToolButton { padding: 1px 1px 1px 1px; border-radius: 2px; border: 1px solid rgba(0,0,0,32); @@ -391,12 +399,12 @@ QToolButton, ToolButton { /* separate corner rounding for play and stop buttons! */ -ToolButton#playButton { +QToolButton#playButton { border-top-left-radius: 5px 15px; border-bottom-left-radius: 5px 15px; } -ToolButton#stopButton { +QToolButton#stopButton { border-top-right-radius: 5px 15px; border-bottom-right-radius: 5px 15px; } @@ -405,20 +413,20 @@ ToolButton#stopButton { /* all tool buttons */ -QToolButton:hover, ToolButton:hover { +QToolButton:hover { background: qradialgradient(cx:0.3, cy:0.3, radius:0.8, fx:0.3, fy:0.3, stop:0 #e0e0e0, stop:0.5 #c9c9c9, stop:1 #969696 ); border: 1px solid rgba(0,0,0,128); color: white; } -QToolButton:pressed, ToolButton:pressed { +QToolButton:pressed { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #969696, stop:0.5 #c9c9c9, stop:1 #969696 ); padding: 2px 1px 0px 1px; border: 1px solid rgba(0,0,0,128); color: white; } -QToolButton:checked, ToolButton:checked { +QToolButton:checked { background: qradialgradient(cx:0.3, cy:0.3, radius:0.8, fx:0.3, fy:0.3, stop:0 #e0e0e0, stop:0.8 #c9c9c9, stop:1 #c0c0c0 ); border-radius: 3px; padding: 2px 1px 0px 1px; From d029c8513a9ccfc60716cf1d5f5927aed7704df5 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 18:23:01 +0100 Subject: [PATCH 10/32] BBEditor: Use Editor superclass --- include/BBEditor.h | 63 ++++++---- include/ComboBox.h | 4 + include/Pattern.h | 2 +- src/core/Song.cpp | 2 +- src/core/Track.cpp | 4 +- src/gui/BBEditor.cpp | 219 ++++++++++++++--------------------- src/gui/widgets/ComboBox.cpp | 20 +++- 7 files changed, 149 insertions(+), 165 deletions(-) diff --git a/include/BBEditor.h b/include/BBEditor.h index 84b99a0da..1e2bda33c 100644 --- a/include/BBEditor.h +++ b/include/BBEditor.h @@ -26,6 +26,7 @@ #ifndef BB_EDITOR_H #define BB_EDITOR_H +#include "Editor.h" #include "TrackContainerView.h" @@ -33,46 +34,60 @@ class BBTrackContainer; class ComboBox; class ToolButton; +class BBTrackContainerView; -class BBEditor : public TrackContainerView +class BBEditor : public Editor { Q_OBJECT public: BBEditor( BBTrackContainer * _tc ); - virtual ~BBEditor(); + ~BBEditor(); - virtual inline bool fixedTCOs() const - { - return( true ); + const BBTrackContainerView* trackContainerView() const { + return m_trackContainerView; + } + BBTrackContainerView* trackContainerView() { + return m_trackContainerView; } - - virtual void dropEvent( QDropEvent * _de ); - - void removeBBView( int _bb ); - - void setPauseIcon( bool pause ); + void removeBBView( int bb ); public slots: void play(); void stop(); - void updatePosition(); - void addAutomationTrack(); - void addSteps(); - void removeSteps(); private: - virtual void keyPressEvent( QKeyEvent * _ke ); - - BBTrackContainer * m_bbtc; - QWidget * m_toolBar; - - ToolButton * m_playButton; - ToolButton * m_stopButton; - + BBTrackContainerView* m_trackContainerView; ComboBox * m_bbComboBox; - } ; + +class BBTrackContainerView : public TrackContainerView +{ + Q_OBJECT +public: + BBTrackContainerView(BBTrackContainer* tc); + + bool fixedTCOs() const + { + return true; + } + + void removeBBView(int bb); + +public slots: + void addSteps(); + void removeSteps(); + void addAutomationTrack(); + +protected slots: + virtual void dropEvent(QDropEvent * de ); + void updatePosition(); + +private: + BBTrackContainer * m_bbtc; +}; + + #endif diff --git a/include/ComboBox.h b/include/ComboBox.h index fdfe12bf3..0c348e53b 100644 --- a/include/ComboBox.h +++ b/include/ComboBox.h @@ -53,6 +53,10 @@ public: virtual QSize sizeHint() const; +public slots: + void selectNext(); + void selectPrevious(); + protected: virtual void contextMenuEvent( QContextMenuEvent* event ); diff --git a/include/Pattern.h b/include/Pattern.h index 163b3429b..840926f51 100644 --- a/include/Pattern.h +++ b/include/Pattern.h @@ -138,7 +138,7 @@ private: int m_steps; friend class PatternView; - friend class BBEditor; + friend class BBTrackContainerView; signals: diff --git a/src/core/Song.cpp b/src/core/Song.cpp index dc19a3d65..a8d3450f8 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -729,7 +729,7 @@ void Song::clearProject() Engine::mixer()->lock(); if( Engine::getBBEditor() ) { - Engine::getBBEditor()->clearAllTracks(); + Engine::getBBEditor()->trackContainerView()->clearAllTracks(); } if( Engine::songEditor() ) { diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 188d57e08..f25623540 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -1134,7 +1134,7 @@ void TrackContentWidget::update() */ void TrackContentWidget::changePosition( const MidiTime & _new_pos ) { - if( m_trackView->trackContainerView() == Engine::getBBEditor() ) + if( m_trackView->trackContainerView() == Engine::getBBEditor()->trackContainerView() ) { const int cur_bb = Engine::getBBTrackContainer()->currentBB(); setUpdatesEnabled( false ); @@ -1466,7 +1466,7 @@ void TrackContentWidget::paintEvent( QPaintEvent * _pe ) int ppt = static_cast( tcv->pixelsPerTact() ); QPainter p( this ); // Don't draw background on BB-Editor - if( m_trackView->trackContainerView() != Engine::getBBEditor() ) + if( m_trackView->trackContainerView() != Engine::getBBEditor()->trackContainerView() ) { p.drawTiledPixmap( rect(), m_background, QPoint( tcv->currentPosition().getTact() * ppt, 0 ) ); diff --git a/src/gui/BBEditor.cpp b/src/gui/BBEditor.cpp index d57da6441..a8d631481 100644 --- a/src/gui/BBEditor.cpp +++ b/src/gui/BBEditor.cpp @@ -22,7 +22,7 @@ * */ - +#include #include #include #include @@ -44,27 +44,13 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : - TrackContainerView( tc ), - m_bbtc( tc ) + Editor(false), + m_trackContainerView( new BBTrackContainerView(tc) ) { - // create toolbar - m_toolBar = new QWidget; - m_toolBar->setFixedHeight( 32 ); - m_toolBar->move( 0, 0 ); - m_toolBar->setAutoFillBackground( true ); - QPalette pal; - pal.setBrush( m_toolBar->backgroundRole(), - embed::getIconPixmap( "toolbar_bg" ) ); - m_toolBar->setPalette( pal ); - static_cast( layout() )->insertWidget( 0, m_toolBar ); - - QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar ); - tb_layout->setSpacing( 0 ); - tb_layout->setMargin( 0 ); - - setWindowIcon( embed::getIconPixmap( "bb_track_btn" ) ); setWindowTitle( tr( "Beat+Bassline Editor" ) ); + setCentralWidget(m_trackContainerView); + // TODO: Use style sheet if( ConfigManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() ) @@ -79,16 +65,8 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : } - m_playButton = new ToolButton( embed::getIconPixmap( "play" ), - tr( "Play/pause current beat/bassline (Space)" ), - this, SLOT( play() ), m_toolBar ); - - m_stopButton = new ToolButton( embed::getIconPixmap( "stop" ), - tr( "Stop playback of current beat/bassline (Space)" ), - this, SLOT( stop() ), m_toolBar ); - - m_playButton->setObjectName( "playButton" ); - m_stopButton->setObjectName( "stopButton" ); + m_playButton->setToolTip(tr( "Play/pause current beat/bassline (Space)" )); + m_stopButton->setToolTip(tr( "Stop playback of current beat/bassline (Space)" )); ToolButton * add_bb_track = new ToolButton( embed::getIconPixmap( "add_bb_track" ), @@ -99,18 +77,17 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : ToolButton * add_automation_track = new ToolButton( embed::getIconPixmap( "add_automation" ), tr( "Add automation-track" ), - this, SLOT( addAutomationTrack() ), m_toolBar ); + m_trackContainerView, SLOT( addAutomationTrack() ), m_toolBar ); ToolButton * remove_bar = new ToolButton( embed::getIconPixmap( "step_btn_remove" ), tr( "Remove steps" ), - this, SLOT( removeSteps() ), m_toolBar ); + m_trackContainerView, SLOT( removeSteps() ), m_toolBar ); ToolButton * add_bar = new ToolButton( embed::getIconPixmap( "step_btn_add" ), tr( "Add steps" ), - this, SLOT( addSteps() ), m_toolBar ); - + m_trackContainerView, SLOT( addSteps() ), m_toolBar ); m_playButton->setWhatsThis( @@ -125,30 +102,35 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : m_bbComboBox->setFixedSize( 200, 22 ); m_bbComboBox->setModel( &tc->m_bbComboBoxModel ); - tb_layout->addSpacing( 5 ); - tb_layout->addWidget( m_playButton ); - tb_layout->addWidget( m_stopButton ); - tb_layout->addSpacing( 20 ); - tb_layout->addWidget( m_bbComboBox ); - tb_layout->addSpacing( 10 ); - tb_layout->addWidget( add_bb_track ); - tb_layout->addWidget( add_automation_track ); - tb_layout->addStretch(); - tb_layout->addWidget( remove_bar ); - tb_layout->addWidget( add_bar ); - tb_layout->addSpacing( 15 ); + m_toolBar->addSeparator(); + m_toolBar->addWidget( m_bbComboBox ); + m_toolBar->addSeparator(); + m_toolBar->addWidget( add_bb_track ); + m_toolBar->addWidget( add_automation_track ); + QWidget* stretch = new QWidget(m_toolBar); + stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_toolBar->addWidget(stretch); + m_toolBar->addWidget( remove_bar ); + m_toolBar->addWidget( add_bar ); + m_toolBar->addSeparator(); - Engine::mainWindow()->workspace()->addSubWindow( this ); - parentWidget()->setAttribute( Qt::WA_DeleteOnClose, false ); parentWidget()->layout()->setSizeConstraint( QLayout::SetMinimumSize ); parentWidget()->resize( minimumWidth(), 300 ); parentWidget()->move( 610, 5 ); parentWidget()->show(); - - setModel( tc ); connect( &tc->m_bbComboBoxModel, SIGNAL( dataChanged() ), - this, SLOT( updatePosition() ) ); + m_trackContainerView, SLOT( updatePosition() ) ); + + QAction* viewNext = new QAction(this); + connect(viewNext, SIGNAL(triggered()), m_bbComboBox, SLOT(selectNext())); + viewNext->setShortcut(Qt::Key_Plus); + addAction(viewNext); + + QAction* viewPrevious = new QAction(this); + connect(viewPrevious, SIGNAL(triggered()), m_bbComboBox, SLOT(selectPrevious())); + viewPrevious->setShortcut(Qt::Key_Minus); + addAction(viewPrevious); } @@ -159,49 +141,11 @@ BBEditor::~BBEditor() } -void BBEditor::dropEvent( QDropEvent * de ) + + +void BBEditor::removeBBView( int bb ) { - QString type = StringPairDrag::decodeKey( de ); - QString value = StringPairDrag::decodeValue( de ); - - if( type.left( 6 ) == "track_" ) - { - DataFile dataFile( value.toUtf8() ); - Track * t = Track::create( dataFile.content().firstChild().toElement(), model() ); - - t->deleteTCOs(); - m_bbtc->updateAfterTrackAdd(); - - de->accept(); - } - else - { - TrackContainerView::dropEvent( de ); - } -} - - -void BBEditor::removeBBView( int _bb ) -{ - foreach( TrackView* view, trackViews() ) - { - view->getTrackContentWidget()->removeTCOView( _bb ); - } -} - - - - -void BBEditor::setPauseIcon( bool pause ) -{ - if( pause == true ) - { - m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); - } - else - { - m_playButton->setIcon( embed::getIconPixmap( "play" ) ); - } + m_trackContainerView->removeBBView(bb); } @@ -230,24 +174,21 @@ void BBEditor::stop() -void BBEditor::updatePosition() + + +BBTrackContainerView::BBTrackContainerView(BBTrackContainer* tc) : + TrackContainerView(tc), + m_bbtc(tc) { - //realignTracks(); - emit positionChanged( m_currentPosition ); + setModel( tc ); } -void BBEditor::addAutomationTrack() -{ - (void) Track::create( Track::AutomationTrack, model() ); -} - - -void BBEditor::addSteps() +void BBTrackContainerView::addSteps() { TrackContainer::TrackList tl = model()->tracks(); @@ -265,7 +206,7 @@ void BBEditor::addSteps() -void BBEditor::removeSteps() +void BBTrackContainerView::removeSteps() { TrackContainer::TrackList tl = model()->tracks(); @@ -283,43 +224,51 @@ void BBEditor::removeSteps() -void BBEditor::keyPressEvent( QKeyEvent * _ke ) +void BBTrackContainerView::addAutomationTrack() { - if ( _ke->key() == Qt::Key_Space ) - { - if( Engine::getSong()->isPlaying() ) - { - stop(); - } - else - { - play(); - } - } - else if ( _ke->key() == Qt::Key_Plus ) - { - if( m_bbtc->currentBB()+ 1 < m_bbtc->numOfBBs() ) - { - m_bbtc->setCurrentBB( m_bbtc->currentBB() + 1 ); - } - } - else if ( _ke->key() == Qt::Key_Minus ) - { - if( m_bbtc->currentBB() > 0 ) - { - m_bbtc->setCurrentBB( m_bbtc->currentBB() - 1 ); - } - } - else - { - // ignore event and pass to parent-widget - _ke->ignore(); - } - + (void) Track::create( Track::AutomationTrack, model() ); } +void BBTrackContainerView::removeBBView(int bb) +{ + foreach( TrackView* view, trackViews() ) + { + view->getTrackContentWidget()->removeTCOView( bb ); + } +} + + +void BBTrackContainerView::dropEvent(QDropEvent* de) +{ + QString type = StringPairDrag::decodeKey( de ); + QString value = StringPairDrag::decodeValue( de ); + + if( type.left( 6 ) == "track_" ) + { + DataFile dataFile( value.toUtf8() ); + Track * t = Track::create( dataFile.content().firstChild().toElement(), model() ); + + t->deleteTCOs(); + m_bbtc->updateAfterTrackAdd(); + + de->accept(); + } + else + { + TrackContainerView::dropEvent( de ); + } +} + + + + +void BBTrackContainerView::updatePosition() +{ + //realignTracks(); + emit positionChanged( m_currentPosition ); +} diff --git a/src/gui/widgets/ComboBox.cpp b/src/gui/widgets/ComboBox.cpp index 950dbf70f..86294a863 100644 --- a/src/gui/widgets/ComboBox.cpp +++ b/src/gui/widgets/ComboBox.cpp @@ -105,6 +105,22 @@ QSize ComboBox::sizeHint() const + +void ComboBox::selectNext() +{ + model()->setInitValue( model()->value() + 1 ); +} + + + + +void ComboBox::selectPrevious() +{ + model()->setInitValue( model()->value() - 1 ); +} + + + void ComboBox::contextMenuEvent( QContextMenuEvent * event ) { if( model() == NULL || event->x() <= width() - CB_ARROW_BTN_WIDTH ) @@ -157,13 +173,13 @@ void ComboBox::mousePressEvent( QMouseEvent* event ) } else if( event->button() == Qt::LeftButton ) { - model()->setInitValue( model()->value() + 1 ); + selectNext(); update(); } } else if( event->button() == Qt::RightButton ) { - model()->setInitValue( model()->value() - 1 ); + selectPrevious(); update(); } else From 11898a5162f32b49431ab4df121cb01f868e040d Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 18:25:10 +0100 Subject: [PATCH 11/32] Move Timeline.cpp to gui directory --- src/{core => gui}/Timeline.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{core => gui}/Timeline.cpp (100%) diff --git a/src/core/Timeline.cpp b/src/gui/Timeline.cpp similarity index 100% rename from src/core/Timeline.cpp rename to src/gui/Timeline.cpp From 7a21d699ea1a17c120ca07e27552178fc33ad411 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 18:46:10 +0100 Subject: [PATCH 12/32] SongEditor: Some renames --- include/SongEditor.h | 29 +++++++++++----------- src/gui/SongEditor.cpp | 55 +++++++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/include/SongEditor.h b/include/SongEditor.h index 3fff287a9..eb42b1ea4 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -58,10 +58,10 @@ class SongEditor : public TrackContainerView { Q_OBJECT public: - enum Mode + enum EditMode { DrawMode, - EditMode + SelectMode }; SongEditor( Song * _song ); @@ -70,22 +70,23 @@ public: public slots: void scrolled( int _new_pos ); - void setMode(Mode mode); - void setModeDraw(); - void setModeEdit(); + void setEditMode(EditMode mode); + void setEditModeDraw(); + void setEditModeSelect(); private slots: void setHighQuality( bool ); - void masterVolumeChanged( int _new_val ); - void masterVolumePressed(); - void masterVolumeMoved( int _new_val ); - void masterVolumeReleased(); - void masterPitchChanged( int _new_val ); - void masterPitchPressed(); - void masterPitchMoved( int _new_val ); - void masterPitchReleased(); + void setMasterVolume( int _new_val ); + void showMasterVolumeFloat(); + void updateMasterVolumeFloat( int _new_val ); + void hideMasterVolumeFloat(); + + void setMasterPitch( int _new_val ); + void showMasterPitchFloat(); + void updateMasterPitchFloat( int _new_val ); + void hideMasterPitchFloat(); void updateScrollBar( int ); void updatePosition( const MidiTime & _t ); @@ -124,7 +125,7 @@ private: bool m_scrollBack; bool m_smoothScroll; - Mode m_mode; + EditMode m_mode; friend class SongEditorWindow; diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index 43f218957..10c76d4bc 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -163,13 +163,13 @@ SongEditor::SongEditor( Song * _song ) : ToolTip::add( m_masterVolumeSlider, tr( "master volume" ) ); connect( m_masterVolumeSlider, SIGNAL( logicValueChanged( int ) ), this, - SLOT( masterVolumeChanged( int ) ) ); + SLOT( setMasterVolume( int ) ) ); connect( m_masterVolumeSlider, SIGNAL( sliderPressed() ), this, - SLOT( masterVolumePressed() ) ); + SLOT( showMasterVolumeFloat()) ); connect( m_masterVolumeSlider, SIGNAL( logicSliderMoved( int ) ), this, - SLOT( masterVolumeMoved( int ) ) ); + SLOT( updateMasterVolumeFloat( int ) ) ); connect( m_masterVolumeSlider, SIGNAL( sliderReleased() ), this, - SLOT( masterVolumeReleased() ) ); + SLOT( hideMasterVolumeFloat() ) ); m_mvsStatus = new TextFloat; m_mvsStatus->setTitle( tr( "Master volume" ) ); @@ -195,13 +195,13 @@ SongEditor::SongEditor( Song * _song ) : m_masterPitchSlider->setTickInterval( 12 ); ToolTip::add( m_masterPitchSlider, tr( "master pitch" ) ); connect( m_masterPitchSlider, SIGNAL( logicValueChanged( int ) ), this, - SLOT( masterPitchChanged( int ) ) ); + SLOT( setMasterPitch( int ) ) ); connect( m_masterPitchSlider, SIGNAL( sliderPressed() ), this, - SLOT( masterPitchPressed() ) ); + SLOT( showMasterPitchFloat() ) ); connect( m_masterPitchSlider, SIGNAL( logicSliderMoved( int ) ), this, - SLOT( masterPitchMoved( int ) ) ); + SLOT( updateMasterPitchFloat( int ) ) ); connect( m_masterPitchSlider, SIGNAL( sliderReleased() ), this, - SLOT( masterPitchReleased() ) ); + SLOT( hideMasterPitchFloat() ) ); m_mpsStatus = new TextFloat; m_mpsStatus->setTitle( tr( "Master pitch" ) ); @@ -284,19 +284,19 @@ void SongEditor::scrolled( int _new_pos ) -void SongEditor::setMode(Mode mode) +void SongEditor::setEditMode(EditMode mode) { m_mode = mode; } -void SongEditor::setModeDraw() +void SongEditor::setEditModeDraw() { - setMode(DrawMode); + setEditMode(DrawMode); } -void SongEditor::setModeEdit() +void SongEditor::setEditModeSelect() { - setMode(EditMode); + setEditMode(SelectMode); } @@ -387,9 +387,8 @@ void SongEditor::wheelEvent( QWheelEvent * _we ) -void SongEditor::masterVolumeChanged( int _new_val ) +void SongEditor::setMasterVolume( int _new_val ) { - masterVolumeMoved( _new_val ); if( m_mvsStatus->isVisible() == false && m_song->m_loadingProject == false && m_masterVolumeSlider->showStatus() ) { @@ -403,18 +402,18 @@ void SongEditor::masterVolumeChanged( int _new_val ) -void SongEditor::masterVolumePressed( void ) +void SongEditor::showMasterVolumeFloat( void ) { m_mvsStatus->moveGlobal( m_masterVolumeSlider, QPoint( m_masterVolumeSlider->width() + 2, -2 ) ); m_mvsStatus->show(); - masterVolumeMoved( m_song->m_masterVolumeModel.value() ); + updateMasterVolumeFloat( m_song->m_masterVolumeModel.value() ); } -void SongEditor::masterVolumeMoved( int _new_val ) +void SongEditor::updateMasterVolumeFloat( int _new_val ) { m_mvsStatus->setText( tr( "Value: %1%" ).arg( _new_val ) ); } @@ -422,7 +421,7 @@ void SongEditor::masterVolumeMoved( int _new_val ) -void SongEditor::masterVolumeReleased( void ) +void SongEditor::hideMasterVolumeFloat( void ) { m_mvsStatus->hide(); } @@ -430,9 +429,9 @@ void SongEditor::masterVolumeReleased( void ) -void SongEditor::masterPitchChanged( int _new_val ) +void SongEditor::setMasterPitch( int _new_val ) { - masterPitchMoved( _new_val ); + updateMasterPitchFloat( _new_val ); if( m_mpsStatus->isVisible() == false && m_song->m_loadingProject == false && m_masterPitchSlider->showStatus() ) { @@ -445,18 +444,18 @@ void SongEditor::masterPitchChanged( int _new_val ) -void SongEditor::masterPitchPressed( void ) +void SongEditor::showMasterPitchFloat( void ) { m_mpsStatus->moveGlobal( m_masterPitchSlider, QPoint( m_masterPitchSlider->width() + 2, -2 ) ); m_mpsStatus->show(); - masterPitchMoved( m_song->m_masterPitchModel.value() ); + updateMasterPitchFloat( m_song->m_masterPitchModel.value() ); } -void SongEditor::masterPitchMoved( int _new_val ) +void SongEditor::updateMasterPitchFloat( int _new_val ) { m_mpsStatus->setText( tr( "Value: %1 semitones").arg( _new_val ) ); @@ -465,7 +464,7 @@ void SongEditor::masterPitchMoved( int _new_val ) -void SongEditor::masterPitchReleased( void ) +void SongEditor::hideMasterPitchFloat( void ) { m_mpsStatus->hide(); } @@ -598,7 +597,7 @@ void SongEditor::adjustUiAfterProjectLoad() bool SongEditor::allowRubberband() const { - return m_mode == EditMode; + return m_mode == SelectMode; } @@ -636,13 +635,13 @@ SongEditorWindow::SongEditorWindow(Song* song) : m_editor->m_song, SLOT(addAutomationTrack())); m_drawModeButton = new ToolButton(embed::getIconPixmap("edit_draw"), - tr("Draw mode"), m_editor, SLOT(setModeDraw())); + tr("Draw mode"), m_editor, SLOT(setEditModeDraw())); m_drawModeButton->setCheckable(true); m_drawModeButton->setChecked(true); m_editModeButton = new ToolButton(embed::getIconPixmap("edit_select"), tr("Edit mode (select and move)"), - m_editor, SLOT(setModeEdit())); + m_editor, SLOT(setEditModeSelect())); m_editModeButton->setCheckable(true); QButtonGroup * tool_button_group = new QButtonGroup(this); From f131fbd87792b64d3d576aa1f2e23729deb2bd45 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 19:22:52 +0100 Subject: [PATCH 13/32] Editors: Add to workspace in MainWindow class, not in themselves --- include/AutomationEditor.h | 2 ++ include/BBEditor.h | 2 ++ include/PianoRoll.h | 2 ++ include/SongEditor.h | 2 ++ src/gui/AutomationEditor.cpp | 17 +++++------------ src/gui/BBEditor.cpp | 15 ++++----------- src/gui/Editor.cpp | 5 ----- src/gui/MainWindow.cpp | 22 ++++++++++++++++++++++ src/gui/PianoRoll.cpp | 18 +++++------------- src/gui/SongEditor.cpp | 7 ++++--- 10 files changed, 48 insertions(+), 44 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 8105e63c6..d203ac25e 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -267,6 +267,8 @@ public: AutomationEditor* m_editor; + QSize sizeHint() const; + signals: void currentPatternChanged(); diff --git a/include/BBEditor.h b/include/BBEditor.h index 1e2bda33c..d13d1cc45 100644 --- a/include/BBEditor.h +++ b/include/BBEditor.h @@ -43,6 +43,8 @@ public: BBEditor( BBTrackContainer * _tc ); ~BBEditor(); + QSize sizeHint() const; + const BBTrackContainerView* trackContainerView() const { return m_trackContainerView; } diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 1d7cd1146..0d87c752a 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -379,6 +379,8 @@ public: return "pianoroll"; } + QSize sizeHint() const; + signals: void currentPatternChanged(); diff --git a/include/SongEditor.h b/include/SongEditor.h index eb42b1ea4..4f523dbb2 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -137,6 +137,8 @@ class SongEditorWindow : public Editor public: SongEditorWindow(Song* song); + QSize sizeHint() const; + SongEditor* m_editor; protected slots: diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index 46ef53f1b..b949b3396 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -2280,18 +2280,6 @@ AutomationEditorWindow::AutomationEditorWindow() : setFocusPolicy( Qt::StrongFocus ); setFocus(); setWindowIcon( embed::getIconPixmap( "automation" ) ); - - // Add us to workspace - if( Engine::mainWindow()->workspace() ) - { - parentWidget()->resize( INITIAL_WIDTH, INITIAL_HEIGHT ); - parentWidget()->hide(); - } - else - { - resize( INITIAL_WIDTH, INITIAL_HEIGHT ); - hide(); - } } @@ -2335,6 +2323,11 @@ int AutomationEditorWindow::quantization() const return m_editor->quantization(); } +QSize AutomationEditorWindow::sizeHint() const +{ + return {INITIAL_WIDTH, INITIAL_HEIGHT}; +} + void AutomationEditorWindow::play() { m_editor->play(); diff --git a/src/gui/BBEditor.cpp b/src/gui/BBEditor.cpp index a8d631481..ef3291f32 100644 --- a/src/gui/BBEditor.cpp +++ b/src/gui/BBEditor.cpp @@ -114,11 +114,6 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : m_toolBar->addWidget( add_bar ); m_toolBar->addSeparator(); - parentWidget()->layout()->setSizeConstraint( QLayout::SetMinimumSize ); - parentWidget()->resize( minimumWidth(), 300 ); - parentWidget()->move( 610, 5 ); - parentWidget()->show(); - connect( &tc->m_bbComboBoxModel, SIGNAL( dataChanged() ), m_trackContainerView, SLOT( updatePosition() ) ); @@ -134,13 +129,15 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : } - - BBEditor::~BBEditor() { } +QSize BBEditor::sizeHint() const +{ + return {minimumWidth(), 300}; +} void BBEditor::removeBBView( int bb ) @@ -149,8 +146,6 @@ void BBEditor::removeBBView( int bb ) } - - void BBEditor::play() { if( Engine::getSong()->playMode() != Song::Mode_PlayBB ) @@ -164,8 +159,6 @@ void BBEditor::play() } - - void BBEditor::stop() { Engine::getSong()->stop(); diff --git a/src/gui/Editor.cpp b/src/gui/Editor.cpp index 57042b623..0e911b960 100644 --- a/src/gui/Editor.cpp +++ b/src/gui/Editor.cpp @@ -98,11 +98,6 @@ Editor::Editor(bool record) : connect(m_recordAccompanyButton, SIGNAL(clicked()), this, SLOT(recordAccompany())); } connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop())); - - - // Add editor to main window - Engine::mainWindow()->workspace()->addSubWindow(this); - parentWidget()->setAttribute(Qt::WA_DeleteOnClose, false); } Editor::~Editor() diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 86a4ea65d..fb99d60bb 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -530,6 +530,28 @@ void MainWindow::finalize() SetupDialog sd( SetupDialog::AudioSettings ); sd.exec(); } + + // Add editor subwindows + for (QWidget* widget : QList{ + Engine::automationEditor(), + Engine::getBBEditor(), + Engine::pianoRoll(), + Engine::songEditor() + }) + { + QMdiSubWindow* window = workspace()->addSubWindow(widget); + window->setWindowIcon(widget->windowIcon()); + window->setAttribute(Qt::WA_DeleteOnClose, false); + window->resize(widget->sizeHint()); + } + + Engine::automationEditor()->parentWidget()->hide(); + Engine::getBBEditor()->parentWidget()->move( 610, 5 ); + Engine::getBBEditor()->parentWidget()->show(); + Engine::pianoRoll()->parentWidget()->move(5, 5); + Engine::pianoRoll()->parentWidget()->hide(); + Engine::songEditor()->parentWidget()->move(5, 5); + Engine::songEditor()->parentWidget()->show(); } diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index b6f8e737d..81cb01ae7 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -4222,18 +4222,6 @@ PianoRollWindow::PianoRollWindow() : setWindowIcon( embed::getIconPixmap( "piano" ) ); setCurrentPattern( NULL ); - if( Engine::mainWindow()->workspace() ) - { - parentWidget()->resize(m_toolBar->sizeHint().width()+10, INITIAL_PIANOROLL_HEIGHT); - parentWidget()->move( 5, 5 ); - parentWidget()->hide(); - } - else - { - resize( m_toolBar->sizeHint().width()+10, INITIAL_PIANOROLL_HEIGHT ); - hide(); - } - // Connections connect(m_editor, SIGNAL(currentPatternChanged()), this, SIGNAL(currentPatternChanged())); } @@ -4294,8 +4282,12 @@ void PianoRollWindow::saveSettings(QDomDocument & doc, QDomElement & de) MainWindow::saveWidgetState(this, de); } - void PianoRollWindow::loadSettings(const QDomElement & de) { MainWindow::restoreWidgetState(this, de); } + +QSize PianoRollWindow::sizeHint() const +{ + return {m_toolBar->sizeHint().width()+10, INITIAL_PIANOROLL_HEIGHT}; +} diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index 10c76d4bc..adb6747c8 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -680,10 +680,11 @@ SongEditorWindow::SongEditorWindow(Song* song) : m_toolBar->addSeparator(); m_toolBar->addWidget( zoom_lbl ); m_toolBar->addWidget( m_zoomingComboBox ); +} - parentWidget()->resize( 600, 300 ); - parentWidget()->move( 5, 5 ); - parentWidget()->show(); +QSize SongEditorWindow::sizeHint() const +{ + return {600, 300}; } From 32da8cb677388a9e2d27f94315505049b7e900dc Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 21:22:52 +0100 Subject: [PATCH 14/32] Editor: Don't use ToolButton --- include/Editor.h | 8 ++++---- src/gui/AutomationEditor.cpp | 8 ++++---- src/gui/BBEditor.cpp | 10 +++++----- src/gui/Editor.cpp | 38 ++++++++++++++++++------------------ src/gui/PianoRoll.cpp | 16 +++++++-------- src/gui/SongEditor.cpp | 14 ++++++------- 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/include/Editor.h b/include/Editor.h index 0b4fa96bb..ffd2f4ae1 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -60,10 +60,10 @@ protected: QToolBar* m_toolBar; - QAbstractButton* m_playButton; - QAbstractButton* m_recordButton; - QAbstractButton* m_recordAccompanyButton; - QAbstractButton* m_stopButton; + QAction* m_playAction; + QAction* m_recordAction; + QAction* m_recordAccompanyAction; + QAction* m_stopAction; private: }; diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index b949b3396..abf0e3225 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -2029,14 +2029,14 @@ AutomationEditorWindow::AutomationEditorWindow() : // Play/stop buttons - m_playButton->setToolTip(tr( "Play/pause current pattern (Space)" )); - m_playButton->setWhatsThis( + m_playAction->setToolTip(tr( "Play/pause current pattern (Space)" )); + m_playAction->setWhatsThis( tr( "Click here if you want to play the current pattern. " "This is useful while editing it. The pattern is " "automatically looped when the end is reached." ) ); - m_stopButton->setToolTip(tr("Stop playing of current pattern (Space)")); - m_stopButton->setWhatsThis( + m_stopAction->setToolTip(tr("Stop playing of current pattern (Space)")); + m_stopAction->setWhatsThis( tr( "Click here if you want to stop playing of the " "current pattern." ) ); diff --git a/src/gui/BBEditor.cpp b/src/gui/BBEditor.cpp index ef3291f32..03499cb87 100644 --- a/src/gui/BBEditor.cpp +++ b/src/gui/BBEditor.cpp @@ -65,8 +65,8 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : } - m_playButton->setToolTip(tr( "Play/pause current beat/bassline (Space)" )); - m_stopButton->setToolTip(tr( "Stop playback of current beat/bassline (Space)" )); + m_playAction->setToolTip(tr( "Play/pause current beat/bassline (Space)" )); + m_stopAction->setToolTip(tr( "Stop playback of current beat/bassline (Space)" )); ToolButton * add_bb_track = new ToolButton( embed::getIconPixmap( "add_bb_track" ), @@ -90,11 +90,11 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : m_trackContainerView, SLOT( addSteps() ), m_toolBar ); - m_playButton->setWhatsThis( + m_playAction->setWhatsThis( tr( "Click here to play the current " "beat/bassline. The beat/bassline is automatically " "looped when its end is reached." ) ); - m_stopButton->setWhatsThis( + m_stopAction->setWhatsThis( tr( "Click here to stop playing of current " "beat/bassline." ) ); @@ -136,7 +136,7 @@ BBEditor::~BBEditor() QSize BBEditor::sizeHint() const { - return {minimumWidth(), 300}; + return {minimumWidth()+10, 300}; } diff --git a/src/gui/Editor.cpp b/src/gui/Editor.cpp index 0e911b960..778a303a9 100644 --- a/src/gui/Editor.cpp +++ b/src/gui/Editor.cpp @@ -36,9 +36,9 @@ void Editor::setPauseIcon(bool displayPauseIcon) { // If we're playing, show a pause icon if (displayPauseIcon) - m_playButton->setIcon(embed::getIconPixmap("pause")); + m_playAction->setIcon(embed::getIconPixmap("pause")); else - m_playButton->setIcon(embed::getIconPixmap("play")); + m_playAction->setIcon(embed::getIconPixmap("play")); } void Editor::play() @@ -59,45 +59,45 @@ void Editor::stop() Editor::Editor(bool record) : m_toolBar(new QToolBar(this)), - m_playButton(nullptr), - m_recordButton(nullptr), - m_recordAccompanyButton(nullptr), - m_stopButton(nullptr) + m_playAction(nullptr), + m_recordAction(nullptr), + m_recordAccompanyAction(nullptr), + m_stopAction(nullptr) { m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu); + m_toolBar->setMovable(false); auto addButton = [this](const char* pixmap_name, QString text, QString objectName) { - ToolButton* button = new ToolButton(embed::getIconPixmap(pixmap_name), text); - button->setObjectName(objectName); - m_toolBar->addWidget(button); - return button; + QAction* action = m_toolBar->addAction(embed::getIconPixmap(pixmap_name), text); + m_toolBar->widgetForAction(action)->setObjectName(objectName); + return action; }; // Set up play button - m_playButton = addButton("play", tr("Play (Space)"), "playButton"); - m_playButton->setShortcut(Qt::Key_Space); + m_playAction = addButton("play", tr("Play (Space)"), "playButton"); + m_playAction->setShortcut(Qt::Key_Space); // Set up record buttons if wanted if (record) { - m_recordButton = addButton("record", tr("Record"), "recordButton"); - m_recordAccompanyButton = addButton("record_accompany", tr("Record while playing"), "recordAccompanyButton"); + m_recordAction = addButton("record", tr("Record"), "recordButton"); + m_recordAccompanyAction = addButton("record_accompany", tr("Record while playing"), "recordAccompanyButton"); } // Set up stop button - m_stopButton = addButton("stop", tr("Stop (Space)"), "stopButton"); + m_stopAction = addButton("stop", tr("Stop (Space)"), "stopButton"); // Add toolbar to window addToolBar(Qt::TopToolBarArea, m_toolBar); // Set up connections - connect(m_playButton, SIGNAL(clicked()), this, SLOT(play())); + connect(m_playAction, SIGNAL(triggered()), this, SLOT(play())); if (record) { - connect(m_recordButton, SIGNAL(clicked()), this, SLOT(record())); - connect(m_recordAccompanyButton, SIGNAL(clicked()), this, SLOT(recordAccompany())); + connect(m_recordAction, SIGNAL(triggered()), this, SLOT(record())); + connect(m_recordAccompanyAction, SIGNAL(triggered()), this, SLOT(recordAccompany())); } - connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop())); + connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stop())); } Editor::~Editor() diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index 81cb01ae7..8c66eb6f8 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -3978,28 +3978,28 @@ PianoRollWindow::PianoRollWindow() : { setCentralWidget(m_editor); - m_playButton->setToolTip(tr("Play/pause current pattern (Space)")); - m_recordButton->setToolTip(tr("Record notes from MIDI-device/channel-piano")); - m_recordAccompanyButton->setToolTip(tr("Record notes from MIDI-device/channel-piano while playing song or BB track")); - m_stopButton->setToolTip(tr("Stop playing of current pattern (Space)")); + m_playAction->setToolTip(tr("Play/pause current pattern (Space)")); + m_recordAction->setToolTip(tr("Record notes from MIDI-device/channel-piano")); + m_recordAccompanyAction->setToolTip(tr("Record notes from MIDI-device/channel-piano while playing song or BB track")); + m_stopAction->setToolTip(tr("Stop playing of current pattern (Space)")); - m_playButton->setWhatsThis( + m_playAction->setWhatsThis( tr( "Click here to play the current pattern. " "This is useful while editing it. The pattern is " "automatically looped when its end is reached." ) ); - m_recordButton->setWhatsThis( + m_recordAction->setWhatsThis( tr( "Click here to record notes from a MIDI-" "device or the virtual test-piano of the according " "channel-window to the current pattern. When recording " "all notes you play will be written to this pattern " "and you can play and edit them afterwards." ) ); - m_recordAccompanyButton->setWhatsThis( + m_recordAccompanyAction->setWhatsThis( tr( "Click here to record notes from a MIDI-" "device or the virtual test-piano of the according " "channel-window to the current pattern. When recording " "all notes you play will be written to this pattern " "and you will hear the song or BB track in the background." ) ); - m_stopButton->setWhatsThis( + m_stopAction->setWhatsThis( tr( "Click here to stop playback of current pattern." ) ); // init edit-buttons at the top diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index adb6747c8..3b63a4bf0 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -611,13 +611,13 @@ SongEditorWindow::SongEditorWindow(Song* song) : setCentralWidget(m_editor); // Set up buttons - m_playButton->setToolTip(tr("Play song (Space)")); - if (m_recordButton && m_recordAccompanyButton) + m_playAction->setToolTip(tr("Play song (Space)")); + if (m_recordAction && m_recordAccompanyAction) { - m_recordButton->setToolTip(tr("Record samples from Audio-device")); - m_recordAccompanyButton->setToolTip(tr( "Record samples from Audio-device while playing song or BB track")); + m_recordAction->setToolTip(tr("Record samples from Audio-device")); + m_recordAccompanyAction->setToolTip(tr( "Record samples from Audio-device while playing song or BB track")); } - m_stopButton->setToolTip(tr( "Stop song (Space)" )); + m_stopAction->setToolTip(tr( "Stop song (Space)" )); m_addBBTrackButton = new ToolButton( embed::getIconPixmap("add_bb_track"), @@ -649,11 +649,11 @@ SongEditorWindow::SongEditorWindow(Song* song) : tool_button_group->addButton(m_editModeButton); tool_button_group->setExclusive(true); - m_playButton->setWhatsThis( + m_playAction->setWhatsThis( tr("Click here, if you want to play your whole song. " "Playing will be started at the song-position-marker (green). " "You can also move it while playing.")); - m_stopButton->setWhatsThis( + m_stopAction->setWhatsThis( tr("Click here, if you want to stop playing of your song. " "The song-position-marker will be set to the start of your song.")); From 968e581844250680f9706ca11264cb49990b3855 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 22:25:52 +0100 Subject: [PATCH 15/32] Editors: Don't use ToolButton --- include/AutomationEditor.h | 21 +++-- include/BBEditor.h | 1 - include/PianoRoll.h | 15 ++-- include/SongEditor.h | 11 ++- src/gui/AutomationEditor.cpp | 144 +++++++++++++++-------------------- src/gui/BBEditor.cpp | 38 +++------ src/gui/PianoRoll.cpp | 109 ++++++++++++-------------- src/gui/SongEditor.cpp | 56 +++++++------- 8 files changed, 168 insertions(+), 227 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index d203ac25e..97ea48572 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -45,7 +45,6 @@ class QScrollBar; class ComboBox; class NotePlayHandle; class Timeline; -class ToolButton; @@ -277,19 +276,19 @@ protected slots: void stop(); private: - QAbstractButton * m_drawButton; - QAbstractButton * m_eraseButton; - QAbstractButton * m_selectButton; - QAbstractButton * m_moveButton; + QAction* m_drawAction; + QAction* m_eraseAction; + QAction* m_selectAction; + QAction* m_moveAction; - ToolButton * m_discreteButton; - ToolButton * m_linearButton; - ToolButton * m_cubicHermiteButton; + QAction* m_discreteAction; + QAction* m_linearAction; + QAction* m_cubicHermiteAction; Knob * m_tensionKnob; - ToolButton * m_cutButton; - ToolButton * m_copyButton; - ToolButton * m_pasteButton; + QAction * m_cutAction; + QAction * m_copyAction; + QAction * m_pasteAction; ComboBox * m_zoomingXComboBox; ComboBox * m_zoomingYComboBox; diff --git a/include/BBEditor.h b/include/BBEditor.h index d13d1cc45..3f9122445 100644 --- a/include/BBEditor.h +++ b/include/BBEditor.h @@ -32,7 +32,6 @@ class BBTrackContainer; class ComboBox; -class ToolButton; class BBTrackContainerView; diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 0d87c752a..0adc98e86 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -49,7 +49,6 @@ class ComboBox; class NotePlayHandle; class Pattern; class Timeline; -class ToolButton; class PianoRoll : public QWidget { @@ -387,14 +386,14 @@ signals: private: PianoRoll* m_editor; - ToolButton * m_drawButton; - ToolButton * m_eraseButton; - ToolButton * m_selectButton; - ToolButton * m_detuneButton; + QAction* m_drawAction; + QAction* m_eraseAction; + QAction* m_selectAction; + QAction* m_detuneAction; - ToolButton * m_cutButton; - ToolButton * m_copyButton; - ToolButton * m_pasteButton; + QAction* m_cutAction; + QAction* m_copyAction; + QAction* m_pasteAction; ComboBox * m_zoomingComboBox; ComboBox * m_quantizeComboBox; diff --git a/include/SongEditor.h b/include/SongEditor.h index 4f523dbb2..44a0c5b2f 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -41,7 +41,6 @@ class MeterDialog; class Song; class TextFloat; class Timeline; -class ToolButton; class positionLine : public QWidget { @@ -148,12 +147,12 @@ protected slots: void stop(); private: - ToolButton * m_addBBTrackButton; - ToolButton * m_addSampleTrackButton; - ToolButton * m_addAutomationTrackButton; + QAction* m_addBBTrackAction; + QAction* m_addSampleTrackAction; + QAction* m_addAutomationTrackAction; - ToolButton * m_drawModeButton; - ToolButton * m_editModeButton; + QAction* m_drawModeAction; + QAction* m_selectModeAction; ComboBox * m_zoomingComboBox; }; diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index abf0e3225..b1d1d49f9 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -57,7 +57,6 @@ #include "gui_templates.h" #include "Timeline.h" #include "ToolTip.h" -#include "ToolButton.h" #include "TextFloat.h" #include "ComboBox.h" #include "BBTrackContainer.h" @@ -2041,17 +2040,19 @@ AutomationEditorWindow::AutomationEditorWindow() : "current pattern." ) ); // Edit mode buttons + QActionGroup * tool_action_group = new QActionGroup(this); - m_drawButton = new ToolButton(embed::getIconPixmap( "edit_draw" ), - tr( "Draw mode (Shift+D)" )); - m_drawButton->setCheckable( true ); - m_drawButton->setChecked( true ); - m_drawButton->setShortcut(Qt::SHIFT | Qt::Key_D); + m_drawAction = new QAction(embed::getIconPixmap("edit_draw"), + tr("Draw mode (Shift+D)"), tool_action_group); + m_drawAction->setCheckable(true); + m_drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); - m_eraseButton = new ToolButton( embed::getIconPixmap( "edit_erase" ), - tr( "Erase mode (Shift+E)" )); - m_eraseButton->setCheckable( true ); - m_eraseButton->setShortcut(Qt::SHIFT | Qt::Key_E); + m_eraseAction = new QAction(embed::getIconPixmap("edit_erase"), + tr("Erase mode (Shift+E)"), tool_action_group); + m_eraseAction->setCheckable(true); + m_eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); + + m_drawAction->setChecked(true); //TODO: m_selectButton and m_moveButton are broken. /*m_selectButton = new ToolButton( embed::getIconPixmap( @@ -2068,32 +2069,30 @@ AutomationEditorWindow::AutomationEditorWindow() : m_moveButton->setCheckable( true );*/ QSignalMapper* signalmapper = new QSignalMapper(this); - signalmapper->setMapping(m_drawButton, AutomationEditor::DRAW); - signalmapper->setMapping(m_eraseButton, AutomationEditor::ERASE); + signalmapper->setMapping(m_drawAction, AutomationEditor::DRAW); + signalmapper->setMapping(m_eraseAction, AutomationEditor::ERASE); // signalmapper->setMapping(m_selectButton, AutomationEditor::SELECT); // signalmapper->setMapping(m_moveButton, AutomationEditor::MOVE); - connect(m_drawButton, SIGNAL(clicked()), signalmapper, SLOT(map())); - connect(m_eraseButton, SIGNAL(clicked()), signalmapper, SLOT(map())); + connect(m_drawAction, SIGNAL(triggered()), signalmapper, SLOT(map())); + connect(m_eraseAction, SIGNAL(triggered()), signalmapper, SLOT(map())); // connect(m_selectButton, SIGNAL(triggered()), signalmapper, SLOT(map())); // connect(m_moveButton, SIGNAL(triggered()), signalmapper, SLOT(map())); connect(signalmapper, SIGNAL(mapped(int)), m_editor, SLOT(setEditMode(int))); - QButtonGroup * tool_button_group = new QButtonGroup(); - tool_button_group->addButton( m_drawButton ); - tool_button_group->addButton( m_eraseButton ); +// tool_action_group->addAction( m_drawButton ); +// tool_action_group->addAction( m_eraseButton ); //tool_button_group->addButton( m_selectButton ); //tool_button_group->addButton( m_moveButton ); - tool_button_group->setExclusive( true ); - m_drawButton->setWhatsThis( + m_drawAction->setWhatsThis( tr( "Click here and draw-mode will be activated. In this " "mode you can add and move single values. This " "is the default mode which is used most of the time. " "You can also press 'Shift+D' on your keyboard to " "activate this mode." ) ); - m_eraseButton->setWhatsThis( + m_eraseAction->setWhatsThis( tr( "Click here and erase-mode will be activated. In this " "mode you can erase single values. You can also press " "'Shift+E' on your keyboard to activate this mode." ) ); @@ -2112,90 +2111,69 @@ AutomationEditorWindow::AutomationEditorWindow() : // Progression type buttons + QActionGroup* progression_type_group = new QActionGroup(this); - m_discreteButton = new ToolButton( embed::getIconPixmap( - "progression_discrete" ), - tr( "Discrete progression" ), - m_editor, SLOT( setProgressionDiscrete() ), - m_toolBar ); - m_discreteButton->setCheckable( true ); - m_discreteButton->setChecked( true ); + m_discreteAction = new QAction(embed::getIconPixmap("progression_discrete"), + tr("Discrete progression"), progression_type_group); + m_linearAction = new QAction(embed::getIconPixmap("progression_linear"), + tr("Linear progression"), progression_type_group); + m_cubicHermiteAction = new QAction(embed::getIconPixmap("progression_cubic_hermite"), + tr( "Cubic Hermite progression"), progression_type_group); - m_linearButton = new ToolButton( embed::getIconPixmap( - "progression_linear" ), - tr( "Linear progression" ), - m_editor, SLOT( setProgressionLinear() ), - m_toolBar ); - m_linearButton->setCheckable( true ); + m_linearAction->setCheckable( true ); + m_cubicHermiteAction->setCheckable( true ); + m_discreteAction->setCheckable( true ); + m_discreteAction->setChecked( true ); - m_cubicHermiteButton = new ToolButton( embed::getIconPixmap( - "progression_cubic_hermite" ), - tr( "Cubic Hermite progression" ), - m_editor, SLOT( - setProgressionHermite() ), - m_toolBar ); - m_cubicHermiteButton->setCheckable( true ); + connect(m_discreteAction, SIGNAL(triggered()), m_editor, SLOT(setProgressionDiscrete())); + connect(m_linearAction, SIGNAL(triggered()), m_editor, SLOT(setProgressionLinear())); + connect(m_cubicHermiteAction, SIGNAL(triggered()), m_editor, SLOT(setProgressionHermite())); // setup tension-stuff m_tensionKnob = new Knob( knobSmall_17, this, "Tension" ); - tool_button_group = new QButtonGroup( this ); - tool_button_group->addButton( m_discreteButton ); - tool_button_group->addButton( m_linearButton ); - tool_button_group->addButton( m_cubicHermiteButton ); - tool_button_group->setExclusive( true ); - - m_discreteButton->setWhatsThis( + m_discreteAction->setWhatsThis( tr( "Click here to choose discrete progressions for this " "automation pattern. The value of the connected " "object will remain constant between control points " "and be set immediately to the new value when each " "control point is reached." ) ); - m_linearButton->setWhatsThis( + m_linearAction->setWhatsThis( tr( "Click here to choose linear progressions for this " "automation pattern. The value of the connected " "object will change at a steady rate over time " "between control points to reach the correct value at " "each control point without a sudden change." ) ); - m_cubicHermiteButton->setWhatsThis( + m_cubicHermiteAction->setWhatsThis( tr( "Click here to choose cubic hermite progressions for this " "automation pattern. The value of the connected " "object will change in a smooth curve and ease in to " "the peaks and valleys." ) ); - - // Copy paste buttons - m_cutButton = new ToolButton( embed::getIconPixmap( "edit_cut" ), - tr( "Cut selected values (Ctrl+X)" ), - m_editor, SLOT( cutSelectedValues() ), - m_toolBar ); + m_cutAction = new QAction(embed::getIconPixmap("edit_cut"), + tr("Cut selected values (Ctrl+X)"), this); + m_copyAction = new QAction(embed::getIconPixmap("edit_copy"), + tr("Copy selected values (Ctrl+C)"), this); + m_pasteAction = new QAction(embed::getIconPixmap("edit_paste"), + tr("Paste values from clipboard Ctrl+V)"), this); - m_copyButton = new ToolButton( embed::getIconPixmap( "edit_copy" ), - tr( "Copy selected values (Ctrl+C)" ), - m_editor, SLOT( copySelectedValues() ), - m_toolBar ); - - m_pasteButton = new ToolButton( embed::getIconPixmap( "edit_paste" ), - tr( "Paste values from clipboard " - "(Ctrl+V)" ), - m_editor, SLOT( pasteValues() ), - m_toolBar ); - - m_cutButton->setWhatsThis( + m_cutAction->setWhatsThis( tr( "Click here and selected values will be cut into the " "clipboard. You can paste them anywhere in any pattern " "by clicking on the paste button." ) ); - m_copyButton->setWhatsThis( + m_copyAction->setWhatsThis( tr( "Click here and selected values will be copied into " "the clipboard. You can paste them anywhere in any " "pattern by clicking on the paste button." ) ); - m_pasteButton->setWhatsThis( + m_pasteAction->setWhatsThis( tr( "Click here and the values from the clipboard will be " "pasted at the first visible measure." ) ); - + connect(m_cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedValues())); + connect(m_copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedValues())); + connect(m_pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteValues())); // Zoom controls @@ -2249,21 +2227,21 @@ AutomationEditorWindow::AutomationEditorWindow() : m_toolBar->addSeparator();; - m_toolBar->addWidget( m_drawButton ); - m_toolBar->addWidget( m_eraseButton ); - //m_toolBar->addWidget( m_selectButton ); - //m_toolBar->addWidget( m_moveButton ); + m_toolBar->addAction(m_drawAction); + m_toolBar->addAction(m_eraseAction); + //m_toolBar->addAction(m_selectButton); + //m_toolBar->addAction(m_moveButton); m_toolBar->addSeparator(); - m_toolBar->addWidget( m_discreteButton ); - m_toolBar->addWidget( m_linearButton ); - m_toolBar->addWidget( m_cubicHermiteButton ); + m_toolBar->addAction(m_discreteAction); + m_toolBar->addAction(m_linearAction); + m_toolBar->addAction(m_cubicHermiteAction); m_toolBar->addSeparator(); m_toolBar->addWidget( new QLabel( tr("Tension: "), m_toolBar )); m_toolBar->addWidget( m_tensionKnob ); m_toolBar->addSeparator(); - m_toolBar->addWidget( m_cutButton ); - m_toolBar->addWidget( m_copyButton ); - m_toolBar->addWidget( m_pasteButton ); + m_toolBar->addAction( m_cutAction ); + m_toolBar->addAction( m_copyAction ); + m_toolBar->addAction( m_pasteAction ); m_toolBar->addSeparator(); m_editor->m_timeLine->addToolButtons(m_toolBar); m_toolBar->addSeparator(); @@ -2298,13 +2276,13 @@ void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern) switch(m_editor->m_pattern->progressionType()) { case AutomationPattern::DiscreteProgression: - m_discreteButton->setChecked(true); + m_discreteAction->setChecked(true); break; case AutomationPattern::LinearProgression: - m_linearButton->setChecked(true); + m_linearAction->setChecked(true); break; case AutomationPattern::CubicHermiteProgression: - m_cubicHermiteButton->setChecked(true); + m_cubicHermiteAction->setChecked(true); break; } diff --git a/src/gui/BBEditor.cpp b/src/gui/BBEditor.cpp index 03499cb87..64a6d1f7c 100644 --- a/src/gui/BBEditor.cpp +++ b/src/gui/BBEditor.cpp @@ -33,7 +33,6 @@ #include "embed.h" #include "MainWindow.h" #include "Song.h" -#include "ToolButton.h" #include "ConfigManager.h" #include "DataFile.h" #include "StringPairDrag.h" @@ -68,28 +67,6 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : m_playAction->setToolTip(tr( "Play/pause current beat/bassline (Space)" )); m_stopAction->setToolTip(tr( "Stop playback of current beat/bassline (Space)" )); - ToolButton * add_bb_track = new ToolButton( - embed::getIconPixmap( "add_bb_track" ), - tr( "Add beat/bassline" ), - Engine::getSong(), SLOT( addBBTrack() ), - m_toolBar ); - - ToolButton * add_automation_track = new ToolButton( - embed::getIconPixmap( "add_automation" ), - tr( "Add automation-track" ), - m_trackContainerView, SLOT( addAutomationTrack() ), m_toolBar ); - - ToolButton * remove_bar = new ToolButton( - embed::getIconPixmap( "step_btn_remove" ), - tr( "Remove steps" ), - m_trackContainerView, SLOT( removeSteps() ), m_toolBar ); - - ToolButton * add_bar = new ToolButton( - embed::getIconPixmap( "step_btn_add" ), - tr( "Add steps" ), - m_trackContainerView, SLOT( addSteps() ), m_toolBar ); - - m_playAction->setWhatsThis( tr( "Click here to play the current " "beat/bassline. The beat/bassline is automatically " @@ -104,14 +81,21 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : m_toolBar->addSeparator(); m_toolBar->addWidget( m_bbComboBox ); + m_toolBar->addSeparator(); - m_toolBar->addWidget( add_bb_track ); - m_toolBar->addWidget( add_automation_track ); + m_toolBar->addAction(embed::getIconPixmap("add_bb_track"), tr("Add beat/bassline"), + Engine::getSong(), SLOT(addBBTrack())); + m_toolBar->addAction(embed::getIconPixmap("add_automation"), tr("Add automation-track"), + m_trackContainerView, SLOT(addAutomationTrack())); + QWidget* stretch = new QWidget(m_toolBar); stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_toolBar->addWidget(stretch); - m_toolBar->addWidget( remove_bar ); - m_toolBar->addWidget( add_bar ); + + m_toolBar->addAction(embed::getIconPixmap("step_btn_remove"), tr("Remove steps"), + m_trackContainerView, SLOT(removeSteps())); + m_toolBar->addAction(embed::getIconPixmap("step_btn_add"), tr("Add steps"), + m_trackContainerView, SLOT(addSteps())); m_toolBar->addSeparator(); connect( &tc->m_bbComboBoxModel, SIGNAL( dataChanged() ), diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index 8c66eb6f8..6cc05f644 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -66,7 +66,6 @@ #include "templates.h" #include "TextFloat.h" #include "Timeline.h" -#include "ToolButton.h" #include "TextFloat.h" @@ -4003,94 +4002,82 @@ PianoRollWindow::PianoRollWindow() : tr( "Click here to stop playback of current pattern." ) ); // init edit-buttons at the top - m_drawButton = new ToolButton( embed::getIconPixmap( "edit_draw" ), - tr( "Draw mode (Shift+D)" ), - m_editor, SLOT( drawButtonToggled() ), - m_toolBar ); - m_drawButton->setShortcut(Qt::SHIFT | Qt::Key_D); - m_drawButton->setCheckable( true ); - m_drawButton->setChecked( true ); + QActionGroup* tool_button_group = new QActionGroup(this); + m_drawAction = new QAction(embed::getIconPixmap("edit_draw"), + tr( "Draw mode (Shift+D)" ), tool_button_group); + m_drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); + m_drawAction->setCheckable( true ); + m_drawAction->setChecked( true ); - m_eraseButton = new ToolButton( embed::getIconPixmap( "edit_erase" ), - tr( "Erase mode (Shift+E)" ), - m_editor, SLOT( eraseButtonToggled() ), - m_toolBar ); - m_eraseButton->setShortcut(Qt::SHIFT | Qt::Key_E); - m_eraseButton->setCheckable( true ); + m_eraseAction = new QAction(embed::getIconPixmap("edit_erase"), + tr("Erase mode (Shift+E)"), tool_button_group); + m_eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); + m_eraseAction->setCheckable( true ); - m_selectButton = new ToolButton( embed::getIconPixmap( - "edit_select" ), - tr( "Select mode (Shift+S)" ), - m_editor, SLOT( selectButtonToggled() ), - m_toolBar ); - m_selectButton->setShortcut(Qt::SHIFT | Qt::Key_S); - m_selectButton->setCheckable( true ); + m_selectAction = new QAction( embed::getIconPixmap("edit_select"), + tr("Select mode (Shift+S)"), tool_button_group); + m_selectAction->setShortcut(Qt::SHIFT | Qt::Key_S); + m_selectAction->setCheckable( true ); - m_detuneButton = new ToolButton( embed::getIconPixmap( "automation"), - tr( "Detune mode (Shift+T)" ), - m_editor, SLOT( detuneButtonToggled() ), - m_toolBar ); - m_detuneButton->setShortcut(Qt::SHIFT | Qt::Key_T); - m_detuneButton->setCheckable( true ); + m_detuneAction = new QAction(embed::getIconPixmap("automation"), + tr("Detune mode (Shift+T)"), tool_button_group); + m_detuneAction->setShortcut(Qt::SHIFT | Qt::Key_T); + m_detuneAction->setCheckable( true ); - QButtonGroup * tool_button_group = new QButtonGroup( this ); - tool_button_group->addButton( m_drawButton ); - tool_button_group->addButton( m_eraseButton ); - tool_button_group->addButton( m_selectButton ); - tool_button_group->addButton( m_detuneButton ); - tool_button_group->setExclusive( true ); - - m_drawButton->setWhatsThis( + m_drawAction->setWhatsThis( tr( "Click here and draw mode will be activated. In this " "mode you can add, resize and move notes. This " "is the default mode which is used most of the time. " "You can also press 'Shift+D' on your keyboard to " "activate this mode. In this mode, hold Ctrl to " "temporarily go into select mode." ) ); - m_eraseButton->setWhatsThis( + m_eraseAction->setWhatsThis( tr( "Click here and erase mode will be activated. In this " "mode you can erase notes. You can also press " "'Shift+E' on your keyboard to activate this mode." ) ); - m_selectButton->setWhatsThis( + m_selectAction->setWhatsThis( tr( "Click here and select mode will be activated. " "In this mode you can select notes. Alternatively, " "you can hold Ctrl in draw mode to temporarily use " "select mode." ) ); - m_detuneButton->setWhatsThis( + m_detuneAction->setWhatsThis( tr( "Click here and detune mode will be activated. " "In this mode you can click a note to open its " "automation detuning. You can utilize this to slide " "notes from one to another. You can also press " "'Shift+T' on your keyboard to activate this mode." ) ); - m_cutButton = new ToolButton( embed::getIconPixmap( "edit_cut" ), - tr( "Cut selected notes (Ctrl+X)" ), - m_editor, SLOT( cutSelectedNotes() ), - m_toolBar ); + connect(m_drawAction, SIGNAL(triggered()), m_editor, SLOT(drawButtonToggled())); + connect(m_eraseAction, SIGNAL(triggered()), m_editor, SLOT(eraseButtonToggled())); + connect(m_selectAction, SIGNAL(triggered()), m_editor, SLOT(selectButtonToggled())); + connect(m_detuneAction, SIGNAL(triggered()), m_editor, SLOT(detuneButtonToggled())); - m_copyButton = new ToolButton( embed::getIconPixmap( "edit_copy" ), - tr( "Copy selected notes (Ctrl+C)" ), - m_editor, SLOT( copySelectedNotes() ), - m_toolBar ); + // Copy + paste actions + m_cutAction = new QAction(embed::getIconPixmap("edit_cut"), + tr("Cut selected notes (Ctrl+X)"), this); - m_pasteButton = new ToolButton( embed::getIconPixmap( "edit_paste" ), - tr( "Paste notes from clipboard " - "(Ctrl+V)" ), - m_editor, SLOT( pasteNotes() ), - m_toolBar ); + m_copyAction = new QAction(embed::getIconPixmap("edit_copy"), + tr("Copy selected notes (Ctrl+C)"), this); - m_cutButton->setWhatsThis( + m_pasteAction = new QAction(embed::getIconPixmap("edit_paste"), + tr("Paste notes from clipboard (Ctrl+V)"), this); + + m_cutAction->setWhatsThis( tr( "Click here and the selected notes will be cut into the " "clipboard. You can paste them anywhere in any pattern " "by clicking on the paste button." ) ); - m_copyButton->setWhatsThis( + m_copyAction->setWhatsThis( tr( "Click here and the selected notes will be copied into the " "clipboard. You can paste them anywhere in any pattern " "by clicking on the paste button." ) ); - m_pasteButton->setWhatsThis( + m_pasteAction->setWhatsThis( tr( "Click here and the notes from the clipboard will be " "pasted at the first visible measure." ) ); + connect(m_cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedNotes())); + connect(m_copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedNotes())); + connect(m_pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteNotes())); + QLabel * zoom_lbl = new QLabel( m_toolBar ); zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) ); @@ -4134,15 +4121,15 @@ PianoRollWindow::PianoRollWindow() : m_toolBar->addSeparator(); - m_toolBar->addWidget( m_drawButton ); - m_toolBar->addWidget( m_eraseButton ); - m_toolBar->addWidget( m_selectButton ); - m_toolBar->addWidget( m_detuneButton ); + m_toolBar->addAction( m_drawAction ); + m_toolBar->addAction( m_eraseAction ); + m_toolBar->addAction( m_selectAction ); + m_toolBar->addAction( m_detuneAction ); m_toolBar->addSeparator(); - m_toolBar->addWidget( m_cutButton ); - m_toolBar->addWidget( m_copyButton ); - m_toolBar->addWidget( m_pasteButton ); + m_toolBar->addAction( m_cutAction ); + m_toolBar->addAction( m_copyAction ); + m_toolBar->addAction( m_pasteAction ); m_toolBar->addSeparator(); m_editor->m_timeLine->addToolButtons(m_toolBar); diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index 3b63a4bf0..ebd6842f7 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -46,7 +46,6 @@ #include "MeterDialog.h" #include "TextFloat.h" #include "Timeline.h" -#include "ToolButton.h" #include "ToolTip.h" #include "VisualizationWidget.h" #include "TimeDisplayWidget.h" @@ -619,35 +618,32 @@ SongEditorWindow::SongEditorWindow(Song* song) : } m_stopAction->setToolTip(tr( "Stop song (Space)" )); - m_addBBTrackButton = new ToolButton( - embed::getIconPixmap("add_bb_track"), - tr("Add beat/bassline"), - m_editor->m_song, SLOT(addBBTrack())); + m_addBBTrackAction = new QAction(embed::getIconPixmap("add_bb_track"), + tr("Add beat/bassline"), this); - m_addSampleTrackButton = new ToolButton( - embed::getIconPixmap("add_sample_track" ), - tr( "Add sample-track"), - m_editor->m_song, SLOT(addSampleTrack())); + m_addSampleTrackAction = new QAction(embed::getIconPixmap("add_sample_track"), + tr("Add sample-track"), this); - m_addAutomationTrackButton = new ToolButton( - embed::getIconPixmap("add_automation" ), - tr( "Add automation-track"), - m_editor->m_song, SLOT(addAutomationTrack())); + m_addAutomationTrackAction = new QAction(embed::getIconPixmap("add_automation"), + tr("Add automation-track"), this); - m_drawModeButton = new ToolButton(embed::getIconPixmap("edit_draw"), - tr("Draw mode"), m_editor, SLOT(setEditModeDraw())); - m_drawModeButton->setCheckable(true); - m_drawModeButton->setChecked(true); + connect(m_addBBTrackAction, SIGNAL(triggered()), m_editor->m_song, SLOT(addBBTrack())); + connect(m_addSampleTrackAction, SIGNAL(triggered()), m_editor->m_song, SLOT(addSampleTrack())); + connect(m_addAutomationTrackAction, SIGNAL(triggered()), m_editor->m_song, SLOT(addAutomationTrack())); - m_editModeButton = new ToolButton(embed::getIconPixmap("edit_select"), - tr("Edit mode (select and move)"), - m_editor, SLOT(setEditModeSelect())); - m_editModeButton->setCheckable(true); + QActionGroup* tool_action_group = new QActionGroup(this); + m_drawModeAction = new QAction(embed::getIconPixmap("edit_draw"), + tr("Draw mode"), tool_action_group); + m_drawModeAction->setCheckable(true); + m_drawModeAction->setChecked(true); + + m_selectModeAction = new QAction(embed::getIconPixmap("edit_select"), + tr("Edit mode (select and move)"), tool_action_group); + m_selectModeAction->setCheckable(true); + + connect(m_drawModeAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeDraw())); + connect(m_selectModeAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeSelect())); - QButtonGroup * tool_button_group = new QButtonGroup(this); - tool_button_group->addButton(m_drawModeButton); - tool_button_group->addButton(m_editModeButton); - tool_button_group->setExclusive(true); m_playAction->setWhatsThis( tr("Click here, if you want to play your whole song. " @@ -669,12 +665,12 @@ SongEditorWindow::SongEditorWindow(Song* song) : m_toolBar->addSeparator(); - m_toolBar->addWidget( m_addBBTrackButton ); - m_toolBar->addWidget( m_addSampleTrackButton ); - m_toolBar->addWidget( m_addAutomationTrackButton ); + m_toolBar->addAction( m_addBBTrackAction ); + m_toolBar->addAction( m_addSampleTrackAction ); + m_toolBar->addAction( m_addAutomationTrackAction ); m_toolBar->addSeparator(); - m_toolBar->addWidget( m_drawModeButton ); - m_toolBar->addWidget( m_editModeButton ); + m_toolBar->addAction( m_drawModeAction ); + m_toolBar->addAction( m_selectModeAction ); m_toolBar->addSeparator(); m_editor->m_timeLine->addToolButtons(m_toolBar); m_toolBar->addSeparator(); From b661e0871b7b323696c089f9cacf30f4072a0266 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 22:33:37 +0100 Subject: [PATCH 16/32] PianoRoll: Slot renames --- include/PianoRoll.h | 26 ++++++++++++++------------ src/gui/PianoRoll.cpp | 38 ++++++-------------------------------- 2 files changed, 20 insertions(+), 44 deletions(-) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 0adc98e86..e190a0e6d 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -58,6 +58,14 @@ class PianoRoll : public QWidget Q_PROPERTY( QColor noteColor READ noteColor WRITE setNoteColor ) Q_PROPERTY( QColor barColor READ barColor WRITE setBarColor ) public: + enum editModes + { + ModeDraw, + ModeErase, + ModeSelect, + ModeEditDetuning, + }; + /*! \brief Resets settings to default when e.g. creating a new project */ void reset(); @@ -97,6 +105,7 @@ public: QColor barColor() const; void setBarColor( const QColor & _c ); + protected: virtual void keyPressEvent( QKeyEvent * _ke ); virtual void keyReleaseEvent( QKeyEvent * _ke ); @@ -131,10 +140,11 @@ protected slots: void horScrolled( int _new_pos ); void verScrolled( int _new_pos ); - void drawButtonToggled(); - void eraseButtonToggled(); - void selectButtonToggled(); - void detuneButtonToggled(); + void setEditMode(editModes mode); + void setEditModeDraw() {setEditMode(ModeDraw); } + void setEditModeErase() {setEditMode(ModeErase); } + void setEditModeSelect() {setEditMode(ModeSelect); } + void setEditModeDetune() {setEditMode(ModeEditDetuning); } void copySelectedNotes(); void cutSelectedNotes(); @@ -162,14 +172,6 @@ signals: private: - enum editModes - { - ModeDraw, - ModeErase, - ModeSelect, - ModeEditDetuning, - }; - enum actions { ActionNone, diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index 6cc05f644..e864bfd5d 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -3459,40 +3459,14 @@ void PianoRoll::verScrolled( int _new_pos ) -void PianoRoll::drawButtonToggled() +void PianoRoll::setEditMode(PianoRoll::editModes mode) { - m_editMode = ModeDraw; - update(); + m_editMode = mode; } -void PianoRoll::eraseButtonToggled() -{ - m_editMode = ModeErase; - update(); -} - - - - -void PianoRoll::selectButtonToggled() -{ - m_editMode = ModeSelect; - update(); -} - - - -void PianoRoll::detuneButtonToggled() -{ - m_editMode = ModeEditDetuning; - update(); -} - - - void PianoRoll::selectAll() { if( hasValidPattern() == false ) @@ -4047,10 +4021,10 @@ PianoRollWindow::PianoRollWindow() : "notes from one to another. You can also press " "'Shift+T' on your keyboard to activate this mode." ) ); - connect(m_drawAction, SIGNAL(triggered()), m_editor, SLOT(drawButtonToggled())); - connect(m_eraseAction, SIGNAL(triggered()), m_editor, SLOT(eraseButtonToggled())); - connect(m_selectAction, SIGNAL(triggered()), m_editor, SLOT(selectButtonToggled())); - connect(m_detuneAction, SIGNAL(triggered()), m_editor, SLOT(detuneButtonToggled())); + connect(m_drawAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeDraw())); + connect(m_eraseAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeErase())); + connect(m_selectAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeSelect())); + connect(m_detuneAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeDetune())); // Copy + paste actions m_cutAction = new QAction(embed::getIconPixmap("edit_cut"), From 47cbc9e7f92833ec223061789ed1a68969b1b15c Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 22:58:11 +0100 Subject: [PATCH 17/32] AutomationEditor + PianoRoll: Move Copy/Paste shortcuts --- src/gui/AutomationEditor.cpp | 50 ++++++++---------------------------- src/gui/PianoRoll.cpp | 40 +++-------------------------- 2 files changed, 14 insertions(+), 76 deletions(-) diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index b1d1d49f9..9838140ea 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -324,29 +324,6 @@ void AutomationEditor::keyPressEvent( QKeyEvent * _ke ) _ke->accept(); break; - case Qt::Key_C: - if( _ke->modifiers() & Qt::ControlModifier ) - { - copySelectedValues(); - _ke->accept(); - } - break; - - case Qt::Key_X: - if( _ke->modifiers() & Qt::ControlModifier ) - { - cutSelectedValues(); - _ke->accept(); - } - break; - - case Qt::Key_V: - if( _ke->modifiers() & Qt::ControlModifier ) - { - pasteValues(); - _ke->accept(); - } - break; //TODO: m_selectButton and m_moveButton are broken. /*case Qt::Key_A: if( _ke->modifiers() & Qt::ControlModifier ) @@ -363,18 +340,6 @@ void AutomationEditor::keyPressEvent( QKeyEvent * _ke ) _ke->accept(); break;*/ - case Qt::Key_Space: - if( Engine::getSong()->isPlaying() ) - { - stop(); - } - else - { - play(); - } - _ke->accept(); - break; - case Qt::Key_Home: m_timeLine->pos().setTicks( 0 ); m_timeLine->updatePosition(); @@ -2171,6 +2136,10 @@ AutomationEditorWindow::AutomationEditorWindow() : tr( "Click here and the values from the clipboard will be " "pasted at the first visible measure." ) ); + m_cutAction->setShortcut(Qt::CTRL | Qt::Key_X); + m_copyAction->setShortcut(Qt::CTRL | Qt::Key_C); + m_pasteAction->setShortcut(Qt::CTRL | Qt::Key_V); + connect(m_cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedValues())); connect(m_copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedValues())); connect(m_pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteValues())); @@ -2229,8 +2198,8 @@ AutomationEditorWindow::AutomationEditorWindow() : m_toolBar->addSeparator();; m_toolBar->addAction(m_drawAction); m_toolBar->addAction(m_eraseAction); - //m_toolBar->addAction(m_selectButton); - //m_toolBar->addAction(m_moveButton); +// m_toolBar->addAction(m_selectButton); +// m_toolBar->addAction(m_moveButton); m_toolBar->addSeparator(); m_toolBar->addAction(m_discreteAction); m_toolBar->addAction(m_linearAction); @@ -2239,9 +2208,10 @@ AutomationEditorWindow::AutomationEditorWindow() : m_toolBar->addWidget( new QLabel( tr("Tension: "), m_toolBar )); m_toolBar->addWidget( m_tensionKnob ); m_toolBar->addSeparator(); - m_toolBar->addAction( m_cutAction ); - m_toolBar->addAction( m_copyAction ); - m_toolBar->addAction( m_pasteAction ); +// Select is broken +// m_toolBar->addAction( m_cutAction ); +// m_toolBar->addAction( m_copyAction ); +// m_toolBar->addAction( m_pasteAction ); m_toolBar->addSeparator(); m_editor->m_timeLine->addToolButtons(m_toolBar); m_toolBar->addSeparator(); diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index e864bfd5d..d7838b5a9 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -1032,30 +1032,6 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) event->accept(); break; - case Qt::Key_C: - if( event->modifiers() & Qt::ControlModifier ) - { - event->accept(); - copySelectedNotes(); - } - break; - - case Qt::Key_X: - if( event->modifiers() & Qt::ControlModifier ) - { - event->accept(); - cutSelectedNotes(); - } - break; - - case Qt::Key_V: - if( event->modifiers() & Qt::ControlModifier ) - { - event->accept(); - pasteNotes(); - } - break; - case Qt::Key_A: if( event->modifiers() & Qt::ControlModifier ) { @@ -1070,18 +1046,6 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) event->accept(); break; - case Qt::Key_Space: - if( Engine::getSong()->isPlaying() ) - { - stop(); - } - else - { - play(); - } - event->accept(); - break; - case Qt::Key_Home: m_timeLine->pos().setTicks( 0 ); m_timeLine->updatePosition(); @@ -4048,6 +4012,10 @@ PianoRollWindow::PianoRollWindow() : tr( "Click here and the notes from the clipboard will be " "pasted at the first visible measure." ) ); + m_cutAction->setShortcut(Qt::CTRL | Qt::Key_X); + m_copyAction->setShortcut(Qt::CTRL | Qt::Key_C); + m_pasteAction->setShortcut(Qt::CTRL | Qt::Key_V); + connect(m_cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedNotes())); connect(m_copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedNotes())); connect(m_pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteNotes())); From 409e8f2700eddc8287ac47feb056c2923db32749 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 23:36:02 +0100 Subject: [PATCH 18/32] AutomationEditor style updates --- include/AutomationEditor.h | 72 +++++------ src/gui/AutomationEditor.cpp | 224 +++++++++++++++++------------------ 2 files changed, 148 insertions(+), 148 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 97ea48572..6b7b7ae29 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -51,27 +51,27 @@ class Timeline; class AutomationEditor : public QWidget, public JournallingObject { Q_OBJECT - Q_PROPERTY( QColor gridColor READ gridColor WRITE setGridColor ) - Q_PROPERTY( QColor vertexColor READ vertexColor WRITE setVertexColor ) - Q_PROPERTY( QBrush scaleColor READ scaleColor WRITE setScaleColor ) - Q_PROPERTY( QBrush graphColor READ graphColor WRITE setGraphColor ) + Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor) + Q_PROPERTY(QColor vertexColor READ vertexColor WRITE setVertexColor) + Q_PROPERTY(QBrush scaleColor READ scaleColor WRITE setScaleColor) + Q_PROPERTY(QBrush graphColor READ graphColor WRITE setGraphColor) public: - void setCurrentPattern( AutomationPattern * _new_pattern ); + void setCurrentPattern(AutomationPattern * new_pattern); inline const AutomationPattern * currentPattern() const { - return( m_pattern ); + return m_pattern; } inline bool validPattern() const { - return( m_pattern != NULL ); + return m_pattern != nullptr; } int quantization() const; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + virtual void saveSettings(QDomDocument & doc, QDomElement & parent); + virtual void loadSettings(const QDomElement & parent); QString nodeName() const { return "automationeditor"; @@ -82,12 +82,12 @@ public: QBrush graphColor() const; QColor vertexColor() const; QBrush scaleColor() const; - void setGridColor( const QColor & c ); - void setGraphColor( const QBrush & c ); - void setVertexColor( const QColor & c ); - void setScaleColor( const QBrush & c ); + void setGridColor(const QColor& c); + void setGraphColor(const QBrush& c); + void setVertexColor(const QColor& c); + void setScaleColor(const QBrush& c); - enum editModes + enum EditModes { DRAW, ERASE, @@ -103,23 +103,23 @@ public slots: protected: typedef AutomationPattern::timeMap timeMap; - virtual void keyPressEvent( QKeyEvent * _ke ); - virtual void leaveEvent( QEvent * _e ); - virtual void mousePressEvent( QMouseEvent * _me ); - virtual void mouseReleaseEvent( QMouseEvent * _me ); - virtual void mouseMoveEvent( QMouseEvent * _me ); - virtual void paintEvent( QPaintEvent * _pe ); - virtual void resizeEvent( QResizeEvent * _re ); - virtual void wheelEvent( QWheelEvent * _we ); + virtual void keyPressEvent(QKeyEvent * ke); + virtual void leaveEvent(QEvent * e); + virtual void mousePressEvent(QMouseEvent * mouseEvent); + virtual void mouseReleaseEvent(QMouseEvent * mouseEvent); + virtual void mouseMoveEvent(QMouseEvent * mouseEvent); + virtual void paintEvent(QPaintEvent * pe); + virtual void resizeEvent(QResizeEvent * re); + virtual void wheelEvent(QWheelEvent * we); - float getLevel( int _y ); - int xCoordOfTick( int _tick ); - int yCoordOfLevel( float _level ); - inline void drawLevelTick( QPainter & _p, int _tick, - float _value, bool _is_selected ); + float getLevel( int y ); + int xCoordOfTick( int tick ); + int yCoordOfLevel( float level ); + inline void drawLevelTick( QPainter & p, int tick, + float value, bool is_selected ); void removeSelection(); void selectAll(); - void getSelectedValues( timeMap & _selected_values ); + void getSelectedValues(timeMap & selected_values ); void drawLine( int x0, float y0, int x1, float y1 ); @@ -127,10 +127,10 @@ protected slots: void play(); void stop(); - void horScrolled( int _new_pos ); - void verScrolled( int _new_pos ); + void horScrolled( int new_pos ); + void verScrolled( int new_pos ); - void setEditMode(AutomationEditor::editModes mode); + void setEditMode(AutomationEditor::EditModes mode); void setEditMode(int mode); void setProgressionType(AutomationPattern::ProgressionTypes type); @@ -144,7 +144,7 @@ protected slots: void pasteValues(); void deleteSelectedValues(); - void updatePosition( const MidiTime & _t ); + void updatePosition( const MidiTime & t ); void zoomingXChanged(); void zoomingYChanged(); @@ -152,7 +152,7 @@ protected slots: private: - enum actions + enum Actions { NONE, MOVE_VALUE, @@ -201,7 +201,7 @@ private: MidiTime m_currentPosition; - actions m_action; + Actions m_action; tick_t m_selectStartTick; tick_t m_selectedTick; @@ -223,13 +223,13 @@ private: timeMap m_selValuesForMove; - editModes m_editMode; + EditModes m_editMode; Timeline * m_timeLine; bool m_scrollBack; - void drawCross( QPainter & _p ); + void drawCross(QPainter & p ); void drawAutomationPoint( QPainter & p, timeMap::iterator it ); bool inBBEditor(); diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index 9838140ea..0599a9119 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -187,10 +187,10 @@ AutomationEditor::~AutomationEditor() -void AutomationEditor::setCurrentPattern( AutomationPattern * _new_pattern ) +void AutomationEditor::setCurrentPattern(AutomationPattern * new_pattern ) { m_patternMutex.lock(); - m_pattern = _new_pattern; + m_pattern = new_pattern; m_patternMutex.unlock(); emit currentPatternChanged(); @@ -199,17 +199,17 @@ void AutomationEditor::setCurrentPattern( AutomationPattern * _new_pattern ) -void AutomationEditor::saveSettings( QDomDocument & _doc, QDomElement & _this ) +void AutomationEditor::saveSettings(QDomDocument & doc, QDomElement & parent ) { - MainWindow::saveWidgetState( this, _this ); + MainWindow::saveWidgetState( this, parent ); } -void AutomationEditor::loadSettings( const QDomElement & _this ) +void AutomationEditor::loadSettings( const QDomElement & parent ) { - MainWindow::restoreWidgetState( this, _this ); + MainWindow::restoreWidgetState( this, parent ); } @@ -293,20 +293,20 @@ void AutomationEditor::removeSelection() -void AutomationEditor::keyPressEvent( QKeyEvent * _ke ) +void AutomationEditor::keyPressEvent(QKeyEvent * ke ) { - switch( _ke->key() ) + switch( ke->key() ) { case Qt::Key_Up: m_topBottomScroll->setValue( m_topBottomScroll->value() - 1 ); - _ke->accept(); + ke->accept(); break; case Qt::Key_Down: m_topBottomScroll->setValue( m_topBottomScroll->value() + 1 ); - _ke->accept(); + ke->accept(); break; case Qt::Key_Left: @@ -315,35 +315,35 @@ void AutomationEditor::keyPressEvent( QKeyEvent * _ke ) m_timeLine->pos().setTicks( 0 ); } m_timeLine->updatePosition(); - _ke->accept(); + ke->accept(); break; case Qt::Key_Right: m_timeLine->pos() += 16; m_timeLine->updatePosition(); - _ke->accept(); + ke->accept(); break; //TODO: m_selectButton and m_moveButton are broken. /*case Qt::Key_A: - if( _ke->modifiers() & Qt::ControlModifier ) + if( ke->modifiers() & Qt::ControlModifier ) { m_selectButton->setChecked( true ); selectAll(); update(); - _ke->accept(); + ke->accept(); } break; case Qt::Key_Delete: deleteSelectedValues(); - _ke->accept(); + ke->accept(); break;*/ case Qt::Key_Home: m_timeLine->pos().setTicks( 0 ); m_timeLine->updatePosition(); - _ke->accept(); + ke->accept(); break; default: @@ -354,23 +354,23 @@ void AutomationEditor::keyPressEvent( QKeyEvent * _ke ) -void AutomationEditor::leaveEvent( QEvent * _e ) +void AutomationEditor::leaveEvent(QEvent * e ) { while( QApplication::overrideCursor() != NULL ) { QApplication::restoreOverrideCursor(); } - QWidget::leaveEvent( _e ); + QWidget::leaveEvent( e ); } -void AutomationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 ) +void AutomationEditor::drawLine( int x0, float y0, int x1, float y1 ) { - int deltax = qRound( qAbs( _x1 - _x0 ) ); - float deltay = qAbs( _y1 - _y0 ); - int x = _x0; - float y = _y0; + int deltax = qRound( qAbs( x1 - x0 ) ); + float deltay = qAbs( y1 - y0 ); + int x = x0; + float y = y0; int xstep; int ystep; @@ -383,7 +383,7 @@ void AutomationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 ) float yscale = deltay / ( deltax ); - if( _x0 < _x1) + if( x0 < x1) { xstep = quantization(); } @@ -392,7 +392,7 @@ void AutomationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 ) xstep = -( quantization() ); } - if( _y0 < _y1 ) + if( y0 < y1 ) { ystep = 1; } @@ -404,7 +404,7 @@ void AutomationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 ) int i = 0; while( i < deltax ) { - y = _y0 + ( ystep * yscale * i ); + y = y0 + ( ystep * yscale * i ); x += xstep; i += 1; @@ -416,7 +416,7 @@ void AutomationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 ) -void AutomationEditor::mousePressEvent( QMouseEvent * _me ) +void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) { QMutexLocker m( &m_patternMutex ); if( !validPattern() ) @@ -424,11 +424,11 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) return; } - if( _me->y() > TOP_MARGIN ) + if( mouseEvent->y() > TOP_MARGIN ) { - float level = getLevel( _me->y() ); + float level = getLevel( mouseEvent->y() ); - int x = _me->x(); + int x = mouseEvent->x(); if( x > VALUES_WIDTH ) { @@ -466,11 +466,11 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) } // left button?? - if( _me->button() == Qt::LeftButton && + if( mouseEvent->button() == Qt::LeftButton && m_editMode == DRAW ) { // Connect the dots - if( _me->modifiers() & Qt::ShiftModifier ) + if( mouseEvent->modifiers() & Qt::ShiftModifier ) { drawLine( m_drawLastTick, m_drawLastLevel, @@ -509,7 +509,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) Engine::getSong()->setModified(); } - else if( ( _me->button() == Qt::RightButton && + else if( ( mouseEvent->button() == Qt::RightButton && m_editMode == DRAW ) || m_editMode == ERASE ) { @@ -521,7 +521,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) } m_action = NONE; } - else if( _me->button() == Qt::LeftButton && + else if( mouseEvent->button() == Qt::LeftButton && m_editMode == SELECT ) { // select an area of values @@ -532,14 +532,14 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) m_selectedLevels = 1; m_action = SELECT_VALUES; } - else if( _me->button() == Qt::RightButton && + else if( mouseEvent->button() == Qt::RightButton && m_editMode == SELECT ) { // when clicking right in select-move, we // switch to move-mode //m_moveButton->setChecked( true ); } - else if( _me->button() == Qt::LeftButton && + else if( mouseEvent->button() == Qt::LeftButton && m_editMode == MOVE ) { // move selection (including selected values) @@ -552,7 +552,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) Engine::getSong()->setModified(); } - else if( _me->button() == Qt::RightButton && + else if( mouseEvent->button() == Qt::RightButton && m_editMode == MOVE ) { // when clicking right in select-move, we @@ -568,7 +568,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) -void AutomationEditor::mouseReleaseEvent( QMouseEvent * _me ) +void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent ) { if( m_editMode == DRAW ) { @@ -585,7 +585,7 @@ void AutomationEditor::mouseReleaseEvent( QMouseEvent * _me ) #include -void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) +void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) { QMutexLocker m( &m_patternMutex ); if( !validPattern() ) @@ -594,12 +594,12 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) return; } - if( _me->y() > TOP_MARGIN ) + if( mouseEvent->y() > TOP_MARGIN ) { - float level = getLevel( _me->y() ); - int x = _me->x(); + float level = getLevel( mouseEvent->y() ); + int x = mouseEvent->x(); - if( _me->x() <= VALUES_WIDTH ) + if( mouseEvent->x() <= VALUES_WIDTH ) { update(); return; @@ -612,7 +612,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; - if( _me->buttons() & Qt::LeftButton && m_editMode == DRAW ) + if( mouseEvent->buttons() & Qt::LeftButton && m_editMode == DRAW ) { if( m_action == MOVE_VALUE ) { @@ -638,14 +638,14 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) Engine::getSong()->setModified(); } - else if( ( _me->buttons() & Qt::RightButton && + else if( ( mouseEvent->buttons() & Qt::RightButton && m_editMode == DRAW ) || - ( _me->buttons() & Qt::LeftButton && + ( mouseEvent->buttons() & Qt::LeftButton && m_editMode == ERASE ) ) { m_pattern->removeValue( MidiTime( pos_ticks ) ); } - else if( _me->buttons() & Qt::NoButton && m_editMode == DRAW ) + else if( mouseEvent->buttons() & Qt::NoButton && m_editMode == DRAW ) { // set move- or resize-cursor @@ -702,7 +702,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) } } } - else if( _me->buttons() & Qt::LeftButton && + else if( mouseEvent->buttons() & Qt::LeftButton && m_editMode == SELECT && m_action == SELECT_VALUES ) { @@ -713,7 +713,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) { x = 0; QCursor::setPos( mapToGlobal( QPoint( - VALUES_WIDTH, _me->y() ) ) ); + VALUES_WIDTH, mouseEvent->y() ) ) ); if( m_currentPosition >= 4 ) { m_leftRightScroll->setValue( @@ -728,7 +728,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) { x = width() - VALUES_WIDTH; QCursor::setPos( mapToGlobal( QPoint( width(), - _me->y() ) ) ); + mouseEvent->y() ) ) ); m_leftRightScroll->setValue( m_currentPosition + 4 ); } @@ -748,7 +748,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) --m_selectedLevels; } } - else if( _me->buttons() & Qt::LeftButton && + else if( mouseEvent->buttons() & Qt::LeftButton && m_editMode == MOVE && m_action == MOVE_SELECTION ) { @@ -863,17 +863,17 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) } else { - if( _me->buttons() & Qt::LeftButton && + if( mouseEvent->buttons() & Qt::LeftButton && m_editMode == SELECT && m_action == SELECT_VALUES ) { - int x = _me->x() - VALUES_WIDTH; + int x = mouseEvent->x() - VALUES_WIDTH; if( x < 0 && m_currentPosition > 0 ) { x = 0; QCursor::setPos( mapToGlobal( QPoint( VALUES_WIDTH, - _me->y() ) ) ); + mouseEvent->y() ) ) ); if( m_currentPosition >= 4 ) { m_leftRightScroll->setValue( @@ -888,7 +888,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) { x = width() - VALUES_WIDTH; QCursor::setPos( mapToGlobal( QPoint( width(), - _me->y() ) ) ); + mouseEvent->y() ) ) ); m_leftRightScroll->setValue( m_currentPosition + 4 ); } @@ -905,11 +905,11 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) m_selectedTick = -m_selectStartTick; } - float level = getLevel( _me->y() ); + float level = getLevel( mouseEvent->y() ); if( level <= m_bottomLevel ) { - QCursor::setPos( mapToGlobal( QPoint( _me->x(), + QCursor::setPos( mapToGlobal( QPoint( mouseEvent->x(), height() - SCROLLBAR_SIZE ) ) ); m_topBottomScroll->setValue( @@ -918,7 +918,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) } else if( level >= m_topLevel ) { - QCursor::setPos( mapToGlobal( QPoint( _me->x(), + QCursor::setPos( mapToGlobal( QPoint( mouseEvent->x(), TOP_MARGIN ) ) ); m_topBottomScroll->setValue( m_topBottomScroll->value() - 1 ); @@ -939,7 +939,7 @@ void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) -inline void AutomationEditor::drawCross( QPainter & _p ) +inline void AutomationEditor::drawCross( QPainter & p ) { QPoint mouse_pos = mapFromGlobal( QCursor::pos() ); float level = getLevel( mouse_pos.y() ); @@ -950,9 +950,9 @@ inline void AutomationEditor::drawCross( QPainter & _p ) / (float)( m_maxLevel - m_minLevel ) ) : grid_bottom - ( level - m_bottomLevel ) * m_y_delta; - _p.setPen( QColor( 0xFF, 0x33, 0x33 ) ); - _p.drawLine( VALUES_WIDTH, (int) cross_y, width(), (int) cross_y ); - _p.drawLine( mouse_pos.x(), TOP_MARGIN, mouse_pos.x(), + p.setPen( QColor( 0xFF, 0x33, 0x33 ) ); + p.drawLine( VALUES_WIDTH, (int) cross_y, width(), (int) cross_y ); + p.drawLine( mouse_pos.x(), TOP_MARGIN, mouse_pos.x(), height() - SCROLLBAR_SIZE ); QPoint tt_pos = QCursor::pos(); tt_pos.ry() -= 64; @@ -977,7 +977,7 @@ inline void AutomationEditor::drawAutomationPoint( QPainter & p, timeMap::iterat -void AutomationEditor::paintEvent( QPaintEvent * _pe ) +void AutomationEditor::paintEvent(QPaintEvent * pe ) { QMutexLocker m( &m_patternMutex ); @@ -1310,27 +1310,27 @@ void AutomationEditor::paintEvent( QPaintEvent * _pe ) -int AutomationEditor::xCoordOfTick( int _tick ) +int AutomationEditor::xCoordOfTick(int tick ) { - return VALUES_WIDTH + ( ( _tick - m_currentPosition ) + return VALUES_WIDTH + ( ( tick - m_currentPosition ) * m_ppt / MidiTime::ticksPerTact() ); } -int AutomationEditor::yCoordOfLevel( float _level ) +int AutomationEditor::yCoordOfLevel(float level ) { int grid_bottom = height() - SCROLLBAR_SIZE - 1; if( m_y_auto ) { return (int)( grid_bottom - ( grid_bottom - TOP_MARGIN ) - * ( _level - m_minLevel ) + * ( level - m_minLevel ) / ( m_maxLevel - m_minLevel ) ); } else { - return (int)( grid_bottom - ( _level - m_bottomLevel ) + return (int)( grid_bottom - ( level - m_bottomLevel ) * m_y_delta ); } } @@ -1338,19 +1338,19 @@ int AutomationEditor::yCoordOfLevel( float _level ) -void AutomationEditor::drawLevelTick( QPainter & _p, int _tick, float _level, - bool _is_selected ) +void AutomationEditor::drawLevelTick(QPainter & p, int tick, float value, + bool is_selected ) { int grid_bottom = height() - SCROLLBAR_SIZE - 1; - const int x = xCoordOfTick( _tick ); - int rect_width = xCoordOfTick( _tick+1 ) - x; + const int x = xCoordOfTick( tick ); + int rect_width = xCoordOfTick( tick+1 ) - x; // is the level in visible area? - if( ( _level >= m_bottomLevel && _level <= m_topLevel ) - || ( _level > m_topLevel && m_topLevel >= 0 ) - || ( _level < m_bottomLevel && m_bottomLevel <= 0 ) ) + if( ( value >= m_bottomLevel && value <= m_topLevel ) + || ( value > m_topLevel && m_topLevel >= 0 ) + || ( value < m_bottomLevel && m_bottomLevel <= 0 ) ) { - int y_start = yCoordOfLevel( _level ); + int y_start = yCoordOfLevel( value ); int rect_height; if( m_y_auto ) @@ -1364,14 +1364,14 @@ void AutomationEditor::drawLevelTick( QPainter & _p, int _tick, float _level, } else { - rect_height = (int)( _level * m_y_delta ); + rect_height = (int)( value * m_y_delta ); } - QBrush currentColor = _is_selected + QBrush currentColor = is_selected ? QBrush( QColor( 0x00, 0x40, 0xC0 ) ) : graphColor(); - _p.fillRect( x, y_start, rect_width, rect_height, currentColor ); + p.fillRect( x, y_start, rect_width, rect_height, currentColor ); } else @@ -1385,7 +1385,7 @@ void AutomationEditor::drawLevelTick( QPainter & _p, int _tick, float _level, // responsible for moving/resizing scrollbars after window-resizing -void AutomationEditor::resizeEvent( QResizeEvent * ) +void AutomationEditor::resizeEvent(QResizeEvent * re) { m_leftRightScroll->setGeometry( VALUES_WIDTH, height() - SCROLLBAR_SIZE, width() - VALUES_WIDTH, @@ -1426,31 +1426,31 @@ void AutomationEditor::resizeEvent( QResizeEvent * ) -void AutomationEditor::wheelEvent( QWheelEvent * _we ) +void AutomationEditor::wheelEvent(QWheelEvent * we ) { - _we->accept(); - if( _we->modifiers() & Qt::ControlModifier && _we->modifiers() & Qt::ShiftModifier ) + we->accept(); + if( we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::ShiftModifier ) { int y = m_zoomingYModel.value(); - if( _we->delta() > 0 ) + if( we->delta() > 0 ) { y++; } - if( _we->delta() < 0 ) + if( we->delta() < 0 ) { y--; } y = qBound( 0, y, m_zoomingYModel.size() - 1 ); m_zoomingYModel.setValue( y ); } - else if( _we->modifiers() & Qt::ControlModifier && _we->modifiers() & Qt::AltModifier ) + else if( we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::AltModifier ) { int q = m_quantizeModel.value(); - if( _we->delta() > 0 ) + if( we->delta() > 0 ) { q--; } - if( _we->delta() < 0 ) + if( we->delta() < 0 ) { q++; } @@ -1458,44 +1458,44 @@ void AutomationEditor::wheelEvent( QWheelEvent * _we ) m_quantizeModel.setValue( q ); update(); } - else if( _we->modifiers() & Qt::ControlModifier ) + else if( we->modifiers() & Qt::ControlModifier ) { int x = m_zoomingXModel.value(); - if( _we->delta() > 0 ) + if( we->delta() > 0 ) { x++; } - if( _we->delta() < 0 ) + if( we->delta() < 0 ) { x--; } x = qBound( 0, x, m_zoomingXModel.size() - 1 ); m_zoomingXModel.setValue( x ); } - else if( _we->modifiers() & Qt::ShiftModifier - || _we->orientation() == Qt::Horizontal ) + else if( we->modifiers() & Qt::ShiftModifier + || we->orientation() == Qt::Horizontal ) { m_leftRightScroll->setValue( m_leftRightScroll->value() - - _we->delta() * 2 / 15 ); + we->delta() * 2 / 15 ); } else { m_topBottomScroll->setValue( m_topBottomScroll->value() - - _we->delta() / 30 ); + we->delta() / 30 ); } } -float AutomationEditor::getLevel( int _y ) +float AutomationEditor::getLevel(int y ) { int level_line_y = height() - SCROLLBAR_SIZE - 1; // pressed level float level = roundf( ( m_bottomLevel + ( m_y_auto ? - ( m_maxLevel - m_minLevel ) * ( level_line_y - _y ) + ( m_maxLevel - m_minLevel ) * ( level_line_y - y ) / (float)( level_line_y - ( TOP_MARGIN + 2 ) ) : - ( level_line_y - _y ) / (float)m_y_delta ) ) / m_step ) * m_step; + ( level_line_y - y ) / (float)m_y_delta ) ) / m_step ) * m_step; // some range-checking-stuff level = qBound( m_bottomLevel, level, m_topLevel ); @@ -1582,9 +1582,9 @@ void AutomationEditor::stop() -void AutomationEditor::horScrolled( int _new_pos ) +void AutomationEditor::horScrolled(int new_pos ) { - m_currentPosition = _new_pos; + m_currentPosition = new_pos; emit positionChanged( m_currentPosition ); update(); } @@ -1592,9 +1592,9 @@ void AutomationEditor::horScrolled( int _new_pos ) -void AutomationEditor::verScrolled( int _new_pos ) +void AutomationEditor::verScrolled(int new_pos ) { - m_scrollLevel = _new_pos; + m_scrollLevel = new_pos; updateTopBottomLevels(); update(); } @@ -1602,7 +1602,7 @@ void AutomationEditor::verScrolled( int _new_pos ) -void AutomationEditor::setEditMode(AutomationEditor::editModes mode) +void AutomationEditor::setEditMode(AutomationEditor::EditModes mode) { if (m_editMode == mode) return; @@ -1626,7 +1626,7 @@ void AutomationEditor::setEditMode(AutomationEditor::editModes mode) void AutomationEditor::setEditMode(int mode) { - setEditMode((AutomationEditor::editModes) mode); + setEditMode((AutomationEditor::EditModes) mode); } @@ -1711,7 +1711,7 @@ void AutomationEditor::selectAll() // returns vector with pointers to all selected values -void AutomationEditor::getSelectedValues( timeMap & _selected_values ) +void AutomationEditor::getSelectedValues( timeMap & selected_values ) { QMutexLocker m( &m_patternMutex ); if( !validPattern() ) @@ -1748,7 +1748,7 @@ void AutomationEditor::getSelectedValues( timeMap & _selected_values ) pos_ticks >= sel_pos_start && pos_ticks + len_ticks <= sel_pos_end ) { - _selected_values[it.key()] = level; + selected_values[it.key()] = level; } } } @@ -1865,7 +1865,7 @@ void AutomationEditor::deleteSelectedValues() -void AutomationEditor::updatePosition( const MidiTime & _t ) +void AutomationEditor::updatePosition(const MidiTime & t ) { if( ( Engine::getSong()->isPlaying() && Engine::getSong()->playMode() == @@ -1873,16 +1873,16 @@ void AutomationEditor::updatePosition( const MidiTime & _t ) m_scrollBack == true ) { const int w = width() - VALUES_WIDTH; - if( _t > m_currentPosition + w * MidiTime::ticksPerTact() / m_ppt ) + if( t > m_currentPosition + w * MidiTime::ticksPerTact() / m_ppt ) { - m_leftRightScroll->setValue( _t.getTact() * + m_leftRightScroll->setValue( t.getTact() * MidiTime::ticksPerTact() ); } - else if( _t < m_currentPosition ) + else if( t < m_currentPosition ) { - MidiTime t = qMax( _t - w * MidiTime::ticksPerTact() * + MidiTime t_ = qMax( t - w * MidiTime::ticksPerTact() * MidiTime::ticksPerTact() / m_ppt, 0 ); - m_leftRightScroll->setValue( t.getTact() * + m_leftRightScroll->setValue( t_.getTact() * MidiTime::ticksPerTact() ); } m_scrollBack = false; From 51f59293cee071e7173d4a43c2d5f46cc997e334 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 23:38:38 +0100 Subject: [PATCH 19/32] Rename Timeline to TimeLineWidget --- include/AutomationEditor.h | 4 +-- include/Editor.h | 2 +- include/PianoRoll.h | 4 +-- include/Song.h | 4 +-- include/SongEditor.h | 4 +-- include/{Timeline.h => TimeLineWidget.h} | 8 ++--- src/core/Song.cpp | 14 ++++---- src/gui/AutomationEditor.cpp | 4 +-- src/gui/PianoRoll.cpp | 6 ++-- src/gui/SongEditor.cpp | 6 ++-- src/gui/{Timeline.cpp => TimeLineWidget.cpp} | 38 ++++++++++---------- 11 files changed, 47 insertions(+), 47 deletions(-) rename include/{Timeline.h => TimeLineWidget.h} (93%) rename src/gui/{Timeline.cpp => TimeLineWidget.cpp} (89%) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 6b7b7ae29..2c48ef800 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -44,7 +44,7 @@ class QScrollBar; class ComboBox; class NotePlayHandle; -class Timeline; +class TimeLineWidget; @@ -226,7 +226,7 @@ private: EditModes m_editMode; - Timeline * m_timeLine; + TimeLineWidget * m_timeLine; bool m_scrollBack; void drawCross(QPainter & p ); diff --git a/include/Editor.h b/include/Editor.h index ffd2f4ae1..02a9cbde5 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -28,7 +28,7 @@ #include #include -#include "Timeline.h" +#include "TimeLineWidget.h" #include "ToolButton.h" /// \brief Superclass for editors with a toolbar. diff --git a/include/PianoRoll.h b/include/PianoRoll.h index e190a0e6d..3d1b74ff3 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -48,7 +48,7 @@ class QSignalMapper; class ComboBox; class NotePlayHandle; class Pattern; -class Timeline; +class TimeLineWidget; class PianoRoll : public QWidget { @@ -317,7 +317,7 @@ private: bool m_mouseDownLeft; //true if left click is being held down bool m_mouseDownRight; //true if right click is being held down - Timeline * m_timeLine; + TimeLineWidget * m_timeLine; bool m_scrollBack; void copy_to_clipboard( const NoteVector & _notes ) const; diff --git a/include/Song.h b/include/Song.h index d0dac5a9c..7a140b3d4 100644 --- a/include/Song.h +++ b/include/Song.h @@ -36,7 +36,7 @@ class AutomationTrack; class Pattern; -class Timeline; +class TimeLineWidget; const bpm_t MinTempo = 10; @@ -83,7 +83,7 @@ public: { return m_currentFrame; } - Timeline * m_timeLine; + TimeLineWidget * m_timeLine; bool m_timeLineUpdate; private: diff --git a/include/SongEditor.h b/include/SongEditor.h index 44a0c5b2f..08b41f74b 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -40,7 +40,7 @@ class LcdSpinBox; class MeterDialog; class Song; class TextFloat; -class Timeline; +class TimeLineWidget; class positionLine : public QWidget { @@ -108,7 +108,7 @@ private: LcdSpinBox * m_tempoSpinBox; - Timeline * m_timeLine; + TimeLineWidget * m_timeLine; MeterDialog * m_timeSigDisplay; AutomatableSlider * m_masterVolumeSlider; diff --git a/include/Timeline.h b/include/TimeLineWidget.h similarity index 93% rename from include/Timeline.h rename to include/TimeLineWidget.h index 47f93d4b6..abf622aaf 100644 --- a/include/Timeline.h +++ b/include/TimeLineWidget.h @@ -1,5 +1,5 @@ /* - * Timeline.h - class timeLine, representing a time-line with position marker + * TimeLineWidget.h - class timeLine, representing a time-line with position marker * * Copyright (c) 2004-2008 Tobias Doerffel * @@ -37,7 +37,7 @@ class NStateButton; class TextFloat; -class Timeline : public QWidget, public JournallingObject +class TimeLineWidget : public QWidget, public JournallingObject { Q_OBJECT public: @@ -61,9 +61,9 @@ public: } ; - Timeline( int _xoff, int _yoff, float _ppt, Song::playPos & _pos, + TimeLineWidget( int _xoff, int _yoff, float _ppt, Song::playPos & _pos, const MidiTime & _begin, QWidget * _parent ); - virtual ~Timeline(); + virtual ~TimeLineWidget(); inline Song::playPos & pos() { diff --git a/src/core/Song.cpp b/src/core/Song.cpp index a8d3450f8..1f3f573f8 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -60,7 +60,7 @@ #include "SongEditor.h" #include "templates.h" #include "TextFloat.h" -#include "Timeline.h" +#include "TimeLineWidget.h" #include "PeakController.h" @@ -179,7 +179,7 @@ void Song::setTimeSignature() void Song::savePos() { - Timeline * tl = m_playPos[m_playMode].m_timeLine; + TimeLineWidget * tl = m_playPos[m_playMode].m_timeLine; if( tl != NULL ) { @@ -246,7 +246,7 @@ void Song::processNextBuffer() } // check for looping-mode and act if necessary - Timeline * tl = m_playPos[m_playMode].m_timeLine; + TimeLineWidget * tl = m_playPos[m_playMode].m_timeLine; bool check_loop = tl != NULL && m_exporting == false && tl->loopPointsEnabled(); if( check_loop ) @@ -565,7 +565,7 @@ void Song::stop() return; } - Timeline * tl = m_playPos[m_playMode].m_timeLine; + TimeLineWidget * tl = m_playPos[m_playMode].m_timeLine; m_playing = false; m_paused = false; m_recording = true; @@ -575,12 +575,12 @@ void Song::stop() switch( tl->behaviourAtStop() ) { - case Timeline::BackToZero: + case TimeLineWidget::BackToZero: m_playPos[m_playMode].setTicks( 0 ); m_elapsedMilliSeconds = 0; break; - case Timeline::BackToStart: + case TimeLineWidget::BackToStart: if( tl->savedPos() >= 0 ) { m_playPos[m_playMode].setTicks( tl->savedPos().getTicks() ); @@ -589,7 +589,7 @@ void Song::stop() } break; - case Timeline::KeepStopPosition: + case TimeLineWidget::KeepStopPosition: default: break; } diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index 0599a9119..2cd915c30 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -55,7 +55,7 @@ #include "PixmapButton.h" #include "templates.h" #include "gui_templates.h" -#include "Timeline.h" +#include "TimeLineWidget.h" #include "ToolTip.h" #include "TextFloat.h" #include "ComboBox.h" @@ -121,7 +121,7 @@ AutomationEditor::AutomationEditor() : m_quantizeModel.setValue( m_quantizeModel.findText( "1/16" ) ); // add time-line - m_timeLine = new Timeline( VALUES_WIDTH, 0, m_ppt, + m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppt, Engine::getSong()->getPlayPos( Song::Mode_PlayAutomationPattern ), m_currentPosition, this ); diff --git a/src/gui/PianoRoll.cpp b/src/gui/PianoRoll.cpp index d7838b5a9..c2bcca769 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/PianoRoll.cpp @@ -65,7 +65,7 @@ #include "SongEditor.h" #include "templates.h" #include "TextFloat.h" -#include "Timeline.h" +#include "TimeLineWidget.h" #include "TextFloat.h" @@ -290,7 +290,7 @@ PianoRoll::PianoRoll() : setAttribute( Qt::WA_OpaquePaintEvent, true ); // add time-line - m_timeLine = new Timeline( WHITE_KEY_WIDTH, 0, m_ppt, + m_timeLine = new TimeLineWidget( WHITE_KEY_WIDTH, 0, m_ppt, Engine::getSong()->getPlayPos( Song::Mode_PlayPattern ), m_currentPosition, this ); @@ -3745,7 +3745,7 @@ void PianoRoll::updatePosition( const MidiTime & _t ) if( ( Engine::getSong()->isPlaying() && Engine::getSong()->playMode() == Song::Mode_PlayPattern && - m_timeLine->autoScroll() == Timeline::AutoScrollEnabled ) || + m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled ) || m_scrollBack == true ) { autoScroll( _t ); diff --git a/src/gui/SongEditor.cpp b/src/gui/SongEditor.cpp index ebd6842f7..5d65e9ee3 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/SongEditor.cpp @@ -45,7 +45,7 @@ #include "MainWindow.h" #include "MeterDialog.h" #include "TextFloat.h" -#include "Timeline.h" +#include "TimeLineWidget.h" #include "ToolTip.h" #include "VisualizationWidget.h" #include "TimeDisplayWidget.h" @@ -86,7 +86,7 @@ SongEditor::SongEditor( Song * _song ) : "compacttrackbuttons" ).toInt()==1 ? DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT : DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_OP_WIDTH; - m_timeLine = new Timeline( widgetTotal, 32, + m_timeLine = new TimeLineWidget( widgetTotal, 32, pixelsPerTact(), m_song->m_playPos[Song::Mode_PlaySong], m_currentPosition, this ); @@ -525,7 +525,7 @@ void SongEditor::updatePosition( const MidiTime & _t ) } if( ( m_song->isPlaying() && m_song->m_playMode == Song::Mode_PlaySong - && m_timeLine->autoScroll() == Timeline::AutoScrollEnabled) || + && m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled) || m_scrollBack == true ) { const int w = width() - widgetWidth diff --git a/src/gui/Timeline.cpp b/src/gui/TimeLineWidget.cpp similarity index 89% rename from src/gui/Timeline.cpp rename to src/gui/TimeLineWidget.cpp index c4c39d7bd..624d0df3e 100644 --- a/src/gui/Timeline.cpp +++ b/src/gui/TimeLineWidget.cpp @@ -1,5 +1,5 @@ /* - * Timeline.cpp - class timeLine, representing a time-line with position marker + * TimeLineWidget.cpp - class timeLine, representing a time-line with position marker * * Copyright (c) 2004-2014 Tobias Doerffel * @@ -32,7 +32,7 @@ #include -#include "Timeline.h" +#include "TimeLineWidget.h" #include "embed.h" #include "Engine.h" #include "templates.h" @@ -46,12 +46,12 @@ #endif -QPixmap * Timeline::s_timeLinePixmap = NULL; -QPixmap * Timeline::s_posMarkerPixmap = NULL; -QPixmap * Timeline::s_loopPointBeginPixmap = NULL; -QPixmap * Timeline::s_loopPointEndPixmap = NULL; +QPixmap * TimeLineWidget::s_timeLinePixmap = NULL; +QPixmap * TimeLineWidget::s_posMarkerPixmap = NULL; +QPixmap * TimeLineWidget::s_loopPointBeginPixmap = NULL; +QPixmap * TimeLineWidget::s_loopPointEndPixmap = NULL; -Timeline::Timeline( const int _xoff, const int _yoff, const float _ppt, +TimeLineWidget::TimeLineWidget( const int _xoff, const int _yoff, const float _ppt, Song::playPos & _pos, const MidiTime & _begin, QWidget * _parent ) : QWidget( _parent ), @@ -110,7 +110,7 @@ Timeline::Timeline( const int _xoff, const int _yoff, const float _ppt, -Timeline::~Timeline() +TimeLineWidget::~TimeLineWidget() { if( Engine::songEditor() ) { @@ -122,7 +122,7 @@ Timeline::~Timeline() -void Timeline::addToolButtons( QToolBar * _tool_bar ) +void TimeLineWidget::addToolButtons( QToolBar * _tool_bar ) { NStateButton * autoScroll = new NStateButton( _tool_bar ); autoScroll->setGeneralToolTip( tr( "Enable/disable auto-scrolling" ) ); @@ -161,7 +161,7 @@ void Timeline::addToolButtons( QToolBar * _tool_bar ) -void Timeline::saveSettings( QDomDocument & _doc, QDomElement & _this ) +void TimeLineWidget::saveSettings( QDomDocument & _doc, QDomElement & _this ) { _this.setAttribute( "lp0pos", (int) loopBegin() ); _this.setAttribute( "lp1pos", (int) loopEnd() ); @@ -171,7 +171,7 @@ void Timeline::saveSettings( QDomDocument & _doc, QDomElement & _this ) -void Timeline::loadSettings( const QDomElement & _this ) +void TimeLineWidget::loadSettings( const QDomElement & _this ) { m_loopPos[0] = _this.attribute( "lp0pos" ).toInt(); m_loopPos[1] = _this.attribute( "lp1pos" ).toInt(); @@ -184,7 +184,7 @@ void Timeline::loadSettings( const QDomElement & _this ) -void Timeline::updatePosition( const MidiTime & ) +void TimeLineWidget::updatePosition( const MidiTime & ) { const int new_x = markerX( m_pos ); @@ -200,7 +200,7 @@ void Timeline::updatePosition( const MidiTime & ) -void Timeline::toggleAutoScroll( int _n ) +void TimeLineWidget::toggleAutoScroll( int _n ) { m_autoScroll = static_cast( _n ); } @@ -208,7 +208,7 @@ void Timeline::toggleAutoScroll( int _n ) -void Timeline::toggleLoopPoints( int _n ) +void TimeLineWidget::toggleLoopPoints( int _n ) { m_loopPoints = static_cast( _n ); update(); @@ -217,7 +217,7 @@ void Timeline::toggleLoopPoints( int _n ) -void Timeline::toggleBehaviourAtStop( int _n ) +void TimeLineWidget::toggleBehaviourAtStop( int _n ) { m_behaviourAtStop = static_cast( _n ); } @@ -225,7 +225,7 @@ void Timeline::toggleBehaviourAtStop( int _n ) -void Timeline::paintEvent( QPaintEvent * ) +void TimeLineWidget::paintEvent( QPaintEvent * ) { QPainter p( this ); @@ -274,7 +274,7 @@ void Timeline::paintEvent( QPaintEvent * ) -void Timeline::mousePressEvent( QMouseEvent* event ) +void TimeLineWidget::mousePressEvent( QMouseEvent* event ) { if( event->x() < m_xOffset ) { @@ -332,7 +332,7 @@ void Timeline::mousePressEvent( QMouseEvent* event ) -void Timeline::mouseMoveEvent( QMouseEvent* event ) +void TimeLineWidget::mouseMoveEvent( QMouseEvent* event ) { const MidiTime t = m_begin + static_cast( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * MidiTime::ticksPerTact() / m_ppt ); @@ -382,7 +382,7 @@ void Timeline::mouseMoveEvent( QMouseEvent* event ) -void Timeline::mouseReleaseEvent( QMouseEvent* event ) +void TimeLineWidget::mouseReleaseEvent( QMouseEvent* event ) { delete m_hint; m_hint = NULL; From b25765ddb842506912320540f4adf91a903c7190 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Mon, 8 Dec 2014 23:43:31 +0100 Subject: [PATCH 20/32] Move Editors to src/gui/editors subdirectory --- include/Editor.h | 4 ++-- src/gui/{ => editors}/AutomationEditor.cpp | 0 src/gui/{ => editors}/BBEditor.cpp | 0 src/gui/{ => editors}/Editor.cpp | 0 src/gui/{ => editors}/PianoRoll.cpp | 0 src/gui/{ => editors}/SongEditor.cpp | 0 6 files changed, 2 insertions(+), 2 deletions(-) rename src/gui/{ => editors}/AutomationEditor.cpp (100%) rename src/gui/{ => editors}/BBEditor.cpp (100%) rename src/gui/{ => editors}/Editor.cpp (100%) rename src/gui/{ => editors}/PianoRoll.cpp (100%) rename src/gui/{ => editors}/SongEditor.cpp (100%) diff --git a/include/Editor.h b/include/Editor.h index 02a9cbde5..4da0fdbdb 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -33,8 +33,8 @@ /// \brief Superclass for editors with a toolbar. /// -/// Those editors include the Song Editor, the Automation Editor, -/// B&B Editor, Piano Roll. +/// Those editors include the Song Editor, the Automation Editor, B&B Editor, +/// and the Piano Roll. class Editor : public QMainWindow { Q_OBJECT diff --git a/src/gui/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp similarity index 100% rename from src/gui/AutomationEditor.cpp rename to src/gui/editors/AutomationEditor.cpp diff --git a/src/gui/BBEditor.cpp b/src/gui/editors/BBEditor.cpp similarity index 100% rename from src/gui/BBEditor.cpp rename to src/gui/editors/BBEditor.cpp diff --git a/src/gui/Editor.cpp b/src/gui/editors/Editor.cpp similarity index 100% rename from src/gui/Editor.cpp rename to src/gui/editors/Editor.cpp diff --git a/src/gui/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp similarity index 100% rename from src/gui/PianoRoll.cpp rename to src/gui/editors/PianoRoll.cpp diff --git a/src/gui/SongEditor.cpp b/src/gui/editors/SongEditor.cpp similarity index 100% rename from src/gui/SongEditor.cpp rename to src/gui/editors/SongEditor.cpp From 1d07a91a83dabb4ce8f6a7e2738b273618ae8c4e Mon Sep 17 00:00:00 2001 From: Lukas W Date: Thu, 11 Dec 2014 01:49:59 +0100 Subject: [PATCH 21/32] PianoRoll: Coding style updates --- include/PianoRoll.h | 72 +++--- src/gui/editors/PianoRoll.cpp | 416 +++++++++++++++++----------------- 2 files changed, 244 insertions(+), 244 deletions(-) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 3d1b74ff3..5ac1a2453 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -58,7 +58,7 @@ class PianoRoll : public QWidget Q_PROPERTY( QColor noteColor READ noteColor WRITE setNoteColor ) Q_PROPERTY( QColor barColor READ barColor WRITE setBarColor ) public: - enum editModes + enum EditModes { ModeDraw, ModeErase, @@ -97,33 +97,33 @@ public: // qproperty acces functions QColor gridColor() const; - void setGridColor( const QColor & _c ); + void setGridColor( const QColor & c ); QColor noteModeColor() const; - void setNoteModeColor( const QColor & _c ); + void setNoteModeColor( const QColor & c ); QColor noteColor() const; - void setNoteColor( const QColor & _c ); + void setNoteColor( const QColor & c ); QColor barColor() const; - void setBarColor( const QColor & _c ); + void setBarColor( const QColor & c ); protected: - virtual void keyPressEvent( QKeyEvent * _ke ); - virtual void keyReleaseEvent( QKeyEvent * _ke ); - virtual void leaveEvent( QEvent * _e ); - virtual void mousePressEvent( QMouseEvent * _me ); - virtual void mouseDoubleClickEvent( QMouseEvent * _me ); - virtual void mouseReleaseEvent( QMouseEvent * _me ); - virtual void mouseMoveEvent( QMouseEvent * _me ); - virtual void paintEvent( QPaintEvent * _pe ); - virtual void resizeEvent( QResizeEvent * _re ); - virtual void wheelEvent( QWheelEvent * _we ); + virtual void keyPressEvent( QKeyEvent * ke ); + virtual void keyReleaseEvent( QKeyEvent * ke ); + virtual void leaveEvent( QEvent * e ); + virtual void mousePressEvent( QMouseEvent * me ); + virtual void mouseDoubleClickEvent( QMouseEvent * me ); + virtual void mouseReleaseEvent( QMouseEvent * me ); + virtual void mouseMoveEvent( QMouseEvent * me ); + virtual void paintEvent( QPaintEvent * pe ); + virtual void resizeEvent( QResizeEvent * re ); + virtual void wheelEvent( QWheelEvent * we ); - int getKey( int _y ) const; - static inline void drawNoteRect( QPainter & _p, int _x, int _y, - int _width, Note * _n, const QColor & noteCol ); + int getKey( int y ) const; + static inline void drawNoteRect( QPainter & p, int x, int y, + int width, Note * n, const QColor & noteCol ); void removeSelection(); void selectAll(); - void getSelectedNotes( NoteVector & _selected_notes ); + void getSelectedNotes( NoteVector & selected_notes ); // for entering values with dblclick in the vol/pan bars void enterValue( NoteVector* nv ); @@ -134,13 +134,13 @@ protected slots: void recordAccompany(); void stop(); - void startRecordNote( const Note & _n ); - void finishRecordNote( const Note & _n ); + void startRecordNote( const Note & n ); + void finishRecordNote( const Note & n ); - void horScrolled( int _new_pos ); - void verScrolled( int _new_pos ); + void horScrolled( int new_pos ); + void verScrolled( int new_pos ); - void setEditMode(editModes mode); + void setEditMode(EditModes mode); void setEditModeDraw() {setEditMode(ModeDraw); } void setEditModeErase() {setEditMode(ModeErase); } void setEditModeSelect() {setEditMode(ModeSelect); } @@ -151,8 +151,8 @@ protected slots: void pasteNotes(); void deleteSelectedNotes(); - void updatePosition( const MidiTime & _t ); - void updatePositionAccompany( const MidiTime & _t ); + void updatePosition(const MidiTime & t ); + void updatePositionAccompany(const MidiTime & t ); void zoomingChanged(); void quantizeChanged(); @@ -172,7 +172,7 @@ signals: private: - enum actions + enum Actions { ActionNone, ActionMoveNote, @@ -182,14 +182,14 @@ private: ActionResizeNoteEditArea }; - enum noteEditMode + enum NoteEditMode { NoteEditVolume, NoteEditPanning, NoteEditCount // make sure this one is always last }; - enum semiToneMarkerAction + enum SemiToneMarkerAction { stmaUnmarkAll, stmaMarkCurrentSemiTone, @@ -214,7 +214,7 @@ private: PianoRoll( const PianoRoll & ); virtual ~PianoRoll(); - void autoScroll( const MidiTime & _t ); + void autoScroll(const MidiTime & t ); MidiTime newNoteLen() const; @@ -224,7 +224,7 @@ private: int selectionCount() const; void testPlayNote( Note * n ); void testPlayKey( int _key, int _vol, int _pan ); - void pauseTestNotes( bool _pause = true ); + void pauseTestNotes(bool pause = true ); inline int noteEditTop() const; inline int keyAreaBottom() const; @@ -270,8 +270,8 @@ private: QList m_recordingNotes; Note * m_currentNote; - actions m_action; - noteEditMode m_noteEditMode; + Actions m_action; + NoteEditMode m_noteEditMode; int m_selectStartTick; int m_selectedTick; @@ -311,8 +311,8 @@ private: int m_startKey; // first key when drawing int m_lastKey; - editModes m_editMode; - editModes m_ctrlMode; // mode they were in before they hit ctrl + EditModes m_editMode; + EditModes m_ctrlMode; // mode they were in before they hit ctrl bool m_mouseDownLeft; //true if left click is being held down bool m_mouseDownRight; //true if right click is being held down @@ -320,7 +320,7 @@ private: TimeLineWidget * m_timeLine; bool m_scrollBack; - void copy_to_clipboard( const NoteVector & _notes ) const; + void copy_to_clipboard(const NoteVector & notes ) const; void drawDetuningInfo( QPainter & _p, Note * _n, int _x, int _y ); bool mouseOverNote(); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index c2bcca769..0ebc9624b 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -430,7 +430,7 @@ void PianoRoll::reset() void PianoRoll::changeNoteEditMode( int i ) { - m_noteEditMode = (noteEditMode) i; + m_noteEditMode = (NoteEditMode) i; repaint(); } @@ -440,7 +440,7 @@ void PianoRoll::markSemiTone( int i ) const int key = getKey( mapFromGlobal( m_semiToneMarkerMenu->pos() ).y() ); const InstrumentFunctionNoteStacking::Chord * chord = 0; - switch( static_cast( i ) ) + switch( static_cast( i ) ) { case stmaUnmarkAll: m_markedSemiTones.clear(); @@ -622,40 +622,40 @@ void PianoRoll::setBarColor( const QColor & c ) -inline void PianoRoll::drawNoteRect( QPainter & _p, int _x, int _y, - int _width, Note * _n, const QColor & noteCol ) +inline void PianoRoll::drawNoteRect(QPainter & p, int x, int y, + int width, Note * n, const QColor & noteCol ) { - ++_x; - ++_y; - _width -= 2; + ++x; + ++y; + width -= 2; - if( _width <= 0 ) + if( width <= 0 ) { - _width = 2; + width = 2; } - int volVal = qMin( 255, 25 + (int) ( ( (float)( _n->getVolume() - MinVolume ) ) / + int volVal = qMin( 255, 25 + (int) ( ( (float)( n->getVolume() - MinVolume ) ) / ( (float)( MaxVolume - MinVolume ) ) * 230.0f) ); float rightPercent = qMin( 1.0f, - ( (float)( _n->getPanning() - PanningLeft ) ) / + ( (float)( n->getPanning() - PanningLeft ) ) / ( (float)( PanningRight - PanningLeft ) ) * 2.0f ); float leftPercent = qMin( 1.0f, - ( (float)( PanningRight - _n->getPanning() ) ) / + ( (float)( PanningRight - n->getPanning() ) ) / ( (float)( PanningRight - PanningLeft ) ) * 2.0f ); QColor col = QColor( noteCol ); - if( _n->length() < 0 ) + if( n->length() < 0 ) { //step note col.setRgb( 0, 255, 0 ); - _p.fillRect( _x, _y, _width, KEY_LINE_HEIGHT - 2, col ); + p.fillRect( x, y, width, KEY_LINE_HEIGHT - 2, col ); } - else if( _n->selected() ) + else if( n->selected() ) { col.setRgb( 0x00, 0x40, 0xC0 ); - _p.fillRect( _x, _y, _width, KEY_LINE_HEIGHT - 2, col ); + p.fillRect( x, y, width, KEY_LINE_HEIGHT - 2, col ); } else { @@ -667,43 +667,43 @@ inline void PianoRoll::drawNoteRect( QPainter & _p, int _x, int _y, volVal * rightPercent ); col = QColor::fromHsv( col.hue(), col.saturation(), volVal ); - QLinearGradient gradient( _x, _y, _x+_width, - _y+KEY_LINE_HEIGHT ); + QLinearGradient gradient( x, y, x+width, + y+KEY_LINE_HEIGHT ); gradient.setColorAt( 0, lcol ); gradient.setColorAt( 1, rcol ); - _p.setBrush( gradient ); - _p.setPen( Qt::NoPen ); - _p.drawRect( _x, _y, _width, KEY_LINE_HEIGHT-1 ); + p.setBrush( gradient ); + p.setPen( Qt::NoPen ); + p.drawRect( x, y, width, KEY_LINE_HEIGHT-1 ); } // hilighting lines around the note - _p.setPen( Qt::SolidLine ); - _p.setBrush( Qt::NoBrush ); + p.setPen( Qt::SolidLine ); + p.setBrush( Qt::NoBrush ); col = QColor( noteCol ); - _p.setPen( QColor::fromHsv( col.hue(), col.saturation(), + p.setPen( QColor::fromHsv( col.hue(), col.saturation(), qMin( 255, volVal*1.7f ) ) ); - _p.drawLine( _x, _y, _x + _width, _y ); - _p.drawLine( _x, _y, _x, _y + KEY_LINE_HEIGHT - 2 ); + p.drawLine( x, y, x + width, y ); + p.drawLine( x, y, x, y + KEY_LINE_HEIGHT - 2 ); col = QColor( noteCol ); - _p.setPen( QColor::fromHsv( col.hue(), col.saturation(), volVal/1.7 ) ); - _p.drawLine( _x + _width, _y, _x + _width, _y + KEY_LINE_HEIGHT - 2 ); - _p.drawLine( _x, _y + KEY_LINE_HEIGHT - 2, _x + _width, - _y + KEY_LINE_HEIGHT - 2 ); + p.setPen( QColor::fromHsv( col.hue(), col.saturation(), volVal/1.7 ) ); + p.drawLine( x + width, y, x + width, y + KEY_LINE_HEIGHT - 2 ); + p.drawLine( x, y + KEY_LINE_HEIGHT - 2, x + width, + y + KEY_LINE_HEIGHT - 2 ); // that little tab thing on the end hinting at the user // to resize the note - _p.setPen( noteCol.lighter( 200 ) ); - if( _width > 2 ) + p.setPen( noteCol.lighter( 200 ) ); + if( width > 2 ) { - _p.drawLine( _x + _width - 3, _y + 2, _x + _width - 3, - _y + KEY_LINE_HEIGHT - 4 ); + p.drawLine( x + width - 3, y + 2, x + width - 3, + y + KEY_LINE_HEIGHT - 4 ); } - _p.drawLine( _x + _width - 1, _y + 2, _x + _width - 1, - _y + KEY_LINE_HEIGHT - 4 ); - _p.drawLine( _x + _width - 2, _y + 2, _x + _width - 2, - _y + KEY_LINE_HEIGHT - 4 ); + p.drawLine( x + width - 1, y + 2, x + width - 1, + y + KEY_LINE_HEIGHT - 4 ); + p.drawLine( x + width - 2, y + 2, x + width - 2, + y + KEY_LINE_HEIGHT - 4 ); } @@ -885,29 +885,29 @@ int PianoRoll::selectionCount() const // how many notes are selected? -void PianoRoll::keyPressEvent( QKeyEvent* event ) +void PianoRoll::keyPressEvent(QKeyEvent* ke ) { - if( hasValidPattern() && event->modifiers() == Qt::NoModifier ) + if( hasValidPattern() && ke->modifiers() == Qt::NoModifier ) { - const int key_num = PianoView::getKeyFromKeyEvent( event ) + ( DefaultOctave - 1 ) * KeysPerOctave; + const int key_num = PianoView::getKeyFromKeyEvent( ke ) + ( DefaultOctave - 1 ) * KeysPerOctave; - if( event->isAutoRepeat() == false && key_num > -1 ) + if( ke->isAutoRepeat() == false && key_num > -1 ) { m_pattern->instrumentTrack()->pianoModel()->handleKeyPress( key_num ); - event->accept(); + ke->accept(); } } - switch( event->key() ) + switch( ke->key() ) { case Qt::Key_Up: - if( ( event->modifiers() & Qt::ControlModifier ) && m_action == ActionNone ) + if( ( ke->modifiers() & Qt::ControlModifier ) && m_action == ActionNone ) { // shift selection up an octave // if nothing selected, shift _everything_ shiftSemiTone( +12 ); } - else if((event->modifiers() & Qt::ShiftModifier) && m_action == ActionNone) + else if((ke->modifiers() & Qt::ShiftModifier) && m_action == ActionNone) { // Move selected notes up by one semitone shiftSemiTone( 1 ); @@ -925,21 +925,21 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) m_action == ActionResizeNote ) { dragNotes( m_lastMouseX, m_lastMouseY, - event->modifiers() & Qt::AltModifier, - event->modifiers() & Qt::ShiftModifier ); + ke->modifiers() & Qt::AltModifier, + ke->modifiers() & Qt::ShiftModifier ); } } - event->accept(); + ke->accept(); break; case Qt::Key_Down: - if( event->modifiers() & Qt::ControlModifier && m_action == ActionNone ) + if( ke->modifiers() & Qt::ControlModifier && m_action == ActionNone ) { // shift selection down an octave // if nothing selected, shift _everything_ shiftSemiTone( -12 ); } - else if((event->modifiers() & Qt::ShiftModifier) && m_action == ActionNone) + else if((ke->modifiers() & Qt::ShiftModifier) && m_action == ActionNone) { // Move selected notes down by one semitone shiftSemiTone( -1 ); @@ -957,23 +957,23 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) m_action == ActionResizeNote ) { dragNotes( m_lastMouseX, m_lastMouseY, - event->modifiers() & Qt::AltModifier, - event->modifiers() & Qt::ShiftModifier ); + ke->modifiers() & Qt::AltModifier, + ke->modifiers() & Qt::ShiftModifier ); } } - event->accept(); + ke->accept(); break; case Qt::Key_Left: - if( event->modifiers() & Qt::ControlModifier && m_action == ActionNone ) + if( ke->modifiers() & Qt::ControlModifier && m_action == ActionNone ) { // Move selected notes by one bar to the left shiftPos( - MidiTime::ticksPerTact() ); } - else if( event->modifiers() & Qt::ShiftModifier && m_action == ActionNone) + else if( ke->modifiers() & Qt::ShiftModifier && m_action == ActionNone) { // move notes - bool quantized = ! ( event->modifiers() & Qt::AltModifier ); + bool quantized = ! ( ke->modifiers() & Qt::AltModifier ); int amt = quantized ? quantization() : 1; shiftPos( -amt ); } @@ -990,24 +990,24 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) m_action == ActionResizeNote ) { dragNotes( m_lastMouseX, m_lastMouseY, - event->modifiers() & Qt::AltModifier, - event->modifiers() & Qt::ShiftModifier ); + ke->modifiers() & Qt::AltModifier, + ke->modifiers() & Qt::ShiftModifier ); } } - event->accept(); + ke->accept(); break; case Qt::Key_Right: - if( event->modifiers() & Qt::ControlModifier && m_action == ActionNone) + if( ke->modifiers() & Qt::ControlModifier && m_action == ActionNone) { // Move selected notes by one bar to the right shiftPos( MidiTime::ticksPerTact() ); } - else if( event->modifiers() & Qt::ShiftModifier && m_action == ActionNone) + else if( ke->modifiers() & Qt::ShiftModifier && m_action == ActionNone) { // move notes - bool quantized = !( event->modifiers() & Qt::AltModifier ); + bool quantized = !( ke->modifiers() & Qt::AltModifier ); int amt = quantized ? quantization() : 1; shiftPos( +amt ); } @@ -1024,18 +1024,18 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) m_action == ActionResizeNote ) { dragNotes( m_lastMouseX, m_lastMouseY, - event->modifiers() & Qt::AltModifier, - event->modifiers() & Qt::ShiftModifier ); + ke->modifiers() & Qt::AltModifier, + ke->modifiers() & Qt::ShiftModifier ); } } - event->accept(); + ke->accept(); break; case Qt::Key_A: - if( event->modifiers() & Qt::ControlModifier ) + if( ke->modifiers() & Qt::ControlModifier ) { - event->accept(); + ke->accept(); selectAll(); update(); } @@ -1043,13 +1043,13 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) case Qt::Key_Delete: deleteSelectedNotes(); - event->accept(); + ke->accept(); break; case Qt::Key_Home: m_timeLine->pos().setTicks( 0 ); m_timeLine->updatePosition(); - event->accept(); + ke->accept(); break; case Qt::Key_0: @@ -1063,20 +1063,20 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) case Qt::Key_8: case Qt::Key_9: { - int len = 1 + event->key() - Qt::Key_0; + int len = 1 + ke->key() - Qt::Key_0; if( len == 10 ) { len = 0; } - if( event->modifiers() & ( Qt::ControlModifier | Qt::KeypadModifier ) ) + if( ke->modifiers() & ( Qt::ControlModifier | Qt::KeypadModifier ) ) { m_noteLenModel.setValue( len ); - event->accept(); + ke->accept(); } - else if( event->modifiers() & Qt::AltModifier ) + else if( ke->modifiers() & Qt::AltModifier ) { m_quantizeModel.setValue( len ); - event->accept(); + ke->accept(); } break; } @@ -1085,7 +1085,7 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) m_ctrlMode = m_editMode; m_editMode = ModeSelect; QApplication::changeOverrideCursor( Qt::ArrowCursor ); - event->accept(); + ke->accept(); break; default: break; @@ -1097,23 +1097,23 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) -void PianoRoll::keyReleaseEvent( QKeyEvent* event ) +void PianoRoll::keyReleaseEvent(QKeyEvent* ke ) { - if( hasValidPattern() && event->modifiers() == Qt::NoModifier ) + if( hasValidPattern() && ke->modifiers() == Qt::NoModifier ) { - const int key_num = PianoView::getKeyFromKeyEvent( event ) + ( DefaultOctave - 1 ) * KeysPerOctave; + const int key_num = PianoView::getKeyFromKeyEvent( ke ) + ( DefaultOctave - 1 ) * KeysPerOctave; - if( event->isAutoRepeat() == false && key_num > -1 ) + if( ke->isAutoRepeat() == false && key_num > -1 ) { m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( key_num ); - event->accept(); + ke->accept(); } } - switch( event->key() ) + switch( ke->key() ) { case Qt::Key_Control: - computeSelectedNotes( event->modifiers() & Qt::ShiftModifier); + computeSelectedNotes( ke->modifiers() & Qt::ShiftModifier); m_editMode = m_ctrlMode; update(); break; @@ -1121,7 +1121,7 @@ void PianoRoll::keyReleaseEvent( QKeyEvent* event ) // update after undo/redo case Qt::Key_Z: case Qt::Key_R: - if( hasValidPattern() && event->modifiers() == Qt::ControlModifier ) + if( hasValidPattern() && ke->modifiers() == Qt::ControlModifier ) { update(); } @@ -1134,14 +1134,14 @@ void PianoRoll::keyReleaseEvent( QKeyEvent* event ) -void PianoRoll::leaveEvent( QEvent * _e ) +void PianoRoll::leaveEvent(QEvent * e ) { while( QApplication::overrideCursor() != NULL ) { QApplication::restoreOverrideCursor(); } - QWidget::leaveEvent( _e ); + QWidget::leaveEvent( e ); s_textFloat->hide(); } @@ -1197,9 +1197,9 @@ inline int PianoRoll::keyAreaBottom() const -void PianoRoll::mousePressEvent( QMouseEvent * _me ) +void PianoRoll::mousePressEvent(QMouseEvent * me ) { - m_startedWithShift = _me->modifiers() & Qt::ShiftModifier; + m_startedWithShift = me->modifiers() & Qt::ShiftModifier; if( hasValidPattern() == false ) { @@ -1213,7 +1213,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) } // if holding control, go to selection mode - if( _me->modifiers() & Qt::ControlModifier && m_editMode != ModeSelect ) + if( me->modifiers() & Qt::ControlModifier && m_editMode != ModeSelect ) { m_ctrlMode = m_editMode; m_editMode = ModeSelect; @@ -1222,13 +1222,13 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) } // keep track of the point where the user clicked down - if( _me->button() == Qt::LeftButton ) + if( me->button() == Qt::LeftButton ) { - m_moveStartX = _me->x(); - m_moveStartY = _me->y(); + m_moveStartX = me->x(); + m_moveStartY = me->y(); } - if( _me->y() > keyAreaBottom() && _me->y() < noteEditTop() ) + if( me->y() > keyAreaBottom() && me->y() < noteEditTop() ) { // resizing the note edit area m_action = ActionResizeNoteEditArea; @@ -1236,13 +1236,13 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) return; } - if( _me->y() > PR_TOP_MARGIN ) + if( me->y() > PR_TOP_MARGIN ) { - bool edit_note = ( _me->y() > noteEditTop() ); + bool edit_note = ( me->y() > noteEditTop() ); - int key_num = getKey( _me->y() ); + int key_num = getKey( me->y() ); - int x = _me->x(); + int x = me->x(); if( x > WHITE_KEY_WIDTH ) @@ -1298,11 +1298,11 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) { m_pattern->addJournalCheckPoint(); // scribble note edit changes - mouseMoveEvent( _me ); + mouseMoveEvent( me ); return; } // left button?? - else if( _me->button() == Qt::LeftButton && + else if( me->button() == Qt::LeftButton && m_editMode == ModeDraw ) { // whether this action creates new note(s) or not @@ -1341,7 +1341,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) { // if a chord is selected, create following notes in chord // or arpeggio mode - const bool arpeggio = _me->modifiers() & Qt::ShiftModifier; + const bool arpeggio = me->modifiers() & Qt::ShiftModifier; for( int i = 1; i < chord.size(); i++ ) { if( arpeggio ) @@ -1460,7 +1460,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) // if they're holding shift, copy all selected notes if( //*it != created_new_note && - ! is_new_note && _me->modifiers() & Qt::ShiftModifier ) + ! is_new_note && me->modifiers() & Qt::ShiftModifier ) { // vector to hold new notes until we're through the loop QVector newNotes; @@ -1498,7 +1498,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) Engine::getSong()->setModified(); } - else if( ( _me->buttons() == Qt::RightButton && + else if( ( me->buttons() == Qt::RightButton && m_editMode == ModeDraw ) || m_editMode == ModeErase ) { @@ -1519,7 +1519,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) Engine::getSong()->setModified(); } } - else if( _me->button() == Qt::LeftButton && + else if( me->button() == Qt::LeftButton && m_editMode == ModeSelect ) { // select an area of notes @@ -1533,18 +1533,18 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) // call mousemove to fix glitch where selection // appears in wrong spot on mousedown - mouseMoveEvent( _me ); + mouseMoveEvent( me ); } update(); } - else if( _me->y() < keyAreaBottom() ) + else if( me->y() < keyAreaBottom() ) { // clicked on keyboard on the left - if( _me->buttons() == Qt::RightButton ) + if( me->buttons() == Qt::RightButton ) { // right click, tone marker contextual menu - m_semiToneMarkerMenu->popup( mapToGlobal( QPoint( _me->x(), _me->y() ) ) ); + m_semiToneMarkerMenu->popup( mapToGlobal( QPoint( me->x(), me->y() ) ) ); } else { @@ -1559,20 +1559,20 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) } else { - if( _me->buttons() == Qt::LeftButton ) + if( me->buttons() == Qt::LeftButton ) { // clicked in the box below the keys to the left of note edit area - m_noteEditMode = (noteEditMode)(((int)m_noteEditMode)+1); + m_noteEditMode = (NoteEditMode)(((int)m_noteEditMode)+1); if( m_noteEditMode == NoteEditCount ) { - m_noteEditMode = (noteEditMode)0; + m_noteEditMode = (NoteEditMode)0; } repaint(); } - else if( _me->buttons() == Qt::RightButton ) + else if( me->buttons() == Qt::RightButton ) { // pop menu asking which one they want to edit - m_noteEditMenu->popup( mapToGlobal( QPoint( _me->x(), _me->y() ) ) ); + m_noteEditMenu->popup( mapToGlobal( QPoint( me->x(), me->y() ) ) ); } } } @@ -1581,7 +1581,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) -void PianoRoll::mouseDoubleClickEvent( QMouseEvent * _me ) +void PianoRoll::mouseDoubleClickEvent(QMouseEvent * me ) { if( hasValidPattern() == false ) { @@ -1589,12 +1589,12 @@ void PianoRoll::mouseDoubleClickEvent( QMouseEvent * _me ) } // if they clicked in the note edit area, enter value for the volume bar - if( _me->x() > noteEditLeft() && _me->x() < noteEditRight() - && _me->y() > noteEditTop() && _me->y() < noteEditBottom() ) + if( me->x() > noteEditLeft() && me->x() < noteEditRight() + && me->y() > noteEditTop() && me->y() < noteEditBottom() ) { // get values for going through notes int pixel_range = 4; - int x = _me->x() - WHITE_KEY_WIDTH; + int x = me->x() - WHITE_KEY_WIDTH; const int ticks_start = ( x-pixel_range/2 ) * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; const int ticks_end = ( x+pixel_range/2 ) * @@ -1675,7 +1675,7 @@ void PianoRoll::testPlayNote( Note * n ) -void PianoRoll::pauseTestNotes( bool _pause ) +void PianoRoll::pauseTestNotes( bool pause ) { const NoteVector & notes = m_pattern->notes(); NoteVector::ConstIterator it = notes.begin(); @@ -1683,7 +1683,7 @@ void PianoRoll::pauseTestNotes( bool _pause ) { if( ( *it )->isPlaying() ) { - if( _pause ) + if( pause ) { // stop note m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( ( *it )->key() ); @@ -1799,33 +1799,33 @@ void PianoRoll::computeSelectedNotes(bool shift) -void PianoRoll::mouseReleaseEvent( QMouseEvent * _me ) +void PianoRoll::mouseReleaseEvent(QMouseEvent * me ) { s_textFloat->hide(); bool mustRepaint = false; - if( _me->button() & Qt::LeftButton ) + if( me->button() & Qt::LeftButton ) { m_mouseDownLeft = false; mustRepaint = true; } - if( _me->button() & Qt::RightButton ) + if( me->button() & Qt::RightButton ) { m_mouseDownRight = false; mustRepaint = true; } - if( _me->button() & Qt::LeftButton && + if( me->button() & Qt::LeftButton && m_editMode == ModeSelect && m_action == ActionSelectNotes ) { // select the notes within the selection rectangle and // then destroy the selection rectangle - computeSelectedNotes( _me->modifiers() & Qt::ShiftModifier ); + computeSelectedNotes( me->modifiers() & Qt::ShiftModifier ); } - else if( _me->button() & Qt::LeftButton && + else if( me->button() & Qt::LeftButton && m_action == ActionMoveNote ) { // we moved one or more notes so they have to be @@ -1835,7 +1835,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * _me ) m_pattern->rearrangeAllNotes(); } - if( _me->button() & Qt::LeftButton && + if( me->button() & Qt::LeftButton && ( m_action == ActionMoveNote || m_action == ActionResizeNote ) ) { // if we only moved one note, deselect it so we can @@ -1886,7 +1886,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * _me ) -void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) +void PianoRoll::mouseMoveEvent( QMouseEvent * me ) { if( hasValidPattern() == false ) { @@ -1894,9 +1894,9 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) return; } - if( m_action == ActionNone && _me->buttons() == 0 ) + if( m_action == ActionNone && me->buttons() == 0 ) { - if( _me->y() > keyAreaBottom() && _me->y() < noteEditTop() ) + if( me->y() > keyAreaBottom() && me->y() < noteEditTop() ) { QApplication::setOverrideCursor( QCursor( Qt::SizeVerCursor ) ); @@ -1907,7 +1907,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) { // change m_notesEditHeight and then repaint m_notesEditHeight = tLimit( - m_oldNotesEditHeight - ( _me->y() - m_moveStartY ), + m_oldNotesEditHeight - ( me->y() - m_moveStartY ), NOTE_EDIT_MIN_HEIGHT, height() - PR_TOP_MARGIN - NOTE_EDIT_RESIZE_BAR - PR_BOTTOM_MARGIN - KEY_AREA_MIN_HEIGHT ); @@ -1915,19 +1915,19 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) return; } - if( _me->y() > PR_TOP_MARGIN || m_action != ActionNone ) + if( me->y() > PR_TOP_MARGIN || m_action != ActionNone ) { - bool edit_note = ( _me->y() > noteEditTop() ) + bool edit_note = ( me->y() > noteEditTop() ) && m_action != ActionSelectNotes; - int key_num = getKey( _me->y() ); - int x = _me->x(); + int key_num = getKey( me->y() ); + int x = me->x(); // see if they clicked on the keyboard on the left if( x < WHITE_KEY_WIDTH && m_action == ActionNone && ! edit_note && key_num != m_lastKey - && _me->buttons() & Qt::LeftButton ) + && me->buttons() & Qt::LeftButton ) { // clicked on a key, play the note testPlayKey( key_num, ( (float) x ) / ( (float) WHITE_KEY_WIDTH ) * MidiDefaultVelocity, 0 ); @@ -1937,7 +1937,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) x -= WHITE_KEY_WIDTH; - if( _me->buttons() & Qt::LeftButton + if( me->buttons() & Qt::LeftButton && m_editMode == ModeDraw && (m_action == ActionMoveNote || m_action == ActionResizeNote ) ) { @@ -1945,26 +1945,26 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) bool replay_note = key_num != m_lastKey && m_action == ActionMoveNote; - if( replay_note || ( m_action == ActionMoveNote && ( _me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) + if( replay_note || ( m_action == ActionMoveNote && ( me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) { pauseTestNotes(); } dragNotes( - _me->x(), - _me->y(), - _me->modifiers() & Qt::AltModifier, - _me->modifiers() & Qt::ShiftModifier + me->x(), + me->y(), + me->modifiers() & Qt::AltModifier, + me->modifiers() & Qt::ShiftModifier ); - if( replay_note && m_action == ActionMoveNote && ! ( ( _me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) + if( replay_note && m_action == ActionMoveNote && ! ( ( me->modifiers() & Qt::ShiftModifier ) && ! m_startedWithShift ) ) { pauseTestNotes( false ); } } else if( ( edit_note == true || m_action == ActionChangeNoteProperty ) && - ( _me->buttons() & Qt::LeftButton || _me->buttons() & Qt::MiddleButton - || ( _me->buttons() & Qt::RightButton && _me->modifiers() & Qt::ShiftModifier ) ) ) + ( me->buttons() & Qt::LeftButton || me->buttons() & Qt::MiddleButton + || ( me->buttons() & Qt::RightButton && me->modifiers() & Qt::ShiftModifier ) ) ) { // editing note properties @@ -1987,15 +1987,15 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) volume_t vol; panning_t pan; - if( _me->buttons() & Qt::LeftButton ) + if( me->buttons() & Qt::LeftButton ) { vol = tLimit( MinVolume + - ( ( (float)noteEditBottom() ) - ( (float)_me->y() ) ) / + ( ( (float)noteEditBottom() ) - ( (float)me->y() ) ) / ( (float)( noteEditBottom() - noteEditTop() ) ) * ( MaxVolume - MinVolume ), MinVolume, MaxVolume ); pan = tLimit( PanningLeft + - ( (float)( noteEditBottom() - _me->y() ) ) / + ( (float)( noteEditBottom() - me->y() ) ) / ( (float)( noteEditBottom() - noteEditTop() ) ) * ( (float)( PanningRight - PanningLeft ) ), PanningLeft, PanningRight); @@ -2081,7 +2081,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) // set textfloat visible if we're on a note if( on_note ) { - s_textFloat->moveGlobal( this, QPoint( _me->x() + 4, _me->y() + 16 ) ); + s_textFloat->moveGlobal( this, QPoint( me->x() + 4, me->y() + 16 ) ); s_textFloat->show(); } else @@ -2094,7 +2094,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) } } - else if( _me->buttons() == Qt::NoButton && m_editMode == ModeDraw ) + else if( me->buttons() == Qt::NoButton && m_editMode == ModeDraw ) { // set move- or resize-cursor @@ -2190,7 +2190,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) } } } - else if( _me->buttons() & Qt::LeftButton && + else if( me->buttons() & Qt::LeftButton && m_editMode == ModeSelect && m_action == ActionSelectNotes ) { @@ -2213,7 +2213,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) --m_selectedKeys; } } - else if( m_editMode == ModeDraw && _me->buttons() & Qt::RightButton ) + else if( m_editMode == ModeDraw && me->buttons() & Qt::RightButton ) { // holding down right-click to delete notes @@ -2277,18 +2277,18 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) } else { - if( _me->buttons() & Qt::LeftButton && + if( me->buttons() & Qt::LeftButton && m_editMode == ModeSelect && m_action == ActionSelectNotes ) { - int x = _me->x() - WHITE_KEY_WIDTH; + int x = me->x() - WHITE_KEY_WIDTH; if( x < 0 && m_currentPosition > 0 ) { x = 0; QCursor::setPos( mapToGlobal( QPoint( WHITE_KEY_WIDTH, - _me->y() ) ) ); + me->y() ) ) ); if( m_currentPosition >= 4 ) { m_leftRightScroll->setValue( @@ -2303,7 +2303,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) { x = width() - WHITE_KEY_WIDTH; QCursor::setPos( mapToGlobal( QPoint( width(), - _me->y() ) ) ); + me->y() ) ) ); m_leftRightScroll->setValue( m_currentPosition + 4 ); } @@ -2322,7 +2322,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) } - int key_num = getKey( _me->y() ); + int key_num = getKey( me->y() ); int visible_keys = ( height() - PR_TOP_MARGIN - PR_BOTTOM_MARGIN - m_notesEditHeight ) / @@ -2331,7 +2331,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) if( key_num <= s_key ) { - QCursor::setPos( mapToGlobal( QPoint( _me->x(), + QCursor::setPos( mapToGlobal( QPoint( me->x(), keyAreaBottom() ) ) ); m_topBottomScroll->setValue( m_topBottomScroll->value() + 1 ); @@ -2339,7 +2339,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) } else if( key_num >= s_key + visible_keys ) { - QCursor::setPos( mapToGlobal( QPoint( _me->x(), + QCursor::setPos( mapToGlobal( QPoint( me->x(), PR_TOP_MARGIN ) ) ); m_topBottomScroll->setValue( m_topBottomScroll->value() - 1 ); @@ -2355,8 +2355,8 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) QApplication::restoreOverrideCursor(); } - m_lastMouseX = _me->x(); - m_lastMouseY = _me->y(); + m_lastMouseX = me->x(); + m_lastMouseY = me->y(); update(); } @@ -2554,7 +2554,7 @@ static void printNoteHeights(QPainter& p, int bottom, int width, int startKey) } } -void PianoRoll::paintEvent( QPaintEvent * _pe ) +void PianoRoll::paintEvent(QPaintEvent * pe ) { QColor horizCol = QColor( gridColor() ); QColor vertCol = QColor( gridColor() ); @@ -3065,7 +3065,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe ) // responsible for moving/resizing scrollbars after window-resizing -void PianoRoll::resizeEvent( QResizeEvent * ) +void PianoRoll::resizeEvent(QResizeEvent * re) { m_leftRightScroll->setGeometry( WHITE_KEY_WIDTH, height() - SCROLLBAR_SIZE, @@ -3098,16 +3098,16 @@ void PianoRoll::resizeEvent( QResizeEvent * ) -void PianoRoll::wheelEvent( QWheelEvent * _we ) +void PianoRoll::wheelEvent(QWheelEvent * we ) { - _we->accept(); + we->accept(); // handle wheel events for note edit area - for editing note vol/pan with mousewheel - if( _we->x() > noteEditLeft() && _we->x() < noteEditRight() - && _we->y() > noteEditTop() && _we->y() < noteEditBottom() ) + if( we->x() > noteEditLeft() && we->x() < noteEditRight() + && we->y() > noteEditTop() && we->y() < noteEditBottom() ) { // get values for going through notes int pixel_range = 8; - int x = _we->x() - WHITE_KEY_WIDTH; + int x = we->x() - WHITE_KEY_WIDTH; int ticks_start = ( x-pixel_range/2 ) * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; int ticks_end = ( x+pixel_range/2 ) * @@ -3131,7 +3131,7 @@ void PianoRoll::wheelEvent( QWheelEvent * _we ) } if( nv.size() > 0 ) { - const int step = _we->delta() > 0 ? 1.0 : -1.0; + const int step = we->delta() > 0 ? 1.0 : -1.0; if( m_noteEditMode == NoteEditVolume ) { foreach( Note * n, nv ) @@ -3164,7 +3164,7 @@ void PianoRoll::wheelEvent( QWheelEvent * _we ) } if( nv.size() == 1 ) { - s_textFloat->moveGlobal( this, QPoint( _we->x() + 4, _we->y() + 16 ) ); + s_textFloat->moveGlobal( this, QPoint( we->x() + 4, we->y() + 16 ) ); s_textFloat->setVisibilityTimeOut( 1000 ); } update(); @@ -3173,42 +3173,42 @@ void PianoRoll::wheelEvent( QWheelEvent * _we ) // not in note edit area, so handle scrolling/zooming and quantization change else - if( _we->modifiers() & Qt::ControlModifier && _we->modifiers() & Qt::AltModifier ) + if( we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::AltModifier ) { int q = m_quantizeModel.value(); - if( _we->delta() > 0 ) + if( we->delta() > 0 ) { q--; } - if( _we->delta() < 0 ) + if( we->delta() < 0 ) { q++; } q = qBound( 0, q, m_quantizeModel.size() - 1 ); m_quantizeModel.setValue( q ); } - else if( _we->modifiers() & Qt::ControlModifier && _we->modifiers() & Qt::ShiftModifier ) + else if( we->modifiers() & Qt::ControlModifier && we->modifiers() & Qt::ShiftModifier ) { int l = m_noteLenModel.value(); - if( _we->delta() > 0 ) + if( we->delta() > 0 ) { l--; } - if( _we->delta() < 0 ) + if( we->delta() < 0 ) { l++; } l = qBound( 0, l, m_noteLenModel.size() - 1 ); m_noteLenModel.setValue( l ); } - else if( _we->modifiers() & Qt::ControlModifier ) + else if( we->modifiers() & Qt::ControlModifier ) { int z = m_zoomingModel.value(); - if( _we->delta() > 0 ) + if( we->delta() > 0 ) { z++; } - if( _we->delta() < 0 ) + if( we->delta() < 0 ) { z--; } @@ -3216,27 +3216,27 @@ void PianoRoll::wheelEvent( QWheelEvent * _we ) // update combobox with zooming-factor m_zoomingModel.setValue( z ); } - else if( _we->modifiers() & Qt::ShiftModifier - || _we->orientation() == Qt::Horizontal ) + else if( we->modifiers() & Qt::ShiftModifier + || we->orientation() == Qt::Horizontal ) { m_leftRightScroll->setValue( m_leftRightScroll->value() - - _we->delta() * 2 / 15 ); + we->delta() * 2 / 15 ); } else { m_topBottomScroll->setValue( m_topBottomScroll->value() - - _we->delta() / 30 ); + we->delta() / 30 ); } } -int PianoRoll::getKey( int _y ) const +int PianoRoll::getKey(int y ) const { int key_line_y = keyAreaBottom() - 1; // pressed key on piano - int key_num = ( key_line_y - _y ) / KEY_LINE_HEIGHT; + int key_num = ( key_line_y - y ) / KEY_LINE_HEIGHT; key_num += m_startKey; // some range-checking-stuff @@ -3345,7 +3345,7 @@ void PianoRoll::stop() -void PianoRoll::startRecordNote( const Note & _n ) +void PianoRoll::startRecordNote(const Note & n ) { if( m_recording == true && hasValidPattern() == true && Engine::getSong()->isPlaying() && @@ -3361,7 +3361,7 @@ void PianoRoll::startRecordNote( const Note & _n ) } Note n( 1, Engine::getSong()->getPlayPos( Engine::getSong()->playMode() ) - sub, - _n.key(), _n.getVolume(), _n.getPanning() ); + n.key(), n.getVolume(), n.getPanning() ); if( n.pos() >= 0 ) { m_recordingNotes << n; @@ -3372,7 +3372,7 @@ void PianoRoll::startRecordNote( const Note & _n ) -void PianoRoll::finishRecordNote( const Note & _n ) +void PianoRoll::finishRecordNote(const Note & n ) { if( m_recording == true && hasValidPattern() == true && Engine::getSong()->isPlaying() && @@ -3384,9 +3384,9 @@ void PianoRoll::finishRecordNote( const Note & _n ) for( QList::Iterator it = m_recordingNotes.begin(); it != m_recordingNotes.end(); ++it ) { - if( it->key() == _n.key() ) + if( it->key() == n.key() ) { - Note n( _n.length(), it->pos(), + Note n( n.length(), it->pos(), it->key(), it->getVolume(), it->getPanning() ); n.quantizeLength( quantization() ); @@ -3402,9 +3402,9 @@ void PianoRoll::finishRecordNote( const Note & _n ) -void PianoRoll::horScrolled( int _new_pos ) +void PianoRoll::horScrolled(int new_pos ) { - m_currentPosition = _new_pos; + m_currentPosition = new_pos; emit positionChanged( m_currentPosition ); update(); } @@ -3412,10 +3412,10 @@ void PianoRoll::horScrolled( int _new_pos ) -void PianoRoll::verScrolled( int _new_pos ) +void PianoRoll::verScrolled( int new_pos ) { // revert value - m_startKey = m_totalKeysToScroll - _new_pos; + m_startKey = m_totalKeysToScroll - new_pos; update(); } @@ -3423,7 +3423,7 @@ void PianoRoll::verScrolled( int _new_pos ) -void PianoRoll::setEditMode(PianoRoll::editModes mode) +void PianoRoll::setEditMode(PianoRoll::EditModes mode) { m_editMode = mode; } @@ -3489,7 +3489,7 @@ void PianoRoll::selectAll() // returns vector with pointers to all selected notes -void PianoRoll::getSelectedNotes( NoteVector & _selected_notes ) +void PianoRoll::getSelectedNotes(NoteVector & selected_notes ) { if( hasValidPattern() == false ) { @@ -3503,7 +3503,7 @@ void PianoRoll::getSelectedNotes( NoteVector & _selected_notes ) { if( ( *it )->selected() ) { - _selected_notes.push_back( *it ); + selected_notes.push_back( *it ); } } } @@ -3554,14 +3554,14 @@ void PianoRoll::enterValue( NoteVector* nv ) } -void PianoRoll::copy_to_clipboard( const NoteVector & _notes ) const +void PianoRoll::copy_to_clipboard( const NoteVector & notes ) const { DataFile dataFile( DataFile::ClipboardData ); QDomElement note_list = dataFile.createElement( "note-list" ); dataFile.content().appendChild( note_list ); - MidiTime start_pos( _notes.front()->pos().getTact(), 0 ); - for( NoteVector::ConstIterator it = _notes.begin(); it != _notes.end(); + MidiTime start_pos( notes.front()->pos().getTact(), 0 ); + for( NoteVector::ConstIterator it = notes.begin(); it != notes.end(); ++it ) { Note clip_note( **it ); @@ -3719,19 +3719,19 @@ void PianoRoll::deleteSelectedNotes() -void PianoRoll::autoScroll( const MidiTime & _t ) +void PianoRoll::autoScroll( const MidiTime & t ) { const int w = width() - WHITE_KEY_WIDTH; - if( _t > m_currentPosition + w * MidiTime::ticksPerTact() / m_ppt ) + if( t > m_currentPosition + w * MidiTime::ticksPerTact() / m_ppt ) { - m_leftRightScroll->setValue( _t.getTact() * + m_leftRightScroll->setValue( t.getTact() * MidiTime::ticksPerTact() ); } - else if( _t < m_currentPosition ) + else if( t < m_currentPosition ) { - MidiTime t = qMax( _t - w * MidiTime::ticksPerTact() * + MidiTime t2 = qMax( t - w * MidiTime::ticksPerTact() * MidiTime::ticksPerTact() / m_ppt, 0 ); - m_leftRightScroll->setValue( t.getTact() * + m_leftRightScroll->setValue( t2.getTact() * MidiTime::ticksPerTact() ); } m_scrollBack = false; @@ -3740,7 +3740,7 @@ void PianoRoll::autoScroll( const MidiTime & _t ) -void PianoRoll::updatePosition( const MidiTime & _t ) +void PianoRoll::updatePosition( const MidiTime & t ) { if( ( Engine::getSong()->isPlaying() && Engine::getSong()->playMode() == @@ -3748,21 +3748,21 @@ void PianoRoll::updatePosition( const MidiTime & _t ) m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled ) || m_scrollBack == true ) { - autoScroll( _t ); + autoScroll( t ); } } -void PianoRoll::updatePositionAccompany( const MidiTime & _t ) +void PianoRoll::updatePositionAccompany( const MidiTime & t ) { Song * s = Engine::getSong(); if( m_recording && hasValidPattern() && s->playMode() != Song::Mode_PlayPattern ) { - MidiTime pos = _t; + MidiTime pos = t; if( s->playMode() != Song::Mode_PlayBB ) { pos -= m_pattern->startPosition(); From ebbec2f2700a993c59429c4323206e62682944ff Mon Sep 17 00:00:00 2001 From: Lukas W Date: Thu, 11 Dec 2014 02:39:04 +0100 Subject: [PATCH 22/32] Editor: Add edit mode support --- include/Editor.h | 18 +++++++++++ include/PianoRoll.h | 6 +--- src/gui/editors/AutomationEditor.cpp | 46 ++++------------------------ src/gui/editors/Editor.cpp | 40 ++++++++++++++++++++++-- src/gui/editors/PianoRoll.cpp | 26 +++++----------- src/gui/editors/SongEditor.cpp | 9 ++---- 6 files changed, 71 insertions(+), 74 deletions(-) diff --git a/include/Editor.h b/include/Editor.h index 4da0fdbdb..458fc34fe 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -25,12 +25,16 @@ #ifndef EDITOR_COMMON_H #define EDITOR_COMMON_H +#include #include #include #include "TimeLineWidget.h" #include "ToolButton.h" +// Forward declarations +class QActionGroup; + /// \brief Superclass for editors with a toolbar. /// /// Those editors include the Song Editor, the Automation Editor, B&B Editor, @@ -41,12 +45,24 @@ class Editor : public QMainWindow public: void setPauseIcon(bool displayPauseIcon=true); + int editMode() const; + void setEditMode(int mode); + +signals: + void editModeChanged(int); + +protected: + QAction* addEditMode(const QIcon &icon, const QString &text, const QString& whatsThis=QString()); + protected slots: virtual void play(); virtual void record(); virtual void recordAccompany(); virtual void stop(); +private slots: + void setEditModeByAction(QAction* action); + signals: protected: @@ -65,6 +81,8 @@ protected: QAction* m_recordAccompanyAction; QAction* m_stopAction; private: + quint8 m_editMode; + QActionGroup* m_editModeGroup; }; diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 5ac1a2453..7a7a3f094 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -140,11 +140,7 @@ protected slots: void horScrolled( int new_pos ); void verScrolled( int new_pos ); - void setEditMode(EditModes mode); - void setEditModeDraw() {setEditMode(ModeDraw); } - void setEditModeErase() {setEditMode(ModeErase); } - void setEditModeSelect() {setEditMode(ModeSelect); } - void setEditModeDetune() {setEditMode(ModeEditDetuning); } + void setEditMode(int mode); void copySelectedNotes(); void cutSelectedNotes(); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 135425abc..7ccf6d286 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -2005,51 +2005,17 @@ AutomationEditorWindow::AutomationEditorWindow() : "current pattern." ) ); // Edit mode buttons - QActionGroup * tool_action_group = new QActionGroup(this); - - m_drawAction = new QAction(embed::getIconPixmap("edit_draw"), - tr("Draw mode (Shift+D)"), tool_action_group); - m_drawAction->setCheckable(true); + m_drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); m_drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); - m_eraseAction = new QAction(embed::getIconPixmap("edit_erase"), - tr("Erase mode (Shift+E)"), tool_action_group); - m_eraseAction->setCheckable(true); + m_eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); m_eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); m_drawAction->setChecked(true); - //TODO: m_selectButton and m_moveButton are broken. - /*m_selectButton = new ToolButton( embed::getIconPixmap( - "edit_select" ), - tr( "Select mode (Shift+S)" ), - this, SLOT( selectButtonToggled() ), - m_toolBar ); - m_selectButton->setCheckable( true ); - - m_moveButton = new ToolButton( embed::getIconPixmap( "edit_move" ), - tr( "Move selection mode (Shift+M)" ), - this, SLOT( moveButtonToggled() ), - m_toolBar ); - m_moveButton->setCheckable( true );*/ - - QSignalMapper* signalmapper = new QSignalMapper(this); - signalmapper->setMapping(m_drawAction, AutomationEditor::DRAW); - signalmapper->setMapping(m_eraseAction, AutomationEditor::ERASE); -// signalmapper->setMapping(m_selectButton, AutomationEditor::SELECT); -// signalmapper->setMapping(m_moveButton, AutomationEditor::MOVE); - - connect(m_drawAction, SIGNAL(triggered()), signalmapper, SLOT(map())); - connect(m_eraseAction, SIGNAL(triggered()), signalmapper, SLOT(map())); -// connect(m_selectButton, SIGNAL(triggered()), signalmapper, SLOT(map())); -// connect(m_moveButton, SIGNAL(triggered()), signalmapper, SLOT(map())); - - connect(signalmapper, SIGNAL(mapped(int)), m_editor, SLOT(setEditMode(int))); - -// tool_action_group->addAction( m_drawButton ); -// tool_action_group->addAction( m_eraseButton ); - //tool_button_group->addButton( m_selectButton ); - //tool_button_group->addButton( m_moveButton ); +// TODO: m_selectButton and m_moveButton are broken. +// m_selectButton = addEditMode(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)")); +// m_moveButton = addEditMode(embed::getIconPixmap("edit_move"), tr("Move selection mode (Shift+M)")); m_drawAction->setWhatsThis( tr( "Click here and draw-mode will be activated. In this " @@ -2073,7 +2039,7 @@ AutomationEditorWindow::AutomationEditorWindow() : "mode. You can also press 'Shift+M' on your keyboard " "to activate this mode." ) );*/ - + connect(this, SIGNAL(editModeChanged(int)), m_editor, SLOT(setEditMode(int))); // Progression type buttons QActionGroup* progression_type_group = new QActionGroup(this); diff --git a/src/gui/editors/Editor.cpp b/src/gui/editors/Editor.cpp index 778a303a9..48921d6bd 100644 --- a/src/gui/editors/Editor.cpp +++ b/src/gui/editors/Editor.cpp @@ -27,9 +27,9 @@ #include "MainWindow.h" #include "embed.h" -#include #include -#include +#include +#include void Editor::setPauseIcon(bool displayPauseIcon) @@ -41,6 +41,28 @@ void Editor::setPauseIcon(bool displayPauseIcon) m_playAction->setIcon(embed::getIconPixmap("play")); } +int Editor::editMode() const +{ + return m_editMode; +} + +void Editor::setEditMode(int mode) +{ + if (mode <= m_editModeGroup->actions().size()) + { + m_editMode = mode; + } + emit(editModeChanged(mode)); +} + +QAction* Editor::addEditMode(const QIcon& icon, const QString& text, const QString& whatsThis) +{ + QAction* editModeAction = new QAction(icon, text, m_editModeGroup); + editModeAction->setWhatsThis(whatsThis); + editModeAction->setCheckable(true); + return editModeAction; +} + void Editor::play() { } @@ -57,12 +79,21 @@ void Editor::stop() { } +void Editor::setEditModeByAction(QAction* action) +{ + int index = m_editModeGroup->actions().indexOf(action); + if (index != -1) + setEditMode(index); +} + Editor::Editor(bool record) : m_toolBar(new QToolBar(this)), m_playAction(nullptr), m_recordAction(nullptr), m_recordAccompanyAction(nullptr), - m_stopAction(nullptr) + m_stopAction(nullptr), + m_editMode(0), + m_editModeGroup(new QActionGroup(this)) { m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu); m_toolBar->setMovable(false); @@ -98,6 +129,9 @@ Editor::Editor(bool record) : connect(m_recordAccompanyAction, SIGNAL(triggered()), this, SLOT(recordAccompany())); } connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stop())); + + // Connect edit mode + connect(m_editModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setEditModeByAction(QAction*))); } Editor::~Editor() diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 0ebc9624b..982d4e003 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -3423,9 +3423,9 @@ void PianoRoll::verScrolled( int new_pos ) -void PianoRoll::setEditMode(PianoRoll::EditModes mode) +void PianoRoll::setEditMode(int mode) { - m_editMode = mode; + m_editMode = (EditModes) mode; } @@ -3940,27 +3940,18 @@ PianoRollWindow::PianoRollWindow() : tr( "Click here to stop playback of current pattern." ) ); // init edit-buttons at the top - QActionGroup* tool_button_group = new QActionGroup(this); - m_drawAction = new QAction(embed::getIconPixmap("edit_draw"), - tr( "Draw mode (Shift+D)" ), tool_button_group); + m_drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); m_drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); - m_drawAction->setCheckable( true ); m_drawAction->setChecked( true ); - m_eraseAction = new QAction(embed::getIconPixmap("edit_erase"), - tr("Erase mode (Shift+E)"), tool_button_group); + m_eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); m_eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); - m_eraseAction->setCheckable( true ); - m_selectAction = new QAction( embed::getIconPixmap("edit_select"), - tr("Select mode (Shift+S)"), tool_button_group); + m_selectAction = addEditMode(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)")); m_selectAction->setShortcut(Qt::SHIFT | Qt::Key_S); - m_selectAction->setCheckable( true ); - m_detuneAction = new QAction(embed::getIconPixmap("automation"), - tr("Detune mode (Shift+T)"), tool_button_group); + m_detuneAction = addEditMode(embed::getIconPixmap("automation"), tr("Detune mode (Shift+T)")); m_detuneAction->setShortcut(Qt::SHIFT | Qt::Key_T); - m_detuneAction->setCheckable( true ); m_drawAction->setWhatsThis( tr( "Click here and draw mode will be activated. In this " @@ -3985,10 +3976,7 @@ PianoRollWindow::PianoRollWindow() : "notes from one to another. You can also press " "'Shift+T' on your keyboard to activate this mode." ) ); - connect(m_drawAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeDraw())); - connect(m_eraseAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeErase())); - connect(m_selectAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeSelect())); - connect(m_detuneAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeDetune())); + connect(this, SIGNAL(editModeChanged(int)), m_editor, SLOT(setEditMode(int))); // Copy + paste actions m_cutAction = new QAction(embed::getIconPixmap("edit_cut"), diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 5d65e9ee3..4ff5153c0 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -631,15 +631,10 @@ SongEditorWindow::SongEditorWindow(Song* song) : connect(m_addSampleTrackAction, SIGNAL(triggered()), m_editor->m_song, SLOT(addSampleTrack())); connect(m_addAutomationTrackAction, SIGNAL(triggered()), m_editor->m_song, SLOT(addAutomationTrack())); - QActionGroup* tool_action_group = new QActionGroup(this); - m_drawModeAction = new QAction(embed::getIconPixmap("edit_draw"), - tr("Draw mode"), tool_action_group); - m_drawModeAction->setCheckable(true); + m_drawModeAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode")); m_drawModeAction->setChecked(true); - m_selectModeAction = new QAction(embed::getIconPixmap("edit_select"), - tr("Edit mode (select and move)"), tool_action_group); - m_selectModeAction->setCheckable(true); + m_selectModeAction = addEditMode(embed::getIconPixmap("edit_select"), tr("Edit mode (select and move)")); connect(m_drawModeAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeDraw())); connect(m_selectModeAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeSelect())); From 9b6612c396a211f08747dccaeeca0ff1d7fbbb34 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Thu, 11 Dec 2014 10:38:04 +0100 Subject: [PATCH 23/32] PianoRoll rename fix --- src/gui/editors/PianoRoll.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 982d4e003..2e4fbe547 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -3347,24 +3347,22 @@ void PianoRoll::stop() void PianoRoll::startRecordNote(const Note & n ) { - if( m_recording == true && hasValidPattern() == true && - Engine::getSong()->isPlaying() && - ( Engine::getSong()->playMode() == - desiredPlayModeForAccompany() || - Engine::getSong()->playMode() == - Song::Mode_PlayPattern ) ) + if(m_recording && hasValidPattern() && + Engine::getSong()->isPlaying() && + (Engine::getSong()->playMode() == desiredPlayModeForAccompany() || + Engine::getSong()->playMode() == Song::Mode_PlayPattern )) { MidiTime sub; if( Engine::getSong()->playMode() == Song::Mode_PlaySong ) { sub = m_pattern->startPosition(); } - Note n( 1, Engine::getSong()->getPlayPos( + Note n1( 1, Engine::getSong()->getPlayPos( Engine::getSong()->playMode() ) - sub, n.key(), n.getVolume(), n.getPanning() ); - if( n.pos() >= 0 ) + if( n1.pos() >= 0 ) { - m_recordingNotes << n; + m_recordingNotes << n1; } } } From 02869b13dde1b6baa99b41aa177ea698144e0a89 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Thu, 11 Dec 2014 11:24:26 +0100 Subject: [PATCH 24/32] Editors: Some cleanups --- include/AutomationEditor.h | 10 +-- include/PianoRoll.h | 9 --- src/gui/editors/AutomationEditor.cpp | 48 ++++++------ src/gui/editors/Editor.cpp | 46 +++++------ src/gui/editors/PianoRoll.cpp | 109 ++++++++++++++------------- src/gui/editors/SongEditor.cpp | 7 +- 6 files changed, 105 insertions(+), 124 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 2c48ef800..ee6fd9842 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -276,19 +276,11 @@ protected slots: void stop(); private: - QAction* m_drawAction; - QAction* m_eraseAction; - QAction* m_selectAction; - QAction* m_moveAction; - QAction* m_discreteAction; QAction* m_linearAction; QAction* m_cubicHermiteAction; - Knob * m_tensionKnob; - QAction * m_cutAction; - QAction * m_copyAction; - QAction * m_pasteAction; + Knob * m_tensionKnob; ComboBox * m_zoomingXComboBox; ComboBox * m_zoomingYComboBox; diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 7a7a3f094..34b6693a0 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -384,15 +384,6 @@ signals: private: PianoRoll* m_editor; - QAction* m_drawAction; - QAction* m_eraseAction; - QAction* m_selectAction; - QAction* m_detuneAction; - - QAction* m_cutAction; - QAction* m_copyAction; - QAction* m_pasteAction; - ComboBox * m_zoomingComboBox; ComboBox * m_quantizeComboBox; ComboBox * m_noteLenComboBox; diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 7ccf6d286..28beedcf5 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -2005,25 +2005,25 @@ AutomationEditorWindow::AutomationEditorWindow() : "current pattern." ) ); // Edit mode buttons - m_drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); - m_drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); + QAction* drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); + drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); - m_eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); - m_eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); + QAction* eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); + eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); - m_drawAction->setChecked(true); + drawAction->setChecked(true); // TODO: m_selectButton and m_moveButton are broken. // m_selectButton = addEditMode(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)")); // m_moveButton = addEditMode(embed::getIconPixmap("edit_move"), tr("Move selection mode (Shift+M)")); - m_drawAction->setWhatsThis( + drawAction->setWhatsThis( tr( "Click here and draw-mode will be activated. In this " "mode you can add and move single values. This " "is the default mode which is used most of the time. " "You can also press 'Shift+D' on your keyboard to " "activate this mode." ) ); - m_eraseAction->setWhatsThis( + eraseAction->setWhatsThis( tr( "Click here and erase-mode will be activated. In this " "mode you can erase single values. You can also press " "'Shift+E' on your keyboard to activate this mode." ) ); @@ -2083,32 +2083,32 @@ AutomationEditorWindow::AutomationEditorWindow() : // Copy paste buttons - m_cutAction = new QAction(embed::getIconPixmap("edit_cut"), + QAction* cutAction = new QAction(embed::getIconPixmap("edit_cut"), tr("Cut selected values (Ctrl+X)"), this); - m_copyAction = new QAction(embed::getIconPixmap("edit_copy"), + QAction* copyAction = new QAction(embed::getIconPixmap("edit_copy"), tr("Copy selected values (Ctrl+C)"), this); - m_pasteAction = new QAction(embed::getIconPixmap("edit_paste"), + QAction* pasteAction = new QAction(embed::getIconPixmap("edit_paste"), tr("Paste values from clipboard Ctrl+V)"), this); - m_cutAction->setWhatsThis( + cutAction->setWhatsThis( tr( "Click here and selected values will be cut into the " "clipboard. You can paste them anywhere in any pattern " "by clicking on the paste button." ) ); - m_copyAction->setWhatsThis( + copyAction->setWhatsThis( tr( "Click here and selected values will be copied into " "the clipboard. You can paste them anywhere in any " "pattern by clicking on the paste button." ) ); - m_pasteAction->setWhatsThis( + pasteAction->setWhatsThis( tr( "Click here and the values from the clipboard will be " "pasted at the first visible measure." ) ); - m_cutAction->setShortcut(Qt::CTRL | Qt::Key_X); - m_copyAction->setShortcut(Qt::CTRL | Qt::Key_C); - m_pasteAction->setShortcut(Qt::CTRL | Qt::Key_V); + cutAction->setShortcut(Qt::CTRL | Qt::Key_X); + copyAction->setShortcut(Qt::CTRL | Qt::Key_C); + pasteAction->setShortcut(Qt::CTRL | Qt::Key_V); - connect(m_cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedValues())); - connect(m_copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedValues())); - connect(m_pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteValues())); + connect(cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedValues())); + connect(copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedValues())); + connect(pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteValues())); // Zoom controls @@ -2162,8 +2162,8 @@ AutomationEditorWindow::AutomationEditorWindow() : m_toolBar->addSeparator();; - m_toolBar->addAction(m_drawAction); - m_toolBar->addAction(m_eraseAction); + m_toolBar->addAction(drawAction); + m_toolBar->addAction(eraseAction); // m_toolBar->addAction(m_selectButton); // m_toolBar->addAction(m_moveButton); m_toolBar->addSeparator(); @@ -2175,9 +2175,9 @@ AutomationEditorWindow::AutomationEditorWindow() : m_toolBar->addWidget( m_tensionKnob ); m_toolBar->addSeparator(); // Select is broken -// m_toolBar->addAction( m_cutAction ); -// m_toolBar->addAction( m_copyAction ); -// m_toolBar->addAction( m_pasteAction ); +// m_toolBar->addAction( cutAction ); +// m_toolBar->addAction( copyAction ); +// m_toolBar->addAction( pasteAction ); m_toolBar->addSeparator(); m_editor->m_timeLine->addToolButtons(m_toolBar); m_toolBar->addSeparator(); diff --git a/src/gui/editors/Editor.cpp b/src/gui/editors/Editor.cpp index 48921d6bd..81903e488 100644 --- a/src/gui/editors/Editor.cpp +++ b/src/gui/editors/Editor.cpp @@ -98,40 +98,40 @@ Editor::Editor(bool record) : m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu); m_toolBar->setMovable(false); - auto addButton = [this](const char* pixmap_name, QString text, QString objectName) { - QAction* action = m_toolBar->addAction(embed::getIconPixmap(pixmap_name), text); + auto addButton = [this](QAction* action, QString objectName) { + m_toolBar->addAction(action); m_toolBar->widgetForAction(action)->setObjectName(objectName); - return action; }; - // Set up play button - m_playAction = addButton("play", tr("Play (Space)"), "playButton"); + // Set up play and record actions + m_playAction = new QAction(embed::getIconPixmap("play"), tr("Play (Space)"), this); + m_stopAction = new QAction(embed::getIconPixmap("stop"), tr("Stop (Space)"), this); + + m_recordAction = new QAction(embed::getIconPixmap("record"), tr("Record"), this); + m_recordAccompanyAction = new QAction(embed::getIconPixmap("record_accompany"), tr("Record while playing"), this); + m_playAction->setShortcut(Qt::Key_Space); - // Set up record buttons if wanted - if (record) - { - m_recordAction = addButton("record", tr("Record"), "recordButton"); - m_recordAccompanyAction = addButton("record_accompany", tr("Record while playing"), "recordAccompanyButton"); - } - - // Set up stop button - m_stopAction = addButton("stop", tr("Stop (Space)"), "stopButton"); - - // Add toolbar to window - addToolBar(Qt::TopToolBarArea, m_toolBar); - // Set up connections connect(m_playAction, SIGNAL(triggered()), this, SLOT(play())); - if (record) - { - connect(m_recordAction, SIGNAL(triggered()), this, SLOT(record())); - connect(m_recordAccompanyAction, SIGNAL(triggered()), this, SLOT(recordAccompany())); - } + connect(m_recordAction, SIGNAL(triggered()), this, SLOT(record())); + connect(m_recordAccompanyAction, SIGNAL(triggered()), this, SLOT(recordAccompany())); connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stop())); // Connect edit mode connect(m_editModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setEditModeByAction(QAction*))); + + // Add toolbar to window + addToolBar(Qt::TopToolBarArea, m_toolBar); + + // Add actions to toolbar + addButton(m_playAction, "playButton"); + if (record) + { + addButton(m_recordAction, "recordButton"); + addButton(m_recordAccompanyAction, "recordAccompanyButton"); + } + addButton(m_stopAction, "stopButton"); } Editor::~Editor() diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 2e4fbe547..b4a00a074 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -197,32 +197,33 @@ PianoRoll::PianoRoll() : signalMapper = new QSignalMapper( this ); m_semiToneMarkerMenu = new QMenu( this ); - QAction * act = new QAction( tr("Mark/unmark current semitone"), this ); - connect( act, SIGNAL(triggered()), signalMapper, SLOT(map()) ); - signalMapper->setMapping( act, static_cast( stmaMarkCurrentSemiTone ) ); - m_semiToneMarkerMenu->addAction( act ); + QAction * markSemitoneAction = new QAction( tr("Mark/unmark current semitone"), this ); + QAction* markScaleAction = new QAction( tr("Mark current scale"), this ); + QAction* markChordAction = new QAction( tr("Mark current chord"), this ); + QAction* unmarkAllAction = new QAction( tr("Unmark all"), this ); - act = new QAction( tr("Mark current scale"), this ); - act->setEnabled( false ); - connect( act, SIGNAL(triggered()), signalMapper, SLOT(map()) ); - connect( this, SIGNAL(semiToneMarkerMenuScaleSetEnabled(bool)), act, SLOT(setEnabled(bool)) ); - signalMapper->setMapping( act, static_cast( stmaMarkCurrentScale ) ); - m_semiToneMarkerMenu->addAction( act ); + connect( markSemitoneAction, SIGNAL(triggered()), signalMapper, SLOT(map()) ); + connect( markScaleAction, SIGNAL(triggered()), signalMapper, SLOT(map()) ); + connect( markChordAction, SIGNAL(triggered()), signalMapper, SLOT(map()) ); + connect( unmarkAllAction, SIGNAL(triggered()), signalMapper, SLOT(map()) ); - act = new QAction( tr("Mark current chord"), this ); - act->setEnabled( false ); - connect( act, SIGNAL(triggered()), signalMapper, SLOT(map()) ); - connect( this, SIGNAL(semiToneMarkerMenuChordSetEnabled(bool)), act, SLOT(setEnabled(bool)) ); - signalMapper->setMapping( act, static_cast( stmaMarkCurrentChord ) ); - m_semiToneMarkerMenu->addAction( act ); + signalMapper->setMapping( markSemitoneAction, static_cast( stmaMarkCurrentSemiTone ) ); + signalMapper->setMapping( markScaleAction, static_cast( stmaMarkCurrentScale ) ); + signalMapper->setMapping( markChordAction, static_cast( stmaMarkCurrentChord ) ); + signalMapper->setMapping( unmarkAllAction, static_cast( stmaUnmarkAll ) ); - act = new QAction( tr("Unmark all"), this ); - connect( act, SIGNAL(triggered()), signalMapper, SLOT(map()) ); - signalMapper->setMapping( act, static_cast( stmaUnmarkAll ) ); - m_semiToneMarkerMenu->addAction( act ); + markScaleAction->setEnabled( false ); + markChordAction->setEnabled( false ); - connect( signalMapper, SIGNAL(mapped(int)), - this, SLOT(markSemiTone(int)) ); + connect( this, SIGNAL(semiToneMarkerMenuScaleSetEnabled(bool)), markScaleAction, SLOT(setEnabled(bool)) ); + connect( this, SIGNAL(semiToneMarkerMenuChordSetEnabled(bool)), markChordAction, SLOT(setEnabled(bool)) ); + + connect( signalMapper, SIGNAL(mapped(int)), this, SLOT(markSemiTone(int)) ); + + m_semiToneMarkerMenu->addAction( markSemitoneAction ); + m_semiToneMarkerMenu->addAction( markScaleAction ); + m_semiToneMarkerMenu->addAction( markChordAction ); + m_semiToneMarkerMenu->addAction( unmarkAllAction ); // init pixmaps if( s_whiteKeySmallPm == NULL ) @@ -3938,36 +3939,36 @@ PianoRollWindow::PianoRollWindow() : tr( "Click here to stop playback of current pattern." ) ); // init edit-buttons at the top - m_drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); - m_drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); - m_drawAction->setChecked( true ); + QAction* drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); + drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); + drawAction->setChecked( true ); - m_eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); - m_eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); + QAction* eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); + eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); - m_selectAction = addEditMode(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)")); - m_selectAction->setShortcut(Qt::SHIFT | Qt::Key_S); + QAction* selectAction = addEditMode(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)")); + selectAction->setShortcut(Qt::SHIFT | Qt::Key_S); - m_detuneAction = addEditMode(embed::getIconPixmap("automation"), tr("Detune mode (Shift+T)")); - m_detuneAction->setShortcut(Qt::SHIFT | Qt::Key_T); + QAction* detuneAction = addEditMode(embed::getIconPixmap("automation"), tr("Detune mode (Shift+T)")); + detuneAction->setShortcut(Qt::SHIFT | Qt::Key_T); - m_drawAction->setWhatsThis( + drawAction->setWhatsThis( tr( "Click here and draw mode will be activated. In this " "mode you can add, resize and move notes. This " "is the default mode which is used most of the time. " "You can also press 'Shift+D' on your keyboard to " "activate this mode. In this mode, hold Ctrl to " "temporarily go into select mode." ) ); - m_eraseAction->setWhatsThis( + eraseAction->setWhatsThis( tr( "Click here and erase mode will be activated. In this " "mode you can erase notes. You can also press " "'Shift+E' on your keyboard to activate this mode." ) ); - m_selectAction->setWhatsThis( + selectAction->setWhatsThis( tr( "Click here and select mode will be activated. " "In this mode you can select notes. Alternatively, " "you can hold Ctrl in draw mode to temporarily use " "select mode." ) ); - m_detuneAction->setWhatsThis( + detuneAction->setWhatsThis( tr( "Click here and detune mode will be activated. " "In this mode you can click a note to open its " "automation detuning. You can utilize this to slide " @@ -3977,34 +3978,34 @@ PianoRollWindow::PianoRollWindow() : connect(this, SIGNAL(editModeChanged(int)), m_editor, SLOT(setEditMode(int))); // Copy + paste actions - m_cutAction = new QAction(embed::getIconPixmap("edit_cut"), + QAction* cutAction = new QAction(embed::getIconPixmap("edit_cut"), tr("Cut selected notes (Ctrl+X)"), this); - m_copyAction = new QAction(embed::getIconPixmap("edit_copy"), + QAction* copyAction = new QAction(embed::getIconPixmap("edit_copy"), tr("Copy selected notes (Ctrl+C)"), this); - m_pasteAction = new QAction(embed::getIconPixmap("edit_paste"), + QAction* pasteAction = new QAction(embed::getIconPixmap("edit_paste"), tr("Paste notes from clipboard (Ctrl+V)"), this); - m_cutAction->setWhatsThis( + cutAction->setWhatsThis( tr( "Click here and the selected notes will be cut into the " "clipboard. You can paste them anywhere in any pattern " "by clicking on the paste button." ) ); - m_copyAction->setWhatsThis( + copyAction->setWhatsThis( tr( "Click here and the selected notes will be copied into the " "clipboard. You can paste them anywhere in any pattern " "by clicking on the paste button." ) ); - m_pasteAction->setWhatsThis( + pasteAction->setWhatsThis( tr( "Click here and the notes from the clipboard will be " "pasted at the first visible measure." ) ); - m_cutAction->setShortcut(Qt::CTRL | Qt::Key_X); - m_copyAction->setShortcut(Qt::CTRL | Qt::Key_C); - m_pasteAction->setShortcut(Qt::CTRL | Qt::Key_V); + cutAction->setShortcut(Qt::CTRL | Qt::Key_X); + copyAction->setShortcut(Qt::CTRL | Qt::Key_C); + pasteAction->setShortcut(Qt::CTRL | Qt::Key_V); - connect(m_cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedNotes())); - connect(m_copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedNotes())); - connect(m_pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteNotes())); + connect(cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedNotes())); + connect(copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedNotes())); + connect(pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteNotes())); QLabel * zoom_lbl = new QLabel( m_toolBar ); zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) ); @@ -4049,15 +4050,15 @@ PianoRollWindow::PianoRollWindow() : m_toolBar->addSeparator(); - m_toolBar->addAction( m_drawAction ); - m_toolBar->addAction( m_eraseAction ); - m_toolBar->addAction( m_selectAction ); - m_toolBar->addAction( m_detuneAction ); + m_toolBar->addAction( drawAction ); + m_toolBar->addAction( eraseAction ); + m_toolBar->addAction( selectAction ); + m_toolBar->addAction( detuneAction ); m_toolBar->addSeparator(); - m_toolBar->addAction( m_cutAction ); - m_toolBar->addAction( m_copyAction ); - m_toolBar->addAction( m_pasteAction ); + m_toolBar->addAction( cutAction ); + m_toolBar->addAction( copyAction ); + m_toolBar->addAction( pasteAction ); m_toolBar->addSeparator(); m_editor->m_timeLine->addToolButtons(m_toolBar); diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 4ff5153c0..8be3b69d4 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -611,11 +611,8 @@ SongEditorWindow::SongEditorWindow(Song* song) : // Set up buttons m_playAction->setToolTip(tr("Play song (Space)")); - if (m_recordAction && m_recordAccompanyAction) - { - m_recordAction->setToolTip(tr("Record samples from Audio-device")); - m_recordAccompanyAction->setToolTip(tr( "Record samples from Audio-device while playing song or BB track")); - } + m_recordAction->setToolTip(tr("Record samples from Audio-device")); + m_recordAccompanyAction->setToolTip(tr( "Record samples from Audio-device while playing song or BB track")); m_stopAction->setToolTip(tr( "Stop song (Space)" )); m_addBBTrackAction = new QAction(embed::getIconPixmap("add_bb_track"), From 787788870b2d76ca32dee42b3b3577c9660f8ff3 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Thu, 11 Dec 2014 12:56:51 +0100 Subject: [PATCH 25/32] Introduce ActionGroup subclass --- include/ActionGroup.h | 57 ++++++++++++++++++++++++++++ include/AutomationEditor.h | 4 +- include/Editor.h | 26 ++----------- src/gui/ActionGroup.cpp | 55 +++++++++++++++++++++++++++ src/gui/editors/AutomationEditor.cpp | 51 +++++++++---------------- src/gui/editors/Editor.cpp | 52 +------------------------ src/gui/editors/PianoRoll.cpp | 17 +++++---- src/gui/editors/SongEditor.cpp | 8 ++-- 8 files changed, 149 insertions(+), 121 deletions(-) create mode 100644 include/ActionGroup.h create mode 100644 src/gui/ActionGroup.cpp diff --git a/include/ActionGroup.h b/include/ActionGroup.h new file mode 100644 index 000000000..9928e8906 --- /dev/null +++ b/include/ActionGroup.h @@ -0,0 +1,57 @@ +/* + * Editor.h - declaration of Editor class + * + * Copyright (c) 2014 Lukas W + * + * 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 ACTION_GROUP_H +#define ACTION_GROUP_H + +#include + +/// \brief Convenience subclass of QActionGroup +/// +/// This class provides the same functionality as QActionGroup, but in addition +/// has the actionTriggered(int) signal. +/// It also sets every added action's checkable property to true. +class ActionGroup : public QActionGroup +{ + Q_OBJECT +public: + ActionGroup(QObject* parent); + + QAction* addAction(QAction *a); + QAction* addAction(const QString &text); + QAction* addAction(const QIcon &icon, const QString &text); + +signals: + /// This signal is emitted when the action at the given index is triggered. + void triggered(int index); + +private slots: + void actionTriggered_(QAction* action); + +private: + QList m_actions; +}; + +#endif diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index ee6fd9842..94798bedd 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -134,9 +134,7 @@ protected slots: void setEditMode(int mode); void setProgressionType(AutomationPattern::ProgressionTypes type); - void setProgressionDiscrete(); - void setProgressionLinear(); - void setProgressionHermite(); + void setProgressionType(int type); void setTension(); void copySelectedValues(); diff --git a/include/Editor.h b/include/Editor.h index 458fc34fe..1070aa649 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -32,9 +32,6 @@ #include "TimeLineWidget.h" #include "ToolButton.h" -// Forward declarations -class QActionGroup; - /// \brief Superclass for editors with a toolbar. /// /// Those editors include the Song Editor, the Automation Editor, B&B Editor, @@ -45,23 +42,11 @@ class Editor : public QMainWindow public: void setPauseIcon(bool displayPauseIcon=true); - int editMode() const; - void setEditMode(int mode); - -signals: - void editModeChanged(int); - -protected: - QAction* addEditMode(const QIcon &icon, const QString &text, const QString& whatsThis=QString()); - protected slots: - virtual void play(); - virtual void record(); - virtual void recordAccompany(); - virtual void stop(); - -private slots: - void setEditModeByAction(QAction* action); + virtual void play() {} + virtual void record() {} + virtual void recordAccompany() {} + virtual void stop() {} signals: @@ -80,9 +65,6 @@ protected: QAction* m_recordAction; QAction* m_recordAccompanyAction; QAction* m_stopAction; -private: - quint8 m_editMode; - QActionGroup* m_editModeGroup; }; diff --git a/src/gui/ActionGroup.cpp b/src/gui/ActionGroup.cpp new file mode 100644 index 000000000..b0f0dbcd3 --- /dev/null +++ b/src/gui/ActionGroup.cpp @@ -0,0 +1,55 @@ +/* + * Editor.h - declaration of Editor class + * + * Copyright (c) 2014 Lukas W + * + * 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. + * + */ + +#include "ActionGroup.h" + +ActionGroup::ActionGroup(QObject* parent) : QActionGroup(parent) +{ + connect(this, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered_(QAction*))); +} + +QAction* ActionGroup::addAction(QAction* a) +{ + a->setCheckable(true); + + return QActionGroup::addAction(a); +} + +QAction* ActionGroup::addAction(const QString& text) +{ + return addAction(new QAction(text, this)); +} + +QAction* ActionGroup::addAction(const QIcon& icon, const QString& text) +{ + return addAction(new QAction(icon, text, this)); +} + +void ActionGroup::actionTriggered_(QAction* action) +{ + Q_ASSERT(action != 0); + Q_ASSERT(actions().contains(action)); + + emit triggered(actions().indexOf(action)); +} diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 28beedcf5..ed5a5bb46 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -47,7 +47,7 @@ #include - +#include "ActionGroup.h" #include "SongEditor.h" #include "MainWindow.h" #include "embed.h" @@ -1643,22 +1643,9 @@ void AutomationEditor::setProgressionType(AutomationPattern::ProgressionTypes ty } } - -void AutomationEditor::setProgressionDiscrete() +void AutomationEditor::setProgressionType(int type) { - setProgressionType(AutomationPattern::DiscreteProgression); -} - - -void AutomationEditor::setProgressionLinear() -{ - setProgressionType(AutomationPattern::LinearProgression); -} - - -void AutomationEditor::setProgressionHermite() -{ - setProgressionType(AutomationPattern::CubicHermiteProgression); + setProgressionType((AutomationPattern::ProgressionTypes) type); } @@ -2005,17 +1992,18 @@ AutomationEditorWindow::AutomationEditorWindow() : "current pattern." ) ); // Edit mode buttons - QAction* drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); + ActionGroup* editModeGroup = new ActionGroup(this); + QAction* drawAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); - QAction* eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); + QAction* eraseAction = editModeGroup->addAction(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); drawAction->setChecked(true); // TODO: m_selectButton and m_moveButton are broken. -// m_selectButton = addEditMode(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)")); -// m_moveButton = addEditMode(embed::getIconPixmap("edit_move"), tr("Move selection mode (Shift+M)")); +// m_selectButton = new QAction(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)"), editModeGroup); +// m_moveButton = new QAction(embed::getIconPixmap("edit_move"), tr("Move selection mode (Shift+M)"), editModeGroup); drawAction->setWhatsThis( tr( "Click here and draw-mode will be activated. In this " @@ -2039,26 +2027,21 @@ AutomationEditorWindow::AutomationEditorWindow() : "mode. You can also press 'Shift+M' on your keyboard " "to activate this mode." ) );*/ - connect(this, SIGNAL(editModeChanged(int)), m_editor, SLOT(setEditMode(int))); + connect(editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int))); // Progression type buttons - QActionGroup* progression_type_group = new QActionGroup(this); + ActionGroup* progression_type_group = new ActionGroup(this); - m_discreteAction = new QAction(embed::getIconPixmap("progression_discrete"), - tr("Discrete progression"), progression_type_group); - m_linearAction = new QAction(embed::getIconPixmap("progression_linear"), - tr("Linear progression"), progression_type_group); - m_cubicHermiteAction = new QAction(embed::getIconPixmap("progression_cubic_hermite"), - tr( "Cubic Hermite progression"), progression_type_group); + m_discreteAction = progression_type_group->addAction( + embed::getIconPixmap("progression_discrete"), tr("Discrete progression")); + m_linearAction = progression_type_group->addAction( + embed::getIconPixmap("progression_linear"), tr("Linear progression")); + m_cubicHermiteAction = progression_type_group->addAction( + embed::getIconPixmap("progression_cubic_hermite"), tr( "Cubic Hermite progression")); - m_linearAction->setCheckable( true ); - m_cubicHermiteAction->setCheckable( true ); - m_discreteAction->setCheckable( true ); m_discreteAction->setChecked( true ); - connect(m_discreteAction, SIGNAL(triggered()), m_editor, SLOT(setProgressionDiscrete())); - connect(m_linearAction, SIGNAL(triggered()), m_editor, SLOT(setProgressionLinear())); - connect(m_cubicHermiteAction, SIGNAL(triggered()), m_editor, SLOT(setProgressionHermite())); + connect(progression_type_group, SIGNAL(triggered(int)), m_editor, SLOT(setProgressionType(int))); // setup tension-stuff m_tensionKnob = new Knob( knobSmall_17, this, "Tension" ); diff --git a/src/gui/editors/Editor.cpp b/src/gui/editors/Editor.cpp index 81903e488..8594f1b95 100644 --- a/src/gui/editors/Editor.cpp +++ b/src/gui/editors/Editor.cpp @@ -41,59 +41,12 @@ void Editor::setPauseIcon(bool displayPauseIcon) m_playAction->setIcon(embed::getIconPixmap("play")); } -int Editor::editMode() const -{ - return m_editMode; -} - -void Editor::setEditMode(int mode) -{ - if (mode <= m_editModeGroup->actions().size()) - { - m_editMode = mode; - } - emit(editModeChanged(mode)); -} - -QAction* Editor::addEditMode(const QIcon& icon, const QString& text, const QString& whatsThis) -{ - QAction* editModeAction = new QAction(icon, text, m_editModeGroup); - editModeAction->setWhatsThis(whatsThis); - editModeAction->setCheckable(true); - return editModeAction; -} - -void Editor::play() -{ -} - -void Editor::record() -{ -} - -void Editor::recordAccompany() -{ -} - -void Editor::stop() -{ -} - -void Editor::setEditModeByAction(QAction* action) -{ - int index = m_editModeGroup->actions().indexOf(action); - if (index != -1) - setEditMode(index); -} - Editor::Editor(bool record) : m_toolBar(new QToolBar(this)), m_playAction(nullptr), m_recordAction(nullptr), m_recordAccompanyAction(nullptr), - m_stopAction(nullptr), - m_editMode(0), - m_editModeGroup(new QActionGroup(this)) + m_stopAction(nullptr) { m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu); m_toolBar->setMovable(false); @@ -118,9 +71,6 @@ Editor::Editor(bool record) : connect(m_recordAccompanyAction, SIGNAL(triggered()), this, SLOT(recordAccompany())); connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stop())); - // Connect edit mode - connect(m_editModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setEditModeByAction(QAction*))); - // Add toolbar to window addToolBar(Qt::TopToolBarArea, m_toolBar); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index b4a00a074..29ccafcdc 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -45,6 +45,7 @@ #include #include +#include "ActionGroup.h" #include "ConfigManager.h" #include "PianoRoll.h" #include "BBTrackContainer.h" @@ -3939,17 +3940,17 @@ PianoRollWindow::PianoRollWindow() : tr( "Click here to stop playback of current pattern." ) ); // init edit-buttons at the top - QAction* drawAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); - drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); + ActionGroup* editModeGroup = new ActionGroup(this); + QAction* drawAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); + QAction* eraseAction = editModeGroup->addAction(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); + QAction* selectAction = editModeGroup->addAction(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)")); + QAction* detuneAction = editModeGroup->addAction(embed::getIconPixmap("automation"), tr("Detune mode (Shift+T)")); + drawAction->setChecked( true ); - QAction* eraseAction = addEditMode(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); + drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); - - QAction* selectAction = addEditMode(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)")); selectAction->setShortcut(Qt::SHIFT | Qt::Key_S); - - QAction* detuneAction = addEditMode(embed::getIconPixmap("automation"), tr("Detune mode (Shift+T)")); detuneAction->setShortcut(Qt::SHIFT | Qt::Key_T); drawAction->setWhatsThis( @@ -3975,7 +3976,7 @@ PianoRollWindow::PianoRollWindow() : "notes from one to another. You can also press " "'Shift+T' on your keyboard to activate this mode." ) ); - connect(this, SIGNAL(editModeChanged(int)), m_editor, SLOT(setEditMode(int))); + connect(editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int))); // Copy + paste actions QAction* cutAction = new QAction(embed::getIconPixmap("edit_cut"), diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 8be3b69d4..afbbb2698 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -35,6 +35,7 @@ #include +#include "ActionGroup.h" #include "SongEditor.h" #include "AutomatableSlider.h" #include "ComboBox.h" @@ -628,10 +629,11 @@ SongEditorWindow::SongEditorWindow(Song* song) : connect(m_addSampleTrackAction, SIGNAL(triggered()), m_editor->m_song, SLOT(addSampleTrack())); connect(m_addAutomationTrackAction, SIGNAL(triggered()), m_editor->m_song, SLOT(addAutomationTrack())); - m_drawModeAction = addEditMode(embed::getIconPixmap("edit_draw"), tr("Draw mode")); - m_drawModeAction->setChecked(true); + ActionGroup* editModeGroup = new ActionGroup(this); + m_drawModeAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode")); + m_selectModeAction = editModeGroup->addAction(embed::getIconPixmap("edit_select"), tr("Edit mode (select and move)")); - m_selectModeAction = addEditMode(embed::getIconPixmap("edit_select"), tr("Edit mode (select and move)")); + m_drawModeAction->setChecked(true); connect(m_drawModeAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeDraw())); connect(m_selectModeAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeSelect())); From 11cb8b5d68e435343776ca6b8591fe822b5694c2 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Fri, 12 Dec 2014 10:51:15 +0100 Subject: [PATCH 26/32] Automation Editor tension fix --- include/AutomationEditor.h | 3 +++ src/core/AutomationPattern.cpp | 5 ----- src/gui/editors/AutomationEditor.cpp | 24 +++++++++++++++++++----- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 94798bedd..2aebe45f5 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -266,6 +266,9 @@ public: QSize sizeHint() const; +public slots: + void clearCurrentPattern(); + signals: void currentPatternChanged(); diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 76b185d42..a1c01720a 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -79,11 +79,6 @@ AutomationPattern::AutomationPattern( const AutomationPattern & _pat_to_copy ) : AutomationPattern::~AutomationPattern() { - if( Engine::automationEditor() && - Engine::automationEditor()->currentPattern() == this ) - { - Engine::automationEditor()->setCurrentPattern( NULL ); - } } diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index ed5a5bb46..e7693f5ee 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -584,7 +584,6 @@ void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent ) -#include void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) { QMutexLocker m( &m_patternMutex ); @@ -1999,8 +1998,6 @@ AutomationEditorWindow::AutomationEditorWindow() : QAction* eraseAction = editModeGroup->addAction(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); - drawAction->setChecked(true); - // TODO: m_selectButton and m_moveButton are broken. // m_selectButton = new QAction(embed::getIconPixmap("edit_select"), tr("Select mode (Shift+S)"), editModeGroup); // m_moveButton = new QAction(embed::getIconPixmap("edit_move"), tr("Move selection mode (Shift+M)"), editModeGroup); @@ -2039,12 +2036,19 @@ AutomationEditorWindow::AutomationEditorWindow() : m_cubicHermiteAction = progression_type_group->addAction( embed::getIconPixmap("progression_cubic_hermite"), tr( "Cubic Hermite progression")); - m_discreteAction->setChecked( true ); - connect(progression_type_group, SIGNAL(triggered(int)), m_editor, SLOT(setProgressionType(int))); // setup tension-stuff m_tensionKnob = new Knob( knobSmall_17, this, "Tension" ); + m_tensionKnob->setModel(m_editor->m_tensionModel); + ToolTip::add(m_tensionKnob, tr("Tension value for spline")); + m_tensionKnob->setWhatsThis( + tr("A higher tension value may make a smoother curve " + "but overshoot some values. A low tension " + "value will cause the slope of the curve to " + "level off at each control point.")); + + connect(m_cubicHermiteAction, SIGNAL(toggled(bool)), m_tensionKnob, SLOT(setEnabled(bool))); m_discreteAction->setWhatsThis( tr( "Click here to choose discrete progressions for this " @@ -2173,6 +2177,9 @@ AutomationEditorWindow::AutomationEditorWindow() : m_toolBar->addWidget( quantize_lbl ); m_toolBar->addWidget( m_quantizeComboBox ); + drawAction->setChecked(true); + m_discreteAction->setChecked(true); + // Setup our actual window setFocusPolicy( Qt::StrongFocus ); setFocus(); @@ -2205,6 +2212,8 @@ void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern) break; } + connect(pattern, SIGNAL(destroyed()), this, SLOT(clearCurrentPattern())); + emit currentPatternChanged(); } @@ -2225,6 +2234,11 @@ QSize AutomationEditorWindow::sizeHint() const return {INITIAL_WIDTH, INITIAL_HEIGHT}; } +void AutomationEditorWindow::clearCurrentPattern() +{ + setCurrentPattern(nullptr); +} + void AutomationEditorWindow::play() { m_editor->play(); From 657fb06c4917670ccaebe7dcba95fb3600d9e2b0 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 17 Dec 2014 11:34:57 +0100 Subject: [PATCH 27/32] More Automation refactoring --- include/AutomationEditor.h | 6 ++-- include/AutomationPattern.h | 28 ++++++------------ include/Note.h | 10 ++----- src/core/AutomationPattern.cpp | 43 +++++++-------------------- src/core/Note.cpp | 8 ----- src/gui/AutomatableModelView.cpp | 6 +++- src/gui/AutomationPatternView.cpp | 2 +- src/gui/editors/AutomationEditor.cpp | 44 ++++++++++++++++++---------- src/gui/editors/PianoRoll.cpp | 5 +++- 9 files changed, 64 insertions(+), 88 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 2aebe45f5..00b4989fb 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -68,8 +68,6 @@ public: return m_pattern != nullptr; } - int quantization() const; - virtual void saveSettings(QDomDocument & doc, QDomElement & parent); virtual void loadSettings(const QDomElement & parent); QString nodeName() const @@ -147,6 +145,8 @@ protected slots: void zoomingXChanged(); void zoomingYChanged(); + /// Updates the pattern's quantization using the current user selected value. + void setQuantization(); private: @@ -260,7 +260,7 @@ public: void setCurrentPattern(AutomationPattern* pattern); const AutomationPattern* currentPattern(); - int quantization() const; + void open(AutomationPattern* pattern); AutomationEditor* m_editor; diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index b6259b3c5..66caddf27 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -136,15 +136,8 @@ public: virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); virtual void loadSettings( const QDomElement & _this ); - static inline const QString classNodeName() - { - return "automationpattern"; - } - - inline virtual QString nodeName() const - { - return classNodeName(); - } + static const QString classNodeName() { return "automationpattern"; } + QString nodeName() const { return classNodeName(); } void processMidiTime( const MidiTime & _time ); @@ -156,19 +149,14 @@ public: static AutomationPattern * globalAutomationPattern( AutomatableModel * _m ); static void resolveAllIDs(); - bool isRecording() const - { - return m_isRecording; - } - - void setRecording( const bool b ) - { - m_isRecording = b; - } + bool isRecording() const { return m_isRecording; } + void setRecording( const bool b ) { m_isRecording = b; } + + static int quantization() { return s_quantization; } + static void setQuantization(int q) { s_quantization = q; } public slots: void clear(); - void openInAutomationEditor(); void objectDestroyed( jo_id_t ); private: @@ -192,6 +180,8 @@ private: bool m_isRecording; float m_lastRecordedValue; + static int s_quantization; + static const float DEFAULT_MIN_VALUE; static const float DEFAULT_MAX_VALUE; diff --git a/include/Note.h b/include/Note.h index eb36462a6..cdd5a717e 100644 --- a/include/Note.h +++ b/include/Note.h @@ -202,11 +202,10 @@ public: { return m_detuning; } - - void editDetuningPattern(); - bool hasDetuningInfo() const; + void createDetuning(); + protected: virtual void saveSettings( QDomDocument & _doc, @@ -228,10 +227,7 @@ private: MidiTime m_length; MidiTime m_pos; DetuningHelper * m_detuning; - - void createDetuning(); - -} ; +}; typedef QVector NoteVector; diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index a1c01720a..176dd35f8 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -25,12 +25,9 @@ */ #include -#include -#include #include "AutomationPattern.h" #include "AutomationPatternView.h" -#include "AutomationEditor.h" #include "AutomationTrack.h" #include "ProjectJournal.h" #include "BBTrackContainer.h" @@ -38,7 +35,7 @@ #include "TextFloat.h" #include "embed.h" - +int AutomationPattern::s_quantization = 1; const float AutomationPattern::DEFAULT_MIN_VALUE = 0; const float AutomationPattern::DEFAULT_MAX_VALUE = 1; @@ -181,10 +178,9 @@ MidiTime AutomationPattern::putValue( const MidiTime & _time, { cleanObjects(); - MidiTime newTime = _quant_pos && Engine::automationEditor() ? - Note::quantized( _time, - Engine::automationEditor()->quantization() ) : - _time; + MidiTime newTime = _quant_pos ? + Note::quantized( _time, quantization() ) : + _time; m_timeMap[newTime] = _value; timeMap::const_iterator it = m_timeMap.find( newTime ); @@ -214,10 +210,9 @@ void AutomationPattern::removeValue( const MidiTime & _time, { cleanObjects(); - MidiTime newTime = _quant_pos && Engine::automationEditor() ? - Note::quantized( _time, - Engine::automationEditor()->quantization() ) : - _time; + MidiTime newTime = _quant_pos ? + Note::quantized( _time, quantization() ) : + _time; m_timeMap.remove( newTime ); m_tangents.remove( newTime ); @@ -254,10 +249,9 @@ MidiTime AutomationPattern::setDragValue( const MidiTime & _time, const float _v { if( m_dragging == false ) { - MidiTime newTime = _quant_pos && Engine::automationEditor() ? - Note::quantized( _time, - Engine::automationEditor()->quantization() ) : - _time; + MidiTime newTime = _quant_pos ? + Note::quantized( _time, quantization() ) : + _time; this->removeValue( newTime ); m_oldTimeMap = m_timeMap; m_dragging = true; @@ -670,23 +664,6 @@ void AutomationPattern::clear() m_tangents.clear(); emit dataChanged(); - - if( Engine::automationEditor() && - Engine::automationEditor()->currentPattern() == this ) - { - Engine::automationEditor()->update(); - } -} - - - - -void AutomationPattern::openInAutomationEditor() -{ - Engine::automationEditor()->setCurrentPattern( this ); - Engine::automationEditor()->parentWidget()->show(); - Engine::automationEditor()->show(); - Engine::automationEditor()->setFocus(); } diff --git a/src/core/Note.cpp b/src/core/Note.cpp index fca078587..937f52ac8 100644 --- a/src/core/Note.cpp +++ b/src/core/Note.cpp @@ -209,14 +209,6 @@ void Note::loadSettings( const QDomElement & _this ) -void Note::editDetuningPattern() -{ - createDetuning(); - m_detuning->automationPattern()->openInAutomationEditor(); -} - - - void Note::createDetuning() { diff --git a/src/gui/AutomatableModelView.cpp b/src/gui/AutomatableModelView.cpp index 3a13ed5c7..9485e636d 100644 --- a/src/gui/AutomatableModelView.cpp +++ b/src/gui/AutomatableModelView.cpp @@ -33,6 +33,8 @@ #include "MainWindow.h" #include "StringPairDrag.h" +#include "AutomationEditor.h" + AutomatableModelView::AutomatableModelView( ::Model* model, QWidget* _this ) : @@ -224,7 +226,9 @@ void AutomatableModelViewSlots::removeConnection() void AutomatableModelViewSlots::editSongGlobalAutomation() { - AutomationPattern::globalAutomationPattern( m_amv->modelUntyped() )->openInAutomationEditor(); + Engine::automationEditor()->open( + AutomationPattern::globalAutomationPattern(m_amv->modelUntyped()) + ); } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index fba27ceb1..cbb3067da 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -203,7 +203,7 @@ void AutomationPatternView::mouseDoubleClickEvent( QMouseEvent * _me ) _me->ignore(); return; } - m_pat->openInAutomationEditor(); + Engine::automationEditor()->open(m_pat); } diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index e7693f5ee..0799bb445 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -118,6 +118,8 @@ AutomationEditor::AutomationEditor() : { m_quantizeModel.addItem( "1/" + QString::number( 1 << i ) ); } + + connect(&m_quantizeModel, SIGNAL(dataChanged()), this, SLOT(setQuantization())); m_quantizeModel.setValue( m_quantizeModel.findText( "1/16" ) ); // add time-line @@ -243,7 +245,6 @@ void AutomationEditor::updateAfterPatternChange() if( !validPattern() ) { - setWindowTitle( tr( "Automation Editor - no pattern" ) ); m_minLevel = m_maxLevel = m_scrollLevel = 0; m_step = 1; resizeEvent( NULL ); @@ -259,8 +260,6 @@ void AutomationEditor::updateAfterPatternChange() // of levels and so on...) resizeEvent( NULL ); - setWindowTitle( tr( "Automation Editor - %1" ).arg( m_pattern->name() ) ); - update(); } @@ -374,22 +373,22 @@ void AutomationEditor::drawLine( int x0, float y0, int x1, float y1 ) int xstep; int ystep; - if( deltax < quantization() ) + if( deltax < AutomationPattern::quantization() ) { return; } - deltax /= quantization(); + deltax /= AutomationPattern::quantization(); float yscale = deltay / ( deltax ); if( x0 < x1) { - xstep = quantization(); + xstep = AutomationPattern::quantization(); } else { - xstep = -( quantization() ); + xstep = -( AutomationPattern::quantization() ); } if( y0 < y1 ) @@ -967,7 +966,7 @@ inline void AutomationEditor::drawAutomationPoint( QPainter & p, timeMap::iterat { int x = xCoordOfTick( it.key() ); int y = yCoordOfLevel( it.value() ); - const int outerRadius = qBound( 2, ( m_ppt * quantization() ) / 576, 5 ); // man, getting this calculation right took forever + const int outerRadius = qBound( 2, ( m_ppt * AutomationPattern::quantization() ) / 576, 5 ); // man, getting this calculation right took forever p.setPen( QPen( vertexColor().lighter( 200 ) ) ); p.setBrush( QBrush( vertexColor() ) ); p.drawEllipse( x - outerRadius, y - outerRadius, outerRadius * 2, outerRadius * 2 ); @@ -1076,10 +1075,10 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) // 3 independent loops, because quantization might not divide evenly into // exotic denominators (e.g. 7/11 time), which are allowed ATM. // First quantization grid... - for( tick = m_currentPosition - m_currentPosition % quantization(), + for( tick = m_currentPosition - m_currentPosition % AutomationPattern::quantization(), x = xCoordOfTick( tick ); x<=width(); - tick += quantization(), x = xCoordOfTick( tick ) ) + tick += AutomationPattern::quantization(), x = xCoordOfTick( tick ) ) { lineColor.setAlpha( 80 ); p.setPen( lineColor ); @@ -1910,9 +1909,10 @@ void AutomationEditor::zoomingYChanged() -int AutomationEditor::quantization() const +void AutomationEditor::setQuantization() { - return DefaultTicksPerTact / (1 << m_quantizeModel.value()); + int quantization = DefaultTicksPerTact / (1 << m_quantizeModel.value());; + AutomationPattern::setQuantization(quantization); } @@ -2194,10 +2194,20 @@ AutomationEditorWindow::~AutomationEditorWindow() void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern) { + if (currentPattern() != nullptr) + { + m_editor->m_pattern->disconnect(this); + } + m_editor->setCurrentPattern(pattern); if (pattern == nullptr) + { + setWindowTitle( tr( "Automation Editor - no pattern" ) ); return; + } + + setWindowTitle( tr( "Automation Editor - %1" ).arg( m_editor->m_pattern->name() ) ); switch(m_editor->m_pattern->progressionType()) { @@ -2212,6 +2222,7 @@ void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern) break; } + connect(pattern, SIGNAL(dataChanged()), this, SLOT(update())); connect(pattern, SIGNAL(destroyed()), this, SLOT(clearCurrentPattern())); emit currentPatternChanged(); @@ -2223,10 +2234,12 @@ const AutomationPattern* AutomationEditorWindow::currentPattern() return m_editor->currentPattern(); } - -int AutomationEditorWindow::quantization() const +void AutomationEditorWindow::open(AutomationPattern* pattern) { - return m_editor->quantization(); + setCurrentPattern(pattern); + parentWidget()->show(); + show(); + setFocus(); } QSize AutomationEditorWindow::sizeHint() const @@ -2236,6 +2249,7 @@ QSize AutomationEditorWindow::sizeHint() const void AutomationEditorWindow::clearCurrentPattern() { + m_editor->m_pattern = nullptr; setCurrentPattern(nullptr); } diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 29ccafcdc..93ec5b2ce 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -45,6 +45,7 @@ #include #include +#include "AutomationEditor.h" #include "ActionGroup.h" #include "ConfigManager.h" #include "PianoRoll.h" @@ -1210,7 +1211,9 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) if( m_editMode == ModeEditDetuning && noteUnderMouse() ) { - noteUnderMouse()->editDetuningPattern(); + Note* n = noteUnderMouse(); + if (n->detuning() == NULL) n->createDetuning(); + Engine::automationEditor()->open( noteUnderMouse()->detuning()->automationPattern() ); return; } From 1ee93409d129f8222a509645c31018e93e5373c6 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 17 Dec 2014 23:25:55 +0100 Subject: [PATCH 28/32] Move Engine' GUI code to new GuiApplication class --- include/AboutDialog.h | 2 +- include/Engine.h | 51 +---------- include/GuiApplication.h | 71 ++++++++++++++++ include/MainWindow.h | 2 +- plugins/MidiImport/MidiImport.cpp | 7 +- .../SpectrumAnalyzerControlDialog.cpp | 3 +- plugins/VstEffect/VstEffectControls.cpp | 3 +- plugins/flp_import/FlpImport.cpp | 5 +- plugins/vestige/vestige.cpp | 3 +- plugins/vst_base/VstPlugin.cpp | 6 +- src/core/Engine.cpp | 39 --------- src/core/Mixer.cpp | 3 +- src/core/Plugin.cpp | 3 +- src/core/Song.cpp | 84 ++++++++++--------- src/core/Track.cpp | 5 +- src/core/TrackContainer.cpp | 4 +- src/core/audio/AudioJack.cpp | 6 +- src/core/main.cpp | 28 ++++--- src/gui/AboutDialog.cpp | 8 +- src/gui/AutomatableModelView.cpp | 5 +- src/gui/AutomationPatternView.cpp | 20 ++--- src/gui/ExportProjectDialog.cpp | 6 +- src/gui/FileBrowser.cpp | 7 +- src/gui/FxMixerView.cpp | 5 +- src/gui/GuiApplication.cpp | 68 +++++++++++++++ src/gui/MainWindow.cpp | 65 +++++++------- src/gui/StringPairDrag.cpp | 6 +- src/gui/TimeLineWidget.cpp | 4 +- src/gui/ToolPluginView.cpp | 3 +- src/gui/editors/AutomationEditor.cpp | 13 +-- src/gui/editors/PianoRoll.cpp | 15 ++-- src/gui/editors/SongEditor.cpp | 46 +++++----- src/gui/widgets/ControllerRackView.cpp | 3 +- src/gui/widgets/ControllerView.cpp | 5 +- src/gui/widgets/EffectView.cpp | 3 +- src/gui/widgets/FxLine.cpp | 7 +- src/gui/widgets/Knob.cpp | 19 +++-- src/gui/widgets/LcdSpinBox.cpp | 3 +- src/gui/widgets/ProjectNotes.cpp | 5 +- src/gui/widgets/TempoSyncKnob.cpp | 13 +-- src/gui/widgets/TextFloat.cpp | 5 +- src/gui/widgets/TimeDisplayWidget.cpp | 3 +- src/gui/widgets/VisualizationWidget.cpp | 5 +- src/tracks/BBTrack.cpp | 11 +-- src/tracks/InstrumentTrack.cpp | 15 ++-- src/tracks/Pattern.cpp | 32 +++---- src/tracks/SampleTrack.cpp | 3 +- 47 files changed, 406 insertions(+), 322 deletions(-) create mode 100644 include/GuiApplication.h create mode 100644 src/gui/GuiApplication.cpp diff --git a/include/AboutDialog.h b/include/AboutDialog.h index 788dc7a11..c07ef6d70 100644 --- a/include/AboutDialog.h +++ b/include/AboutDialog.h @@ -34,7 +34,7 @@ class AboutDialog : public QDialog, public Ui::AboutDialog { public: - AboutDialog( void ); + AboutDialog(QWidget* parent=0); } ; diff --git a/include/Engine.h b/include/Engine.h index 509e668af..322f109c9 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -97,42 +97,6 @@ public: 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; @@ -143,11 +107,6 @@ public: return s_dummyTC; } - static ControllerRackView * getControllerRackView() - { - return s_controllerRackView; - } - static float framesPerTick() { return s_framesPerTick; @@ -182,22 +141,14 @@ private: 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 s_pluginFileHandling; static void initPluginFileHandling(); + friend class GuiApplication; } ; diff --git a/include/GuiApplication.h b/include/GuiApplication.h new file mode 100644 index 000000000..c35994e81 --- /dev/null +++ b/include/GuiApplication.h @@ -0,0 +1,71 @@ +/* + * GuiApplication.h + * + * Copyright (c) 2014 Lukas W + * + * 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 diff --git a/include/MainWindow.h b/include/MainWindow.h index 9fd9acecd..468a31524 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -178,7 +178,7 @@ private: QList* m_errors; - friend class Engine; + friend class GuiApplication; private slots: diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index 853decb32..ec3178d85 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -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" @@ -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). " @@ -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 " @@ -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 ); diff --git a/plugins/SpectrumAnalyzer/SpectrumAnalyzerControlDialog.cpp b/plugins/SpectrumAnalyzer/SpectrumAnalyzerControlDialog.cpp index 42aa5ed86..d8b096a3e 100644 --- a/plugins/SpectrumAnalyzer/SpectrumAnalyzerControlDialog.cpp +++ b/plugins/SpectrumAnalyzer/SpectrumAnalyzerControlDialog.cpp @@ -27,6 +27,7 @@ #include "SpectrumAnalyzer.h" #include "MainWindow.h" +#include "GuiApplication.h" #include "LedCheckbox.h" #include "embed.h" @@ -59,7 +60,7 @@ public: 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 ); } diff --git a/plugins/VstEffect/VstEffectControls.cpp b/plugins/VstEffect/VstEffectControls.cpp index 08f8e28ac..8f2594c6a 100644 --- a/plugins/VstEffect/VstEffectControls.cpp +++ b/plugins/VstEffect/VstEffectControls.cpp @@ -28,6 +28,7 @@ #include "VstEffect.h" #include "MainWindow.h" +#include "GuiApplication.h" #include #include @@ -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); diff --git a/plugins/flp_import/FlpImport.cpp b/plugins/flp_import/FlpImport.cpp index 8fc869dfc..c23097d2c 100644 --- a/plugins/flp_import/FlpImport.cpp +++ b/plugins/flp_import/FlpImport.cpp @@ -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" @@ -1418,7 +1419,7 @@ else { Engine::fxMixer()->createChannel(); } - Engine::fxMixerView()->refreshDisplay(); + gui->fxMixerView()->refreshDisplay(); // set global parameters Engine::getSong()->setMasterVolume( p.mainVolume ); @@ -1426,7 +1427,7 @@ else 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() + diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index f1b9fffd9..4c6870c69 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -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" @@ -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 ); diff --git a/plugins/vst_base/VstPlugin.cpp b/plugins/vst_base/VstPlugin.cpp index 0cc604d63..3f93b0ee5 100644 --- a/plugins/vst_base/VstPlugin.cpp +++ b/plugins/vst_base/VstPlugin.cpp @@ -46,7 +46,7 @@ #endif #include "ConfigManager.h" -#include "Engine.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "Song.h" #include "templates.h" @@ -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; @@ -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 ); diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index 8db5d74c4..e569e612e 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -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" @@ -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 Engine::s_pluginFileHandling; @@ -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; @@ -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(); @@ -141,8 +104,6 @@ void Engine::destroy() //delete ConfigManager::inst(); deleteHelper( &s_projectJournal ); - s_mainWindow = NULL; - deleteHelper( &s_song ); delete ConfigManager::inst(); diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 0630b8e47..b6aff0446 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -37,6 +37,7 @@ #include "Engine.h" #include "ConfigManager.h" #include "SamplePlayHandle.h" +#include "GuiApplication.h" #include "PianoRoll.h" // platform-specific audio-interface-classes @@ -323,7 +324,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer() Song::playPos p = Engine::getSong()->getPlayPos( Song::Mode_PlayPattern ); if( Engine::getSong()->playMode() == Song::Mode_PlayPattern && - Engine::pianoRoll()->isRecording() == true && + gui->pianoRoll()->isRecording() == true && p != last_metro_pos ) { if ( p.getTicks() % (MidiTime::ticksPerTact() / 1 ) == 0 ) diff --git a/src/core/Plugin.cpp b/src/core/Plugin.cpp index 769ed04f2..ebfb62cb1 100644 --- a/src/core/Plugin.cpp +++ b/src/core/Plugin.cpp @@ -30,6 +30,7 @@ #include "Plugin.h" #include "embed.h" #include "Engine.h" +#include "GuiApplication.h" #include "Mixer.h" #include "ConfigManager.h" #include "DummyPlugin.h" @@ -127,7 +128,7 @@ Plugin * Plugin::instantiate( const QString & pluginName, Model * parent, void Plugin::collectErrorForUI( QString err_msg ) { - Engine::mainWindow()->collectError( err_msg ); + gui->mainWindow()->collectError( err_msg ); } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index bd6438de6..fc54689d8 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -22,6 +22,8 @@ * */ +#include "Song.h" + #include #include #include @@ -30,7 +32,6 @@ #include -#include "Song.h" #include "AutomationTrack.h" #include "AutomationEditor.h" #include "BBEditor.h" @@ -44,6 +45,7 @@ #include "ExportProjectDialog.h" #include "FxMixer.h" #include "FxMixerView.h" +#include "GuiApplication.h" #include "ImportFilter.h" #include "InstrumentTrack.h" #include "MainWindow.h" @@ -727,17 +729,17 @@ void Song::clearProject() Engine::mixer()->lock(); - if( Engine::getBBEditor() ) + if( gui->getBBEditor() ) { - Engine::getBBEditor()->trackContainerView()->clearAllTracks(); + gui->getBBEditor()->trackContainerView()->clearAllTracks(); } - if( Engine::songEditor() ) + if( gui->songEditor() ) { - Engine::songEditor()->m_editor->clearAllTracks(); + gui->songEditor()->m_editor->clearAllTracks(); } - if( Engine::fxMixerView() ) + if( gui->fxMixerView() ) { - Engine::fxMixerView()->clear(); + gui->fxMixerView()->clear(); } QCoreApplication::sendPostedEvents(); Engine::getBBTrackContainer()->clearAllTracks(); @@ -745,14 +747,14 @@ void Song::clearProject() Engine::fxMixer()->clear(); - if( Engine::automationEditor() ) + if( gui->automationEditor() ) { - Engine::automationEditor()->setCurrentPattern( NULL ); + gui->automationEditor()->setCurrentPattern( NULL ); } - if( Engine::pianoRoll() ) + if( gui->pianoRoll() ) { - Engine::pianoRoll()->reset(); + gui->pianoRoll()->reset(); } m_tempoModel.reset(); @@ -768,9 +770,9 @@ void Song::clearProject() Engine::mixer()->unlock(); - if( Engine::getProjectNotes() ) + if( gui->getProjectNotes() ) { - Engine::getProjectNotes()->clear(); + gui->getProjectNotes()->clear(); } // Move to function @@ -849,9 +851,9 @@ void Song::createNewProject() m_modified = false; - if( Engine::mainWindow() ) + if( gui->mainWindow() ) { - Engine::mainWindow()->resetWindowTitle(); + gui->mainWindow()->resetWindowTitle(); } } @@ -865,9 +867,9 @@ void Song::createNewProjectFromTemplate( const QString & _template ) // saving... m_fileName = m_oldFileName = ""; // update window title - if( Engine::mainWindow() ) + if( gui->mainWindow() ) { - Engine::mainWindow()->resetWindowTitle(); + gui->mainWindow()->resetWindowTitle(); } } @@ -883,7 +885,7 @@ void Song::loadProject( const QString & _file_name ) m_loadingProject = true; Engine::projectJournal()->setJournalling( false ); - Engine::mainWindow()->clearErrors(); + gui->mainWindow()->clearErrors(); m_fileName = _file_name; m_oldFileName = _file_name; @@ -931,7 +933,7 @@ void Song::loadProject( const QString & _file_name ) if( Engine::hasGUI() ) { // refresh FxMixerView - Engine::fxMixerView()->refreshDisplay(); + gui->fxMixerView()->refreshDisplay(); } } @@ -950,21 +952,21 @@ void Song::loadProject( const QString & _file_name ) } else if( Engine::hasGUI() ) { - if( node.nodeName() == Engine::getControllerRackView()->nodeName() ) + if( node.nodeName() == gui->getControllerRackView()->nodeName() ) { - Engine::getControllerRackView()->restoreState( node.toElement() ); + gui->getControllerRackView()->restoreState( node.toElement() ); } - else if( node.nodeName() == Engine::pianoRoll()->nodeName() ) + else if( node.nodeName() == gui->pianoRoll()->nodeName() ) { - Engine::pianoRoll()->restoreState( node.toElement() ); + gui->pianoRoll()->restoreState( node.toElement() ); } - else if( node.nodeName() == Engine::automationEditor()->m_editor->nodeName() ) + else if( node.nodeName() == gui->automationEditor()->m_editor->nodeName() ) { - Engine::automationEditor()->m_editor->restoreState( node.toElement() ); + gui->automationEditor()->m_editor->restoreState( node.toElement() ); } - else if( node.nodeName() == Engine::getProjectNotes()->nodeName() ) + else if( node.nodeName() == gui->getProjectNotes()->nodeName() ) { - Engine::getProjectNotes()->SerializingObject::restoreState( node.toElement() ); + gui->getProjectNotes()->SerializingObject::restoreState( node.toElement() ); } else if( node.nodeName() == m_playPos[Mode_PlaySong].m_timeLine->nodeName() ) { @@ -995,14 +997,14 @@ void Song::loadProject( const QString & _file_name ) emit projectLoaded(); - Engine::mainWindow()->showErrors( tr( "The following errors occured while loading: " ) ); + gui->mainWindow()->showErrors( tr( "The following errors occured while loading: " ) ); m_loadingProject = false; m_modified = false; - if( Engine::mainWindow() ) + if( gui->mainWindow() ) { - Engine::mainWindow()->resetWindowTitle(); + gui->mainWindow()->resetWindowTitle(); } } @@ -1025,10 +1027,10 @@ bool Song::saveProjectFile( const QString & _filename ) Engine::fxMixer()->saveState( dataFile, dataFile.content() ); if( Engine::hasGUI() ) { - Engine::getControllerRackView()->saveState( dataFile, dataFile.content() ); - Engine::pianoRoll()->saveState( dataFile, dataFile.content() ); - Engine::automationEditor()->m_editor->saveState( dataFile, dataFile.content() ); - Engine::getProjectNotes()->SerializingObject::saveState( dataFile, dataFile.content() ); + gui->getControllerRackView()->saveState( dataFile, dataFile.content() ); + gui->pianoRoll()->saveState( dataFile, dataFile.content() ); + gui->automationEditor()->m_editor->saveState( dataFile, dataFile.content() ); + gui->getProjectNotes()->SerializingObject::saveState( dataFile, dataFile.content() ); m_playPos[Mode_PlaySong].m_timeLine->saveState( dataFile, dataFile.content() ); } @@ -1053,7 +1055,7 @@ bool Song::guiSaveProject() 2000 ); ConfigManager::inst()->addRecentlyOpenedProject( m_fileName ); m_modified = false; - Engine::mainWindow()->resetWindowTitle(); + gui->mainWindow()->resetWindowTitle(); } else if( Engine::hasGUI() ) { @@ -1156,7 +1158,7 @@ void Song::exportProject(bool multiExport) { if( isEmpty() ) { - QMessageBox::information( Engine::mainWindow(), + QMessageBox::information( gui->mainWindow(), tr( "Empty project" ), tr( "This project is empty so exporting makes " "no sense. Please put some items into " @@ -1164,7 +1166,7 @@ void Song::exportProject(bool multiExport) return; } - FileDialog efd( Engine::mainWindow() ); + FileDialog efd( gui->mainWindow() ); if (multiExport) { efd.setFileMode( FileDialog::Directory); @@ -1224,7 +1226,7 @@ void Song::exportProject(bool multiExport) } const QString export_file_name = efd.selectedFiles()[0] + suffix; - ExportProjectDialog epd( export_file_name, Engine::mainWindow(), multiExport ); + ExportProjectDialog epd( export_file_name, gui->mainWindow(), multiExport ); epd.exec(); } } @@ -1245,10 +1247,10 @@ void Song::setModified() if( !m_loadingProject ) { m_modified = true; - if( Engine::mainWindow() && - QThread::currentThread() == Engine::mainWindow()->thread() ) + if( Engine::hasGUI() && gui->mainWindow() && + QThread::currentThread() == gui->mainWindow()->thread() ) { - Engine::mainWindow()->resetWindowTitle(); + gui->mainWindow()->resetWindowTitle(); } } } diff --git a/src/core/Track.cpp b/src/core/Track.cpp index a594ffdba..6d1e5dfef 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -56,6 +56,7 @@ #include "Clipboard.h" #include "embed.h" #include "Engine.h" +#include "GuiApplication.h" #include "gui_templates.h" #include "InstrumentTrack.h" #include "MainWindow.h" @@ -1134,7 +1135,7 @@ void TrackContentWidget::update() */ void TrackContentWidget::changePosition( const MidiTime & _new_pos ) { - if( m_trackView->trackContainerView() == Engine::getBBEditor()->trackContainerView() ) + if( m_trackView->trackContainerView() == gui->getBBEditor()->trackContainerView() ) { const int cur_bb = Engine::getBBTrackContainer()->currentBB(); setUpdatesEnabled( false ); @@ -1466,7 +1467,7 @@ void TrackContentWidget::paintEvent( QPaintEvent * _pe ) int ppt = static_cast( tcv->pixelsPerTact() ); QPainter p( this ); // Don't draw background on BB-Editor - if( m_trackView->trackContainerView() != Engine::getBBEditor()->trackContainerView() ) + if( m_trackView->trackContainerView() != gui->getBBEditor()->trackContainerView() ) { p.drawTiledPixmap( rect(), m_background, QPoint( tcv->currentPosition().getTact() * ppt, 0 ) ); diff --git a/src/core/TrackContainer.cpp b/src/core/TrackContainer.cpp index 400113b88..2cf02e28c 100644 --- a/src/core/TrackContainer.cpp +++ b/src/core/TrackContainer.cpp @@ -30,7 +30,7 @@ #include "TrackContainer.h" #include "InstrumentTrack.h" -#include "Engine.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "Song.h" @@ -89,7 +89,7 @@ void TrackContainer::loadSettings( const QDomElement & _this ) pd = new QProgressDialog( tr( "Loading project..." ), tr( "Cancel" ), 0, _this.childNodes().count(), - Engine::mainWindow() ); + gui->mainWindow() ); pd->setWindowModality( Qt::ApplicationModal ); pd->setWindowTitle( tr( "Please wait..." ) ); pd->show(); diff --git a/src/core/audio/AudioJack.cpp b/src/core/audio/AudioJack.cpp index 004f1e504..ac594aa06 100644 --- a/src/core/audio/AudioJack.cpp +++ b/src/core/audio/AudioJack.cpp @@ -32,8 +32,8 @@ #include -#include "debug.h" #include "Engine.h" +#include "GuiApplication.h" #include "templates.h" #include "gui_templates.h" #include "ConfigManager.h" @@ -106,7 +106,7 @@ void AudioJack::restartAfterZombified() { m_active = false; startProcessing(); - QMessageBox::information( Engine::mainWindow(), + QMessageBox::information( gui->mainWindow(), tr( "JACK client restarted" ), tr( "LMMS was kicked by JACK for some reason. " "Therefore the JACK backend of LMMS has been " @@ -115,7 +115,7 @@ void AudioJack::restartAfterZombified() } else { - QMessageBox::information( Engine::mainWindow(), + QMessageBox::information( gui->mainWindow(), tr( "JACK server down" ), tr( "The JACK server seems to have been shutdown " "and starting a new instance failed. " diff --git a/src/core/main.cpp b/src/core/main.cpp index 08042ef89..369a580db 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -69,6 +69,7 @@ #include "NotePlayHandle.h" #include "embed.h" #include "Engine.h" +#include "GuiApplication.h" #include "LmmsStyle.h" #include "ImportFilter.h" #include "MainWindow.h" @@ -102,7 +103,7 @@ int main( int argc, char * * argv ) // initialize memory managers MemoryManager::init(); NotePlayHandleManager::init(); - + // intialize RNG srand( getpid() + time( 0 ) ); @@ -437,9 +438,8 @@ int main( int argc, char * * argv ) qApp->processEvents(); // init central engine which handles all components of LMMS - Engine::init(); - - splashScreen.hide(); + Engine::init(false); + new GuiApplication(); // re-intialize RNG - shared libraries might have srand() or // srandom() calls in their init procedure @@ -449,7 +449,7 @@ int main( int argc, char * * argv ) QString recoveryFile = ConfigManager::inst()->recoveryFile(); if( QFileInfo(recoveryFile).exists() && - QMessageBox::question( Engine::mainWindow(), MainWindow::tr( "Project recovery" ), + QMessageBox::question( gui->mainWindow(), MainWindow::tr( "Project recovery" ), MainWindow::tr( "It looks like the last session did not end properly. " "Do you want to recover the project of this session?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) @@ -460,10 +460,10 @@ int main( int argc, char * * argv ) // we try to load given file if( !file_to_load.isEmpty() ) { - Engine::mainWindow()->show(); + gui->mainWindow()->show(); if( fullscreen ) { - Engine::mainWindow()->showMaximized(); + gui->mainWindow()->showMaximized(); } if( file_to_load == recoveryFile ) { @@ -482,10 +482,10 @@ int main( int argc, char * * argv ) return 0; } - Engine::mainWindow()->show(); + gui->mainWindow()->show(); if( fullscreen ) { - Engine::mainWindow()->showMaximized(); + gui->mainWindow()->showMaximized(); } } else @@ -494,12 +494,14 @@ int main( int argc, char * * argv ) // [Settel] workaround: showMaximized() doesn't work with // FVWM2 unless the window is already visible -> show() first - Engine::mainWindow()->show(); + gui->mainWindow()->show(); if( fullscreen ) { - Engine::mainWindow()->showMaximized(); + gui->mainWindow()->showMaximized(); } } + + splashScreen.finish(gui->mainWindow()); } else { @@ -536,9 +538,9 @@ int main( int argc, char * * argv ) const int ret = app->exec(); delete app; - + // cleanup memory managers MemoryManager::cleanup(); - + return( ret ); } diff --git a/src/gui/AboutDialog.cpp b/src/gui/AboutDialog.cpp index 5b152e07d..6d39a8e46 100644 --- a/src/gui/AboutDialog.cpp +++ b/src/gui/AboutDialog.cpp @@ -2,7 +2,7 @@ * AboutDialog.cpp - implementation of about-dialog * * Copyright (c) 2004-2008 Tobias Doerffel - * + * * This file is part of LMMS - http://lmms.io * * This program is free software; you can redistribute it and/or @@ -26,14 +26,12 @@ #include "lmmsversion.h" #include "AboutDialog.h" #include "embed.h" -#include "Engine.h" -#include "MainWindow.h" #include "versioninfo.h" -AboutDialog::AboutDialog() : - QDialog( Engine::mainWindow() ), +AboutDialog::AboutDialog(QWidget* parent) : + QDialog(parent), Ui::AboutDialog() { setupUi( this ); diff --git a/src/gui/AutomatableModelView.cpp b/src/gui/AutomatableModelView.cpp index 9485e636d..453d7e013 100644 --- a/src/gui/AutomatableModelView.cpp +++ b/src/gui/AutomatableModelView.cpp @@ -30,6 +30,7 @@ #include "ControllerConnectionDialog.h" #include "ControllerConnection.h" #include "embed.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "StringPairDrag.h" @@ -179,7 +180,7 @@ void AutomatableModelViewSlots::execConnectionDialog() AutomatableModel* m = m_amv->modelUntyped(); m->displayName(); - ControllerConnectionDialog d( (QWidget*) Engine::mainWindow(), m ); + ControllerConnectionDialog d( gui->mainWindow(), m ); if( d.exec() == 1 ) { @@ -226,7 +227,7 @@ void AutomatableModelViewSlots::removeConnection() void AutomatableModelViewSlots::editSongGlobalAutomation() { - Engine::automationEditor()->open( + gui->automationEditor()->open( AutomationPattern::globalAutomationPattern(m_amv->modelUntyped()) ); } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index cbb3067da..e777bdc07 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -30,7 +30,7 @@ #include "AutomationEditor.h" #include "AutomationPattern.h" #include "embed.h" -#include "Engine.h" +#include "GuiApplication.h" #include "gui_templates.h" #include "ProjectJournal.h" #include "RenameDialog.h" @@ -49,7 +49,7 @@ AutomationPatternView::AutomationPatternView( AutomationPattern * _pattern, { connect( m_pat, SIGNAL( dataChanged() ), this, SLOT( update() ) ); - connect( Engine::automationEditor(), SIGNAL( currentPatternChanged() ), + connect( gui->automationEditor(), SIGNAL( currentPatternChanged() ), this, SLOT( update() ) ); setAttribute( Qt::WA_OpaquePaintEvent, true ); @@ -123,9 +123,9 @@ void AutomationPatternView::disconnectObject( QAction * _a ) update(); //If automation editor is opened, update its display after disconnection - if( Engine::automationEditor() ) + if( gui->automationEditor() ) { - Engine::automationEditor()->m_editor->updateAfterPatternChange(); + gui->automationEditor()->m_editor->updateAfterPatternChange(); } //if there is no more connection connected to the AutomationPattern @@ -203,7 +203,7 @@ void AutomationPatternView::mouseDoubleClickEvent( QMouseEvent * _me ) _me->ignore(); return; } - Engine::automationEditor()->open(m_pat); + gui->automationEditor()->open(m_pat); } @@ -242,7 +242,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) lingrad.setColorAt( 0, c ); p.setBrush( lingrad ); - if( Engine::automationEditor()->currentPattern() == m_pat ) + if( gui->automationEditor()->currentPattern() == m_pat ) p.setPen( c.lighter( 160 ) ); else p.setPen( c.lighter( 130 ) ); @@ -325,7 +325,7 @@ void AutomationPatternView::paintEvent( QPaintEvent * ) // outer edge p.setBrush( QBrush() ); - if( Engine::automationEditor()->currentPattern() == m_pat ) + if( gui->automationEditor()->currentPattern() == m_pat ) p.setPen( c.lighter( 130 ) ); else p.setPen( c.darker( 300 ) ); @@ -386,10 +386,10 @@ void AutomationPatternView::dropEvent( QDropEvent * _de ) } update(); - if( Engine::automationEditor() && - Engine::automationEditor()->currentPattern() == m_pat ) + if( gui->automationEditor() && + gui->automationEditor()->currentPattern() == m_pat ) { - Engine::automationEditor()->setCurrentPattern( m_pat ); + gui->automationEditor()->setCurrentPattern( m_pat ); } } else diff --git a/src/gui/ExportProjectDialog.cpp b/src/gui/ExportProjectDialog.cpp index 7241216b6..67e13eced 100644 --- a/src/gui/ExportProjectDialog.cpp +++ b/src/gui/ExportProjectDialog.cpp @@ -28,7 +28,7 @@ #include "ExportProjectDialog.h" #include "Song.h" -#include "Engine.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "BBTrackContainer.h" #include "BBTrack.h" @@ -278,7 +278,7 @@ void ExportProjectDialog::render( ProjectRenderer* renderer ) connect( renderer, SIGNAL( progressChanged( int ) ), progressBar, SLOT( setValue( int ) ) ); connect( renderer, SIGNAL( progressChanged( int ) ), this, SLOT( updateTitleBar( int ) )) ; connect( renderer, SIGNAL( finished() ), this, SLOT( accept() ) ); - connect( renderer, SIGNAL( finished() ), Engine::mainWindow(), SLOT( resetWindowTitle() ) ); + connect( renderer, SIGNAL( finished() ), gui->mainWindow(), SLOT( resetWindowTitle() ) ); renderer->startProcessing(); } @@ -337,6 +337,6 @@ void ExportProjectDialog::startBtnClicked() void ExportProjectDialog::updateTitleBar( int _prog ) { - Engine::mainWindow()->setWindowTitle( + gui->mainWindow()->setWindowTitle( tr( "Rendering: %1%" ).arg( _prog ) ); } diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index ac84e404a..e8effe9fb 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -38,6 +38,7 @@ #include "debug.h" #include "embed.h" #include "Engine.h" +#include "GuiApplication.h" #include "gui_templates.h" #include "ImportFilter.h" #include "Instrument.h" @@ -549,7 +550,7 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it ) switch( f->handling() ) { case FileItem::LoadAsProject: - if( Engine::mainWindow()->mayChangeProject() ) + if( gui->mainWindow()->mayChangeProject() ) { Engine::getSong()->loadProject( f->fullName() ); } @@ -580,7 +581,7 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it ) case FileItem::ImportAsProject: if( f->type() == FileItem::FlpFile && - !Engine::mainWindow()->mayChangeProject() ) + !gui->mainWindow()->mayChangeProject() ) { break; } @@ -663,7 +664,7 @@ void FileBrowserTreeWidget::sendToActiveInstrumentTrack( void ) { // get all windows opened in the workspace QList pl = - Engine::mainWindow()->workspace()-> + gui->mainWindow()->workspace()-> subWindowList( QMdiArea::StackingOrder ); QListIterator w( pl ); w.toBack(); diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index aefdcf274..cb87ad84b 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -41,6 +41,7 @@ #include "Knob.h" #include "Engine.h" #include "embed.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "gui_templates.h" #include "InstrumentTrack.h" @@ -141,13 +142,13 @@ FxMixerView::FxMixerView() : updateGeometry(); // timer for updating faders - connect( Engine::mainWindow(), SIGNAL( periodicUpdate() ), + connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( updateFaders() ) ); // add ourself to workspace QMdiSubWindow * subWin = - Engine::mainWindow()->workspace()->addSubWindow( this ); + gui->mainWindow()->workspace()->addSubWindow( this ); Qt::WindowFlags flags = subWin->windowFlags(); flags &= ~Qt::WindowMaximizeButtonHint; subWin->setWindowFlags( flags ); diff --git a/src/gui/GuiApplication.cpp b/src/gui/GuiApplication.cpp new file mode 100644 index 000000000..ef62b2b57 --- /dev/null +++ b/src/gui/GuiApplication.cpp @@ -0,0 +1,68 @@ +/* + * GuiApplication.cpp + * + * Copyright (c) 2014 Lukas W + * + * 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. + * + */ + +#include "GuiApplication.h" + +#include "AutomationEditor.h" +#include "BBEditor.h" +#include "ControllerRackView.h" +#include "FxMixerView.h" +#include "InstrumentTrack.h" +#include "MainWindow.h" +#include "PianoRoll.h" +#include "ProjectNotes.h" +#include "SongEditor.h" + +#include "QApplication" + +GuiApplication* GuiApplication::s_instance = nullptr; + +GuiApplication* GuiApplication::instance() +{ + return s_instance; +} + +GuiApplication::GuiApplication() +{ + s_instance = this; + + m_mainWindow = new MainWindow; + + m_songEditor = new SongEditorWindow(Engine::getSong()); + m_fxMixerView = new FxMixerView; + m_controllerRackView = new ControllerRackView; + m_projectNotes = new ProjectNotes; + m_bbEditor = new BBEditor(Engine::getBBTrackContainer()); + m_pianoRoll = new PianoRollWindow(); + m_automationEditor = new AutomationEditorWindow; + + m_mainWindow->finalize(); + + Engine::s_hasGUI = true; +} + +GuiApplication::~GuiApplication() +{ + InstrumentTrackView::cleanupWindowCache(); +} diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 6e45f37f1..296d27b63 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -22,6 +22,7 @@ * */ +#include "MainWindow.h" #include #include @@ -36,7 +37,7 @@ #include #include "lmmsversion.h" -#include "MainWindow.h" +#include "GuiApplication.h" #include "BBEditor.h" #include "SongEditor.h" #include "Song.h" @@ -533,10 +534,10 @@ void MainWindow::finalize() // Add editor subwindows for (QWidget* widget : QList{ - Engine::automationEditor(), - Engine::getBBEditor(), - Engine::pianoRoll(), - Engine::songEditor() + gui->automationEditor(), + gui->getBBEditor(), + gui->pianoRoll(), + gui->songEditor() }) { QMdiSubWindow* window = workspace()->addSubWindow(widget); @@ -545,13 +546,13 @@ void MainWindow::finalize() window->resize(widget->sizeHint()); } - Engine::automationEditor()->parentWidget()->hide(); - Engine::getBBEditor()->parentWidget()->move( 610, 5 ); - Engine::getBBEditor()->parentWidget()->show(); - Engine::pianoRoll()->parentWidget()->move(5, 5); - Engine::pianoRoll()->parentWidget()->hide(); - Engine::songEditor()->parentWidget()->move(5, 5); - Engine::songEditor()->parentWidget()->show(); + gui->automationEditor()->parentWidget()->hide(); + gui->getBBEditor()->parentWidget()->move( 610, 5 ); + gui->getBBEditor()->parentWidget()->show(); + gui->pianoRoll()->parentWidget()->move(5, 5); + gui->pianoRoll()->parentWidget()->hide(); + gui->songEditor()->parentWidget()->move(5, 5); + gui->songEditor()->parentWidget()->show(); } @@ -866,7 +867,7 @@ void MainWindow::showSettingsDialog() void MainWindow::aboutLMMS() { - AboutDialog().exec(); + AboutDialog(this).exec(); } @@ -923,10 +924,10 @@ void MainWindow::refocus() { QList editors; editors - << Engine::songEditor()->parentWidget() - << Engine::getBBEditor()->parentWidget() - << Engine::pianoRoll()->parentWidget() - << Engine::automationEditor()->parentWidget(); + << gui->songEditor()->parentWidget() + << gui->getBBEditor()->parentWidget() + << gui->pianoRoll()->parentWidget() + << gui->automationEditor()->parentWidget(); bool found = false; QList::Iterator editor; @@ -948,7 +949,7 @@ void MainWindow::refocus() void MainWindow::toggleBBEditorWin( bool forceShow ) { - toggleWindow( Engine::getBBEditor(), forceShow ); + toggleWindow( gui->getBBEditor(), forceShow ); } @@ -956,7 +957,7 @@ void MainWindow::toggleBBEditorWin( bool forceShow ) void MainWindow::toggleSongEditorWin() { - toggleWindow( Engine::songEditor() ); + toggleWindow( gui->songEditor() ); } @@ -964,7 +965,7 @@ void MainWindow::toggleSongEditorWin() void MainWindow::toggleProjectNotesWin() { - toggleWindow( Engine::getProjectNotes() ); + toggleWindow( gui->getProjectNotes() ); } @@ -972,7 +973,7 @@ void MainWindow::toggleProjectNotesWin() void MainWindow::togglePianoRollWin() { - toggleWindow( Engine::pianoRoll() ); + toggleWindow( gui->pianoRoll() ); } @@ -980,7 +981,7 @@ void MainWindow::togglePianoRollWin() void MainWindow::toggleAutomationEditorWin() { - toggleWindow( Engine::automationEditor() ); + toggleWindow( gui->automationEditor() ); } @@ -988,7 +989,7 @@ void MainWindow::toggleAutomationEditorWin() void MainWindow::toggleFxMixerWin() { - toggleWindow( Engine::fxMixerView() ); + toggleWindow( gui->fxMixerView() ); } @@ -996,7 +997,7 @@ void MainWindow::toggleFxMixerWin() void MainWindow::toggleControllerRack() { - toggleWindow( Engine::getControllerRackView() ); + toggleWindow( gui->getControllerRackView() ); } @@ -1004,29 +1005,29 @@ void MainWindow::toggleControllerRack() void MainWindow::updatePlayPauseIcons() { - Engine::songEditor()->setPauseIcon( false ); - Engine::automationEditor()->setPauseIcon( false ); - Engine::getBBEditor()->setPauseIcon( false ); - Engine::pianoRoll()->setPauseIcon( false ); + gui->songEditor()->setPauseIcon( false ); + gui->automationEditor()->setPauseIcon( false ); + gui->getBBEditor()->setPauseIcon( false ); + gui->pianoRoll()->setPauseIcon( false ); if( Engine::getSong()->isPlaying() ) { switch( Engine::getSong()->playMode() ) { case Song::Mode_PlaySong: - Engine::songEditor()->setPauseIcon( true ); + gui->songEditor()->setPauseIcon( true ); break; case Song::Mode_PlayAutomationPattern: - Engine::automationEditor()->setPauseIcon( true ); + gui->automationEditor()->setPauseIcon( true ); break; case Song::Mode_PlayBB: - Engine::getBBEditor()->setPauseIcon( true ); + gui->getBBEditor()->setPauseIcon( true ); break; case Song::Mode_PlayPattern: - Engine::pianoRoll()->setPauseIcon( true ); + gui->pianoRoll()->setPauseIcon( true ); break; default: diff --git a/src/gui/StringPairDrag.cpp b/src/gui/StringPairDrag.cpp index ac0347530..244362a70 100644 --- a/src/gui/StringPairDrag.cpp +++ b/src/gui/StringPairDrag.cpp @@ -31,7 +31,7 @@ #include "StringPairDrag.h" -#include "Engine.h" +#include "GuiApplication.h" #include "MainWindow.h" @@ -64,9 +64,9 @@ StringPairDrag::~StringPairDrag() { // during a drag, we might have lost key-press-events, so reset // modifiers of main-win - if( Engine::mainWindow() ) + if( gui->mainWindow() ) { - Engine::mainWindow()->clearKeyModifiers(); + gui->mainWindow()->clearKeyModifiers(); } } diff --git a/src/gui/TimeLineWidget.cpp b/src/gui/TimeLineWidget.cpp index 624d0df3e..5966e7d51 100644 --- a/src/gui/TimeLineWidget.cpp +++ b/src/gui/TimeLineWidget.cpp @@ -37,7 +37,7 @@ #include "Engine.h" #include "templates.h" #include "NStateButton.h" -#include "MainWindow.h" +#include "GuiApplication.h" #include "TextFloat.h" @@ -112,7 +112,7 @@ TimeLineWidget::TimeLineWidget( const int _xoff, const int _yoff, const float _p TimeLineWidget::~TimeLineWidget() { - if( Engine::songEditor() ) + if( gui->songEditor() ) { m_pos.m_timeLine = NULL; } diff --git a/src/gui/ToolPluginView.cpp b/src/gui/ToolPluginView.cpp index 72953c82c..8426c146e 100644 --- a/src/gui/ToolPluginView.cpp +++ b/src/gui/ToolPluginView.cpp @@ -31,13 +31,14 @@ #include "embed.h" #include "Engine.h" +#include "GuiApplication.h" #include "MainWindow.h" ToolPluginView::ToolPluginView( ToolPlugin * _toolPlugin ) : PluginView( _toolPlugin, NULL ) { - Engine::mainWindow()->workspace()->addSubWindow( this ); + gui->mainWindow()->workspace()->addSubWindow( this ); parentWidget()->setAttribute( Qt::WA_DeleteOnClose, false ); setWindowTitle( _toolPlugin->displayName() ); diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 0799bb445..e97a3eaea 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -50,6 +50,7 @@ #include "ActionGroup.h" #include "SongEditor.h" #include "MainWindow.h" +#include "GuiApplication.h" #include "embed.h" #include "Engine.h" #include "PixmapButton.h" @@ -274,7 +275,7 @@ void AutomationEditor::update() // Note detuning? if( m_pattern && !m_pattern->getTrack() ) { - Engine::pianoRoll()->update(); + gui->pianoRoll()->update(); } } @@ -1527,7 +1528,7 @@ void AutomationEditor::play() if( Engine::getSong()->playMode() != Song::Mode_PlayPattern ) { Engine::getSong()->stop(); - Engine::getSong()->playPattern( Engine::pianoRoll()->currentPattern() ); + Engine::getSong()->playPattern( gui->pianoRoll()->currentPattern() ); } else if( Engine::getSong()->isStopped() == false ) { @@ -1535,7 +1536,7 @@ void AutomationEditor::play() } else { - Engine::getSong()->playPattern( Engine::pianoRoll()->currentPattern() ); + Engine::getSong()->playPattern( gui->pianoRoll()->currentPattern() ); } } else if( inBBEditor() ) @@ -1791,7 +1792,7 @@ void AutomationEditor::cutSelectedValues() } update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } @@ -1813,7 +1814,7 @@ void AutomationEditor::pasteValues() // least one value... Engine::getSong()->setModified(); update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } } @@ -1843,7 +1844,7 @@ void AutomationEditor::deleteSelectedValues() { Engine::getSong()->setModified(); update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } } diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index d989cb85d..567833800 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -55,6 +55,7 @@ #include "debug.h" #include "DetuningHelper.h" #include "embed.h" +#include "GuiApplication.h" #include "gui_templates.h" #include "InstrumentTrack.h" #include "MainWindow.h" @@ -817,7 +818,7 @@ void PianoRoll::shiftSemiTone( int amount ) // shift notes by amount semitones // we modified the song update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } @@ -853,7 +854,7 @@ void PianoRoll::shiftPos( int amount ) //shift notes pos by amount // we modified the song update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } @@ -1218,7 +1219,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) { Note* n = noteUnderMouse(); if (n->detuning() == NULL) n->createDetuning(); - Engine::automationEditor()->open( noteUnderMouse()->detuning()->automationPattern() ); + gui->automationEditor()->open( noteUnderMouse()->detuning()->automationPattern() ); return; } @@ -1498,7 +1499,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) // added new notes, so must update engine, song, etc Engine::getSong()->setModified(); update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } } @@ -3626,7 +3627,7 @@ void PianoRoll::cutSelectedNotes() } update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } @@ -3675,7 +3676,7 @@ void PianoRoll::pasteNotes() // least one note... Engine::getSong()->setModified(); update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } } @@ -3719,7 +3720,7 @@ void PianoRoll::deleteSelectedNotes() { Engine::getSong()->setModified(); update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } } diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index afbbb2698..bf3be5d63 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -22,6 +22,8 @@ * */ +#include "SongEditor.h" + #include #include #include @@ -36,12 +38,12 @@ #include #include "ActionGroup.h" -#include "SongEditor.h" #include "AutomatableSlider.h" #include "ComboBox.h" #include "ConfigManager.h" #include "CPULoadWidget.h" #include "embed.h" +#include "GuiApplication.h" #include "LcdSpinBox.h" #include "MainWindow.h" #include "MeterDialog.h" @@ -108,9 +110,9 @@ SongEditor::SongEditor( Song * _song ) : // add some essential widgets to global tool-bar - QWidget * tb = Engine::mainWindow()->toolBar(); + QWidget * tb = gui->mainWindow()->toolBar(); - Engine::mainWindow()->addSpacingToToolBar( 10 ); + gui->mainWindow()->addSpacingToToolBar( 10 ); m_tempoSpinBox = new LcdSpinBox( 3, tb, tr( "Tempo" ) ); m_tempoSpinBox->setModel( &m_song->m_tempoModel ); @@ -125,7 +127,7 @@ SongEditor::SongEditor( Song * _song ) : "should be played within a minute (or how many measures " "should be played within four minutes)." ) ); - int tempoSpinBoxCol = Engine::mainWindow()->addWidgetToToolBar( m_tempoSpinBox, 0 ); + int tempoSpinBoxCol = gui->mainWindow()->addWidgetToToolBar( m_tempoSpinBox, 0 ); #if 0 toolButton * hq_btn = new toolButton( embed::getIconPixmap( "hq_mode" ), @@ -135,18 +137,18 @@ SongEditor::SongEditor( Song * _song ) : connect( hq_btn, SIGNAL( toggled( bool ) ), this, SLOT( setHighQuality( bool ) ) ); hq_btn->setFixedWidth( 42 ); - Engine::mainWindow()->addWidgetToToolBar( hq_btn, 1, col ); + gui->mainWindow()->addWidgetToToolBar( hq_btn, 1, col ); #endif - Engine::mainWindow()->addWidgetToToolBar( new TimeDisplayWidget, 1, tempoSpinBoxCol ); + gui->mainWindow()->addWidgetToToolBar( new TimeDisplayWidget, 1, tempoSpinBoxCol ); - Engine::mainWindow()->addSpacingToToolBar( 10 ); + gui->mainWindow()->addSpacingToToolBar( 10 ); m_timeSigDisplay = new MeterDialog( this, true ); m_timeSigDisplay->setModel( &m_song->m_timeSigModel ); - Engine::mainWindow()->addWidgetToToolBar( m_timeSigDisplay ); + gui->mainWindow()->addWidgetToToolBar( m_timeSigDisplay ); - Engine::mainWindow()->addSpacingToToolBar( 10 ); + gui->mainWindow()->addSpacingToToolBar( 10 ); QLabel * master_vol_lbl = new QLabel( tb ); @@ -175,11 +177,11 @@ SongEditor::SongEditor( Song * _song ) : m_mvsStatus->setTitle( tr( "Master volume" ) ); m_mvsStatus->setPixmap( embed::getIconPixmap( "master_volume" ) ); - Engine::mainWindow()->addWidgetToToolBar( master_vol_lbl ); - Engine::mainWindow()->addWidgetToToolBar( m_masterVolumeSlider ); + gui->mainWindow()->addWidgetToToolBar( master_vol_lbl ); + gui->mainWindow()->addWidgetToToolBar( m_masterVolumeSlider ); - Engine::mainWindow()->addSpacingToToolBar( 10 ); + gui->mainWindow()->addSpacingToToolBar( 10 ); QLabel * master_pitch_lbl = new QLabel( tb ); @@ -207,10 +209,10 @@ SongEditor::SongEditor( Song * _song ) : m_mpsStatus->setTitle( tr( "Master pitch" ) ); m_mpsStatus->setPixmap( embed::getIconPixmap( "master_pitch" ) ); - Engine::mainWindow()->addWidgetToToolBar( master_pitch_lbl ); - Engine::mainWindow()->addWidgetToToolBar( m_masterPitchSlider ); + gui->mainWindow()->addWidgetToToolBar( master_pitch_lbl ); + gui->mainWindow()->addWidgetToToolBar( m_masterPitchSlider ); - Engine::mainWindow()->addSpacingToToolBar( 10 ); + gui->mainWindow()->addSpacingToToolBar( 10 ); // create widget for visualization- and cpu-load-widget QWidget * vc_w = new QWidget( tb ); @@ -225,7 +227,7 @@ SongEditor::SongEditor( Song * _song ) : vcw_layout->addWidget( new CPULoadWidget( vc_w ) ); vcw_layout->addStretch(); - Engine::mainWindow()->addWidgetToToolBar( vc_w ); + gui->mainWindow()->addWidgetToToolBar( vc_w ); static_cast( layout() )->insertWidget( 0, m_timeLine ); @@ -305,13 +307,13 @@ void SongEditor::setEditModeSelect() void SongEditor::keyPressEvent( QKeyEvent * _ke ) { if( /*_ke->modifiers() & Qt::ShiftModifier*/ - Engine::mainWindow()->isShiftPressed() == true && + gui->mainWindow()->isShiftPressed() == true && _ke->key() == Qt::Key_Insert ) { m_song->insertBar(); } else if(/* _ke->modifiers() & Qt::ShiftModifier &&*/ - Engine::mainWindow()->isShiftPressed() == true && + gui->mainWindow()->isShiftPressed() == true && _ke->key() == Qt::Key_Delete ) { m_song->removeBar(); @@ -347,7 +349,7 @@ void SongEditor::keyPressEvent( QKeyEvent * _ke ) void SongEditor::wheelEvent( QWheelEvent * _we ) { - if( Engine::mainWindow()->isCtrlPressed() == true ) + if( gui->mainWindow()->isCtrlPressed() == true ) { if( _we->delta() > 0 ) { @@ -371,7 +373,7 @@ void SongEditor::wheelEvent( QWheelEvent * _we ) // and make sure, all TCO's are resized and relocated realignTracks(); } - else if( Engine::mainWindow()->isShiftPressed() == true ) + else if( gui->mainWindow()->isShiftPressed() == true ) { m_leftRightScroll->setValue( m_leftRightScroll->value() - _we->delta() / 30 ); @@ -586,7 +588,7 @@ void SongEditor::adjustUiAfterProjectLoad() // make sure to bring us to front as the song editor is the central // widget in a song and when just opening a song in order to listen to // it, it's very annyoing to manually bring up the song editor each time - Engine::mainWindow()->workspace()->setActiveSubWindow( + gui->mainWindow()->workspace()->setActiveSubWindow( qobject_cast( parentWidget() ) ); } scrolled( 0 ); @@ -706,5 +708,5 @@ void SongEditorWindow::recordAccompany() void SongEditorWindow::stop() { m_editor->m_song->stop(); - Engine::pianoRoll()->stopRecording(); + gui->pianoRoll()->stopRecording(); } diff --git a/src/gui/widgets/ControllerRackView.cpp b/src/gui/widgets/ControllerRackView.cpp index 7ec3ab711..0c6690335 100644 --- a/src/gui/widgets/ControllerRackView.cpp +++ b/src/gui/widgets/ControllerRackView.cpp @@ -34,6 +34,7 @@ #include "Song.h" #include "embed.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "GroupBox.h" #include "ControllerRackView.h" @@ -75,7 +76,7 @@ ControllerRackView::ControllerRackView( ) : this->setLayout( layout ); QMdiSubWindow * subWin = - Engine::mainWindow()->workspace()->addSubWindow( this ); + gui->mainWindow()->workspace()->addSubWindow( this ); // No maximize button Qt::WindowFlags flags = subWin->windowFlags(); diff --git a/src/gui/widgets/ControllerView.cpp b/src/gui/widgets/ControllerView.cpp index aaaa3ef1a..8b618a3e1 100644 --- a/src/gui/widgets/ControllerView.cpp +++ b/src/gui/widgets/ControllerView.cpp @@ -39,6 +39,7 @@ #include "gui_templates.h" #include "embed.h" #include "Engine.h" +#include "GuiApplication.h" #include "LedCheckbox.h" #include "MainWindow.h" #include "ToolTip.h" @@ -62,9 +63,9 @@ ControllerView::ControllerView( Controller * _model, QWidget * _parent ) : connect( ctls_btn, SIGNAL( clicked() ), this, SLOT( editControls() ) ); - m_controllerDlg = getController()->createDialog( Engine::mainWindow()->workspace() ); + m_controllerDlg = getController()->createDialog( gui->mainWindow()->workspace() ); - m_subWindow = Engine::mainWindow()->workspace()->addSubWindow( + m_subWindow = gui->mainWindow()->workspace()->addSubWindow( m_controllerDlg ); Qt::WindowFlags flags = m_subWindow->windowFlags(); diff --git a/src/gui/widgets/EffectView.cpp b/src/gui/widgets/EffectView.cpp index 6214747d5..64463caed 100644 --- a/src/gui/widgets/EffectView.cpp +++ b/src/gui/widgets/EffectView.cpp @@ -37,6 +37,7 @@ #include "EffectControlDialog.h" #include "embed.h" #include "Engine.h" +#include "GuiApplication.h" #include "gui_templates.h" #include "Knob.h" #include "LedCheckbox.h" @@ -109,7 +110,7 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) : m_controlView = effect()->controls()->createView(); if( m_controlView ) { - m_subWindow = Engine::mainWindow()->workspace()->addSubWindow( + m_subWindow = gui->mainWindow()->workspace()->addSubWindow( m_controlView, Qt::SubWindow | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint ); diff --git a/src/gui/widgets/FxLine.cpp b/src/gui/widgets/FxLine.cpp index 36baa782f..9703c4ba9 100644 --- a/src/gui/widgets/FxLine.cpp +++ b/src/gui/widgets/FxLine.cpp @@ -35,6 +35,7 @@ #include "FxMixerView.h" #include "embed.h" #include "Engine.h" +#include "GuiApplication.h" #include "SendButtonIndicator.h" #include "gui_templates.h" #include "CaptionMenu.h" @@ -224,21 +225,21 @@ void FxLine::renameChannel() void FxLine::removeChannel() { - FxMixerView * mix = Engine::fxMixerView(); + FxMixerView * mix = gui->fxMixerView(); mix->deleteChannel( m_channelIndex ); } void FxLine::moveChannelLeft() { - FxMixerView * mix = Engine::fxMixerView(); + FxMixerView * mix = gui->fxMixerView(); mix->moveChannelLeft( m_channelIndex ); } void FxLine::moveChannelRight() { - FxMixerView * mix = Engine::fxMixerView(); + FxMixerView * mix = gui->fxMixerView(); mix->moveChannelRight( m_channelIndex ); } diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index e5d8be854..75732679d 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -43,6 +43,7 @@ #include "embed.h" #include "Engine.h" #include "gui_templates.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "ProjectJournal.h" #include "Song.h" @@ -458,15 +459,15 @@ float Knob::getValue( const QPoint & _p ) { float value; - // arcane mathemagicks for calculating knob movement + // arcane mathemagicks for calculating knob movement value = ( ( _p.y() + _p.y() * qMin( qAbs( _p.y() / 2.5f ), 6.0f ) ) ) / 12.0f; - + // if shift pressed we want slower movement - if( Engine::mainWindow()->isShiftPressed() ) + if( gui->mainWindow()->isShiftPressed() ) { value /= 4.0f; value = qBound( -4.0f, value, 4.0f ); - } + } return value * pageSize(); } @@ -483,7 +484,7 @@ void Knob::contextMenuEvent( QContextMenuEvent * ) CaptionMenu contextMenu( model()->displayName(), this ); addDefaultActions( &contextMenu ); - contextMenu.addAction( QPixmap(), + contextMenu.addAction( QPixmap(), model()->isScaleLogarithmic() ? tr( "Set linear" ) : tr( "Set logarithmic" ), this, SLOT( toggleScale() ) ); contextMenu.addSeparator(); @@ -561,7 +562,7 @@ void Knob::mousePressEvent( QMouseEvent * _me ) m_buttonPressed = true; } else if( _me->button() == Qt::LeftButton && - Engine::mainWindow()->isShiftPressed() == true ) + gui->mainWindow()->isShiftPressed() == true ) { new StringPairDrag( "float_value", QString::number( model()->value() ), @@ -681,7 +682,7 @@ void Knob::setPosition( const QPoint & _p ) if( model()->isScaleLogarithmic() ) // logarithmic code { - const float pos = model()->minValue() < 0 + const float pos = model()->minValue() < 0 ? oldValue / qMax( qAbs( model()->maxValue() ), qAbs( model()->minValue() ) ) : ( oldValue - model()->minValue() ) / model()->range(); const float ratio = 0.1f + qAbs( pos ) * 15.f; @@ -697,11 +698,11 @@ void Knob::setPosition( const QPoint & _p ) } } - + else // linear code { if( qAbs( value ) >= step ) - { + { model()->setValue( oldValue - value ); m_leftOver = 0.0f; } diff --git a/src/gui/widgets/LcdSpinBox.cpp b/src/gui/widgets/LcdSpinBox.cpp index afdf85943..73534f5c7 100644 --- a/src/gui/widgets/LcdSpinBox.cpp +++ b/src/gui/widgets/LcdSpinBox.cpp @@ -35,6 +35,7 @@ #include "CaptionMenu.h" #include "Engine.h" #include "embed.h" +#include "GuiApplication.h" #include "gui_templates.h" #include "templates.h" #include "MainWindow.h" @@ -126,7 +127,7 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event ) if( m_mouseMoving ) { int dy = event->globalY() - m_origMousePos.y(); - if( Engine::mainWindow()->isShiftPressed() ) + if( gui->mainWindow()->isShiftPressed() ) dy = qBound( -4, dy/4, 4 ); if( dy > 1 || dy < -1 ) { diff --git a/src/gui/widgets/ProjectNotes.cpp b/src/gui/widgets/ProjectNotes.cpp index bc6908f50..b4dcf8e27 100644 --- a/src/gui/widgets/ProjectNotes.cpp +++ b/src/gui/widgets/ProjectNotes.cpp @@ -39,13 +39,14 @@ #include "embed.h" #include "Engine.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "Song.h" ProjectNotes::ProjectNotes() : - QMainWindow( Engine::mainWindow()->workspace() ) + QMainWindow( gui->mainWindow()->workspace() ) { m_edit = new QTextEdit( this ); m_edit->setAutoFillBackground( true ); @@ -70,7 +71,7 @@ ProjectNotes::ProjectNotes() : setWindowTitle( tr( "Project notes" ) ); setWindowIcon( embed::getIconPixmap( "project_notes" ) ); - Engine::mainWindow()->workspace()->addSubWindow( this ); + gui->mainWindow()->workspace()->addSubWindow( this ); parentWidget()->setAttribute( Qt::WA_DeleteOnClose, false ); parentWidget()->move( 700, 10 ); parentWidget()->resize( 400, 300 ); diff --git a/src/gui/widgets/TempoSyncKnob.cpp b/src/gui/widgets/TempoSyncKnob.cpp index 0022691e0..598cfc062 100644 --- a/src/gui/widgets/TempoSyncKnob.cpp +++ b/src/gui/widgets/TempoSyncKnob.cpp @@ -30,6 +30,7 @@ #include "Engine.h" #include "CaptionMenu.h" #include "embed.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "MeterDialog.h" #include "Song.h" @@ -86,10 +87,10 @@ void TempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) CaptionMenu contextMenu( model()->displayName(), this ); addDefaultActions( &contextMenu ); contextMenu.addSeparator(); - + float limit = 60000.0f / ( Engine::getSong()->getTempo() * model()->m_scale ); - + QMenu * syncMenu = contextMenu.addMenu( m_tempoSyncIcon, m_tempoSyncDescription ); if( limit / 8.0f <= model()->maxValue() ) @@ -149,7 +150,7 @@ void TempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) contextMenu.addHelpAction(); contextMenu.exec( QCursor::pos() ); - + delete syncMenu; } @@ -163,7 +164,7 @@ void TempoSyncKnob::updateDescAndIcon() switch( model()->m_tempoSyncMode ) { case TempoSyncKnobModel::SyncCustom: - m_tempoSyncDescription = tr( "Custom " ) + + m_tempoSyncDescription = tr( "Custom " ) + "(" + QString::number( model()->m_custom.numeratorModel().value() ) + "/" + @@ -291,8 +292,8 @@ void TempoSyncKnob::showCustom() { if( m_custom == NULL ) { - m_custom = new MeterDialog( Engine::mainWindow()->workspace() ); - Engine::mainWindow()->workspace()->addSubWindow( m_custom ); + m_custom = new MeterDialog( gui->mainWindow()->workspace() ); + gui->mainWindow()->workspace()->addSubWindow( m_custom ); m_custom->setWindowTitle( "Meter" ); m_custom->setModel( &model()->m_custom ); } diff --git a/src/gui/widgets/TextFloat.cpp b/src/gui/widgets/TextFloat.cpp index 9947b09cd..99d990699 100644 --- a/src/gui/widgets/TextFloat.cpp +++ b/src/gui/widgets/TextFloat.cpp @@ -28,13 +28,14 @@ #include "TextFloat.h" #include "gui_templates.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "Engine.h" TextFloat::TextFloat() : - QWidget( Engine::mainWindow(), Qt::ToolTip ), + QWidget( gui->mainWindow(), Qt::ToolTip ), m_title(), m_text(), m_pixmap() @@ -89,7 +90,7 @@ void TextFloat::setVisibilityTimeOut( int _msecs ) TextFloat * TextFloat::displayMessage( const QString & _msg, int _timeout, QWidget * _parent, int _add_y_margin ) { - QWidget * mw = Engine::mainWindow(); + QWidget * mw = gui->mainWindow(); TextFloat * tf = new TextFloat; if( _parent != NULL ) { diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index d2afe9240..a06a1c3fb 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -25,6 +25,7 @@ #include #include "TimeDisplayWidget.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "Engine.h" #include "ToolTip.h" @@ -53,7 +54,7 @@ TimeDisplayWidget::TimeDisplayWidget() : // update labels of LCD spinboxes setDisplayMode( m_displayMode ); - connect( Engine::mainWindow(), SIGNAL( periodicUpdate() ), + connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( updateTime() ) ); } diff --git a/src/gui/widgets/VisualizationWidget.cpp b/src/gui/widgets/VisualizationWidget.cpp index e7e21d589..734defc68 100644 --- a/src/gui/widgets/VisualizationWidget.cpp +++ b/src/gui/widgets/VisualizationWidget.cpp @@ -27,6 +27,7 @@ #include #include "VisualizationWidget.h" +#include "GuiApplication.h" #include "gui_templates.h" #include "MainWindow.h" #include "embed.h" @@ -90,7 +91,7 @@ void VisualizationWidget::setActive( bool _active ) m_active = _active; if( m_active ) { - connect( Engine::mainWindow(), + connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) ); connect( Engine::mixer(), @@ -99,7 +100,7 @@ void VisualizationWidget::setActive( bool _active ) } else { - disconnect( Engine::mainWindow(), + disconnect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) ); disconnect( Engine::mixer(), diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index f30d59bbe..b3f494255 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.cpp @@ -34,6 +34,7 @@ #include "Engine.h" #include "gui_templates.h" #include "MainWindow.h" +#include "GuiApplication.h" #include "Mixer.h" #include "RenameDialog.h" #include "Song.h" @@ -275,7 +276,7 @@ void BBTCOView::openInBBEditor() { Engine::getBBTrackContainer()->setCurrentBB( m_bbTCO->bbTrackIndex() ); - Engine::mainWindow()->toggleBBEditorWin( true ); + gui->mainWindow()->toggleBBEditorWin( true ); } @@ -310,7 +311,7 @@ void BBTCOView::changeColor() if( isSelected() ) { QVector selected = - Engine::songEditor()->m_editor->selectedObjects(); + gui->songEditor()->m_editor->selectedObjects(); for( QVector::iterator it = selected.begin(); it != selected.end(); ++it ) @@ -599,7 +600,7 @@ BBTrackView::BBTrackView( BBTrack * _bbt, TrackContainerView* tcv ) : BBTrackView::~BBTrackView() { - Engine::getBBEditor()->removeBBView( BBTrack::s_infoMap[m_bbTrack] ); + gui->getBBEditor()->removeBBView( BBTrack::s_infoMap[m_bbTrack] ); } @@ -607,7 +608,7 @@ BBTrackView::~BBTrackView() bool BBTrackView::close() { - Engine::getBBEditor()->removeBBView( BBTrack::s_infoMap[m_bbTrack] ); + gui->getBBEditor()->removeBBView( BBTrack::s_infoMap[m_bbTrack] ); return TrackView::close(); } @@ -617,7 +618,7 @@ bool BBTrackView::close() void BBTrackView::clickedTrackLabel() { Engine::getBBTrackContainer()->setCurrentBB( m_bbTrack->index() ); - Engine::getBBEditor()->show(); + gui->getBBEditor()->show(); /* foreach( bbTrackView * tv, trackContainerView()->findChildren() ) { diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 06219b942..0466d9152 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -52,6 +52,7 @@ #include "FileBrowser.h" #include "FxMixer.h" #include "FxMixerView.h" +#include "GuiApplication.h" #include "InstrumentSoundShaping.h" #include "InstrumentSoundShapingView.h" #include "FadeButton.h" @@ -935,7 +936,7 @@ InstrumentTrackWindow * InstrumentTrackView::topLevelInstrumentTrackWindow() { InstrumentTrackWindow * w = NULL; foreach( QMdiSubWindow * sw, - Engine::mainWindow()->workspace()->subWindowList( + gui->mainWindow()->workspace()->subWindowList( QMdiArea::ActivationHistoryOrder ) ) { if( sw->isVisible() && sw->widget()->inherits( "InstrumentTrackWindow" ) ) @@ -1129,10 +1130,10 @@ class fxLineLcdSpinBox : public LcdSpinBox protected: virtual void mouseDoubleClickEvent ( QMouseEvent * _me ) { - Engine::fxMixerView()->setCurrentFxLine( model()->value() ); + gui->fxMixerView()->setCurrentFxLine( model()->value() ); - Engine::fxMixerView()->show();// show fxMixer window - Engine::fxMixerView()->setFocus();// set focus to fxMixer window + gui->fxMixerView()->show();// show fxMixer window + gui->fxMixerView()->setFocus();// set focus to fxMixer window //engine::getFxMixerView()->raise(); } }; @@ -1274,7 +1275,7 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : setFixedWidth( INSTRUMENT_WIDTH ); resize( sizeHint() ); - QMdiSubWindow * subWin = Engine::mainWindow()->workspace()->addSubWindow( this ); + QMdiSubWindow * subWin = gui->mainWindow()->workspace()->addSubWindow( this ); Qt::WindowFlags flags = subWin->windowFlags(); flags |= Qt::MSWindowsFixedSizeDialogHint; flags &= ~Qt::WindowMaximizeButtonHint; @@ -1300,7 +1301,7 @@ InstrumentTrackWindow::~InstrumentTrackWindow() delete m_instrumentView; - if( Engine::mainWindow()->workspace() ) + if( gui->mainWindow()->workspace() ) { parentWidget()->hide(); parentWidget()->deleteLater(); @@ -1466,7 +1467,7 @@ void InstrumentTrackWindow::closeEvent( QCloseEvent* event ) { event->ignore(); - if( Engine::mainWindow()->workspace() ) + if( gui->mainWindow()->workspace() ) { parentWidget()->hide(); } diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index f53c57713..5bdab5e3d 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -38,7 +38,7 @@ #include "templates.h" #include "gui_templates.h" #include "embed.h" -#include "Engine.h" +#include "GuiApplication.h" #include "PianoRoll.h" #include "TrackContainer.h" #include "RenameDialog.h" @@ -170,9 +170,9 @@ MidiTime Pattern::beatPatternLength() const Note * Pattern::addNote( const Note & _new_note, const bool _quant_pos ) { Note * new_note = new Note( _new_note ); - if( _quant_pos && Engine::pianoRoll() ) + if( _quant_pos && gui->pianoRoll() ) { - new_note->quantizePos( Engine::pianoRoll()->quantization() ); + new_note->quantizePos( gui->pianoRoll()->quantization() ); } instrumentTrack()->lock(); @@ -539,9 +539,9 @@ void Pattern::updateBBTrack() Engine::getBBTrackContainer()->updateBBTrack( this ); } - if( Engine::pianoRoll() && Engine::pianoRoll()->currentPattern() == this ) + if( gui->pianoRoll() && gui->pianoRoll()->currentPattern() == this ) { - Engine::pianoRoll()->update(); + gui->pianoRoll()->update(); } } @@ -607,7 +607,7 @@ PatternView::PatternView( Pattern* pattern, TrackView* parent ) : m_paintPixmap(), m_needsUpdate( true ) { - connect( Engine::pianoRoll(), SIGNAL( currentPatternChanged() ), + connect( gui->pianoRoll(), SIGNAL( currentPatternChanged() ), this, SLOT( update() ) ); if( s_stepBtnOn == NULL ) @@ -668,10 +668,10 @@ void PatternView::update() void PatternView::openInPianoRoll() { - Engine::pianoRoll()->setCurrentPattern( m_pat ); - Engine::pianoRoll()->parentWidget()->show(); - Engine::pianoRoll()->show(); - Engine::pianoRoll()->setFocus(); + gui->pianoRoll()->setCurrentPattern( m_pat ); + gui->pianoRoll()->parentWidget()->show(); + gui->pianoRoll()->show(); + gui->pianoRoll()->setFocus(); } @@ -802,9 +802,9 @@ void PatternView::mousePressEvent( QMouseEvent * _me ) Engine::getSong()->setModified(); update(); - if( Engine::pianoRoll()->currentPattern() == m_pat ) + if( gui->pianoRoll()->currentPattern() == m_pat ) { - Engine::pianoRoll()->update(); + gui->pianoRoll()->update(); } } else @@ -863,9 +863,9 @@ void PatternView::wheelEvent( QWheelEvent * _we ) Engine::getSong()->setModified(); update(); - if( Engine::pianoRoll()->currentPattern() == m_pat ) + if( gui->pianoRoll()->currentPattern() == m_pat ) { - Engine::pianoRoll()->update(); + gui->pianoRoll()->update(); } } _we->accept(); @@ -925,7 +925,7 @@ void PatternView::paintEvent( QPaintEvent * ) } p.setBrush( lingrad ); - if( Engine::pianoRoll()->currentPattern() == m_pat && m_pat->m_patternType != Pattern::BeatPattern ) + if( gui->pianoRoll()->currentPattern() == m_pat && m_pat->m_patternType != Pattern::BeatPattern ) p.setPen( c.lighter( 130 ) ); else p.setPen( c.darker( 300 ) ); @@ -934,7 +934,7 @@ void PatternView::paintEvent( QPaintEvent * ) p.setBrush( QBrush() ); if( m_pat->m_patternType != Pattern::BeatPattern ) { - if( Engine::pianoRoll()->currentPattern() == m_pat ) + if( gui->pianoRoll()->currentPattern() == m_pat ) p.setPen( c.lighter( 160 ) ); else p.setPen( c.lighter( 130 ) ); diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 49d59f66c..4312fd1e2 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -44,6 +44,7 @@ #include "StringPairDrag.h" #include "Knob.h" #include "MainWindow.h" +#include "GuiApplication.h" #include "EffectRackView.h" #include "TrackLabelButton.h" #include "ConfigManager.h" @@ -553,7 +554,7 @@ SampleTrackView::SampleTrackView( SampleTrack * _t, TrackContainerView* tcv ) : m_effectRack = new EffectRackView( _t->audioPort()->effects() ); m_effectRack->setFixedSize( 240, 242 ); - m_effWindow = Engine::mainWindow()->workspace()->addSubWindow( m_effectRack ); + m_effWindow = gui->mainWindow()->workspace()->addSubWindow( m_effectRack ); m_effWindow->setAttribute( Qt::WA_DeleteOnClose, false ); m_effWindow->layout()->setSizeConstraint( QLayout::SetFixedSize ); m_effWindow->setWindowTitle( _t->name() ); From 0df3998f956978a2d63490f63555cc810ddbf233 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Tue, 6 Jan 2015 15:59:15 +0100 Subject: [PATCH 29/32] Move some gui initialization to GuiApplication's constructor --- src/core/main.cpp | 21 --------------------- src/gui/GuiApplication.cpp | 29 ++++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/core/main.cpp b/src/core/main.cpp index 369a580db..cfa7ae5d0 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -419,26 +419,6 @@ int main( int argc, char * * argv ) if( render_out.isEmpty() ) { - // init style and palette - LmmsStyle * lmmsstyle = new LmmsStyle(); - QApplication::setStyle( lmmsstyle ); - - LmmsPalette * lmmspal = new LmmsPalette( NULL, lmmsstyle ); - QPalette lpal = lmmspal->palette(); - - QApplication::setPalette( lpal ); - LmmsStyle::s_palette = &lpal; - - - // show splash screen - QSplashScreen splashScreen( embed::getIconPixmap( "splash" ) ); - splashScreen.show(); - splashScreen.showMessage( MainWindow::tr( "Version %1" ).arg( LMMS_VERSION ), - Qt::AlignRight | Qt::AlignBottom, Qt::white ); - qApp->processEvents(); - - // init central engine which handles all components of LMMS - Engine::init(false); new GuiApplication(); // re-intialize RNG - shared libraries might have srand() or @@ -501,7 +481,6 @@ int main( int argc, char * * argv ) } } - splashScreen.finish(gui->mainWindow()); } else { diff --git a/src/gui/GuiApplication.cpp b/src/gui/GuiApplication.cpp index ef62b2b57..5801e52f6 100644 --- a/src/gui/GuiApplication.cpp +++ b/src/gui/GuiApplication.cpp @@ -24,6 +24,11 @@ #include "GuiApplication.h" +#include "lmmsversion.h" + +#include "LmmsStyle.h" +#include "LmmsPalette.h" + #include "AutomationEditor.h" #include "BBEditor.h" #include "ControllerRackView.h" @@ -34,7 +39,8 @@ #include "ProjectNotes.h" #include "SongEditor.h" -#include "QApplication" +#include +#include GuiApplication* GuiApplication::s_instance = nullptr; @@ -47,6 +53,26 @@ GuiApplication::GuiApplication() { s_instance = this; + // Init style and palette + LmmsStyle* lmmsstyle = new LmmsStyle(); + QApplication::setStyle(lmmsstyle); + + LmmsPalette* lmmspal = new LmmsPalette(nullptr, lmmsstyle); + QPalette* lpal = new QPalette(lmmspal->palette()); + + QApplication::setPalette( *lpal ); + LmmsStyle::s_palette = lpal; + + // Show splash screen + QSplashScreen splashScreen( embed::getIconPixmap( "splash" ) ); + splashScreen.show(); + splashScreen.showMessage( MainWindow::tr( "Version %1" ).arg( LMMS_VERSION ), + Qt::AlignRight | Qt::AlignBottom, Qt::white ); + qApp->processEvents(); + + // Init central engine which handles all components of LMMS + Engine::init(false); + m_mainWindow = new MainWindow; m_songEditor = new SongEditorWindow(Engine::getSong()); @@ -58,6 +84,7 @@ GuiApplication::GuiApplication() m_automationEditor = new AutomationEditorWindow; m_mainWindow->finalize(); + splashScreen.finish(m_mainWindow); Engine::s_hasGUI = true; } From 0c4833ca4a007187a807b3eb5e3d187bf158e79a Mon Sep 17 00:00:00 2001 From: Lukas W Date: Tue, 6 Jan 2015 23:40:14 +0100 Subject: [PATCH 30/32] Adjust automation editor flip implementation --- include/AutomationEditor.h | 7 ++-- include/AutomationPattern.h | 1 + src/core/AutomationPattern.cpp | 8 +++++ src/gui/editors/AutomationEditor.cpp | 50 +++++++++++----------------- 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index a96c8ae71..64cfeb718 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -131,9 +131,6 @@ protected slots: void setEditMode(AutomationEditor::EditModes mode); void setEditMode(int mode); - void flipYButtonPressed(); - void flipXButtonPressed(); - void setProgressionType(AutomationPattern::ProgressionTypes type); void setProgressionType(int type); void setTension(); @@ -286,8 +283,8 @@ private: QAction* m_linearAction; QAction* m_cubicHermiteAction; - ToolButton * m_flipYButton; - ToolButton * m_flipXButton; + QAction* m_flipYAction; + QAction* m_flipXAction; Knob * m_tensionKnob; diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index 231b73836..5257cecab 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -159,6 +159,7 @@ public slots: void clear(); void objectDestroyed( jo_id_t ); void flipY( int min, int max ); + void flipY(); void flipX( int length = -1 ); private: diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 7564a46f0..ac69b6539 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -408,6 +408,14 @@ void AutomationPattern::flipY( int min, int max ) +void AutomationPattern::flipY() +{ + flipY(getMin(), getMax()); +} + + + + void AutomationPattern::flipX( int length ) { timeMap tempMap; diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 897acfbff..57f0bae86 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -1645,21 +1645,6 @@ void AutomationEditor::setEditMode(AutomationEditor::EditModes mode) -void AutomationEditor::flipYButtonPressed() -{ - m_pattern->flipY( m_minLevel, m_maxLevel ); -} - - - - -void AutomationEditor::flipXButtonPressed() -{ - m_pattern->flipX(); -} - - - void AutomationEditor::setEditMode(int mode) { setEditMode((AutomationEditor::EditModes) mode); @@ -2036,20 +2021,13 @@ AutomationEditorWindow::AutomationEditorWindow() : QAction* eraseAction = editModeGroup->addAction(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); - m_flipYButton = new ToolButton( embed::getIconPixmap( "flip_y" ), - tr( "Flip Vertically" ), - m_editor, SLOT( flipYButtonPressed() ), - m_toolBar ); + m_flipYAction = new QAction(embed::getIconPixmap("flip_y"), tr("Flip vertically"), this); + m_flipXAction = new QAction(embed::getIconPixmap("flip_x"), tr("Flip horizontally"), this); - m_flipXButton = new ToolButton( embed::getIconPixmap( "flip_x" ), - tr( "Flip Horizontally" ), - m_editor, SLOT( flipXButtonPressed() ), - m_toolBar ); - - m_flipYButton->setWhatsThis( + m_flipYAction->setWhatsThis( tr( "Click here and the pattern will be inverted." "The points are flipped in the y direction. " ) ); - m_flipXButton->setWhatsThis( + m_flipXAction->setWhatsThis( tr( "Click here and the pattern will be reversed. " "The points are flipped in the x direction." ) ); @@ -2208,8 +2186,8 @@ AutomationEditorWindow::AutomationEditorWindow() : m_toolBar->addAction(eraseAction); // m_toolBar->addAction(m_selectButton); // m_toolBar->addAction(m_moveButton); - m_toolBar->addWidget(m_flipXButton); - m_toolBar->addWidget(m_flipYButton); + m_toolBar->addAction(m_flipXAction); + m_toolBar->addAction(m_flipYAction); m_toolBar->addSeparator(); m_toolBar->addAction(m_discreteAction); m_toolBar->addAction(m_linearAction); @@ -2251,13 +2229,17 @@ AutomationEditorWindow::~AutomationEditorWindow() void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern) { + // Disconnect our old pattern if (currentPattern() != nullptr) { m_editor->m_pattern->disconnect(this); + m_flipXAction->disconnect(); + m_flipYAction->disconnect(); } m_editor->setCurrentPattern(pattern); + // Set our window's title if (pattern == nullptr) { setWindowTitle( tr( "Automation Editor - no pattern" ) ); @@ -2266,6 +2248,7 @@ void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern) setWindowTitle( tr( "Automation Editor - %1" ).arg( m_editor->m_pattern->name() ) ); + switch(m_editor->m_pattern->progressionType()) { case AutomationPattern::DiscreteProgression: @@ -2279,8 +2262,15 @@ void AutomationEditorWindow::setCurrentPattern(AutomationPattern* pattern) break; } - connect(pattern, SIGNAL(dataChanged()), this, SLOT(update())); - connect(pattern, SIGNAL(destroyed()), this, SLOT(clearCurrentPattern())); + // Connect new pattern + if (pattern) + { + connect(pattern, SIGNAL(dataChanged()), this, SLOT(update())); + connect(pattern, SIGNAL(destroyed()), this, SLOT(clearCurrentPattern())); + + connect(m_flipXAction, SIGNAL(triggered()), pattern, SLOT(flipX())); + connect(m_flipYAction, SIGNAL(triggered()), pattern, SLOT(flipY())); + } emit currentPatternChanged(); } From e0dbfa696ed9f96e27c15c291b167af025e697e9 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Wed, 7 Jan 2015 00:22:40 +0100 Subject: [PATCH 31/32] Remove Engine's has_gui option --- include/Engine.h | 12 ++++-------- src/core/Engine.cpp | 12 ++++++++---- src/core/main.cpp | 2 +- src/gui/GuiApplication.cpp | 9 ++++----- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/include/Engine.h b/include/Engine.h index 322f109c9..5106222dc 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -53,13 +53,10 @@ class ControllerRackView; class EXPORT Engine { public: - static void init( const bool _has_gui = true ); + static void init(); static void destroy(); - static bool hasGUI() - { - return s_hasGUI; - } + static bool hasGUI(); static void setSuppressMessages( bool _on ) { @@ -68,7 +65,7 @@ public: static bool suppressMessages() { - return !s_hasGUI || s_suppressMessages; + return !hasGUI() || s_suppressMessages; } // core @@ -130,7 +127,6 @@ private: delete tmp; } - static bool s_hasGUI; static bool s_suppressMessages; static float s_framesPerTick; @@ -149,7 +145,7 @@ private: static void initPluginFileHandling(); friend class GuiApplication; -} ; +}; diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index e569e612e..cbe826bed 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -38,8 +38,9 @@ #include "Song.h" #include "BandLimitedWave.h" +#include "GuiApplication.h" + -bool Engine::s_hasGUI = true; bool Engine::s_suppressMessages = false; float Engine::s_framesPerTick; Mixer* Engine::s_mixer = NULL; @@ -54,10 +55,8 @@ QMap Engine::s_pluginFileHandling; -void Engine::init( const bool _has_gui ) +void Engine::init() { - s_hasGUI = _has_gui; - // generate (load from file) bandlimited wavetables BandLimitedWave::generateWaves(); @@ -109,6 +108,11 @@ void Engine::destroy() delete ConfigManager::inst(); } +bool Engine::hasGUI() +{ + return gui != nullptr; +} + diff --git a/src/core/main.cpp b/src/core/main.cpp index cfa7ae5d0..d3f98d909 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -485,7 +485,7 @@ int main( int argc, char * * argv ) else { // we're going to render our song - Engine::init( false ); + Engine::init(); printf( "loading project...\n" ); Engine::getSong()->loadProject( file_to_load ); diff --git a/src/gui/GuiApplication.cpp b/src/gui/GuiApplication.cpp index 5801e52f6..78cf609ef 100644 --- a/src/gui/GuiApplication.cpp +++ b/src/gui/GuiApplication.cpp @@ -51,8 +51,6 @@ GuiApplication* GuiApplication::instance() GuiApplication::GuiApplication() { - s_instance = this; - // Init style and palette LmmsStyle* lmmsstyle = new LmmsStyle(); QApplication::setStyle(lmmsstyle); @@ -71,7 +69,9 @@ GuiApplication::GuiApplication() qApp->processEvents(); // Init central engine which handles all components of LMMS - Engine::init(false); + Engine::init(); + + s_instance = this; m_mainWindow = new MainWindow; @@ -85,11 +85,10 @@ GuiApplication::GuiApplication() m_mainWindow->finalize(); splashScreen.finish(m_mainWindow); - - Engine::s_hasGUI = true; } GuiApplication::~GuiApplication() { InstrumentTrackView::cleanupWindowCache(); + s_instance = nullptr; } From 23dbe95e80b2386be1f3f7d08d8942d2f717b585 Mon Sep 17 00:00:00 2001 From: Lukas W Date: Sun, 11 Jan 2015 13:05:44 +0100 Subject: [PATCH 32/32] Stop on second space key press --- include/Editor.h | 4 ++++ src/gui/editors/Editor.cpp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/Editor.h b/include/Editor.h index 1070aa649..e4da281dc 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -48,6 +48,10 @@ protected slots: virtual void recordAccompany() {} virtual void stop() {} +private slots: + /// Called by pressing the space key. Plays or stops. + void togglePlayStop(); + signals: protected: diff --git a/src/gui/editors/Editor.cpp b/src/gui/editors/Editor.cpp index 8594f1b95..985d22f40 100644 --- a/src/gui/editors/Editor.cpp +++ b/src/gui/editors/Editor.cpp @@ -30,6 +30,7 @@ #include #include #include +#include void Editor::setPauseIcon(bool displayPauseIcon) @@ -41,6 +42,14 @@ void Editor::setPauseIcon(bool displayPauseIcon) m_playAction->setIcon(embed::getIconPixmap("play")); } +void Editor::togglePlayStop() +{ + if (Engine::getSong()->isPlaying()) + stop(); + else + play(); +} + Editor::Editor(bool record) : m_toolBar(new QToolBar(this)), m_playAction(nullptr), @@ -63,13 +72,12 @@ Editor::Editor(bool record) : m_recordAction = new QAction(embed::getIconPixmap("record"), tr("Record"), this); m_recordAccompanyAction = new QAction(embed::getIconPixmap("record_accompany"), tr("Record while playing"), this); - m_playAction->setShortcut(Qt::Key_Space); - // Set up connections connect(m_playAction, SIGNAL(triggered()), this, SLOT(play())); connect(m_recordAction, SIGNAL(triggered()), this, SLOT(record())); connect(m_recordAccompanyAction, SIGNAL(triggered()), this, SLOT(recordAccompany())); connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stop())); + new QShortcut(Qt::Key_Space, this, SLOT(togglePlayStop())); // Add toolbar to window addToolBar(Qt::TopToolBarArea, m_toolBar);