• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // dear imgui, v1.67
2 // (internal structures/api)
3 
4 // You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
5 // Set:
6 //   #define IMGUI_DEFINE_MATH_OPERATORS
7 // To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators)
8 
9 /*
10 
11 Index of this file:
12 // Header mess
13 // Forward declarations
14 // STB libraries includes
15 // Context pointer
16 // Generic helpers
17 // Misc data structures
18 // Main imgui context
19 // Tab bar, tab item
20 // Internal API
21 
22 */
23 
24 #pragma once
25 
26 //-----------------------------------------------------------------------------
27 // Header mess
28 //-----------------------------------------------------------------------------
29 
30 #ifndef IMGUI_VERSION
31 #error Must include imgui.h before imgui_internal.h
32 #endif
33 
34 #include <stdio.h>      // FILE*
35 #include <stdlib.h>     // NULL, malloc, free, qsort, atoi, atof
36 #include <math.h>       // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
37 #include <limits.h>     // INT_MIN, INT_MAX
38 
39 #ifdef _MSC_VER
40 #pragma warning (push)
41 #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)
42 #endif
43 
44 #ifdef __clang__
45 #pragma clang diagnostic push
46 #pragma clang diagnostic ignored "-Wunused-function"                // for stb_textedit.h
47 #pragma clang diagnostic ignored "-Wmissing-prototypes"             // for stb_textedit.h
48 #pragma clang diagnostic ignored "-Wold-style-cast"
49 #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
50 #if __has_warning("-Wdouble-promotion")
51 #pragma clang diagnostic ignored "-Wdouble-promotion"
52 #endif
53 #endif
54 
55 //-----------------------------------------------------------------------------
56 // Forward declarations
57 //-----------------------------------------------------------------------------
58 
59 struct ImRect;                      // An axis-aligned rectangle (2 points)
60 struct ImDrawDataBuilder;           // Helper to build a ImDrawData instance
61 struct ImDrawListSharedData;        // Data shared between all ImDrawList instances
62 struct ImGuiColorMod;               // Stacked color modifier, backup of modified data so we can restore it
63 struct ImGuiColumnData;             // Storage data for a single column
64 struct ImGuiColumnsSet;             // Storage data for a columns set
65 struct ImGuiContext;                // Main imgui context
66 struct ImGuiGroupData;              // Stacked storage data for BeginGroup()/EndGroup()
67 struct ImGuiInputTextState;         // Internal state of the currently focused/edited text input box
68 struct ImGuiItemHoveredDataBackup;  // Backup and restore IsItemHovered() internal data
69 struct ImGuiMenuColumns;            // Simple column measurement, currently used for MenuItem() only
70 struct ImGuiNavMoveResult;          // Result of a directional navigation move query result
71 struct ImGuiNextWindowData;         // Storage for SetNexWindow** functions
72 struct ImGuiPopupRef;               // Storage for current popup stack
73 struct ImGuiSettingsHandler;        // Storage for one type registered in the .ini file
74 struct ImGuiStyleMod;               // Stacked style modifier, backup of modified data so we can restore it
75 struct ImGuiTabBar;                 // Storage for a tab bar
76 struct ImGuiTabItem;                // Storage for a tab item (within a tab bar)
77 struct ImGuiWindow;                 // Storage for one window
78 struct ImGuiWindowTempData;         // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame)
79 struct ImGuiWindowSettings;         // Storage for window settings stored in .ini file (we keep one of those even if the actual window wasn't instanced during this session)
80 
81 // Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
82 typedef int ImGuiLayoutType;        // -> enum ImGuiLayoutType_        // Enum: Horizontal or vertical
83 typedef int ImGuiButtonFlags;       // -> enum ImGuiButtonFlags_       // Flags: for ButtonEx(), ButtonBehavior()
84 typedef int ImGuiItemFlags;         // -> enum ImGuiItemFlags_         // Flags: for PushItemFlag()
85 typedef int ImGuiItemStatusFlags;   // -> enum ImGuiItemStatusFlags_   // Flags: for DC.LastItemStatusFlags
86 typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
87 typedef int ImGuiNavDirSourceFlags; // -> enum ImGuiNavDirSourceFlags_ // Flags: for GetNavInputAmount2d()
88 typedef int ImGuiNavMoveFlags;      // -> enum ImGuiNavMoveFlags_      // Flags: for navigation requests
89 typedef int ImGuiSeparatorFlags;    // -> enum ImGuiSeparatorFlags_    // Flags: for Separator() - internal
90 typedef int ImGuiSliderFlags;       // -> enum ImGuiSliderFlags_       // Flags: for SliderBehavior()
91 typedef int ImGuiDragFlags;         // -> enum ImGuiDragFlags_         // Flags: for DragBehavior()
92 
93 //-------------------------------------------------------------------------
94 // STB libraries includes
95 //-------------------------------------------------------------------------
96 
97 namespace ImGuiStb
98 {
99 
100 #undef STB_TEXTEDIT_STRING
101 #undef STB_TEXTEDIT_CHARTYPE
102 #define STB_TEXTEDIT_STRING             ImGuiInputTextState
103 #define STB_TEXTEDIT_CHARTYPE           ImWchar
104 #define STB_TEXTEDIT_GETWIDTH_NEWLINE   -1.0f
105 #include "imstb_textedit.h"
106 
107 } // namespace ImGuiStb
108 
109 //-----------------------------------------------------------------------------
110 // Context pointer
111 //-----------------------------------------------------------------------------
112 
113 #ifndef GImGui
114 extern IMGUI_API ImGuiContext* GImGui;  // Current implicit ImGui context pointer
115 #endif
116 
117 //-----------------------------------------------------------------------------
118 // Generic helpers
119 //-----------------------------------------------------------------------------
120 
121 #define IM_PI           3.14159265358979323846f
122 #ifdef _WIN32
123 #define IM_NEWLINE      "\r\n"   // Play it nice with Windows users (2018/05 news: Microsoft announced that Notepad will finally display Unix-style carriage returns!)
124 #else
125 #define IM_NEWLINE      "\n"
126 #endif
127 #define IMGUI_DEBUG_LOG(_FMT,...)       printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
128 #define IM_STATIC_ASSERT(_COND)         typedef char static_assertion_##__line__[(_COND)?1:-1]
129 #define IM_F32_TO_INT8_UNBOUND(_VAL)    ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f)))   // Unsaturated, for display purpose
130 #define IM_F32_TO_INT8_SAT(_VAL)        ((int)(ImSaturate(_VAL) * 255.0f + 0.5f))               // Saturated, always output 0..255
131 
132 // Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
133 #ifdef _MSC_VER
134 #define IMGUI_CDECL __cdecl
135 #else
136 #define IMGUI_CDECL
137 #endif
138 
139 // Helpers: UTF-8 <> wchar
140 IMGUI_API int           ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end);      // return output UTF-8 bytes count
141 IMGUI_API int           ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end);          // read one character. return input UTF-8 bytes count
142 IMGUI_API int           ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL);   // return input UTF-8 bytes count
143 IMGUI_API int           ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end);                            // return number of UTF-8 code-points (NOT bytes count)
144 IMGUI_API int           ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end);                        // return number of bytes to express one char in UTF-8
145 IMGUI_API int           ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end);                   // return number of bytes to express string in UTF-8
146 
147 // Helpers: Misc
148 IMGUI_API ImU32         ImHash(const void* data, int data_size, ImU32 seed = 0);    // Pass data_size==0 for zero-terminated strings
149 IMGUI_API void*         ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0);
150 IMGUI_API FILE*         ImFileOpen(const char* filename, const char* file_open_mode);
ImCharIsBlankA(char c)151 static inline bool      ImCharIsBlankA(char c)          { return c == ' ' || c == '\t'; }
ImCharIsBlankW(unsigned int c)152 static inline bool      ImCharIsBlankW(unsigned int c)  { return c == ' ' || c == '\t' || c == 0x3000; }
ImIsPowerOfTwo(int v)153 static inline bool      ImIsPowerOfTwo(int v)           { return v != 0 && (v & (v - 1)) == 0; }
ImUpperPowerOfTwo(int v)154 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; }
155 #define ImQsort         qsort
156 
157 // Helpers: Geometry
158 IMGUI_API ImVec2        ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
159 IMGUI_API bool          ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
160 IMGUI_API ImVec2        ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
161 IMGUI_API void          ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
162 IMGUI_API ImGuiDir      ImGetDirQuadrantFromDelta(float dx, float dy);
163 
164 // Helpers: String
165 IMGUI_API int           ImStricmp(const char* str1, const char* str2);
166 IMGUI_API int           ImStrnicmp(const char* str1, const char* str2, size_t count);
167 IMGUI_API void          ImStrncpy(char* dst, const char* src, size_t count);
168 IMGUI_API char*         ImStrdup(const char* str);
169 IMGUI_API char*         ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str);
170 IMGUI_API const char*   ImStrchrRange(const char* str_begin, const char* str_end, char c);
171 IMGUI_API int           ImStrlenW(const ImWchar* str);
172 IMGUI_API const char*   ImStreolRange(const char* str, const char* str_end);                // End end-of-line
173 IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin);   // Find beginning-of-line
174 IMGUI_API const char*   ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
175 IMGUI_API void          ImStrTrimBlanks(char* str);
176 IMGUI_API int           ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
177 IMGUI_API int           ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
178 IMGUI_API const char*   ImParseFormatFindStart(const char* format);
179 IMGUI_API const char*   ImParseFormatFindEnd(const char* format);
180 IMGUI_API const char*   ImParseFormatTrimDecorations(const char* format, char* buf, int buf_size);
181 IMGUI_API int           ImParseFormatPrecision(const char* format, int default_value);
182 
183 // Helpers: ImVec2/ImVec4 operators
184 // We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.)
185 // We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself.
186 #ifdef IMGUI_DEFINE_MATH_OPERATORS
187 static inline ImVec2 operator*(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
188 static inline ImVec2 operator/(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x/rhs, lhs.y/rhs); }
189 static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
190 static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
191 static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
192 static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
193 static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
194 static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
195 static inline ImVec2& operator*=(ImVec2& lhs, const float rhs)                  { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
196 static inline ImVec2& operator/=(ImVec2& lhs, const float rhs)                  { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
197 static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs)            { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
198 static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs)            { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
199 static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs)            { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
200 #endif
201 
202 // Helpers: Maths
203 // - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
204 #ifndef IMGUI_DISABLE_MATH_FUNCTIONS
ImFabs(float x)205 static inline float  ImFabs(float x)                                            { return fabsf(x); }
ImSqrt(float x)206 static inline float  ImSqrt(float x)                                            { return sqrtf(x); }
ImPow(float x,float y)207 static inline float  ImPow(float x, float y)                                    { return powf(x, y); }
ImPow(double x,double y)208 static inline double ImPow(double x, double y)                                  { return pow(x, y); }
ImFmod(float x,float y)209 static inline float  ImFmod(float x, float y)                                   { return fmodf(x, y); }
ImFmod(double x,double y)210 static inline double ImFmod(double x, double y)                                 { return fmod(x, y); }
ImCos(float x)211 static inline float  ImCos(float x)                                             { return cosf(x); }
ImSin(float x)212 static inline float  ImSin(float x)                                             { return sinf(x); }
ImAcos(float x)213 static inline float  ImAcos(float x)                                            { return acosf(x); }
ImAtan2(float y,float x)214 static inline float  ImAtan2(float y, float x)                                  { return atan2f(y, x); }
ImAtof(const char * s)215 static inline double ImAtof(const char* s)                                      { return atof(s); }
ImFloorStd(float x)216 static inline float  ImFloorStd(float x)                                        { return floorf(x); }   // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype)
ImCeil(float x)217 static inline float  ImCeil(float x)                                            { return ceilf(x); }
218 #endif
219 // - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double, using templates here but we could also redefine them 6 times
ImMin(T lhs,T rhs)220 template<typename T> static inline T ImMin(T lhs, T rhs)                        { return lhs < rhs ? lhs : rhs; }
ImMax(T lhs,T rhs)221 template<typename T> static inline T ImMax(T lhs, T rhs)                        { return lhs >= rhs ? lhs : rhs; }
ImClamp(T v,T mn,T mx)222 template<typename T> static inline T ImClamp(T v, T mn, T mx)                   { return (v < mn) ? mn : (v > mx) ? mx : v; }
ImLerp(T a,T b,float t)223 template<typename T> static inline T ImLerp(T a, T b, float t)                  { return (T)(a + (b - a) * t); }
ImSwap(T & a,T & b)224 template<typename T> static inline void ImSwap(T& a, T& b)                      { T tmp = a; a = b; b = tmp; }
225 // - Misc maths helpers
ImMin(const ImVec2 & lhs,const ImVec2 & rhs)226 static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs)                { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
ImMax(const ImVec2 & lhs,const ImVec2 & rhs)227 static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs)                { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
ImClamp(const ImVec2 & v,const ImVec2 & mn,ImVec2 mx)228 static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx)      { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
ImLerp(const ImVec2 & a,const ImVec2 & b,float t)229 static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t)          { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
ImLerp(const ImVec2 & a,const ImVec2 & b,const ImVec2 & t)230 static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t)  { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
ImLerp(const ImVec4 & a,const ImVec4 & b,float t)231 static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t)          { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
ImSaturate(float f)232 static inline float  ImSaturate(float f)                                        { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
ImLengthSqr(const ImVec2 & lhs)233 static inline float  ImLengthSqr(const ImVec2& lhs)                             { return lhs.x*lhs.x + lhs.y*lhs.y; }
ImLengthSqr(const ImVec4 & lhs)234 static inline float  ImLengthSqr(const ImVec4& lhs)                             { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
ImInvLength(const ImVec2 & lhs,float fail_value)235 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 1.0f / ImSqrt(d); return fail_value; }
ImFloor(float f)236 static inline float  ImFloor(float f)                                           { return (float)(int)f; }
ImFloor(const ImVec2 & v)237 static inline ImVec2 ImFloor(const ImVec2& v)                                   { return ImVec2((float)(int)v.x, (float)(int)v.y); }
ImDot(const ImVec2 & a,const ImVec2 & b)238 static inline float  ImDot(const ImVec2& a, const ImVec2& b)                    { return a.x * b.x + a.y * b.y; }
ImRotate(const ImVec2 & v,float cos_a,float sin_a)239 static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a)        { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
ImLinearSweep(float current,float target,float speed)240 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; }
ImMul(const ImVec2 & lhs,const ImVec2 & rhs)241 static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs)                { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
242 
243 // Helper: ImBoolVector. Store 1-bit per value.
244 // Note that Resize() currently clears the whole vector.
245 struct ImBoolVector
246 {
247     ImVector<int>   Storage;
ImBoolVectorImBoolVector248     ImBoolVector()  { }
ResizeImBoolVector249     void            Resize(int sz)          { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
ClearImBoolVector250     void            Clear()                 { Storage.clear(); }
GetBitImBoolVector251     bool            GetBit(int n) const     { int off = (n >> 5); int mask = 1 << (n & 31); return (Storage[off] & mask) != 0; }
SetBitImBoolVector252     void            SetBit(int n, bool v)   { int off = (n >> 5); int mask = 1 << (n & 31); if (v) Storage[off] |= mask; else Storage[off] &= ~mask; }
253 };
254 
255 // Helper: ImPool<>. Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer,
256 // Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
257 typedef int ImPoolIdx;
258 template<typename T>
259 struct IMGUI_API ImPool
260 {
261     ImVector<T>     Data;       // Contiguous data
262     ImGuiStorage    Map;        // ID->Index
263     ImPoolIdx       FreeIdx;    // Next free idx to use
264 
ImPoolImPool265     ImPool()    { FreeIdx = 0; }
~ImPoolImPool266     ~ImPool()   { Clear(); }
GetByKeyImPool267     T*          GetByKey(ImGuiID key)               { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; }
GetByIndexImPool268     T*          GetByIndex(ImPoolIdx n)             { return &Data[n]; }
GetIndexImPool269     ImPoolIdx   GetIndex(const T* p) const          { IM_ASSERT(p >= Data.Data && p < Data.Data + Data.Size); return (ImPoolIdx)(p - Data.Data); }
GetOrAddByKeyImPool270     T*          GetOrAddByKey(ImGuiID key)          { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); }
ClearImPool271     void        Clear()                             { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Data[idx].~T(); }  Map.Clear(); Data.clear(); FreeIdx = 0; }
AddImPool272     T*          Add()                               { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; }
RemoveImPool273     void        Remove(ImGuiID key, const T* p)     { Remove(key, GetIndex(p)); }
RemoveImPool274     void        Remove(ImGuiID key, ImPoolIdx idx)  { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
ReserveImPool275     void        Reserve(int capacity)               { Data.reserve(capacity); Map.Data.reserve(capacity); }
GetSizeImPool276     int         GetSize() const                     { return Data.Size; }
277 };
278 
279 //-----------------------------------------------------------------------------
280 // Misc data structures
281 //-----------------------------------------------------------------------------
282 
283 // 1D vector (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
284 struct ImVec1
285 {
286     float               x;
ImVec1ImVec1287     ImVec1()            { x = 0.0f; }
ImVec1ImVec1288     ImVec1(float _x)    { x = _x; }
289 };
290 
291 enum ImGuiButtonFlags_
292 {
293     ImGuiButtonFlags_None                   = 0,
294     ImGuiButtonFlags_Repeat                 = 1 << 0,   // hold to repeat
295     ImGuiButtonFlags_PressedOnClickRelease  = 1 << 1,   // return true on click + release on same item [DEFAULT if no PressedOn* flag is set]
296     ImGuiButtonFlags_PressedOnClick         = 1 << 2,   // return true on click (default requires click+release)
297     ImGuiButtonFlags_PressedOnRelease       = 1 << 3,   // return true on release (default requires click+release)
298     ImGuiButtonFlags_PressedOnDoubleClick   = 1 << 4,   // return true on double-click (default requires click+release)
299     ImGuiButtonFlags_FlattenChildren        = 1 << 5,   // allow interactions even if a child window is overlapping
300     ImGuiButtonFlags_AllowItemOverlap       = 1 << 6,   // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
301     ImGuiButtonFlags_DontClosePopups        = 1 << 7,   // disable automatically closing parent popup on press // [UNUSED]
302     ImGuiButtonFlags_Disabled               = 1 << 8,   // disable interactions
303     ImGuiButtonFlags_AlignTextBaseLine      = 1 << 9,   // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
304     ImGuiButtonFlags_NoKeyModifiers         = 1 << 10,  // disable interaction if a key modifier is held
305     ImGuiButtonFlags_NoHoldingActiveID      = 1 << 11,  // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
306     ImGuiButtonFlags_PressedOnDragDropHold  = 1 << 12,  // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
307     ImGuiButtonFlags_NoNavFocus             = 1 << 13   // don't override navigation focus when activated
308 };
309 
310 enum ImGuiSliderFlags_
311 {
312     ImGuiSliderFlags_None                   = 0,
313     ImGuiSliderFlags_Vertical               = 1 << 0
314 };
315 
316 enum ImGuiDragFlags_
317 {
318     ImGuiDragFlags_None                     = 0,
319     ImGuiDragFlags_Vertical                 = 1 << 0
320 };
321 
322 enum ImGuiColumnsFlags_
323 {
324     // Default: 0
325     ImGuiColumnsFlags_None                  = 0,
326     ImGuiColumnsFlags_NoBorder              = 1 << 0,   // Disable column dividers
327     ImGuiColumnsFlags_NoResize              = 1 << 1,   // Disable resizing columns when clicking on the dividers
328     ImGuiColumnsFlags_NoPreserveWidths      = 1 << 2,   // Disable column width preservation when adjusting columns
329     ImGuiColumnsFlags_NoForceWithinWindow   = 1 << 3,   // Disable forcing columns to fit within window
330     ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4    // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
331 };
332 
333 enum ImGuiSelectableFlagsPrivate_
334 {
335     // NB: need to be in sync with last value of ImGuiSelectableFlags_
336     ImGuiSelectableFlags_NoHoldingActiveID  = 1 << 10,
337     ImGuiSelectableFlags_PressedOnClick     = 1 << 11,
338     ImGuiSelectableFlags_PressedOnRelease   = 1 << 12,
339     ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 13
340 };
341 
342 enum ImGuiSeparatorFlags_
343 {
344     ImGuiSeparatorFlags_None                = 0,
345     ImGuiSeparatorFlags_Horizontal          = 1 << 0,   // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
346     ImGuiSeparatorFlags_Vertical            = 1 << 1
347 };
348 
349 // Storage for LastItem data
350 enum ImGuiItemStatusFlags_
351 {
352     ImGuiItemStatusFlags_None               = 0,
353     ImGuiItemStatusFlags_HoveredRect        = 1 << 0,
354     ImGuiItemStatusFlags_HasDisplayRect     = 1 << 1,
355     ImGuiItemStatusFlags_Edited             = 1 << 2    // Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
356 
357 #ifdef IMGUI_ENABLE_TEST_ENGINE
358     , // [imgui-test only]
359     ImGuiItemStatusFlags_Openable           = 1 << 10,  //
360     ImGuiItemStatusFlags_Opened             = 1 << 11,  //
361     ImGuiItemStatusFlags_Checkable          = 1 << 12,  //
362     ImGuiItemStatusFlags_Checked            = 1 << 13   //
363 #endif
364 };
365 
366 // FIXME: this is in development, not exposed/functional as a generic feature yet.
367 // Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2
368 enum ImGuiLayoutType_
369 {
370     ImGuiLayoutType_Horizontal = 0,
371     ImGuiLayoutType_Vertical = 1
372 };
373 
374 // X/Y enums are fixed to 0/1 so they may be used to index ImVec2
375 enum ImGuiAxis
376 {
377     ImGuiAxis_None = -1,
378     ImGuiAxis_X = 0,
379     ImGuiAxis_Y = 1
380 };
381 
382 enum ImGuiPlotType
383 {
384     ImGuiPlotType_Lines,
385     ImGuiPlotType_Histogram
386 };
387 
388 enum ImGuiInputSource
389 {
390     ImGuiInputSource_None = 0,
391     ImGuiInputSource_Mouse,
392     ImGuiInputSource_Nav,
393     ImGuiInputSource_NavKeyboard,   // Only used occasionally for storage, not tested/handled by most code
394     ImGuiInputSource_NavGamepad,    // "
395     ImGuiInputSource_COUNT
396 };
397 
398 // FIXME-NAV: Clarify/expose various repeat delay/rate
399 enum ImGuiInputReadMode
400 {
401     ImGuiInputReadMode_Down,
402     ImGuiInputReadMode_Pressed,
403     ImGuiInputReadMode_Released,
404     ImGuiInputReadMode_Repeat,
405     ImGuiInputReadMode_RepeatSlow,
406     ImGuiInputReadMode_RepeatFast
407 };
408 
409 enum ImGuiNavHighlightFlags_
410 {
411     ImGuiNavHighlightFlags_None         = 0,
412     ImGuiNavHighlightFlags_TypeDefault  = 1 << 0,
413     ImGuiNavHighlightFlags_TypeThin     = 1 << 1,
414     ImGuiNavHighlightFlags_AlwaysDraw   = 1 << 2,
415     ImGuiNavHighlightFlags_NoRounding   = 1 << 3
416 };
417 
418 enum ImGuiNavDirSourceFlags_
419 {
420     ImGuiNavDirSourceFlags_None         = 0,
421     ImGuiNavDirSourceFlags_Keyboard     = 1 << 0,
422     ImGuiNavDirSourceFlags_PadDPad      = 1 << 1,
423     ImGuiNavDirSourceFlags_PadLStick    = 1 << 2
424 };
425 
426 enum ImGuiNavMoveFlags_
427 {
428     ImGuiNavMoveFlags_None                  = 0,
429     ImGuiNavMoveFlags_LoopX                 = 1 << 0,   // On failed request, restart from opposite side
430     ImGuiNavMoveFlags_LoopY                 = 1 << 1,
431     ImGuiNavMoveFlags_WrapX                 = 1 << 2,   // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left)
432     ImGuiNavMoveFlags_WrapY                 = 1 << 3,   // This is not super useful for provided for completeness
433     ImGuiNavMoveFlags_AllowCurrentNavId     = 1 << 4,   // Allow scoring and considering the current NavId as a move target candidate. This is used when the move source is offset (e.g. pressing PageDown actually needs to send a Up move request, if we are pressing PageDown from the bottom-most item we need to stay in place)
434     ImGuiNavMoveFlags_AlsoScoreVisibleSet   = 1 << 5    // Store alternate result in NavMoveResultLocalVisibleSet that only comprise elements that are already fully visible.
435 };
436 
437 enum ImGuiNavForward
438 {
439     ImGuiNavForward_None,
440     ImGuiNavForward_ForwardQueued,
441     ImGuiNavForward_ForwardActive
442 };
443 
444 enum ImGuiNavLayer
445 {
446     ImGuiNavLayer_Main  = 0,    // Main scrolling layer
447     ImGuiNavLayer_Menu  = 1,    // Menu layer (access with Alt/ImGuiNavInput_Menu)
448     ImGuiNavLayer_COUNT
449 };
450 
451 enum ImGuiPopupPositionPolicy
452 {
453     ImGuiPopupPositionPolicy_Default,
454     ImGuiPopupPositionPolicy_ComboBox
455 };
456 
457 // 2D axis aligned bounding-box
458 // NB: we can't rely on ImVec2 math operators being available here
459 struct IMGUI_API ImRect
460 {
461     ImVec2      Min;    // Upper-left
462     ImVec2      Max;    // Lower-right
463 
ImRectImRect464     ImRect()                                        : Min(FLT_MAX,FLT_MAX), Max(-FLT_MAX,-FLT_MAX)  {}
ImRectImRect465     ImRect(const ImVec2& min, const ImVec2& max)    : Min(min), Max(max)                            {}
ImRectImRect466     ImRect(const ImVec4& v)                         : Min(v.x, v.y), Max(v.z, v.w)                  {}
ImRectImRect467     ImRect(float x1, float y1, float x2, float y2)  : Min(x1, y1), Max(x2, y2)                      {}
468 
GetCenterImRect469     ImVec2      GetCenter() const                   { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
GetSizeImRect470     ImVec2      GetSize() const                     { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
GetWidthImRect471     float       GetWidth() const                    { return Max.x - Min.x; }
GetHeightImRect472     float       GetHeight() const                   { return Max.y - Min.y; }
GetTLImRect473     ImVec2      GetTL() const                       { return Min; }                   // Top-left
GetTRImRect474     ImVec2      GetTR() const                       { return ImVec2(Max.x, Min.y); }  // Top-right
GetBLImRect475     ImVec2      GetBL() const                       { return ImVec2(Min.x, Max.y); }  // Bottom-left
GetBRImRect476     ImVec2      GetBR() const                       { return Max; }                   // Bottom-right
ContainsImRect477     bool        Contains(const ImVec2& p) const     { return p.x     >= Min.x && p.y     >= Min.y && p.x     <  Max.x && p.y     <  Max.y; }
ContainsImRect478     bool        Contains(const ImRect& r) const     { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x <= Max.x && r.Max.y <= Max.y; }
OverlapsImRect479     bool        Overlaps(const ImRect& r) const     { return r.Min.y <  Max.y && r.Max.y >  Min.y && r.Min.x <  Max.x && r.Max.x >  Min.x; }
AddImRect480     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; }
AddImRect481     void        Add(const ImRect& r)                { if (Min.x > r.Min.x) Min.x = r.Min.x; if (Min.y > r.Min.y) Min.y = r.Min.y; if (Max.x < r.Max.x) Max.x = r.Max.x; if (Max.y < r.Max.y) Max.y = r.Max.y; }
ExpandImRect482     void        Expand(const float amount)          { Min.x -= amount;   Min.y -= amount;   Max.x += amount;   Max.y += amount; }
ExpandImRect483     void        Expand(const ImVec2& amount)        { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
TranslateImRect484     void        Translate(const ImVec2& d)          { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; }
TranslateXImRect485     void        TranslateX(float dx)                { Min.x += dx; Max.x += dx; }
TranslateYImRect486     void        TranslateY(float dy)                { Min.y += dy; Max.y += dy; }
ClipWithImRect487     void        ClipWith(const ImRect& r)           { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); }                   // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
ClipWithFullImRect488     void        ClipWithFull(const ImRect& r)       { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped.
FloorImRect489     void        Floor()                             { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
IsInvertedImRect490     bool        IsInverted() const                  { return Min.x > Max.x || Min.y > Max.y; }
491 };
492 
493 // Stacked color modifier, backup of modified data so we can restore it
494 struct ImGuiColorMod
495 {
496     ImGuiCol    Col;
497     ImVec4      BackupValue;
498 };
499 
500 // Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
501 struct ImGuiStyleMod
502 {
503     ImGuiStyleVar   VarIdx;
504     union           { int BackupInt[2]; float BackupFloat[2]; };
ImGuiStyleModImGuiStyleMod505     ImGuiStyleMod(ImGuiStyleVar idx, int v)     { VarIdx = idx; BackupInt[0] = v; }
ImGuiStyleModImGuiStyleMod506     ImGuiStyleMod(ImGuiStyleVar idx, float v)   { VarIdx = idx; BackupFloat[0] = v; }
ImGuiStyleModImGuiStyleMod507     ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v)  { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
508 };
509 
510 // Stacked storage data for BeginGroup()/EndGroup()
511 struct ImGuiGroupData
512 {
513     ImVec2      BackupCursorPos;
514     ImVec2      BackupCursorMaxPos;
515     ImVec1      BackupIndent;
516     ImVec1      BackupGroupOffset;
517     ImVec2      BackupCurrentLineSize;
518     float       BackupCurrentLineTextBaseOffset;
519     float       BackupLogLinePosY;
520     ImGuiID     BackupActiveIdIsAlive;
521     bool        BackupActiveIdPreviousFrameIsAlive;
522     bool        AdvanceCursor;
523 };
524 
525 // Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper.
526 struct IMGUI_API ImGuiMenuColumns
527 {
528     int         Count;
529     float       Spacing;
530     float       Width, NextWidth;
531     float       Pos[4], NextWidths[4];
532 
533     ImGuiMenuColumns();
534     void        Update(int count, float spacing, bool clear);
535     float       DeclColumns(float w0, float w1, float w2);
536     float       CalcExtraSpace(float avail_w);
537 };
538 
539 // Internal state of the currently focused/edited text input box
540 struct IMGUI_API ImGuiInputTextState
541 {
542     ImGuiID                 ID;                     // widget id owning the text state
543     ImVector<ImWchar>       TextW;                  // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
544     ImVector<char>          InitialText;            // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
545     ImVector<char>          TempBuffer;             // temporary buffer for callback and other other operations. size=capacity.
546     int                     CurLenA, CurLenW;       // we need to maintain our buffer length in both UTF-8 and wchar format.
547     int                     BufCapacityA;           // end-user buffer capacity
548     float                   ScrollX;
549     ImGuiStb::STB_TexteditState StbState;
550     float                   CursorAnim;
551     bool                    CursorFollow;
552     bool                    SelectedAllMouseLock;
553 
554     // Temporarily set when active
555     ImGuiInputTextFlags     UserFlags;
556     ImGuiInputTextCallback  UserCallback;
557     void*                   UserCallbackData;
558 
ImGuiInputTextStateImGuiInputTextState559     ImGuiInputTextState()                           { memset(this, 0, sizeof(*this)); }
CursorAnimResetImGuiInputTextState560     void                CursorAnimReset()           { CursorAnim = -0.30f; }                                   // After a user-input the cursor stays on for a while without blinking
CursorClampImGuiInputTextState561     void                CursorClamp()               { StbState.cursor = ImMin(StbState.cursor, CurLenW); StbState.select_start = ImMin(StbState.select_start, CurLenW); StbState.select_end = ImMin(StbState.select_end, CurLenW); }
HasSelectionImGuiInputTextState562     bool                HasSelection() const        { return StbState.select_start != StbState.select_end; }
ClearSelectionImGuiInputTextState563     void                ClearSelection()            { StbState.select_start = StbState.select_end = StbState.cursor; }
SelectAllImGuiInputTextState564     void                SelectAll()                 { StbState.select_start = 0; StbState.cursor = StbState.select_end = CurLenW; StbState.has_preferred_x = false; }
565     void                OnKeyPressed(int key);      // Cannot be inline because we call in code in stb_textedit.h implementation
566 };
567 
568 // Windows data saved in imgui.ini file
569 struct ImGuiWindowSettings
570 {
571     char*       Name;
572     ImGuiID     ID;
573     ImVec2      Pos;
574     ImVec2      Size;
575     bool        Collapsed;
576 
ImGuiWindowSettingsImGuiWindowSettings577     ImGuiWindowSettings() { Name = NULL; ID = 0; Pos = Size = ImVec2(0,0); Collapsed = false; }
578 };
579 
580 struct ImGuiSettingsHandler
581 {
582     const char* TypeName;   // Short description stored in .ini file. Disallowed characters: '[' ']'
583     ImGuiID     TypeHash;   // == ImHash(TypeName, 0, 0)
584     void*       (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name);              // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
585     void        (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
586     void        (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf);      // Write: Output every entries into 'out_buf'
587     void*       UserData;
588 
ImGuiSettingsHandlerImGuiSettingsHandler589     ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); }
590 };
591 
592 // Storage for current popup stack
593 struct ImGuiPopupRef
594 {
595     ImGuiID             PopupId;        // Set on OpenPopup()
596     ImGuiWindow*        Window;         // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
597     ImGuiWindow*        ParentWindow;   // Set on OpenPopup()
598     int                 OpenFrameCount; // Set on OpenPopup()
599     ImGuiID             OpenParentId;   // Set on OpenPopup(), we need this to differenciate multiple menu sets from each others (e.g. inside menu bar vs loose menu items)
600     ImVec2              OpenPopupPos;   // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse)
601     ImVec2              OpenMousePos;   // Set on OpenPopup(), copy of mouse position at the time of opening popup
602 };
603 
604 struct ImGuiColumnData
605 {
606     float               OffsetNorm;         // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
607     float               OffsetNormBeforeResize;
608     ImGuiColumnsFlags   Flags;              // Not exposed
609     ImRect              ClipRect;
610 
ImGuiColumnDataImGuiColumnData611     ImGuiColumnData()   { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = 0; }
612 };
613 
614 struct ImGuiColumnsSet
615 {
616     ImGuiID             ID;
617     ImGuiColumnsFlags   Flags;
618     bool                IsFirstFrame;
619     bool                IsBeingResized;
620     int                 Current;
621     int                 Count;
622     float               MinX, MaxX;
623     float               LineMinY, LineMaxY;
624     float               StartPosY;          // Copy of CursorPos
625     float               StartMaxPosX;       // Copy of CursorMaxPos
626     ImVector<ImGuiColumnData> Columns;
627 
ImGuiColumnsSetImGuiColumnsSet628     ImGuiColumnsSet()   { Clear(); }
ClearImGuiColumnsSet629     void Clear()
630     {
631         ID = 0;
632         Flags = 0;
633         IsFirstFrame = false;
634         IsBeingResized = false;
635         Current = 0;
636         Count = 1;
637         MinX = MaxX = 0.0f;
638         LineMinY = LineMaxY = 0.0f;
639         StartPosY = 0.0f;
640         StartMaxPosX = 0.0f;
641         Columns.clear();
642     }
643 };
644 
645 // Data shared between all ImDrawList instances
646 struct IMGUI_API ImDrawListSharedData
647 {
648     ImVec2          TexUvWhitePixel;            // UV of white pixel in the atlas
649     ImFont*         Font;                       // Current/default font (optional, for simplified AddText overload)
650     float           FontSize;                   // Current/default font size (optional, for simplified AddText overload)
651     float           CurveTessellationTol;
652     ImVec4          ClipRectFullscreen;         // Value for PushClipRectFullscreen()
653 
654     // Const data
655     // FIXME: Bake rounded corners fill/borders in atlas
656     ImVec2          CircleVtx12[12];
657 
658     ImDrawListSharedData();
659 };
660 
661 struct ImDrawDataBuilder
662 {
663     ImVector<ImDrawList*>   Layers[2];           // Global layers for: regular, tooltip
664 
ClearImDrawDataBuilder665     void Clear()            { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
ClearFreeMemoryImDrawDataBuilder666     void ClearFreeMemory()  { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
667     IMGUI_API void FlattenIntoSingleLayer();
668 };
669 
670 struct ImGuiNavMoveResult
671 {
672     ImGuiID       ID;           // Best candidate
673     ImGuiWindow*  Window;       // Best candidate window
674     float         DistBox;      // Best candidate box distance to current NavId
675     float         DistCenter;   // Best candidate center distance to current NavId
676     float         DistAxial;
677     ImRect        RectRel;      // Best candidate bounding box in window relative space
678 
ImGuiNavMoveResultImGuiNavMoveResult679     ImGuiNavMoveResult() { Clear(); }
ClearImGuiNavMoveResult680     void Clear()         { ID = 0; Window = NULL; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); }
681 };
682 
683 // Storage for SetNexWindow** functions
684 struct ImGuiNextWindowData
685 {
686     ImGuiCond               PosCond;
687     ImGuiCond               SizeCond;
688     ImGuiCond               ContentSizeCond;
689     ImGuiCond               CollapsedCond;
690     ImGuiCond               SizeConstraintCond;
691     ImGuiCond               FocusCond;
692     ImGuiCond               BgAlphaCond;
693     ImVec2                  PosVal;
694     ImVec2                  PosPivotVal;
695     ImVec2                  SizeVal;
696     ImVec2                  ContentSizeVal;
697     bool                    CollapsedVal;
698     ImRect                  SizeConstraintRect;
699     ImGuiSizeCallback       SizeCallback;
700     void*                   SizeCallbackUserData;
701     float                   BgAlphaVal;
702     ImVec2                  MenuBarOffsetMinVal;                // This is not exposed publicly, so we don't clear it.
703 
ImGuiNextWindowDataImGuiNextWindowData704     ImGuiNextWindowData()
705     {
706         PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
707         PosVal = PosPivotVal = SizeVal = ImVec2(0.0f, 0.0f);
708         ContentSizeVal = ImVec2(0.0f, 0.0f);
709         CollapsedVal = false;
710         SizeConstraintRect = ImRect();
711         SizeCallback = NULL;
712         SizeCallbackUserData = NULL;
713         BgAlphaVal = FLT_MAX;
714         MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
715     }
716 
ClearImGuiNextWindowData717     void    Clear()
718     {
719         PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
720     }
721 };
722 
723 struct ImGuiTabBarSortItem
724 {
725     int         Index;
726     float       Width;
727 };
728 
729 //-----------------------------------------------------------------------------
730 // Main imgui context
731 //-----------------------------------------------------------------------------
732 
733 struct ImGuiContext
734 {
735     bool                    Initialized;
736     bool                    FrameScopeActive;                   // Set by NewFrame(), cleared by EndFrame()
737     bool                    FrameScopePushedImplicitWindow;     // Set by NewFrame(), cleared by EndFrame()
738     bool                    FontAtlasOwnedByContext;            // Io.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
739     ImGuiIO                 IO;
740     ImGuiStyle              Style;
741     ImFont*                 Font;                               // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
742     float                   FontSize;                           // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
743     float                   FontBaseSize;                       // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
744     ImDrawListSharedData    DrawListSharedData;
745 
746     double                  Time;
747     int                     FrameCount;
748     int                     FrameCountEnded;
749     int                     FrameCountRendered;
750     ImVector<ImGuiWindow*>  Windows;                            // Windows, sorted in display order, back to front
751     ImVector<ImGuiWindow*>  WindowsFocusOrder;                  // Windows, sorted in focus order, back to front
752     ImVector<ImGuiWindow*>  WindowsSortBuffer;
753     ImVector<ImGuiWindow*>  CurrentWindowStack;
754     ImGuiStorage            WindowsById;
755     int                     WindowsActiveCount;
756     ImGuiWindow*            CurrentWindow;                      // Being drawn into
757     ImGuiWindow*            HoveredWindow;                      // Will catch mouse inputs
758     ImGuiWindow*            HoveredRootWindow;                  // Will catch mouse inputs (for focus/move only)
759     ImGuiID                 HoveredId;                          // Hovered widget
760     bool                    HoveredIdAllowOverlap;
761     ImGuiID                 HoveredIdPreviousFrame;
762     float                   HoveredIdTimer;                     // Measure contiguous hovering time
763     float                   HoveredIdNotActiveTimer;            // Measure contiguous hovering time where the item has not been active
764     ImGuiID                 ActiveId;                           // Active widget
765     ImGuiID                 ActiveIdPreviousFrame;
766     ImGuiID                 ActiveIdIsAlive;                    // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
767     float                   ActiveIdTimer;
768     bool                    ActiveIdIsJustActivated;            // Set at the time of activation for one frame
769     bool                    ActiveIdAllowOverlap;               // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
770     bool                    ActiveIdHasBeenEdited;              // Was the value associated to the widget Edited over the course of the Active state.
771     bool                    ActiveIdPreviousFrameIsAlive;
772     bool                    ActiveIdPreviousFrameHasBeenEdited;
773     int                     ActiveIdAllowNavDirFlags;           // Active widget allows using directional navigation (e.g. can activate a button and move away from it)
774     ImVec2                  ActiveIdClickOffset;                // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
775     ImGuiWindow*            ActiveIdWindow;
776     ImGuiWindow*            ActiveIdPreviousFrameWindow;
777     ImGuiInputSource        ActiveIdSource;                     // Activating with mouse or nav (gamepad/keyboard)
778     ImGuiID                 LastActiveId;                       // Store the last non-zero ActiveId, useful for animation.
779     float                   LastActiveIdTimer;                  // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
780     ImVec2                  LastValidMousePos;
781     ImGuiWindow*            MovingWindow;                       // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
782     ImVector<ImGuiColorMod> ColorModifiers;                     // Stack for PushStyleColor()/PopStyleColor()
783     ImVector<ImGuiStyleMod> StyleModifiers;                     // Stack for PushStyleVar()/PopStyleVar()
784     ImVector<ImFont*>       FontStack;                          // Stack for PushFont()/PopFont()
785     ImVector<ImGuiPopupRef> OpenPopupStack;                     // Which popups are open (persistent)
786     ImVector<ImGuiPopupRef> BeginPopupStack;                    // Which level of BeginPopup() we are in (reset every frame)
787     ImGuiNextWindowData     NextWindowData;                     // Storage for SetNextWindow** functions
788     bool                    NextTreeNodeOpenVal;                // Storage for SetNextTreeNode** functions
789     ImGuiCond               NextTreeNodeOpenCond;
790 
791     // Navigation data (for gamepad/keyboard)
792     ImGuiWindow*            NavWindow;                          // Focused window for navigation. Could be called 'FocusWindow'
793     ImGuiID                 NavId;                              // Focused item for navigation
794     ImGuiID                 NavActivateId;                      // ~~ (g.ActiveId == 0) && IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0, also set when calling ActivateItem()
795     ImGuiID                 NavActivateDownId;                  // ~~ IsNavInputDown(ImGuiNavInput_Activate) ? NavId : 0
796     ImGuiID                 NavActivatePressedId;               // ~~ IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0
797     ImGuiID                 NavInputId;                         // ~~ IsNavInputPressed(ImGuiNavInput_Input) ? NavId : 0
798     ImGuiID                 NavJustTabbedId;                    // Just tabbed to this id.
799     ImGuiID                 NavJustMovedToId;                   // Just navigated to this id (result of a successfully MoveRequest)
800     ImGuiID                 NavNextActivateId;                  // Set by ActivateItem(), queued until next frame
801     ImGuiInputSource        NavInputSource;                     // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
802     ImRect                  NavScoringRectScreen;               // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring.
803     int                     NavScoringCount;                    // Metrics for debugging
804     ImGuiWindow*            NavWindowingTarget;                 // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed front-most.
805     ImGuiWindow*            NavWindowingTargetAnim;             // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f
806     ImGuiWindow*            NavWindowingList;
807     float                   NavWindowingTimer;
808     float                   NavWindowingHighlightAlpha;
809     bool                    NavWindowingToggleLayer;
810     ImGuiNavLayer           NavLayer;                           // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
811     int                     NavIdTabCounter;                    // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
812     bool                    NavIdIsAlive;                       // Nav widget has been seen this frame ~~ NavRefRectRel is valid
813     bool                    NavMousePosDirty;                   // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
814     bool                    NavDisableHighlight;                // When user starts using mouse, we hide gamepad/keyboard highlight (NB: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover)
815     bool                    NavDisableMouseHover;               // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
816     bool                    NavAnyRequest;                      // ~~ NavMoveRequest || NavInitRequest
817     bool                    NavInitRequest;                     // Init request for appearing window to select first item
818     bool                    NavInitRequestFromMove;
819     ImGuiID                 NavInitResultId;
820     ImRect                  NavInitResultRectRel;
821     bool                    NavMoveFromClampedRefRect;          // Set by manual scrolling, if we scroll to a point where NavId isn't visible we reset navigation from visible items
822     bool                    NavMoveRequest;                     // Move request for this frame
823     ImGuiNavMoveFlags       NavMoveRequestFlags;
824     ImGuiNavForward         NavMoveRequestForward;              // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu)
825     ImGuiDir                NavMoveDir, NavMoveDirLast;         // Direction of the move request (left/right/up/down), direction of the previous move request
826     ImGuiDir                NavMoveClipDir;
827     ImGuiNavMoveResult      NavMoveResultLocal;                 // Best move request candidate within NavWindow
828     ImGuiNavMoveResult      NavMoveResultLocalVisibleSet;       // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
829     ImGuiNavMoveResult      NavMoveResultOther;                 // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
830 
831     // Render
832     ImDrawData              DrawData;                           // Main ImDrawData instance to pass render information to the user
833     ImDrawDataBuilder       DrawDataBuilder;
834     float                   DimBgRatio;                         // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
835     ImDrawList              OverlayDrawList;                    // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays
836     ImGuiMouseCursor        MouseCursor;
837 
838     // Drag and Drop
839     bool                    DragDropActive;
840     bool                    DragDropWithinSourceOrTarget;
841     ImGuiDragDropFlags      DragDropSourceFlags;
842     int                     DragDropSourceFrameCount;
843     int                     DragDropMouseButton;
844     ImGuiPayload            DragDropPayload;
845     ImRect                  DragDropTargetRect;
846     ImGuiID                 DragDropTargetId;
847     ImGuiDragDropFlags      DragDropAcceptFlags;
848     float                   DragDropAcceptIdCurrRectSurface;    // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
849     ImGuiID                 DragDropAcceptIdCurr;               // Target item id (set at the time of accepting the payload)
850     ImGuiID                 DragDropAcceptIdPrev;               // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
851     int                     DragDropAcceptFrameCount;           // Last time a target expressed a desire to accept the source
852     ImVector<unsigned char> DragDropPayloadBufHeap;             // We don't expose the ImVector<> directly
853     unsigned char           DragDropPayloadBufLocal[8];         // Local buffer for small payloads
854 
855     // Tab bars
856     ImPool<ImGuiTabBar>     TabBars;
857     ImVector<ImGuiTabBar*>  CurrentTabBar;
858     ImVector<ImGuiTabBarSortItem>   TabSortByWidthBuffer;
859 
860     // Widget state
861     ImGuiInputTextState     InputTextState;
862     ImFont                  InputTextPasswordFont;
863     ImGuiID                 ScalarAsInputTextId;                // Temporary text input when CTRL+clicking on a slider, etc.
864     ImGuiColorEditFlags     ColorEditOptions;                   // Store user options for color edit widgets
865     ImVec4                  ColorPickerRef;
866     bool                    DragCurrentAccumDirty;
867     float                   DragCurrentAccum;                   // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
868     float                   DragSpeedDefaultRatio;              // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
869     ImVec2                  ScrollbarClickDeltaToGrabCenter;    // Distance between mouse and center of grab box, normalized in parent space. Use storage?
870     int                     TooltipOverrideCount;
871     ImVector<char>          PrivateClipboard;                   // If no custom clipboard handler is defined
872 
873     // Platform support
874     ImVec2                  PlatformImePos, PlatformImeLastPos; // Cursor position request & last passed to the OS Input Method Editor
875 
876     // Settings
877     bool                           SettingsLoaded;
878     float                          SettingsDirtyTimer;          // Save .ini Settings to memory when time reaches zero
879     ImGuiTextBuffer                SettingsIniData;             // In memory .ini settings
880     ImVector<ImGuiSettingsHandler> SettingsHandlers;            // List of .ini settings handlers
881     ImVector<ImGuiWindowSettings>  SettingsWindows;             // ImGuiWindow .ini settings entries (parsed from the last loaded .ini file and maintained on saving)
882 
883     // Logging
884     bool                    LogEnabled;
885     FILE*                   LogFile;                            // If != NULL log to stdout/ file
886     ImGuiTextBuffer         LogClipboard;                       // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
887     int                     LogStartDepth;
888     int                     LogAutoExpandMaxDepth;
889 
890     // Misc
891     float                   FramerateSecPerFrame[120];          // Calculate estimate of framerate for user over the last 2 seconds.
892     int                     FramerateSecPerFrameIdx;
893     float                   FramerateSecPerFrameAccum;
894     int                     WantCaptureMouseNextFrame;          // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags
895     int                     WantCaptureKeyboardNextFrame;
896     int                     WantTextInputNextFrame;
897     char                    TempBuffer[1024*3+1];               // Temporary text buffer
898 
ImGuiContextImGuiContext899     ImGuiContext(ImFontAtlas* shared_font_atlas) : OverlayDrawList(NULL)
900     {
901         Initialized = false;
902         FrameScopeActive = FrameScopePushedImplicitWindow = false;
903         Font = NULL;
904         FontSize = FontBaseSize = 0.0f;
905         FontAtlasOwnedByContext = shared_font_atlas ? false : true;
906         IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
907 
908         Time = 0.0f;
909         FrameCount = 0;
910         FrameCountEnded = FrameCountRendered = -1;
911         WindowsActiveCount = 0;
912         CurrentWindow = NULL;
913         HoveredWindow = NULL;
914         HoveredRootWindow = NULL;
915         HoveredId = 0;
916         HoveredIdAllowOverlap = false;
917         HoveredIdPreviousFrame = 0;
918         HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
919         ActiveId = 0;
920         ActiveIdPreviousFrame = 0;
921         ActiveIdIsAlive = 0;
922         ActiveIdTimer = 0.0f;
923         ActiveIdIsJustActivated = false;
924         ActiveIdAllowOverlap = false;
925         ActiveIdHasBeenEdited = false;
926         ActiveIdPreviousFrameIsAlive = false;
927         ActiveIdPreviousFrameHasBeenEdited = false;
928         ActiveIdAllowNavDirFlags = 0;
929         ActiveIdClickOffset = ImVec2(-1,-1);
930         ActiveIdWindow = ActiveIdPreviousFrameWindow = NULL;
931         ActiveIdSource = ImGuiInputSource_None;
932         LastActiveId = 0;
933         LastActiveIdTimer = 0.0f;
934         LastValidMousePos = ImVec2(0.0f, 0.0f);
935         MovingWindow = NULL;
936         NextTreeNodeOpenVal = false;
937         NextTreeNodeOpenCond = 0;
938 
939         NavWindow = NULL;
940         NavId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
941         NavJustTabbedId = NavJustMovedToId = NavNextActivateId = 0;
942         NavInputSource = ImGuiInputSource_None;
943         NavScoringRectScreen = ImRect();
944         NavScoringCount = 0;
945         NavWindowingTarget = NavWindowingTargetAnim = NavWindowingList = NULL;
946         NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
947         NavWindowingToggleLayer = false;
948         NavLayer = ImGuiNavLayer_Main;
949         NavIdTabCounter = INT_MAX;
950         NavIdIsAlive = false;
951         NavMousePosDirty = false;
952         NavDisableHighlight = true;
953         NavDisableMouseHover = false;
954         NavAnyRequest = false;
955         NavInitRequest = false;
956         NavInitRequestFromMove = false;
957         NavInitResultId = 0;
958         NavMoveFromClampedRefRect = false;
959         NavMoveRequest = false;
960         NavMoveRequestFlags = 0;
961         NavMoveRequestForward = ImGuiNavForward_None;
962         NavMoveDir = NavMoveDirLast = NavMoveClipDir = ImGuiDir_None;
963 
964         DimBgRatio = 0.0f;
965         OverlayDrawList._Data = &DrawListSharedData;
966         OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
967         MouseCursor = ImGuiMouseCursor_Arrow;
968 
969         DragDropActive = DragDropWithinSourceOrTarget = false;
970         DragDropSourceFlags = 0;
971         DragDropSourceFrameCount = -1;
972         DragDropMouseButton = -1;
973         DragDropTargetId = 0;
974         DragDropAcceptFlags = 0;
975         DragDropAcceptIdCurrRectSurface = 0.0f;
976         DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
977         DragDropAcceptFrameCount = -1;
978         memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal));
979 
980         ScalarAsInputTextId = 0;
981         ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
982         DragCurrentAccumDirty = false;
983         DragCurrentAccum = 0.0f;
984         DragSpeedDefaultRatio = 1.0f / 100.0f;
985         ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
986         TooltipOverrideCount = 0;
987         PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX);
988 
989         SettingsLoaded = false;
990         SettingsDirtyTimer = 0.0f;
991 
992         LogEnabled = false;
993         LogFile = NULL;
994         LogStartDepth = 0;
995         LogAutoExpandMaxDepth = 2;
996 
997         memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
998         FramerateSecPerFrameIdx = 0;
999         FramerateSecPerFrameAccum = 0.0f;
1000         WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
1001         memset(TempBuffer, 0, sizeof(TempBuffer));
1002     }
1003 };
1004 
1005 // Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
1006 // This is going to be exposed in imgui.h when stabilized enough.
1007 enum ImGuiItemFlags_
1008 {
1009     ImGuiItemFlags_NoTabStop                    = 1 << 0,  // false
1010     ImGuiItemFlags_ButtonRepeat                 = 1 << 1,  // false    // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
1011     ImGuiItemFlags_Disabled                     = 1 << 2,  // false    // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
1012     ImGuiItemFlags_NoNav                        = 1 << 3,  // false
1013     ImGuiItemFlags_NoNavDefaultFocus            = 1 << 4,  // false
1014     ImGuiItemFlags_SelectableDontClosePopup     = 1 << 5,  // false    // MenuItem/Selectable() automatically closes current Popup window
1015     ImGuiItemFlags_Default_                     = 0
1016 };
1017 
1018 // Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
1019 // FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered.
1020 struct IMGUI_API ImGuiWindowTempData
1021 {
1022     ImVec2                  CursorPos;
1023     ImVec2                  CursorPosPrevLine;
1024     ImVec2                  CursorStartPos;         // Initial position in client area with padding
1025     ImVec2                  CursorMaxPos;           // Used to implicitly calculate the size of our contents, always growing during the frame. Turned into window->SizeContents at the beginning of next frame
1026     ImVec2                  CurrentLineSize;
1027     float                   CurrentLineTextBaseOffset;
1028     ImVec2                  PrevLineSize;
1029     float                   PrevLineTextBaseOffset;
1030     float                   LogLinePosY;
1031     int                     TreeDepth;
1032     ImU32                   TreeDepthMayJumpToParentOnPop; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31
1033     ImGuiID                 LastItemId;
1034     ImGuiItemStatusFlags    LastItemStatusFlags;
1035     ImRect                  LastItemRect;           // Interaction rect
1036     ImRect                  LastItemDisplayRect;    // End-user display rect (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect)
1037     ImGuiNavLayer           NavLayerCurrent;        // Current layer, 0..31 (we currently only use 0..1)
1038     int                     NavLayerCurrentMask;    // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping.
1039     int                     NavLayerActiveMask;     // Which layer have been written to (result from previous frame)
1040     int                     NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame)
1041     bool                    NavHideHighlightOneFrame;
1042     bool                    NavHasScroll;           // Set when scrolling can be used (ScrollMax > 0.0f)
1043     bool                    MenuBarAppending;       // FIXME: Remove this
1044     ImVec2                  MenuBarOffset;          // MenuBarOffset.x is sort of equivalent of a per-layer CursorPos.x, saved/restored as we switch to the menu bar. The only situation when MenuBarOffset.y is > 0 if when (SafeAreaPadding.y > FramePadding.y), often used on TVs.
1045     ImVector<ImGuiWindow*>  ChildWindows;
1046     ImGuiStorage*           StateStorage;
1047     ImGuiLayoutType         LayoutType;
1048     ImGuiLayoutType         ParentLayoutType;       // Layout type of parent window at the time of Begin()
1049 
1050     // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
1051     ImGuiItemFlags          ItemFlags;              // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
1052     float                   ItemWidth;              // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
1053     float                   TextWrapPos;            // == TextWrapPosStack.back() [empty == -1.0f]
1054     ImVector<ImGuiItemFlags>ItemFlagsStack;
1055     ImVector<float>         ItemWidthStack;
1056     ImVector<float>         TextWrapPosStack;
1057     ImVector<ImGuiGroupData>GroupStack;
1058     short                   StackSizesBackup[6];    // Store size of various stacks for asserting
1059 
1060     ImVec1                  Indent;                 // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
1061     ImVec1                  GroupOffset;
1062     ImVec1                  ColumnsOffset;          // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
1063     ImGuiColumnsSet*        ColumnsSet;             // Current columns set
1064 
ImGuiWindowTempDataImGuiWindowTempData1065     ImGuiWindowTempData()
1066     {
1067         CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
1068         CurrentLineSize = PrevLineSize = ImVec2(0.0f, 0.0f);
1069         CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
1070         LogLinePosY = -1.0f;
1071         TreeDepth = 0;
1072         TreeDepthMayJumpToParentOnPop = 0x00;
1073         LastItemId = 0;
1074         LastItemStatusFlags = 0;
1075         LastItemRect = LastItemDisplayRect = ImRect();
1076         NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
1077         NavLayerCurrent = ImGuiNavLayer_Main;
1078         NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
1079         NavHideHighlightOneFrame = false;
1080         NavHasScroll = false;
1081         MenuBarAppending = false;
1082         MenuBarOffset = ImVec2(0.0f, 0.0f);
1083         StateStorage = NULL;
1084         LayoutType = ParentLayoutType = ImGuiLayoutType_Vertical;
1085         ItemWidth = 0.0f;
1086         ItemFlags = ImGuiItemFlags_Default_;
1087         TextWrapPos = -1.0f;
1088         memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
1089 
1090         Indent = ImVec1(0.0f);
1091         GroupOffset = ImVec1(0.0f);
1092         ColumnsOffset = ImVec1(0.0f);
1093         ColumnsSet = NULL;
1094     }
1095 };
1096 
1097 // Storage for one window
1098 struct IMGUI_API ImGuiWindow
1099 {
1100     char*                   Name;
1101     ImGuiID                 ID;                                 // == ImHash(Name)
1102     ImGuiWindowFlags        Flags;                              // See enum ImGuiWindowFlags_
1103     ImVec2                  Pos;                                // Position (always rounded-up to nearest pixel)
1104     ImVec2                  Size;                               // Current size (==SizeFull or collapsed title bar size)
1105     ImVec2                  SizeFull;                           // Size when non collapsed
1106     ImVec2                  SizeFullAtLastBegin;                // Copy of SizeFull at the end of Begin. This is the reference value we'll use on the next frame to decide if we need scrollbars.
1107     ImVec2                  SizeContents;                       // Size of contents (== extents reach of the drawing cursor) from previous frame. Include decoration, window title, border, menu, etc.
1108     ImVec2                  SizeContentsExplicit;               // Size of contents explicitly set by the user via SetNextWindowContentSize()
1109     ImVec2                  WindowPadding;                      // Window padding at the time of begin.
1110     float                   WindowRounding;                     // Window rounding at the time of begin.
1111     float                   WindowBorderSize;                   // Window border size at the time of begin.
1112     int                     NameBufLen;                         // Size of buffer storing Name. May be larger than strlen(Name)!
1113     ImGuiID                 MoveId;                             // == window->GetID("#MOVE")
1114     ImGuiID                 ChildId;                            // ID of corresponding item in parent window (for navigation to return from child window to parent window)
1115     ImVec2                  Scroll;
1116     ImVec2                  ScrollTarget;                       // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
1117     ImVec2                  ScrollTargetCenterRatio;            // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
1118     ImVec2                  ScrollbarSizes;                     // Size taken by scrollbars on each axis
1119     bool                    ScrollbarX, ScrollbarY;
1120     bool                    Active;                             // Set to true on Begin(), unless Collapsed
1121     bool                    WasActive;
1122     bool                    WriteAccessed;                      // Set to true when any widget access the current window
1123     bool                    Collapsed;                          // Set when collapsing window to become only title-bar
1124     bool                    WantCollapseToggle;
1125     bool                    SkipItems;                          // Set when items can safely be all clipped (e.g. window not visible or collapsed)
1126     bool                    Appearing;                          // Set during the frame where the window is appearing (or re-appearing)
1127     bool                    Hidden;                             // Do not display (== (HiddenFramesForResize > 0) ||
1128     bool                    HasCloseButton;                     // Set when the window has a close button (p_open != NULL)
1129     short                   BeginCount;                         // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
1130     short                   BeginOrderWithinParent;             // Order within immediate parent window, if we are a child window. Otherwise 0.
1131     short                   BeginOrderWithinContext;            // Order within entire imgui context. This is mostly used for debugging submission order related issues.
1132     ImGuiID                 PopupId;                            // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
1133     int                     AutoFitFramesX, AutoFitFramesY;
1134     bool                    AutoFitOnlyGrows;
1135     int                     AutoFitChildAxises;
1136     ImGuiDir                AutoPosLastDirection;
1137     int                     HiddenFramesRegular;                // Hide the window for N frames
1138     int                     HiddenFramesForResize;              // Hide the window for N frames while allowing items to be submitted so we can measure their size
1139     ImGuiCond               SetWindowPosAllowFlags;             // store acceptable condition flags for SetNextWindowPos() use.
1140     ImGuiCond               SetWindowSizeAllowFlags;            // store acceptable condition flags for SetNextWindowSize() use.
1141     ImGuiCond               SetWindowCollapsedAllowFlags;       // store acceptable condition flags for SetNextWindowCollapsed() use.
1142     ImVec2                  SetWindowPosVal;                    // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
1143     ImVec2                  SetWindowPosPivot;                  // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
1144 
1145     ImGuiWindowTempData     DC;                                 // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name.
1146     ImVector<ImGuiID>       IDStack;                            // ID stack. ID are hashes seeded with the value at the top of the stack
1147     ImRect                  ClipRect;                           // Current clipping rectangle. = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
1148     ImRect                  OuterRectClipped;                   // = WindowRect just after setup in Begin(). == window->Rect() for root window.
1149     ImRect                  InnerMainRect, InnerClipRect;
1150     ImRect                  ContentsRegionRect;                 // FIXME: This is currently confusing/misleading. Maximum visible content position ~~ Pos + (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
1151     int                     LastFrameActive;                    // Last frame number the window was Active.
1152     float                   ItemWidthDefault;
1153     ImGuiMenuColumns        MenuColumns;                        // Simplified columns storage for menu items
1154     ImGuiStorage            StateStorage;
1155     ImVector<ImGuiColumnsSet> ColumnsStorage;
1156     float                   FontWindowScale;                    // User scale multiplier per-window
1157     int                     SettingsIdx;                        // Index into SettingsWindow[] (indices are always valid as we only grow the array from the back)
1158 
1159     ImDrawList*             DrawList;                           // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
1160     ImDrawList              DrawListInst;
1161     ImGuiWindow*            ParentWindow;                       // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
1162     ImGuiWindow*            RootWindow;                         // Point to ourself or first ancestor that is not a child window.
1163     ImGuiWindow*            RootWindowForTitleBarHighlight;     // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
1164     ImGuiWindow*            RootWindowForNav;                   // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
1165 
1166     ImGuiWindow*            NavLastChildNavWindow;              // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.)
1167     ImGuiID                 NavLastIds[ImGuiNavLayer_COUNT];    // Last known NavId for this window, per layer (0/1)
1168     ImRect                  NavRectRel[ImGuiNavLayer_COUNT];    // Reference rectangle, in window relative space
1169 
1170     // Navigation / Focus
1171     // FIXME-NAV: Merge all this with the new Nav system, at least the request variables should be moved to ImGuiContext
1172     int                     FocusIdxAllCounter;                 // Start at -1 and increase as assigned via FocusItemRegister()
1173     int                     FocusIdxTabCounter;                 // (same, but only count widgets which you can Tab through)
1174     int                     FocusIdxAllRequestCurrent;          // Item being requested for focus
1175     int                     FocusIdxTabRequestCurrent;          // Tab-able item being requested for focus
1176     int                     FocusIdxAllRequestNext;             // Item being requested for focus, for next update (relies on layout to be stable between the frame pressing TAB and the next frame)
1177     int                     FocusIdxTabRequestNext;             // "
1178 
1179 public:
1180     ImGuiWindow(ImGuiContext* context, const char* name);
1181     ~ImGuiWindow();
1182 
1183     ImGuiID     GetID(const char* str, const char* str_end = NULL);
1184     ImGuiID     GetID(const void* ptr);
1185     ImGuiID     GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
1186     ImGuiID     GetIDNoKeepAlive(const void* ptr);
1187     ImGuiID     GetIDFromRectangle(const ImRect& r_abs);
1188 
1189     // We don't use g.FontSize because the window may be != g.CurrentWidow.
RectImGuiWindow1190     ImRect      Rect() const                            { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
CalcFontSizeImGuiWindow1191     float       CalcFontSize() const                    { return GImGui->FontBaseSize * FontWindowScale; }
TitleBarHeightImGuiWindow1192     float       TitleBarHeight() const                  { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; }
TitleBarRectImGuiWindow1193     ImRect      TitleBarRect() const                    { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
MenuBarHeightImGuiWindow1194     float       MenuBarHeight() const                   { return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
MenuBarRectImGuiWindow1195     ImRect      MenuBarRect() const                     { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
1196 };
1197 
1198 // Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
1199 struct ImGuiItemHoveredDataBackup
1200 {
1201     ImGuiID                 LastItemId;
1202     ImGuiItemStatusFlags    LastItemStatusFlags;
1203     ImRect                  LastItemRect;
1204     ImRect                  LastItemDisplayRect;
1205 
ImGuiItemHoveredDataBackupImGuiItemHoveredDataBackup1206     ImGuiItemHoveredDataBackup() { Backup(); }
BackupImGuiItemHoveredDataBackup1207     void Backup()           { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; }
RestoreImGuiItemHoveredDataBackup1208     void Restore() const    { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; }
1209 };
1210 
1211 //-----------------------------------------------------------------------------
1212 // Tab bar, tab item
1213 //-----------------------------------------------------------------------------
1214 
1215 enum ImGuiTabBarFlagsPrivate_
1216 {
1217     ImGuiTabBarFlags_DockNode                   = 1 << 20,  // [Docking: Unused in Master Branch] Part of a dock node
1218     ImGuiTabBarFlags_DockNodeIsDockSpace        = 1 << 21,  // [Docking: Unused in Master Branch] Part of an explicit dockspace node node
1219     ImGuiTabBarFlags_IsFocused                  = 1 << 22,
1220     ImGuiTabBarFlags_SaveSettings               = 1 << 23   // FIXME: Settings are handled by the docking system, this only request the tab bar to mark settings dirty when reordering tabs
1221 };
1222 
1223 // Storage for one active tab item (sizeof() 26~32 bytes)
1224 struct ImGuiTabItem
1225 {
1226     ImGuiID             ID;
1227     ImGuiTabItemFlags   Flags;
1228     int                 LastFrameVisible;
1229     int                 LastFrameSelected;      // This allows us to infer an ordered list of the last activated tabs with little maintenance
1230     float               Offset;                 // Position relative to beginning of tab
1231     float               Width;                  // Width currently displayed
1232     float               WidthContents;          // Width of actual contents, stored during BeginTabItem() call
1233 
ImGuiTabItemImGuiTabItem1234     ImGuiTabItem()      { ID = Flags = 0; LastFrameVisible = LastFrameSelected = -1; Offset = Width = WidthContents = 0.0f; }
1235 };
1236 
1237 // Storage for a tab bar (sizeof() 92~96 bytes)
1238 struct ImGuiTabBar
1239 {
1240     ImVector<ImGuiTabItem> Tabs;
1241     ImGuiID             ID;                     // Zero for tab-bars used by docking
1242     ImGuiID             SelectedTabId;          // Selected tab
1243     ImGuiID             NextSelectedTabId;
1244     ImGuiID             VisibleTabId;           // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview)
1245     int                 CurrFrameVisible;
1246     int                 PrevFrameVisible;
1247     ImRect              BarRect;
1248     float               ContentsHeight;
1249     float               OffsetMax;              // Distance from BarRect.Min.x, locked during layout
1250     float               OffsetNextTab;          // Distance from BarRect.Min.x, incremented with each BeginTabItem() call, not used if ImGuiTabBarFlags_Reorderable if set.
1251     float               ScrollingAnim;
1252     float               ScrollingTarget;
1253     ImGuiTabBarFlags    Flags;
1254     ImGuiID             ReorderRequestTabId;
1255     int                 ReorderRequestDir;
1256     bool                WantLayout;
1257     bool                VisibleTabWasSubmitted;
1258     short               LastTabItemIdx;         // For BeginTabItem()/EndTabItem()
1259 
1260     ImGuiTabBar();
GetTabOrderImGuiTabBar1261     int                 GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); }
1262 };
1263 
1264 //-----------------------------------------------------------------------------
1265 // Internal API
1266 // No guarantee of forward compatibility here.
1267 //-----------------------------------------------------------------------------
1268 
1269 namespace ImGui
1270 {
1271     // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
1272     // If this ever crash because g.CurrentWindow is NULL it means that either
1273     // - ImGui::NewFrame() has never been called, which is illegal.
1274     // - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
GetCurrentWindowRead()1275     inline    ImGuiWindow*  GetCurrentWindowRead()      { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
GetCurrentWindow()1276     inline    ImGuiWindow*  GetCurrentWindow()          { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
1277     IMGUI_API ImGuiWindow*  FindWindowByID(ImGuiID id);
1278     IMGUI_API ImGuiWindow*  FindWindowByName(const char* name);
1279     IMGUI_API void          FocusWindow(ImGuiWindow* window);
1280     IMGUI_API void          FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window);
1281     IMGUI_API void          BringWindowToFocusFront(ImGuiWindow* window);
1282     IMGUI_API void          BringWindowToDisplayFront(ImGuiWindow* window);
1283     IMGUI_API void          BringWindowToDisplayBack(ImGuiWindow* window);
1284     IMGUI_API void          UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
1285     IMGUI_API ImVec2        CalcWindowExpectedSize(ImGuiWindow* window);
1286     IMGUI_API bool          IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
1287     IMGUI_API bool          IsWindowNavFocusable(ImGuiWindow* window);
1288     IMGUI_API void          SetWindowScrollX(ImGuiWindow* window, float new_scroll_x);
1289     IMGUI_API void          SetWindowScrollY(ImGuiWindow* window, float new_scroll_y);
1290     IMGUI_API float         GetWindowScrollMaxX(ImGuiWindow* window);
1291     IMGUI_API float         GetWindowScrollMaxY(ImGuiWindow* window);
1292     IMGUI_API ImRect        GetWindowAllowedExtentRect(ImGuiWindow* window);
1293 
1294     IMGUI_API void          SetCurrentFont(ImFont* font);
GetDefaultFont()1295     inline ImFont*          GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
1296 
1297     // Init
1298     IMGUI_API void          Initialize(ImGuiContext* context);
1299     IMGUI_API void          Shutdown(ImGuiContext* context);    // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
1300 
1301     // NewFrame
1302     IMGUI_API void          UpdateHoveredWindowAndCaptureFlags();
1303     IMGUI_API void          StartMouseMovingWindow(ImGuiWindow* window);
1304     IMGUI_API void          UpdateMouseMovingWindowNewFrame();
1305     IMGUI_API void          UpdateMouseMovingWindowEndFrame();
1306 
1307     // Settings
1308     IMGUI_API void                  MarkIniSettingsDirty();
1309     IMGUI_API void                  MarkIniSettingsDirty(ImGuiWindow* window);
1310     IMGUI_API ImGuiWindowSettings*  CreateNewWindowSettings(const char* name);
1311     IMGUI_API ImGuiWindowSettings*  FindWindowSettings(ImGuiID id);
1312     IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
1313 
1314     // Basic Accessors
GetItemID()1315     inline ImGuiID          GetItemID()     { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; }
GetActiveID()1316     inline ImGuiID          GetActiveID()   { ImGuiContext& g = *GImGui; return g.ActiveId; }
GetFocusID()1317     inline ImGuiID          GetFocusID()    { ImGuiContext& g = *GImGui; return g.NavId; }
1318     IMGUI_API void          SetActiveID(ImGuiID id, ImGuiWindow* window);
1319     IMGUI_API void          SetFocusID(ImGuiID id, ImGuiWindow* window);
1320     IMGUI_API void          ClearActiveID();
1321     IMGUI_API ImGuiID       GetHoveredID();
1322     IMGUI_API void          SetHoveredID(ImGuiID id);
1323     IMGUI_API void          KeepAliveID(ImGuiID id);
1324     IMGUI_API void          MarkItemEdited(ImGuiID id);
1325 
1326     // Basic Helpers for widget code
1327     IMGUI_API void          ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
1328     IMGUI_API void          ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
1329     IMGUI_API bool          ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
1330     IMGUI_API bool          ItemHoverable(const ImRect& bb, ImGuiID id);
1331     IMGUI_API bool          IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
1332     IMGUI_API bool          FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop = true);      // Return true if focus is requested
1333     IMGUI_API void          FocusableItemUnregister(ImGuiWindow* window);
1334     IMGUI_API ImVec2        CalcItemSize(ImVec2 size, float default_x, float default_y);
1335     IMGUI_API float         CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
1336     IMGUI_API void          PushMultiItemsWidths(int components, float width_full = 0.0f);
1337     IMGUI_API void          PushItemFlag(ImGuiItemFlags option, bool enabled);
1338     IMGUI_API void          PopItemFlag();
1339 
1340     // Popups, Modals, Tooltips
1341     IMGUI_API void          OpenPopupEx(ImGuiID id);
1342     IMGUI_API void          ClosePopupToLevel(int remaining, bool apply_focus_to_window_under);
1343     IMGUI_API void          ClosePopupsOverWindow(ImGuiWindow* ref_window);
1344     IMGUI_API bool          IsPopupOpen(ImGuiID id); // Test for id within current popup stack level (currently begin-ed into); this doesn't scan the whole popup stack!
1345     IMGUI_API bool          BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
1346     IMGUI_API void          BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
1347     IMGUI_API ImGuiWindow*  GetFrontMostPopupModal();
1348     IMGUI_API ImVec2        FindBestWindowPosForPopup(ImGuiWindow* window);
1349     IMGUI_API ImVec2        FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy = ImGuiPopupPositionPolicy_Default);
1350 
1351     // Navigation
1352     IMGUI_API void          NavInitWindow(ImGuiWindow* window, bool force_reinit);
1353     IMGUI_API bool          NavMoveRequestButNoResultYet();
1354     IMGUI_API void          NavMoveRequestCancel();
1355     IMGUI_API void          NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags);
1356     IMGUI_API void          NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
1357     IMGUI_API float         GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode);
1358     IMGUI_API ImVec2        GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f);
1359     IMGUI_API int           CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
1360     IMGUI_API void          ActivateItem(ImGuiID id);   // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again.
1361     IMGUI_API void          SetNavID(ImGuiID id, int nav_layer);
1362     IMGUI_API void          SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_rel);
1363 
1364     // Inputs
1365     inline bool             IsKeyPressedMap(ImGuiKey key, bool repeat = true)           { const int key_index = GImGui->IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; }
IsNavInputDown(ImGuiNavInput n)1366     inline bool             IsNavInputDown(ImGuiNavInput n)                             { return GImGui->IO.NavInputs[n] > 0.0f; }
IsNavInputPressed(ImGuiNavInput n,ImGuiInputReadMode mode)1367     inline bool             IsNavInputPressed(ImGuiNavInput n, ImGuiInputReadMode mode) { return GetNavInputAmount(n, mode) > 0.0f; }
IsNavInputPressedAnyOfTwo(ImGuiNavInput n1,ImGuiNavInput n2,ImGuiInputReadMode mode)1368     inline bool             IsNavInputPressedAnyOfTwo(ImGuiNavInput n1, ImGuiNavInput n2, ImGuiInputReadMode mode) { return (GetNavInputAmount(n1, mode) + GetNavInputAmount(n2, mode)) > 0.0f; }
1369 
1370     // Drag and Drop
1371     IMGUI_API bool          BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
1372     IMGUI_API void          ClearDragDrop();
1373     IMGUI_API bool          IsDragDropPayloadBeingAccepted();
1374 
1375     // New Columns API (FIXME-WIP)
1376     IMGUI_API void          BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
1377     IMGUI_API void          EndColumns();                                                             // close columns
1378     IMGUI_API void          PushColumnClipRect(int column_index = -1);
1379 
1380     // Tab Bars
1381     IMGUI_API bool          BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags);
1382     IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
1383     IMGUI_API void          TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
1384     IMGUI_API void          TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
1385     IMGUI_API void          TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir);
1386     IMGUI_API bool          TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags);
1387     IMGUI_API ImVec2        TabItemCalcSize(const char* label, bool has_close_button);
1388     IMGUI_API void          TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col);
1389     IMGUI_API bool          TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, const char* label, ImGuiID tab_id, ImGuiID close_button_id);
1390 
1391     // Render helpers
1392     // AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT.
1393     // NB: All position are in absolute pixels coordinates (we are never using window coordinates internally)
1394     IMGUI_API void          RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
1395     IMGUI_API void          RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
1396     IMGUI_API void          RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0,0), const ImRect* clip_rect = NULL);
1397     IMGUI_API void          RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL);
1398     IMGUI_API void          RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
1399     IMGUI_API void          RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
1400     IMGUI_API void          RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
1401     IMGUI_API void          RenderArrow(ImVec2 pos, ImGuiDir dir, float scale = 1.0f);
1402     IMGUI_API void          RenderBullet(ImVec2 pos);
1403     IMGUI_API void          RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
1404     IMGUI_API void          RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
1405     IMGUI_API const char*   FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
1406     IMGUI_API void          LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
1407 
1408     // Render helpers (those functions don't access any ImGui state!)
1409     IMGUI_API void          RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor = ImGuiMouseCursor_Arrow);
1410     IMGUI_API void          RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
1411     IMGUI_API void          RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
1412     IMGUI_API void          RenderPixelEllipsis(ImDrawList* draw_list, ImVec2 pos, int count, ImU32 col);
1413 
1414     // Widgets
1415     IMGUI_API bool          ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0);
1416     IMGUI_API bool          CloseButton(ImGuiID id, const ImVec2& pos, float radius);
1417     IMGUI_API bool          CollapseButton(ImGuiID id, const ImVec2& pos);
1418     IMGUI_API bool          ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags);
1419     IMGUI_API void          Scrollbar(ImGuiLayoutType direction);
1420     IMGUI_API void          VerticalSeparator();        // Vertical separator, for menu bars (use current line height). Not exposed because it is misleading and it doesn't have an effect on regular layout.
1421 
1422     // Widgets low-level behaviors
1423     IMGUI_API bool          ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
1424     IMGUI_API bool          DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power, ImGuiDragFlags flags);
1425     IMGUI_API bool          SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
1426     IMGUI_API bool          SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f);
1427     IMGUI_API bool          TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
1428     IMGUI_API bool          TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0);                     // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
1429     IMGUI_API void          TreePushRawID(ImGuiID id);
1430 
1431     // Template functions are instantiated in imgui_widgets.cpp for a finite number of types.
1432     // To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036).
1433     // e.g. " extern template IMGUI_API float RoundScalarWithFormatT<float, float>(const char* format, ImGuiDataType data_type, float v); "
1434     template<typename T, typename SIGNED_T, typename FLOAT_T>   IMGUI_API bool  DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, const T v_min, const T v_max, const char* format, float power, ImGuiDragFlags flags);
1435     template<typename T, typename SIGNED_T, typename FLOAT_T>   IMGUI_API bool  SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, const T v_min, const T v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
1436     template<typename T, typename FLOAT_T>                      IMGUI_API float SliderCalcRatioFromValueT(ImGuiDataType data_type, T v, T v_min, T v_max, float power, float linear_zero_pos);
1437     template<typename T, typename SIGNED_T>                     IMGUI_API T     RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v);
1438 
1439     // InputText
1440     IMGUI_API bool          InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
1441     IMGUI_API bool          InputScalarAsWidgetReplacement(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* data_ptr, const char* format);
1442 
1443     // Color
1444     IMGUI_API void          ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
1445     IMGUI_API void          ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
1446     IMGUI_API void          ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags);
1447 
1448     // Plot
1449     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 graph_size);
1450 
1451     // Shade functions (write over already created vertices)
1452     IMGUI_API void          ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
1453     IMGUI_API void          ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
1454 
1455 } // namespace ImGui
1456 
1457 // ImFontAtlas internals
1458 IMGUI_API bool              ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
1459 IMGUI_API void              ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
1460 IMGUI_API void              ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
1461 IMGUI_API void              ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
1462 IMGUI_API void              ImFontAtlasBuildFinish(ImFontAtlas* atlas);
1463 IMGUI_API void              ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
1464 IMGUI_API void              ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
1465 
1466 // Test engine hooks (imgui-test)
1467 //#define IMGUI_ENABLE_TEST_ENGINE
1468 #ifdef IMGUI_ENABLE_TEST_ENGINE
1469 extern void                 ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx);
1470 extern void                 ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx);
1471 extern void                 ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
1472 extern void                 ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, int flags);
1473 #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS)  ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS)   // Register status flags
1474 #else
1475 #define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS)  do { } while (0)
1476 #endif
1477 
1478 #ifdef __clang__
1479 #pragma clang diagnostic pop
1480 #endif
1481 
1482 #ifdef _MSC_VER
1483 #pragma warning (pop)
1484 #endif
1485