Merge remote-tracking branch 'origin/stable-1.1'

Conflicts:
	data/locale/zh.ts
	src/tracks/Pattern.cpp
This commit is contained in:
Tobias Doerffel
2014-09-30 22:53:24 +02:00
55 changed files with 183 additions and 178 deletions

View File

@@ -27,7 +27,7 @@
#include "bb_track.h"
#include "engine.h"
#include "InstrumentTrack.h"
#include "pattern.h"
#include "Pattern.h"
#include "SampleBuffer.h"
#include "SampleTrack.h"

View File

@@ -27,7 +27,7 @@
#include "bb_track.h"
#include "engine.h"
#include "InstrumentTrack.h"
#include "pattern.h"
#include "Pattern.h"
#include "SampleBuffer.h"
#include "SampleTrack.h"

View File

@@ -35,7 +35,7 @@
#include "ladspa_2_lmms.h"
#include "MainWindow.h"
#include "Mixer.h"
#include "pattern.h"
#include "Pattern.h"
#include "PianoRoll.h"
#include "PresetPreviewPlayHandle.h"
#include "ProjectJournal.h"

View File

@@ -51,7 +51,7 @@
#include "MidiClient.h"
#include "DataFile.h"
#include "NotePlayHandle.h"
#include "pattern.h"
#include "Pattern.h"
#include "PianoRoll.h"
#include "ProjectJournal.h"
#include "project_notes.h"
@@ -473,14 +473,14 @@ void song::playBB()
void song::playPattern( pattern * _patternToPlay, bool _loop )
void song::playPattern( Pattern* patternToPlay, bool _loop )
{
if( isStopped() == false )
{
stop();
}
m_patternToPlay = _patternToPlay;
m_patternToPlay = patternToPlay;
m_loopPattern = _loop;
if( m_patternToPlay != NULL )

View File

@@ -1932,7 +1932,7 @@ void AutomationEditor::play()
if( engine::getSong()->playMode() != song::Mode_PlayPattern )
{
engine::getSong()->stop();
engine::getSong()->playPattern( (pattern *) engine::pianoRoll()->currentPattern() );
engine::getSong()->playPattern( (Pattern *) engine::pianoRoll()->currentPattern() );
}
else if( engine::getSong()->isStopped() == false )
{
@@ -1940,7 +1940,7 @@ void AutomationEditor::play()
}
else
{
engine::getSong()->playPattern( (pattern *) engine::pianoRoll()->currentPattern() );
engine::getSong()->playPattern( (Pattern *) engine::pianoRoll()->currentPattern() );
}
}
else if( inBBEditor() )

View File

