diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 44c4d5df..61a9f9a1 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -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= 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 ); + } +} + } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index c2105a6b..7e68fe05 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -56,6 +56,7 @@ private: void DrawImpl(); void DrawFrames(); + void DrawZones(); std::string m_addr;