Move ToggleButton() out of TracyView.cpp.

This commit is contained in:
Bartosz Taudul 2020-05-03 20:40:53 +02:00
parent 5ad1023088
commit d99129f0e4
2 changed files with 15 additions and 15 deletions

View File

@ -102,6 +102,21 @@ namespace tracy
draw->AddText( pos, color, text ); 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 #endif

View File

@ -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 ) static inline uint64_t GetThreadBit( uint8_t thread )
{ {
return uint64_t( 1 ) << thread; return uint64_t( 1 ) << thread;