Extract small color box drawing.

This commit is contained in:
Bartosz Taudul 2019-09-11 18:38:10 +02:00
parent 00409b0b94
commit 4ea62ecb06
2 changed files with 11 additions and 8 deletions

View File

@ -5,6 +5,8 @@
# pragma warning( disable: 4244 ) // conversion from don't care to whatever, possible loss of data
#endif
#include <stdint.h>
#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

View File

@ -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 ) );