31 #error Must include imgui.h before imgui_internal.h
41 #pragma warning (push)
42 #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)
46 #if defined(__clang__)
47 #pragma clang diagnostic push
48 #pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h
49 #pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h
50 #pragma clang diagnostic ignored "-Wold-style-cast"
51 #if __has_warning("-Wzero-as-null-pointer-constant")
52 #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
54 #if __has_warning("-Wdouble-promotion")
55 #pragma clang diagnostic ignored "-Wdouble-promotion"
57 #elif defined(__GNUC__)
58 #pragma GCC diagnostic push
59 #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
60 #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
64 #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74
65 #error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
67 #ifdef IMGUI_DISABLE_MATH_FUNCTIONS // Renamed in 1.74
68 #error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
123 #undef STB_TEXTEDIT_STRING
124 #undef STB_TEXTEDIT_CHARTYPE
125 #define STB_TEXTEDIT_STRING ImGuiInputTextState
126 #define STB_TEXTEDIT_CHARTYPE ImWchar
127 #define STB_TEXTEDIT_GETWIDTH_NEWLINE -1.0f
128 #define STB_TEXTEDIT_UNDOSTATECOUNT 99
129 #define STB_TEXTEDIT_UNDOCHARCOUNT 999
147 #ifndef IMGUI_DEBUG_LOG
148 #define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
152 #if (__cplusplus >= 201100)
153 #define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
155 #define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1]
159 #define IMGUI_DEBUG_PARANOID 0
160 #if IMGUI_DEBUG_PARANOID
161 #define IM_ASSERT_PARANOID(_EXPR) IM_ASSERT(_EXPR)
163 #define IM_ASSERT_PARANOID(_EXPR)
168 #ifndef IM_ASSERT_USER_ERROR
169 #define IM_ASSERT_USER_ERROR(_EXP,_MSG) IM_ASSERT((_EXP) && (_MSG)) // Recoverable User Error
173 #define IM_PI 3.14159265358979323846f
175 #define IM_NEWLINE "\r\n" // Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!)
177 #define IM_NEWLINE "\n"
179 #define IM_TABSIZE (4)
180 #define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose
181 #define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255
182 #define IM_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds
183 #define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) //
187 #define IMGUI_CDECL __cdecl
208 #define ImQsort qsort
211 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
217 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; }
229 IMGUI_API const char*
ImStristr(
const char* haystack,
const char* haystack_end,
const char* needle,
const char* needle_end);
239 static inline bool ImCharIsBlankW(
unsigned int c) {
return c ==
' ' || c ==
'\t' || c == 0x3000; }
252 #ifdef IMGUI_DEFINE_MATH_OPERATORS
253 static inline ImVec2 operator*(
const ImVec2& lhs,
const float rhs) {
return ImVec2(lhs.
x*rhs, lhs.
y*rhs); }
254 static inline ImVec2 operator/(
const ImVec2& lhs,
const float rhs) {
return ImVec2(lhs.
x/rhs, lhs.
y/rhs); }
259 static inline ImVec2& operator+=(
ImVec2& lhs,
const ImVec2& rhs) { lhs.
x += rhs.
x; lhs.
y += rhs.
y;
return lhs; }
260 static inline ImVec2& operator-=(
ImVec2& lhs,
const ImVec2& rhs) { lhs.
x -= rhs.
x; lhs.
y -= rhs.
y;
return lhs; }
261 static inline ImVec2& operator*=(
ImVec2& lhs,
const float rhs) { lhs.
x *= rhs; lhs.
y *= rhs;
return lhs; }
262 static inline ImVec2& operator/=(
ImVec2& lhs,
const float rhs) { lhs.
x /= rhs; lhs.
y /= rhs;
return lhs; }
269 #if defined(__EMSCRIPTEN__) && !defined(IMGUI_DISABLE_FILE_FUNCTIONS)
270 #define IMGUI_DISABLE_FILE_FUNCTIONS
272 #ifdef IMGUI_DISABLE_FILE_FUNCTIONS
273 #define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
282 #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
290 #define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions
296 #ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
297 static inline float ImFabs(
float x) {
return fabsf(x); }
298 static inline float ImSqrt(
float x) {
return sqrtf(x); }
299 static inline float ImPow(
float x,
float y) {
return powf(x, y); }
300 static inline double ImPow(
double x,
double y) {
return pow(x, y); }
301 static inline float ImFmod(
float x,
float y) {
return fmodf(x, y); }
302 static inline double ImFmod(
double x,
double y) {
return fmod(x, y); }
303 static inline float ImCos(
float x) {
return cosf(x); }
304 static inline float ImSin(
float x) {
return sinf(x); }
305 static inline float ImAcos(
float x) {
return acosf(x); }
306 static inline float ImAtan2(
float y,
float x) {
return atan2f(y, x); }
307 static inline double ImAtof(
const char*
s) {
return atof(s); }
309 static inline float ImCeil(
float x) {
return ceilf(x); }
313 template<
typename T>
static inline T
ImMin(T lhs, T rhs) {
return lhs < rhs ? lhs : rhs; }
314 template<
typename T>
static inline T
ImMax(T lhs, T rhs) {
return lhs >= rhs ? lhs : rhs; }
315 template<
typename T>
static inline T
ImClamp(T
v, T mn, T mx) {
return (v < mn) ? mn : (v > mx) ? mx : v; }
316 template<
typename T>
static inline T
ImLerp(T
a, T
b,
float t) {
return (T)(a + (b -
a) * t); }
317 template<
typename T>
static inline void ImSwap(T&
a, T&
b) { T tmp =
a; a =
b; b = tmp; }
318 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; }
319 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; }
327 static inline float ImSaturate(
float f) {
return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
330 static inline float ImInvLength(
const ImVec2& lhs,
float fail_value) {
float d = lhs.
x*lhs.
x + lhs.
y*lhs.
y;
if (d > 0.0
f)
return 1.0f /
ImSqrt(d);
return fail_value; }
336 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; }
353 void Resize(
int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (
size_t)Storage.Size *
sizeof(Storage.Data[0])); }
355 bool GetBit(
int n)
const {
int off = (n >> 5);
int mask = 1 << (n & 31);
return (Storage[off] & mask) != 0; }
356 void SetBit(
int n,
bool v) {
int off = (n >> 5);
int mask = 1 << (n & 31);
if (v) Storage[off] |=
mask;
else Storage[off] &= ~mask; }
374 ImPoolIdx
GetIndex(
const T*
p)
const {
IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size);
return (ImPoolIdx)(p - Buf.Data); }
375 T*
GetOrAddByKey(
ImGuiID key) {
int* p_idx = Map.GetIntRef(key, -1);
if (*p_idx != -1)
return &Buf[*p_idx]; *p_idx = FreeIdx;
return Add(); }
376 bool Contains(
const T*
p)
const {
return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
377 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 = 0; }
378 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();
return &Buf[idx]; }
380 void Remove(
ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(
int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
381 void Reserve(
int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); }
396 bool empty()
const {
return Buf.Size == 0; }
397 int size()
const {
return Buf.Size; }
398 T*
alloc_chunk(
size_t sz) {
size_t HDR_SZ = 4; sz = ((HDR_SZ + sz) + 3u) & ~3u;
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); }
399 T*
begin() {
size_t HDR_SZ = 4;
if (!Buf.Data)
return NULL;
return (T*)(
void*)(Buf.Data + HDR_SZ); }
400 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; }
402 T*
end() {
return (T*)(
void*)(Buf.Data + Buf.Size); }
507 #ifdef IMGUI_ENABLE_TEST_ENGINE
509 ImGuiItemStatusFlags_Openable = 1 << 10,
510 ImGuiItemStatusFlags_Opened = 1 << 11,
511 ImGuiItemStatusFlags_Checkable = 1 << 12,
512 ImGuiItemStatusFlags_Checked = 1 << 13
646 ImRect() : Min(FLT_MAX,FLT_MAX), Max(-FLT_MAX,-FLT_MAX) {}
649 ImRect(
float x1,
float y1,
float x2,
float y2) : Min(x1, y1), Max(x2, y2) {}
659 bool Contains(
const ImVec2&
p)
const {
return p.
x >= Min.x && p.
y >= Min.y && p.
x < Max.x && p.
y < Max.y; }
662 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; }
664 void Expand(
const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
665 void Expand(
const ImVec2& amount) { Min.x -= amount.
x; Min.y -= amount.
y; Max.x += amount.
x; Max.y += amount.
y; }
672 bool IsInverted()
const {
return Min.x > Max.x || Min.y > Max.y; }
719 float Pos[3], NextWidths[3];
722 void Update(
int count,
float spacing,
bool clear);
723 float DeclColumns(
float w0,
float w1,
float w2);
724 float CalcExtraSpace(
float avail_w)
const;
747 void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); }
751 void OnKeyPressed(
int key);
755 void CursorClamp() { Stb.cursor =
ImMin(Stb.cursor, CurLenW); Stb.select_start =
ImMin(Stb.select_start, CurLenW); Stb.select_end =
ImMin(Stb.select_end, CurLenW); }
756 bool HasSelection()
const {
return Stb.select_start != Stb.select_end; }
758 void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
1341 short StackSizesBackup[6];
1350 CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos =
ImVec2(0.0
f, 0.0
f);
1351 CurrLineSize = PrevLineSize =
ImVec2(0.0
f, 0.0
f);
1352 CurrLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
1354 TreeMayJumpToParentOnPopMask = 0x00;
1356 LastItemStatusFlags = 0;
1357 LastItemRect = LastItemDisplayRect =
ImRect();
1358 NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
1361 NavHideHighlightOneFrame =
false;
1362 NavHasScroll =
false;
1363 MenuBarAppending =
false;
1364 MenuBarOffset =
ImVec2(0.0
f, 0.0
f);
1365 StateStorage = NULL;
1367 FocusCounterAll = FocusCounterTab = -1;
1371 TextWrapPos = -1.0f;
1372 memset(StackSizesBackup, 0,
sizeof(StackSizesBackup));
1377 CurrentColumns = NULL;
1470 ImGuiID GetID(
const char* str,
const char* str_end = NULL);
1473 ImGuiID GetIDNoKeepAlive(
const char* str,
const char* str_end = NULL);
1474 ImGuiID GetIDNoKeepAlive(
const void* ptr);
1748 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1779 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,
float power,
ImGuiSliderFlags flags,
ImRect* out_grab_bb);
1800 IMGUI_API void 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);
1823 #ifndef IM_DEBUG_BREAK
1824 #if defined(__clang__)
1825 #define IM_DEBUG_BREAK() __builtin_debugtrap()
1826 #elif defined (_MSC_VER)
1827 #define IM_DEBUG_BREAK() __debugbreak()
1829 #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!
1831 #endif // #ifndef IM_DEBUG_BREAK
1835 #ifdef IMGUI_ENABLE_TEST_ENGINE
1836 extern void ImGuiTestEngineHook_PreNewFrame(
ImGuiContext* ctx);
1837 extern void ImGuiTestEngineHook_PostNewFrame(
ImGuiContext* ctx);
1840 extern void ImGuiTestEngineHook_Log(
ImGuiContext* ctx,
const char* fmt, ...);
1841 #define IMGUI_TEST_ENGINE_ITEM_ADD(_BB, _ID) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box
1842 #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional)
1843 #define IMGUI_TEST_ENGINE_LOG(_FMT, ...) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log
1845 #define IMGUI_TEST_ENGINE_ITEM_ADD(_BB, _ID) do { } while (0)
1846 #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) do { } while (0)
1847 #define IMGUI_TEST_ENGINE_LOG(_FMT, ...) do { } while (0)
1850 #if defined(__clang__)
1851 #pragma clang diagnostic pop
1852 #elif defined(__GNUC__)
1853 #pragma GCC diagnostic pop
1857 #pragma warning (pop)