Commented standard library include with the functions we use. Using ImFormatString in place of sprintf (part of #172)

docking
ocornut 10 years ago
parent 7c8946b9b7
commit 85f432dc8d

@ -339,10 +339,10 @@
#endif #endif
#include "imgui.h" #include "imgui.h"
#include <ctype.h> // toupper #include <ctype.h> // toupper, isprint
#include <math.h> // sqrtf #include <math.h> // sqrtf, fabsf, fmodf, powf, cosf, sinf, floorf, ceilf
#include <stdint.h> // intptr_t #include <stdint.h> // intptr_t
#include <stdio.h> // vsnprintf #include <stdio.h> // vsnprintf, sscanf
#include <new> // new (ptr) #include <new> // new (ptr)
#ifdef _MSC_VER #ifdef _MSC_VER
@ -6710,9 +6710,9 @@ bool ImGui::ColorEdit4(const char* label, float col[4], bool alpha)
const float w_slider_all = w_full - square_sz; const float w_slider_all = w_full - square_sz;
char buf[64]; char buf[64];
if (alpha) if (alpha)
sprintf(buf, "#%02X%02X%02X%02X", ix, iy, iz, iw); ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", ix, iy, iz, iw);
else else
sprintf(buf, "#%02X%02X%02X", ix, iy, iz); ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ix, iy, iz);
ImGui::PushItemWidth(w_slider_all - style.ItemInnerSpacing.x); ImGui::PushItemWidth(w_slider_all - style.ItemInnerSpacing.x);
value_changed |= ImGui::InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal); value_changed |= ImGui::InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal);
ImGui::PopItemWidth(); ImGui::PopItemWidth();
@ -7224,7 +7224,7 @@ void ImGui::Value(const char* prefix, float v, const char* float_format)
if (float_format) if (float_format)
{ {
char fmt[64]; char fmt[64];
sprintf(fmt, "%%s: %s", float_format); ImFormatString(fmt, IM_ARRAYSIZE(fmt), "%%s: %s", float_format);
ImGui::Text(fmt, prefix, v); ImGui::Text(fmt, prefix, v);
} }
else else

@ -9,9 +9,9 @@
#include "imconfig.h" // User-editable configuration file #include "imconfig.h" // User-editable configuration file
#include <float.h> // FLT_MAX #include <float.h> // FLT_MAX
#include <stdarg.h> // va_list #include <stdarg.h> // va_list
#include <stddef.h> // ptrdiff_t #include <stddef.h> // ptrdiff_t, NULL
#include <stdlib.h> // NULL, malloc #include <stdlib.h> // NULL, malloc, free, qsort, atoi
#include <string.h> // memset, memmove #include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
#define IMGUI_VERSION "1.37 WIP" #define IMGUI_VERSION "1.37 WIP"

Loading…
Cancel
Save