Allow ignoring custom zone colors.

This commit is contained in:
Bartosz Taudul 2020-09-21 02:04:13 +02:00
parent 1a91acc661
commit a668b61320
3 changed files with 9 additions and 3 deletions

View File

@ -21,7 +21,7 @@ constexpr auto FileAnnotations = "annotations";
constexpr auto FileSourceSubstitutions = "srcsub"; constexpr auto FileSourceSubstitutions = "srcsub";
enum : uint32_t { VersionTimeline = 0 }; enum : uint32_t { VersionTimeline = 0 };
enum : uint32_t { VersionOptions = 5 }; enum : uint32_t { VersionOptions = 6 };
enum : uint32_t { VersionAnnotations = 0 }; enum : uint32_t { VersionAnnotations = 0 };
enum : uint32_t { VersionSourceSubstitutions = 0 }; enum : uint32_t { VersionSourceSubstitutions = 0 };
@ -108,6 +108,7 @@ void UserData::LoadState( ViewData& data )
fread( &data.drawCpuUsageGraph, 1, sizeof( data.drawCpuUsageGraph ), f ); fread( &data.drawCpuUsageGraph, 1, sizeof( data.drawCpuUsageGraph ), f );
fread( &data.drawSamples, 1, sizeof( data.drawSamples ), f ); fread( &data.drawSamples, 1, sizeof( data.drawSamples ), f );
fread( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f ); fread( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
fread( &data.forceColors, 1, sizeof( data.forceColors ), f );
fread( &data.ghostZones, 1, sizeof( data.ghostZones ), f ); fread( &data.ghostZones, 1, sizeof( data.ghostZones ), f );
} }
fclose( f ); fclose( f );
@ -149,6 +150,7 @@ void UserData::SaveState( const ViewData& data )
fwrite( &data.drawCpuUsageGraph, 1, sizeof( data.drawCpuUsageGraph ), f ); fwrite( &data.drawCpuUsageGraph, 1, sizeof( data.drawCpuUsageGraph ), f );
fwrite( &data.drawSamples, 1, sizeof( data.drawSamples ), f ); fwrite( &data.drawSamples, 1, sizeof( data.drawSamples ), f );
fwrite( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f ); fwrite( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
fwrite( &data.forceColors, 1, sizeof( data.forceColors ), f );
fwrite( &data.ghostZones, 1, sizeof( data.ghostZones ), f ); fwrite( &data.ghostZones, 1, sizeof( data.ghostZones ), f );
fclose( f ); fclose( f );
} }

View File

@ -8252,6 +8252,9 @@ void View::DrawOptions()
int ival = m_vd.dynamicColors; int ival = m_vd.dynamicColors;
ImGui::TextUnformatted( ICON_FA_PALETTE " Zone colors" ); ImGui::TextUnformatted( ICON_FA_PALETTE " Zone colors" );
ImGui::SameLine();
bool forceColors = m_vd.forceColors;
if( SmallCheckbox( "Ignore custom", &forceColors ) ) m_vd.forceColors = forceColors;
ImGui::Indent(); ImGui::Indent();
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
ImGui::RadioButton( "Static", &ival, 0 ); ImGui::RadioButton( "Static", &ival, 0 );
@ -16133,7 +16136,7 @@ uint32_t View::GetRawSrcLocColor( const SourceLocation& srcloc, int depth )
uint32_t View::GetSrcLocColor( const SourceLocation& srcloc, int depth ) uint32_t View::GetSrcLocColor( const SourceLocation& srcloc, int depth )
{ {
const auto color = srcloc.color; const auto color = srcloc.color;
if( color != 0 ) return color | 0xFF000000; if( color != 0 && !m_vd.forceColors ) return color | 0xFF000000;
if( m_vd.dynamicColors == 0 ) return 0xFFCC5555; if( m_vd.dynamicColors == 0 ) return 0xFFCC5555;
return GetRawSrcLocColor( srcloc, depth ); return GetRawSrcLocColor( srcloc, depth );
} }
@ -16143,7 +16146,7 @@ uint32_t View::GetRawZoneColor( const ZoneEvent& ev, uint64_t thread, int depth
const auto sl = ev.SrcLoc(); const auto sl = ev.SrcLoc();
const auto& srcloc = m_worker.GetSourceLocation( sl ); const auto& srcloc = m_worker.GetSourceLocation( sl );
const auto color = srcloc.color; const auto color = srcloc.color;
if( color != 0 ) return color | 0xFF000000; if( color != 0 && !m_vd.forceColors ) return color | 0xFF000000;
switch( m_vd.dynamicColors ) switch( m_vd.dynamicColors )
{ {
case 0: case 0:

View File

@ -52,6 +52,7 @@ struct ViewData
uint8_t drawCpuUsageGraph = true; uint8_t drawCpuUsageGraph = true;
uint8_t drawSamples = true; uint8_t drawSamples = true;
uint8_t dynamicColors = 1; uint8_t dynamicColors = 1;
uint8_t forceColors = false;
uint8_t ghostZones = true; uint8_t ghostZones = true;
}; };