Fixes flipping visiblesegment horizontally

This commit is contained in:
Spekular
2014-12-23 19:23:35 +01:00
parent bfeced7140
commit ddbf9cd264
4 changed files with 57 additions and 17 deletions

View File

@@ -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();

View File

@@ -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;

View File

@@ -2072,7 +2072,7 @@ void AutomationEditor::flipYButtonPressed()
void AutomationEditor::flipXButtonPressed()
{
m_pattern->flipX( false );
m_pattern->flipX();
}

View File

@@ -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() )
{