From 293c76625cee827c75b94402e6098f049898637a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 28 Sep 2024 01:53:26 +0200 Subject: [PATCH] Add centered button function. --- profiler/src/profiler/TracyImGui.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/profiler/src/profiler/TracyImGui.hpp b/profiler/src/profiler/TracyImGui.hpp index 70b1b9b4..505d91d0 100644 --- a/profiler/src/profiler/TracyImGui.hpp +++ b/profiler/src/profiler/TracyImGui.hpp @@ -83,6 +83,13 @@ static constexpr const uint32_t AsmSyntaxColors[] = { ImGui::TextUnformatted( text ); } +[[maybe_unused]] static inline bool ButtonCentered( const char* text ) +{ + const auto tw = ImGui::CalcTextSize( text ).x + ImGui::GetStyle().FramePadding.x * 2; + ImGui::SetCursorPosX( ( ImGui::GetWindowWidth() - tw ) * 0.5f ); + return ImGui::Button( text ); +} + [[maybe_unused]] static inline void TextColoredUnformatted( uint32_t col, const char* text, const char* end = nullptr ) { ImGui::PushStyleColor( ImGuiCol_Text, col );