From 2be8eaa4db77f254beb08995591af8636d4165b6 Mon Sep 17 00:00:00 2001 From: Dave French Date: Thu, 22 Jan 2015 20:16:00 +0000 Subject: [PATCH 1/2] Proposed fix for 446, select notes in piano roll using timeline --- include/PianoRoll.h | 2 ++ src/gui/editors/PianoRoll.cpp | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 8f1dabdc3..98e074619 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -160,6 +160,8 @@ protected slots: void hidePattern( Pattern* pattern ); + void selectRegionFromPixels( int x, int y ); + signals: void currentPatternChanged(); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 366920df7..679da308c 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -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( + m_selectStartTick ); + } + m_selectedKeys = key_num - m_selectStartKey; + if( key_num <= m_selectStartKey ) + { + --m_selectedKeys; + } + + computeSelectedNotes( false ); +} + + + From e2a2d27bbaf9bdf95dad313a7f4c9d5764d82a82 Mon Sep 17 00:00:00 2001 From: Dave French Date: Sat, 24 Jan 2015 06:30:23 +0000 Subject: [PATCH 2/2] 446 change parameter names --- include/PianoRoll.h | 2 +- src/gui/editors/PianoRoll.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 98e074619..6260eaa7e 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -160,7 +160,7 @@ protected slots: void hidePattern( Pattern* pattern ); - void selectRegionFromPixels( int x, int y ); + void selectRegionFromPixels( int xStart, int xEnd ); signals: diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 679da308c..0d3540975 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -593,14 +593,14 @@ void PianoRoll::hidePattern( Pattern* pattern ) } } -void PianoRoll::selectRegionFromPixels(int x, int y) +void PianoRoll::selectRegionFromPixels( int xStart, int xEnd ) { - x -= WHITE_KEY_WIDTH; - y -= WHITE_KEY_WIDTH; + xStart -= WHITE_KEY_WIDTH; + xEnd -= WHITE_KEY_WIDTH; // select an area of notes - int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + + int pos_ticks = xStart * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; int key_num = 0; m_selectStartTick = pos_ticks; @@ -610,7 +610,7 @@ void PianoRoll::selectRegionFromPixels(int x, int y) // change size of selection // get tick in which the cursor is posated - pos_ticks = y * MidiTime::ticksPerTact() / m_ppt + + pos_ticks = xEnd * MidiTime::ticksPerTact() / m_ppt + m_currentPosition; key_num = 120;