diff --git a/data/themes/default/style.css b/data/themes/default/style.css index a95abb793d5..03d9212fabd 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; +} + +QToolBar::separator { + border: none; + width: 5px; } -QToolButton, ToolButton { +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; diff --git a/include/AboutDialog.h b/include/AboutDialog.h index 788dc7a118e..c07ef6d7097 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/ActionGroup.h b/include/ActionGroup.h new file mode 100644 index 00000000000..9928e8906c3 --- /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 fe46c9af081..64cfeb718b8 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,58 +38,60 @@ #include "ComboBoxModel.h" #include "Knob.h" - class QPainter; class QPixmap; class QScrollBar; class ComboBox; class NotePlayHandle; -class Timeline; -class ToolButton; +class TimeLineWidget; + 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 ); - inline virtual QString nodeName() const + virtual void saveSettings(QDomDocument & doc, QDomElement & parent); + virtual void loadSettings(const QDomElement & parent); + QString nodeName() const { - return( "automationeditor" ); + return "automationeditor"; } - void setPauseIcon( bool pause ); - // qproperty access methods QColor gridColor() const; 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 + { + DRAW, + ERASE, + SELECT, + MOVE + }; public slots: void update(); @@ -97,69 +101,56 @@ 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 ); - 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 ); - - float getLevel( int _y ); - int xCoordOfTick( int _tick ); - int yCoordOfLevel( float _level ); - inline void drawLevelTick( QPainter & _p, int _tick, - float _value, bool _is_selected ); + 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 ); void removeSelection(); void selectAll(); - void getSelectedValues( timeMap & _selected_values ); + void getSelectedValues(timeMap & selected_values ); void drawLine( int x0, float y0, int x1, float y1 ); - void disableTensionKnob(); 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 drawButtonToggled(); - void eraseButtonToggled(); - void selectButtonToggled(); - void moveButtonToggled(); - void flipYButtonPressed(); - void flipXButtonPressed(); + void setEditMode(AutomationEditor::EditModes mode); + void setEditMode(int mode); - void discreteButtonToggled(); - void linearButtonToggled(); - void cubicHermiteButtonToggled(); - void tensionChanged(); + void setProgressionType(AutomationPattern::ProgressionTypes type); + void setProgressionType(int type); + void setTension(); void copySelectedValues(); void cutSelectedValues(); void pasteValues(); void deleteSelectedValues(); - void updatePosition( const MidiTime & _t ); + void updatePosition( const MidiTime & t ); void zoomingXChanged(); void zoomingYChanged(); + /// Updates the pattern's quantization using the current user selected value. + void setQuantization(); private: - enum editModes - { - DRAW, - ERASE, - SELECT, - MOVE - } ; - - enum actions + enum Actions { NONE, MOVE_VALUE, @@ -168,11 +159,8 @@ protected slots: } ; // 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; @@ -184,7 +172,6 @@ protected slots: AutomationEditor( const AutomationEditor & ); virtual ~AutomationEditor(); - static QPixmap * s_toolDraw; static QPixmap * s_toolErase; static QPixmap * s_toolSelect; @@ -192,37 +179,12 @@ protected slots: static QPixmap * s_toolYFlip; static QPixmap * s_toolXFlip; - - QWidget * m_toolBar; - - ToolButton * m_playButton; - ToolButton * m_stopButton; - - ToolButton * m_drawButton; - ToolButton * m_eraseButton; - ToolButton * m_selectButton; - ToolButton * m_moveButton; - ToolButton * m_flipYButton; - ToolButton * m_flipXButton; - - 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; @@ -239,7 +201,7 @@ protected slots: MidiTime m_currentPosition; - actions m_action; + Actions m_action; tick_t m_selectStartTick; tick_t m_selectedTick; @@ -261,13 +223,13 @@ protected slots: timeMap m_selValuesForMove; - editModes m_editMode; + EditModes m_editMode; - Timeline * m_timeLine; + TimeLineWidget * m_timeLine; bool m_scrollBack; - void drawCross( QPainter & _p ); + void drawCross(QPainter & p ); void drawAutomationPoint( QPainter & p, timeMap::iterator it ); bool inBBEditor(); @@ -276,14 +238,62 @@ protected slots: 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(); + + void open(AutomationPattern* pattern); + + AutomationEditor* m_editor; + + QSize sizeHint() const; + +public slots: + void clearCurrentPattern(); + +signals: + void currentPatternChanged(); + +protected slots: + void play(); + void stop(); + +private: + QAction* m_discreteAction; + QAction* m_linearAction; + QAction* m_cubicHermiteAction; + + QAction* m_flipYAction; + QAction* m_flipXAction; + + Knob * m_tensionKnob; + + ComboBox * m_zoomingXComboBox; + ComboBox * m_zoomingYComboBox; + ComboBox * m_quantizeComboBox; + + friend class Engine; +}; + + #endif diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index d95b6f3d268..5257cecabc8 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -136,15 +136,8 @@ class EXPORT AutomationPattern : public TrackContentObject 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,21 +149,17 @@ class EXPORT AutomationPattern : public TrackContentObject 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 ); void flipY( int min, int max ); + void flipY(); void flipX( int length = -1 ); private: @@ -194,6 +183,8 @@ public slots: 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/BBEditor.h b/include/BBEditor.h index e1a286ac343..abd325bc229 100644 --- a/include/BBEditor.h +++ b/include/BBEditor.h @@ -26,56 +26,72 @@ #ifndef BB_EDITOR_H #define BB_EDITOR_H +#include "Editor.h" #include "TrackContainerView.h" 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 ); - } - - virtual void dropEvent( QDropEvent * _de ); + QSize sizeHint() const; - void removeBBView( int _bb ); - - void setPauseIcon( bool pause ); + const BBTrackContainerView* trackContainerView() const { + return m_trackContainerView; + } + BBTrackContainerView* trackContainerView() { + return m_trackContainerView; + } + void removeBBView( int bb ); public slots: void play(); void stop(); - void updatePosition(); - void addAutomationTrack(); - void addSteps(); - void removeSteps(); protected: virtual void closeEvent( QCloseEvent * _ce ); private: - virtual void keyPressEvent( QKeyEvent * _ke ); + BBTrackContainerView* m_trackContainerView; + ComboBox * m_bbComboBox; +} ; - BBTrackContainer * m_bbtc; - QWidget * m_toolBar; - ToolButton * m_playButton; - ToolButton * m_stopButton; - 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 fdfe12bf36c..0c348e53b2f 100644 --- a/include/ComboBox.h +++ b/include/ComboBox.h @@ -53,6 +53,10 @@ class EXPORT ComboBox : public QWidget, public IntModelView virtual QSize sizeHint() const; +public slots: + void selectNext(); + void selectPrevious(); + protected: virtual void contextMenuEvent( QContextMenuEvent* event ); diff --git a/include/Editor.h b/include/Editor.h new file mode 100644 index 00000000000..e4da281dcb0 --- /dev/null +++ b/include/Editor.h @@ -0,0 +1,75 @@ +/* + * 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 + +#include "TimeLineWidget.h" +#include "ToolButton.h" + +/// \brief Superclass for editors with a toolbar. +/// +/// Those editors include the Song Editor, the Automation Editor, B&B Editor, +/// and the Piano Roll. +class Editor : public QMainWindow +{ + Q_OBJECT +public: + void setPauseIcon(bool displayPauseIcon=true); + +protected slots: + virtual void play() {} + virtual void record() {} + virtual void recordAccompany() {} + virtual void stop() {} + +private slots: + /// Called by pressing the space key. Plays or stops. + void togglePlayStop(); + +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; + + QAction* m_playAction; + QAction* m_recordAction; + QAction* m_recordAccompanyAction; + QAction* m_stopAction; +}; + + +#endif diff --git a/include/Engine.h b/include/Engine.h index b7839f817ab..5106222dca5 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; @@ -42,10 +42,10 @@ class FxMixerView; class ProjectJournal; class MainWindow; class Mixer; -class PianoRoll; +class PianoRollWindow; class ProjectNotes; class Song; -class SongEditor; +class SongEditorWindow; class Ladspa2LMMS; class ControllerRackView; @@ -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 @@ class EXPORT Engine static bool suppressMessages() { - return !s_hasGUI || s_suppressMessages; + return !hasGUI() || s_suppressMessages; } // core @@ -97,42 +94,6 @@ class EXPORT Engine return s_projectJournal; } - // GUI - static MainWindow * mainWindow() - { - return s_mainWindow; - } - - static FxMixerView * fxMixerView() - { - return s_fxMixerView; - } - - static SongEditor* songEditor() - { - return s_songEditor; - } - - static BBEditor * getBBEditor() - { - return s_bbEditor; - } - - static PianoRoll* pianoRoll() - { - return s_pianoRoll; - } - - static ProjectNotes * getProjectNotes() - { - return s_projectNotes; - } - - static AutomationEditor * automationEditor() - { - return s_automationEditor; - } - static Ladspa2LMMS * getLADSPAManager() { return s_ladspaManager; @@ -143,11 +104,6 @@ class EXPORT Engine return s_dummyTC; } - static ControllerRackView * getControllerRackView() - { - return s_controllerRackView; - } - static float framesPerTick() { return s_framesPerTick; @@ -171,7 +127,6 @@ class EXPORT Engine delete tmp; } - static bool s_hasGUI; static bool s_suppressMessages; static float s_framesPerTick; @@ -182,23 +137,15 @@ class EXPORT Engine static BBTrackContainer * s_bbTrackContainer; static ProjectJournal * s_projectJournal; static DummyTrackContainer * s_dummyTC; - static ControllerRackView * s_controllerRackView; - - // GUI - static MainWindow * s_mainWindow; - static FxMixerView * s_fxMixerView; - static SongEditor* s_songEditor; - static AutomationEditor * s_automationEditor; - static BBEditor * s_bbEditor; - static PianoRoll* 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 00000000000..c35994e8162 --- /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 dd12c05a749..d02b68494f9 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -180,7 +180,7 @@ public slots: QList* m_errors; - friend class Engine; + friend class GuiApplication; private slots: diff --git a/include/Note.h b/include/Note.h index d179ba9394d..d5cc0363e44 100644 --- a/include/Note.h +++ b/include/Note.h @@ -202,11 +202,10 @@ class EXPORT Note : public SerializingObject { return m_detuning; } - - void editDetuningPattern(); - bool hasDetuningInfo() const; + void createDetuning(); + protected: virtual void saveSettings( QDomDocument & _doc, @@ -228,10 +227,7 @@ class EXPORT Note : public SerializingObject MidiTime m_length; MidiTime m_pos; DetuningHelper * m_detuning; - - void createDetuning(); - -} ; +}; typedef QVector NoteVector; diff --git a/include/Pattern.h b/include/Pattern.h index 163b3429bc0..840926f5184 100644 --- a/include/Pattern.h +++ b/include/Pattern.h @@ -138,7 +138,7 @@ protected slots: int m_steps; friend class PatternView; - friend class BBEditor; + friend class BBTrackContainerView; signals: diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 84a8ffee856..bc2a0d8cb1b 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" @@ -47,10 +48,9 @@ class QSignalMapper; class ComboBox; class NotePlayHandle; class Pattern; -class Timeline; -class ToolButton; +class TimeLineWidget; -class PianoRoll : public QWidget, public SerializingObject +class PianoRoll : public QWidget { Q_OBJECT Q_PROPERTY( QColor gridColor READ gridColor WRITE setGridColor ) @@ -58,6 +58,14 @@ class PianoRoll : public QWidget, public SerializingObject 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(); @@ -86,47 +94,36 @@ class PianoRoll : public QWidget, public SerializingObject 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; - 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 closeEvent( QCloseEvent * _ce ); - 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 ); + 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 ); 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 ); @@ -137,24 +134,21 @@ 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 drawButtonToggled(); - void eraseButtonToggled(); - void selectButtonToggled(); - void detuneButtonToggled(); + void setEditMode(int mode); void copySelectedNotes(); void cutSelectedNotes(); 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(); @@ -174,15 +168,7 @@ protected slots: private: - enum editModes - { - ModeDraw, - ModeErase, - ModeSelect, - ModeEditDetuning, - }; - - enum actions + enum Actions { ActionNone, ActionMoveNote, @@ -192,14 +178,14 @@ protected slots: ActionResizeNoteEditArea }; - enum noteEditMode + enum NoteEditMode { NoteEditVolume, NoteEditPanning, NoteEditCount // make sure this one is always last }; - enum semiToneMarkerAction + enum SemiToneMarkerAction { stmaUnmarkAll, stmaMarkCurrentSemiTone, @@ -224,7 +210,7 @@ protected slots: PianoRoll( const PianoRoll & ); virtual ~PianoRoll(); - void autoScroll( const MidiTime & _t ); + void autoScroll(const MidiTime & t ); MidiTime newNoteLen() const; @@ -234,7 +220,7 @@ protected slots: 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; @@ -264,28 +250,6 @@ protected slots: 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 +257,6 @@ protected slots: ComboBoxModel m_chordModel; - Pattern* m_pattern; QScrollBar * m_leftRightScroll; QScrollBar * m_topBottomScroll; @@ -303,8 +266,8 @@ protected slots: QList m_recordingNotes; Note * m_currentNote; - actions m_action; - noteEditMode m_noteEditMode; + Actions m_action; + NoteEditMode m_noteEditMode; int m_selectStartTick; int m_selectedTick; @@ -344,16 +307,16 @@ protected slots: 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 - Timeline * m_timeLine; + 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(); @@ -367,6 +330,7 @@ protected slots: bool m_startedWithShift; friend class Engine; + friend class PianoRollWindow; // qproperty fields QColor m_gridColor; @@ -380,5 +344,54 @@ protected slots: } ; +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"; + } + + QSize sizeHint() const; + +signals: + void currentPatternChanged(); + +private: + PianoRoll* m_editor; + + ComboBox * m_zoomingComboBox; + ComboBox * m_quantizeComboBox; + ComboBox * m_noteLenComboBox; + ComboBox * m_scaleComboBox; + ComboBox * m_chordComboBox; + +}; + + #endif diff --git a/include/Song.h b/include/Song.h index ee5f594d92f..90f29cf24c1 100644 --- a/include/Song.h +++ b/include/Song.h @@ -37,7 +37,7 @@ class AutomationTrack; class Pattern; -class Timeline; +class TimeLineWidget; const bpm_t MinTempo = 10; @@ -84,7 +84,7 @@ class EXPORT Song : public TrackContainer { return m_currentFrame; } - Timeline * m_timeLine; + TimeLineWidget * m_timeLine; bool m_timeLineUpdate; private: diff --git a/include/SongEditor.h b/include/SongEditor.h index 96dcfdfd256..9b2e6cd9402 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,12 +35,12 @@ class QScrollBar; class AutomatableSlider; class ComboBox; +class ComboBoxModel; class LcdSpinBox; class MeterDialog; class Song; class TextFloat; -class Timeline; -class ToolButton; +class TimeLineWidget; class positionLine : public QWidget { @@ -56,34 +57,37 @@ class SongEditor : public TrackContainerView { Q_OBJECT public: - SongEditor( Song * _song ); - virtual ~SongEditor(); - - void setPauseIcon( bool pause ); + enum EditMode + { + DrawMode, + SelectMode + }; + SongEditor( Song * _song ); + ~SongEditor(); public slots: void scrolled( int _new_pos ); + void setEditMode(EditMode mode); + void setEditModeDraw(); + void setEditModeSelect(); + protected: virtual void closeEvent( QCloseEvent * _ce ); private slots: void setHighQuality( bool ); - void play(); - void record(); - void recordAccompany(); - void stop(); + void setMasterVolume( int _new_val ); + void showMasterVolumeFloat(); + void updateMasterVolumeFloat( int _new_val ); + void hideMasterVolumeFloat(); - 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 setMasterPitch( int _new_val ); + void showMasterPitchFloat(); + void updateMasterPitchFloat( int _new_val ); + void hideMasterPitchFloat(); void updateScrollBar( int ); void updatePosition( const MidiTime & _t ); @@ -104,15 +108,9 @@ private slots: QScrollBar * m_leftRightScroll; - QWidget * m_toolBar; - - ToolButton * m_playButton; - ToolButton * m_recordButton; - ToolButton * m_recordAccompanyButton; - ToolButton * m_stopButton; LcdSpinBox * m_tempoSpinBox; - Timeline * m_timeLine; + TimeLineWidget * m_timeLine; MeterDialog * m_timeSigDisplay; AutomatableSlider * m_masterVolumeSlider; @@ -121,22 +119,44 @@ private slots: TextFloat * m_mvsStatus; TextFloat * m_mpsStatus; - ToolButton * m_addBBTrackButton; - ToolButton * m_addSampleTrackButton; - ToolButton * m_addAutomationTrackButton; - - ToolButton * m_drawModeButton; - ToolButton * m_editModeButton; - - ComboBox * m_zoomingComboBox; - positionLine * m_positionLine; + ComboBoxModel* m_zoomingModel; + bool m_scrollBack; bool m_smoothScroll; + EditMode m_mode; + + friend class SongEditorWindow; + } ; +class SongEditorWindow : public Editor +{ + Q_OBJECT +public: + SongEditorWindow(Song* song); + + QSize sizeHint() const; + + SongEditor* m_editor; +protected slots: + void play(); + void record(); + void recordAccompany(); + void stop(); + +private: + QAction* m_addBBTrackAction; + QAction* m_addSampleTrackAction; + QAction* m_addAutomationTrackAction; + + QAction* m_drawModeAction; + QAction* m_selectModeAction; + + ComboBox * m_zoomingComboBox; +}; #endif diff --git a/include/Timeline.h b/include/TimeLineWidget.h similarity index 92% rename from include/Timeline.h rename to include/TimeLineWidget.h index 78dc00ddc2d..abf622aaf09 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 * @@ -32,11 +32,12 @@ class QPixmap; +class QToolBar; class NStateButton; class TextFloat; -class Timeline : public QWidget, public JournallingObject +class TimeLineWidget : public QWidget, public JournallingObject { Q_OBJECT public: @@ -60,9 +61,9 @@ class Timeline : public QWidget, public JournallingObject } ; - 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() { @@ -111,7 +112,7 @@ class Timeline : public QWidget, public JournallingObject update(); } - void addToolButtons( QWidget * _tool_bar ); + void addToolButtons(QToolBar* _tool_bar ); virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); diff --git a/include/ToolButton.h b/include/ToolButton.h index 7e1183e14d1..27365d69dbb 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/plugins/Eq/EqFader.h b/plugins/Eq/EqFader.h index 9ef7f80c3e6..0e1ae986aa7 100644 --- a/plugins/Eq/EqFader.h +++ b/plugins/Eq/EqFader.h @@ -26,6 +26,7 @@ #include "Fader.h" #include "EffectControls.h" #include "MainWindow.h" +#include "GuiApplication.h" #include "qwidget.h" #include "TextFloat.h" #include "qlist.h" @@ -46,7 +47,7 @@ class EqFader : public Fader resize( 23, 116 ); m_lPeak = lPeak; m_rPeak = rPeak; - connect( Engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( updateVuMeters() ) ); + connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( updateVuMeters() ) ); m_model = model; setPeak_L( 0 ); setPeak_R( 0 ); diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index 853decb32df..ec3178d853e 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 42aa5ed86a3..d8b096a3e17 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 @@ class SpectrumView : public QWidget m_background( PLUGIN_NAME::getIconPixmap( "spectrum_background" ).toImage() ) { setFixedSize( 249, 151 ); - connect( Engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) ); + connect( gui->mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) ); setAttribute( Qt::WA_OpaquePaintEvent, true ); } diff --git a/plugins/VstEffect/VstEffectControls.cpp b/plugins/VstEffect/VstEffectControls.cpp index 08f8e28ac50..8f2594c6ac6 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/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index 08ef2885784..2caf210aec7 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -35,6 +35,7 @@ #include "Engine.h" #include "Song.h" #include "MainWindow.h" +#include "GuiApplication.h" #include "InstrumentTrack.h" #include "NotePlayHandle.h" #include "interpolation.h" @@ -241,7 +242,7 @@ void audioFileProcessor::loadSettings( const QDomElement & _this ) { QString message = tr( "Sample not found: %1" ).arg( m_sampleBuffer.audioFile() ); - Engine::mainWindow()->collectError( message ); + gui->mainWindow()->collectError( message ); } } else if( _this.attribute( "sampledata" ) != "" ) diff --git a/plugins/delay/delaycontrols.cpp b/plugins/delay/delaycontrols.cpp index 8653cf21cb5..fd7aaf24040 100644 --- a/plugins/delay/delaycontrols.cpp +++ b/plugins/delay/delaycontrols.cpp @@ -37,7 +37,7 @@ DelayControls::DelayControls( DelayEffect* effect ): m_lfoTimeModel(2.0, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Lfo Frequency" ) ), m_lfoAmountModel(0.0, 0.0, 2.0, 0.0001, 2000.0, this, tr ( "Lfo Amount" ) ) { - connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) ); + connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) ); } diff --git a/plugins/delay/delaycontrolsdialog.cpp b/plugins/delay/delaycontrolsdialog.cpp index 555b6c85260..aae4c0aa479 100644 --- a/plugins/delay/delaycontrolsdialog.cpp +++ b/plugins/delay/delaycontrolsdialog.cpp @@ -46,12 +46,12 @@ DelayControlsDialog::DelayControlsDialog( DelayControls *controls ) : sampleDelayKnob->setLabel( tr( "Delay" ) ); sampleDelayKnob->setHintText( tr( "Delay Time" ) + " ", " s" ); - Knob * feedbackKnob = new Knob( knobBright_26, this ); - feedbackKnob->move( 63,10 ); - feedbackKnob->setVolumeKnob( true) ; - feedbackKnob->setModel( &controls->m_feedbackModel); - feedbackKnob->setLabel( tr( "Regen" ) ); - feedbackKnob->setHintText( tr ( "Feedback Amount" ) + " " , "" ); + Knob * feedbackKnob = new Knob( knobBright_26, this ); + feedbackKnob->move( 63,10 ); + feedbackKnob->setVolumeKnob( true) ; + feedbackKnob->setModel( &controls->m_feedbackModel); + feedbackKnob->setLabel( tr( "Regen" ) ); + feedbackKnob->setHintText( tr ( "Feedback Amount" ) + " " , "" ); TempoSyncKnob * lfoFreqKnob = new TempoSyncKnob( knobBright_26, this ); lfoFreqKnob->move( 106,10 ); diff --git a/plugins/flp_import/FlpImport.cpp b/plugins/flp_import/FlpImport.cpp index 8fc869dfcbc..c23097d2c89 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 f1b9fffd999..4c6870c69b5 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 38b789d130f..954b6196cea 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" @@ -189,7 +189,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; @@ -238,7 +238,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/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 20ab58de9dd..beb11bd2db7 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; @@ -106,11 +103,6 @@ AutomationPattern::AutomationPattern( const AutomationPattern & _pat_to_copy ) : AutomationPattern::~AutomationPattern() { - if( Engine::automationEditor() && - Engine::automationEditor()->currentPattern() == this ) - { - Engine::automationEditor()->setCurrentPattern( NULL ); - } } @@ -213,10 +205,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 ); @@ -246,10 +237,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 ); @@ -286,10 +276,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; @@ -440,9 +429,15 @@ void AutomationPattern::flipY( int min, int max ) } generateTangents(); - Engine::automationEditor()->update(); emit dataChanged(); +} + + + +void AutomationPattern::flipY() +{ + flipY(getMin(), getMax()); } @@ -512,7 +507,6 @@ void AutomationPattern::flipX( int length ) m_timeMap = tempMap; generateTangents(); - Engine::automationEditor()->update(); emit dataChanged(); } @@ -810,22 +804,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()->setFocus(); } diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index d744af1c790..cbe826bedb8 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -24,55 +24,39 @@ #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" +#include "GuiApplication.h" + -bool Engine::s_hasGUI = true; 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; -SongEditor* Engine::s_songEditor = NULL; -AutomationEditor * Engine::s_automationEditor = NULL; -BBEditor * Engine::s_bbEditor = NULL; -PianoRoll* 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; -void Engine::init( const bool _has_gui ) +void Engine::init() { - s_hasGUI = _has_gui; - // generate (load from file) bandlimited wavetables BandLimitedWave::generateWaves(); @@ -90,20 +74,6 @@ void Engine::init( const bool _has_gui ) s_mixer->initDevices(); - if( s_hasGUI ) - { - s_mainWindow = new MainWindow; - s_songEditor = new SongEditor( s_song ); - s_fxMixerView = new FxMixerView; - s_controllerRackView = new ControllerRackView; - s_projectNotes = new ProjectNotes; - s_bbEditor = new BBEditor( s_bbTrackContainer ); - s_pianoRoll = new PianoRoll; - s_automationEditor = new AutomationEditor; - - s_mainWindow->finalize(); - } - PresetPreviewPlayHandle::init(); s_dummyTC = new DummyTrackContainer; @@ -118,15 +88,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,13 +103,16 @@ void Engine::destroy() //delete ConfigManager::inst(); deleteHelper( &s_projectJournal ); - s_mainWindow = NULL; - deleteHelper( &s_song ); delete ConfigManager::inst(); } +bool Engine::hasGUI() +{ + return gui != nullptr; +} + diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 0630b8e4749..b6aff04463c 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/Note.cpp b/src/core/Note.cpp index fca078587e5..937f52ac8b3 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/core/Plugin.cpp b/src/core/Plugin.cpp index 769ed04f281..ebfb62cb14e 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 c4cc905d878..07d55a0dd46 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" @@ -60,7 +62,7 @@ #include "SongEditor.h" #include "templates.h" #include "TextFloat.h" -#include "Timeline.h" +#include "TimeLineWidget.h" #include "PeakController.h" @@ -181,7 +183,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 ) { @@ -248,7 +250,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 ) @@ -586,7 +588,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; @@ -596,12 +598,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() ); @@ -610,7 +612,7 @@ void Song::stop() } break; - case Timeline::KeepStopPosition: + case TimeLineWidget::KeepStopPosition: default: break; } @@ -756,17 +758,17 @@ void Song::clearProject() Engine::mixer()->lock(); - if( Engine::getBBEditor() ) + if( gui->getBBEditor() ) { - Engine::getBBEditor()->clearAllTracks(); + gui->getBBEditor()->trackContainerView()->clearAllTracks(); } - if( Engine::songEditor() ) + if( gui->songEditor() ) { - Engine::songEditor()->clearAllTracks(); + gui->songEditor()->m_editor->clearAllTracks(); } - if( Engine::fxMixerView() ) + if( gui->fxMixerView() ) { - Engine::fxMixerView()->clear(); + gui->fxMixerView()->clear(); } QCoreApplication::sendPostedEvents(); Engine::getBBTrackContainer()->clearAllTracks(); @@ -774,14 +776,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(); @@ -797,9 +799,9 @@ void Song::clearProject() Engine::mixer()->unlock(); - if( Engine::getProjectNotes() ) + if( gui->getProjectNotes() ) { - Engine::getProjectNotes()->clear(); + gui->getProjectNotes()->clear(); } // Move to function @@ -878,9 +880,9 @@ void Song::createNewProject() m_modified = false; - if( Engine::mainWindow() ) + if( gui->mainWindow() ) { - Engine::mainWindow()->resetWindowTitle(); + gui->mainWindow()->resetWindowTitle(); } } @@ -894,9 +896,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(); } } @@ -912,9 +914,9 @@ void Song::loadProject( const QString & _file_name ) m_loadingProject = true; Engine::projectJournal()->setJournalling( false ); - if( Engine::mainWindow() ) + if( gui ) { - Engine::mainWindow()->clearErrors(); + gui->mainWindow()->clearErrors(); } m_fileName = _file_name; @@ -963,7 +965,7 @@ void Song::loadProject( const QString & _file_name ) if( Engine::hasGUI() ) { // refresh FxMixerView - Engine::fxMixerView()->refreshDisplay(); + gui->fxMixerView()->refreshDisplay(); } } @@ -982,21 +984,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()->nodeName() ) + else if( node.nodeName() == gui->automationEditor()->m_editor->nodeName() ) { - Engine::automationEditor()->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() ) { @@ -1027,17 +1029,17 @@ void Song::loadProject( const QString & _file_name ) emit projectLoaded(); - if( Engine::mainWindow() ) + if( gui ) { - 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(); } } @@ -1060,10 +1062,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()->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() ); } @@ -1088,7 +1090,7 @@ bool Song::guiSaveProject() 2000 ); ConfigManager::inst()->addRecentlyOpenedProject( m_fileName ); m_modified = false; - Engine::mainWindow()->resetWindowTitle(); + gui->mainWindow()->resetWindowTitle(); } else if( Engine::hasGUI() ) { @@ -1191,7 +1193,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 " @@ -1199,7 +1201,7 @@ void Song::exportProject(bool multiExport) return; } - FileDialog efd( Engine::mainWindow() ); + FileDialog efd( gui->mainWindow() ); if (multiExport) { efd.setFileMode( FileDialog::Directory); @@ -1259,7 +1261,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(); } } @@ -1280,10 +1282,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 1b5cf1d0e44..ad25f979cdd 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" @@ -1122,7 +1123,7 @@ void TrackContentWidget::update() */ void TrackContentWidget::changePosition( const MidiTime & _new_pos ) { - if( m_trackView->trackContainerView() == Engine::getBBEditor() ) + if( m_trackView->trackContainerView() == gui->getBBEditor()->trackContainerView() ) { const int cur_bb = Engine::getBBTrackContainer()->currentBB(); setUpdatesEnabled( false ); @@ -1459,7 +1460,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() != 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 400113b8872..2cf02e28c37 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 482cc4e2f31..51389898343 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 08042ef89d4..d3f98d90926 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 ) ); @@ -418,28 +419,7 @@ 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(); - - splashScreen.hide(); + new GuiApplication(); // re-intialize RNG - shared libraries might have srand() or // srandom() calls in their init procedure @@ -449,7 +429,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 +440,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 +462,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,17 +474,18 @@ 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(); } } + } else { // we're going to render our song - Engine::init( false ); + Engine::init(); printf( "loading project...\n" ); Engine::getSong()->loadProject( file_to_load ); @@ -536,9 +517,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 5b152e07d48..6d39a8e46c0 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/ActionGroup.cpp b/src/gui/ActionGroup.cpp new file mode 100644 index 00000000000..b0f0dbcd326 --- /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/AutomatableModelView.cpp b/src/gui/AutomatableModelView.cpp index 3a13ed5c72a..453d7e0134d 100644 --- a/src/gui/AutomatableModelView.cpp +++ b/src/gui/AutomatableModelView.cpp @@ -30,9 +30,12 @@ #include "ControllerConnectionDialog.h" #include "ControllerConnection.h" #include "embed.h" +#include "GuiApplication.h" #include "MainWindow.h" #include "StringPairDrag.h" +#include "AutomationEditor.h" + AutomatableModelView::AutomatableModelView( ::Model* model, QWidget* _this ) : @@ -177,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 ) { @@ -224,7 +227,9 @@ void AutomatableModelViewSlots::removeConnection() void AutomatableModelViewSlots::editSongGlobalAutomation() { - AutomationPattern::globalAutomationPattern( m_amv->modelUntyped() )->openInAutomationEditor(); + gui->automationEditor()->open( + AutomationPattern::globalAutomationPattern(m_amv->modelUntyped()) + ); } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index cbea1211e09..34bc81dfee0 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 ); @@ -122,9 +122,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()->updateAfterPatternChange(); + gui->automationEditor()->m_editor->updateAfterPatternChange(); } //if there is no more connection connected to the AutomationPattern @@ -229,7 +229,7 @@ void AutomationPatternView::mouseDoubleClickEvent( QMouseEvent * _me ) _me->ignore(); return; } - m_pat->openInAutomationEditor(); + gui->automationEditor()->open(m_pat); } @@ -273,7 +273,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 ) ); @@ -356,7 +356,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 ) ); @@ -417,10 +417,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 4d0158c321a..dd1586704a4 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" @@ -282,7 +282,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(); } @@ -341,6 +341,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 7a7780a4480..80390293f0b 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 b32183e9ee5..2267cbe8e2e 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 00000000000..78cf609efb6 --- /dev/null +++ b/src/gui/GuiApplication.cpp @@ -0,0 +1,94 @@ +/* + * 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 "lmmsversion.h" + +#include "LmmsStyle.h" +#include "LmmsPalette.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 +#include + +GuiApplication* GuiApplication::s_instance = nullptr; + +GuiApplication* GuiApplication::instance() +{ + return s_instance; +} + +GuiApplication::GuiApplication() +{ + // 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(); + + 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(); + splashScreen.finish(m_mainWindow); +} + +GuiApplication::~GuiApplication() +{ + InstrumentTrackView::cleanupWindowCache(); + s_instance = nullptr; +} diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 13f98d74b67..7211bd2e1fc 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" @@ -530,6 +531,29 @@ void MainWindow::finalize() SetupDialog sd( SetupDialog::AudioSettings ); sd.exec(); } + + // Add editor subwindows + for (QWidget* widget : QList{ + gui->automationEditor(), + gui->getBBEditor(), + gui->pianoRoll(), + gui->songEditor() + }) + { + QMdiSubWindow* window = workspace()->addSubWindow(widget); + window->setWindowIcon(widget->windowIcon()); + window->setAttribute(Qt::WA_DeleteOnClose, false); + window->resize(widget->sizeHint()); + } + + 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(); + // reset window title every time we change the state of a subwindow to show the correct title foreach( QMdiSubWindow * subWindow, workspace()->subWindowList() ) { @@ -855,7 +879,7 @@ void MainWindow::showSettingsDialog() void MainWindow::aboutLMMS() { - AboutDialog().exec(); + AboutDialog(this).exec(); } @@ -912,10 +936,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; @@ -937,7 +961,7 @@ void MainWindow::refocus() void MainWindow::toggleBBEditorWin( bool forceShow ) { - toggleWindow( Engine::getBBEditor(), forceShow ); + toggleWindow( gui->getBBEditor(), forceShow ); } @@ -945,7 +969,7 @@ void MainWindow::toggleBBEditorWin( bool forceShow ) void MainWindow::toggleSongEditorWin() { - toggleWindow( Engine::songEditor() ); + toggleWindow( gui->songEditor() ); } @@ -953,7 +977,7 @@ void MainWindow::toggleSongEditorWin() void MainWindow::toggleProjectNotesWin() { - toggleWindow( Engine::getProjectNotes() ); + toggleWindow( gui->getProjectNotes() ); } @@ -961,7 +985,7 @@ void MainWindow::toggleProjectNotesWin() void MainWindow::togglePianoRollWin() { - toggleWindow( Engine::pianoRoll() ); + toggleWindow( gui->pianoRoll() ); } @@ -969,7 +993,7 @@ void MainWindow::togglePianoRollWin() void MainWindow::toggleAutomationEditorWin() { - toggleWindow( Engine::automationEditor() ); + toggleWindow( gui->automationEditor() ); } @@ -977,7 +1001,7 @@ void MainWindow::toggleAutomationEditorWin() void MainWindow::toggleFxMixerWin() { - toggleWindow( Engine::fxMixerView() ); + toggleWindow( gui->fxMixerView() ); } @@ -985,7 +1009,7 @@ void MainWindow::toggleFxMixerWin() void MainWindow::toggleControllerRack() { - toggleWindow( Engine::getControllerRackView() ); + toggleWindow( gui->getControllerRackView() ); } @@ -993,29 +1017,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 ac034753016..244362a7038 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/core/Timeline.cpp b/src/gui/TimeLineWidget.cpp similarity index 87% rename from src/core/Timeline.cpp rename to src/gui/TimeLineWidget.cpp index d30682d79e1..5966e7d5132 100644 --- a/src/core/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 * @@ -29,14 +29,15 @@ #include #include #include +#include -#include "Timeline.h" +#include "TimeLineWidget.h" #include "embed.h" #include "Engine.h" #include "templates.h" #include "NStateButton.h" -#include "MainWindow.h" +#include "GuiApplication.h" #include "TextFloat.h" @@ -45,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 ), @@ -109,9 +110,9 @@ Timeline::Timeline( const int _xoff, const int _yoff, const float _ppt, -Timeline::~Timeline() +TimeLineWidget::~TimeLineWidget() { - if( Engine::songEditor() ) + if( gui->songEditor() ) { m_pos.m_timeLine = NULL; } @@ -121,7 +122,7 @@ Timeline::~Timeline() -void Timeline::addToolButtons( QWidget * _tool_bar ) +void TimeLineWidget::addToolButtons( QToolBar * _tool_bar ) { NStateButton * autoScroll = new NStateButton( _tool_bar ); autoScroll->setGeneralToolTip( tr( "Enable/disable auto-scrolling" ) ); @@ -152,16 +153,15 @@ 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 ); } -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; diff --git a/src/gui/ToolPluginView.cpp b/src/gui/ToolPluginView.cpp index 72953c82c1b..8426c146e44 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/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp similarity index 70% rename from src/gui/AutomationEditor.cpp rename to src/gui/editors/AutomationEditor.cpp index 474402be5f0..c5da787a32f 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #ifndef __USE_XOPEN @@ -46,17 +47,17 @@ #include - +#include "ActionGroup.h" #include "SongEditor.h" #include "MainWindow.h" +#include "GuiApplication.h" #include "embed.h" #include "Engine.h" #include "PixmapButton.h" #include "templates.h" #include "gui_templates.h" -#include "Timeline.h" +#include "TimeLineWidget.h" #include "ToolTip.h" -#include "ToolButton.h" #include "TextFloat.h" #include "ComboBox.h" #include "BBTrackContainer.h" @@ -109,26 +110,16 @@ AutomationEditor::AutomationEditor() : Qt::QueuedConnection ); connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ), this, SLOT( update() ) ); - // init pixmaps - if( s_toolDraw == NULL ) - { - s_toolDraw = new QPixmap( embed::getIconPixmap( - "edit_draw" ) ); - } - if( s_toolErase == NULL ) - { - s_toolErase= new QPixmap( embed::getIconPixmap( - "edit_erase" ) ); - } - if( s_toolSelect == NULL ) - { - s_toolSelect = new QPixmap( embed::getIconPixmap( - "edit_select" ) ); - } - if( s_toolMove == NULL ) + + 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 ) { - s_toolMove = new QPixmap( embed::getIconPixmap( - "edit_move" ) ); + m_quantizeModel.addItem( "1/" + QString::number( 1 << i ) ); } if( s_toolYFlip == NULL ) { @@ -141,10 +132,11 @@ AutomationEditor::AutomationEditor() : "flip_x" ) ); } - setAttribute( Qt::WA_OpaquePaintEvent, true ); + connect(&m_quantizeModel, SIGNAL(dataChanged()), this, SLOT(setQuantization())); + m_quantizeModel.setValue( m_quantizeModel.findText( "1/16" ) ); // add time-line - m_timeLine = new Timeline( VALUES_WIDTH, 32, m_ppt, + m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppt, Engine::getSong()->getPlayPos( Song::Mode_PlayAutomationPattern ), m_currentPosition, this ); @@ -153,43 +145,6 @@ AutomationEditor::AutomationEditor() : 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 @@ -204,282 +159,31 @@ AutomationEditor::AutomationEditor() : 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_flipYButton = new ToolButton( embed::getIconPixmap( "flip_y" ), - tr( "Flip Vertically" ), - this, SLOT( flipYButtonPressed() ), - m_toolBar ); - - m_flipXButton = new ToolButton( embed::getIconPixmap( "flip_x" ), - tr( "Flip Horizontally" ), - this, SLOT( flipXButtonPressed() ), - m_toolBar ); - - //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_flipYButton ); - tool_button_group->addButton( m_flipXButton ); - //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_flipYButton->setWhatsThis( - tr( "Click here and the pattern will be inverted." - "The points are flipped in the y direction. " ) ); - m_flipXButton->setWhatsThis( - tr( "Click here and the pattern will be reversed. " - "The points are flipped in the x direction." ) ); - /*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 ) + // init pixmaps + if( s_toolDraw == NULL ) + { + s_toolDraw = new QPixmap( embed::getIconPixmap( + "edit_draw" ) ); + } + if( s_toolErase == NULL ) { - m_zoomingXModel.addItem( QString::number( 25 << i ) + "%" ); + s_toolErase= new QPixmap( embed::getIconPixmap( + "edit_erase" ) ); } - 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 ) + if( s_toolSelect == NULL ) { - m_zoomingYModel.addItem( QString::number( 25 << i ) + "%" ); + s_toolSelect = new QPixmap( embed::getIconPixmap( + "edit_select" ) ); } - 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 ) + if( s_toolMove == NULL ) { - m_quantizeModel.addItem( "1/" + QString::number( 1 << i ) ); + s_toolMove = new QPixmap( embed::getIconPixmap( + "edit_move" ) ); } - 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->addSpacing( 10 ); - tb_layout->addWidget( m_flipYButton ); - tb_layout->addWidget( m_flipXButton ); - //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(); - } } @@ -498,46 +202,43 @@ AutomationEditor::~AutomationEditor() -void AutomationEditor::setCurrentPattern( AutomationPattern * _new_pattern ) +void AutomationEditor::setCurrentPattern(AutomationPattern * new_pattern ) { + if (m_pattern) + { + m_pattern->disconnect(this); + } + m_patternMutex.lock(); - m_pattern = _new_pattern; + m_pattern = new_pattern; m_patternMutex.unlock(); + if (m_pattern != nullptr) + { + connect(m_pattern, SIGNAL(dataChanged()), this, SLOT(update())); + } + emit currentPatternChanged(); } -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 ); } - -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 @@ -567,34 +268,12 @@ void AutomationEditor::updateAfterPatternChange() if( !validPattern() ) { - setWindowTitle( tr( "Automation Editor - no pattern" ) ); m_minLevel = m_maxLevel = m_scrollLevel = 0; m_step = 1; resizeEvent( NULL ); 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(); @@ -604,8 +283,6 @@ void AutomationEditor::updateAfterPatternChange() // of levels and so on...) resizeEvent( NULL ); - setWindowTitle( tr( "Automation Editor - %1" ).arg( m_pattern->name() ) ); - update(); } @@ -620,7 +297,7 @@ void AutomationEditor::update() // Note detuning? if( m_pattern && !m_pattern->getTrack() ) { - Engine::pianoRoll()->update(); + gui->pianoRoll()->update(); } } @@ -638,37 +315,20 @@ void AutomationEditor::removeSelection() -void AutomationEditor::closeEvent( QCloseEvent * _ce ) +void AutomationEditor::keyPressEvent(QKeyEvent * ke ) { - QApplication::restoreOverrideCursor(); - if( parentWidget() ) - { - parentWidget()->hide(); - } - else - { - hide(); - } - _ce->ignore(); -} - - - - -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: @@ -677,102 +337,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; - 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 ) + if( ke->modifiers() & Qt::ControlModifier ) { m_selectButton->setChecked( true ); selectAll(); update(); - _ke->accept(); - } - break;*/ - - case Qt::Key_D: - if( _ke->modifiers() & Qt::ShiftModifier ) - { - m_drawButton->setChecked( true ); - _ke->accept(); + 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; - - case Qt::Key_Space: - if( Engine::getSong()->isPlaying() ) - { - stop(); - } - else - { - play(); - } - _ke->accept(); - break; + ke->accept(); + break;*/ case Qt::Key_Home: m_timeLine->pos().setTicks( 0 ); m_timeLine->updatePosition(); - _ke->accept(); + ke->accept(); break; default: @@ -783,45 +376,45 @@ 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; - if( deltax < quantization() ) + if( deltax < AutomationPattern::quantization() ) { return; } - deltax /= quantization(); + deltax /= AutomationPattern::quantization(); float yscale = deltay / ( deltax ); - if( _x0 < _x1) + if( x0 < x1) { - xstep = quantization(); + xstep = AutomationPattern::quantization(); } else { - xstep = -( quantization() ); + xstep = -( AutomationPattern::quantization() ); } - if( _y0 < _y1 ) + if( y0 < y1 ) { ystep = 1; } @@ -833,7 +426,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; @@ -845,15 +438,7 @@ void AutomationEditor::drawLine( int _x0, float _y0, int _x1, float _y1 ) -void AutomationEditor::disableTensionKnob() -{ - m_tensionKnob->setEnabled( false ); -} - - - - -void AutomationEditor::mousePressEvent( QMouseEvent * _me ) +void AutomationEditor::mousePressEvent( QMouseEvent* mouseEvent ) { QMutexLocker m( &m_patternMutex ); if( !validPattern() ) @@ -861,11 +446,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 ) { @@ -903,11 +488,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, @@ -946,7 +531,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 ) { @@ -958,7 +543,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 @@ -969,14 +554,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 ); + //m_moveButton->setChecked( true ); } - else if( _me->button() == Qt::LeftButton && + else if( mouseEvent->button() == Qt::LeftButton && m_editMode == MOVE ) { // move selection (including selected values) @@ -989,12 +574,12 @@ 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 // switch to draw-mode - m_drawButton->setChecked( true ); + //m_drawButton->setChecked( true ); } update(); @@ -1005,7 +590,7 @@ void AutomationEditor::mousePressEvent( QMouseEvent * _me ) -void AutomationEditor::mouseReleaseEvent( QMouseEvent * _me ) +void AutomationEditor::mouseReleaseEvent(QMouseEvent * mouseEvent ) { if( m_editMode == DRAW ) { @@ -1021,8 +606,7 @@ void AutomationEditor::mouseReleaseEvent( QMouseEvent * _me ) -#include -void AutomationEditor::mouseMoveEvent( QMouseEvent * _me ) +void AutomationEditor::mouseMoveEvent(QMouseEvent * mouseEvent ) { QMutexLocker m( &m_patternMutex ); if( !validPattern() ) @@ -1031,12 +615,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; @@ -1049,7 +633,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 ) { @@ -1075,14 +659,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 @@ -1139,7 +723,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 ) { @@ -1150,7 +734,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( @@ -1165,7 +749,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 ); } @@ -1185,7 +769,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 ) { @@ -1300,17 +884,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( @@ -1325,7 +909,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 ); } @@ -1342,11 +926,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( @@ -1355,7 +939,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 ); @@ -1376,7 +960,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() ); @@ -1387,9 +971,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; @@ -1405,7 +989,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 ); @@ -1414,7 +998,7 @@ inline void AutomationEditor::drawAutomationPoint( QPainter & p, timeMap::iterat -void AutomationEditor::paintEvent( QPaintEvent * _pe ) +void AutomationEditor::paintEvent(QPaintEvent * pe ) { QMutexLocker m( &m_patternMutex ); @@ -1514,10 +1098,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 ); @@ -1747,27 +1331,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 ); } } @@ -1775,19 +1359,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 ) @@ -1801,14 +1385,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 @@ -1822,7 +1406,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, @@ -1855,7 +1439,6 @@ void AutomationEditor::resizeEvent( QResizeEvent * ) Engine::getSong()->getPlayPos( Song::Mode_PlayAutomationPattern ).m_timeLine->setFixedWidth( width() ); } - m_toolBar->setFixedWidth( width() ); updateTopBottomLevels(); update(); @@ -1864,31 +1447,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++; } @@ -1896,44 +1479,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 ); @@ -1967,7 +1550,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 ) { @@ -1975,7 +1558,7 @@ void AutomationEditor::play() } else { - Engine::getSong()->playPattern( Engine::pianoRoll()->currentPattern() ); + Engine::getSong()->playPattern( gui->pianoRoll()->currentPattern() ); } } else if( inBBEditor() ) @@ -1993,8 +1576,6 @@ void AutomationEditor::play() Engine::getSong()->togglePause(); } } - - setPauseIcon( Engine::getSong()->isPlaying() ); } @@ -2022,9 +1603,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(); } @@ -2032,9 +1613,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(); } @@ -2042,118 +1623,57 @@ void AutomationEditor::verScrolled( int _new_pos ) -void AutomationEditor::drawButtonToggled() +void AutomationEditor::setEditMode(AutomationEditor::EditModes mode) { - m_editMode = DRAW; - removeSelection(); - update(); -} - - - - -void AutomationEditor::eraseButtonToggled() -{ - m_editMode = ERASE; - removeSelection(); - update(); -} - - - - -void AutomationEditor::flipYButtonPressed() -{ - m_pattern->flipY( m_minLevel, m_maxLevel ); -} - - - - -void AutomationEditor::flipXButtonPressed() -{ - m_pattern->flipX(); -} - - - - -void AutomationEditor::selectButtonToggled() -{ - m_editMode = SELECT; - removeSelection(); - update(); -} - - - + if (m_editMode == mode) + return; -void AutomationEditor::moveButtonToggled() -{ - m_editMode = MOVE; - m_selValuesForMove.clear(); - getSelectedValues( m_selValuesForMove ); + m_editMode = mode; + switch (mode) + { + case DRAW: + case ERASE: + case SELECT: + removeSelection(); + break; + case MOVE: + m_selValuesForMove.clear(); + getSelectedValues(m_selValuesForMove); + } update(); } -void AutomationEditor::discreteButtonToggled() +void AutomationEditor::setEditMode(int mode) { - if ( validPattern() ) - { - QMutexLocker m( &m_patternMutex ); - disableTensionKnob(); - m_pattern->setProgressionType( - AutomationPattern::DiscreteProgression ); - Engine::getSong()->setModified(); - update(); - } + setEditMode((AutomationEditor::EditModes) mode); } -void AutomationEditor::linearButtonToggled() +void AutomationEditor::setProgressionType(AutomationPattern::ProgressionTypes type) { - if ( validPattern() ) + if (validPattern()) { - QMutexLocker m( &m_patternMutex ); - disableTensionKnob(); - m_pattern->setProgressionType( - AutomationPattern::LinearProgression ); + QMutexLocker m(&m_patternMutex); + m_pattern->setProgressionType(type); Engine::getSong()->setModified(); update(); } } - - - -void AutomationEditor::cubicHermiteButtonToggled() +void AutomationEditor::setProgressionType(int type) { - 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(); - } + setProgressionType((AutomationPattern::ProgressionTypes) type); } -void AutomationEditor::tensionChanged() +void AutomationEditor::setTension() { m_pattern->setTension( QString::number( m_tensionModel->value() ) ); update(); @@ -2200,7 +1720,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() ) @@ -2237,7 +1757,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; } } } @@ -2295,7 +1815,7 @@ void AutomationEditor::cutSelectedValues() } update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } @@ -2317,7 +1837,7 @@ void AutomationEditor::pasteValues() // least one value... Engine::getSong()->setModified(); update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } } @@ -2347,14 +1867,14 @@ void AutomationEditor::deleteSelectedValues() { Engine::getSong()->setModified(); update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } } -void AutomationEditor::updatePosition( const MidiTime & _t ) +void AutomationEditor::updatePosition(const MidiTime & t ) { if( ( Engine::getSong()->isPlaying() && Engine::getSong()->playMode() == @@ -2362,16 +1882,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; @@ -2413,12 +1933,10 @@ void AutomationEditor::zoomingYChanged() -int AutomationEditor::quantization() const +void AutomationEditor::setQuantization() { - return( DefaultTicksPerTact / - m_quantizeComboBox->model()->currentText().right( - m_quantizeComboBox->model()->currentText().length() - - 2 ).toInt() ); + int quantization = DefaultTicksPerTact / (1 << m_quantizeModel.value());; + AutomationPattern::setQuantization(quantization); } @@ -2474,3 +1992,322 @@ void AutomationEditor::updateTopBottomLevels() + + +AutomationEditorWindow::AutomationEditorWindow() : + Editor(), + m_editor(new AutomationEditor()) +{ + setCentralWidget(m_editor); + + + + // Play/stop buttons + 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_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." ) ); + + // Edit mode buttons + 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 = editModeGroup->addAction(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); + eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); + + 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_flipYAction->setWhatsThis( + tr( "Click here and the pattern will be inverted." + "The points are flipped in the y direction. " ) ); + m_flipXAction->setWhatsThis( + tr( "Click here and the pattern will be reversed. " + "The points are flipped in the x direction." ) ); + +// 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); + + 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." ) ); + 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." ) ); + /*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." ) );*/ + + connect(editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int))); + + // Progression type buttons + ActionGroup* progression_type_group = new ActionGroup(this); + + 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")); + + 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 " + "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_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_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 + + QAction* cutAction = new QAction(embed::getIconPixmap("edit_cut"), + tr("Cut selected values (Ctrl+X)"), this); + QAction* copyAction = new QAction(embed::getIconPixmap("edit_copy"), + tr("Copy selected values (Ctrl+C)"), this); + QAction* pasteAction = new QAction(embed::getIconPixmap("edit_paste"), + tr("Paste values from clipboard Ctrl+V)"), this); + + 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." ) ); + 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." ) ); + pasteAction->setWhatsThis( + tr( "Click here and the values from the clipboard will be " + "pasted at the first visible measure." ) ); + + cutAction->setShortcut(Qt::CTRL | Qt::Key_X); + copyAction->setShortcut(Qt::CTRL | Qt::Key_C); + pasteAction->setShortcut(Qt::CTRL | Qt::Key_V); + + 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 + + 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->addAction(drawAction); + m_toolBar->addAction(eraseAction); +// m_toolBar->addAction(m_selectButton); +// m_toolBar->addAction(m_moveButton); + m_toolBar->addAction(m_flipXAction); + m_toolBar->addAction(m_flipYAction); + m_toolBar->addSeparator(); + 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(); +// Select is broken +// 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(); + 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 ); + + drawAction->setChecked(true); + m_discreteAction->setChecked(true); + + // Setup our actual window + setFocusPolicy( Qt::StrongFocus ); + setFocus(); + setWindowIcon( embed::getIconPixmap( "automation" ) ); +} + + +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" ) ); + return; + } + + setWindowTitle( tr( "Automation Editor - %1" ).arg( m_editor->m_pattern->name() ) ); + + + switch(m_editor->m_pattern->progressionType()) + { + case AutomationPattern::DiscreteProgression: + m_discreteAction->setChecked(true); + break; + case AutomationPattern::LinearProgression: + m_linearAction->setChecked(true); + break; + case AutomationPattern::CubicHermiteProgression: + m_cubicHermiteAction->setChecked(true); + break; + } + + // 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(); +} + + +const AutomationPattern* AutomationEditorWindow::currentPattern() +{ + return m_editor->currentPattern(); +} + +void AutomationEditorWindow::open(AutomationPattern* pattern) +{ + setCurrentPattern(pattern); + parentWidget()->show(); + show(); + setFocus(); +} + +QSize AutomationEditorWindow::sizeHint() const +{ + return {INITIAL_WIDTH, INITIAL_HEIGHT}; +} + +void AutomationEditorWindow::clearCurrentPattern() +{ + m_editor->m_pattern = nullptr; + setCurrentPattern(nullptr); +} + +void AutomationEditorWindow::play() +{ + m_editor->play(); + setPauseIcon(Engine::getSong()->isPlaying()); +} + +void AutomationEditorWindow::stop() +{ + m_editor->stop(); +} diff --git a/src/gui/BBEditor.cpp b/src/gui/editors/BBEditor.cpp similarity index 52% rename from src/gui/BBEditor.cpp rename to src/gui/editors/BBEditor.cpp index 2e661bc8256..21949fe73a1 100644 --- a/src/gui/BBEditor.cpp +++ b/src/gui/editors/BBEditor.cpp @@ -22,7 +22,7 @@ * */ - +#include #include #include #include @@ -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" @@ -44,27 +43,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,45 +64,14 @@ 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" ); - - ToolButton * add_bb_track = new ToolButton( - embed::getIconPixmap( "add_bb_track" ), - tr( "Add beat/bassline" ), - Engine::getSong(), SLOT( addBBTrack() ), - m_toolBar ); + m_playAction->setToolTip(tr( "Play/pause current beat/bassline (Space)" )); + m_stopAction->setToolTip(tr( "Stop playback of current beat/bassline (Space)" )); - ToolButton * add_automation_track = new ToolButton( - embed::getIconPixmap( "add_automation" ), - tr( "Add automation-track" ), - this, SLOT( addAutomationTrack() ), m_toolBar ); - - ToolButton * remove_bar = new ToolButton( - embed::getIconPixmap( "step_btn_remove" ), - tr( "Remove steps" ), - this, SLOT( removeSteps() ), m_toolBar ); - - ToolButton * add_bar = new ToolButton( - embed::getIconPixmap( "step_btn_add" ), - tr( "Add steps" ), - this, 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." ) ); @@ -125,88 +79,57 @@ 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 ); - - 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(); + m_toolBar->addSeparator(); + m_toolBar->addWidget( m_bbComboBox ); + m_toolBar->addSeparator(); + 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())); - setModel( tc ); - connect( &tc->m_bbComboBoxModel, SIGNAL( dataChanged() ), - this, SLOT( updatePosition() ) ); -} + QWidget* stretch = new QWidget(m_toolBar); + stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_toolBar->addWidget(stretch); + 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() ), + m_trackContainerView, SLOT( updatePosition() ) ); + QAction* viewNext = new QAction(this); + connect(viewNext, SIGNAL(triggered()), m_bbComboBox, SLOT(selectNext())); + viewNext->setShortcut(Qt::Key_Plus); + addAction(viewNext); -BBEditor::~BBEditor() -{ + QAction* viewPrevious = new QAction(this); + connect(viewPrevious, SIGNAL(triggered()), m_bbComboBox, SLOT(selectPrevious())); + viewPrevious->setShortcut(Qt::Key_Minus); + addAction(viewPrevious); } -void BBEditor::dropEvent( QDropEvent * de ) +BBEditor::~BBEditor() { - 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 ) +QSize BBEditor::sizeHint() const { - foreach( TrackView* view, trackViews() ) - { - view->getTrackContentWidget()->removeTCOView( _bb ); - } + return {minimumWidth()+10, 300}; } - - -void BBEditor::setPauseIcon( bool pause ) +void BBEditor::removeBBView( int bb ) { - if( pause == true ) - { - m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); - } - else - { - m_playButton->setIcon( embed::getIconPixmap( "play" ) ); - } + m_trackContainerView->removeBBView(bb); } - - void BBEditor::play() { if( Engine::getSong()->playMode() != Song::Mode_PlayBB ) @@ -220,8 +143,6 @@ void BBEditor::play() } - - void BBEditor::stop() { Engine::getSong()->stop(); @@ -230,24 +151,21 @@ void BBEditor::stop() -void BBEditor::updatePosition() -{ - //realignTracks(); - emit positionChanged( m_currentPosition ); -} - - -void BBEditor::addAutomationTrack() +BBTrackContainerView::BBTrackContainerView(BBTrackContainer* tc) : + TrackContainerView(tc), + m_bbtc(tc) { - (void) Track::create( Track::AutomationTrack, model() ); + setModel( tc ); } -void BBEditor::addSteps() + + +void BBTrackContainerView::addSteps() { TrackContainer::TrackList tl = model()->tracks(); @@ -265,7 +183,7 @@ void BBEditor::addSteps() -void BBEditor::removeSteps() +void BBTrackContainerView::removeSteps() { TrackContainer::TrackList tl = model()->tracks(); @@ -283,44 +201,54 @@ 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 ) + (void) Track::create( Track::AutomationTrack, model() ); +} + + + + +void BBTrackContainerView::removeBBView(int bb) +{ + foreach( TrackView* view, trackViews() ) { - if( m_bbtc->currentBB()+ 1 < m_bbtc->numOfBBs() ) - { - m_bbtc->setCurrentBB( m_bbtc->currentBB() + 1 ); - } + view->getTrackContentWidget()->removeTCOView( bb ); } - else if ( _ke->key() == Qt::Key_Minus ) +} + + + + +void BBTrackContainerView::dropEvent(QDropEvent* de) +{ + QString type = StringPairDrag::decodeKey( de ); + QString value = StringPairDrag::decodeValue( de ); + + if( type.left( 6 ) == "track_" ) { - if( m_bbtc->currentBB() > 0 ) - { - m_bbtc->setCurrentBB( m_bbtc->currentBB() - 1 ); - } + DataFile dataFile( value.toUtf8() ); + Track * t = Track::create( dataFile.content().firstChild().toElement(), model() ); + + t->deleteTCOs(); + m_bbtc->updateAfterTrackAdd(); + + de->accept(); } else { - // ignore event and pass to parent-widget - _ke->ignore(); + TrackContainerView::dropEvent( de ); } - } +void BBTrackContainerView::updatePosition() +{ + //realignTracks(); + emit positionChanged( m_currentPosition ); +} void BBEditor::closeEvent( QCloseEvent * _ce ) { diff --git a/src/gui/editors/Editor.cpp b/src/gui/editors/Editor.cpp new file mode 100644 index 00000000000..985d22f402c --- /dev/null +++ b/src/gui/editors/Editor.cpp @@ -0,0 +1,98 @@ +/* + * 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 "MainWindow.h" +#include "embed.h" + +#include +#include +#include +#include + + +void Editor::setPauseIcon(bool displayPauseIcon) +{ + // If we're playing, show a pause icon + if (displayPauseIcon) + m_playAction->setIcon(embed::getIconPixmap("pause")); + else + 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), + m_recordAction(nullptr), + m_recordAccompanyAction(nullptr), + m_stopAction(nullptr) +{ + m_toolBar->setContextMenuPolicy(Qt::PreventContextMenu); + m_toolBar->setMovable(false); + + auto addButton = [this](QAction* action, QString objectName) { + m_toolBar->addAction(action); + m_toolBar->widgetForAction(action)->setObjectName(objectName); + }; + + // 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); + + // 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); + + // 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/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp similarity index 80% rename from src/gui/PianoRoll.cpp rename to src/gui/editors/PianoRoll.cpp index 980b24396f5..c4e4bdcb8b9 100644 --- a/src/gui/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -45,6 +45,8 @@ #include #include +#include "AutomationEditor.h" +#include "ActionGroup.h" #include "ConfigManager.h" #include "PianoRoll.h" #include "BBTrackContainer.h" @@ -53,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" @@ -65,8 +68,7 @@ #include "SongEditor.h" #include "templates.h" #include "TextFloat.h" -#include "Timeline.h" -#include "ToolButton.h" +#include "TimeLineWidget.h" #include "TextFloat.h" @@ -97,7 +99,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; @@ -200,32 +202,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 ); - - 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 ); - - 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 ); - - act = new QAction( tr("Unmark all"), this ); - connect( act, SIGNAL(triggered()), signalMapper, SLOT(map()) ); - signalMapper->setMapping( act, static_cast( stmaUnmarkAll ) ); - 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 ); - connect( signalMapper, SIGNAL(mapped(int)), - this, SLOT(markSemiTone(int)) ); + 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()) ); + + signalMapper->setMapping( markSemitoneAction, static_cast( stmaMarkCurrentSemiTone ) ); + signalMapper->setMapping( markScaleAction, static_cast( stmaMarkCurrentScale ) ); + signalMapper->setMapping( markChordAction, static_cast( stmaMarkCurrentChord ) ); + signalMapper->setMapping( unmarkAllAction, static_cast( stmaUnmarkAll ) ); + + markScaleAction->setEnabled( false ); + markChordAction->setEnabled( false ); + + 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 ) @@ -293,7 +296,7 @@ PianoRoll::PianoRoll() : setAttribute( Qt::WA_OpaquePaintEvent, true ); // add time-line - m_timeLine = new Timeline( WHITE_KEY_WIDTH, 32, m_ppt, + m_timeLine = new TimeLineWidget( WHITE_KEY_WIDTH, 0, m_ppt, Engine::getSong()->getPlayPos( Song::Mode_PlayPattern ), m_currentPosition, this ); @@ -313,64 +316,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 @@ -385,94 +330,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 ) { @@ -481,14 +338,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 ) { @@ -500,17 +351,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", @@ -529,20 +374,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 ) { @@ -553,18 +393,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 ) { @@ -575,126 +408,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() ) ); @@ -712,7 +436,7 @@ void PianoRoll::reset() void PianoRoll::changeNoteEditMode( int i ) { - m_noteEditMode = (noteEditMode) i; + m_noteEditMode = (NoteEditMode) i; repaint(); } @@ -722,7 +446,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(); @@ -876,34 +600,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 ) - { - m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); - } - else - { - m_playButton->setIcon( embed::getIconPixmap( "play" ) ); - } -} - /** \brief qproperty access implementation */ @@ -933,36 +629,36 @@ 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 ); } - else if( _n->selected() ) + else if( n->selected() ) { col.setRgb( 0x00, 0x40, 0xC0 ); } @@ -975,28 +671,28 @@ 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( QColor::fromHsv( col.hue(), col.saturation(), + p.setBrush( gradient ); + p.setPen( QColor::fromHsv( col.hue(), col.saturation(), qMin( 255, volVal*1.7f ) ) ); - _p.setRenderHint(QPainter::Antialiasing); - _p.drawRoundedRect( _x, _y, _width, KEY_LINE_HEIGHT-1, 5, 2 ); + p.setRenderHint(QPainter::Antialiasing); + p.drawRoundedRect( x, y, width, KEY_LINE_HEIGHT-1, 5, 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 ); } @@ -1081,23 +777,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(); @@ -1116,7 +795,7 @@ void PianoRoll::shiftSemiTone( int amount ) // shift notes by amount semitones // we modified the song update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } @@ -1152,7 +831,7 @@ void PianoRoll::shiftPos( int amount ) //shift notes pos by amount // we modified the song update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } @@ -1196,29 +875,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() && key_num > -1 ) + if(! ke->isAutoRepeat() && 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 ); @@ -1236,21 +915,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 ); @@ -1268,23 +947,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 ); } @@ -1301,24 +980,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 ); } @@ -1335,100 +1014,32 @@ 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(); - 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(); - } + ke->accept(); break; case Qt::Key_A: - if( event->modifiers() & Qt::ControlModifier ) + if( ke->modifiers() & Qt::ControlModifier ) { - event->accept(); + ke->accept(); selectAll(); update(); } 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(); - break; - - case Qt::Key_Space: - if( Engine::getSong()->isPlaying() ) - { - stop(); - } - else - { - play(); - } - 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: @@ -1442,20 +1053,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; } @@ -1466,7 +1077,7 @@ void PianoRoll::keyPressEvent( QKeyEvent* event ) m_ctrlMode = m_editMode; m_editMode = ModeSelect; QApplication::changeOverrideCursor( Qt::ArrowCursor ); - event->accept(); + ke->accept(); } break; default: @@ -1479,23 +1090,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() && key_num > -1 ) + if( ! ke->isAutoRepeat() && 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; @@ -1503,7 +1114,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(); } @@ -1516,14 +1127,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(); } @@ -1579,9 +1190,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() ) { @@ -1590,12 +1201,14 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) if( m_editMode == ModeEditDetuning && noteUnderMouse() ) { - noteUnderMouse()->editDetuningPattern(); + Note* n = noteUnderMouse(); + if (n->detuning() == NULL) n->createDetuning(); + gui->automationEditor()->open( noteUnderMouse()->detuning()->automationPattern() ); return; } // 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; @@ -1604,13 +1217,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; @@ -1618,13 +1231,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 ) @@ -1681,11 +1294,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 @@ -1724,7 +1337,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 ) @@ -1839,7 +1452,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) QApplication::setOverrideCursor( c ); // if they're holding shift, copy all selected notes - if( ! is_new_note && _me->modifiers() & Qt::ShiftModifier ) + if( ! is_new_note && me->modifiers() & Qt::ShiftModifier ) { // vector to hold new notes until we're through the loop QVector newNotes; @@ -1868,7 +1481,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(); } } @@ -1878,7 +1491,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 ) { @@ -1900,7 +1513,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 @@ -1913,18 +1526,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 { @@ -1936,20 +1549,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() ) ) ); } } } @@ -1958,7 +1571,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me ) -void PianoRoll::mouseDoubleClickEvent( QMouseEvent * _me ) +void PianoRoll::mouseDoubleClickEvent(QMouseEvent * me ) { if( ! hasValidPattern() ) { @@ -1966,12 +1579,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 ) * @@ -2053,7 +1666,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(); @@ -2062,7 +1675,7 @@ void PianoRoll::pauseTestNotes( bool _pause ) Note *note = *it; if( note->isPlaying() ) { - if( _pause ) + if( pause ) { // stop note m_pattern->instrumentTrack()->pianoModel()->handleKeyRelease( note->key() ); @@ -2173,33 +1786,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 @@ -2209,7 +1822,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 @@ -2261,7 +1874,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * _me ) -void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) +void PianoRoll::mouseMoveEvent( QMouseEvent * me ) { if( ! hasValidPattern() ) { @@ -2269,9 +1882,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 ) ); @@ -2282,7 +1895,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 ); @@ -2290,19 +1903,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 ); @@ -2312,7 +1925,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 ) ) { @@ -2320,26 +1933,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 || 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 @@ -2362,15 +1975,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); @@ -2456,7 +2069,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 @@ -2469,7 +2082,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 @@ -2567,7 +2180,7 @@ void PianoRoll::mouseMoveEvent( QMouseEvent * _me ) } } } - else if( _me->buttons() & Qt::LeftButton && + else if( me->buttons() & Qt::LeftButton && m_editMode == ModeSelect && m_action == ActionSelectNotes ) { @@ -2590,7 +2203,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 @@ -2655,18 +2268,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( @@ -2681,7 +2294,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 ); } @@ -2700,7 +2313,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 ) / @@ -2709,7 +2322,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 ); @@ -2717,7 +2330,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 ); @@ -2733,8 +2346,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(); } @@ -2924,7 +2537,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() ); @@ -3434,7 +3047,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() - @@ -3461,23 +3074,23 @@ void PianoRoll::resizeEvent( QResizeEvent * ) Engine::getSong()->getPlayPos( Song::Mode_PlayPattern ).m_timeLine->setFixedWidth( width() ); - m_toolBar->setFixedWidth( width() ); + update(); } -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 ) * @@ -3501,7 +3114,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 ) @@ -3534,7 +3147,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(); @@ -3543,42 +3156,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--; } @@ -3586,27 +3199,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 @@ -3715,26 +3328,24 @@ void PianoRoll::stop() -void PianoRoll::startRecordNote( const Note & _n ) +void PianoRoll::startRecordNote(const Note & n ) { if( m_recording && hasValidPattern() && - Engine::getSong()->isPlaying() && - ( Engine::getSong()->playMode() == - desiredPlayModeForAccompany() || - Engine::getSong()->playMode() == - Song::Mode_PlayPattern ) ) + 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 ) + n.key(), n.getVolume(), n.getPanning() ); + if( n1.pos() >= 0 ) { - m_recordingNotes << n; + m_recordingNotes << n1; } } } @@ -3742,7 +3353,7 @@ void PianoRoll::startRecordNote( const Note & _n ) -void PianoRoll::finishRecordNote( const Note & _n ) +void PianoRoll::finishRecordNote(const Note & n ) { if( m_recording && hasValidPattern() && Engine::getSong()->isPlaying() && @@ -3754,9 +3365,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() ); @@ -3772,9 +3383,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(); } @@ -3782,51 +3393,25 @@ 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; - - update(); -} - + m_startKey = m_totalKeysToScroll - new_pos; - - -void PianoRoll::drawButtonToggled() -{ - m_editMode = ModeDraw; update(); } -void PianoRoll::eraseButtonToggled() +void PianoRoll::setEditMode(int mode) { - m_editMode = ModeErase; - update(); + m_editMode = (EditModes) mode; } -void PianoRoll::selectButtonToggled() -{ - m_editMode = ModeSelect; - update(); -} - - - -void PianoRoll::detuneButtonToggled() -{ - m_editMode = ModeEditDetuning; - update(); -} - - - void PianoRoll::selectAll() { if( ! hasValidPattern() ) @@ -3887,7 +3472,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() ) { @@ -3902,7 +3487,7 @@ void PianoRoll::getSelectedNotes( NoteVector & _selected_notes ) Note *note = *it; if( note->selected() ) { - _selected_notes.push_back( note ); + selected_notes.push_back( note ); } } } @@ -3953,14 +3538,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 ); @@ -4018,7 +3603,7 @@ void PianoRoll::cutSelectedNotes() } update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } @@ -4066,10 +3651,8 @@ 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(); + gui->songEditor()->update(); } } @@ -4114,7 +3697,7 @@ void PianoRoll::deleteSelectedNotes() { Engine::getSong()->setModified(); update(); - Engine::songEditor()->update(); + gui->songEditor()->update(); } } @@ -4122,18 +3705,18 @@ 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() * MidiTime::ticksPerTact() ); + 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, (tick_t) 0 ); - m_leftRightScroll->setValue( t.getTact() * MidiTime::ticksPerTact() ); + m_leftRightScroll->setValue( t2.getTact() * MidiTime::ticksPerTact() ); } m_scrollBack = false; } @@ -4141,28 +3724,28 @@ 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() == Song::Mode_PlayPattern - && m_timeLine->autoScroll() == Timeline::AutoScrollEnabled + && m_timeLine->autoScroll() == TimeLineWidget::AutoScrollEnabled ) || m_scrollBack ) { - 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(); @@ -4299,3 +3882,311 @@ Note * PianoRoll::noteUnderMouse() return note; } + + + + + + + + + +PianoRollWindow::PianoRollWindow() : + Editor(true), + m_editor(new PianoRoll()) +{ + setCentralWidget(m_editor); + + 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_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_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_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_stopAction->setWhatsThis( + tr( "Click here to stop playback of current pattern." ) ); + + // init edit-buttons at the top + 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 ); + + drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); + eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); + selectAction->setShortcut(Qt::SHIFT | Qt::Key_S); + detuneAction->setShortcut(Qt::SHIFT | Qt::Key_T); + + 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." ) ); + 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." ) ); + 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." ) ); + 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." ) ); + + connect(editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int))); + + // Copy + paste actions + QAction* cutAction = new QAction(embed::getIconPixmap("edit_cut"), + tr("Cut selected notes (Ctrl+X)"), this); + + QAction* copyAction = new QAction(embed::getIconPixmap("edit_copy"), + tr("Copy selected notes (Ctrl+C)"), this); + + QAction* pasteAction = new QAction(embed::getIconPixmap("edit_paste"), + tr("Paste notes from clipboard (Ctrl+V)"), this); + + 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." ) ); + 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." ) ); + pasteAction->setWhatsThis( + tr( "Click here and the notes from the clipboard will be " + "pasted at the first visible measure." ) ); + + cutAction->setShortcut(Qt::CTRL | Qt::Key_X); + copyAction->setShortcut(Qt::CTRL | Qt::Key_C); + pasteAction->setShortcut(Qt::CTRL | Qt::Key_V); + + 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" ) ); + + 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->addAction( drawAction ); + m_toolBar->addAction( eraseAction ); + m_toolBar->addAction( selectAction ); + m_toolBar->addAction( detuneAction ); + + m_toolBar->addSeparator(); + 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(); + 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 ); + + // 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); +} + +QSize PianoRollWindow::sizeHint() const +{ + return {m_toolBar->sizeHint().width()+10, INITIAL_PIANOROLL_HEIGHT}; +} diff --git a/src/gui/SongEditor.cpp b/src/gui/editors/SongEditor.cpp similarity index 63% rename from src/gui/SongEditor.cpp rename to src/gui/editors/SongEditor.cpp index d495fcd621e..1a2e711941b 100644 --- a/src/gui/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -22,6 +22,8 @@ * */ +#include "SongEditor.h" + #include #include #include @@ -35,18 +37,18 @@ #include -#include "SongEditor.h" +#include "ActionGroup.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" #include "TextFloat.h" -#include "Timeline.h" -#include "ToolButton.h" +#include "TimeLineWidget.h" #include "ToolTip.h" #include "VisualizationWidget.h" #include "TimeDisplayWidget.h" @@ -77,21 +79,17 @@ 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 ? 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 ); @@ -103,6 +101,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() ), @@ -110,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 ); @@ -127,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" ), @@ -137,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 ); @@ -165,23 +165,23 @@ 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" ) ); 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 ); @@ -197,22 +197,22 @@ 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" ) ); 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 ); @@ -227,156 +227,9 @@ SongEditor::SongEditor( Song * _song ) : vcw_layout->addWidget( new CPULoadWidget( vc_w ) ); vcw_layout->addStretch(); - 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(); + gui->mainWindow()->addWidgetToToolBar( vc_w ); + static_cast( layout() )->insertWidget( 0, m_timeLine ); m_leftRightScroll = new QScrollBar( Qt::Horizontal, this ); m_leftRightScroll->setMinimum( 0 ); @@ -389,12 +242,19 @@ SongEditor::SongEditor( Song * _song ) : connect( m_song, SIGNAL( lengthChanged( int ) ), this, SLOT( updateScrollBar( int ) ) ); + // 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() ) ); - Engine::mainWindow()->workspace()->addSubWindow( this ); - parentWidget()->setAttribute( Qt::WA_DeleteOnClose, false ); - parentWidget()->resize( 600, 300 ); - parentWidget()->move( 5, 5 ); - parentWidget()->show(); + setFocusPolicy( Qt::StrongFocus ); + setFocus(); } @@ -426,56 +286,19 @@ void SongEditor::scrolled( int _new_pos ) -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() +void SongEditor::setEditMode(EditMode mode) { - m_song->record(); + m_mode = mode; } - - - -void SongEditor::recordAccompany() +void SongEditor::setEditModeDraw() { - m_song->playAndRecord(); + setEditMode(DrawMode); } - - - -void SongEditor::stop() +void SongEditor::setEditModeSelect() { - m_song->stop(); - Engine::pianoRoll()->stopRecording(); + setEditMode(SelectMode); } @@ -484,13 +307,13 @@ void SongEditor::stop() 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(); @@ -511,17 +334,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 ); @@ -537,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 ) { @@ -549,8 +361,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 ) ) + @@ -561,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 ); @@ -592,9 +404,8 @@ void SongEditor::closeEvent( QCloseEvent * _ce ) -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() ) { @@ -608,18 +419,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 ) ); } @@ -627,7 +438,7 @@ void SongEditor::masterVolumeMoved( int _new_val ) -void SongEditor::masterVolumeReleased( void ) +void SongEditor::hideMasterVolumeFloat( void ) { m_mvsStatus->hide(); } @@ -635,9 +446,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() ) { @@ -650,18 +461,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 ) ); @@ -670,7 +481,7 @@ void SongEditor::masterPitchMoved( int _new_val ) -void SongEditor::masterPitchReleased( void ) +void SongEditor::hideMasterPitchFloat( void ) { m_mpsStatus->hide(); } @@ -732,7 +543,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 @@ -774,7 +585,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-> @@ -792,7 +603,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 ); @@ -803,5 +614,114 @@ void SongEditor::adjustUiAfterProjectLoad() bool SongEditor::allowRubberband() const { - return( m_editModeButton->isChecked() ); + return m_mode == SelectMode; +} + + +SongEditorWindow::SongEditorWindow(Song* song) : + Editor(Engine::mixer()->audioDev()->supportsCapture()), + m_editor(new SongEditor(song)) +{ + setWindowTitle( tr( "Song-Editor" ) ); + setWindowIcon( embed::getIconPixmap( "songeditor" ) ); + + setCentralWidget(m_editor); + + // Set up buttons + m_playAction->setToolTip(tr("Play song (Space)")); + 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"), + tr("Add beat/bassline"), this); + + m_addSampleTrackAction = new QAction(embed::getIconPixmap("add_sample_track"), + tr("Add sample-track"), this); + + m_addAutomationTrackAction = new QAction(embed::getIconPixmap("add_automation"), + tr("Add automation-track"), this); + + 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())); + + 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_drawModeAction->setChecked(true); + + connect(m_drawModeAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeDraw())); + connect(m_selectModeAction, SIGNAL(triggered()), m_editor, SLOT(setEditModeSelect())); + + + 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_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.")); + + + 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->addAction( m_addBBTrackAction ); + m_toolBar->addAction( m_addSampleTrackAction ); + m_toolBar->addAction( m_addAutomationTrackAction ); + m_toolBar->addSeparator(); + m_toolBar->addAction( m_drawModeAction ); + m_toolBar->addAction( m_selectModeAction ); + m_toolBar->addSeparator(); + m_editor->m_timeLine->addToolButtons(m_toolBar); + m_toolBar->addSeparator(); + m_toolBar->addWidget( zoom_lbl ); + m_toolBar->addWidget( m_zoomingComboBox ); +} + +QSize SongEditorWindow::sizeHint() const +{ + return {600, 300}; +} + + +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(); + gui->pianoRoll()->stopRecording(); } diff --git a/src/gui/widgets/ComboBox.cpp b/src/gui/widgets/ComboBox.cpp index 950dbf70f97..86294a86391 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 diff --git a/src/gui/widgets/ControllerRackView.cpp b/src/gui/widgets/ControllerRackView.cpp index 327ab5ab1c2..72f0b8eed94 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 aaaa3ef1a9c..8b618a3e191 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 6214747d5fd..64463caed32 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 adb47d4f824..13c20c4c866 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" @@ -229,28 +230,28 @@ void FxLine::renameChannel() void FxLine::removeChannel() { - FxMixerView * mix = Engine::fxMixerView(); + FxMixerView * mix = gui->fxMixerView(); mix->deleteChannel( m_channelIndex ); } void FxLine::removeUnusedChannels() { - FxMixerView * mix = Engine::fxMixerView(); + FxMixerView * mix = gui->fxMixerView(); mix->deleteUnusedChannels(); } 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 e5d8be8547f..75732679d1a 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 afdf85943dd..73534f5c71a 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 5137e83116c..75f2143385a 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 0022691e0b8..598cfc06234 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 9947b09cd10..99d99069999 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 981af4b4348..d6e1e5210ee 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/ToolButton.cpp b/src/gui/widgets/ToolButton.cpp index d2031abc6fb..20e6018682f 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() ); - } -} - - - - diff --git a/src/gui/widgets/VisualizationWidget.cpp b/src/gui/widgets/VisualizationWidget.cpp index e7e21d58914..734defc68ce 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 78892e728f2..45210b05f4e 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" @@ -281,7 +282,7 @@ void BBTCOView::openInBBEditor() { Engine::getBBTrackContainer()->setCurrentBB( m_bbTCO->bbTrackIndex() ); - Engine::mainWindow()->toggleBBEditorWin( true ); + gui->mainWindow()->toggleBBEditorWin( true ); } @@ -316,7 +317,7 @@ void BBTCOView::changeColor() if( isSelected() ) { QVector selected = - Engine::songEditor()->selectedObjects(); + gui->songEditor()->m_editor->selectedObjects(); for( QVector::iterator it = selected.begin(); it != selected.end(); ++it ) @@ -605,7 +606,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] ); } @@ -613,7 +614,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(); } @@ -623,7 +624,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 f2e14fee584..c620f09af7e 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -53,6 +53,7 @@ #include "FileBrowser.h" #include "FxMixer.h" #include "FxMixerView.h" +#include "GuiApplication.h" #include "InstrumentSoundShaping.h" #include "InstrumentSoundShapingView.h" #include "FadeButton.h" @@ -941,7 +942,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" ) ) @@ -1135,10 +1136,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(); } }; @@ -1280,7 +1281,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; @@ -1306,7 +1307,7 @@ InstrumentTrackWindow::~InstrumentTrackWindow() delete m_instrumentView; - if( Engine::mainWindow()->workspace() ) + if( gui->mainWindow()->workspace() ) { parentWidget()->hide(); parentWidget()->deleteLater(); @@ -1472,7 +1473,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 4c95aa6fcd8..b5d2da75bd3 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" @@ -183,9 +183,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(); @@ -559,9 +559,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(); } } @@ -627,7 +627,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 ) @@ -687,9 +687,10 @@ void PatternView::update() void PatternView::openInPianoRoll() { - Engine::pianoRoll()->setCurrentPattern( m_pat ); - Engine::pianoRoll()->parentWidget()->show(); - Engine::pianoRoll()->setFocus(); + gui->pianoRoll()->setCurrentPattern( m_pat ); + gui->pianoRoll()->parentWidget()->show(); + gui->pianoRoll()->show(); + gui->pianoRoll()->setFocus(); } @@ -820,9 +821,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 @@ -881,9 +882,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(); @@ -950,7 +951,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 ) ); @@ -959,7 +960,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 1aa3044e696..3ee6836053b 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" @@ -588,7 +589,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() );