SongEditor: made smoooth scrolling an optional feature

As smooth scrolling seems to cause problems for some users it now has
to be enabled explicitely in the settings dialog.

Closes #3194891.
This commit is contained in:
Tobias Doerffel
2011-03-17 09:23:38 +01:00
parent dd9ba4b2ad
commit a90ffed0a8
4 changed files with 49 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
/*
* setup_dialog.h - dialog for setting up LMMS
*
* Copyright (c) 2005-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2011 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* 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<QString, AudioDevice::setupWidget *> AswMap;

View File

@@ -129,6 +129,7 @@ private:
positionLine * m_positionLine;
bool m_scrollBack;
bool m_smoothScroll;
} ;

View File

@@ -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;

View File

@@ -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<QTimeLine *>();
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<QTimeLine *>();
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;
}