Allow discarding active trace.

This commit is contained in:
Bartosz Taudul 2018-11-25 19:29:20 +01:00
parent fec0017bb6
commit 1235a5aa0a
2 changed files with 37 additions and 3 deletions

View File

@ -547,7 +547,7 @@ bool View::DrawImpl()
bool* keepOpenPtr = nullptr; bool* keepOpenPtr = nullptr;
if( !m_staticView ) if( !m_staticView )
{ {
DrawConnection(); if( !DrawConnection() ) return false;
} }
else else
{ {
@ -777,7 +777,7 @@ bool View::DrawImpl()
return keepOpen; return keepOpen;
} }
void View::DrawConnection() bool View::DrawConnection()
{ {
const auto ty = ImGui::GetFontSize(); const auto ty = ImGui::GetFontSize();
const auto cs = ty * 0.9f; const auto cs = ty * 0.9f;
@ -854,7 +854,41 @@ void View::DrawConnection()
} }
} }
ImGui::SameLine( 0, ty * 4 );
#ifdef TRACY_EXTENDED_FONT
if( ImGui::Button( ICON_FA_EXCLAMATION_TRIANGLE " Discard" ) )
#else
if( ImGui::Button( "Discard" ) )
#endif
{
ImGui::OpenPopup( "Confirm trace discard" );
}
if( ImGui::BeginPopupModal( "Confirm trace discard", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
{
#ifdef TRACY_EXTENDED_FONT
TextCentered( ICON_FA_EXCLAMATION_TRIANGLE );
#endif
ImGui::Text( "All unsaved profiling data will be lost!" );
ImGui::Text( "Are you sure you want to proceed?" );
ImGui::Separator();
if( ImGui::Button( "Yes" ) )
{
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
ImGui::End();
return false;
}
ImGui::SameLine( 0, ty * 2 );
if( ImGui::Button( "No", ImVec2( ty * 8, 0 ) ) )
{
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
ImGui::End(); ImGui::End();
return true;
} }
static ImU32 GetFrameColor( uint64_t frameTime ) static ImU32 GetFrameColor( uint64_t frameTime )

View File

@ -73,7 +73,7 @@ private:
void DrawTextContrast( ImDrawList* draw, const ImVec2& pos, uint32_t color, const char* text ); void DrawTextContrast( ImDrawList* draw, const ImVec2& pos, uint32_t color, const char* text );
bool DrawImpl(); bool DrawImpl();
void DrawConnection(); bool DrawConnection();
void DrawFrames(); void DrawFrames();
bool DrawZoneFramesHeader(); bool DrawZoneFramesHeader();
bool DrawZoneFrames( const FrameData& frames ); bool DrawZoneFrames( const FrameData& frames );