Fix zone depth calculation.

This commit is contained in:
Bartosz Taudul 2017-10-12 19:14:03 +02:00
parent a0a397207d
commit c1090a3116

View File

@ -1367,7 +1367,7 @@ void View::DrawZones()
m_lastCpu = -1; m_lastCpu = -1;
auto depth = DrawZoneLevel( v->timeline, hover, pxns, wpos, offset, 0 ); auto depth = DrawZoneLevel( v->timeline, hover, pxns, wpos, offset, 0 );
offset += ostep * ( depth + 1 ); offset += ostep * depth;
depth = DrawLocks( v->id, hover, pxns, wpos, offset, nextLockHighlight ); depth = DrawLocks( v->id, hover, pxns, wpos, offset, nextLockHighlight );
offset += ostep * ( depth + 0.2f ); offset += ostep * ( depth + 0.2f );
@ -1377,10 +1377,12 @@ void View::DrawZones()
int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth ) int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth )
{ {
int maxdepth = depth;
auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart - m_delay, [] ( const auto& l, const auto& r ) { return l->end < r; } ); auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart - m_delay, [] ( const auto& l, const auto& r ) { return l->end < r; } );
if( it != vec.end() ) if( it == vec.end() ) return depth;
{
const auto zitend = std::lower_bound( vec.begin(), vec.end(), m_zvEnd + m_resolution, [] ( const auto& l, const auto& r ) { return l->start < r; } );
if( it == zitend ) return depth;
const auto w = ImGui::GetWindowContentRegionWidth(); const auto w = ImGui::GetWindowContentRegionWidth();
const auto ty = ImGui::GetFontSize(); const auto ty = ImGui::GetFontSize();
const auto ostep = ty + 1; const auto ostep = ty + 1;
@ -1389,7 +1391,9 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
const auto dsz = m_delay * pxns; const auto dsz = m_delay * pxns;
const auto rsz = m_resolution * pxns; const auto rsz = m_resolution * pxns;
const auto zitend = std::lower_bound( vec.begin(), vec.end(), m_zvEnd + m_resolution, [] ( const auto& l, const auto& r ) { return l->start < r; } ); depth++;
int maxdepth = depth;
while( it < zitend ) while( it < zitend )
{ {
auto& ev = **it; auto& ev = **it;
@ -1470,7 +1474,7 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
if( !ev.child.empty() ) if( !ev.child.empty() )
{ {
const auto d = DrawZoneLevel( ev.child, hover, pxns, wpos, _offset, depth+1 ); const auto d = DrawZoneLevel( ev.child, hover, pxns, wpos, _offset, depth );
if( d > maxdepth ) maxdepth = d; if( d > maxdepth ) maxdepth = d;
} }
@ -1540,7 +1544,6 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
++it; ++it;
} }
} }
}
return maxdepth; return maxdepth;
} }