1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Proper tooltip for condensed lock events.

This commit is contained in:
Bartosz Taudul 2017-10-28 15:33:34 +02:00
parent 32fc88de7b
commit f89713b7c6

View File

@ -2345,7 +2345,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
const auto px0 = ( t0 - m_zvStart ) * pxns; const auto px0 = ( t0 - m_zvStart ) * pxns;
auto tx0 = px0; auto tx0 = px0;
double px1 = ( t1 - m_zvStart ) * pxns; double px1 = ( t1 - m_zvStart ) * pxns;
bool condensed = false; uint64_t condensed = 0;
for(;;) for(;;)
{ {
@ -2370,12 +2370,20 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
px1 = px2; px1 = px2;
next = n; next = n;
nextState = ns; nextState = ns;
condensed = true; condensed++;
drawState = CombineLockState( drawState, nextState ); drawState = CombineLockState( drawState, nextState );
} }
bool itemHovered = hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ty ) ); bool itemHovered = hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ty ) );
if( itemHovered ) if( itemHovered )
{
if( condensed != 0 )
{
ImGui::BeginTooltip();
ImGui::Text( "Multiple lock events (%" PRIu64 ")", condensed );
ImGui::EndTooltip();
}
else
{ {
highlight.blocked = drawState == LockState::HasBlockingLock; highlight.blocked = drawState == LockState::HasBlockingLock;
if( !highlight.blocked ) if( !highlight.blocked )
@ -2497,15 +2505,16 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
} }
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
}
const auto cfilled = drawState == LockState::HasLock ? 0xFF228A22 : ( drawState == LockState::HasBlockingLock ? 0xFF228A8A : 0xFF2222BD ); const auto cfilled = drawState == LockState::HasLock ? 0xFF228A22 : ( drawState == LockState::HasBlockingLock ? 0xFF228A8A : 0xFF2222BD );
draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ty ), cfilled, condensed ? 0.f : 2.f ); draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ty ), cfilled, condensed != 0 ? 0.f : 2.f );
if( m_lockHighlight.thread != thread && ( drawState == LockState::HasBlockingLock ) != m_lockHighlight.blocked && next != tl.end() && m_lockHighlight.id == v.first && m_lockHighlight.begin <= (*vbegin)->time && m_lockHighlight.end >= (*next)->time ) if( m_lockHighlight.thread != thread && ( drawState == LockState::HasBlockingLock ) != m_lockHighlight.blocked && next != tl.end() && m_lockHighlight.id == v.first && m_lockHighlight.begin <= (*vbegin)->time && m_lockHighlight.end >= (*next)->time )
{ {
const auto t = uint8_t( ( sin( std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now().time_since_epoch() ).count() * 0.01 ) * 0.5 + 0.5 ) * 255 ); const auto t = uint8_t( ( sin( std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now().time_since_epoch() ).count() * 0.01 ) * 0.5 + 0.5 ) * 255 );
draw->AddRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ty ), 0x00FFFFFF | ( t << 24 ), 2.f, -1, 2.f ); draw->AddRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ty ), 0x00FFFFFF | ( t << 24 ), 2.f, -1, 2.f );
} }
else if( !condensed ) else if( condensed == 0 )
{ {
const auto coutline = drawState == LockState::HasLock ? 0xFF3BA33B : ( drawState == LockState::HasBlockingLock ? 0xFF3BA3A3 : 0xFF3B3BD6 ); const auto coutline = drawState == LockState::HasLock ? 0xFF3BA33B : ( drawState == LockState::HasBlockingLock ? 0xFF3BA3A3 : 0xFF3B3BD6 );
draw->AddRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ty ), coutline, 2.f ); draw->AddRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ty ), coutline, 2.f );