Sequencer - Remove overrides that no longer exist
This commit is contained in:
parent
c2860a7d02
commit
9eb719d0aa
4 changed files with 75 additions and 12 deletions
1
TODO
1
TODO
|
@ -28,7 +28,6 @@ Scripting:
|
||||||
Sync / inputs:
|
Sync / inputs:
|
||||||
* Widget for displaying single inputs
|
* Widget for displaying single inputs
|
||||||
* Widget for displaying overrides
|
* Widget for displaying overrides
|
||||||
* Check for inputs/overrides that no longer exist
|
|
||||||
* Structure for undoing actions
|
* Structure for undoing actions
|
||||||
* Curve file external updates
|
* Curve file external updates
|
||||||
* Segment creation
|
* Segment creation
|
||||||
|
|
13
sync.cc
13
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(
|
void T_SyncManager::setOverridesActive(
|
||||||
const bool active ,
|
const bool active ,
|
||||||
const uint32_t n ,
|
const uint32_t n ,
|
||||||
|
|
3
sync.hh
3
sync.hh
|
@ -369,6 +369,9 @@ struct T_SyncManager : public virtual A_MouseCtrl
|
||||||
void clearOverrides( ) noexcept;
|
void clearOverrides( ) noexcept;
|
||||||
void mergeOverrides( T_SyncOverrideSection& overrides );
|
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
|
// Mark a bunch of inputs as overridden / not overridden
|
||||||
void setOverridesActive( bool active ,
|
void setOverridesActive( bool active ,
|
||||||
uint32_t n ,
|
uint32_t n ,
|
||||||
|
|
70
syncview.cc
70
syncview.cc
|
@ -155,19 +155,11 @@ struct T_SyncViewImpl_
|
||||||
static constexpr float SeqHeaderHeight = 24;
|
static constexpr float SeqHeaderHeight = 24;
|
||||||
static constexpr float BarWidth = 40;
|
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;
|
bool display( ) noexcept;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Make sure all displayed curves/inputs/overrides still exist
|
||||||
|
void checkSelectedCurves( ) noexcept;
|
||||||
void displayToolbar( ) noexcept;
|
void displayToolbar( ) noexcept;
|
||||||
|
|
||||||
void computeMetrics( float innerWidth ) noexcept;
|
void computeMetrics( float innerWidth ) noexcept;
|
||||||
|
@ -179,6 +171,19 @@ struct T_SyncViewImpl_
|
||||||
void displayCurveSelector( ) noexcept;
|
void displayCurveSelector( ) noexcept;
|
||||||
void displayOverrideSelector( ) 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
|
// Misc stuff
|
||||||
T_StringBuilder stringBuffer; // XXX damn this shit to fucking hell
|
T_StringBuilder stringBuffer; // XXX damn this shit to fucking hell
|
||||||
|
|
||||||
|
@ -229,6 +234,7 @@ bool T_SyncViewImpl_::display( ) noexcept
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkSelectedCurves( );
|
||||||
displayToolbar( );
|
displayToolbar( );
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -255,6 +261,48 @@ bool T_SyncViewImpl_::display( ) noexcept
|
||||||
return true;
|
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
|
void T_SyncViewImpl_::displayToolbar( ) noexcept
|
||||||
{
|
{
|
||||||
using namespace ImGui;
|
using namespace ImGui;
|
||||||
|
|
Loading…
Reference in a new issue