1 // dear imgui, v1.50
2 // (internals)
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 // Implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators)
6 //   #define IMGUI_DEFINE_MATH_OPERATORS
7 
8 #pragma once
9 
10 #ifndef IMGUI_VERSION
11 #error Must include imgui.h before imgui_internal.h
12 #endif
13 
14 #include <stdio.h>      // FILE*
15 #include <math.h>       // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
16 
17 #ifdef _MSC_VER
18 #pragma warning (push)
19 #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)
20 #endif
21 
22 #ifdef __clang__
23 #pragma clang diagnostic push
24 #pragma clang diagnostic ignored "-Wunused-function"        // for stb_textedit.h
25 #pragma clang diagnostic ignored "-Wmissing-prototypes"     // for stb_textedit.h
26 #pragma clang diagnostic ignored "-Wold-style-cast"
27 #endif
28 
29 //-----------------------------------------------------------------------------
30 // Forward Declarations
31 //-----------------------------------------------------------------------------
32 
33 struct ImRect;
34 struct ImGuiColMod;
35 struct ImGuiStyleMod;
36 struct ImGuiGroupData;
37 struct ImGuiSimpleColumns;
38 struct ImGuiDrawContext;
39 struct ImGuiTextEditState;
40 struct ImGuiIniData;
41 struct ImGuiMouseCursorData;
42 struct ImGuiPopupRef;
43 struct ImGuiWindow;
44 
45 typedef int ImGuiLayoutType;      // enum ImGuiLayoutType_
46 typedef int ImGuiButtonFlags;     // enum ImGuiButtonFlags_
47 typedef int ImGuiTreeNodeFlags;   // enum ImGuiTreeNodeFlags_
48 typedef int ImGuiSliderFlags;     // enum ImGuiSliderFlags_
49 
50 //-------------------------------------------------------------------------
51 // STB libraries
52 //-------------------------------------------------------------------------
53 
54 namespace ImGuiStb
55 {
56 
57 #undef STB_TEXTEDIT_STRING
58 #undef STB_TEXTEDIT_CHARTYPE
59 #define STB_TEXTEDIT_STRING             ImGuiTextEditState
60 #define STB_TEXTEDIT_CHARTYPE           ImWchar
61 #define STB_TEXTEDIT_GETWIDTH_NEWLINE   -1.0f
62 #include "stb_textedit.h"
63 
64 } // namespace ImGuiStb
65 
66 //-----------------------------------------------------------------------------
67 // Context
68 //-----------------------------------------------------------------------------
69 
70 #ifndef GImGui
71 extern IMGUI_API ImGuiContext* GImGui;  // Current implicit ImGui context pointer
72 #endif
73 
74 //-----------------------------------------------------------------------------
75 // Helpers
76 //-----------------------------------------------------------------------------
77 
78 #define IM_ARRAYSIZE(_ARR)      ((int)(sizeof(_ARR)/sizeof(*_ARR)))
79 #define IM_PI                   3.14159265358979323846f
80 #define IM_OFFSETOF(_TYPE,_ELM) ((size_t)&(((_TYPE*)0)->_ELM))
81 
82 // Helpers: UTF-8 <> wchar
83 IMGUI_API int           ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end);      // return output UTF-8 bytes count
84 IMGUI_API int           ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end);          // return input UTF-8 bytes count
85 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
86 IMGUI_API int           ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end);                            // return number of UTF-8 code-points (NOT bytes count)
87 IMGUI_API int           ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end);                   // return number of bytes to express string as UTF-8 code-points
88 
89 // Helpers: Misc
90 IMGUI_API ImU32         ImHash(const void* data, int data_size, ImU32 seed = 0);    // Pass data_size==0 for zero-terminated strings
91 IMGUI_API void*         ImFileLoadToMemory(const char* filename, const char* file_open_mode, int* out_file_size = NULL, int padding_bytes = 0);
92 IMGUI_API FILE*         ImFileOpen(const char* filename, const char* file_open_mode);
93 IMGUI_API bool          ImIsPointInTriangle(const ImVec2& p, const ImVec2& a, const ImVec2& b, const ImVec2& c);
ImCharIsSpace(int c)94 static inline bool      ImCharIsSpace(int c)            { return c == ' ' || c == '\t' || c == 0x3000; }
ImUpperPowerOfTwo(int v)95 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; }
96 
97 // Helpers: String
98 IMGUI_API int           ImStricmp(const char* str1, const char* str2);
99 IMGUI_API int           ImStrnicmp(const char* str1, const char* str2, int count);
100 IMGUI_API char*         ImStrdup(const char* str);
101 IMGUI_API int           ImStrlenW(const ImWchar* str);
102 IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
103 IMGUI_API const char*   ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
104 IMGUI_API int           ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_PRINTFARGS(3);
105 IMGUI_API int           ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args);
106 
107 // Helpers: Math
108 // We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined)
109 #ifdef IMGUI_DEFINE_MATH_OPERATORS
110 static inline ImVec2 operator*(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
111 static inline ImVec2 operator/(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x/rhs, lhs.y/rhs); }
112 static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
113 static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
114 static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
115 static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
116 static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
117 static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
118 static inline ImVec2& operator*=(ImVec2& lhs, const float rhs)                  { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
119 static inline ImVec2& operator/=(ImVec2& lhs, const float rhs)                  { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
120 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); }
121 #endif
122 
ImMin(int lhs,int rhs)123 static inline int    ImMin(int lhs, int rhs)                                    { return lhs < rhs ? lhs : rhs; }
ImMax(int lhs,int rhs)124 static inline int    ImMax(int lhs, int rhs)                                    { return lhs >= rhs ? lhs : rhs; }
ImMin(float lhs,float rhs)125 static inline float  ImMin(float lhs, float rhs)                                { return lhs < rhs ? lhs : rhs; }
ImMax(float lhs,float rhs)126 static inline float  ImMax(float lhs, float rhs)                                { return lhs >= rhs ? lhs : rhs; }
ImMin(const ImVec2 & lhs,const ImVec2 & rhs)127 static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs)                { return ImVec2(ImMin(lhs.x,rhs.x), ImMin(lhs.y,rhs.y)); }
ImMax(const ImVec2 & lhs,const ImVec2 & rhs)128 static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs)                { return ImVec2(ImMax(lhs.x,rhs.x), ImMax(lhs.y,rhs.y)); }
ImClamp(int v,int mn,int mx)129 static inline int    ImClamp(int v, int mn, int mx)                             { return (v < mn) ? mn : (v > mx) ? mx : v; }
ImClamp(float v,float mn,float mx)130 static inline float  ImClamp(float v, float mn, float mx)                       { return (v < mn) ? mn : (v > mx) ? mx : v; }
ImClamp(const ImVec2 & f,const ImVec2 & mn,ImVec2 mx)131 static inline ImVec2 ImClamp(const ImVec2& f, const ImVec2& mn, ImVec2 mx)      { return ImVec2(ImClamp(f.x,mn.x,mx.x), ImClamp(f.y,mn.y,mx.y)); }
ImSaturate(float f)132 static inline float  ImSaturate(float f)                                        { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
ImLerp(float a,float b,float t)133 static inline float  ImLerp(float a, float b, float t)                          { return a + (b - a) * t; }
ImLerp(const ImVec2 & a,const ImVec2 & b,const ImVec2 & t)134 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); }
ImLengthSqr(const ImVec2 & lhs)135 static inline float  ImLengthSqr(const ImVec2& lhs)                             { return lhs.x*lhs.x + lhs.y*lhs.y; }
ImLengthSqr(const ImVec4 & lhs)136 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)137 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 / sqrtf(d); return fail_value; }
ImFloor(float f)138 static inline float  ImFloor(float f)                                           { return (float)(int)f; }
ImFloor(ImVec2 v)139 static inline ImVec2 ImFloor(ImVec2 v)                                          { return ImVec2((float)(int)v.x, (float)(int)v.y); }
140 
141 // We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
142 // Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
143 #ifdef IMGUI_DEFINE_PLACEMENT_NEW
144 struct ImPlacementNewDummy {};
new(size_t,ImPlacementNewDummy,void * ptr)145 inline void* operator new(size_t, ImPlacementNewDummy, void* ptr) { return ptr; }
delete(void *,ImPlacementNewDummy,void *)146 inline void operator delete(void*, ImPlacementNewDummy, void*) {}
147 #define IM_PLACEMENT_NEW(_PTR)  new(ImPlacementNewDummy(), _PTR)
148 #endif
149 
150 //-----------------------------------------------------------------------------
151 // Types
152 //-----------------------------------------------------------------------------
153 
154 enum ImGuiButtonFlags_
155 {
156     ImGuiButtonFlags_Repeat                 = 1 << 0,   // hold to repeat
157     ImGuiButtonFlags_PressedOnClickRelease  = 1 << 1,   // (default) return pressed on click+release on same item (default if no PressedOn** flag is set)
158     ImGuiButtonFlags_PressedOnClick         = 1 << 2,   // return pressed on click (default requires click+release)
159     ImGuiButtonFlags_PressedOnRelease       = 1 << 3,   // return pressed on release (default requires click+release)
160     ImGuiButtonFlags_PressedOnDoubleClick   = 1 << 4,   // return pressed on double-click (default requires click+release)
161     ImGuiButtonFlags_FlattenChilds          = 1 << 5,   // allow interaction even if a child window is overlapping
162     ImGuiButtonFlags_DontClosePopups        = 1 << 6,   // disable automatically closing parent popup on press
163     ImGuiButtonFlags_Disabled               = 1 << 7,   // disable interaction
164     ImGuiButtonFlags_AlignTextBaseLine      = 1 << 8,   // vertically align button to match text baseline - ButtonEx() only
165     ImGuiButtonFlags_NoKeyModifiers         = 1 << 9,   // disable interaction if a key modifier is held
166     ImGuiButtonFlags_AllowOverlapMode       = 1 << 10   // require previous frame HoveredId to either match id or be null before being usable
167 };
168 
169 enum ImGuiSliderFlags_
170 {
171     ImGuiSliderFlags_Vertical               = 1 << 0
172 };
173 
174 enum ImGuiSelectableFlagsPrivate_
175 {
176     // NB: need to be in sync with last value of ImGuiSelectableFlags_
177     ImGuiSelectableFlags_Menu               = 1 << 3,
178     ImGuiSelectableFlags_MenuItem           = 1 << 4,
179     ImGuiSelectableFlags_Disabled           = 1 << 5,
180     ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
181 };
182 
183 // FIXME: this is in development, not exposed/functional as a generic feature yet.
184 enum ImGuiLayoutType_
185 {
186     ImGuiLayoutType_Vertical,
187     ImGuiLayoutType_Horizontal
188 };
189 
190 enum ImGuiPlotType
191 {
192     ImGuiPlotType_Lines,
193     ImGuiPlotType_Histogram
194 };
195 
196 enum ImGuiDataType
197 {
198     ImGuiDataType_Int,
199     ImGuiDataType_Float,
200     ImGuiDataType_Float2
201 };
202 
203 enum ImGuiCorner
204 {
205     ImGuiCorner_TopLeft     = 1 << 0, // 1
206     ImGuiCorner_TopRight    = 1 << 1, // 2
207     ImGuiCorner_BottomRight = 1 << 2, // 4
208     ImGuiCorner_BottomLeft  = 1 << 3, // 8
209     ImGuiCorner_All         = 0x0F
210 };
211 
212 // 2D axis aligned bounding-box
213 // NB: we can't rely on ImVec2 math operators being available here
214 struct IMGUI_API ImRect
215 {
216     ImVec2      Min;    // Upper-left
217     ImVec2      Max;    // Lower-right
218 
ImRectImRect219     ImRect()                                        : Min(FLT_MAX,FLT_MAX), Max(-FLT_MAX,-FLT_MAX)  {}
ImRectImRect220     ImRect(const ImVec2& min, const ImVec2& max)    : Min(min), Max(max)                            {}
ImRectImRect221     ImRect(const ImVec4& v)                         : Min(v.x, v.y), Max(v.z, v.w)                  {}
ImRectImRect222     ImRect(float x1, float y1, float x2, float y2)  : Min(x1, y1), Max(x2, y2)                      {}
223 
GetCenterImRect224     ImVec2      GetCenter() const               { return ImVec2((Min.x+Max.x)*0.5f, (Min.y+Max.y)*0.5f); }
GetSizeImRect225     ImVec2      GetSize() const                 { return ImVec2(Max.x-Min.x, Max.y-Min.y); }
GetWidthImRect226     float       GetWidth() const                { return Max.x-Min.x; }
GetHeightImRect227     float       GetHeight() const               { return Max.y-Min.y; }
GetTLImRect228     ImVec2      GetTL() const                   { return Min; }                   // Top-left
GetTRImRect229     ImVec2      GetTR() const                   { return ImVec2(Max.x, Min.y); }  // Top-right
GetBLImRect230     ImVec2      GetBL() const                   { return ImVec2(Min.x, Max.y); }  // Bottom-left
GetBRImRect231     ImVec2      GetBR() const                   { return Max; }                   // Bottom-right
ContainsImRect232     bool        Contains(const ImVec2& p) const { return p.x >= Min.x     && p.y >= Min.y     && p.x < Max.x     && p.y < Max.y; }
ContainsImRect233     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; }
OverlapsImRect234     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; }
AddImRect235     void        Add(const ImVec2& rhs)          { if (Min.x > rhs.x)     Min.x = rhs.x;     if (Min.y > rhs.y) Min.y = rhs.y;         if (Max.x < rhs.x) Max.x = rhs.x;         if (Max.y < rhs.y) Max.y = rhs.y; }
AddImRect236     void        Add(const ImRect& rhs)          { if (Min.x > rhs.Min.x) Min.x = rhs.Min.x; if (Min.y > rhs.Min.y) Min.y = rhs.Min.y; if (Max.x < rhs.Max.x) Max.x = rhs.Max.x; if (Max.y < rhs.Max.y) Max.y = rhs.Max.y; }
ExpandImRect237     void        Expand(const float amount)      { Min.x -= amount;   Min.y -= amount;   Max.x += amount;   Max.y += amount; }
ExpandImRect238     void        Expand(const ImVec2& amount)    { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
ReduceImRect239     void        Reduce(const ImVec2& amount)    { Min.x += amount.x; Min.y += amount.y; Max.x -= amount.x; Max.y -= amount.y; }
ClipImRect240     void        Clip(const ImRect& clip)        { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
FloorImRect241     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; }
GetClosestPointImRect242     ImVec2      GetClosestPoint(ImVec2 p, bool on_edge) const
243     {
244         if (!on_edge && Contains(p))
245             return p;
246         if (p.x > Max.x) p.x = Max.x;
247         else if (p.x < Min.x) p.x = Min.x;
248         if (p.y > Max.y) p.y = Max.y;
249         else if (p.y < Min.y) p.y = Min.y;
250         return p;
251     }
252 };
253 
254 // Stacked color modifier, backup of modified data so we can restore it
255 struct ImGuiColMod
256 {
257     ImGuiCol    Col;
258     ImVec4      BackupValue;
259 };
260 
261 // Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
262 struct ImGuiStyleMod
263 {
264     ImGuiStyleVar   VarIdx;
265     union           { int BackupInt[2]; float BackupFloat[2]; };
ImGuiStyleModImGuiStyleMod266     ImGuiStyleMod(ImGuiStyleVar idx, int v)     { VarIdx = idx; BackupInt[0] = v; }
ImGuiStyleModImGuiStyleMod267     ImGuiStyleMod(ImGuiStyleVar idx, float v)   { VarIdx = idx; BackupFloat[0] = v; }
ImGuiStyleModImGuiStyleMod268     ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v)  { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
269 };
270 
271 // Stacked data for BeginGroup()/EndGroup()
272 struct ImGuiGroupData
273 {
274     ImVec2      BackupCursorPos;
275     ImVec2      BackupCursorMaxPos;
276     float       BackupIndentX;
277     float       BackupGroupOffsetX;
278     float       BackupCurrentLineHeight;
279     float       BackupCurrentLineTextBaseOffset;
280     float       BackupLogLinePosY;
281     bool        BackupActiveIdIsAlive;
282     bool        AdvanceCursor;
283 };
284 
285 // Per column data for Columns()
286 struct ImGuiColumnData
287 {
288     float       OffsetNorm;     // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
289     //float     IndentX;
290 };
291 
292 // Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper.
293 struct IMGUI_API ImGuiSimpleColumns
294 {
295     int         Count;
296     float       Spacing;
297     float       Width, NextWidth;
298     float       Pos[8], NextWidths[8];
299 
300     ImGuiSimpleColumns();
301     void        Update(int count, float spacing, bool clear);
302     float       DeclColumns(float w0, float w1, float w2);
303     float       CalcExtraSpace(float avail_w);
304 };
305 
306 // Internal state of the currently focused/edited text input box
307 struct IMGUI_API ImGuiTextEditState
308 {
309     ImGuiID             Id;                         // widget id owning the text state
310     ImVector<ImWchar>   Text;                       // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
311     ImVector<char>      InitialText;                // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
312     ImVector<char>      TempTextBuffer;
313     int                 CurLenA, CurLenW;           // we need to maintain our buffer length in both UTF-8 and wchar format.
314     int                 BufSizeA;                   // end-user buffer size
315     float               ScrollX;
316     ImGuiStb::STB_TexteditState   StbState;
317     float               CursorAnim;
318     bool                CursorFollow;
319     bool                SelectedAllMouseLock;
320 
ImGuiTextEditStateImGuiTextEditState321     ImGuiTextEditState()                            { memset(this, 0, sizeof(*this)); }
CursorAnimResetImGuiTextEditState322     void                CursorAnimReset()           { CursorAnim = -0.30f; }                                   // After a user-input the cursor stays on for a while without blinking
CursorClampImGuiTextEditState323     void                CursorClamp()               { StbState.cursor = ImMin(StbState.cursor, CurLenW); StbState.select_start = ImMin(StbState.select_start, CurLenW); StbState.select_end = ImMin(StbState.select_end, CurLenW); }
HasSelectionImGuiTextEditState324     bool                HasSelection() const        { return StbState.select_start != StbState.select_end; }
ClearSelectionImGuiTextEditState325     void                ClearSelection()            { StbState.select_start = StbState.select_end = StbState.cursor; }
SelectAllImGuiTextEditState326     void                SelectAll()                 { StbState.select_start = 0; StbState.select_end = CurLenW; StbState.cursor = StbState.select_end; StbState.has_preferred_x = false; }
327     void                OnKeyPressed(int key);
328 };
329 
330 // Data saved in imgui.ini file
331 struct ImGuiIniData
332 {
333     char*       Name;
334     ImGuiID     Id;
335     ImVec2      Pos;
336     ImVec2      Size;
337     bool        Collapsed;
338 };
339 
340 // Mouse cursor data (used when io.MouseDrawCursor is set)
341 struct ImGuiMouseCursorData
342 {
343     ImGuiMouseCursor    Type;
344     ImVec2              HotOffset;
345     ImVec2              Size;
346     ImVec2              TexUvMin[2];
347     ImVec2              TexUvMax[2];
348 };
349 
350 // Storage for current popup stack
351 struct ImGuiPopupRef
352 {
353     ImGuiID         PopupId;        // Set on OpenPopup()
354     ImGuiWindow*    Window;         // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
355     ImGuiWindow*    ParentWindow;   // Set on OpenPopup()
356     ImGuiID         ParentMenuSet;  // Set on OpenPopup()
357     ImVec2          MousePosOnOpen; // Copy of mouse position at the time of opening popup
358 
ImGuiPopupRefImGuiPopupRef359     ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
360 };
361 
362 // Main state for ImGui
363 struct ImGuiContext
364 {
365     bool                    Initialized;
366     ImGuiIO                 IO;
367     ImGuiStyle              Style;
368     ImFont*                 Font;                               // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
369     float                   FontSize;                           // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize()
370     float                   FontBaseSize;                       // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Size of characters.
371     ImVec2                  FontTexUvWhitePixel;                // (Shortcut) == Font->TexUvWhitePixel
372 
373     float                   Time;
374     int                     FrameCount;
375     int                     FrameCountEnded;
376     int                     FrameCountRendered;
377     ImVector<ImGuiWindow*>  Windows;
378     ImVector<ImGuiWindow*>  WindowsSortBuffer;
379     ImGuiWindow*            CurrentWindow;                      // Being drawn into
380     ImVector<ImGuiWindow*>  CurrentWindowStack;
381     ImGuiWindow*            FocusedWindow;                      // Will catch keyboard inputs
382     ImGuiWindow*            HoveredWindow;                      // Will catch mouse inputs
383     ImGuiWindow*            HoveredRootWindow;                  // Will catch mouse inputs (for focus/move only)
384     ImGuiID                 HoveredId;                          // Hovered widget
385     bool                    HoveredIdAllowOverlap;
386     ImGuiID                 HoveredIdPreviousFrame;
387     ImGuiID                 ActiveId;                           // Active widget
388     ImGuiID                 ActiveIdPreviousFrame;
389     bool                    ActiveIdIsAlive;
390     bool                    ActiveIdIsJustActivated;            // Set at the time of activation for one frame
391     bool                    ActiveIdAllowOverlap;               // Set only by active widget
392     ImVec2                  ActiveIdClickOffset;                // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
393     ImGuiWindow*            ActiveIdWindow;
394     ImGuiWindow*            MovedWindow;                        // Track the child window we clicked on to move a window.
395     ImGuiID                 MovedWindowMoveId;                  // == MovedWindow->RootWindow->MoveId
396     ImVector<ImGuiIniData>  Settings;                           // .ini Settings
397     float                   SettingsDirtyTimer;                 // Save .ini Settings on disk when time reaches zero
398     ImVector<ImGuiColMod>   ColorModifiers;                     // Stack for PushStyleColor()/PopStyleColor()
399     ImVector<ImGuiStyleMod> StyleModifiers;                     // Stack for PushStyleVar()/PopStyleVar()
400     ImVector<ImFont*>       FontStack;                          // Stack for PushFont()/PopFont()
401     ImVector<ImGuiPopupRef> OpenPopupStack;                     // Which popups are open (persistent)
402     ImVector<ImGuiPopupRef> CurrentPopupStack;                  // Which level of BeginPopup() we are in (reset every frame)
403 
404     // Storage for SetNexWindow** and SetNextTreeNode*** functions
405     ImVec2                  SetNextWindowPosVal;
406     ImVec2                  SetNextWindowSizeVal;
407     ImVec2                  SetNextWindowContentSizeVal;
408     bool                    SetNextWindowCollapsedVal;
409     ImGuiSetCond            SetNextWindowPosCond;
410     ImGuiSetCond            SetNextWindowSizeCond;
411     ImGuiSetCond            SetNextWindowContentSizeCond;
412     ImGuiSetCond            SetNextWindowCollapsedCond;
413     ImRect                  SetNextWindowSizeConstraintRect;           // Valid if 'SetNextWindowSizeConstraint' is true
414     ImGuiSizeConstraintCallback SetNextWindowSizeConstraintCallback;
415     void*                       SetNextWindowSizeConstraintCallbackUserData;
416     bool                    SetNextWindowSizeConstraint;
417     bool                    SetNextWindowFocus;
418     bool                    SetNextTreeNodeOpenVal;
419     ImGuiSetCond            SetNextTreeNodeOpenCond;
420 
421     // Render
422     ImDrawData              RenderDrawData;                     // Main ImDrawData instance to pass render information to the user
423     ImVector<ImDrawList*>   RenderDrawLists[3];
424     float                   ModalWindowDarkeningRatio;
425     ImDrawList              OverlayDrawList;                    // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays
426     ImGuiMouseCursor        MouseCursor;
427     ImGuiMouseCursorData    MouseCursorData[ImGuiMouseCursor_Count_];
428 
429     // Widget state
430     ImGuiTextEditState      InputTextState;
431     ImFont                  InputTextPasswordFont;
432     ImGuiID                 ScalarAsInputTextId;                // Temporary text input when CTRL+clicking on a slider, etc.
433     ImGuiStorage            ColorEditModeStorage;               // Store user selection of color edit mode
434     float                   DragCurrentValue;                   // Currently dragged value, always float, not rounded by end-user precision settings
435     ImVec2                  DragLastMouseDelta;
436     float                   DragSpeedDefaultRatio;              // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
437     float                   DragSpeedScaleSlow;
438     float                   DragSpeedScaleFast;
439     ImVec2                  ScrollbarClickDeltaToGrabCenter;    // Distance between mouse and center of grab box, normalized in parent space. Use storage?
440     char                    Tooltip[1024];
441     char*                   PrivateClipboard;                   // If no custom clipboard handler is defined
442     ImVec2                  OsImePosRequest, OsImePosSet;       // Cursor position request & last passed to the OS Input Method Editor
443 
444     // Logging
445     bool                    LogEnabled;
446     FILE*                   LogFile;                            // If != NULL log to stdout/ file
447     ImGuiTextBuffer*        LogClipboard;                       // Else log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
448     int                     LogStartDepth;
449     int                     LogAutoExpandMaxDepth;
450 
451     // Misc
452     float                   FramerateSecPerFrame[120];          // calculate estimate of framerate for user
453     int                     FramerateSecPerFrameIdx;
454     float                   FramerateSecPerFrameAccum;
455     int                     CaptureMouseNextFrame;              // explicit capture via CaptureInputs() sets those flags
456     int                     CaptureKeyboardNextFrame;
457     char                    TempBuffer[1024*3+1];               // temporary text buffer
458 
ImGuiContextImGuiContext459     ImGuiContext()
460     {
461         Initialized = false;
462         Font = NULL;
463         FontSize = FontBaseSize = 0.0f;
464         FontTexUvWhitePixel = ImVec2(0.0f, 0.0f);
465 
466         Time = 0.0f;
467         FrameCount = 0;
468         FrameCountEnded = FrameCountRendered = -1;
469         CurrentWindow = NULL;
470         FocusedWindow = NULL;
471         HoveredWindow = NULL;
472         HoveredRootWindow = NULL;
473         HoveredId = 0;
474         HoveredIdAllowOverlap = false;
475         HoveredIdPreviousFrame = 0;
476         ActiveId = 0;
477         ActiveIdPreviousFrame = 0;
478         ActiveIdIsAlive = false;
479         ActiveIdIsJustActivated = false;
480         ActiveIdAllowOverlap = false;
481         ActiveIdClickOffset = ImVec2(-1,-1);
482         ActiveIdWindow = NULL;
483         MovedWindow = NULL;
484         MovedWindowMoveId = 0;
485         SettingsDirtyTimer = 0.0f;
486 
487         SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
488         SetNextWindowSizeVal = ImVec2(0.0f, 0.0f);
489         SetNextWindowCollapsedVal = false;
490         SetNextWindowPosCond = 0;
491         SetNextWindowSizeCond = 0;
492         SetNextWindowContentSizeCond = 0;
493         SetNextWindowCollapsedCond = 0;
494         SetNextWindowSizeConstraintRect = ImRect();
495         SetNextWindowSizeConstraintCallback = NULL;
496         SetNextWindowSizeConstraintCallbackUserData = NULL;
497         SetNextWindowSizeConstraint = false;
498         SetNextWindowFocus = false;
499         SetNextTreeNodeOpenVal = false;
500         SetNextTreeNodeOpenCond = 0;
501 
502         ScalarAsInputTextId = 0;
503         DragCurrentValue = 0.0f;
504         DragLastMouseDelta = ImVec2(0.0f, 0.0f);
505         DragSpeedDefaultRatio = 1.0f / 100.0f;
506         DragSpeedScaleSlow = 0.01f;
507         DragSpeedScaleFast = 10.0f;
508         ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
509         memset(Tooltip, 0, sizeof(Tooltip));
510         PrivateClipboard = NULL;
511         OsImePosRequest = OsImePosSet = ImVec2(-1.0f, -1.0f);
512 
513         ModalWindowDarkeningRatio = 0.0f;
514         OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
515         MouseCursor = ImGuiMouseCursor_Arrow;
516         memset(MouseCursorData, 0, sizeof(MouseCursorData));
517 
518         LogEnabled = false;
519         LogFile = NULL;
520         LogClipboard = NULL;
521         LogStartDepth = 0;
522         LogAutoExpandMaxDepth = 2;
523 
524         memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
525         FramerateSecPerFrameIdx = 0;
526         FramerateSecPerFrameAccum = 0.0f;
527         CaptureMouseNextFrame = CaptureKeyboardNextFrame = -1;
528         memset(TempBuffer, 0, sizeof(TempBuffer));
529     }
530 };
531 
532 // Transient per-window data, reset at the beginning of the frame
533 // FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
534 struct IMGUI_API ImGuiDrawContext
535 {
536     ImVec2                  CursorPos;
537     ImVec2                  CursorPosPrevLine;
538     ImVec2                  CursorStartPos;
539     ImVec2                  CursorMaxPos;           // Implicitly calculate the size of our contents, always extending. Saved into window->SizeContents at the end of the frame
540     float                   CurrentLineHeight;
541     float                   CurrentLineTextBaseOffset;
542     float                   PrevLineHeight;
543     float                   PrevLineTextBaseOffset;
544     float                   LogLinePosY;
545     int                     TreeDepth;
546     ImGuiID                 LastItemId;
547     ImRect                  LastItemRect;
548     bool                    LastItemHoveredAndUsable;  // Item rectangle is hovered, and its window is currently interactable with (not blocked by a popup preventing access to the window)
549     bool                    LastItemHoveredRect;       // Item rectangle is hovered, but its window may or not be currently interactable with (might be blocked by a popup preventing access to the window)
550     bool                    MenuBarAppending;
551     float                   MenuBarOffsetX;
552     ImVector<ImGuiWindow*>  ChildWindows;
553     ImGuiStorage*           StateStorage;
554     ImGuiLayoutType         LayoutType;
555 
556     // 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.
557     float                   ItemWidth;              // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
558     float                   TextWrapPos;            // == TextWrapPosStack.back() [empty == -1.0f]
559     bool                    AllowKeyboardFocus;     // == AllowKeyboardFocusStack.back() [empty == true]
560     bool                    ButtonRepeat;           // == ButtonRepeatStack.back() [empty == false]
561     ImVector<float>         ItemWidthStack;
562     ImVector<float>         TextWrapPosStack;
563     ImVector<bool>          AllowKeyboardFocusStack;
564     ImVector<bool>          ButtonRepeatStack;
565     ImVector<ImGuiGroupData>GroupStack;
566     ImGuiColorEditMode      ColorEditMode;
567     int                     StackSizesBackup[6];    // Store size of various stacks for asserting
568 
569     float                   IndentX;                // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
570     float                   GroupOffsetX;
571     float                   ColumnsOffsetX;         // 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.
572     int                     ColumnsCurrent;
573     int                     ColumnsCount;
574     float                   ColumnsMinX;
575     float                   ColumnsMaxX;
576     float                   ColumnsStartPosY;
577     float                   ColumnsCellMinY;
578     float                   ColumnsCellMaxY;
579     bool                    ColumnsShowBorders;
580     ImGuiID                 ColumnsSetId;
581     ImVector<ImGuiColumnData> ColumnsData;
582 
ImGuiDrawContextImGuiDrawContext583     ImGuiDrawContext()
584     {
585         CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
586         CurrentLineHeight = PrevLineHeight = 0.0f;
587         CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
588         LogLinePosY = -1.0f;
589         TreeDepth = 0;
590         LastItemId = 0;
591         LastItemRect = ImRect(0.0f,0.0f,0.0f,0.0f);
592         LastItemHoveredAndUsable = LastItemHoveredRect = false;
593         MenuBarAppending = false;
594         MenuBarOffsetX = 0.0f;
595         StateStorage = NULL;
596         LayoutType = ImGuiLayoutType_Vertical;
597         ItemWidth = 0.0f;
598         ButtonRepeat = false;
599         AllowKeyboardFocus = true;
600         TextWrapPos = -1.0f;
601         ColorEditMode = ImGuiColorEditMode_RGB;
602         memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
603 
604         IndentX = 0.0f;
605         GroupOffsetX = 0.0f;
606         ColumnsOffsetX = 0.0f;
607         ColumnsCurrent = 0;
608         ColumnsCount = 1;
609         ColumnsMinX = ColumnsMaxX = 0.0f;
610         ColumnsStartPosY = 0.0f;
611         ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
612         ColumnsShowBorders = true;
613         ColumnsSetId = 0;
614     }
615 };
616 
617 // Windows data
618 struct IMGUI_API ImGuiWindow
619 {
620     char*                   Name;
621     ImGuiID                 ID;                                 // == ImHash(Name)
622     ImGuiWindowFlags        Flags;                              // See enum ImGuiWindowFlags_
623     int                     IndexWithinParent;                  // Order within immediate parent window, if we are a child window. Otherwise 0.
624     ImVec2                  PosFloat;
625     ImVec2                  Pos;                                // Position rounded-up to nearest pixel
626     ImVec2                  Size;                               // Current size (==SizeFull or collapsed title bar size)
627     ImVec2                  SizeFull;                           // Size when non collapsed
628     ImVec2                  SizeContents;                       // Size of contents (== extents reach of the drawing cursor) from previous frame
629     ImVec2                  SizeContentsExplicit;               // Size of contents explicitly set by the user via SetNextWindowContentSize()
630     ImRect                  ContentsRegionRect;                 // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
631     ImVec2                  WindowPadding;                      // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
632     ImGuiID                 MoveId;                             // == window->GetID("#MOVE")
633     ImVec2                  Scroll;
634     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)
635     ImVec2                  ScrollTargetCenterRatio;            // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
636     bool                    ScrollbarX, ScrollbarY;
637     ImVec2                  ScrollbarSizes;
638     float                   BorderSize;
639     bool                    Active;                             // Set to true on Begin()
640     bool                    WasActive;
641     bool                    Accessed;                           // Set to true when any widget access the current window
642     bool                    Collapsed;                          // Set when collapsing window to become only title-bar
643     bool                    SkipItems;                          // == Visible && !Collapsed
644     int                     BeginCount;                         // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
645     ImGuiID                 PopupId;                            // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
646     int                     AutoFitFramesX, AutoFitFramesY;
647     bool                    AutoFitOnlyGrows;
648     int                     AutoPosLastDirection;
649     int                     HiddenFrames;
650     int                     SetWindowPosAllowFlags;             // bit ImGuiSetCond_*** specify if SetWindowPos() call will succeed with this particular flag.
651     int                     SetWindowSizeAllowFlags;            // bit ImGuiSetCond_*** specify if SetWindowSize() call will succeed with this particular flag.
652     int                     SetWindowCollapsedAllowFlags;       // bit ImGuiSetCond_*** specify if SetWindowCollapsed() call will succeed with this particular flag.
653     bool                    SetWindowPosCenterWanted;
654 
655     ImGuiDrawContext        DC;                                 // Temporary per-window data, reset at the beginning of the frame
656     ImVector<ImGuiID>       IDStack;                            // ID stack. ID are hashes seeded with the value at the top of the stack
657     ImRect                  ClipRect;                           // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
658     ImRect                  WindowRectClipped;                  // = WindowRect just after setup in Begin(). == window->Rect() for root window.
659     int                     LastFrameActive;
660     float                   ItemWidthDefault;
661     ImGuiSimpleColumns      MenuColumns;                        // Simplified columns storage for menu items
662     ImGuiStorage            StateStorage;
663     float                   FontWindowScale;                    // Scale multiplier per-window
664     ImDrawList*             DrawList;
665     ImGuiWindow*            RootWindow;                         // If we are a child window, this is pointing to the first non-child parent window. Else point to ourself.
666     ImGuiWindow*            RootNonPopupWindow;                 // If we are a child window, this is pointing to the first non-child non-popup parent window. Else point to ourself.
667     ImGuiWindow*            ParentWindow;                       // If we are a child window, this is pointing to our parent window. Else point to NULL.
668 
669     // Navigation / Focus
670     int                     FocusIdxAllCounter;                 // Start at -1 and increase as assigned via FocusItemRegister()
671     int                     FocusIdxTabCounter;                 // (same, but only count widgets which you can Tab through)
672     int                     FocusIdxAllRequestCurrent;          // Item being requested for focus
673     int                     FocusIdxTabRequestCurrent;          // Tab-able item being requested for focus
674     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)
675     int                     FocusIdxTabRequestNext;             // "
676 
677 public:
678     ImGuiWindow(const char* name);
679     ~ImGuiWindow();
680 
681     ImGuiID     GetID(const char* str, const char* str_end = NULL);
682     ImGuiID     GetID(const void* ptr);
683     ImGuiID     GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
684 
RectImGuiWindow685     ImRect      Rect() const                            { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
CalcFontSizeImGuiWindow686     float       CalcFontSize() const                    { return GImGui->FontBaseSize * FontWindowScale; }
TitleBarHeightImGuiWindow687     float       TitleBarHeight() const                  { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; }
TitleBarRectImGuiWindow688     ImRect      TitleBarRect() const                    { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
MenuBarHeightImGuiWindow689     float       MenuBarHeight() const                   { return (Flags & ImGuiWindowFlags_MenuBar) ? CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
MenuBarRectImGuiWindow690     ImRect      MenuBarRect() const                     { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
691 };
692 
693 //-----------------------------------------------------------------------------
694 // Internal API
695 // No guarantee of forward compatibility here.
696 //-----------------------------------------------------------------------------
697 
698 namespace ImGui
699 {
700     // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
701     // If this ever crash because g.CurrentWindow is NULL it means that either
702     // - ImGui::NewFrame() has never been called, which is illegal.
703     // - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
GetCurrentWindowRead()704     inline    ImGuiWindow*  GetCurrentWindowRead()      { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
GetCurrentWindow()705     inline    ImGuiWindow*  GetCurrentWindow()          { ImGuiContext& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
706     IMGUI_API ImGuiWindow*  GetParentWindow();
707     IMGUI_API ImGuiWindow*  FindWindowByName(const char* name);
708     IMGUI_API void          FocusWindow(ImGuiWindow* window);
709 
710     IMGUI_API void          EndFrame();                 // Ends the ImGui frame. Automatically called by Render()! you most likely don't need to ever call that yourself directly. If you don't need to render you can call EndFrame() but you'll have wasted CPU already. If you don't need to render, don't create any windows instead!
711 
712     IMGUI_API void          SetActiveID(ImGuiID id, ImGuiWindow* window);
713 	IMGUI_API void          ClearActiveID();
714     IMGUI_API void          SetHoveredID(ImGuiID id);
715     IMGUI_API void          KeepAliveID(ImGuiID id);
716 
717     IMGUI_API void          ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
718     IMGUI_API void          ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
719     IMGUI_API bool          ItemAdd(const ImRect& bb, const ImGuiID* id);
720     IMGUI_API bool          IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged);
721     IMGUI_API bool          IsHovered(const ImRect& bb, ImGuiID id, bool flatten_childs = false);
722     IMGUI_API bool          FocusableItemRegister(ImGuiWindow* window, bool is_active, bool tab_stop = true);      // Return true if focus is requested
723     IMGUI_API void          FocusableItemUnregister(ImGuiWindow* window);
724     IMGUI_API ImVec2        CalcItemSize(ImVec2 size, float default_x, float default_y);
725     IMGUI_API float         CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
726 
727     IMGUI_API void          OpenPopupEx(const char* str_id, bool reopen_existing);
728 
729     // NB: All position are in absolute pixels coordinates (not window coordinates)
730     // FIXME: All those functions are a mess and needs to be refactored into something decent. AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION.
731     // We need: a sort of symbol library, preferably baked into font atlas when possible + decent text rendering helpers.
732     IMGUI_API void          RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
733     IMGUI_API void          RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
734     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);
735     IMGUI_API void          RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
736     IMGUI_API void          RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f);
737     IMGUI_API void          RenderBullet(ImVec2 pos);
738     IMGUI_API void          RenderCheckMark(ImVec2 pos, ImU32 col);
739     IMGUI_API const char*   FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
740 
741     IMGUI_API bool          ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
742     IMGUI_API bool          ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0);
743     IMGUI_API bool          CloseButton(ImGuiID id, const ImVec2& pos, float radius);
744 
745     IMGUI_API bool          SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags = 0);
746     IMGUI_API bool          SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* display_format, float power);
747     IMGUI_API bool          SliderIntN(const char* label, int* v, int components, int v_min, int v_max, const char* display_format);
748 
749     IMGUI_API bool          DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_speed, float v_min, float v_max, int decimal_precision, float power);
750     IMGUI_API bool          DragFloatN(const char* label, float* v, int components, float v_speed, float v_min, float v_max, const char* display_format, float power);
751     IMGUI_API bool          DragIntN(const char* label, int* v, int components, float v_speed, int v_min, int v_max, const char* display_format);
752 
753     IMGUI_API bool          InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
754     IMGUI_API bool          InputFloatN(const char* label, float* v, int components, int decimal_precision, ImGuiInputTextFlags extra_flags);
755     IMGUI_API bool          InputIntN(const char* label, int* v, int components, ImGuiInputTextFlags extra_flags);
756     IMGUI_API bool          InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags);
757     IMGUI_API bool          InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision);
758 
759     IMGUI_API bool          TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
760     IMGUI_API bool          TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0);                     // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
761     IMGUI_API void          TreePushRawID(ImGuiID id);
762 
763     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);
764 
765     IMGUI_API int           ParseFormatPrecision(const char* fmt, int default_value);
766     IMGUI_API float         RoundScalar(float value, int decimal_precision);
767 
768 } // namespace ImGui
769 
770 #ifdef __clang__
771 #pragma clang diagnostic pop
772 #endif
773 
774 #ifdef _MSC_VER
775 #pragma warning (pop)
776 #endif
777