diff --git a/server/TracyImGui.hpp b/server/TracyImGui.hpp index e805867e..fd959dcd 100644 --- a/server/TracyImGui.hpp +++ b/server/TracyImGui.hpp @@ -5,6 +5,8 @@ # pragma warning( disable: 4244 ) // conversion from don't care to whatever, possible loss of data #endif +#include + #include "../imgui/imgui.h" #include "../imgui/imgui_internal.h" @@ -65,6 +67,13 @@ namespace tracy return ret; } + static inline void SmallColorBox( uint32_t color ) + { + ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); + ImGui::ColorButton( "c1", ImVec4( (color & 0xFF) / 255.f, ((color>>8) & 0xFF ) / 255.f, ((color>>16) & 0xFF ) / 255.f, 1.f ), ImGuiColorEditFlags_NoTooltip ); + ImGui::PopStyleVar(); + } + } #endif diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 8c4adcdf..5458940f 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -5203,10 +5203,7 @@ void View::DrawZoneInfoWindow() ImGui::SameLine(); ImGui::Text( "%s:%i", m_worker.GetString( srcloc.file ), srcloc.line ); ImGui::SameLine(); - ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); - const auto col = GetRawZoneColor( ev, tid, GetZoneDepth( ev, tid ) ); - ImGui::ColorButton( "c1", ImVec4( (col & 0xFF) / 255.f, ((col>>8) & 0xFF ) / 255.f, ((col>>16) & 0xFF ) / 255.f, 1.f ), ImGuiColorEditFlags_NoTooltip ); - ImGui::PopStyleVar(); + SmallColorBox( GetRawZoneColor( ev, tid, GetZoneDepth( ev, tid ) ) ); TextFocused( "Thread:", m_worker.GetThreadName( tid ) ); ImGui::SameLine(); ImGui::TextDisabled( "(%s)", RealToString( tid, true ) ); @@ -5969,10 +5966,7 @@ void View::DrawGpuInfoWindow() ImGui::SameLine(); ImGui::Text( "%s:%i", m_worker.GetString( srcloc.file ), srcloc.line ); ImGui::SameLine(); - ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); - const auto col = GetRawZoneColor( ev ); - ImGui::ColorButton( "c1", ImVec4( (col & 0xFF) / 255.f, ((col>>8) & 0xFF ) / 255.f, ((col>>16) & 0xFF ) / 255.f, 1.f ), ImGuiColorEditFlags_NoTooltip ); - ImGui::PopStyleVar(); + SmallColorBox( GetRawZoneColor( ev ) ); TextFocused( "Thread:", m_worker.GetThreadName( tid ) ); ImGui::SameLine(); ImGui::TextDisabled( "(%s)", RealToString( tid, true ) );