mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
Internals: move "%s" skip-formatting logic to ImFormatStringToTempBuffer() function, meaning Text() and all the *V() functions can also benefit from it. (#3466)
Amend645a6e0
and23a785a
.
This commit is contained in:
@ -274,7 +274,6 @@ void ImGui::TextV(const char* fmt, va_list args)
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
// FIXME-OPT: Handle the %s shortcut?
|
||||
const char* text, *text_end;
|
||||
ImFormatStringToTempBufferV(&text, &text_end, fmt, args);
|
||||
TextEx(text, text_end, ImGuiTextFlags_NoWidthForLargeClippedText);
|
||||
@ -291,10 +290,7 @@ void ImGui::TextColored(const ImVec4& col, const char* fmt, ...)
|
||||
void ImGui::TextColoredV(const ImVec4& col, const char* fmt, va_list args)
|
||||
{
|
||||
PushStyleColor(ImGuiCol_Text, col);
|
||||
if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0)
|
||||
TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting
|
||||
else
|
||||
TextV(fmt, args);
|
||||
TextV(fmt, args);
|
||||
PopStyleColor();
|
||||
}
|
||||
|
||||
@ -310,10 +306,7 @@ void ImGui::TextDisabledV(const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]);
|
||||
if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0)
|
||||
TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting
|
||||
else
|
||||
TextV(fmt, args);
|
||||
TextV(fmt, args);
|
||||
PopStyleColor();
|
||||
}
|
||||
|
||||
@ -328,13 +321,10 @@ void ImGui::TextWrapped(const char* fmt, ...)
|
||||
void ImGui::TextWrappedV(const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
bool need_backup = (g.CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set
|
||||
const bool need_backup = (g.CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set
|
||||
if (need_backup)
|
||||
PushTextWrapPos(0.0f);
|
||||
if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0)
|
||||
TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting
|
||||
else
|
||||
TextV(fmt, args);
|
||||
TextV(fmt, args);
|
||||
if (need_backup)
|
||||
PopTextWrapPos();
|
||||
}
|
||||
|
Reference in New Issue
Block a user