diff --git a/TODO b/TODO index 159fe77..bc722f5 100644 --- a/TODO +++ b/TODO @@ -28,7 +28,6 @@ Scripting: Sync / inputs: * Widget for displaying single inputs * Widget for displaying overrides -* Check for inputs/overrides that no longer exist * Structure for undoing actions * Curve file external updates * Segment creation diff --git a/sync.cc b/sync.cc index 7828f1c..5acf01e 100644 --- a/sync.cc +++ b/sync.cc @@ -764,6 +764,19 @@ void T_SyncManager::mergeOverrides( ); } +bool T_SyncManager::overrideExists( + T_String const& id ) const noexcept +{ + return soTable_.contains( id ); +} + +A_SyncOverride* T_SyncManager::getOverride( + T_String const& id ) const noexcept +{ + const auto rv{ soTable_.get( id ) }; + return rv ? *rv : nullptr; +} + void T_SyncManager::setOverridesActive( const bool active , const uint32_t n , diff --git a/sync.hh b/sync.hh index e6a5d7c..f0f3cd0 100644 --- a/sync.hh +++ b/sync.hh @@ -369,6 +369,9 @@ struct T_SyncManager : public virtual A_MouseCtrl void clearOverrides( ) noexcept; void mergeOverrides( T_SyncOverrideSection& overrides ); + bool overrideExists( T_String const& id ) const noexcept; + A_SyncOverride* getOverride( T_String const& id ) const noexcept; + // Mark a bunch of inputs as overridden / not overridden void setOverridesActive( bool active , uint32_t n , diff --git a/syncview.cc b/syncview.cc index c5b0bab..d162fba 100644 --- a/syncview.cc +++ b/syncview.cc @@ -155,19 +155,11 @@ struct T_SyncViewImpl_ static constexpr float SeqHeaderHeight = 24; static constexpr float BarWidth = 40; - const uint32_t ColFrame{ ImGui::GetColorU32( ImVec4{ 0 , 0 , 0 , .8 } ) }; - const uint32_t ColHeader{ ImGui::GetColorU32( ImVec4{ .5 , .5 , .5 , .8 } ) }; - const uint32_t ColHeaderText{ ImGui::GetColorU32( ImVec4{ 0 , 0 , 0 , 1 } ) }; - const uint32_t ColMain{ ImGui::GetColorU32( ImVec4{ .4 , .4 , .4 , .8 } ) }; - const uint32_t ColSelection{ ImGui::GetColorU32( ImVec4{ .8 , 1 , .8 , .2 } ) }; - const ImVec2 BtSize{ 20 , 0 }; - - float zoomLevel{ 0.f }; - float startPos{ 0.f }; - bool followTime{ true }; - bool display( ) noexcept; + private: + // Make sure all displayed curves/inputs/overrides still exist + void checkSelectedCurves( ) noexcept; void displayToolbar( ) noexcept; void computeMetrics( float innerWidth ) noexcept; @@ -179,6 +171,19 @@ struct T_SyncViewImpl_ void displayCurveSelector( ) noexcept; void displayOverrideSelector( ) noexcept; + // Colors, sizes, etc. + const uint32_t ColFrame{ ImGui::GetColorU32( ImVec4{ 0 , 0 , 0 , .8 } ) }; + const uint32_t ColHeader{ ImGui::GetColorU32( ImVec4{ .5 , .5 , .5 , .8 } ) }; + const uint32_t ColHeaderText{ ImGui::GetColorU32( ImVec4{ 0 , 0 , 0 , 1 } ) }; + const uint32_t ColMain{ ImGui::GetColorU32( ImVec4{ .4 , .4 , .4 , .8 } ) }; + const uint32_t ColSelection{ ImGui::GetColorU32( ImVec4{ .8 , 1 , .8 , .2 } ) }; + const ImVec2 BtSize{ 20 , 0 }; + + // Sequencer settings + float zoomLevel{ 0.f }; + float startPos{ 0.f }; + bool followTime{ true }; + // Misc stuff T_StringBuilder stringBuffer; // XXX damn this shit to fucking hell @@ -229,6 +234,7 @@ bool T_SyncViewImpl_::display( ) noexcept return false; } + checkSelectedCurves( ); displayToolbar( ); //---------------------------------------------------------------------- @@ -255,6 +261,48 @@ bool T_SyncViewImpl_::display( ) noexcept return true; } +void T_SyncViewImpl_::checkSelectedCurves( ) noexcept +{ + auto& sync{ Globals::Sync( ) }; + + // Check for "dead" overrides + { + bool ovRemoved{ false }; + for ( auto i = 0u ; i < sOverrides.size( ) ; ) { + if ( sync.overrideExists( sOverrides[ i ] ) ) { + i ++; + } else { + sOverrides.remove( sOverrides[ i ] ); + ovRemoved = true; + } + } + if ( !ovRemoved ) { + return; + } + } + + // Remove all curves that come from overrides + for ( auto i = 0u ; i < sCurves.size( ) ; ) { + if ( sCurves.values( )[ i ] ) { + sCurves.remove( sCurves.keys( )[ i ] ); + } else { + i ++; + } + } + + // Re-add curves for the remaining overrides + const auto no{ sOverrides.size( ) }; + for ( auto i = 0u ; i < no ; i ++ ) { + auto const* od{ sync.getOverride( sOverrides[ i ] ) }; + assert( od ); + const auto ni{ od->inputNames( ).size( ) }; + for ( auto j = 0u ; j < ni ; j ++ ) { + const bool ok{ sCurves.add( od->inputNames( )[ j ] , true ) }; + assert( ok ); (void) ok; + } + } +} + void T_SyncViewImpl_::displayToolbar( ) noexcept { using namespace ImGui;