1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-30 04:43:53 +00:00

Unify coloring of highlighted buttons.

This commit is contained in:
Bartosz Taudul 2018-12-18 16:28:09 +01:00
parent c2485fbcb0
commit b60d5b892a

View File

@ -267,15 +267,17 @@ static void TextFocused( const char* label, const char* value )
ImGui::Text( "%s", value ); ImGui::Text( "%s", value );
} }
static void SetButtonHighlightColor()
{
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.45f, 0.6f, 0.6f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.45f, 0.7f, 0.7f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.45f, 0.8f, 0.8f ) );
}
static void ToggleButton( const char* label, bool& toggle ) static void ToggleButton( const char* label, bool& toggle )
{ {
const auto active = toggle; const auto active = toggle;
if( active ) if( active ) SetButtonHighlightColor();
{
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.45f, 0.6f, 0.6f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.45f, 0.7f, 0.7f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.45f, 0.8f, 0.8f ) );
}
if( ImGui::Button( label ) ) toggle = !toggle; if( ImGui::Button( label ) ) toggle = !toggle;
if( active ) ImGui::PopStyleColor( 3 ); if( active ) ImGui::PopStyleColor( 3 );
} }
@ -3745,9 +3747,7 @@ void View::DrawZoneInfoWindow()
bool hilite = m_callstackInfoWindow == ev.callstack; bool hilite = m_callstackInfoWindow == ev.callstack;
if( hilite ) if( hilite )
{ {
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.f, 0.6f, 0.6f ) ); SetButtonHighlightColor();
ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.f, 0.7f, 0.7f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.f, 0.8f, 0.8f ) );
} }
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
if( ImGui::Button( ICON_FA_ALIGN_JUSTIFY " Call stack" ) ) if( ImGui::Button( ICON_FA_ALIGN_JUSTIFY " Call stack" ) )
@ -3769,9 +3769,7 @@ void View::DrawZoneInfoWindow()
bool hilite = m_textEditorFile == fileName; bool hilite = m_textEditorFile == fileName;
if( hilite ) if( hilite )
{ {
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.f, 0.6f, 0.6f ) ); SetButtonHighlightColor();
ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.f, 0.7f, 0.7f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.f, 0.8f, 0.8f ) );
} }
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
if( ImGui::Button( ICON_FA_FILE_ALT " Source" ) ) if( ImGui::Button( ICON_FA_FILE_ALT " Source" ) )
@ -4106,9 +4104,7 @@ void View::DrawGpuInfoWindow()
bool hilite = m_callstackInfoWindow == ev.callstack; bool hilite = m_callstackInfoWindow == ev.callstack;
if( hilite ) if( hilite )
{ {
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.f, 0.6f, 0.6f ) ); SetButtonHighlightColor();
ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.f, 0.7f, 0.7f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.f, 0.8f, 0.8f ) );
} }
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
if( ImGui::Button( ICON_FA_ALIGN_JUSTIFY " Call stack" ) ) if( ImGui::Button( ICON_FA_ALIGN_JUSTIFY " Call stack" ) )
@ -4130,9 +4126,7 @@ void View::DrawGpuInfoWindow()
bool hilite = m_textEditorFile == fileName; bool hilite = m_textEditorFile == fileName;
if( hilite ) if( hilite )
{ {
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.f, 0.6f, 0.6f ) ); SetButtonHighlightColor();
ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.f, 0.7f, 0.7f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.f, 0.8f, 0.8f ) );
} }
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
if( ImGui::Button( ICON_FA_FILE_ALT " Source" ) ) if( ImGui::Button( ICON_FA_FILE_ALT " Source" ) )
@ -7049,9 +7043,7 @@ void View::DrawInfo()
bool hilite = m_callstackInfoWindow == crash.callstack; bool hilite = m_callstackInfoWindow == crash.callstack;
if( hilite ) if( hilite )
{ {
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.f, 0.6f, 0.6f ) ); SetButtonHighlightColor();
ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.f, 0.7f, 0.7f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.f, 0.8f, 0.8f ) );
} }
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
if( ImGui::Button( ICON_FA_ALIGN_JUSTIFY " Call stack" ) ) if( ImGui::Button( ICON_FA_ALIGN_JUSTIFY " Call stack" ) )
@ -8564,9 +8556,7 @@ void View::SmallCallstackButton( const char* name, uint32_t callstack, int& idx
bool hilite = m_callstackInfoWindow == callstack; bool hilite = m_callstackInfoWindow == callstack;
if( hilite ) if( hilite )
{ {
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.f, 0.6f, 0.6f ) ); SetButtonHighlightColor();
ImGui::PushStyleColor( ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV( 0.f, 0.7f, 0.7f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.f, 0.8f, 0.8f ) );
} }
ImGui::PushID( idx++ ); ImGui::PushID( idx++ );
if( ImGui::SmallButton( name ) ) if( ImGui::SmallButton( name ) )