Sequencer - Preparing for overrides support

Added a TrackID structure and used it where appropriate.
This commit is contained in:
Emmanuel BENOîT 2017-11-28 16:47:35 +01:00
parent 6557d369eb
commit d32d5e7365

View file

@ -159,11 +159,17 @@ struct T_SyncViewImpl_
bool display( ) noexcept; bool display( ) noexcept;
private: private:
// Track display data // Track identifier
struct T_TrackDisplay struct T_TrackId_
{ {
T_String id; T_String id;
bool isOverride; bool isOverride;
};
// Track display data
struct T_TrackDisplay
{
T_TrackId_ id;
ImRect area; ImRect area;
uint32_t dispSegs; uint32_t dispSegs;
uint32_t firstSeg; uint32_t firstSeg;
@ -315,8 +321,7 @@ struct T_SyncViewImpl_
float curZoomPixel; float curZoomPixel;
// Selected item // Selected item
T_String selId{ }; T_Optional< T_TrackId_ > selId{ };
bool selIsOverride;
T_Optional< uint32_t > selSegment; T_Optional< uint32_t > selSegment;
T_Optional< uint32_t > selPoint; T_Optional< uint32_t > selPoint;
bool selPointDnD{ false }; bool selPointDnD{ false };
@ -460,8 +465,8 @@ void T_SyncViewImpl_::checkSelection( ) noexcept
if ( !selId ) { if ( !selId ) {
return; return;
} }
assert( !selIsOverride ); // XXX assert( !selId->isOverride ); // XXX
auto const* const curve{ Common::Sync( ).getCurve( selId ) }; auto const* const curve{ Common::Sync( ).getCurve( selId->id ) };
// Missing curve // Missing curve
if ( !curve ) { if ( !curve ) {
@ -471,8 +476,8 @@ void T_SyncViewImpl_::checkSelection( ) noexcept
selPoint.clear( ); selPoint.clear( );
} }
// If there's no matching input, unselect the track // If there's no matching input, unselect the track
if ( !Common::Sync( ).hasInput( selId ) ) { if ( !Common::Sync( ).hasInput( selId->id ) ) {
selId = T_String{}; selId.clear( );
} }
} else { } else {
// No segment selected? We're ok. // No segment selected? We're ok.
@ -711,7 +716,6 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
auto const& dTrack{ dspTracks[ mp.index ] }; auto const& dTrack{ dspTracks[ mp.index ] };
if ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) { if ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) {
selId = dTrack.id; selId = dTrack.id;
selIsOverride = dTrack.isOverride;
selSegment = decltype( selSegment ){}; selSegment = decltype( selSegment ){};
selPoint = decltype( selPoint ){}; selPoint = decltype( selPoint ){};
sub = E_SubWindow::SW_TRACK; sub = E_SubWindow::SW_TRACK;
@ -721,7 +725,6 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
auto const& dTrack{ dspTracks[ dSeg.track ] }; auto const& dTrack{ dspTracks[ dSeg.track ] };
if ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) { if ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) {
selId = dTrack.id; selId = dTrack.id;
selIsOverride = dTrack.isOverride;
selSegment = dSeg.seg; selSegment = dSeg.seg;
selPoint = decltype( selPoint ){}; selPoint = decltype( selPoint ){};
sub = E_SubWindow::SW_SEGMENT; sub = E_SubWindow::SW_SEGMENT;
@ -732,14 +735,13 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept
auto const& dTrack{ dspTracks[ dSeg.track ] }; auto const& dTrack{ dspTracks[ dSeg.track ] };
if ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) { if ( io.MouseDown[ 0 ] || io.MouseDown[ 1 ] ) {
selId = dTrack.id; selId = dTrack.id;
selIsOverride = dTrack.isOverride;
selSegment = dSeg.seg; selSegment = dSeg.seg;
selPoint = dPoint.index; selPoint = dPoint.index;
selPointDnD = io.MouseDown[ 0 ] && dPoint.index != 0; selPointDnD = io.MouseDown[ 0 ] && dPoint.index != 0;
if ( selPointDnD ) { if ( selPointDnD ) {
assert( selUpdate == E_ChangeType::NONE ); assert( selUpdate == E_ChangeType::NONE );
selPointDnDStart = selPointDnDCur = mPixels; selPointDnDStart = selPointDnDCur = mPixels;
selUpdatingOriginal = *sync.getCurve( dTrack.id ); // XXX selUpdatingOriginal = *sync.getCurve( selId->id ); // XXX
selUpdate = E_ChangeType::POINT_DND; selUpdate = E_ChangeType::POINT_DND;
} }
sub = E_SubWindow::SW_POINT; sub = E_SubWindow::SW_POINT;
@ -927,15 +929,14 @@ void T_SyncViewImpl_::sequencerTrack(
// Add track display record // Add track display record
const auto dTrackIdx{ dspTracks.size( ) }; const auto dTrackIdx{ dspTracks.size( ) };
auto& dTrack{ dspTracks.addNew( ) }; auto& dTrack{ dspTracks.addNew( ) };
dTrack.id = id; dTrack.id = T_TrackId_{ id , false };
dTrack.isOverride = false;
dTrack.dispSegs = 0; dTrack.dispSegs = 0;
dTrack.firstSeg = dspSegments.size( ); dTrack.firstSeg = dspSegments.size( );
dTrack.area = bb; dTrack.area = bb;
// Compute colors // Compute colors
using namespace ImGui; using namespace ImGui;
const bool sCurve{ selId && !selIsOverride && selId == id }; const bool sCurve{ selId && !selId->isOverride && selId->id == id };
const float scv{ sCurve ? 1.f : .7f }; const float scv{ sCurve ? 1.f : .7f };
const auto bgColor{ ColorHSVAToU32( hue , .25f , scv , .25f ) } , const auto bgColor{ ColorHSVAToU32( hue , .25f , scv , .25f ) } ,
borderColor{ ColorHSVAToU32( hue , .5f , scv , 1.f ) }; borderColor{ ColorHSVAToU32( hue , .5f , scv , 1.f ) };
@ -1088,7 +1089,7 @@ void T_SyncViewImpl_::displayTooltips(
// Curve from track // Curve from track
auto& sync{ Common::Sync( ) }; auto& sync{ Common::Sync( ) };
T_SyncCurve const* const curve{ sync.getCurve( track.id ) }; T_SyncCurve const* const curve{ sync.getCurve( track.id.id ) };
assert( mp.type == E_MousePosType::TRACK || curve != nullptr ); assert( mp.type == E_MousePosType::TRACK || curve != nullptr );
// Time offset // Time offset
@ -1115,9 +1116,9 @@ void T_SyncViewImpl_::displayTooltips(
const float value{ point const float value{ point
? curve->segments[ seg->seg ].values[ point->index ] ? curve->segments[ seg->seg ].values[ point->index ]
: ( curve ? curve->computeValue( dUTime ) : ( curve ? curve->computeValue( dUTime )
: sync.inputs( )[ sync.inputPos( track.id ) ] ) }; : sync.inputs( )[ sync.inputPos( track.id.id ) ] ) };
stringBuffer.clear( ) << track.id << " (input)\n"; stringBuffer.clear( ) << track.id.id << " (input)\n";
if ( mp.type == E_MousePosType::TRACK ) { if ( mp.type == E_MousePosType::TRACK ) {
stringBuffer << "No segment"; stringBuffer << "No segment";
} else { } else {
@ -1480,12 +1481,12 @@ void T_SyncViewImpl_::displayTrackWindow( ) noexcept
// Get the curve // Get the curve
auto& sync{ Common::Sync( ) }; auto& sync{ Common::Sync( ) };
auto const* const curve{ sync.getCurve( selId ) }; auto const* const curve{ sync.getCurve( selId->id ) };
Text( "Curve:" ); Text( "Curve:" );
SameLine( 110 ); SameLine( 110 );
Text( "%s" , selId.toOSString( ).data( ) ); Text( "%s" , selId->id.toOSString( ).data( ) );
if ( !sync.hasInput( selId ) ) { if ( !sync.hasInput( selId->id ) ) {
Text( " " ); Text( " " );
SameLine( 110 ); SameLine( 110 );
Text( "No matching input" ); Text( "No matching input" );
@ -1542,7 +1543,7 @@ void T_SyncViewImpl_::displayTrackWindow( ) noexcept
Text( " " ); Text( " " );
SameLine( 110 ); SameLine( 110 );
if ( Button( "Clear" , ImVec2{ -1 , 0 } ) ) { if ( Button( "Clear" , ImVec2{ -1 , 0 } ) ) {
SyncEditor::DeleteCurve( selId ); SyncEditor::DeleteCurve( selId->id );
} }
} }
if ( tDuration < dDuration ) { if ( tDuration < dDuration ) {
@ -1551,7 +1552,7 @@ void T_SyncViewImpl_::displayTrackWindow( ) noexcept
if ( Button( "Append segment" , ImVec2{ -1 , 0 } ) ) { if ( Button( "Append segment" , ImVec2{ -1 , 0 } ) ) {
const uint32_t ns{ std::max( 1u , const uint32_t ns{ std::max( 1u ,
( sync.durationUnits( ) - duration ) / 2 ) }; ( sync.durationUnits( ) - duration ) / 2 ) };
SyncEditor::AppendSegment( selId , ns ); SyncEditor::AppendSegment( selId->id , ns );
} }
} }
@ -1578,7 +1579,7 @@ void T_SyncViewImpl_::displaySegmentWindow( ) noexcept
Text( "Curve:" ); Text( "Curve:" );
SameLine( 110 ); SameLine( 110 );
Text( "%s" , selId.toOSString( ).data( ) ); Text( "%s" , selId->id.toOSString( ).data( ) );
Text( "Index:" ); Text( "Index:" );
SameLine( 110 ); SameLine( 110 );
@ -1588,7 +1589,7 @@ void T_SyncViewImpl_::displaySegmentWindow( ) noexcept
// Access curve and segment // Access curve and segment
auto& sync{ Common::Sync( ) }; auto& sync{ Common::Sync( ) };
auto const* const curve{ sync.getCurve( selId ) }; auto const* const curve{ sync.getCurve( selId->id ) };
auto const& segment{ curve->segments[ sid ] }; auto const& segment{ curve->segments[ sid ] };
// Find start and duration // Find start and duration
@ -1676,7 +1677,7 @@ void T_SyncViewImpl_::displaySegmentWindow( ) noexcept
} else { } else {
selSegment = decltype( selSegment ){}; selSegment = decltype( selSegment ){};
} }
SyncEditor::DeleteSegment( selId , sid ); SyncEditor::DeleteSegment( selId->id , sid );
} }
if ( change ) { if ( change ) {
@ -1709,12 +1710,12 @@ void T_SyncViewImpl_::displayPointWindow( ) noexcept
auto& sync{ Common::Sync( ) }; auto& sync{ Common::Sync( ) };
auto const* const curve{ selUpdatingCopy auto const* const curve{ selUpdatingCopy
? selUpdatingCopy.target( ) ? selUpdatingCopy.target( )
: sync.getCurve( selId ) }; : sync.getCurve( selId->id ) };
auto const& segment{ curve->segments[ sid ] }; auto const& segment{ curve->segments[ sid ] };
Text( "Curve:" ); Text( "Curve:" );
SameLine( 110 ); SameLine( 110 );
Text( "%s" , selId.toOSString( ).data( ) ); Text( "%s" , selId->id.toOSString( ).data( ) );
Text( "Segment index:" ); Text( "Segment index:" );
SameLine( 110 ); SameLine( 110 );
@ -1776,7 +1777,7 @@ void T_SyncViewImpl_::displayPointWindow( ) noexcept
Text( " " ); Text( " " );
SameLine( 110 ); SameLine( 110 );
if ( Button( "Delete point" , ImVec2{ -1 , 0 } ) && canUseButtons ) { if ( Button( "Delete point" , ImVec2{ -1 , 0 } ) && canUseButtons ) {
SyncEditor::DeletePoint( selId , sid , pid ); SyncEditor::DeletePoint( selId->id , sid , pid );
selPoint.clear( ); selPoint.clear( );
sub = SW_SEGMENT; sub = SW_SEGMENT;
} }
@ -1788,7 +1789,7 @@ void T_SyncViewImpl_::displayPointWindow( ) noexcept
Text( " " ); Text( " " );
SameLine( 110 ); SameLine( 110 );
if ( Button( "Insert before" , ImVec2{ -1 , 0 } ) && canUseButtons ) { if ( Button( "Insert before" , ImVec2{ -1 , 0 } ) && canUseButtons ) {
SyncEditor::InsertPoint( selId , sid , pid ); SyncEditor::InsertPoint( selId->id , sid , pid );
(*selPoint) ++; (*selPoint) ++;
} }
} }
@ -1796,7 +1797,7 @@ void T_SyncViewImpl_::displayPointWindow( ) noexcept
Text( " " ); Text( " " );
SameLine( 110 ); SameLine( 110 );
if ( Button( "Insert after" , ImVec2{ -1 , 0 } ) && canUseButtons ) { if ( Button( "Insert after" , ImVec2{ -1 , 0 } ) && canUseButtons ) {
SyncEditor::InsertPoint( selId , sid , pid + 1 ); SyncEditor::InsertPoint( selId->id , sid , pid + 1 );
} }
} }
} }