Skip to content

Commit ba5a4b7

Browse files
committed
Limit cropper display zone to window and only take margin into account when active, to avoid flickering when hovering
1 parent 11e3295 commit ba5a4b7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎profiler/src/profiler/TracyView_ZoneTimeline.cpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ void View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, con
6262

6363
// Display cropper if currently limited or if hovering the cropper area
6464
const auto threadDepthLimitIt = m_threadDepthLimit.find( thread.id );
65-
const bool displayCropper = ( threadDepthLimitIt != m_threadDepthLimit.end() && threadDepthLimitIt->second <= depth )
66-
|| ( ImGui::GetMousePos().x < wpos.x + cropperAdditionalMargin );
67-
65+
const bool croppingActive = ( threadDepthLimitIt != m_threadDepthLimit.end() && threadDepthLimitIt->second <= depth );
66+
const bool mouseInCropperDisplayZone = ImGui::GetMousePos().x >= 0 && ImGui::GetMousePos().x < wpos.x + cropperAdditionalMargin && ImGui::GetMousePos().y > ctx.yMin && ImGui::GetMousePos().y < ctx.yMax;
67+
68+
const bool displayCropper = croppingActive || mouseInCropperDisplayZone;
6869
if( displayCropper )
6970
{
7071
if(depth > 0) depth = DrawThreadCropper( depth, thread.id, wpos.x, yPos, ostep, cropperCircleRadius, cropperWidth, hasCtxSwitch );
@@ -74,7 +75,8 @@ void View::DrawThread( const TimelineContext& ctx, const ThreadData& thread, con
7475
}
7576
if( !draw.empty() && yPos <= yMax && yPos + ostep * depth >= yMin )
7677
{
77-
DrawZoneList( ctx, draw, offset, thread.id, depth, displayCropper ? cropperAdditionalMargin + GetScale() /* Ensure text has a bit of space for text */ : 0.f );
78+
// Only apply margin when croppingActive to avoid text moving around when mouse is getting close to the cropper widget
79+
DrawZoneList( ctx, draw, offset, thread.id, depth, croppingActive ? cropperAdditionalMargin + GetScale() /* Ensure text has a bit of space for text */ : 0.f );
7880
}
7981
offset += ostep * depth;
8082

0 commit comments

Comments
 (0)