Sequencer - Segment type modification code moved to SyncEdit
This commit is contained in:
parent
42e8437692
commit
93aec231c5
3 changed files with 33 additions and 8 deletions
|
@ -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 ) );
|
||||
}
|
||||
|
|
|
@ -89,4 +89,10 @@ struct SyncEditor final
|
|||
uint32_t units ,
|
||||
float uSize ,
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -1241,14 +1241,8 @@ void T_SyncViewImpl_::displaySegmentWindow( ) noexcept
|
|||
Text( "%f" , sMax );
|
||||
|
||||
if ( change ) {
|
||||
#warning fixme move to syncedit
|
||||
T_SyncCurve copy{ *curve };
|
||||
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 ) );
|
||||
SyncEditor::SetSegmentType( *curve , selSegment ,
|
||||
T_SyncSegment::E_SegmentType( t ) );
|
||||
}
|
||||
|
||||
End( );
|
||||
|
|
Loading…
Reference in a new issue