diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 23ec6e47e..8d4f8726b 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -27,6 +27,7 @@ #define AUTOMATION_EDITOR_H #include +#include #include #include "Editor.h" @@ -186,6 +187,8 @@ private: ComboBoxModel m_zoomingYModel; ComboBoxModel m_quantizeModel; + static const QVector m_zoomXLevels; + FloatModel * m_tensionModel; QMutex m_patternMutex; @@ -252,6 +255,7 @@ signals: + class AutomationEditorWindow : public Editor { Q_OBJECT diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 28f323def..9878346f8 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -27,6 +27,7 @@ #ifndef PIANO_ROLL_H #define PIANO_ROLL_H +#include #include #include @@ -292,6 +293,7 @@ private: ComboBoxModel m_scaleModel; ComboBoxModel m_chordModel; + static const QVector m_zoomLevels; Pattern* m_pattern; QScrollBar * m_leftRightScroll; @@ -386,6 +388,8 @@ signals: } ; + + class PianoRollWindow : public Editor, SerializingObject { Q_OBJECT diff --git a/include/SongEditor.h b/include/SongEditor.h index 005a72bab..d5bddc8ae 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -27,6 +27,8 @@ #ifndef SONG_EDITOR_H #define SONG_EDITOR_H +#include + #include "Editor.h" #include "TrackContainerView.h" @@ -124,6 +126,8 @@ private: ComboBoxModel* m_zoomingModel; + static const QVector m_zoomLevels; + bool m_scrollBack; bool m_smoothScroll; @@ -133,6 +137,9 @@ private: } ; + + + class SongEditorWindow : public Editor { Q_OBJECT diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index b7190632f..c532d1414 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -75,6 +75,8 @@ QPixmap * AutomationEditor::s_toolMove = NULL; QPixmap * AutomationEditor::s_toolYFlip = NULL; QPixmap * AutomationEditor::s_toolXFlip = NULL; +const QVector AutomationEditor::m_zoomXLevels = + { 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f }; @@ -1491,11 +1493,11 @@ void AutomationEditor::wheelEvent(QWheelEvent * we ) int x = m_zoomingXModel.value(); if( we->delta() > 0 ) { - x++; + x--; } if( we->delta() < 0 ) { - x--; + x++; } x = qBound( 0, x, m_zoomingXModel.size() - 1 ); m_zoomingXModel.setValue( x ); @@ -1917,8 +1919,7 @@ void AutomationEditor::updatePosition(const MidiTime & t ) void AutomationEditor::zoomingXChanged() { - const QString & zfac = m_zoomingXModel.currentText(); - m_ppt = zfac.left( zfac.length() - 1 ).toInt() * DEFAULT_PPT / 100; + m_ppt = m_zoomXLevels[m_zoomingXModel.value()] * DEFAULT_PPT; assert( m_ppt > 0 ); @@ -2208,9 +2209,9 @@ AutomationEditorWindow::AutomationEditorWindow() : m_zoomingXComboBox = new ComboBox( zoomToolBar ); m_zoomingXComboBox->setFixedSize( 80, 22 ); - for( int i = 0; i < 6; ++i ) + for( float const & zoomLevel : m_editor->m_zoomXLevels ) { - m_editor->m_zoomingXModel.addItem( QString::number( 25 << i ) + "%" ); + m_editor->m_zoomingXModel.addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) ); } m_editor->m_zoomingXModel.setValue( m_editor->m_zoomingXModel.findText( "100%" ) ); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 3fafca3eb..fab230887 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -152,6 +152,9 @@ PianoRoll::PianoRollKeyTypes PianoRoll::prKeyOrder[] = const int DEFAULT_PR_PPT = KEY_LINE_HEIGHT * DefaultStepsPerTact; +const QVector PianoRoll::m_zoomLevels = + { 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f }; + PianoRoll::PianoRoll() : m_nemStr( QVector() ), @@ -350,9 +353,9 @@ PianoRoll::PianoRoll() : SLOT( verScrolled( int ) ) ); // setup zooming-stuff - for( int i = 0; i < 6; ++i ) + for( float const & zoomLevel : m_zoomLevels ) { - m_zoomingModel.addItem( QString::number( 25 << i ) + "%" ); + m_zoomingModel.addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) ); } m_zoomingModel.setValue( m_zoomingModel.findText( "100%" ) ); connect( &m_zoomingModel, SIGNAL( dataChanged() ), @@ -3255,11 +3258,11 @@ void PianoRoll::wheelEvent(QWheelEvent * we ) int z = m_zoomingModel.value(); if( we->delta() > 0 ) { - z++; + z--; } if( we->delta() < 0 ) { - z--; + z++; } z = qBound( 0, z, m_zoomingModel.size() - 1 ); // update combobox with zooming-factor @@ -3853,8 +3856,7 @@ void PianoRoll::updatePositionAccompany( const MidiTime & t ) void PianoRoll::zoomingChanged() { - const QString & zfac = m_zoomingModel.currentText(); - m_ppt = zfac.left( zfac.length() - 1 ).toInt() * DEFAULT_PR_PPT / 100; + m_ppt = m_zoomLevels[m_zoomingModel.value()] * DEFAULT_PR_PPT; assert( m_ppt > 0 ); @@ -3871,6 +3873,8 @@ void PianoRoll::quantizeChanged() } + + int PianoRoll::quantization() const { if( m_quantizeModel.value() == 0 ) diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index de0060979..b7ea65695 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -73,7 +73,8 @@ void positionLine::paintEvent( QPaintEvent * pe ) p.fillRect( rect(), QColor( 255, 255, 255, 153 ) ); } - +const QVector SongEditor::m_zoomLevels = + { 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f, 16.0f }; SongEditor::SongEditor( Song * song ) : @@ -242,10 +243,9 @@ SongEditor::SongEditor( Song * song ) : this, SLOT( updateScrollBar( int ) ) ); // Set up zooming model - for( int i = 0; i < 7; ++i ) + for( float const & zoomLevel : m_zoomLevels ) { - m_zoomingModel->addItem( - QString::number( 25 << i ) + "%" ); + m_zoomingModel->addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) ); } m_zoomingModel->setInitValue( m_zoomingModel->findText( "100%" ) ); @@ -360,22 +360,20 @@ void SongEditor::wheelEvent( QWheelEvent * we ) { if( gui->mainWindow()->isCtrlPressed() == true ) { + int z = m_zoomingModel->value(); + if( we->delta() > 0 ) { - setPixelsPerTact( (int) qMin( pixelsPerTact() * 2, - 256.0f ) ); + z--; } - else if( pixelsPerTact() >= 8 ) + if( we->delta() < 0 ) { - setPixelsPerTact( (int) pixelsPerTact() / 2 ); + z++; } + z = qBound( 0, z, m_zoomingModel->size() - 1 ); // update combobox with zooming-factor - m_zoomingModel->setValue( - m_zoomingModel->findText( - QString::number( - static_cast( pixelsPerTact() * - 100 / DEFAULT_PIXELS_PER_TACT ) ) + - "%" ) ); + m_zoomingModel->setValue( z ); + // update timeline m_song->m_playPos[Song::Mode_PlaySong].m_timeLine-> setPixelsPerTact( pixelsPerTact() ); @@ -593,9 +591,8 @@ void SongEditor::updatePosition( const MidiTime & t ) void SongEditor::zoomingChanged() { - const QString & zfac = m_zoomingModel->currentText(); - setPixelsPerTact( zfac.left( zfac.length() - 1 ).toInt() * - DEFAULT_PIXELS_PER_TACT / 100 ); + setPixelsPerTact( m_zoomLevels[m_zoomingModel->value()] * DEFAULT_PIXELS_PER_TACT ); + m_song->m_playPos[Song::Mode_PlaySong].m_timeLine-> setPixelsPerTact( pixelsPerTact() ); realignTracks(); @@ -603,13 +600,16 @@ void SongEditor::zoomingChanged() + bool SongEditor::allowRubberband() const { return m_mode == SelectMode; } -SongEditorWindow::SongEditorWindow( Song* song ) : + + +SongEditorWindow::SongEditorWindow(Song* song) : Editor(Engine::mixer()->audioDev()->supportsCapture()), m_editor(new SongEditor(song)) {