56 #if (defined __SSE__ || defined __x86_64__ || defined _M_X64) && !defined(IMGUI_DISABLE_SSE)
57 #define IMGUI_ENABLE_SSE
58 #include <immintrin.h>
63 #pragma warning (push)
64 #pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
65 #pragma warning (disable: 26812) // The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer)
66 #pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
67 #if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
68 #pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
73 #if defined(__clang__)
74 #pragma clang diagnostic push
75 #if __has_warning("-Wunknown-warning-option")
76 #pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx'
78 #pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx'
79 #pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants ok, for ImFloorSigned()
80 #pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h
81 #pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h
82 #pragma clang diagnostic ignored "-Wold-style-cast"
83 #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
84 #pragma clang diagnostic ignored "-Wdouble-promotion"
85 #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
86 #pragma clang diagnostic ignored "-Wmissing-noreturn" // warning: function 'xxx' could be declared with attribute 'noreturn'
87 #elif defined(__GNUC__)
88 #pragma GCC diagnostic push
89 #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
90 #pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
94 #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74
95 #error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
97 #ifdef IMGUI_DISABLE_MATH_FUNCTIONS // Renamed in 1.74
98 #error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
103 #ifndef IMGUI_ENABLE_FREETYPE
104 #define IMGUI_ENABLE_STB_TRUETYPE
139 struct ImGuiTableColumnsSettings;
178 #undef STB_TEXTEDIT_STRING
179 #undef STB_TEXTEDIT_CHARTYPE
180 #define STB_TEXTEDIT_STRING ImGuiInputTextState
181 #define STB_TEXTEDIT_CHARTYPE ImWchar
182 #define STB_TEXTEDIT_GETWIDTH_NEWLINE (-1.0f)
183 #define STB_TEXTEDIT_UNDOSTATECOUNT 99
184 #define STB_TEXTEDIT_UNDOCHARCOUNT 999
194 #ifndef IMGUI_DEBUG_LOG
195 #define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
201 #define IMGUI_DEBUG_LOG_POPUP(...) ((void)0) // Disable log
202 #define IMGUI_DEBUG_LOG_NAV(...) ((void)0) // Disable log
205 #if (__cplusplus >= 201100) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201100)
206 #define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
208 #define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1]
214 #ifdef IMGUI_DEBUG_PARANOID
215 #define IM_ASSERT_PARANOID(_EXPR) IM_ASSERT(_EXPR)
217 #define IM_ASSERT_PARANOID(_EXPR)
222 #ifndef IM_ASSERT_USER_ERROR
223 #define IM_ASSERT_USER_ERROR(_EXP,_MSG) IM_ASSERT((_EXP) && _MSG) // Recoverable User Error
227 #define IM_PI 3.14159265358979323846f
229 #define IM_NEWLINE "\r\n" // Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!)
231 #define IM_NEWLINE "\n"
233 #define IM_TABSIZE (4)
234 #define IM_MEMALIGN(_OFF,_ALIGN) (((_OFF) + (_ALIGN - 1)) & ~(_ALIGN - 1)) // Memory align e.g. IM_ALIGN(0,4)=0, IM_ALIGN(1,4)=4, IM_ALIGN(4,4)=4, IM_ALIGN(5,4)=8
235 #define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose
236 #define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255
237 #define IM_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds
238 #define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) //
242 #define IMGUI_CDECL __cdecl
248 #if defined(_MSC_VER) && !defined(__clang__)
249 #define IM_MSVC_WARNING_SUPPRESS(XXXX) __pragma(warning(suppress: XXXX))
251 #define IM_MSVC_WARNING_SUPPRESS(XXXX)
256 #ifndef IM_DEBUG_BREAK
257 #if defined(__clang__)
258 #define IM_DEBUG_BREAK() __builtin_debugtrap()
259 #elif defined (_MSC_VER)
260 #define IM_DEBUG_BREAK() __debugbreak()
262 #define IM_DEBUG_BREAK() IM_ASSERT(0) // It is expected that you define IM_DEBUG_BREAK() into something that will break nicely in a debugger!
264 #endif // #ifndef IM_DEBUG_BREAK
292 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
297 #define ImQsort qsort
303 static inline bool ImIsPowerOfTwo(
int v) {
return v != 0 && (v & (v - 1)) == 0; }
305 static inline int ImUpperPowerOfTwo(
int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++;
return v; }
317 IMGUI_API const char*
ImStristr(
const char* haystack,
const char* haystack_end,
const char* needle,
const char* needle_end);
327 static inline bool ImCharIsBlankW(
unsigned int c) {
return c ==
' ' || c ==
'\t' || c == 0x3000; }
341 #ifdef IMGUI_DEFINE_MATH_OPERATORS
343 static inline ImVec2 operator*(
const ImVec2& lhs,
const float rhs) {
return ImVec2(lhs.
x * rhs, lhs.
y * rhs); }
344 static inline ImVec2 operator/(
const ImVec2& lhs,
const float rhs) {
return ImVec2(lhs.
x / rhs, lhs.
y / rhs); }
349 static inline ImVec2& operator*=(
ImVec2& lhs,
const float rhs) { lhs.
x *= rhs; lhs.
y *= rhs;
return lhs; }
350 static inline ImVec2& operator/=(
ImVec2& lhs,
const float rhs) { lhs.
x /= rhs; lhs.
y /= rhs;
return lhs; }
354 static inline ImVec2& operator/=(
ImVec2& lhs,
const ImVec2& rhs) { lhs.
x /= rhs.
x; lhs.
y /= rhs.
y;
return lhs; }
362 #ifdef IMGUI_DISABLE_FILE_FUNCTIONS
363 #define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
371 #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
379 #define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions
386 #ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
387 #define ImFabs(X) fabsf(X)
388 #define ImSqrt(X) sqrtf(X)
389 #define ImFmod(X, Y) fmodf((X), (Y))
390 #define ImCos(X) cosf(X)
391 #define ImSin(X) sinf(X)
392 #define ImAcos(X) acosf(X)
393 #define ImAtan2(Y, X) atan2f((Y), (X))
394 #define ImAtof(STR) atof(STR)
396 #define ImCeil(X) ceilf(X)
397 static inline float ImPow(
float x,
float y) {
return powf(x, y); }
398 static inline double ImPow(
double x,
double y) {
return pow(x, y); }
399 static inline float ImLog(
float x) {
return logf(x); }
400 static inline double ImLog(
double x) {
return log(x); }
401 static inline int ImAbs(
int x) {
return x < 0 ? -x :
x; }
402 static inline float ImAbs(
float x) {
return fabsf(x); }
403 static inline double ImAbs(
double x) {
return fabs(x); }
404 static inline float ImSign(
float x) {
return (x < 0.0f) ? -1.0f : ((x > 0.0f) ? 1.0f : 0.0f); }
405 static inline double ImSign(
double x) {
return (x < 0.0) ? -1.0 : ((x > 0.0) ? 1.0 : 0.0); }
406 #ifdef IMGUI_ENABLE_SSE
407 static inline float ImRsqrt(
float x) {
return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x))); }
409 static inline float ImRsqrt(
float x) {
return 1.0f / sqrtf(x); }
411 static inline double ImRsqrt(
double x) {
return 1.0 / sqrt(x); }
415 template<
typename T>
static inline T
ImMin(T lhs, T rhs) {
return lhs < rhs ? lhs : rhs; }
416 template<
typename T>
static inline T
ImMax(T lhs, T rhs) {
return lhs >= rhs ? lhs : rhs; }
417 template<
typename T>
static inline T
ImClamp(T v, T mn, T mx) {
return (v < mn) ? mn : (v > mx) ? mx : v; }
418 template<
typename T>
static inline T
ImLerp(T a, T b,
float t) {
return (T)(a + (b - a) * t); }
419 template<
typename T>
static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
420 template<
typename T>
static inline T
ImAddClampOverflow(T a, T b, T mn, T mx) {
if (b < 0 && (a < mn - b))
return mn;
if (b > 0 && (a > mx - b))
return mx;
return a + b; }
421 template<
typename T>
static inline T
ImSubClampOverflow(T a, T b, T mn, T mx) {
if (b > 0 && (a < mn + b))
return mn;
if (b < 0 && (a > mx + b))
return mx;
return a - b; }
429 static inline float ImSaturate(
float f) {
return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
432 static inline float ImInvLength(
const ImVec2& lhs,
float fail_value) {
float d = (lhs.
x * lhs.
x) + (lhs.
y * lhs.
y);
if (d > 0.0f)
return ImRsqrt(d);
return fail_value; }
433 static inline float ImFloor(
float f) {
return (
float)(
int)(f); }
434 static inline float ImFloorSigned(
float f) {
return (
float)((f >= 0 || (
int)f == f) ? (
int)f : (
int)f - 1); }
439 static inline float ImLinearSweep(
float current,
float target,
float speed) {
if (current < target)
return ImMin(current + speed, target);
if (current > target)
return ImMax(current - speed, target);
return current; }
481 ImRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {}
484 ImRect(
float x1,
float y1,
float x2,
float y2) : Min(x1, y1), Max(x2, y2) {}
490 float GetArea()
const {
return (Max.x - Min.x) * (Max.y - Min.y); }
495 bool Contains(
const ImVec2& p)
const {
return p.
x >= Min.x && p.
y >= Min.y && p.
x < Max.x && p.
y < Max.y; }
498 void Add(
const ImVec2& p) {
if (Min.x > p.
x) Min.x = p.
x;
if (Min.y > p.
y) Min.y = p.
y;
if (Max.x < p.
x) Max.x = p.
x;
if (Max.y < p.
y) Max.y = p.
y; }
500 void Expand(
const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
501 void Expand(
const ImVec2& amount) { Min.x -= amount.
x; Min.y -= amount.
y; Max.x += amount.
x; Max.y += amount.
y; }
508 bool IsInverted()
const {
return Min.x > Max.x || Min.y > Max.y; }
522 int a_mod = (n & 31);
523 int b_mod = (n2 > (n | 31) ? 31 : (n2 & 31)) + 1;
532 template<
int BITCOUNT>
535 ImU32 Storage[(BITCOUNT + 31) >> 5];
550 void Create(
int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (
size_t)Storage.Size *
sizeof(Storage.Data[0])); }
622 T*
GetByKey(
ImGuiID key) {
int idx = Map.GetInt(key, -1);
return (idx != -1) ? &Buf[idx] : NULL; }
624 ImPoolIdx
GetIndex(
const T* p)
const {
IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size);
return (ImPoolIdx)(p - Buf.Data); }
625 T*
GetOrAddByKey(
ImGuiID key) {
int* p_idx = Map.GetIntRef(key, -1);
if (*p_idx != -1)
return &Buf[*p_idx]; *p_idx = FreeIdx;
return Add(); }
626 bool Contains(
const T* p)
const {
return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
627 void Clear() {
for (
int n = 0; n < Map.Data.Size; n++) {
int idx = Map.Data[n].val_i;
if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = AliveCount = 0; }
628 T*
Add() {
int idx = FreeIdx;
if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; }
else { FreeIdx = *(
int*)&Buf[idx]; }
IM_PLACEMENT_NEW(&Buf[idx]) T(); AliveCount++;
return &Buf[idx]; }
630 void Remove(
ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(
int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); AliveCount--; }
631 void Reserve(
int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); }
638 T*
TryGetMapData(ImPoolIdx n) {
int idx = Map.Data[n].val_i;
if (idx == -1)
return NULL;
return GetByIndex(idx); }
639 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
655 bool empty()
const {
return Buf.Size == 0; }
656 int size()
const {
return Buf.Size; }
657 T*
alloc_chunk(
size_t sz) {
size_t HDR_SZ = 4; sz =
IM_MEMALIGN(HDR_SZ + sz, 4u);
int off = Buf.Size; Buf.resize(off + (
int)sz); ((
int*)(
void*)(Buf.Data + off))[0] = (
int)sz;
return (T*)(
void*)(Buf.Data + off + (
int)HDR_SZ); }
658 T*
begin() {
size_t HDR_SZ = 4;
if (!Buf.Data)
return NULL;
return (T*)(
void*)(Buf.Data + HDR_SZ); }
659 T*
next_chunk(T* p) {
size_t HDR_SZ = 4;
IM_ASSERT(p >= begin() && p < end()); p = (T*)(
void*)((
char*)(
void*)p + chunk_size(p));
if (p == (T*)(
void*)((
char*)end() + HDR_SZ))
return (T*)0;
IM_ASSERT(p < end());
return p; }
661 T*
end() {
return (T*)(
void*)(Buf.Data + Buf.Size); }
662 int offset_from_ptr(
const T* p) {
IM_ASSERT(p >= begin() && p < end());
const ptrdiff_t off = (
const char*)p - Buf.Data; return (
int)off; }
683 #define IM_ROUNDUP_TO_EVEN(_V) ((((_V) + 1) / 2) * 2)
684 #define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN 4
685 #define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX 512
686 #define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR) ImClamp(IM_ROUNDUP_TO_EVEN((int)ImCeil(IM_PI / ImAcos(1 - ImMin((_MAXERROR), (_RAD)) / (_RAD)))), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX)
689 #define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(_N,_MAXERROR) ((_MAXERROR) / (1 - ImCos(IM_PI / ImMax((float)(_N), IM_PI))))
690 #define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_ERROR(_N,_RAD) ((1 - ImCos(IM_PI / ImMax((float)(_N), IM_PI))) / (_RAD))
693 #ifndef IM_DRAWLIST_ARCFAST_TABLE_SIZE
694 #define IM_DRAWLIST_ARCFAST_TABLE_SIZE 48 // Number of samples in lookup table.
696 #define IM_DRAWLIST_ARCFAST_SAMPLE_MAX IM_DRAWLIST_ARCFAST_TABLE_SIZE // Sample index _PathArcToFastEx() for 360 angle.
717 void SetCircleTessellationMaxError(
float max_error);
764 #ifdef IMGUI_ENABLE_TEST_ENGINE
766 ImGuiItemStatusFlags_Openable = 1 << 20,
767 ImGuiItemStatusFlags_Opened = 1 << 21,
768 ImGuiItemStatusFlags_Checkable = 1 << 22,
769 ImGuiItemStatusFlags_Checked = 1 << 23
999 void Update(
float spacing,
bool window_reappearing);
1000 float DeclColumns(
float w_icon,
float w_label,
float w_shortcut,
float w_mark);
1001 void CalcNextTotalWidth(
bool update_offsets);
1026 void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); }
1030 void OnKeyPressed(
int key);
1034 void CursorClamp() { Stb.cursor =
ImMin(Stb.cursor, CurLenW); Stb.select_start =
ImMin(Stb.select_start, CurLenW); Stb.select_end =
ImMin(Stb.select_end, CurLenW); }
1040 void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
1138 void SetToCurrentState();
1139 void CompareWithCurrentState();
1263 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1308 #ifdef IMGUI_HAS_MULTI_SELECT
1310 #endif // #ifdef IMGUI_HAS_MULTI_SELECT
1316 #ifdef IMGUI_HAS_DOCK
1318 #endif // #ifdef IMGUI_HAS_DOCK
2014 ImGuiID GetID(
const char* str,
const char* str_end = NULL);
2017 ImGuiID GetIDNoKeepAlive(
const char* str,
const char* str_end = NULL);
2018 ImGuiID GetIDNoKeepAlive(
const void* ptr);
2019 ImGuiID GetIDNoKeepAlive(
int n);
2028 ImRect MenuBarRect()
const {
float y1 = Pos.y + TitleBarHeight();
return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
2117 #define IM_COL32_DISABLE IM_COL32(0,0,0,1) // Special sentinel code which cannot be used as a regular color.
2118 #define IMGUI_TABLE_MAX_COLUMNS 64 // sizeof(ImU64) * 8. This is solely because we frequently encode columns set in a ImU64.
2119 #define IMGUI_TABLE_MAX_DRAW_CHANNELS (4 + 64 * 2) // See TableSetupDrawChannels()
2175 memset(
this, 0,
sizeof(*
this));
2479 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
2513 IMGUI_API bool MenuItemEx(
const char* label,
const char* icon,
const char* shortcut = NULL,
bool selected =
false,
bool enabled =
true);
2661 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
2696 template<
typename T,
typename SIGNED_T,
typename FLOAT_T>
IMGUI_API float ScaleRatioFromValueT(
ImGuiDataType data_type, T v, T v_min, T v_max,
bool is_logarithmic,
float logarithmic_zero_epsilon,
float zero_deadzone_size);
2697 template<
typename T,
typename SIGNED_T,
typename FLOAT_T>
IMGUI_API T
ScaleValueFromRatioT(
ImGuiDataType data_type,
float t, T v_min, T v_max,
bool is_logarithmic,
float logarithmic_zero_epsilon,
float zero_deadzone_size);
2699 template<
typename T,
typename SIGNED_T,
typename FLOAT_T>
IMGUI_API bool SliderBehaviorT(
const ImRect& bb,
ImGuiID id,
ImGuiDataType data_type, T* v, T v_min, T v_max,
const char* format,
ImGuiSliderFlags flags,
ImRect* out_grab_bb);
2724 IMGUI_API int PlotEx(
ImGuiPlotType plot_type,
const char* label,
float (*values_getter)(
void*
data,
int idx),
void* data,
int values_count,
int values_offset,
const char* overlay_text,
float scale_min,
float scale_max,
ImVec2 frame_size);
2785 #ifdef IMGUI_ENABLE_TEST_ENGINE
2788 extern void ImGuiTestEngineHook_Log(
ImGuiContext* ctx,
const char* fmt, ...);
2791 #define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box
2792 #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional)
2793 #define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log
2795 #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) ((void)0)
2800 #if defined(__clang__)
2801 #pragma clang diagnostic pop
2802 #elif defined(__GNUC__)
2803 #pragma GCC diagnostic pop
2807 #pragma warning (pop)
2810 #endif // #ifndef IMGUI_DISABLE