move timeLine marker in Piano Roll and autoscroll when recording while playing song (closes #2486334) (stable backport)

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms/stable-0.4@2054 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2009-02-19 14:27:42 +00:00
parent 264ad268ba
commit 625c947d7a
3 changed files with 57 additions and 11 deletions

View File

@@ -18,6 +18,8 @@
current play position to use the correct note postitions on NoteOff
events (play position might have wrapped around in the meantime due
to looppoints or end of BB track) (closes #2486299, #2486203)
- move timeLine marker in Piano Roll and autoscroll when recording while
playing song (closes #2486334)
2009-02-14 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>

View File

@@ -135,6 +135,7 @@ protected slots:
void deleteSelectedNotes( void );
void updatePosition( const midiTime & _t );
void updatePositionAccompany( const midiTime & _t );
void zoomingChanged( void );
void quantizeChanged( void );
@@ -184,6 +185,8 @@ private:
pianoRoll( const pianoRoll & );
virtual ~pianoRoll();
void autoScroll( const midiTime & _t );
midiTime newNoteLen( void ) const;
void shiftPos(int amount);

View File

@@ -236,6 +236,17 @@ pianoRoll::pianoRoll( void ) :
connect( m_timeLine, SIGNAL( positionChanged( const midiTime & ) ),
this, SLOT( updatePosition( const midiTime & ) ) );
// update timeline when in record-accompany mode
connect( engine::getSong()->getPlayPos( song::Mode_PlaySong ).m_timeLine,
SIGNAL( positionChanged( const midiTime & ) ),
this,
SLOT( updatePositionAccompany( const midiTime & ) ) );
// TODO
/* connect( engine::getSong()->getPlayPos( song::Mode_PlayBB ).m_timeLine,
SIGNAL( positionChanged( const midiTime & ) ),
this,
SLOT( updatePositionAccompany( const midiTime & ) ) );*/
m_toolBar = new QWidget( this );
m_toolBar->setFixedHeight( 32 );
@@ -3436,6 +3447,27 @@ void pianoRoll::deleteSelectedNotes( void )
void pianoRoll::autoScroll( const midiTime & _t )
{
const int w = width() - WHITE_KEY_WIDTH;
if( _t > m_currentPosition + w * midiTime::ticksPerTact() / m_ppt )
{
m_leftRightScroll->setValue( _t.getTact() *
midiTime::ticksPerTact() );
}
else if( _t < m_currentPosition )
{
midiTime t = qMax( _t - w * midiTime::ticksPerTact() *
midiTime::ticksPerTact() / m_ppt, 0 );
m_leftRightScroll->setValue( t.getTact() *
midiTime::ticksPerTact() );
}
m_scrollBack = false;
}
void pianoRoll::updatePosition( const midiTime & _t )
{
if( ( engine::getSong()->isPlaying() &&
@@ -3444,21 +3476,30 @@ void pianoRoll::updatePosition( const midiTime & _t )
m_timeLine->autoScroll() == timeLine::AutoScrollEnabled ) ||
m_scrollBack == true )
{
const int w = width() - WHITE_KEY_WIDTH;
if( _t > m_currentPosition + w * midiTime::ticksPerTact() /
m_ppt )
autoScroll( _t );
}
}
void pianoRoll::updatePositionAccompany( const midiTime & _t )
{
song * s = engine::getSong();
if( m_recording && validPattern() &&
s->playMode() != song::Mode_PlayPattern )
{
midiTime pos = _t;
if( s->playMode() != song::Mode_PlayBB )
{
m_leftRightScroll->setValue( _t.getTact() *
midiTime::ticksPerTact() );
pos -= m_pattern->startPosition();
}
else if( _t < m_currentPosition )
if( (int) pos > 0 )
{
midiTime t = qMax( _t - w * midiTime::ticksPerTact() *
midiTime::ticksPerTact() / m_ppt, 0 );
m_leftRightScroll->setValue( t.getTact() *
midiTime::ticksPerTact() );
s->getPlayPos( song::Mode_PlayPattern ).setTicks( pos );
autoScroll( pos );
}
m_scrollBack = false;
}
}