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