mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Display time stamp when hovering mouse over time scale.
This commit is contained in:
parent
5e559322a0
commit
833653ce40
@ -2020,60 +2020,63 @@ void View::DrawZoneFramesHeader()
|
|||||||
const auto ty0375 = round( ty * 0.375f );
|
const auto ty0375 = round( ty * 0.375f );
|
||||||
const auto ty05 = round( ty * 0.5f );
|
const auto ty05 = round( ty * 0.5f );
|
||||||
|
|
||||||
|
const auto timespan = m_vd.zvEnd - m_vd.zvStart;
|
||||||
|
const auto pxns = w / double( timespan );
|
||||||
|
const auto nspx = 1.0 / pxns;
|
||||||
|
const auto scale = std::max( 0.0, round( log10( nspx ) + 2 ) );
|
||||||
|
const auto step = pow( 10, scale );
|
||||||
|
|
||||||
ImGui::InvisibleButton( "##zoneFrames", ImVec2( w, ty * 1.5f ) );
|
ImGui::InvisibleButton( "##zoneFrames", ImVec2( w, ty * 1.5f ) );
|
||||||
|
if( ImGui::IsItemHovered() )
|
||||||
auto timespan = m_vd.zvEnd - m_vd.zvStart;
|
|
||||||
auto pxns = w / double( timespan );
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto nspx = 1.0 / pxns;
|
ImGui::BeginTooltip();
|
||||||
const auto scale = std::max( 0.0, round( log10( nspx ) + 2 ) );
|
ImGui::TextUnformatted( TimeToStringExact( m_vd.zvStart + ( ImGui::GetIO().MousePos.x - wpos.x ) * nspx ) );
|
||||||
const auto step = pow( 10, scale );
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
const auto dx = step * pxns;
|
const auto dx = step * pxns;
|
||||||
double x = 0;
|
double x = 0;
|
||||||
int tw = 0;
|
int tw = 0;
|
||||||
int tx = 0;
|
int tx = 0;
|
||||||
int64_t tt = 0;
|
int64_t tt = 0;
|
||||||
while( x < w )
|
while( x < w )
|
||||||
|
{
|
||||||
|
draw->AddLine( wpos + ImVec2( x, 0 ), wpos + ImVec2( x, ty05 ), 0x66FFFFFF );
|
||||||
|
if( tw == 0 )
|
||||||
{
|
{
|
||||||
draw->AddLine( wpos + ImVec2( x, 0 ), wpos + ImVec2( x, ty05 ), 0x66FFFFFF );
|
char buf[128];
|
||||||
if( tw == 0 )
|
auto txt = TimeToStringExact( m_vd.zvStart );
|
||||||
|
if( m_vd.zvStart >= 0 )
|
||||||
{
|
{
|
||||||
char buf[128];
|
sprintf( buf, "+%s", txt );
|
||||||
auto txt = TimeToStringExact( m_vd.zvStart );
|
txt = buf;
|
||||||
if( m_vd.zvStart >= 0 )
|
|
||||||
{
|
|
||||||
sprintf( buf, "+%s", txt );
|
|
||||||
txt = buf;
|
|
||||||
}
|
|
||||||
draw->AddText( wpos + ImVec2( x, ty05 ), 0x66FFFFFF, txt );
|
|
||||||
tw = ImGui::CalcTextSize( txt ).x;
|
|
||||||
}
|
}
|
||||||
else if( x > tx + tw + ty * 2 )
|
draw->AddText( wpos + ImVec2( x, ty05 ), 0x66FFFFFF, txt );
|
||||||
{
|
tw = ImGui::CalcTextSize( txt ).x;
|
||||||
tx = x;
|
|
||||||
auto txt = TimeToString( tt );
|
|
||||||
draw->AddText( wpos + ImVec2( x, ty05 ), 0x66FFFFFF, txt );
|
|
||||||
tw = ImGui::CalcTextSize( txt ).x;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( scale != 0 )
|
|
||||||
{
|
|
||||||
for( int i=1; i<5; i++ )
|
|
||||||
{
|
|
||||||
draw->AddLine( wpos + ImVec2( x + i * dx / 10, 0 ), wpos + ImVec2( x + i * dx / 10, ty025 ), 0x33FFFFFF );
|
|
||||||
}
|
|
||||||
draw->AddLine( wpos + ImVec2( x + 5 * dx / 10, 0 ), wpos + ImVec2( x + 5 * dx / 10, ty0375 ), 0x33FFFFFF );
|
|
||||||
for( int i=6; i<10; i++ )
|
|
||||||
{
|
|
||||||
draw->AddLine( wpos + ImVec2( x + i * dx / 10, 0 ), wpos + ImVec2( x + i * dx / 10, ty025 ), 0x33FFFFFF );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
x += dx;
|
|
||||||
tt += step;
|
|
||||||
}
|
}
|
||||||
|
else if( x > tx + tw + ty * 2 )
|
||||||
|
{
|
||||||
|
tx = x;
|
||||||
|
auto txt = TimeToString( tt );
|
||||||
|
draw->AddText( wpos + ImVec2( x, ty05 ), 0x66FFFFFF, txt );
|
||||||
|
tw = ImGui::CalcTextSize( txt ).x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( scale != 0 )
|
||||||
|
{
|
||||||
|
for( int i=1; i<5; i++ )
|
||||||
|
{
|
||||||
|
draw->AddLine( wpos + ImVec2( x + i * dx / 10, 0 ), wpos + ImVec2( x + i * dx / 10, ty025 ), 0x33FFFFFF );
|
||||||
|
}
|
||||||
|
draw->AddLine( wpos + ImVec2( x + 5 * dx / 10, 0 ), wpos + ImVec2( x + 5 * dx / 10, ty0375 ), 0x33FFFFFF );
|
||||||
|
for( int i=6; i<10; i++ )
|
||||||
|
{
|
||||||
|
draw->AddLine( wpos + ImVec2( x + i * dx / 10, 0 ), wpos + ImVec2( x + i * dx / 10, ty025 ), 0x33FFFFFF );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x += dx;
|
||||||
|
tt += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user