diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index 9035491b3..d95b6f3d2 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -171,7 +171,7 @@ public slots: void openInAutomationEditor(); void objectDestroyed( jo_id_t ); void flipY( int min, int max ); - void flipX( bool visible ); + void flipX( int length = -1 ); private: void cleanObjects(); diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 7571ddfbe..7ab4b5977 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -421,7 +421,7 @@ void AutomationPattern::flipY( int min, int max ) -void AutomationPattern::flipX( bool visible ) +void AutomationPattern::flipX( int length ) { timeMap tempMap; @@ -429,26 +429,65 @@ void AutomationPattern::flipX( bool visible ) float tempValue = 0; int numPoints = 0; - //(iterate+1).key() - iterate.key(); gets the "distance" to the next point - for( int i = 0; ( iterate + i + 1 ) != m_timeMap.end() && ( iterate + i ) != m_timeMap.end() ; i++) { numPoints++; } float realLength = ( iterate + numPoints ).key(); - - for( int i = 0; i <= numPoints; i++ ) + + if ( length != -1 && length != realLength) { - tempValue = valueAt( ( iterate + i ).key() ); + if ( realLength < length ) + { + tempValue = valueAt( ( iterate + numPoints ).key() ); + putValue( MidiTime( length ) , tempValue, false); + numPoints++; + for( int i = 0; i <= numPoints; i++ ) + { + tempValue = valueAt( ( iterate + i ).key() ); + cleanObjects(); + MidiTime newTime = MidiTime( length - ( iterate + i ).key() ); + tempMap[newTime] = tempValue; + } + } + else + { + //for ( int i = 0; ( iterate + i ).key() < length ; i++ ) + //{ + // tempValue = valueAt( ( iterate + i ).key() ); + //} + //putValue( MidiTime( length ) , tempValue, false); + //numPoints++; + for( int i = 0; i <= numPoints; i++ ) + { + tempValue = valueAt( ( iterate + i ).key() ); + cleanObjects(); + MidiTime newTime; - cleanObjects(); - - MidiTime newTime = MidiTime( realLength - ( iterate + i ).key() ); - - tempMap[newTime] = tempValue; + if ( ( iterate + i ).key() <= length ) + { + newTime = MidiTime( length - ( iterate + i ).key() ); + } + else + { + newTime = MidiTime( ( iterate + i ).key() ); + } + tempMap[newTime] = tempValue; + } + } } - + else + { + for( int i = 0; i <= numPoints; i++ ) + { + tempValue = valueAt( ( iterate + i ).key() ); + cleanObjects(); + MidiTime newTime = MidiTime( realLength - ( iterate + i ).key() ); + tempMap[newTime] = tempValue; + } + } + m_timeMap.clear(); m_timeMap = tempMap; diff --git a/src/gui/AutomationEditor.cpp b/src/gui/AutomationEditor.cpp index 3468299b8..2d28bd8f1 100644 --- a/src/gui/AutomationEditor.cpp +++ b/src/gui/AutomationEditor.cpp @@ -2072,7 +2072,7 @@ void AutomationEditor::flipYButtonPressed() void AutomationEditor::flipXButtonPressed() { - m_pattern->flipX( false ); + m_pattern->flipX(); } diff --git a/src/gui/AutomationPatternView.cpp b/src/gui/AutomationPatternView.cpp index 869c1ef82..1c404e6ef 100644 --- a/src/gui/AutomationPatternView.cpp +++ b/src/gui/AutomationPatternView.cpp @@ -158,7 +158,8 @@ void AutomationPatternView::flipY() void AutomationPatternView::flipX() { - m_pat->flipX( true ); + //m_pat->flipX( m_pat->length() ); + m_pat->flipX( m_pat->TrackContentObject::length() ); update(); } @@ -189,10 +190,10 @@ void AutomationPatternView::constructContextMenu( QMenu * _cm ) tr( "Set/clear record" ), this, SLOT( toggleRecording() ) ); _cm->addAction( embed::getIconPixmap( "flip_y" ), - tr( "Flip Y" ), + tr( "Flip Vertically (Visible)" ), this, SLOT( flipY() ) ); _cm->addAction( embed::getIconPixmap( "flip_x" ), - tr( "Flip X" ), + tr( "Flip Horizontally (Visible)" ), this, SLOT( flipX() ) ); if( !m_pat->m_objects.isEmpty() ) {