Hide frame related information if no frame instrumentation.

This commit is contained in:
Bartosz Taudul 2022-09-05 20:12:36 +02:00
parent 23ebce2862
commit 5200ea2c84
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
4 changed files with 84 additions and 75 deletions

View File

@ -836,55 +836,58 @@ bool View::DrawImpl()
ImGui::EndPopup(); ImGui::EndPopup();
} }
} }
ImGui::SameLine(); if( m_worker.AreFramesUsed() )
if( ImGui::SmallButton( " " ICON_FA_CARET_LEFT " " ) ) ZoomToPrevFrame();
ImGui::SameLine();
{ {
const auto vis = Vis( m_frames ); ImGui::SameLine();
if( !vis ) if( ImGui::SmallButton( " " ICON_FA_CARET_LEFT " " ) ) ZoomToPrevFrame();
ImGui::SameLine();
{ {
ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] ); const auto vis = Vis( m_frames );
} if( !vis )
ImGui::Text( "%s: %s", GetFrameSetName( *m_frames ), RealToString( m_worker.GetFrameCount( *m_frames ) ) );
if( !vis )
{
ImGui::PopStyleColor();
}
if( ImGui::IsItemClicked() ) ImGui::OpenPopup( "GoToFramePopup" );
}
ImGui::SameLine();
if( ImGui::SmallButton( " " ICON_FA_CARET_RIGHT " " ) ) ZoomToNextFrame();
ImGui::SameLine();
if( ImGui::BeginCombo( "##frameCombo", nullptr, ImGuiComboFlags_NoPreview ) )
{
auto& frames = m_worker.GetFrames();
for( auto& fd : frames )
{
bool isSelected = m_frames == fd;
if( ImGui::Selectable( GetFrameSetName( *fd ), isSelected ) )
{ {
m_frames = fd; ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] );
} }
if( isSelected ) ImGui::Text( "%s: %s", GetFrameSetName( *m_frames ), RealToString( m_worker.GetFrameCount( *m_frames ) ) );
if( !vis )
{ {
ImGui::SetItemDefaultFocus(); ImGui::PopStyleColor();
} }
ImGui::SameLine(); if( ImGui::IsItemClicked() ) ImGui::OpenPopup( "GoToFramePopup" );
ImGui::TextDisabled( "(%s)", RealToString( fd->frames.size() ) ); }
ImGui::SameLine();
if( ImGui::SmallButton( " " ICON_FA_CARET_RIGHT " " ) ) ZoomToNextFrame();
ImGui::SameLine();
if( ImGui::BeginCombo( "##frameCombo", nullptr, ImGuiComboFlags_NoPreview ) )
{
auto& frames = m_worker.GetFrames();
for( auto& fd : frames )
{
bool isSelected = m_frames == fd;
if( ImGui::Selectable( GetFrameSetName( *fd ), isSelected ) )
{
m_frames = fd;
}
if( isSelected )
{
ImGui::SetItemDefaultFocus();
}
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", RealToString( fd->frames.size() ) );
}
ImGui::EndCombo();
}
if( ImGui::BeginPopup( "GoToFramePopup" ) )
{
static int frameNum = 1;
const bool mainFrameSet = m_frames->name == 0;
const auto numFrames = mainFrameSet ? m_frames->frames.size() - 1 : m_frames->frames.size();
const auto frameOffset = mainFrameSet ? 0 : 1;
ImGui::SetNextItemWidth( 120 * GetScale() );
const bool clicked = ImGui::InputInt( "##goToFrame", &frameNum, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue );
frameNum = std::min( std::max( frameNum, 1 ), int( numFrames ) );
if( clicked ) ZoomToRange( m_worker.GetFrameBegin( *m_frames, frameNum - frameOffset ), m_worker.GetFrameEnd( *m_frames, frameNum - frameOffset ) );
ImGui::EndPopup();
} }
ImGui::EndCombo();
}
if( ImGui::BeginPopup( "GoToFramePopup" ) )
{
static int frameNum = 1;
const bool mainFrameSet = m_frames->name == 0;
const auto numFrames = mainFrameSet ? m_frames->frames.size() - 1 : m_frames->frames.size();
const auto frameOffset = mainFrameSet ? 0 : 1;
ImGui::SetNextItemWidth( 120 * GetScale() );
const bool clicked = ImGui::InputInt( "##goToFrame", &frameNum, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue );
frameNum = std::min( std::max( frameNum, 1 ), int( numFrames ) );
if( clicked ) ZoomToRange( m_worker.GetFrameBegin( *m_frames, frameNum - frameOffset ), m_worker.GetFrameEnd( *m_frames, frameNum - frameOffset ) );
ImGui::EndPopup();
} }
{ {

View File

@ -696,39 +696,42 @@ void View::DrawOptions()
ImGui::TreePop(); ImGui::TreePop();
} }
ImGui::Separator(); if( m_worker.AreFramesUsed() )
expand = ImGui::TreeNode( ICON_FA_IMAGES " Visible frame sets:" );
ImGui::SameLine();
ImGui::TextDisabled( "(%zu)", m_worker.GetFrames().size() );
if( expand )
{ {
ImGui::Separator();
expand = ImGui::TreeNode( ICON_FA_IMAGES " Visible frame sets:" );
ImGui::SameLine(); ImGui::SameLine();
if( ImGui::SmallButton( "Select all" ) ) ImGui::TextDisabled( "(%zu)", m_worker.GetFrames().size() );
if( expand )
{ {
for( const auto& fd : m_worker.GetFrames() )
{
Vis( fd ) = true;
}
}
ImGui::SameLine();
if( ImGui::SmallButton( "Unselect all" ) )
{
for( const auto& fd : m_worker.GetFrames() )
{
Vis( fd ) = false;
}
}
int idx = 0;
for( const auto& fd : m_worker.GetFrames() )
{
ImGui::PushID( idx++ );
SmallCheckbox( GetFrameSetName( *fd ), &Vis( fd ) );
ImGui::PopID();
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextDisabled( "%s %sframes", RealToString( fd->frames.size() ), fd->continuous ? "" : "discontinuous " ); if( ImGui::SmallButton( "Select all" ) )
{
for( const auto& fd : m_worker.GetFrames() )
{
Vis( fd ) = true;
}
}
ImGui::SameLine();
if( ImGui::SmallButton( "Unselect all" ) )
{
for( const auto& fd : m_worker.GetFrames() )
{
Vis( fd ) = false;
}
}
int idx = 0;
for( const auto& fd : m_worker.GetFrames() )
{
ImGui::PushID( idx++ );
SmallCheckbox( GetFrameSetName( *fd ), &Vis( fd ) );
ImGui::PopID();
ImGui::SameLine();
ImGui::TextDisabled( "%s %sframes", RealToString( fd->frames.size() ), fd->continuous ? "" : "discontinuous " );
}
ImGui::TreePop();
} }
ImGui::TreePop();
} }
ImGui::End(); ImGui::End();
} }

View File

@ -296,12 +296,15 @@ void View::DrawTimeline()
m_tc.Begin(); m_tc.Begin();
DrawTimelineFramesHeader(); DrawTimelineFramesHeader();
auto& frames = m_worker.GetFrames(); if( m_worker.AreFramesUsed() )
for( auto fd : frames )
{ {
if( Vis( fd ) ) auto& frames = m_worker.GetFrames();
for( auto fd : frames )
{ {
DrawTimelineFrames( *fd ); if( Vis( fd ) )
{
DrawTimelineFrames( *fd );
}
} }
} }

View File

@ -183,7 +183,7 @@ void View::DrawInfo()
ImGui::TreePop(); ImGui::TreePop();
} }
if( ImGui::TreeNode( "Frame statistics" ) ) if( m_worker.AreFramesUsed() && ImGui::TreeNode( "Frame statistics" ) )
{ {
auto fsz = m_worker.GetFullFrameCount( *m_frames ); auto fsz = m_worker.GetFullFrameCount( *m_frames );
if( fsz != 0 ) if( fsz != 0 )