From e1e0e6e1403368a166db7644fe3ca0de166fd6d6 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 17 Aug 2018 23:07:58 +0200 Subject: [PATCH] Centered text helper. --- server/TracyImGui.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/TracyImGui.hpp b/server/TracyImGui.hpp index 2d486185..703eb905 100644 --- a/server/TracyImGui.hpp +++ b/server/TracyImGui.hpp @@ -9,4 +9,16 @@ static inline ImVec2 operator+( const ImVec2& l, const ImVec2& r ) { return ImVe static inline ImVec2 operator-( const ImVec2& l, const ImVec2& r ) { return ImVec2( l.x - r.x, l.y - r.y ); } #endif +namespace tracy +{ + + static inline void TextCentered( const char* text ) + { + const auto tw = ImGui::CalcTextSize( text ).x; + ImGui::SetCursorPosX( ( ImGui::GetWindowWidth() - tw ) * 0.5f ); + ImGui::Text( text ); + } + +} + #endif