Move drawing of a single zone line to a separate function.

This commit is contained in:
Bartosz Taudul 2017-09-24 00:07:06 +02:00
parent 73df330dd5
commit c9a982360f
2 changed files with 47 additions and 38 deletions

View File

@ -918,11 +918,20 @@ void View::DrawZones()
draw->AddText( wpos + ImVec2( 0, offset ), 0xFFFFFFFF, GetThreadString( v.id ) ); draw->AddText( wpos + ImVec2( 0, offset ), 0xFFFFFFFF, GetThreadString( v.id ) );
offset += ostep; offset += ostep;
auto& timeline = v.timeline; DrawZoneLevel( v.timeline, hover, pxns, wpos, offset );
auto it = std::lower_bound( timeline.begin(), timeline.end(), m_zvStart, [] ( const auto& l, const auto& r ) { return l->end < r; } );
if( it != timeline.end() ) offset += ostep * 1.2f;
}
}
void View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset )
{ {
const auto zitend = std::lower_bound( timeline.begin(), timeline.end(), m_zvEnd, [] ( const auto& l, const auto& r ) { return l->start < r; } ); auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart, [] ( const auto& l, const auto& r ) { return l->end < r; } );
if( it != vec.end() )
{
auto draw = ImGui::GetWindowDrawList();
const auto zitend = std::lower_bound( vec.begin(), vec.end(), m_zvEnd, [] ( const auto& l, const auto& r ) { return l->start < r; } );
while( it < zitend ) while( it < zitend )
{ {
auto& ev = **it; auto& ev = **it;
@ -956,9 +965,6 @@ void View::DrawZones()
it++; it++;
} }
} }
offset += ostep * 1.2f;
}
} }
} }

View File

@ -17,6 +17,8 @@
#include "TracySourceLocation.hpp" #include "TracySourceLocation.hpp"
#include "TracyVector.hpp" #include "TracyVector.hpp"
struct ImVec2;
namespace tracy namespace tracy
{ {
@ -71,6 +73,7 @@ private:
void DrawImpl(); void DrawImpl();
void DrawFrames(); void DrawFrames();
void DrawZones(); void DrawZones();
void DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset );
std::string m_addr; std::string m_addr;