Sequencer - Segment type modification code moved to SyncEdit

This commit is contained in:
Emmanuel BENOîT 2017-11-26 09:17:29 +01:00
parent 42e8437692
commit 93aec231c5
3 changed files with 33 additions and 8 deletions

View file

@ -170,3 +170,28 @@ void SyncEditor::SetDuration(
} }
} }
/*----------------------------------------------------------------------------*/
void SyncEditor::SetSegmentType(
T_SyncCurve const& initial ,
const uint32_t segmentIndex ,
const T_SyncSegment::E_SegmentType newType ) noexcept
{
assert( segmentIndex < initial.segments.size( ) );
T_SyncSegment const& iSegment{ initial.segments[ segmentIndex ] };
if ( iSegment.type == newType ) {
return;
}
// Create new curve
T_SyncCurve copy{ initial };
copy.segments[ segmentIndex ].type = newType;
// Create undo entry
auto& undo{ dynamic_cast< T_UndoSyncChanges& >(
Common::Undo( ).add< T_UndoSyncChanges >( ) ) };
undo.curveReplacement( initial , copy );
// Replace curve
Common::Sync( ).setCurve( std::move( copy ) );
}

View file

@ -89,4 +89,10 @@ struct SyncEditor final
uint32_t units , uint32_t units ,
float uSize , float uSize ,
bool scaleCurves ) noexcept; bool scaleCurves ) noexcept;
// Change the type of a segment in a curve.
static void SetSegmentType(
T_SyncCurve const& initial ,
uint32_t segmentIndex ,
T_SyncSegment::E_SegmentType newType ) noexcept;
}; };

View file

@ -1241,14 +1241,8 @@ void T_SyncViewImpl_::displaySegmentWindow( ) noexcept
Text( "%f" , sMax ); Text( "%f" , sMax );
if ( change ) { if ( change ) {
#warning fixme move to syncedit SyncEditor::SetSegmentType( *curve , selSegment ,
T_SyncCurve copy{ *curve }; T_SyncSegment::E_SegmentType( t ) );
copy.segments[ selSegment ].type = T_SyncSegment::E_SegmentType( t );
auto& undo{ dynamic_cast< T_UndoSyncChanges& >(
Common::Undo( ).add< T_UndoSyncChanges >( ) ) };
undo.curveReplacement( *curve , copy );
sync.setCurve( std::move( copy ) );
} }
End( ); End( );