From 2d25e969e9518e1ea34840dd2fba2307ac9ef4c7 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 13 Apr 2020 15:00:37 +0200 Subject: [PATCH] Fix time span indicators visual jitter. --- server/TracyView.cpp | 66 ++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 72230392..e7608a75 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -624,31 +624,49 @@ bool View::DrawImpl() ImGui::TextUnformatted( "Go to frame" ); ImGui::EndTooltip(); } - ImGui::SameLine(); - ImGui::Spacing(); - ImGui::SameLine(); - ImGui::Text( ICON_FA_EYE " %-10s", TimeToString( m_vd.zvEnd - m_vd.zvStart ) ); - if( ImGui::IsItemHovered() ) + { - ImGui::BeginTooltip(); - ImGui::Text( "View span" ); - ImGui::EndTooltip(); - } - ImGui::SameLine(); - ImGui::Text( ICON_FA_DATABASE " %-10s", TimeToString( m_worker.GetLastTime() ) ); - if( ImGui::IsItemHovered() ) - { - ImGui::BeginTooltip(); - ImGui::Text( "Time span" ); - ImGui::EndTooltip(); - } - ImGui::SameLine(); - ImGui::Text( ICON_FA_MEMORY " %-10s", MemSizeToString( memUsage ) ); - if( ImGui::IsItemHovered() ) - { - ImGui::BeginTooltip(); - ImGui::Text( "Profiler memory usage" ); - ImGui::EndTooltip(); + ImGui::SameLine(); + ImGui::Spacing(); + ImGui::SameLine(); + const auto targetLabelSize = ImGui::CalcTextSize( "WWWWWWW" ).x; + + auto cx = ImGui::GetCursorPosX(); + ImGui::Text( ICON_FA_EYE " %s", TimeToString( m_vd.zvEnd - m_vd.zvStart ) ); + if( ImGui::IsItemHovered() ) + { + ImGui::BeginTooltip(); + ImGui::Text( "View span" ); + ImGui::EndTooltip(); + } + ImGui::SameLine(); + auto dx = ImGui::GetCursorPosX() - cx; + if( dx < targetLabelSize ) ImGui::SameLine( cx + targetLabelSize ); + + cx = ImGui::GetCursorPosX(); + ImGui::Text( ICON_FA_DATABASE " %s", TimeToString( m_worker.GetLastTime() ) ); + if( ImGui::IsItemHovered() ) + { + ImGui::BeginTooltip(); + ImGui::Text( "Time span" ); + ImGui::EndTooltip(); + } + ImGui::SameLine(); + dx = ImGui::GetCursorPosX() - cx; + if( dx < targetLabelSize ) ImGui::SameLine( cx + targetLabelSize ); + + cx = ImGui::GetCursorPosX(); + ImGui::Text( ICON_FA_MEMORY " %s", MemSizeToString( memUsage ) ); + if( ImGui::IsItemHovered() ) + { + ImGui::BeginTooltip(); + ImGui::Text( "Profiler memory usage" ); + ImGui::EndTooltip(); + } + ImGui::SameLine(); + dx = ImGui::GetCursorPosX() - cx; + if( dx < targetLabelSize ) ImGui::SameLine( cx + targetLabelSize ); + ImGui::Spacing(); } DrawNotificationArea();