Proposed fix for 446, select notes in piano roll using timeline

This commit is contained in:
Dave French
2015-01-22 20:16:00 +00:00
parent 786e7dd389
commit 2be8eaa4db
2 changed files with 44 additions and 0 deletions

View File

@@ -160,6 +160,8 @@ protected slots:
void hidePattern( Pattern* pattern );
void selectRegionFromPixels( int x, int y );
signals:
void currentPatternChanged();

View File

@@ -417,6 +417,10 @@ PianoRoll::PianoRoll() :
connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ),
this, SLOT( update() ) );
//connection for selecion from timeline
connect( m_timeLine, SIGNAL( regionSelectedFromPixels( int, int ) ),
this, SLOT( selectRegionFromPixels( int, int ) ) );
}
@@ -589,6 +593,44 @@ void PianoRoll::hidePattern( Pattern* pattern )
}
}
void PianoRoll::selectRegionFromPixels(int x, int y)
{
x -= WHITE_KEY_WIDTH;
y -= WHITE_KEY_WIDTH;
// select an area of notes
int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt +
m_currentPosition;
int key_num = 0;
m_selectStartTick = pos_ticks;
m_selectedTick = 0;
m_selectStartKey = key_num;
m_selectedKeys = 1;
// change size of selection
// get tick in which the cursor is posated
pos_ticks = y * MidiTime::ticksPerTact() / m_ppt +
m_currentPosition;
key_num = 120;
m_selectedTick = pos_ticks - m_selectStartTick;
if( (int) m_selectStartTick + m_selectedTick < 0 )
{
m_selectedTick = -static_cast<int>(
m_selectStartTick );
}
m_selectedKeys = key_num - m_selectStartKey;
if( key_num <= m_selectStartKey )
{
--m_selectedKeys;
}
computeSelectedNotes( false );
}