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

Separate small callstack button setup.

This commit is contained in:
Bartosz Taudul 2018-07-17 22:53:38 +02:00
parent e7b71f29a5
commit 6485a090ed
2 changed files with 30 additions and 42 deletions

View File

@ -5311,27 +5311,7 @@ void View::ListMemData( T ptr, T end, std::function<const MemEvent*(T&)> 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<const MemEvent*(T&)> 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 );
}
}
}

View File

@ -128,6 +128,8 @@ private:
std::pair<int8_t*, size_t> GetMemoryPages() const;
const char* GetPlotName( const PlotData* plot ) const;
void SmallCallstackButton( const char* name, uint32_t callstack, int& idx );
flat_hash_map<const void*, bool, nohash<const void*>> m_visible;
flat_hash_map<const void*, bool, nohash<const void*>> m_showFull;
flat_hash_map<const void*, int, nohash<const void*>> m_gpuDrift;