@@ -58,7 +58,7 @@
#include "MainWindow.h"
#include "MidiEvent.h"
#include "DataFile.h"
#include "pattern.h"
#include "Pattern.h"
#include "Piano.h"
#include "pixmap_button.h"
#include "song.h"
@@ -787,19 +787,27 @@ PianoRoll::~PianoRoll()
}
void PianoRoll::setCurrentPattern( pattern * _new_pattern )
void PianoRoll::setCurrentPattern( Pattern* newPattern )
{
if( validPattern() )
if( hasValidPattern() )
{
m_pattern->instrumentTrack()->disconnect( this );
}
m_pattern = _new_pattern;
// force the song-editor to stop playing if it played pattern before
if( engine::getSong()->isPlaying() &&
engine::getSong()->playMode() == song::Mode_PlayPattern )
{
engine::getSong()->playPattern( NULL );
}
// set new data
m_pattern = newPattern;
m_currentPosition = 0;
m_currentNote = NULL;
m_startKey = INITIAL_START_KEY;
if( validPattern() == false )
if( hasValidPattern() == false )
{
//resizeEvent( NULL );
setWindowTitle( tr( "Piano-Roll - no pattern" ) );
@@ -840,6 +848,9 @@ void PianoRoll::setCurrentPattern( pattern * _new_pattern )
// of start-notes and so on...)
resizeEvent( NULL );
// make sure to always get informed about the pattern being destroyed
connect( m_pattern, SIGNAL( destroyedPattern( Pattern* ) ), this, SLOT( hidePattern( Pattern* ) ) );
connect( m_pattern->instrumentTrack(), SIGNAL( midiNoteOn( const note& ) ), this, SLOT( startRecordNote( const note& ) ) );
connect( m_pattern->instrumentTrack(), SIGNAL( midiNoteOff( const note& ) ), this, SLOT( finishRecordNote( const note& ) ) );
connect( m_pattern->instrumentTrack()->pianoModel(), SIGNAL( dataChanged() ), this, SLOT( update() ) );
@@ -852,6 +863,15 @@ void PianoRoll::setCurrentPattern( pattern * _new_pattern )
void PianoRoll::hidePattern( Pattern* pattern )
{
if( m_pattern == pattern )
{
setCurrentPattern( NULL );
}
}
void PianoRoll::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
@@ -1192,7 +1212,7 @@ int PianoRoll::selectionCount() const // how many notes are selected?
void PianoRoll::keyPressEvent( QKeyEvent* event )
{
if( validPattern() && event->modifiers() == Qt::NoModifier )
if( hasValidPattern() && event->modifiers() == Qt::NoModifier )
{
const int key_num = PianoView::getKeyFromKeyEvent( event ) + ( DefaultOctave - 1 ) * KeysPerOctave;
@@ -1468,7 +1488,7 @@ void PianoRoll::keyPressEvent( QKeyEvent* event )
void PianoRoll::keyReleaseEvent( QKeyEvent* event )
{
if( validPattern() && event->modifiers() == Qt::NoModifier )
if( hasValidPattern() && event->modifiers() == Qt::NoModifier )
{
const int key_num = PianoView::getKeyFromKeyEvent( event ) + ( DefaultOctave - 1 ) * KeysPerOctave;
@@ -1490,7 +1510,7 @@ void PianoRoll::keyReleaseEvent( QKeyEvent* event )
// update after undo/redo
case Qt::Key_Z:
case Qt::Key_R:
if( validPattern() && event->modifiers() == Qt::ControlModifier )
if( hasValidPattern() && event->modifiers() == Qt::ControlModifier )
{
update();
}
@@ -1570,7 +1590,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me )
{
m_startedWithShift = _me->modifiers() & Qt::ShiftModifier;
if( validPattern() == false )
if( hasValidPattern() == false )
{
return;
}
@@ -1684,7 +1704,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me )
{
is_new_note = true;
m_pattern->addJournalCheckPoint();
m_pattern->setType( pattern::MelodyPattern );
m_pattern->setType( Pattern::MelodyPattern );
// then set new note
@@ -1952,7 +1972,7 @@ void PianoRoll::mousePressEvent( QMouseEvent * _me )
void PianoRoll::mouseDoubleClickEvent( QMouseEvent * _me )
{
if( validPattern() == false )
if( hasValidPattern() == false )
{
return;
}
@@ -2114,7 +2134,7 @@ void PianoRoll::computeSelectedNotes(bool shift)
}
//int y_base = noteEditTop() - 1;
if( validPattern() == true )
if( hasValidPattern() == true )
{
const NoteVector & notes = m_pattern->notes();
@@ -2216,7 +2236,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * _me )
}
if( validPattern() == true )
if( hasValidPattern() == true )
{
// turn off all notes that are playing
const NoteVector & notes = m_pattern->notes();
@@ -2257,7 +2277,7 @@ void PianoRoll::mouseReleaseEvent( QMouseEvent * _me )
void PianoRoll::mouseMoveEvent( QMouseEvent * _me )
{
if( validPattern() == false )
if( hasValidPattern() == false )
{
update();
return;
@@ -3011,7 +3031,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe )
if( prKeyOrder[key % KeysPerOctave] == PR_WHITE_KEY_SMALL )
{
// draw a small one while checking if it is pressed or not
if( validPattern() && m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
if( hasValidPattern() && m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
{
p.drawPixmap( PIANO_X, y - WHITE_KEY_SMALL_HEIGHT, *s_whiteKeySmallPressedPm );
}
@@ -3027,7 +3047,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe )
PR_WHITE_KEY_BIG )
{
// draw a big one while checking if it is pressed or not
if( validPattern() && m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
if( hasValidPattern() && m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
{
p.drawPixmap( PIANO_X, y - WHITE_KEY_BIG_HEIGHT, *s_whiteKeyBigPressedPm );
}
@@ -3100,7 +3120,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe )
// then draw it (calculation of y very complicated,
// but that's the only working solution, sorry...)
// check if the key is pressed or not
if( validPattern() && m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
if( hasValidPattern() && m_pattern->instrumentTrack()->pianoModel()->isKeyPressed( key ) )
{
p.drawPixmap( PIANO_X, y - ( first_white_key_height -
WHITE_KEY_SMALL_HEIGHT ) -
@@ -3237,7 +3257,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe )
}
int y_base = keyAreaBottom() - 1;
if( validPattern() == true )
if( hasValidPattern() == true )
{
p.setClipRect( WHITE_KEY_WIDTH, PR_TOP_MARGIN,
width() - WHITE_KEY_WIDTH,
@@ -3371,7 +3391,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe )
p.drawRect( x + WHITE_KEY_WIDTH, y, w, h );
// TODO: Get this out of paint event
int l = ( validPattern() == true )? (int) m_pattern->length() : 0;
int l = ( hasValidPattern() == true )? (int) m_pattern->length() : 0;
// reset scroll-range
if( m_leftRightScroll->maximum() != l )
@@ -3384,7 +3404,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe )
horizCol.setAlpha( 64 );
// horizontal line for the key under the cursor
if( validPattern() == true )
if( hasValidPattern() == true )
{
int key_num = getKey( mapFromGlobal( QCursor::pos() ).y() );
p.fillRect( 10, keyAreaBottom() + 3 - KEY_LINE_HEIGHT *
@@ -3640,7 +3660,7 @@ song::PlayModes PianoRoll::desiredPlayModeForAccompany() const
void PianoRoll::play()
{
if( validPattern() == false )
if( hasValidPattern() == false )
{
return;
}
@@ -3664,7 +3684,7 @@ void PianoRoll::record()
{
stop();
}
if( m_recording == true || validPattern() == false )
if( m_recording == true || hasValidPattern() == false )
{
return;
}
@@ -3683,7 +3703,7 @@ void PianoRoll::recordAccompany()
{
stop();
}
if( m_recording == true || validPattern() == false )
if( m_recording == true || hasValidPattern() == false )
{
return;
}
@@ -3716,7 +3736,7 @@ void PianoRoll::stop()
void PianoRoll::startRecordNote( const note & _n )
{
if( m_recording == true && validPattern() == true &&
if( m_recording == true && hasValidPattern() == true &&
engine::getSong()->isPlaying() &&
( engine::getSong()->playMode() ==
desiredPlayModeForAccompany() ||
@@ -3743,7 +3763,7 @@ void PianoRoll::startRecordNote( const note & _n )
void PianoRoll::finishRecordNote( const note & _n )
{
if( m_recording == true && validPattern() == true &&
if( m_recording == true && hasValidPattern() == true &&
engine::getSong()->isPlaying() &&
( engine::getSong()->playMode() ==
desiredPlayModeForAccompany() ||
@@ -3828,7 +3848,7 @@ void PianoRoll::detuneButtonToggled()
void PianoRoll::selectAll()
{
if( validPattern() == false )
if( hasValidPattern() == false )
{
return;
}
@@ -3886,7 +3906,7 @@ void PianoRoll::selectAll()
// returns vector with pointers to all selected notes
void PianoRoll::getSelectedNotes( NoteVector & _selected_notes )
{
if( validPattern() == false )
if( hasValidPattern() == false )
{
return;
}
@@ -3989,7 +4009,7 @@ void PianoRoll::copySelectedNotes()
void PianoRoll::cutSelectedNotes()
{
if( validPattern() == false )
if( hasValidPattern() == false )
{
return;
}
@@ -4021,7 +4041,7 @@ void PianoRoll::cutSelectedNotes()
void PianoRoll::pasteNotes()
{
if( validPattern() == false )
if( hasValidPattern() == false )
{
return;
}
@@ -4073,7 +4093,7 @@ void PianoRoll::pasteNotes()
void PianoRoll::deleteSelectedNotes()
{
if( validPattern() == false )
if( hasValidPattern() == false )
{
return;
}
@@ -4156,7 +4176,7 @@ void PianoRoll::updatePositionAccompany( const MidiTime & _t )
{
song * s = engine::getSong();
if( m_recording && validPattern() &&
if( m_recording && hasValidPattern() &&
s->playMode() != song::Mode_PlayPattern )
{
MidiTime pos = _t;
@@ -4248,7 +4268,7 @@ MidiTime PianoRoll::newNoteLen() const
bool PianoRoll::mouseOverNote()
{
return validPattern() && noteUnderMouse() != NULL;
return hasValidPattern() && noteUnderMouse() != NULL;
}

View File

@@ -39,7 +39,7 @@
#include "string_pair_drag.h"
#include "TrackContainer.h"
#include "pattern.h"
#include "Pattern.h"
@@ -256,8 +256,7 @@ void bbEditor::addSteps()
{
if( ( *it )->type() == track::InstrumentTrack )
{
pattern * p = static_cast<pattern *>(
( *it )->getTCO( m_bbtc->currentBB() ) );
Pattern* p = static_cast<Pattern *>( ( *it )->getTCO( m_bbtc->currentBB() ) );
p->addSteps();
}
}
@@ -275,8 +274,7 @@ void bbEditor::removeSteps()
{
if( ( *it )->type() == track::InstrumentTrack )
{
pattern * p = static_cast<pattern *>(
( *it )->getTCO( m_bbtc->currentBB() ) );
Pattern* p = static_cast<Pattern *>( ( *it )->getTCO( m_bbtc->currentBB() ) );
p->removeSteps();
}
}

View File

@@ -68,7 +68,7 @@
#include "MixHelpers.h"
#include "DataFile.h"
#include "NotePlayHandle.h"
#include "pattern.h"
#include "Pattern.h"
#include "PluginView.h"
#include "SamplePlayHandle.h"
#include "song.h"
@@ -514,7 +514,7 @@ void InstrumentTrack::setName( const QString & _new_name )
// which have the same name as the instrument-track
for( int i = 0; i < numOfTCOs(); ++i )
{
pattern * p = dynamic_cast<pattern *>( getTCO( i ) );
Pattern* p = dynamic_cast<Pattern*>( getTCO( i ) );
if( ( p != NULL && p->name() == name() ) || p->name() == "" )
{
p->setName( _new_name );
@@ -630,7 +630,7 @@ bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames,
for( tcoVector::Iterator it = tcos.begin(); it != tcos.end(); ++it )
{
pattern * p = dynamic_cast<pattern *>( *it );
Pattern* p = dynamic_cast<Pattern*>( *it );
// everything which is not a pattern or muted won't be played
if( p == NULL || ( *it )->isMuted() )
{
@@ -695,7 +695,7 @@ bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames,
trackContentObject * InstrumentTrack::createTCO( const MidiTime & )
{
return new pattern( this );
return new Pattern( this );
}

View File

@@ -33,7 +33,7 @@
#include <QPushButton>
#include <QtAlgorithms>
#include "pattern.h"
#include "Pattern.h"
#include "InstrumentTrack.h"
#include "templates.h"
#include "gui_templates.h"
@@ -51,14 +51,14 @@
#include "MainWindow.h"
QPixmap * patternView::s_stepBtnOn = NULL;
QPixmap * patternView::s_stepBtnOverlay = NULL;
QPixmap * patternView::s_stepBtnOff = NULL;
QPixmap * patternView::s_stepBtnOffLight = NULL;
QPixmap * PatternView::s_stepBtnOn = NULL;
QPixmap * PatternView::s_stepBtnOverlay = NULL;
QPixmap * PatternView::s_stepBtnOff = NULL;
QPixmap * PatternView::s_stepBtnOffLight = NULL;
pattern::pattern( InstrumentTrack * _instrument_track ) :
Pattern::Pattern( InstrumentTrack * _instrument_track ) :
trackContentObject( _instrument_track ),
m_instrumentTrack( _instrument_track ),
m_patternType( BeatPattern ),
@@ -71,14 +71,13 @@ pattern::pattern( InstrumentTrack * _instrument_track ) :
pattern::pattern( const pattern & _pat_to_copy ) :
trackContentObject( _pat_to_copy.m_instrumentTrack ),
m_instrumentTrack( _pat_to_copy.m_instrumentTrack ),
m_patternType( _pat_to_copy.m_patternType ),
m_steps( _pat_to_copy.m_steps )
Pattern::Pattern( const Pattern& other ) :
trackContentObject( other.m_instrumentTrack ),
m_instrumentTrack( other.m_instrumentTrack ),
m_patternType( other.m_patternType ),
m_steps( other.m_steps )
{
for( NoteVector::ConstIterator it = _pat_to_copy.m_notes.begin();
it != _pat_to_copy.m_notes.end(); ++it )
for( NoteVector::ConstIterator it = other.m_notes.begin(); it != other.m_notes.end(); ++it )
{
m_notes.push_back( new note( **it ) );
}
@@ -87,8 +86,10 @@ pattern::pattern( const pattern & _pat_to_copy ) :
}
pattern::~pattern()
Pattern::~Pattern()
{
emit destroyedPattern( this );
for( NoteVector::Iterator it = m_notes.begin();
it != m_notes.end(); ++it )
{
@@ -101,7 +102,7 @@ pattern::~pattern()
void pattern::init()
void Pattern::init()
{
connect( engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ),
this, SLOT( changeTimeSignature() ) );
@@ -116,7 +117,7 @@ void pattern::init()
MidiTime pattern::length() const
MidiTime Pattern::length() const
{
if( m_patternType == BeatPattern )
{
@@ -141,7 +142,7 @@ MidiTime pattern::length() const
MidiTime pattern::beatPatternLength() const
MidiTime Pattern::beatPatternLength() const
{
tick_t max_length = MidiTime::ticksPerTact();
@@ -166,7 +167,7 @@ MidiTime pattern::beatPatternLength() const
return MidiTime( max_length ).nextFullTact() * MidiTime::ticksPerTact();
}
note * pattern::addNote( const note & _new_note, const bool _quant_pos )
note * Pattern::addNote( const note & _new_note, const bool _quant_pos )
{
note * new_note = new note( _new_note );
if( _quant_pos && engine::pianoRoll() )
@@ -212,7 +213,7 @@ note * pattern::addNote( const note & _new_note, const bool _quant_pos )
void pattern::removeNote( const note * _note_to_del )
void Pattern::removeNote( const note * _note_to_del )
{
instrumentTrack()->lock();
NoteVector::Iterator it = m_notes.begin();
@@ -239,7 +240,7 @@ void pattern::removeNote( const note * _note_to_del )
// returns a pointer to the note at specified step, or NULL if note doesn't exist
note * pattern::noteAtStep( int _step )
note * Pattern::noteAtStep( int _step )
{
for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end();
++it )
@@ -253,7 +254,7 @@ note * pattern::noteAtStep( int _step )
}
note * pattern::rearrangeNote( const note * _note_to_proc,
note * Pattern::rearrangeNote( const note * _note_to_proc,
const bool _quant_pos )
{
// just rearrange the position of the note by removing it and adding
@@ -266,7 +267,7 @@ note * pattern::rearrangeNote( const note * _note_to_proc,
void pattern::rearrangeAllNotes()
void Pattern::rearrangeAllNotes()
{
// sort notes by start time
qSort(m_notes.begin(), m_notes.end(), note::lessThan );
@@ -274,7 +275,7 @@ void pattern::rearrangeAllNotes()
void pattern::clearNotes()
void Pattern::clearNotes()
{
instrumentTrack()->lock();
for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end();
@@ -292,7 +293,7 @@ void pattern::clearNotes()
void pattern::setStep( int _step, bool _enabled )
void Pattern::setStep( int _step, bool _enabled )
{
for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end();
++it )
@@ -309,7 +310,7 @@ void pattern::setStep( int _step, bool _enabled )
void pattern::setType( PatternTypes _new_pattern_type )
void Pattern::setType( PatternTypes _new_pattern_type )
{
if( _new_pattern_type == BeatPattern ||
_new_pattern_type == MelodyPattern )
@@ -321,25 +322,25 @@ void pattern::setType( PatternTypes _new_pattern_type )
void pattern::checkType()
void Pattern::checkType()
{
NoteVector::Iterator it = m_notes.begin();
while( it != m_notes.end() )
{
if( ( *it )->length() > 0 )
{
setType( pattern::MelodyPattern );
setType( Pattern::MelodyPattern );
return;
}
++it;
}
setType( pattern::BeatPattern );
setType( Pattern::BeatPattern );
}
void pattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
void Pattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setAttribute( "type", m_patternType );
_this.setAttribute( "name", name() );
@@ -373,7 +374,7 @@ void pattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
void pattern::loadSettings( const QDomElement & _this )
void Pattern::loadSettings( const QDomElement & _this )
{
m_patternType = static_cast<PatternTypes>( _this.attribute( "type"
).toInt() );
@@ -420,7 +421,7 @@ void pattern::loadSettings( const QDomElement & _this )
void pattern::clear()
void Pattern::clear()
{
addJournalCheckPoint();
clearNotes();
@@ -430,7 +431,7 @@ void pattern::clear()
void pattern::addSteps()
void Pattern::addSteps()
{
m_steps += MidiTime::stepsPerTact();
ensureBeatNotes();
@@ -441,7 +442,7 @@ void pattern::addSteps()
void pattern::removeSteps()
void Pattern::removeSteps()
{
int _n = MidiTime::stepsPerTact();
if( _n < m_steps )
@@ -470,16 +471,16 @@ void pattern::removeSteps()
trackContentObjectView * pattern::createView( trackView * _tv )
trackContentObjectView * Pattern::createView( trackView * _tv )
{
return new patternView( this, _tv );
return new PatternView( this, _tv );
}
void pattern::ensureBeatNotes()
void Pattern::ensureBeatNotes()
{
// make sure, that all step-note exist
for( int i = 0; i < m_steps; ++i )
@@ -531,7 +532,7 @@ void pattern::ensureBeatNotes()
void pattern::updateBBTrack()
void Pattern::updateBBTrack()
{
if( getTrack()->trackContainer() == engine::getBBTrackContainer() )
{
@@ -547,7 +548,7 @@ void pattern::updateBBTrack()
bool pattern::empty()
bool Pattern::empty()
{
for( NoteVector::ConstIterator it = m_notes.begin();
it != m_notes.end(); ++it )
@@ -563,7 +564,7 @@ bool pattern::empty()
void pattern::changeTimeSignature()
void Pattern::changeTimeSignature()
{
MidiTime last_pos = MidiTime::ticksPerTact();
for( NoteVector::ConstIterator cit = m_notes.begin();
@@ -600,9 +601,9 @@ void pattern::changeTimeSignature()
patternView::patternView( pattern * _pattern, trackView * _parent ) :
trackContentObjectView( _pattern, _parent ),
m_pat( _pattern ),
PatternView::PatternView( Pattern* pattern, trackView* parent ) :
trackContentObjectView( pattern, parent ),
m_pat( pattern ),
m_paintPixmap(),
m_needsUpdate( true )
{
@@ -647,29 +648,15 @@ patternView::patternView( pattern * _pattern, trackView * _parent ) :
patternView::~patternView()
PatternView::~PatternView()
{
if( engine::pianoRoll()->currentPattern() == m_pat )
{
engine::pianoRoll()->disconnect( this );
engine::pianoRoll()->setCurrentPattern( NULL );
// we have to have the song-editor to stop playing if it played
// us before
if( engine::getSong()->isPlaying() &&
engine::getSong()->playMode() ==
song::Mode_PlayPattern )
{
engine::getSong()->playPattern( NULL );
}
}
}
void patternView::update()
void PatternView::update()
{
m_needsUpdate = true;
m_pat->changeLength( m_pat->length() );
@@ -679,7 +666,7 @@ void patternView::update()
void patternView::openInPianoRoll()
void PatternView::openInPianoRoll()
{
engine::pianoRoll()->setCurrentPattern( m_pat );
engine::pianoRoll()->parentWidget()->show();
@@ -689,7 +676,7 @@ void patternView::openInPianoRoll()
void patternView::resetName()
void PatternView::resetName()
{
m_pat->setName( m_pat->m_instrumentTrack->name() );
}
@@ -697,7 +684,7 @@ void patternView::resetName()
void patternView::changeName()
void PatternView::changeName()
{
QString s = m_pat->name();
renameDialog rename_dlg( s );
@@ -708,7 +695,7 @@ void patternView::changeName()
void patternView::constructContextMenu( QMenu * _cm )
void PatternView::constructContextMenu( QMenu * _cm )
{
QAction * a = new QAction( embed::getIconPixmap( "piano" ),
tr( "Open in piano-roll" ), _cm );
@@ -739,15 +726,15 @@ void patternView::constructContextMenu( QMenu * _cm )
void patternView::mouseDoubleClickEvent( QMouseEvent * _me )
void PatternView::mouseDoubleClickEvent( QMouseEvent * _me )
{
if( _me->button() != Qt::LeftButton )
{
_me->ignore();
return;
}
if( m_pat->type() == pattern::MelodyPattern ||
!( m_pat->type() == pattern::BeatPattern &&
if( m_pat->type() == Pattern::MelodyPattern ||
!( m_pat->type() == Pattern::BeatPattern &&
( pixelsPerTact() >= 192 ||
m_pat->m_steps != MidiTime::stepsPerTact() ) &&
_me->y() > height() - s_stepBtnOff->height() ) )
@@ -759,10 +746,10 @@ void patternView::mouseDoubleClickEvent( QMouseEvent * _me )
void patternView::mousePressEvent( QMouseEvent * _me )
void PatternView::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton &&
m_pat->m_patternType == pattern::BeatPattern &&
m_pat->m_patternType == Pattern::BeatPattern &&
( fixedTCOs() || pixelsPerTact() >= 96 ||
m_pat->m_steps != MidiTime::stepsPerTact() ) &&
_me->y() > height() - s_stepBtnOff->height() )
@@ -831,9 +818,9 @@ void patternView::mousePressEvent( QMouseEvent * _me )
void patternView::wheelEvent( QWheelEvent * _we )
void PatternView::wheelEvent( QWheelEvent * _we )
{
if( m_pat->m_patternType == pattern::BeatPattern &&
if( m_pat->m_patternType == Pattern::BeatPattern &&
( fixedTCOs() || pixelsPerTact() >= 96 ||
m_pat->m_steps != MidiTime::stepsPerTact() ) &&
_we->y() > height() - s_stepBtnOff->height() )
@@ -891,7 +878,7 @@ void patternView::wheelEvent( QWheelEvent * _we )
void patternView::paintEvent( QPaintEvent * )
void PatternView::paintEvent( QPaintEvent * )
{
if( m_needsUpdate == false )
{
@@ -918,14 +905,14 @@ void patternView::paintEvent( QPaintEvent * )
QColor c;
if(( m_pat->m_patternType != pattern::BeatPattern ) &&
if(( m_pat->m_patternType != Pattern::BeatPattern ) &&
!( m_pat->getTrack()->isMuted() || m_pat->isMuted() ))
c = isSelected() ? QColor( 0, 0, 224 )
: styleColor;
else
c = QColor( 80, 80, 80 );
if( m_pat->m_patternType != pattern::BeatPattern )
if( m_pat->m_patternType != Pattern::BeatPattern )
{
lingrad.setColorAt( 1, c.darker( 300 ) );
lingrad.setColorAt( 0, c );
@@ -937,14 +924,14 @@ void patternView::paintEvent( QPaintEvent * )
}
p.setBrush( lingrad );
if( engine::pianoRoll()->currentPattern() == m_pat && m_pat->m_patternType != pattern::BeatPattern )
if( engine::pianoRoll()->currentPattern() == m_pat && m_pat->m_patternType != Pattern::BeatPattern )
p.setPen( c.lighter( 130 ) );
else
p.setPen( c.darker( 300 ) );
p.drawRect( QRect( 0, 0, width() - 1, height() - 1 ) );
p.setBrush( QBrush() );
if( m_pat->m_patternType != pattern::BeatPattern )
if( m_pat->m_patternType != Pattern::BeatPattern )
{
if( engine::pianoRoll()->currentPattern() == m_pat )
p.setPen( c.lighter( 160 ) );
@@ -974,7 +961,7 @@ void patternView::paintEvent( QPaintEvent * )
// melody pattern paint event
if( m_pat->m_patternType == pattern::MelodyPattern )
if( m_pat->m_patternType == Pattern::MelodyPattern )
{
if( m_pat->m_notes.size() > 0 )
{
@@ -1064,7 +1051,7 @@ void patternView::paintEvent( QPaintEvent * )
// beat pattern paint event
else if( m_pat->m_patternType == pattern::BeatPattern &&
else if( m_pat->m_patternType == Pattern::BeatPattern &&
( fixedTCOs() || ppt >= 96
|| m_pat->m_steps != MidiTime::stepsPerTact() ) )
{
@@ -1159,8 +1146,3 @@ void patternView::paintEvent( QPaintEvent * )
}