diff --git a/include/setup_dialog.h b/include/setup_dialog.h index 31c26ed95..fb1c58e87 100644 --- a/include/setup_dialog.h +++ b/include/setup_dialog.h @@ -1,7 +1,7 @@ /* * setup_dialog.h - dialog for setting up LMMS * - * Copyright (c) 2005-2010 Tobias Doerffel + * Copyright (c) 2005-2011 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -104,6 +104,7 @@ private slots: void toggleDisableChActInd( bool _disabled ); void toggleManualChPiano( bool _enabled ); + void toggleSmoothScroll( bool _enabled ); void toggleOneInstrumentTrackWindow( bool _enabled ); @@ -149,6 +150,7 @@ private: bool m_disableChActInd; bool m_manualChPiano; + bool m_smoothScroll; bool m_oneInstrumentTrackWindow; typedef QMap AswMap; diff --git a/include/song_editor.h b/include/song_editor.h index 3321fce06..82d507065 100644 --- a/include/song_editor.h +++ b/include/song_editor.h @@ -129,6 +129,7 @@ private: positionLine * m_positionLine; bool m_scrollBack; + bool m_smoothScroll; } ; diff --git a/src/gui/setup_dialog.cpp b/src/gui/setup_dialog.cpp index d15f95818..b2d36873e 100644 --- a/src/gui/setup_dialog.cpp +++ b/src/gui/setup_dialog.cpp @@ -112,6 +112,7 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : "disablechannelactivityindicators" ).toInt() ), m_manualChPiano( configManager::inst()->value( "ui", "manualchannelpiano" ).toInt() ), + m_smoothScroll( configManager::inst()->value( "ui", "smoothscroll" ).toInt() ), m_oneInstrumentTrackWindow( configManager::inst()->value( "ui", "oneinstrumenttrackwindow" ).toInt() ) { @@ -453,7 +454,7 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : tabWidget * ui_fx_tw = new tabWidget( tr( "UI effects vs. " "performance" ).toUpper(), performance ); - ui_fx_tw->setFixedHeight( 70 ); + ui_fx_tw->setFixedHeight( 90 ); ledCheckBox * disable_ch_act_ind = new ledCheckBox( tr( "Disable channel activity indicators" ), @@ -472,6 +473,13 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : connect( manual_ch_piano, SIGNAL( toggled( bool ) ), this, SLOT( toggleManualChPiano( bool ) ) ); + ledCheckBox * smoothScroll = new ledCheckBox( + tr( "Smooth scroll in Song Editor" ), ui_fx_tw ); + smoothScroll->move( 10, 60 ); + smoothScroll->setChecked( m_smoothScroll ); + connect( smoothScroll, SIGNAL( toggled( bool ) ), + this, SLOT( toggleSmoothScroll( bool ) ) ); + perf_layout->addWidget( ui_fx_tw ); @@ -739,6 +747,8 @@ void setupDialog::accept() QString::number( m_disableChActInd ) ); configManager::inst()->setValue( "ui", "manualchannelpiano", QString::number( m_manualChPiano ) ); + configManager::inst()->setValue( "ui", "smoothscroll", + QString::number( m_smoothScroll ) ); configManager::inst()->setValue( "ui", "oneinstrumenttrackwindow", QString::number( m_oneInstrumentTrackWindow ) ); @@ -897,6 +907,15 @@ void setupDialog::toggleManualChPiano( bool _enabled ) +void setupDialog::toggleSmoothScroll( bool _enabled ) +{ + m_smoothScroll = _enabled; +} + + + + + void setupDialog::toggleOneInstrumentTrackWindow( bool _enabled ) { m_oneInstrumentTrackWindow = _enabled; diff --git a/src/gui/song_editor.cpp b/src/gui/song_editor.cpp index 3e7ed2c65..615b25161 100644 --- a/src/gui/song_editor.cpp +++ b/src/gui/song_editor.cpp @@ -38,6 +38,7 @@ #include "song_editor.h" #include "automatable_slider.h" #include "combobox.h" +#include "config_mgr.h" #include "cpuload_widget.h" #include "embed.h" #include "lcd_spinbox.h" @@ -76,7 +77,8 @@ void positionLine::paintEvent( QPaintEvent * _pe ) songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) : trackContainerView( _song ), m_s( _song ), - m_scrollBack( false ) + m_scrollBack( false ), + m_smoothScroll( configManager::inst()->value( "ui", "smoothscroll" ).toInt() ) { _engine_ptr = this; @@ -650,24 +652,31 @@ void songEditor::updateScrollBar( int _len ) -static inline void animateScroll( QScrollBar *scrollBar, int newVal ) +static inline void animateScroll( QScrollBar *scrollBar, int newVal, bool smoothScroll ) { - // do smooth scroll animation using QTimeLine - QTimeLine *t = scrollBar->findChild(); - if( t == NULL ) + if( smoothScroll == false ) { - t = new QTimeLine( 600, scrollBar ); - t->setFrameRange( scrollBar->value(), newVal ); - t->connect( t, SIGNAL( finished() ), SLOT( deleteLater() ) ); - - scrollBar->connect( t, SIGNAL( frameChanged( int ) ), SLOT( setValue( int ) ) ); - - t->start(); + scrollBar->setValue( newVal ); } else { - // smooth scrolling is still active, therefore just update the end frame - t->setEndFrame( newVal ); + // do smooth scroll animation using QTimeLine + QTimeLine *t = scrollBar->findChild(); + if( t == NULL ) + { + t = new QTimeLine( 600, scrollBar ); + t->setFrameRange( scrollBar->value(), newVal ); + t->connect( t, SIGNAL( finished() ), SLOT( deleteLater() ) ); + + scrollBar->connect( t, SIGNAL( frameChanged( int ) ), SLOT( setValue( int ) ) ); + + t->start(); + } + else + { + // smooth scrolling is still active, therefore just update the end frame + t->setEndFrame( newVal ); + } } } @@ -684,7 +693,7 @@ void songEditor::updatePosition( const midiTime & _t ) if( _t > m_currentPosition + w * midiTime::ticksPerTact() / pixelsPerTact() ) { - animateScroll( m_leftRightScroll, _t.getTact() ); + animateScroll( m_leftRightScroll, _t.getTact(), m_smoothScroll ); } else if( _t < m_currentPosition ) { @@ -692,7 +701,7 @@ void songEditor::updatePosition( const midiTime & _t ) (int)( _t - w * midiTime::ticksPerTact() / pixelsPerTact() ), 0 ); - animateScroll( m_leftRightScroll, t.getTact() ); + animateScroll( m_leftRightScroll, t.getTact(), m_smoothScroll ); } m_scrollBack = false; }