Separate tooltip showing function.

This commit is contained in:
Bartosz Taudul 2017-09-29 22:55:24 +02:00
parent 5dc5500065
commit 3ac65a7524
2 changed files with 44 additions and 18 deletions

View File

@ -1161,16 +1161,14 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
} }
else else
{ {
const char* func;
const char* zoneName; const char* zoneName;
if( ev.text && ev.text->zoneName ) if( ev.text && ev.text->zoneName )
{ {
zoneName = GetString( ev.text->zoneName ); zoneName = GetString( ev.text->zoneName );
func = GetString( srcloc.function );
} }
else else
{ {
func = zoneName = GetString( srcloc.function ); zoneName = GetString( srcloc.function );
} }
int dmul = 1; int dmul = 1;
@ -1180,9 +1178,6 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
if( ev.text->userText ) dmul++; if( ev.text->userText ) dmul++;
} }
const auto filename = GetString( srcloc.file );
const auto line = srcloc.line;
const auto tsz = ImGui::CalcTextSize( zoneName ); const auto tsz = ImGui::CalcTextSize( zoneName );
const auto pr0 = ( ev.start - m_zvStart ) * pxns; const auto pr0 = ( ev.start - m_zvStart ) * pxns;
const auto pr1 = ( end - m_zvStart ) * pxns; const auto pr1 = ( end - m_zvStart ) * pxns;
@ -1228,18 +1223,7 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ) ) ) if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ) ) )
{ {
ImGui::BeginTooltip(); ZoneTooltip( ev );
ImGui::Text( "%s", func );
ImGui::Text( "%s:%i", filename, line );
ImGui::Text( "Execution time: %s", TimeToString( end - ev.start ) );
ImGui::Text( "Without profiling: %s", TimeToString( end - ev.start - m_delay * dmul ) );
if( ev.text && ev.text->userText )
{
ImGui::Text( "" );
ImGui::TextColored( ImVec4( 0xCC / 255.f, 0xCC / 255.f, 0x22 / 255.f, 1.f ), "%s", ev.text->userText );
}
ImGui::EndTooltip();
if( m_zvStartNext == 0 && ImGui::IsMouseClicked( 2 ) ) if( m_zvStartNext == 0 && ImGui::IsMouseClicked( 2 ) )
{ {
@ -1388,4 +1372,45 @@ void View::ZoomToZone( const Event& ev )
m_zvEndNext = ev.end; m_zvEndNext = ev.end;
} }
void View::ZoneTooltip( const Event& ev )
{
int dmul = 1;
if( ev.text )
{
if( ev.text->zoneName ) dmul++;
if( ev.text->userText ) dmul++;
}
auto& srcloc = GetSourceLocation( ev.srcloc );
const auto filename = GetString( srcloc.file );
const auto line = srcloc.line;
const char* func;
const char* zoneName;
if( ev.text && ev.text->zoneName )
{
zoneName = GetString( ev.text->zoneName );
func = GetString( srcloc.function );
}
else
{
func = zoneName = GetString( srcloc.function );
}
const auto end = GetZoneEnd( ev );
ImGui::BeginTooltip();
ImGui::Text( "%s", func );
ImGui::Text( "%s:%i", filename, line );
ImGui::Text( "Execution time: %s", TimeToString( end - ev.start ) );
ImGui::Text( "Without profiling: %s", TimeToString( end - ev.start - m_delay * dmul ) );
if( ev.text && ev.text->userText )
{
ImGui::Text( "" );
ImGui::TextColored( ImVec4( 0xCC / 255.f, 0xCC / 255.f, 0x22 / 255.f, 1.f ), "%s", ev.text->userText );
}
ImGui::EndTooltip();
}
} }

View File

@ -89,6 +89,7 @@ private:
uint32_t GetZoneHighlight( const Event& ev ); uint32_t GetZoneHighlight( const Event& ev );
void ZoomToZone( const Event& ev ); void ZoomToZone( const Event& ev );
void ZoneTooltip( const Event& ev );
std::string m_addr; std::string m_addr;