From 6485a090ed9e07a1c4432549ee2f9edaa3a50452 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 17 Jul 2018 22:53:38 +0200 Subject: [PATCH] Separate small callstack button setup. --- server/TracyView.cpp | 70 ++++++++++++++++++-------------------------- server/TracyView.hpp | 2 ++ 2 files changed, 30 insertions(+), 42 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 24e62466..b4648e90 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -5311,27 +5311,7 @@ void View::ListMemData( T ptr, T end, std::function DrawAdd } else { - bool hilite = m_callstackInfoWindow == v->csAlloc; - if( hilite ) - { - ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.f, 0.6f, 0.6f ) ); - ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.f, 0.7f, 0.7f ) ); - ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.f, 0.8f, 0.8f ) ); - } - ImGui::PushID( idx++ ); - if( ImGui::SmallButton( "alloc" ) ) - { - m_callstackInfoWindow = v->csAlloc; - } - ImGui::PopID(); - if( hilite ) - { - ImGui::PopStyleColor( 3 ); - } - if( ImGui::IsItemHovered() ) - { - CallstackTooltip( v->csAlloc ); - } + SmallCallstackButton( "alloc", v->csAlloc, idx ); } ImGui::SameLine(); ImGui::Spacing(); @@ -5342,27 +5322,7 @@ void View::ListMemData( T ptr, T end, std::function DrawAdd } else { - bool hilite = m_callstackInfoWindow == v->csFree; - if( hilite ) - { - ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.f, 0.6f, 0.6f ) ); - ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.f, 0.7f, 0.7f ) ); - ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.f, 0.8f, 0.8f ) ); - } - ImGui::PushID( idx++ ); - if( ImGui::SmallButton( "free" ) ) - { - m_callstackInfoWindow = v->csFree; - } - ImGui::PopID(); - if( hilite ) - { - ImGui::PopStyleColor( 3 ); - } - if( ImGui::IsItemHovered() ) - { - CallstackTooltip( v->csFree ); - } + SmallCallstackButton( "free", v->csFree, idx ); } ImGui::NextColumn(); ptr++; @@ -6203,4 +6163,30 @@ void View::FindZonesCompare() } #endif +void View::SmallCallstackButton( const char* name, uint32_t callstack, int& idx ) +{ + bool hilite = m_callstackInfoWindow == callstack; + if( hilite ) + { + ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.f, 0.6f, 0.6f ) ); + ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.f, 0.7f, 0.7f ) ); + ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.f, 0.8f, 0.8f ) ); + } + ImGui::PushID( idx++ ); + if( ImGui::SmallButton( name ) ) + { + m_callstackInfoWindow = callstack; + } + ImGui::PopID(); + if( hilite ) + { + ImGui::PopStyleColor( 3 ); + } + if( ImGui::IsItemHovered() ) + { + CallstackTooltip( callstack ); + } + +} + } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index b08f9e89..faec75c2 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -128,6 +128,8 @@ private: std::pair GetMemoryPages() const; const char* GetPlotName( const PlotData* plot ) const; + void SmallCallstackButton( const char* name, uint32_t callstack, int& idx ); + flat_hash_map> m_visible; flat_hash_map> m_showFull; flat_hash_map> m_gpuDrift;