1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 12:23:53 +00:00

Remove namespace indent in TracyImGui.hpp.

This commit is contained in:
Bartosz Taudul 2021-05-01 02:26:46 +02:00
parent 57d87af8a2
commit b9ce9540be
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -22,7 +22,7 @@ static inline ImVec2 operator-( const ImVec2& l, const ImVec2& r ) { return ImVe
namespace tracy namespace tracy
{ {
static const ImVec4 SyntaxColors[] = { static const ImVec4 SyntaxColors[] = {
{ 0.7f, 0.7f, 0.7f, 1 }, // default { 0.7f, 0.7f, 0.7f, 1 }, // default
{ 0.45f, 0.68f, 0.32f, 1 }, // comment { 0.45f, 0.68f, 0.32f, 1 }, // comment
{ 0.72f, 0.37f, 0.12f, 1 }, // preprocessor { 0.72f, 0.37f, 0.12f, 1 }, // preprocessor
@ -33,9 +33,9 @@ namespace tracy
{ 0.9f, 0.9f, 0.9f, 1 }, // punctuation { 0.9f, 0.9f, 0.9f, 1 }, // punctuation
{ 0.78f, 0.46f, 0.75f, 1 }, // type { 0.78f, 0.46f, 0.75f, 1 }, // type
{ 0.21f, 0.69f, 0.89f, 1 }, // special { 0.21f, 0.69f, 0.89f, 1 }, // special
}; };
static const ImVec4 SyntaxColorsDimmed[] = { static const ImVec4 SyntaxColorsDimmed[] = {
{ 0.7f, 0.7f, 0.7f, 0.6f }, // default { 0.7f, 0.7f, 0.7f, 0.6f }, // default
{ 0.45f, 0.68f, 0.32f, 0.6f }, // comment { 0.45f, 0.68f, 0.32f, 0.6f }, // comment
{ 0.72f, 0.37f, 0.12f, 0.6f }, // preprocessor { 0.72f, 0.37f, 0.12f, 0.6f }, // preprocessor
@ -46,45 +46,45 @@ namespace tracy
{ 0.9f, 0.9f, 0.9f, 0.6f }, // punctuation { 0.9f, 0.9f, 0.9f, 0.6f }, // punctuation
{ 0.78f, 0.46f, 0.75f, 0.6f }, // type { 0.78f, 0.46f, 0.75f, 0.6f }, // type
{ 0.21f, 0.69f, 0.89f, 0.6f }, // special { 0.21f, 0.69f, 0.89f, 0.6f }, // special
}; };
[[maybe_unused]] static inline void TextCentered( const char* text ) [[maybe_unused]] static inline void TextCentered( const char* text )
{ {
const auto tw = ImGui::CalcTextSize( text ).x; const auto tw = ImGui::CalcTextSize( text ).x;
ImGui::SetCursorPosX( ( ImGui::GetWindowWidth() - tw ) * 0.5f ); ImGui::SetCursorPosX( ( ImGui::GetWindowWidth() - tw ) * 0.5f );
ImGui::TextUnformatted( text ); ImGui::TextUnformatted( text );
} }
[[maybe_unused]] static inline void TextColoredUnformatted( uint32_t col, const char* text, const char* end = nullptr ) [[maybe_unused]] static inline void TextColoredUnformatted( uint32_t col, const char* text, const char* end = nullptr )
{ {
ImGui::PushStyleColor( ImGuiCol_Text, col ); ImGui::PushStyleColor( ImGuiCol_Text, col );
ImGui::TextUnformatted( text, end ); ImGui::TextUnformatted( text, end );
ImGui::PopStyleColor(); ImGui::PopStyleColor();
} }
[[maybe_unused]] static inline void TextColoredUnformatted( const ImVec4& col, const char* text, const char* end = nullptr ) [[maybe_unused]] static inline void TextColoredUnformatted( const ImVec4& col, const char* text, const char* end = nullptr )
{ {
ImGui::PushStyleColor( ImGuiCol_Text, col ); ImGui::PushStyleColor( ImGuiCol_Text, col );
ImGui::TextUnformatted( text, end ); ImGui::TextUnformatted( text, end );
ImGui::PopStyleColor(); ImGui::PopStyleColor();
} }
[[maybe_unused]] static inline void TextDisabledUnformatted( const char* begin, const char* end = nullptr ) [[maybe_unused]] static inline void TextDisabledUnformatted( const char* begin, const char* end = nullptr )
{ {
ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] ); ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] );
ImGui::TextUnformatted( begin, end ); ImGui::TextUnformatted( begin, end );
ImGui::PopStyleColor(); ImGui::PopStyleColor();
} }
[[maybe_unused]] static inline void TextFocused( const char* label, const char* value ) [[maybe_unused]] static inline void TextFocused( const char* label, const char* value )
{ {
TextDisabledUnformatted( label ); TextDisabledUnformatted( label );
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextUnformatted( value ); ImGui::TextUnformatted( value );
} }
[[maybe_unused]] static inline void DrawWaitingDots( double time ) [[maybe_unused]] static inline void DrawWaitingDots( double time )
{ {
ImGui::TextUnformatted( "" ); ImGui::TextUnformatted( "" );
auto draw = ImGui::GetWindowDrawList(); auto draw = ImGui::GetWindowDrawList();
const auto wpos = ImGui::GetWindowPos(); const auto wpos = ImGui::GetWindowPos();
@ -94,25 +94,25 @@ namespace tracy
draw->AddCircleFilled( wpos + ImVec2( w * 0.5f - ty, h ), ty * ( 0.15f + 0.2f * ( pow( cos( time * 3.5f + 0.3f ), 16.f ) ) ), 0xFFBBBBBB, 12 ); draw->AddCircleFilled( wpos + ImVec2( w * 0.5f - ty, h ), ty * ( 0.15f + 0.2f * ( pow( cos( time * 3.5f + 0.3f ), 16.f ) ) ), 0xFFBBBBBB, 12 );
draw->AddCircleFilled( wpos + ImVec2( w * 0.5f , h ), ty * ( 0.15f + 0.2f * ( pow( cos( time * 3.5f ), 16.f ) ) ), 0xFFBBBBBB, 12 ); draw->AddCircleFilled( wpos + ImVec2( w * 0.5f , h ), ty * ( 0.15f + 0.2f * ( pow( cos( time * 3.5f ), 16.f ) ) ), 0xFFBBBBBB, 12 );
draw->AddCircleFilled( wpos + ImVec2( w * 0.5f + ty, h ), ty * ( 0.15f + 0.2f * ( pow( cos( time * 3.5f - 0.3f ), 16.f ) ) ), 0xFFBBBBBB, 12 ); draw->AddCircleFilled( wpos + ImVec2( w * 0.5f + ty, h ), ty * ( 0.15f + 0.2f * ( pow( cos( time * 3.5f - 0.3f ), 16.f ) ) ), 0xFFBBBBBB, 12 );
} }
[[maybe_unused]] static inline bool SmallCheckbox( const char* label, bool* var ) [[maybe_unused]] static inline bool SmallCheckbox( const char* label, bool* var )
{ {
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
auto ret = ImGui::Checkbox( label, var ); auto ret = ImGui::Checkbox( label, var );
ImGui::PopStyleVar(); ImGui::PopStyleVar();
return ret; return ret;
} }
[[maybe_unused]] static inline void SmallColorBox( uint32_t color ) [[maybe_unused]] static inline void SmallColorBox( uint32_t color )
{ {
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
ImGui::ColorButton( "c1", ImVec4( (color & 0xFF) / 255.f, ((color>>8) & 0xFF ) / 255.f, ((color>>16) & 0xFF ) / 255.f, 1.f ), ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop ); ImGui::ColorButton( "c1", ImVec4( (color & 0xFF) / 255.f, ((color>>8) & 0xFF ) / 255.f, ((color>>16) & 0xFF ) / 255.f, 1.f ), ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoDragDrop );
ImGui::PopStyleVar(); ImGui::PopStyleVar();
} }
[[maybe_unused]] static inline bool ButtonDisablable( const char* label, bool disabled ) [[maybe_unused]] static inline bool ButtonDisablable( const char* label, bool disabled )
{ {
if( disabled ) if( disabled )
{ {
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor( 0.3f, 0.3f, 0.3f, 1.0f ) ); ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor( 0.3f, 0.3f, 0.3f, 1.0f ) );
@ -124,10 +124,10 @@ namespace tracy
{ {
return ImGui::Button( label ); return ImGui::Button( label );
} }
} }
[[maybe_unused]] static inline bool SmallButtonDisablable( const char* label, bool disabled ) [[maybe_unused]] static inline bool SmallButtonDisablable( const char* label, bool disabled )
{ {
if( disabled ) if( disabled )
{ {
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor( 0.3f, 0.3f, 0.3f, 1.0f ) ); ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor( 0.3f, 0.3f, 0.3f, 1.0f ) );
@ -143,41 +143,41 @@ namespace tracy
{ {
return ImGui::SmallButton( label ); return ImGui::SmallButton( label );
} }
} }
[[maybe_unused]] static inline void DrawTextContrast( ImDrawList* draw, const ImVec2& pos, uint32_t color, const char* text ) [[maybe_unused]] static inline void DrawTextContrast( ImDrawList* draw, const ImVec2& pos, uint32_t color, const char* text )
{ {
draw->AddText( pos + ImVec2( 1, 1 ), 0xAA000000, text ); draw->AddText( pos + ImVec2( 1, 1 ), 0xAA000000, text );
draw->AddText( pos, color, text ); draw->AddText( pos, color, text );
} }
[[maybe_unused]] static void SetButtonHighlightColor() [[maybe_unused]] static void SetButtonHighlightColor()
{ {
ImGui::PushStyleColor( ImGuiCol_Button, (ImVec4)ImColor::HSV( 0.35f, 0.6f, 0.6f ) ); 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_ButtonHovered, (ImVec4)ImColor::HSV( 0.35f, 0.8f, 0.8f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.35f, 0.7f, 0.7f ) ); ImGui::PushStyleColor( ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV( 0.35f, 0.7f, 0.7f ) );
} }
[[maybe_unused]] static void ToggleButton( const char* label, bool& toggle ) [[maybe_unused]] static void ToggleButton( const char* label, bool& toggle )
{ {
const auto active = toggle; const auto active = toggle;
if( active ) SetButtonHighlightColor(); if( active ) SetButtonHighlightColor();
if( ImGui::Button( label ) ) toggle = !toggle; if( ImGui::Button( label ) ) toggle = !toggle;
if( active ) ImGui::PopStyleColor( 3 ); if( active ) ImGui::PopStyleColor( 3 );
} }
[[maybe_unused]] static void SmallToggleButton( const char* label, bool& toggle ) [[maybe_unused]] static void SmallToggleButton( const char* label, bool& toggle )
{ {
const auto active = toggle; const auto active = toggle;
if( active ) SetButtonHighlightColor(); if( active ) SetButtonHighlightColor();
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
if( ImGui::Button( label ) ) toggle = !toggle; if( ImGui::Button( label ) ) toggle = !toggle;
ImGui::PopStyleVar( 1 ); ImGui::PopStyleVar( 1 );
if( active ) ImGui::PopStyleColor( 3 ); if( active ) ImGui::PopStyleColor( 3 );
} }
[[maybe_unused]] static bool ClipboardButton( int id = 0 ) [[maybe_unused]] static bool ClipboardButton( int id = 0 )
{ {
ImGui::PushStyleColor( ImGuiCol_Border, ImVec4( 0.43f, 0.43f, 0.50f, 0.25f ) ); ImGui::PushStyleColor( ImGuiCol_Border, ImVec4( 0.43f, 0.43f, 0.50f, 0.25f ) );
ImGui::PushStyleColor( ImGuiCol_Button, ImVec4( 0.26f, 0.59f, 0.98f, 0.20f ) ); ImGui::PushStyleColor( ImGuiCol_Button, ImVec4( 0.26f, 0.59f, 0.98f, 0.20f ) );
ImGui::PushStyleColor( ImGuiCol_ButtonHovered, ImVec4( 0.26f, 0.59f, 0.98f, 0.5f ) ); ImGui::PushStyleColor( ImGuiCol_ButtonHovered, ImVec4( 0.26f, 0.59f, 0.98f, 0.5f ) );
@ -188,10 +188,10 @@ namespace tracy
ImGui::PopID(); ImGui::PopID();
ImGui::PopStyleColor( 5 ); ImGui::PopStyleColor( 5 );
return res; return res;
} }
[[maybe_unused]] static void DrawStripedRect( ImDrawList* draw, double x0, double y0, double x1, double y1, double sw, uint32_t color, bool fix_stripes_in_screen_space, bool inverted ) [[maybe_unused]] static void DrawStripedRect( ImDrawList* draw, double x0, double y0, double x1, double y1, double sw, uint32_t color, bool fix_stripes_in_screen_space, bool inverted )
{ {
assert( x1 >= x0 ); assert( x1 >= x0 );
assert( y1 >= y0 ); assert( y1 >= y0 );
assert( sw > 0 ); assert( sw > 0 );
@ -236,7 +236,7 @@ namespace tracy
} }
ImGui::PopClipRect(); ImGui::PopClipRect();
} }
} }