mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Draw frames in zone view.
This commit is contained in:
parent
43dc12ca39
commit
c3df475de7
@ -445,6 +445,7 @@ void View::DrawImpl()
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( "Frames: %-7i Time span: %-10s View span: %s", m_frames.size(), TimeToString( GetLastTime() - m_frames[0] ), TimeToString( m_zvEnd - m_zvStart ) );
|
||||
DrawFrames();
|
||||
DrawZones();
|
||||
ImGui::End();
|
||||
|
||||
ImGui::ShowTestWindow();
|
||||
@ -617,4 +618,84 @@ void View::DrawFrames()
|
||||
}
|
||||
}
|
||||
|
||||
struct TimeScale
|
||||
{
|
||||
uint64_t div;
|
||||
const char* fmt;
|
||||
};
|
||||
|
||||
void View::DrawZones()
|
||||
{
|
||||
if( m_zvStart == m_zvEnd ) return;
|
||||
assert( m_zvStart < m_zvEnd );
|
||||
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
if( window->SkipItems ) return;
|
||||
|
||||
const auto wpos = ImGui::GetCursorScreenPos();
|
||||
const auto w = ImGui::GetWindowContentRegionWidth();
|
||||
const auto h = ImGui::GetContentRegionAvail().y;
|
||||
auto draw = ImGui::GetWindowDrawList();
|
||||
|
||||
enum { TimeHeight = 50 };
|
||||
|
||||
ImGui::InvisibleButton( "##zones", ImVec2( w, h ) );
|
||||
bool hover = ImGui::IsItemHovered();
|
||||
|
||||
const auto timespan = m_zvEnd - m_zvStart;
|
||||
const auto pxns = w / double( timespan );
|
||||
|
||||
const auto zitbegin = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvStart );
|
||||
const auto zitend = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvEnd );
|
||||
|
||||
const auto zbegin = (int)std::distance( m_frames.begin(), zitbegin );
|
||||
const auto zend = (int)std::distance( m_frames.begin(), zitend );
|
||||
|
||||
for( int i=zbegin; i<zend; i++ )
|
||||
{
|
||||
const auto ftime = GetFrameTime( i );
|
||||
const auto fbegin = GetFrameBegin( i );
|
||||
const auto fend = GetFrameEnd( i );
|
||||
|
||||
char buf[128];
|
||||
sprintf( buf, "Frame %i (%s)", i, TimeToString( ftime ) );
|
||||
const auto tsz = ImGui::CalcTextSize( buf );
|
||||
const auto fsz = pxns * ftime;
|
||||
|
||||
if( fbegin >= m_zvStart )
|
||||
{
|
||||
draw->AddLine( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns, 0 ), wpos + ImVec2( ( fbegin - m_zvStart ) * pxns, h ), 0x22FFFFFF );
|
||||
}
|
||||
|
||||
if( fsz >= 5 )
|
||||
{
|
||||
if( fbegin >= m_zvStart )
|
||||
{
|
||||
draw->AddLine( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns + 2, 1 ), wpos + ImVec2( ( fbegin - m_zvStart ) * pxns + 2, tsz.y - 1 ), 0xFFFFFFFF );
|
||||
}
|
||||
if( fend <= m_zvEnd )
|
||||
{
|
||||
draw->AddLine( wpos + ImVec2( ( fend - m_zvStart ) * pxns - 2, 1 ), wpos + ImVec2( ( fend - m_zvStart ) * pxns - 2, tsz.y - 1 ), 0xFFFFFFFF );
|
||||
}
|
||||
if( fsz - 5 > tsz.x )
|
||||
{
|
||||
const auto part = ( fsz - 5 - tsz.x ) / 2;
|
||||
draw->AddLine( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns + 2, tsz.y / 2 ), wpos + ImVec2( ( fbegin - m_zvStart ) * pxns + part, tsz.y / 2 ), 0xFFFFFFFF );
|
||||
draw->AddText( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns + 2 + part, 0 ), 0xFFFFFFFF, buf );
|
||||
draw->AddLine( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns + 2 + part + tsz.x, tsz.y / 2 ), wpos + ImVec2( ( fend - m_zvStart ) * pxns - 2, tsz.y / 2 ), 0xFFFFFFFF );
|
||||
}
|
||||
else
|
||||
{
|
||||
draw->AddLine( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns + 2, tsz.y / 2 ), wpos + ImVec2( ( fend - m_zvStart ) * pxns - 2, tsz.y / 2 ), 0xFFFFFFFF );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto fend = GetFrameEnd( zend-1 );
|
||||
if( fend == m_zvEnd )
|
||||
{
|
||||
draw->AddLine( wpos + ImVec2( ( fend - m_zvStart ) * pxns, 0 ), wpos + ImVec2( ( fend - m_zvStart ) * pxns, h ), 0x22FFFFFF );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ private:
|
||||
|
||||
void DrawImpl();
|
||||
void DrawFrames();
|
||||
void DrawZones();
|
||||
|
||||
std::string m_addr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user