demotool/c-syncedit.hh

99 lines
2.4 KiB
C++
Raw Normal View History

#pragma once
#include "c-sync.hh"
#include "c-undo.hh"
2017-11-22 14:14:49 +01:00
/*= GENERAL STRUCTURE FOR SYNC EDITOR UNDOS ==================================*/
class T_UndoSyncChanges : public A_UndoAction
{
protected:
struct T_CurveChange_
{
T_String inputId;
T_Optional< T_SyncCurve > before;
T_Optional< T_SyncCurve > after;
explicit T_CurveChange_( T_SyncCurve before ) noexcept
: inputId{ before.name } ,
before{ std::move( before ) } ,
after{ }
{}
T_CurveChange_( const bool ,
T_SyncCurve after ) noexcept
: inputId{ after.name } , before{ } ,
after{ std::move( after ) }
{}
T_CurveChange_( T_SyncCurve before ,
T_SyncCurve after ) noexcept
: inputId{ before.name } ,
before{ std::move( before ) } ,
after{ std::move( after ) }
{}
};
T_AutoArray< T_CurveChange_ , 4 , 32 > changes_;
public:
T_UndoSyncChanges( ) noexcept = default;
DEF_MOVE( T_UndoSyncChanges );
NO_COPY( T_UndoSyncChanges );
void undo( ) const noexcept override;
void redo( ) const noexcept override;
T_UndoSyncChanges& curveCreation(
T_SyncCurve curve ) noexcept;
T_UndoSyncChanges& curveDeletion(
T_SyncCurve curve ) noexcept;
T_UndoSyncChanges& curveReplacement(
T_SyncCurve before ,
T_SyncCurve after ) noexcept;
};
2017-11-22 14:14:49 +01:00
/*= DURATION CHANGES =========================================================*/
class T_UndoDurationChanges final : public T_UndoSyncChanges
{
private:
uint32_t unitsBefore_ , unitsAfter_;
float uSizeBefore_ , uSizeAfter_;
public:
T_UndoDurationChanges(
uint32_t units ,
uint32_t oldUnits ,
float unitSize ,
float oldUnitSize ) noexcept;
T_UndoDurationChanges( ) noexcept = delete;
DEF_MOVE( T_UndoDurationChanges );
NO_COPY( T_UndoDurationChanges );
void undo( ) const noexcept override;
void redo( ) const noexcept override;
};
/*= EDITION FUNCTIONS ========================================================*/
struct SyncEditor final
{
// Change the duration of the demo using the specified unit count and
// size. If scaleCurves is true and the unit size has changed, the
// curves' durations will be scaled so that the timings match as
// closely as possible.
static void SetDuration(
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;
2017-11-22 14:14:49 +01:00
};