From 0d41a6c48bbe5651558b361dd0ee1464b7b3a816 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 2 Jul 2022 15:27:08 +0200 Subject: [PATCH] Move DrawHistogramMinMaxLabel() to TracyImGui.cpp. --- server/TracyImGui.cpp | 20 ++++++++++++++++++++ server/TracyImGui.hpp | 1 + server/TracyView.cpp | 19 ------------------- server/TracyView.hpp | 2 -- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/server/TracyImGui.cpp b/server/TracyImGui.cpp index df767bb0..b50b818e 100644 --- a/server/TracyImGui.cpp +++ b/server/TracyImGui.cpp @@ -1,3 +1,4 @@ +#include "TracyPrint.hpp" #include "TracyImGui.hpp" namespace tracy @@ -98,4 +99,23 @@ void DrawStripedRect( ImDrawList* draw, const ImVec2& wpos, double x0, double y0 ImGui::PopClipRect(); } +void DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImVec2 wpos, float w, float ty ) +{ + const auto dpos = wpos + ImVec2( 0.5f, 0.5f ); + const auto ty15 = round( ty * 1.5f ); + const auto mintxt = TimeToString( tmin ); + const auto maxtxt = TimeToString( tmax ); + const auto maxsz = ImGui::CalcTextSize( maxtxt ).x; + DrawLine( draw, dpos, dpos + ImVec2( 0, ty15 ), 0x66FFFFFF ); + DrawLine( draw, dpos + ImVec2( w-1, 0 ), dpos + ImVec2( w-1, ty15 ), 0x66FFFFFF ); + draw->AddText( wpos + ImVec2( 0, ty15 ), 0x66FFFFFF, mintxt ); + draw->AddText( wpos + ImVec2( w-1-maxsz, ty15 ), 0x66FFFFFF, maxtxt ); + + char range[64]; + sprintf( range, ICON_FA_LONG_ARROW_ALT_LEFT " %s " ICON_FA_LONG_ARROW_ALT_RIGHT, TimeToString( tmax - tmin ) ); + + const auto rsz = ImGui::CalcTextSize( range ).x; + draw->AddText( wpos + ImVec2( round( (w-1-rsz) * 0.5 ), ty15 ), 0x66FFFFFF, range ); +} + } diff --git a/server/TracyImGui.hpp b/server/TracyImGui.hpp index 4017a3c7..890fe815 100644 --- a/server/TracyImGui.hpp +++ b/server/TracyImGui.hpp @@ -25,6 +25,7 @@ namespace tracy void DrawZigZag( ImDrawList* draw, const ImVec2& wpos, double start, double end, double h, uint32_t color, float thickness = 1.f ); void DrawStripedRect( ImDrawList* draw, const ImVec2& wpos, double x0, double y0, double x1, double y1, double sw, uint32_t color, bool fix_stripes_in_screen_space, bool inverted ); +void DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImVec2 wpos, float w, float ty ); static constexpr const ImVec4 SyntaxColors[] = { diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 189024cc..df36b962 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -3632,25 +3632,6 @@ int View::SkipGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, return maxdepth; } -void View::DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImVec2 wpos, float w, float ty ) -{ - const auto dpos = wpos + ImVec2( 0.5f, 0.5f ); - const auto ty15 = round( ty * 1.5f ); - const auto mintxt = TimeToString( tmin ); - const auto maxtxt = TimeToString( tmax ); - const auto maxsz = ImGui::CalcTextSize( maxtxt ).x; - DrawLine( draw, dpos, dpos + ImVec2( 0, ty15 ), 0x66FFFFFF ); - DrawLine( draw, dpos + ImVec2( w-1, 0 ), dpos + ImVec2( w-1, ty15 ), 0x66FFFFFF ); - draw->AddText( wpos + ImVec2( 0, ty15 ), 0x66FFFFFF, mintxt ); - draw->AddText( wpos + ImVec2( w-1-maxsz, ty15 ), 0x66FFFFFF, maxtxt ); - - char range[64]; - sprintf( range, ICON_FA_LONG_ARROW_ALT_LEFT " %s " ICON_FA_LONG_ARROW_ALT_RIGHT, TimeToString( tmax - tmin ) ); - - const auto rsz = ImGui::CalcTextSize( range ).x; - draw->AddText( wpos + ImVec2( round( (w-1-rsz) * 0.5 ), ty15 ), 0x66FFFFFF, range ); -} - void View::DrawTextEditor() { const auto scale = GetScale(); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 8fbef937..790b98a5 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -387,8 +387,6 @@ private: void AdjustThreadHeight( View::VisData& vis, int oldOffset, int& offset ); float AdjustThreadPosition( View::VisData& vis, float wy, int& offset ); - - void DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImVec2 wpos, float w, float ty ); static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift ); static const char* DecodeContextSwitchState( uint8_t state );