1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 01:20:55 +01:00

Log/Capture: Added LogTextV, a va_list variant of LogText. (#3828)

This commit is contained in:
David Maas 2021-02-22 04:58:51 -06:00 committed by GitHub
parent a8f76c23a4
commit ece854564a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 7 deletions

View File

@ -59,6 +59,7 @@ Other Changes:
- Examples: Reworked setup of clear color to be compatible with transparent values.
- CI: Use a dedicated "scheduled" workflow to trigger scheduled builds. Forks may disable this workflow if
scheduled builds builds are not required. [@rokups]
- Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid]
-----------------------------------------------------------------------

View File

@ -9911,14 +9911,8 @@ void ImGui::EndDragDropTarget()
//-----------------------------------------------------------------------------
// Pass text data straight to log (without being displayed)
void ImGui::LogText(const char* fmt, ...)
static inline void LogTextV(ImGuiContext& g, const char* fmt, va_list args)
{
ImGuiContext& g = *GImGui;
if (!g.LogEnabled)
return;
va_list args;
va_start(args, fmt);
if (g.LogFile)
{
g.LogBuffer.Buf.resize(0);
@ -9929,9 +9923,29 @@ void ImGui::LogText(const char* fmt, ...)
{
g.LogBuffer.appendfv(fmt, args);
}
}
void ImGui::LogText(const char* fmt, ...)
{
ImGuiContext& g = *GImGui;
if (!g.LogEnabled)
return;
va_list args;
va_start(args, fmt);
LogTextV(g, fmt, args);
va_end(args);
}
void ImGui::LogTextV(const char* fmt, va_list args)
{
ImGuiContext& g = *GImGui;
if (!g.LogEnabled)
return;
LogTextV(g, fmt, args);
}
// 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.

View File

@ -748,6 +748,7 @@ namespace ImGui
IMGUI_API void LogFinish(); // stop logging (close file, etc.)
IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard
IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed)
IMGUI_API void LogTextV(const char* fmt, va_list args) IM_FMTLIST(1);
// Drag and Drop
// - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip as replacement)