MCPcopy Create free account
hub / github.com/RenderKit/embree / LogRenderedText

Method LogRenderedText

tutorials/common/imgui/imgui.cpp:12089–12145  ·  view source on GitHub ↗

Internal version that takes a position to decide on newline placement and pad items according to their depth. We split text into individual lines to add current tree level padding FIXME: This code is a little complicated perhaps, considering simplifying the whole system.

Source from the content-addressed store, hash-verified

12087// We split text into individual lines to add current tree level padding
12088// FIXME: This code is a little complicated perhaps, considering simplifying the whole system.
12089void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end)
12090{
12091 ImGuiContext& g = *GImGui;
12092 ImGuiWindow* window = g.CurrentWindow;
12093
12094 const char* prefix = g.LogNextPrefix;
12095 const char* suffix = g.LogNextSuffix;
12096 g.LogNextPrefix = g.LogNextSuffix = NULL;
12097
12098 if (!text_end)
12099 text_end = FindRenderedTextEnd(text, text_end);
12100
12101 const bool log_new_line = ref_pos && (ref_pos->y > g.LogLinePosY + g.Style.FramePadding.y + 1);
12102 if (ref_pos)
12103 g.LogLinePosY = ref_pos->y;
12104 if (log_new_line)
12105 {
12106 LogText(IM_NEWLINE);
12107 g.LogLineFirstItem = true;
12108 }
12109
12110 if (prefix)
12111 LogRenderedText(ref_pos, prefix, prefix + strlen(prefix)); // Calculate end ourself to ensure "##" are included here.
12112
12113 // Re-adjust padding if we have popped out of our starting depth
12114 if (g.LogDepthRef > window->DC.TreeDepth)
12115 g.LogDepthRef = window->DC.TreeDepth;
12116 const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef);
12117
12118 const char* text_remaining = text;
12119 for (;;)
12120 {
12121 // Split the string. Each new line (after a '\n') is followed by indentation corresponding to the current depth of our log entry.
12122 // We don't add a trailing \n yet to allow a subsequent item on the same line to be captured.
12123 const char* line_start = text_remaining;
12124 const char* line_end = ImStreolRange(line_start, text_end);
12125 const bool is_last_line = (line_end == text_end);
12126 if (line_start != line_end || !is_last_line)
12127 {
12128 const int line_length = (int)(line_end - line_start);
12129 const int indentation = g.LogLineFirstItem ? tree_depth * 4 : 1;
12130 LogText("%*s%.*s", indentation, "", line_length, line_start);
12131 g.LogLineFirstItem = false;
12132 if (*line_end == '\n')
12133 {
12134 LogText(IM_NEWLINE);
12135 g.LogLineFirstItem = true;
12136 }
12137 }
12138 if (is_last_line)
12139 break;
12140 text_remaining = line_end + 1;
12141 }
12142
12143 if (suffix)
12144 LogRenderedText(ref_pos, suffix, suffix + strlen(suffix));
12145}
12146

Callers

nothing calls this directly

Calls 1

ImStreolRangeFunction · 0.85

Tested by

no test coverage detected