mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-15 05:15:23 +00:00
Add ImGui::SameLine() capable wrapped text printing function.
Adapted from imgui_markdown.
This commit is contained in:
@@ -127,4 +127,24 @@ void PrintSource( const std::vector<Tokenizer::Line>& lines )
|
||||
}
|
||||
}
|
||||
|
||||
void PrintTextWrapped( const char* text, const char* end )
|
||||
{
|
||||
if( !end ) end = text + strlen( text );
|
||||
|
||||
auto scale = ImGui::GetIO().FontGlobalScale;
|
||||
auto left = ImGui::GetContentRegionAvail().x;
|
||||
auto endLine = ImGui::GetFont()->CalcWordWrapPositionA( scale, text, end, left );
|
||||
ImGui::TextUnformatted( text, endLine );
|
||||
|
||||
left = ImGui::GetContentRegionAvail().x;
|
||||
while( endLine < end )
|
||||
{
|
||||
text = endLine;
|
||||
if( *text == ' ' ) text++;
|
||||
endLine = ImGui::GetFont()->CalcWordWrapPositionA( scale, text, end, left );
|
||||
if( text == endLine ) endLine++;
|
||||
ImGui::TextUnformatted( text, endLine );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ void DrawZigZag( ImDrawList* draw, const ImVec2& wpos, double start, double end,
|
||||
void DrawStripedRect( ImDrawList* draw, const ImVec2& wpos, double x0, double y0, double x1, double y1, double sw, uint32_t color, bool fix_stripes_in_screen_space, bool inverted );
|
||||
void DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImVec2 wpos, float w, float ty );
|
||||
void PrintSource( const std::vector<Tokenizer::Line>& lines );
|
||||
void PrintTextWrapped( const char* text, const char* end = nullptr );
|
||||
|
||||
|
||||
static constexpr const uint32_t SyntaxColors[] = {
|
||||
|
||||
Reference in New Issue
Block a user