From d99129f0e490b0d53430bff09896fcad29f8e312 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 3 May 2020 20:40:53 +0200 Subject: [PATCH] Move ToggleButton() out of TracyView.cpp. --- server/TracyImGui.hpp | 15 +++++++++++++++ server/TracyView.cpp | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/server/TracyImGui.hpp b/server/TracyImGui.hpp index f020ee54..f8b1a6b3 100644 --- a/server/TracyImGui.hpp +++ b/server/TracyImGui.hpp @@ -102,6 +102,21 @@ namespace tracy draw->AddText( pos, color, text ); } + static void SetButtonHighlightColor() + { + ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.35f, 0.6f, 0.6f ) ); + ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.35f, 0.8f, 0.8f ) ); + ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.35f, 0.7f, 0.7f ) ); + } + + static void ToggleButton( const char* label, bool& toggle ) + { + const auto active = toggle; + if( active ) SetButtonHighlightColor(); + if( ImGui::Button( label ) ) toggle = !toggle; + if( active ) ImGui::PopStyleColor( 3 ); + } + } #endif diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 834d3d19..84d3bfd7 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -73,21 +73,6 @@ static const char* s_tracyStackFrames[] = { }; -static void SetButtonHighlightColor() -{ - ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.35f, 0.6f, 0.6f ) ); - ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.35f, 0.8f, 0.8f ) ); - ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.35f, 0.7f, 0.7f ) ); -} - -static void ToggleButton( const char* label, bool& toggle ) -{ - const auto active = toggle; - if( active ) SetButtonHighlightColor(); - if( ImGui::Button( label ) ) toggle = !toggle; - if( active ) ImGui::PopStyleColor( 3 ); -} - static inline uint64_t GetThreadBit( uint8_t thread ) { return uint64_t( 1 ) << thread;