1// dear imgui, v1.90.0
2// (internal structures/api)
3
4// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
5
6/*
7
8Index of this file:
9
10// [SECTION] Header mess
11// [SECTION] Forward declarations
12// [SECTION] Context pointer
13// [SECTION] STB libraries includes
14// [SECTION] Macros
15// [SECTION] Generic helpers
16// [SECTION] ImDrawList support
17// [SECTION] Widgets support: flags, enums, data structures
18// [SECTION] Inputs support
19// [SECTION] Clipper support
20// [SECTION] Navigation support
21// [SECTION] Typing-select support
22// [SECTION] Columns support
23// [SECTION] Multi-select support
24// [SECTION] Docking support
25// [SECTION] Viewport support
26// [SECTION] Settings support
27// [SECTION] Localization support
28// [SECTION] Metrics, Debug tools
29// [SECTION] Generic context hooks
30// [SECTION] ImGuiContext (main imgui context)
31// [SECTION] ImGuiWindowTempData, ImGuiWindow
32// [SECTION] Tab bar, Tab item support
33// [SECTION] Table support
34// [SECTION] ImGui internal API
35// [SECTION] ImFontAtlas internal API
36// [SECTION] Test Engine specific hooks (imgui_test_engine)
37
38*/
39
40#pragma once
41#ifndef IMGUI_DISABLE
42
43//-----------------------------------------------------------------------------
44// [SECTION] Header mess
45//-----------------------------------------------------------------------------
46
47#ifndef IMGUI_VERSION
48#include "imgui.h"
49#endif
50
51#include <stdio.h> // FILE*, sscanf
52#include <stdlib.h> // NULL, malloc, free, qsort, atoi, atof
53#include <math.h> // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
54#include <limits.h> // INT_MIN, INT_MAX
55
56// Enable SSE intrinsics if available
57#if (defined __SSE__ || defined __x86_64__ || defined _M_X64 || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1))) && !defined(IMGUI_DISABLE_SSE)
58#define IMGUI_ENABLE_SSE
59#include <immintrin.h>
60#endif
61
62// Visual Studio warnings
63#ifdef _MSC_VER
64#pragma warning (push)
65#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)
66#pragma warning (disable: 26812) // The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer)
67#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
68#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
69#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
70#endif
71#endif
72
73// Clang/GCC warnings with -Weverything
74#if defined(__clang__)
75#pragma clang diagnostic push
76#if __has_warning("-Wunknown-warning-option")
77#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx'
78#endif
79#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx'
80#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants ok, for ImFloor()
81#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h
82#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h
83#pragma clang diagnostic ignored "-Wold-style-cast"
84#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
85#pragma clang diagnostic ignored "-Wdouble-promotion"
86#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
87#pragma clang diagnostic ignored "-Wmissing-noreturn" // warning: function 'xxx' could be declared with attribute 'noreturn'
88#elif defined(__GNUC__)
89#pragma GCC diagnostic push
90#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
91#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
92#endif
93
94// In 1.89.4, we moved the implementation of "courtesy maths operators" from imgui_internal.h in imgui.h
95// As they are frequently requested, we do not want to encourage to many people using imgui_internal.h
96#if defined(IMGUI_DEFINE_MATH_OPERATORS) && !defined(IMGUI_DEFINE_MATH_OPERATORS_IMPLEMENTED)
97#error Please '#define IMGUI_DEFINE_MATH_OPERATORS' _BEFORE_ including imgui.h!
98#endif
99
100// Legacy defines
101#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74
102#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
103#endif
104#ifdef IMGUI_DISABLE_MATH_FUNCTIONS // Renamed in 1.74
105#error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
106#endif
107
108// Enable stb_truetype by default unless FreeType is enabled.
109// You can compile with both by defining both IMGUI_ENABLE_FREETYPE and IMGUI_ENABLE_STB_TRUETYPE together.
110#ifndef IMGUI_ENABLE_FREETYPE
111#define IMGUI_ENABLE_STB_TRUETYPE
112#endif
113
114//-----------------------------------------------------------------------------
115// [SECTION] Forward declarations
116//-----------------------------------------------------------------------------
117
118struct ImBitVector; // Store 1-bit per value
119struct ImRect; // An axis-aligned rectangle (2 points)
120struct ImDrawDataBuilder; // Helper to build a ImDrawData instance
121struct ImDrawListSharedData; // Data shared between all ImDrawList instances
122struct ImGuiColorMod; // Stacked color modifier, backup of modified data so we can restore it
123struct ImGuiContext; // Main Dear ImGui context
124struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine
125struct ImGuiDataVarInfo; // Variable information (e.g. to avoid style variables from an enum)
126struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
127struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
128struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
129struct ImGuiInputTextDeactivateData;// Short term storage to backup text of a deactivating InputText() while another is stealing active id
130struct ImGuiLastItemData; // Status storage for last submitted items
131struct ImGuiLocEntry; // A localization entry.
132struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
133struct ImGuiNavItemData; // Result of a gamepad/keyboard directional navigation move query result
134struct ImGuiNavTreeNodeData; // Temporary storage for last TreeNode() being a Left arrow landing candidate.
135struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions
136struct ImGuiNextWindowData; // Storage for SetNextWindow** functions
137struct ImGuiNextItemData; // Storage for SetNextItem** functions
138struct ImGuiOldColumnData; // Storage data for a single column for legacy Columns() api
139struct ImGuiOldColumns; // Storage data for a columns set for legacy Columns() api
140struct ImGuiPopupData; // Storage for current popup stack
141struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file
142struct ImGuiStackSizes; // Storage of stack sizes for debugging/asserting
143struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it
144struct ImGuiTabBar; // Storage for a tab bar
145struct ImGuiTabItem; // Storage for a tab item (within a tab bar)
146struct ImGuiTable; // Storage for a table
147struct ImGuiTableColumn; // Storage for one column of a table
148struct ImGuiTableInstanceData; // Storage for one instance of a same table
149struct ImGuiTableTempData; // Temporary storage for one table (one per table in the stack), shared between tables.
150struct ImGuiTableSettings; // Storage for a table .ini settings
151struct ImGuiTableColumnsSettings; // Storage for a column .ini settings
152struct ImGuiTypingSelectState; // Storage for GetTypingSelectRequest()
153struct ImGuiTypingSelectRequest; // Storage for GetTypingSelectRequest() (aimed to be public)
154struct ImGuiWindow; // Storage for one window
155struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame, in practice we currently keep it for each window)
156struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
157
158// Enumerations
159// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
160enum ImGuiLocKey : int; // -> enum ImGuiLocKey // Enum: a localization entry for translation.
161typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
162
163// Flags
164typedef int ImGuiActivateFlags; // -> enum ImGuiActivateFlags_ // Flags: for navigation/focus function (will be for ActivateItem() later)
165typedef int ImGuiDebugLogFlags; // -> enum ImGuiDebugLogFlags_ // Flags: for ShowDebugLogWindow(), g.DebugLogFlags
166typedef int ImGuiFocusRequestFlags; // -> enum ImGuiFocusRequestFlags_ // Flags: for FocusWindow();
167typedef int ImGuiInputFlags; // -> enum ImGuiInputFlags_ // Flags: for IsKeyPressed(), IsMouseClicked(), SetKeyOwner(), SetItemKeyOwner() etc.
168typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), g.LastItemData.InFlags
169typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for g.LastItemData.StatusFlags
170typedef int ImGuiOldColumnFlags; // -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns()
171typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
172typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // Flags: for navigation requests
173typedef int ImGuiNextItemDataFlags; // -> enum ImGuiNextItemDataFlags_ // Flags: for SetNextItemXXX() functions
174typedef int ImGuiNextWindowDataFlags; // -> enum ImGuiNextWindowDataFlags_// Flags: for SetNextWindowXXX() functions
175typedef int ImGuiScrollFlags; // -> enum ImGuiScrollFlags_ // Flags: for ScrollToItem() and navigation requests
176typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for SeparatorEx()
177typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
178typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx()
179typedef int ImGuiTypingSelectFlags; // -> enum ImGuiTypingSelectFlags_ // Flags: for GetTypingSelectRequest()
180
181typedef void (*ImGuiErrorLogCallback)(void* user_data, const char* fmt, ...);
182
183//-----------------------------------------------------------------------------
184// [SECTION] Context pointer
185// See implementation of this variable in imgui.cpp for comments and details.
186//-----------------------------------------------------------------------------
187
188#ifndef GImGui
189extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
190#endif
191
192//-------------------------------------------------------------------------
193// [SECTION] STB libraries includes
194//-------------------------------------------------------------------------
195
196namespace ImStb
197{
198
199#undef STB_TEXTEDIT_STRING
200#undef STB_TEXTEDIT_CHARTYPE
201#define STB_TEXTEDIT_STRING ImGuiInputTextState
202#define STB_TEXTEDIT_CHARTYPE ImWchar
203#define STB_TEXTEDIT_GETWIDTH_NEWLINE (-1.0f)
204#define STB_TEXTEDIT_UNDOSTATECOUNT 99
205#define STB_TEXTEDIT_UNDOCHARCOUNT 999
206#include "imstb_textedit.h"
207
208} // namespace ImStb
209
210//-----------------------------------------------------------------------------
211// [SECTION] Macros
212//-----------------------------------------------------------------------------
213
214// Debug Printing Into TTY
215// (since IMGUI_VERSION_NUM >= 18729: IMGUI_DEBUG_LOG was reworked into IMGUI_DEBUG_PRINTF (and removed framecount from it). If you were using a #define IMGUI_DEBUG_LOG please rename)
216#ifndef IMGUI_DEBUG_PRINTF
217#ifndef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
218#define IMGUI_DEBUG_PRINTF(_FMT,...) printf(_FMT, __VA_ARGS__)
219#else
220#define IMGUI_DEBUG_PRINTF(_FMT,...) ((void)0)
221#endif
222#endif
223
224// Debug Logging for ShowDebugLogWindow(). This is designed for relatively rare events so please don't spam.
225#ifndef IMGUI_DISABLE_DEBUG_TOOLS
226#define IMGUI_DEBUG_LOG(...) ImGui::DebugLog(__VA_ARGS__)
227#else
228#define IMGUI_DEBUG_LOG(...) ((void)0)
229#endif
230#define IMGUI_DEBUG_LOG_ACTIVEID(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventActiveId) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
231#define IMGUI_DEBUG_LOG_FOCUS(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventFocus) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
232#define IMGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
233#define IMGUI_DEBUG_LOG_NAV(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventNav) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
234#define IMGUI_DEBUG_LOG_SELECTION(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection)IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
235#define IMGUI_DEBUG_LOG_CLIPPER(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
236#define IMGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
237
238// Static Asserts
239#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
240
241// "Paranoid" Debug Asserts are meant to only be enabled during specific debugging/work, otherwise would slow down the code too much.
242// We currently don't have many of those so the effect is currently negligible, but onward intent to add more aggressive ones in the code.
243//#define IMGUI_DEBUG_PARANOID
244#ifdef IMGUI_DEBUG_PARANOID
245#define IM_ASSERT_PARANOID(_EXPR) IM_ASSERT(_EXPR)
246#else
247#define IM_ASSERT_PARANOID(_EXPR)
248#endif
249
250// Error handling
251// Down the line in some frameworks/languages we would like to have a way to redirect those to the programmer and recover from more faults.
252#ifndef IM_ASSERT_USER_ERROR
253#define IM_ASSERT_USER_ERROR(_EXP,_MSG) IM_ASSERT((_EXP) && _MSG) // Recoverable User Error
254#endif
255
256// Misc Macros
257#define IM_PI 3.14159265358979323846f
258#ifdef _WIN32
259#define IM_NEWLINE "\r\n" // Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!)
260#else
261#define IM_NEWLINE "\n"
262#endif
263#ifndef IM_TABSIZE // Until we move this to runtime and/or add proper tab support, at least allow users to compile-time override
264#define IM_TABSIZE (4)
265#endif
266#define IM_MEMALIGN(_OFF,_ALIGN) (((_OFF) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1)) // Memory align e.g. IM_ALIGN(0,4)=0, IM_ALIGN(1,4)=4, IM_ALIGN(4,4)=4, IM_ALIGN(5,4)=8
267#define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose
268#define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255
269#define IM_TRUNC(_VAL) ((float)(int)(_VAL)) // ImTrunc() is not inlined in MSVC debug builds
270#define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) //
271#define IM_STRINGIFY_HELPER(_X) #_X
272#define IM_STRINGIFY(_X) IM_STRINGIFY_HELPER(_X) // Preprocessor idiom to stringify e.g. an integer.
273#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
274#define IM_FLOOR IM_TRUNC
275#endif
276
277// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
278#ifdef _MSC_VER
279#define IMGUI_CDECL __cdecl
280#else
281#define IMGUI_CDECL
282#endif
283
284// Warnings
285#if defined(_MSC_VER) && !defined(__clang__)
286#define IM_MSVC_WARNING_SUPPRESS(XXXX) __pragma(warning(suppress: XXXX))
287#else
288#define IM_MSVC_WARNING_SUPPRESS(XXXX)
289#endif
290
291// Debug Tools
292// Use 'Metrics/Debugger->Tools->Item Picker' to break into the call-stack of a specific item.
293// This will call IM_DEBUG_BREAK() which you may redefine yourself. See https://github.com/scottt/debugbreak for more reference.
294#ifndef IM_DEBUG_BREAK
295#if defined (_MSC_VER)
296#define IM_DEBUG_BREAK() __debugbreak()
297#elif defined(__clang__)
298#define IM_DEBUG_BREAK() __builtin_debugtrap()
299#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
300#define IM_DEBUG_BREAK() __asm__ volatile("int $0x03")
301#elif defined(__GNUC__) && defined(__thumb__)
302#define IM_DEBUG_BREAK() __asm__ volatile(".inst 0xde01")
303#elif defined(__GNUC__) && defined(__arm__) && !defined(__thumb__)
304#define IM_DEBUG_BREAK() __asm__ volatile(".inst 0xe7f001f0");
305#else
306#define IM_DEBUG_BREAK() IM_ASSERT(0) // It is expected that you define IM_DEBUG_BREAK() into something that will break nicely in a debugger!
307#endif
308#endif // #ifndef IM_DEBUG_BREAK
309
310// Format specifiers, printing 64-bit hasn't been decently standardized...
311// In a real application you should be using PRId64 and PRIu64 from <inttypes.h> (non-windows) and on Windows define them yourself.
312#if defined(_MSC_VER) && !defined(__clang__)
313#define IM_PRId64 "I64d"
314#define IM_PRIu64 "I64u"
315#define IM_PRIX64 "I64X"
316#else
317#define IM_PRId64 "lld"
318#define IM_PRIu64 "llu"
319#define IM_PRIX64 "llX"
320#endif
321
322//-----------------------------------------------------------------------------
323// [SECTION] Generic helpers
324// Note that the ImXXX helpers functions are lower-level than ImGui functions.
325// ImGui functions or the ImGui context are never called/used from other ImXXX functions.
326//-----------------------------------------------------------------------------
327// - Helpers: Hashing
328// - Helpers: Sorting
329// - Helpers: Bit manipulation
330// - Helpers: String
331// - Helpers: Formatting
332// - Helpers: UTF-8 <> wchar conversions
333// - Helpers: ImVec2/ImVec4 operators
334// - Helpers: Maths
335// - Helpers: Geometry
336// - Helper: ImVec1
337// - Helper: ImVec2ih
338// - Helper: ImRect
339// - Helper: ImBitArray
340// - Helper: ImBitVector
341// - Helper: ImSpan<>, ImSpanAllocator<>
342// - Helper: ImPool<>
343// - Helper: ImChunkStream<>
344// - Helper: ImGuiTextIndex
345//-----------------------------------------------------------------------------
346
347// Helpers: Hashing
348IMGUI_API ImGuiID ImHashData(const void* data, size_t data_size, ImGuiID seed = 0);
349IMGUI_API ImGuiID ImHashStr(const char* data, size_t data_size = 0, ImGuiID seed = 0);
350
351// Helpers: Sorting
352#ifndef ImQsort
353static inline void ImQsort(void* base, size_t count, size_t size_of_element, int(IMGUI_CDECL *compare_func)(void const*, void const*)) { if (count > 1) qsort(base: base, nmemb: count, size: size_of_element, compar: compare_func); }
354#endif
355
356// Helpers: Color Blending
357IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b);
358
359// Helpers: Bit manipulation
360static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
361static inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v & (v - 1)) == 0; }
362static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
363
364// Helpers: String
365IMGUI_API int ImStricmp(const char* str1, const char* str2); // Case insensitive compare.
366IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count); // Case insensitive compare to a certain count.
367IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count); // Copy to a certain count and always zero terminate (strncpy doesn't).
368IMGUI_API char* ImStrdup(const char* str); // Duplicate a string.
369IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str); // Copy in provided buffer, recreate buffer if needed.
370IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c); // Find first occurrence of 'c' in string range.
371IMGUI_API const char* ImStreolRange(const char* str, const char* str_end); // End end-of-line
372IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end); // Find a substring in a string range.
373IMGUI_API void ImStrTrimBlanks(char* str); // Remove leading and trailing blanks from a buffer.
374IMGUI_API const char* ImStrSkipBlank(const char* str); // Find first non-blank character.
375IMGUI_API int ImStrlenW(const ImWchar* str); // Computer string length (ImWchar string)
376IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line (ImWchar string)
377IM_MSVC_RUNTIME_CHECKS_OFF
378static inline char ImToUpper(char c) { return (c >= 'a' && c <= 'z') ? c &= ~32 : c; }
379static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
380static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
381IM_MSVC_RUNTIME_CHECKS_RESTORE
382
383// Helpers: Formatting
384IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
385IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
386IMGUI_API void ImFormatStringToTempBuffer(const char** out_buf, const char** out_buf_end, const char* fmt, ...) IM_FMTARGS(3);
387IMGUI_API void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end, const char* fmt, va_list args) IM_FMTLIST(3);
388IMGUI_API const char* ImParseFormatFindStart(const char* format);
389IMGUI_API const char* ImParseFormatFindEnd(const char* format);
390IMGUI_API const char* ImParseFormatTrimDecorations(const char* format, char* buf, size_t buf_size);
391IMGUI_API void ImParseFormatSanitizeForPrinting(const char* fmt_in, char* fmt_out, size_t fmt_out_size);
392IMGUI_API const char* ImParseFormatSanitizeForScanning(const char* fmt_in, char* fmt_out, size_t fmt_out_size);
393IMGUI_API int ImParseFormatPrecision(const char* format, int default_value);
394
395// Helpers: UTF-8 <> wchar conversions
396IMGUI_API const char* ImTextCharToUtf8(char out_buf[5], unsigned int c); // return out_buf
397IMGUI_API int ImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
398IMGUI_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
399IMGUI_API int ImTextStrFromUtf8(ImWchar* out_buf, int out_buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
400IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
401IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
402IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
403IMGUI_API const char* ImTextFindPreviousUtf8Codepoint(const char* in_text_start, const char* in_text_curr); // return previous UTF-8 code-point.
404
405// Helpers: File System
406#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
407#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
408typedef void* ImFileHandle;
409static inline ImFileHandle ImFileOpen(const char*, const char*) { return NULL; }
410static inline bool ImFileClose(ImFileHandle) { return false; }
411static inline ImU64 ImFileGetSize(ImFileHandle) { return (ImU64)-1; }
412static inline ImU64 ImFileRead(void*, ImU64, ImU64, ImFileHandle) { return 0; }
413static inline ImU64 ImFileWrite(const void*, ImU64, ImU64, ImFileHandle) { return 0; }
414#endif
415#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
416typedef FILE* ImFileHandle;
417IMGUI_API ImFileHandle ImFileOpen(const char* filename, const char* mode);
418IMGUI_API bool ImFileClose(ImFileHandle file);
419IMGUI_API ImU64 ImFileGetSize(ImFileHandle file);
420IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
421IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file);
422#else
423#define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions
424#endif
425IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size = NULL, int padding_bytes = 0);
426
427// Helpers: Maths
428IM_MSVC_RUNTIME_CHECKS_OFF
429// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
430#ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
431#define ImFabs(X) fabsf(X)
432#define ImSqrt(X) sqrtf(X)
433#define ImFmod(X, Y) fmodf((X), (Y))
434#define ImCos(X) cosf(X)
435#define ImSin(X) sinf(X)
436#define ImAcos(X) acosf(X)
437#define ImAtan2(Y, X) atan2f((Y), (X))
438#define ImAtof(STR) atof(STR)
439#define ImCeil(X) ceilf(X)
440static inline float ImPow(float x, float y) { return powf(x: x, y: y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
441static inline double ImPow(double x, double y) { return pow(x: x, y: y); }
442static inline float ImLog(float x) { return logf(x: x); } // DragBehaviorT/SliderBehaviorT uses ImLog with either float/double and need the precision
443static inline double ImLog(double x) { return log(x: x); }
444static inline int ImAbs(int x) { return x < 0 ? -x : x; }
445static inline float ImAbs(float x) { return fabsf(x: x); }
446static inline double ImAbs(double x) { return fabs(x: x); }
447static inline float ImSign(float x) { return (x < 0.0f) ? -1.0f : (x > 0.0f) ? 1.0f : 0.0f; } // Sign operator - returns -1, 0 or 1 based on sign of argument
448static inline double ImSign(double x) { return (x < 0.0) ? -1.0 : (x > 0.0) ? 1.0 : 0.0; }
449#ifdef IMGUI_ENABLE_SSE
450static inline float ImRsqrt(float x) { return _mm_cvtss_f32(a: _mm_rsqrt_ss(a: _mm_set_ss(w: x))); }
451#else
452static inline float ImRsqrt(float x) { return 1.0f / sqrtf(x); }
453#endif
454static inline double ImRsqrt(double x) { return 1.0 / sqrt(x: x); }
455#endif
456// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double
457// (Exceptionally using templates here but we could also redefine them for those types)
458template<typename T> static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
459template<typename T> static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
460template<typename T> static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
461template<typename T> static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); }
462template<typename T> static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
463template<typename T> static inline T ImAddClampOverflow(T a, T b, T mn, T mx) { if (b < 0 && (a < mn - b)) return mn; if (b > 0 && (a > mx - b)) return mx; return a + b; }
464template<typename T> static inline T ImSubClampOverflow(T a, T b, T mn, T mx) { if (b > 0 && (a < mn + b)) return mn; if (b < 0 && (a > mx + b)) return mx; return a - b; }
465// - Misc maths helpers
466static 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); }
467static 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); }
468static 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); }
469static 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); }
470static 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); }
471static 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); }
472static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
473static inline float ImLengthSqr(const ImVec2& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y); }
474static inline float ImLengthSqr(const ImVec4& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); }
475static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return ImRsqrt(x: d); return fail_value; }
476static inline float ImTrunc(float f) { return (float)(int)(f); }
477static inline ImVec2 ImTrunc(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); }
478static inline float ImFloor(float f) { return (float)((f >= 0 || (float)(int)f == f) ? (int)f : (int)f - 1); } // Decent replacement for floorf()
479static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2(ImFloor(f: v.x), ImFloor(f: v.y)); }
480static inline int ImModPositive(int a, int b) { return (a + b) % b; }
481static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
482static 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); }
483static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(lhs: current + speed, rhs: target); if (current > target) return ImMax(lhs: current - speed, rhs: target); return current; }
484static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
485static inline bool ImIsFloatAboveGuaranteedIntegerPrecision(float f) { return f <= -16777216 || f >= 16777216; }
486static inline float ImExponentialMovingAverage(float avg, float sample, int n) { avg -= avg / n; avg += sample / n; return avg; }
487IM_MSVC_RUNTIME_CHECKS_RESTORE
488
489// Helpers: Geometry
490IMGUI_API ImVec2 ImBezierCubicCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t);
491IMGUI_API ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments); // For curves with explicit number of segments
492IMGUI_API ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol);// For auto-tessellated curves you can use tess_tol = style.CurveTessellationTol
493IMGUI_API ImVec2 ImBezierQuadraticCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, float t);
494IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
495IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
496IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
497IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
498inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; }
499
500// Helper: ImVec1 (1D vector)
501// (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
502IM_MSVC_RUNTIME_CHECKS_OFF
503struct ImVec1
504{
505 float x;
506 constexpr ImVec1() : x(0.0f) { }
507 constexpr ImVec1(float _x) : x(_x) { }
508};
509
510// Helper: ImVec2ih (2D vector, half-size integer, for long-term packed storage)
511struct ImVec2ih
512{
513 short x, y;
514 constexpr ImVec2ih() : x(0), y(0) {}
515 constexpr ImVec2ih(short _x, short _y) : x(_x), y(_y) {}
516 constexpr explicit ImVec2ih(const ImVec2& rhs) : x((short)rhs.x), y((short)rhs.y) {}
517};
518
519// Helper: ImRect (2D axis aligned bounding-box)
520// NB: we can't rely on ImVec2 math operators being available here!
521struct IMGUI_API ImRect
522{
523 ImVec2 Min; // Upper-left
524 ImVec2 Max; // Lower-right
525
526 constexpr ImRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {}
527 constexpr ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {}
528 constexpr ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
529 constexpr ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {}
530
531 ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
532 ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
533 float GetWidth() const { return Max.x - Min.x; }
534 float GetHeight() const { return Max.y - Min.y; }
535 float GetArea() const { return (Max.x - Min.x) * (Max.y - Min.y); }
536 ImVec2 GetTL() const { return Min; } // Top-left
537 ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right
538 ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left
539 ImVec2 GetBR() const { return Max; } // Bottom-right
540 bool Contains(const ImVec2& p) const { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; }
541 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; }
542 bool ContainsWithPad(const ImVec2& p, const ImVec2& pad) const { return p.x >= Min.x - pad.x && p.y >= Min.y - pad.y && p.x < Max.x + pad.x && p.y < Max.y + pad.y; }
543 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; }
544 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; }
545 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; }
546 void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
547 void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
548 void Translate(const ImVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; }
549 void TranslateX(float dx) { Min.x += dx; Max.x += dx; }
550 void TranslateY(float dy) { Min.y += dy; Max.y += dy; }
551 void ClipWith(const ImRect& r) { Min = ImMax(lhs: Min, rhs: r.Min); Max = ImMin(lhs: Max, rhs: r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
552 void ClipWithFull(const ImRect& r) { Min = ImClamp(v: Min, mn: r.Min, mx: r.Max); Max = ImClamp(v: Max, mn: r.Min, mx: r.Max); } // Full version, ensure both points are fully clipped.
553 void Floor() { Min.x = IM_TRUNC(Min.x); Min.y = IM_TRUNC(Min.y); Max.x = IM_TRUNC(Max.x); Max.y = IM_TRUNC(Max.y); }
554 bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; }
555 ImVec4 ToVec4() const { return ImVec4(Min.x, Min.y, Max.x, Max.y); }
556};
557
558// Helper: ImBitArray
559#define IM_BITARRAY_TESTBIT(_ARRAY, _N) ((_ARRAY[(_N) >> 5] & ((ImU32)1 << ((_N) & 31))) != 0) // Macro version of ImBitArrayTestBit(): ensure args have side-effect or are costly!
560#define IM_BITARRAY_CLEARBIT(_ARRAY, _N) ((_ARRAY[(_N) >> 5] &= ~((ImU32)1 << ((_N) & 31)))) // Macro version of ImBitArrayClearBit(): ensure args have side-effect or are costly!
561inline size_t ImBitArrayGetStorageSizeInBytes(int bitcount) { return (size_t)((bitcount + 31) >> 5) << 2; }
562inline void ImBitArrayClearAllBits(ImU32* arr, int bitcount){ memset(s: arr, c: 0, n: ImBitArrayGetStorageSizeInBytes(bitcount)); }
563inline bool ImBitArrayTestBit(const ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); return (arr[n >> 5] & mask) != 0; }
564inline void ImBitArrayClearBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] &= ~mask; }
565inline void ImBitArraySetBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] |= mask; }
566inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2) // Works on range [n..n2)
567{
568 n2--;
569 while (n <= n2)
570 {
571 int a_mod = (n & 31);
572 int b_mod = (n2 > (n | 31) ? 31 : (n2 & 31)) + 1;
573 ImU32 mask = (ImU32)(((ImU64)1 << b_mod) - 1) & ~(ImU32)(((ImU64)1 << a_mod) - 1);
574 arr[n >> 5] |= mask;
575 n = (n + 32) & ~31;
576 }
577}
578
579typedef ImU32* ImBitArrayPtr; // Name for use in structs
580
581// Helper: ImBitArray class (wrapper over ImBitArray functions)
582// Store 1-bit per value.
583template<int BITCOUNT, int OFFSET = 0>
584struct ImBitArray
585{
586 ImU32 Storage[(BITCOUNT + 31) >> 5];
587 ImBitArray() { ClearAllBits(); }
588 void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
589 void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
590 bool TestBit(int n) const { n += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT); return IM_BITARRAY_TESTBIT(Storage, n); }
591 void SetBit(int n) { n += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT); ImBitArraySetBit(Storage, n); }
592 void ClearBit(int n) { n += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT); ImBitArrayClearBit(Storage, n); }
593 void SetBitRange(int n, int n2) { n += OFFSET; n2 += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT && n2 > n && n2 <= BITCOUNT); ImBitArraySetBitRange(Storage, n, n2); } // Works on range [n..n2)
594 bool operator[](int n) const { n += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT); return IM_BITARRAY_TESTBIT(Storage, n); }
595};
596
597// Helper: ImBitVector
598// Store 1-bit per value.
599struct IMGUI_API ImBitVector
600{
601 ImVector<ImU32> Storage;
602 void Create(int sz) { Storage.resize(new_size: (sz + 31) >> 5); memset(s: Storage.Data, c: 0, n: (size_t)Storage.Size * sizeof(Storage.Data[0])); }
603 void Clear() { Storage.clear(); }
604 bool TestBit(int n) const { IM_ASSERT(n < (Storage.Size << 5)); return IM_BITARRAY_TESTBIT(Storage.Data, n); }
605 void SetBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArraySetBit(arr: Storage.Data, n); }
606 void ClearBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArrayClearBit(arr: Storage.Data, n); }
607};
608IM_MSVC_RUNTIME_CHECKS_RESTORE
609
610// Helper: ImSpan<>
611// Pointing to a span of data we don't own.
612template<typename T>
613struct ImSpan
614{
615 T* Data;
616 T* DataEnd;
617
618 // Constructors, destructor
619 inline ImSpan() { Data = DataEnd = NULL; }
620 inline ImSpan(T* data, int size) { Data = data; DataEnd = data + size; }
621 inline ImSpan(T* data, T* data_end) { Data = data; DataEnd = data_end; }
622
623 inline void set(T* data, int size) { Data = data; DataEnd = data + size; }
624 inline void set(T* data, T* data_end) { Data = data; DataEnd = data_end; }
625 inline int size() const { return (int)(ptrdiff_t)(DataEnd - Data); }
626 inline int size_in_bytes() const { return (int)(ptrdiff_t)(DataEnd - Data) * (int)sizeof(T); }
627 inline T& operator[](int i) { T* p = Data + i; IM_ASSERT(p >= Data && p < DataEnd); return *p; }
628 inline const T& operator[](int i) const { const T* p = Data + i; IM_ASSERT(p >= Data && p < DataEnd); return *p; }
629
630 inline T* begin() { return Data; }
631 inline const T* begin() const { return Data; }
632 inline T* end() { return DataEnd; }
633 inline const T* end() const { return DataEnd; }
634
635 // Utilities
636 inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it < DataEnd); const ptrdiff_t off = it - Data; return (int)off; }
637};
638
639// Helper: ImSpanAllocator<>
640// Facilitate storing multiple chunks into a single large block (the "arena")
641// - Usage: call Reserve() N times, allocate GetArenaSizeInBytes() worth, pass it to SetArenaBasePtr(), call GetSpan() N times to retrieve the aligned ranges.
642template<int CHUNKS>
643struct ImSpanAllocator
644{
645 char* BasePtr;
646 int CurrOff;
647 int CurrIdx;
648 int Offsets[CHUNKS];
649 int Sizes[CHUNKS];
650
651 ImSpanAllocator() { memset(this, 0, sizeof(*this)); }
652 inline void Reserve(int n, size_t sz, int a=4) { IM_ASSERT(n == CurrIdx && n < CHUNKS); CurrOff = IM_MEMALIGN(CurrOff, a); Offsets[n] = CurrOff; Sizes[n] = (int)sz; CurrIdx++; CurrOff += (int)sz; }
653 inline int GetArenaSizeInBytes() { return CurrOff; }
654 inline void SetArenaBasePtr(void* base_ptr) { BasePtr = (char*)base_ptr; }
655 inline void* GetSpanPtrBegin(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrIdx == CHUNKS); return (void*)(BasePtr + Offsets[n]); }
656 inline void* GetSpanPtrEnd(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrIdx == CHUNKS); return (void*)(BasePtr + Offsets[n] + Sizes[n]); }
657 template<typename T>
658 inline void GetSpan(int n, ImSpan<T>* span) { span->set((T*)GetSpanPtrBegin(n), (T*)GetSpanPtrEnd(n)); }
659};
660
661// Helper: ImPool<>
662// Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer,
663// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
664typedef int ImPoolIdx;
665template<typename T>
666struct ImPool
667{
668 ImVector<T> Buf; // Contiguous data
669 ImGuiStorage Map; // ID->Index
670 ImPoolIdx FreeIdx; // Next free idx to use
671 ImPoolIdx AliveCount; // Number of active/alive items (for display purpose)
672
673 ImPool() { FreeIdx = AliveCount = 0; }
674 ~ImPool() { Clear(); }
675 T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, default_val: -1); return (idx != -1) ? &Buf[idx] : NULL; }
676 T* GetByIndex(ImPoolIdx n) { return &Buf[n]; }
677 ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); }
678 T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, default_val: -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); }
679 bool Contains(const T* p) const { return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
680 void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = AliveCount = 0; }
681 T* Add() { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); AliveCount++; return &Buf[idx]; }
682 void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
683 void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, val: -1); AliveCount--; }
684 void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(new_capacity: capacity); }
685
686 // To iterate a ImPool: for (int n = 0; n < pool.GetMapSize(); n++) if (T* t = pool.TryGetMapData(n)) { ... }
687 // Can be avoided if you know .Remove() has never been called on the pool, or AliveCount == GetMapSize()
688 int GetAliveCount() const { return AliveCount; } // Number of active/alive items in the pool (for display purpose)
689 int GetBufSize() const { return Buf.Size; }
690 int GetMapSize() const { return Map.Data.Size; } // It is the map we need iterate to find valid items, since we don't have "alive" storage anywhere
691 T* TryGetMapData(ImPoolIdx n) { int idx = Map.Data[n].val_i; if (idx == -1) return NULL; return GetByIndex(n: idx); }
692#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
693 int GetSize() { return GetMapSize(); } // For ImPlot: should use GetMapSize() from (IMGUI_VERSION_NUM >= 18304)
694#endif
695};
696
697// Helper: ImChunkStream<>
698// Build and iterate a contiguous stream of variable-sized structures.
699// This is used by Settings to store persistent data while reducing allocation count.
700// We store the chunk size first, and align the final size on 4 bytes boundaries.
701// The tedious/zealous amount of casting is to avoid -Wcast-align warnings.
702template<typename T>
703struct ImChunkStream
704{
705 ImVector<char> Buf;
706
707 void clear() { Buf.clear(); }
708 bool empty() const { return Buf.Size == 0; }
709 int size() const { return Buf.Size; }
710 T* alloc_chunk(size_t sz) { size_t HDR_SZ = 4; sz = IM_MEMALIGN(HDR_SZ + sz, 4u); int off = Buf.Size; Buf.resize(new_size: off + (int)sz); ((int*)(void*)(Buf.Data + off))[0] = (int)sz; return (T*)(void*)(Buf.Data + off + (int)HDR_SZ); }
711 T* begin() { size_t HDR_SZ = 4; if (!Buf.Data) return NULL; return (T*)(void*)(Buf.Data + HDR_SZ); }
712 T* next_chunk(T* p) { size_t HDR_SZ = 4; IM_ASSERT(p >= begin() && p < end()); p = (T*)(void*)((char*)(void*)p + chunk_size(p)); if (p == (T*)(void*)((char*)end() + HDR_SZ)) return (T*)0; IM_ASSERT(p < end()); return p; }
713 int chunk_size(const T* p) { return ((const int*)p)[-1]; }
714 T* end() { return (T*)(void*)(Buf.Data + Buf.Size); }
715 int offset_from_ptr(const T* p) { IM_ASSERT(p >= begin() && p < end()); const ptrdiff_t off = (const char*)p - Buf.Data; return (int)off; }
716 T* ptr_from_offset(int off) { IM_ASSERT(off >= 4 && off < Buf.Size); return (T*)(void*)(Buf.Data + off); }
717 void swap(ImChunkStream<T>& rhs) { rhs.Buf.swap(Buf); }
718};
719
720// Helper: ImGuiTextIndex<>
721// Maintain a line index for a text buffer. This is a strong candidate to be moved into the public API.
722struct ImGuiTextIndex
723{
724 ImVector<int> LineOffsets;
725 int EndOffset = 0; // Because we don't own text buffer we need to maintain EndOffset (may bake in LineOffsets?)
726
727 void clear() { LineOffsets.clear(); EndOffset = 0; }
728 int size() { return LineOffsets.Size; }
729 const char* get_line_begin(const char* base, int n) { return base + LineOffsets[n]; }
730 const char* get_line_end(const char* base, int n) { return base + (n + 1 < LineOffsets.Size ? (LineOffsets[n + 1] - 1) : EndOffset); }
731 void append(const char* base, int old_size, int new_size);
732};
733
734//-----------------------------------------------------------------------------
735// [SECTION] ImDrawList support
736//-----------------------------------------------------------------------------
737
738// ImDrawList: Helper function to calculate a circle's segment count given its radius and a "maximum error" value.
739// Estimation of number of circle segment based on error is derived using method described in https://stackoverflow.com/a/2244088/15194693
740// Number of segments (N) is calculated using equation:
741// N = ceil ( pi / acos(1 - error / r) ) where r > 0, error <= r
742// Our equation is significantly simpler that one in the post thanks for choosing segment that is
743// perpendicular to X axis. Follow steps in the article from this starting condition and you will
744// will get this result.
745//
746// Rendering circles with an odd number of segments, while mathematically correct will produce
747// asymmetrical results on the raster grid. Therefore we're rounding N to next even number (7->8, 8->8, 9->10 etc.)
748#define IM_ROUNDUP_TO_EVEN(_V) ((((_V) + 1) / 2) * 2)
749#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN 4
750#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX 512
751#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR) ImClamp(IM_ROUNDUP_TO_EVEN((int)ImCeil(IM_PI / ImAcos(1 - ImMin((_MAXERROR), (_RAD)) / (_RAD)))), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX)
752
753// Raw equation from IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC rewritten for 'r' and 'error'.
754#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(_N,_MAXERROR) ((_MAXERROR) / (1 - ImCos(IM_PI / ImMax((float)(_N), IM_PI))))
755#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_ERROR(_N,_RAD) ((1 - ImCos(IM_PI / ImMax((float)(_N), IM_PI))) / (_RAD))
756
757// ImDrawList: Lookup table size for adaptive arc drawing, cover full circle.
758#ifndef IM_DRAWLIST_ARCFAST_TABLE_SIZE
759#define IM_DRAWLIST_ARCFAST_TABLE_SIZE 48 // Number of samples in lookup table.
760#endif
761#define IM_DRAWLIST_ARCFAST_SAMPLE_MAX IM_DRAWLIST_ARCFAST_TABLE_SIZE // Sample index _PathArcToFastEx() for 360 angle.
762
763// Data shared between all ImDrawList instances
764// You may want to create your own instance of this if you want to use ImDrawList completely without ImGui. In that case, watch out for future changes to this structure.
765struct IMGUI_API ImDrawListSharedData
766{
767 ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas
768 ImFont* Font; // Current/default font (optional, for simplified AddText overload)
769 float FontSize; // Current/default font size (optional, for simplified AddText overload)
770 float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo()
771 float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc
772 ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen()
773 ImDrawListFlags InitialFlags; // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards)
774
775 // [Internal] Temp write buffer
776 ImVector<ImVec2> TempBuffer;
777
778 // [Internal] Lookup tables
779 ImVec2 ArcFastVtx[IM_DRAWLIST_ARCFAST_TABLE_SIZE]; // Sample points on the quarter of the circle.
780 float ArcFastRadiusCutoff; // Cutoff radius after which arc drawing will fallback to slower PathArcTo()
781 ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius before we calculate it dynamically (to avoid calculation overhead)
782 const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas
783
784 ImDrawListSharedData();
785 void SetCircleTessellationMaxError(float max_error);
786};
787
788struct ImDrawDataBuilder
789{
790 ImVector<ImDrawList*>* Layers[2]; // Pointers to global layers for: regular, tooltip. LayersP[0] is owned by DrawData.
791 ImVector<ImDrawList*> LayerData1;
792
793 ImDrawDataBuilder() { memset(s: this, c: 0, n: sizeof(*this)); }
794};
795
796//-----------------------------------------------------------------------------
797// [SECTION] Widgets support: flags, enums, data structures
798//-----------------------------------------------------------------------------
799
800// Flags used by upcoming items
801// - input: PushItemFlag() manipulates g.CurrentItemFlags, ItemAdd() calls may add extra flags.
802// - output: stored in g.LastItemData.InFlags
803// Current window shared by all windows.
804// This is going to be exposed in imgui.h when stabilized enough.
805enum ImGuiItemFlags_
806{
807 // Controlled by user
808 ImGuiItemFlags_None = 0,
809 ImGuiItemFlags_NoTabStop = 1 << 0, // false // Disable keyboard tabbing. This is a "lighter" version of ImGuiItemFlags_NoNav.
810 ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
811 ImGuiItemFlags_Disabled = 1 << 2, // false // Disable interactions but doesn't affect visuals. See BeginDisabled()/EndDisabled(). See github.com/ocornut/imgui/issues/211
812 ImGuiItemFlags_NoNav = 1 << 3, // false // Disable any form of focusing (keyboard/gamepad directional navigation and SetKeyboardFocusHere() calls)
813 ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false // Disable item being a candidate for default focus (e.g. used by title bar items)
814 ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // Disable MenuItem/Selectable() automatically closing their popup window
815 ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
816 ImGuiItemFlags_ReadOnly = 1 << 7, // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
817 ImGuiItemFlags_NoWindowHoverableCheck = 1 << 8, // false // Disable hoverable check in ItemHoverable()
818 ImGuiItemFlags_AllowOverlap = 1 << 9, // false // Allow being overlapped by another widget. Not-hovered to Hovered transition deferred by a frame.
819
820 // Controlled by widget code
821 ImGuiItemFlags_Inputable = 1 << 10, // false // [WIP] Auto-activate input mode when tab focused. Currently only used and supported by a few items before it becomes a generic feature.
822 ImGuiItemFlags_HasSelectionUserData = 1 << 11, // false // Set by SetNextItemSelectionUserData()
823};
824
825// Status flags for an already submitted item
826// - output: stored in g.LastItemData.StatusFlags
827enum ImGuiItemStatusFlags_
828{
829 ImGuiItemStatusFlags_None = 0,
830 ImGuiItemStatusFlags_HoveredRect = 1 << 0, // Mouse position is within item rectangle (does NOT mean that the window is in correct z-order and can be hovered!, this is only one part of the most-common IsItemHovered test)
831 ImGuiItemStatusFlags_HasDisplayRect = 1 << 1, // g.LastItemData.DisplayRect is valid
832 ImGuiItemStatusFlags_Edited = 1 << 2, // Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
833 ImGuiItemStatusFlags_ToggledSelection = 1 << 3, // Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected", only state changes, in order to easily handle clipping with less issues.
834 ImGuiItemStatusFlags_ToggledOpen = 1 << 4, // Set when TreeNode() reports toggling their open state.
835 ImGuiItemStatusFlags_HasDeactivated = 1 << 5, // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag.
836 ImGuiItemStatusFlags_Deactivated = 1 << 6, // Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
837 ImGuiItemStatusFlags_HoveredWindow = 1 << 7, // Override the HoveredWindow test to allow cross-window hover testing.
838 ImGuiItemStatusFlags_FocusedByTabbing = 1 << 8, // Set when the Focusable item just got focused by Tabbing (FIXME: to be removed soon)
839 ImGuiItemStatusFlags_Visible = 1 << 9, // [WIP] Set when item is overlapping the current clipping rectangle (Used internally. Please don't use yet: API/system will change as we refactor Itemadd()).
840
841 // Additional status + semantic for ImGuiTestEngine
842#ifdef IMGUI_ENABLE_TEST_ENGINE
843 ImGuiItemStatusFlags_Openable = 1 << 20, // Item is an openable (e.g. TreeNode)
844 ImGuiItemStatusFlags_Opened = 1 << 21, // Opened status
845 ImGuiItemStatusFlags_Checkable = 1 << 22, // Item is a checkable (e.g. CheckBox, MenuItem)
846 ImGuiItemStatusFlags_Checked = 1 << 23, // Checked status
847 ImGuiItemStatusFlags_Inputable = 1 << 24, // Item is a text-inputable (e.g. InputText, SliderXXX, DragXXX)
848#endif
849};
850
851// Extend ImGuiHoveredFlags_
852enum ImGuiHoveredFlagsPrivate_
853{
854 ImGuiHoveredFlags_DelayMask_ = ImGuiHoveredFlags_DelayNone | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay,
855 ImGuiHoveredFlags_AllowedMaskForIsWindowHovered = ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary,
856 ImGuiHoveredFlags_AllowedMaskForIsItemHovered = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled | ImGuiHoveredFlags_NoNavOverride | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayMask_,
857};
858
859// Extend ImGuiInputTextFlags_
860enum ImGuiInputTextFlagsPrivate_
861{
862 // [Internal]
863 ImGuiInputTextFlags_Multiline = 1 << 26, // For internal use by InputTextMultiline()
864 ImGuiInputTextFlags_NoMarkEdited = 1 << 27, // For internal use by functions using InputText() before reformatting data
865 ImGuiInputTextFlags_MergedItem = 1 << 28, // For internal use by TempInputText(), will skip calling ItemAdd(). Require bounding-box to strictly match.
866};
867
868// Extend ImGuiButtonFlags_
869enum ImGuiButtonFlagsPrivate_
870{
871 ImGuiButtonFlags_PressedOnClick = 1 << 4, // return true on click (mouse down event)
872 ImGuiButtonFlags_PressedOnClickRelease = 1 << 5, // [Default] return true on click + release on same item <-- this is what the majority of Button are using
873 ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 6, // return true on click + release even if the release event is not done while hovering the item
874 ImGuiButtonFlags_PressedOnRelease = 1 << 7, // return true on release (default requires click+release)
875 ImGuiButtonFlags_PressedOnDoubleClick = 1 << 8, // return true on double-click (default requires click+release)
876 ImGuiButtonFlags_PressedOnDragDropHold = 1 << 9, // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
877 ImGuiButtonFlags_Repeat = 1 << 10, // hold to repeat
878 ImGuiButtonFlags_FlattenChildren = 1 << 11, // allow interactions even if a child window is overlapping
879 ImGuiButtonFlags_AllowOverlap = 1 << 12, // require previous frame HoveredId to either match id or be null before being usable.
880 ImGuiButtonFlags_DontClosePopups = 1 << 13, // disable automatically closing parent popup on press // [UNUSED]
881 //ImGuiButtonFlags_Disabled = 1 << 14, // disable interactions -> use BeginDisabled() or ImGuiItemFlags_Disabled
882 ImGuiButtonFlags_AlignTextBaseLine = 1 << 15, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
883 ImGuiButtonFlags_NoKeyModifiers = 1 << 16, // disable mouse interaction if a key modifier is held
884 ImGuiButtonFlags_NoHoldingActiveId = 1 << 17, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
885 ImGuiButtonFlags_NoNavFocus = 1 << 18, // don't override navigation focus when activated (FIXME: this is essentially used everytime an item uses ImGuiItemFlags_NoNav, but because legacy specs don't requires LastItemData to be set ButtonBehavior(), we can't poll g.LastItemData.InFlags)
886 ImGuiButtonFlags_NoHoveredOnFocus = 1 << 19, // don't report as hovered when nav focus is on this item
887 ImGuiButtonFlags_NoSetKeyOwner = 1 << 20, // don't set key/input owner on the initial click (note: mouse buttons are keys! often, the key in question will be ImGuiKey_MouseLeft!)
888 ImGuiButtonFlags_NoTestKeyOwner = 1 << 21, // don't test key/input owner when polling the key (note: mouse buttons are keys! often, the key in question will be ImGuiKey_MouseLeft!)
889 ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold,
890 ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease,
891};
892
893// Extend ImGuiComboFlags_
894enum ImGuiComboFlagsPrivate_
895{
896 ImGuiComboFlags_CustomPreview = 1 << 20, // enable BeginComboPreview()
897};
898
899// Extend ImGuiSliderFlags_
900enum ImGuiSliderFlagsPrivate_
901{
902 ImGuiSliderFlags_Vertical = 1 << 20, // Should this slider be orientated vertically?
903 ImGuiSliderFlags_ReadOnly = 1 << 21, // Consider using g.NextItemData.ItemFlags |= ImGuiItemFlags_ReadOnly instead.
904};
905
906// Extend ImGuiSelectableFlags_
907enum ImGuiSelectableFlagsPrivate_
908{
909 // NB: need to be in sync with last value of ImGuiSelectableFlags_
910 ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
911 ImGuiSelectableFlags_SelectOnNav = 1 << 21, // (WIP) Auto-select when moved into. This is not exposed in public API as to handle multi-select and modifiers we will need user to explicitly control focus scope. May be replaced with a BeginSelection() API.
912 ImGuiSelectableFlags_SelectOnClick = 1 << 22, // Override button behavior to react on Click (default is Click+Release)
913 ImGuiSelectableFlags_SelectOnRelease = 1 << 23, // Override button behavior to react on Release (default is Click+Release)
914 ImGuiSelectableFlags_SpanAvailWidth = 1 << 24, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
915 ImGuiSelectableFlags_SetNavIdOnHover = 1 << 25, // Set Nav/Focus ID on mouse hover (used by MenuItem)
916 ImGuiSelectableFlags_NoPadWithHalfSpacing = 1 << 26, // Disable padding each side with ItemSpacing * 0.5f
917 ImGuiSelectableFlags_NoSetKeyOwner = 1 << 27, // Don't set key/input owner on the initial click (note: mouse buttons are keys! often, the key in question will be ImGuiKey_MouseLeft!)
918};
919
920// Extend ImGuiTreeNodeFlags_
921enum ImGuiTreeNodeFlagsPrivate_
922{
923 ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20,
924 ImGuiTreeNodeFlags_UpsideDownArrow = 1 << 21,// (FIXME-WIP) Turn Down arrow into an Up arrow, but reversed trees (#6517)
925};
926
927enum ImGuiSeparatorFlags_
928{
929 ImGuiSeparatorFlags_None = 0,
930 ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
931 ImGuiSeparatorFlags_Vertical = 1 << 1,
932 ImGuiSeparatorFlags_SpanAllColumns = 1 << 2, // Make separator cover all columns of a legacy Columns() set.
933};
934
935// Flags for FocusWindow(). This is not called ImGuiFocusFlags to avoid confusion with public-facing ImGuiFocusedFlags.
936// FIXME: Once we finishing replacing more uses of GetTopMostPopupModal()+IsWindowWithinBeginStackOf()
937// and FindBlockingModal() with this, we may want to change the flag to be opt-out instead of opt-in.
938enum ImGuiFocusRequestFlags_
939{
940 ImGuiFocusRequestFlags_None = 0,
941 ImGuiFocusRequestFlags_RestoreFocusedChild = 1 << 0, // Find last focused child (if any) and focus it instead.
942 ImGuiFocusRequestFlags_UnlessBelowModal = 1 << 1, // Do not set focus if the window is below a modal.
943};
944
945enum ImGuiTextFlags_
946{
947 ImGuiTextFlags_None = 0,
948 ImGuiTextFlags_NoWidthForLargeClippedText = 1 << 0,
949};
950
951enum ImGuiTooltipFlags_
952{
953 ImGuiTooltipFlags_None = 0,
954 ImGuiTooltipFlags_OverridePrevious = 1 << 1, // Clear/ignore previously submitted tooltip (defaults to append)
955};
956
957// FIXME: this is in development, not exposed/functional as a generic feature yet.
958// Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2
959enum ImGuiLayoutType_
960{
961 ImGuiLayoutType_Horizontal = 0,
962 ImGuiLayoutType_Vertical = 1
963};
964
965enum ImGuiLogType
966{
967 ImGuiLogType_None = 0,
968 ImGuiLogType_TTY,
969 ImGuiLogType_File,
970 ImGuiLogType_Buffer,
971 ImGuiLogType_Clipboard,
972};
973
974// X/Y enums are fixed to 0/1 so they may be used to index ImVec2
975enum ImGuiAxis
976{
977 ImGuiAxis_None = -1,
978 ImGuiAxis_X = 0,
979 ImGuiAxis_Y = 1
980};
981
982enum ImGuiPlotType
983{
984 ImGuiPlotType_Lines,
985 ImGuiPlotType_Histogram,
986};
987
988enum ImGuiPopupPositionPolicy
989{
990 ImGuiPopupPositionPolicy_Default,
991 ImGuiPopupPositionPolicy_ComboBox,
992 ImGuiPopupPositionPolicy_Tooltip,
993};
994
995struct ImGuiDataVarInfo
996{
997 ImGuiDataType Type;
998 ImU32 Count; // 1+
999 ImU32 Offset; // Offset in parent structure
1000 void* GetVarPtr(void* parent) const { return (void*)((unsigned char*)parent + Offset); }
1001};
1002
1003struct ImGuiDataTypeTempStorage
1004{
1005 ImU8 Data[8]; // Can fit any data up to ImGuiDataType_COUNT
1006};
1007
1008// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo().
1009struct ImGuiDataTypeInfo
1010{
1011 size_t Size; // Size in bytes
1012 const char* Name; // Short descriptive name for the type, for debugging
1013 const char* PrintFmt; // Default printf format for the type
1014 const char* ScanFmt; // Default scanf format for the type
1015};
1016
1017// Extend ImGuiDataType_
1018enum ImGuiDataTypePrivate_
1019{
1020 ImGuiDataType_String = ImGuiDataType_COUNT + 1,
1021 ImGuiDataType_Pointer,
1022 ImGuiDataType_ID,
1023};
1024
1025// Stacked color modifier, backup of modified data so we can restore it
1026struct ImGuiColorMod
1027{
1028 ImGuiCol Col;
1029 ImVec4 BackupValue;
1030};
1031
1032// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
1033struct ImGuiStyleMod
1034{
1035 ImGuiStyleVar VarIdx;
1036 union { int BackupInt[2]; float BackupFloat[2]; };
1037 ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; }
1038 ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; }
1039 ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
1040};
1041
1042// Storage data for BeginComboPreview()/EndComboPreview()
1043struct IMGUI_API ImGuiComboPreviewData
1044{
1045 ImRect PreviewRect;
1046 ImVec2 BackupCursorPos;
1047 ImVec2 BackupCursorMaxPos;
1048 ImVec2 BackupCursorPosPrevLine;
1049 float BackupPrevLineTextBaseOffset;
1050 ImGuiLayoutType BackupLayout;
1051
1052 ImGuiComboPreviewData() { memset(s: this, c: 0, n: sizeof(*this)); }
1053};
1054
1055// Stacked storage data for BeginGroup()/EndGroup()
1056struct IMGUI_API ImGuiGroupData
1057{
1058 ImGuiID WindowID;
1059 ImVec2 BackupCursorPos;
1060 ImVec2 BackupCursorMaxPos;
1061 ImVec2 BackupCursorPosPrevLine;
1062 ImVec1 BackupIndent;
1063 ImVec1 BackupGroupOffset;
1064 ImVec2 BackupCurrLineSize;
1065 float BackupCurrLineTextBaseOffset;
1066 ImGuiID BackupActiveIdIsAlive;
1067 bool BackupActiveIdPreviousFrameIsAlive;
1068 bool BackupHoveredIdIsAlive;
1069 bool BackupIsSameLine;
1070 bool EmitItem;
1071};
1072
1073// Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper.
1074struct IMGUI_API ImGuiMenuColumns
1075{
1076 ImU32 TotalWidth;
1077 ImU32 NextTotalWidth;
1078 ImU16 Spacing;
1079 ImU16 OffsetIcon; // Always zero for now
1080 ImU16 OffsetLabel; // Offsets are locked in Update()
1081 ImU16 OffsetShortcut;
1082 ImU16 OffsetMark;
1083 ImU16 Widths[4]; // Width of: Icon, Label, Shortcut, Mark (accumulators for current frame)
1084
1085 ImGuiMenuColumns() { memset(s: this, c: 0, n: sizeof(*this)); }
1086 void Update(float spacing, bool window_reappearing);
1087 float DeclColumns(float w_icon, float w_label, float w_shortcut, float w_mark);
1088 void CalcNextTotalWidth(bool update_offsets);
1089};
1090
1091// Internal temporary state for deactivating InputText() instances.
1092struct IMGUI_API ImGuiInputTextDeactivatedState
1093{
1094 ImGuiID ID; // widget id owning the text state (which just got deactivated)
1095 ImVector<char> TextA; // text buffer
1096
1097 ImGuiInputTextDeactivatedState() { memset(s: this, c: 0, n: sizeof(*this)); }
1098 void ClearFreeMemory() { ID = 0; TextA.clear(); }
1099};
1100// Internal state of the currently focused/edited text input box
1101// For a given item ID, access with ImGui::GetInputTextState()
1102struct IMGUI_API ImGuiInputTextState
1103{
1104 ImGuiContext* Ctx; // parent UI context (needs to be set explicitly by parent).
1105 ImGuiID ID; // widget id owning the text state
1106 int CurLenW, CurLenA; // we need to maintain our buffer length in both UTF-8 and wchar format. UTF-8 length is valid even if TextA is not.
1107 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.
1108 ImVector<char> TextA; // temporary UTF8 buffer for callbacks and other operations. this is not updated in every code-path! size=capacity.
1109 ImVector<char> InitialTextA; // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
1110 bool TextAIsValid; // temporary UTF8 buffer is not initially valid before we make the widget active (until then we pull the data from user argument)
1111 int BufCapacityA; // end-user buffer capacity
1112 float ScrollX; // horizontal scrolling/offset
1113 ImStb::STB_TexteditState Stb; // state for stb_textedit.h
1114 float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
1115 bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
1116 bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
1117 bool Edited; // edited this frame
1118 ImGuiInputTextFlags Flags; // copy of InputText() flags. may be used to check if e.g. ImGuiInputTextFlags_Password is set.
1119
1120 ImGuiInputTextState() { memset(s: this, c: 0, n: sizeof(*this)); }
1121 void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); }
1122 void ClearFreeMemory() { TextW.clear(); TextA.clear(); InitialTextA.clear(); }
1123 int GetUndoAvailCount() const { return Stb.undostate.undo_point; }
1124 int GetRedoAvailCount() const { return STB_TEXTEDIT_UNDOSTATECOUNT - Stb.undostate.redo_point; }
1125 void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation
1126
1127 // Cursor & Selection
1128 void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking
1129 void CursorClamp() { Stb.cursor = ImMin(lhs: Stb.cursor, rhs: CurLenW); Stb.select_start = ImMin(lhs: Stb.select_start, rhs: CurLenW); Stb.select_end = ImMin(lhs: Stb.select_end, rhs: CurLenW); }
1130 bool HasSelection() const { return Stb.select_start != Stb.select_end; }
1131 void ClearSelection() { Stb.select_start = Stb.select_end = Stb.cursor; }
1132 int GetCursorPos() const { return Stb.cursor; }
1133 int GetSelectionStart() const { return Stb.select_start; }
1134 int GetSelectionEnd() const { return Stb.select_end; }
1135 void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
1136};
1137
1138// Storage for current popup stack
1139struct ImGuiPopupData
1140{
1141 ImGuiID PopupId; // Set on OpenPopup()
1142 ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
1143 ImGuiWindow* BackupNavWindow;// Set on OpenPopup(), a NavWindow that will be restored on popup close
1144 int ParentNavLayer; // Resolved on BeginPopup(). Actually a ImGuiNavLayer type (declared down below), initialized to -1 which is not part of an enum, but serves well-enough as "not any of layers" value
1145 int OpenFrameCount; // Set on OpenPopup()
1146 ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differentiate multiple menu sets from each others (e.g. inside menu bar vs loose menu items)
1147 ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse)
1148 ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup
1149
1150 ImGuiPopupData() { memset(s: this, c: 0, n: sizeof(*this)); ParentNavLayer = OpenFrameCount = -1; }
1151};
1152
1153enum ImGuiNextWindowDataFlags_
1154{
1155 ImGuiNextWindowDataFlags_None = 0,
1156 ImGuiNextWindowDataFlags_HasPos = 1 << 0,
1157 ImGuiNextWindowDataFlags_HasSize = 1 << 1,
1158 ImGuiNextWindowDataFlags_HasContentSize = 1 << 2,
1159 ImGuiNextWindowDataFlags_HasCollapsed = 1 << 3,
1160 ImGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4,
1161 ImGuiNextWindowDataFlags_HasFocus = 1 << 5,
1162 ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6,
1163 ImGuiNextWindowDataFlags_HasScroll = 1 << 7,
1164 ImGuiNextWindowDataFlags_HasChildFlags = 1 << 8,
1165};
1166
1167// Storage for SetNexWindow** functions
1168struct ImGuiNextWindowData
1169{
1170 ImGuiNextWindowDataFlags Flags;
1171 ImGuiCond PosCond;
1172 ImGuiCond SizeCond;
1173 ImGuiCond CollapsedCond;
1174 ImVec2 PosVal;
1175 ImVec2 PosPivotVal;
1176 ImVec2 SizeVal;
1177 ImVec2 ContentSizeVal;
1178 ImVec2 ScrollVal;
1179 ImGuiChildFlags ChildFlags;
1180 bool CollapsedVal;
1181 ImRect SizeConstraintRect;
1182 ImGuiSizeCallback SizeCallback;
1183 void* SizeCallbackUserData;
1184 float BgAlphaVal; // Override background alpha
1185 ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?)
1186
1187 ImGuiNextWindowData() { memset(s: this, c: 0, n: sizeof(*this)); }
1188 inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; }
1189};
1190
1191// Multi-Selection item index or identifier when using SetNextItemSelectionUserData()/BeginMultiSelect()
1192// (Most users are likely to use this store an item INDEX but this may be used to store a POINTER as well.)
1193typedef ImS64 ImGuiSelectionUserData;
1194
1195enum ImGuiNextItemDataFlags_
1196{
1197 ImGuiNextItemDataFlags_None = 0,
1198 ImGuiNextItemDataFlags_HasWidth = 1 << 0,
1199 ImGuiNextItemDataFlags_HasOpen = 1 << 1,
1200};
1201
1202struct ImGuiNextItemData
1203{
1204 ImGuiNextItemDataFlags Flags;
1205 ImGuiItemFlags ItemFlags; // Currently only tested/used for ImGuiItemFlags_AllowOverlap.
1206 // Non-flags members are NOT cleared by ItemAdd() meaning they are still valid during NavProcessItem()
1207 float Width; // Set by SetNextItemWidth()
1208 ImGuiSelectionUserData SelectionUserData; // Set by SetNextItemSelectionUserData() (note that NULL/0 is a valid value, we use -1 == ImGuiSelectionUserData_Invalid to mark invalid values)
1209 ImGuiCond OpenCond;
1210 bool OpenVal; // Set by SetNextItemOpen()
1211
1212 ImGuiNextItemData() { memset(s: this, c: 0, n: sizeof(*this)); SelectionUserData = -1; }
1213 inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; ItemFlags = ImGuiItemFlags_None; } // Also cleared manually by ItemAdd()!
1214};
1215
1216// Status storage for the last submitted item
1217struct ImGuiLastItemData
1218{
1219 ImGuiID ID;
1220 ImGuiItemFlags InFlags; // See ImGuiItemFlags_
1221 ImGuiItemStatusFlags StatusFlags; // See ImGuiItemStatusFlags_
1222 ImRect Rect; // Full rectangle
1223 ImRect NavRect; // Navigation scoring rectangle (not displayed)
1224 ImRect DisplayRect; // Display rectangle (only if ImGuiItemStatusFlags_HasDisplayRect is set)
1225
1226 ImGuiLastItemData() { memset(s: this, c: 0, n: sizeof(*this)); }
1227};
1228
1229// Store data emitted by TreeNode() for usage by TreePop() to implement ImGuiTreeNodeFlags_NavLeftJumpsBackHere.
1230// This is the minimum amount of data that we need to perform the equivalent of NavApplyItemToResult() and which we can't infer in TreePop()
1231// Only stored when the node is a potential candidate for landing on a Left arrow jump.
1232struct ImGuiNavTreeNodeData
1233{
1234 ImGuiID ID;
1235 ImGuiItemFlags InFlags;
1236 ImRect NavRect;
1237};
1238
1239struct IMGUI_API ImGuiStackSizes
1240{
1241 short SizeOfIDStack;
1242 short SizeOfColorStack;
1243 short SizeOfStyleVarStack;
1244 short SizeOfFontStack;
1245 short SizeOfFocusScopeStack;
1246 short SizeOfGroupStack;
1247 short SizeOfItemFlagsStack;
1248 short SizeOfBeginPopupStack;
1249 short SizeOfDisabledStack;
1250
1251 ImGuiStackSizes() { memset(s: this, c: 0, n: sizeof(*this)); }
1252 void SetToContextState(ImGuiContext* ctx);
1253 void CompareWithContextState(ImGuiContext* ctx);
1254};
1255
1256// Data saved for each window pushed into the stack
1257struct ImGuiWindowStackData
1258{
1259 ImGuiWindow* Window;
1260 ImGuiLastItemData ParentLastItemDataBackup;
1261 ImGuiStackSizes StackSizesOnBegin; // Store size of various stacks for asserting
1262};
1263
1264struct ImGuiShrinkWidthItem
1265{
1266 int Index;
1267 float Width;
1268 float InitialWidth;
1269};
1270
1271struct ImGuiPtrOrIndex
1272{
1273 void* Ptr; // Either field can be set, not both. e.g. Dock node tab bars are loose while BeginTabBar() ones are in a pool.
1274 int Index; // Usually index in a main pool.
1275
1276 ImGuiPtrOrIndex(void* ptr) { Ptr = ptr; Index = -1; }
1277 ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
1278};
1279
1280//-----------------------------------------------------------------------------
1281// [SECTION] Inputs support
1282//-----------------------------------------------------------------------------
1283
1284// Bit array for named keys
1285typedef ImBitArray<ImGuiKey_NamedKey_COUNT, -ImGuiKey_NamedKey_BEGIN> ImBitArrayForNamedKeys;
1286
1287// [Internal] Key ranges
1288#define ImGuiKey_LegacyNativeKey_BEGIN 0
1289#define ImGuiKey_LegacyNativeKey_END 512
1290#define ImGuiKey_Keyboard_BEGIN (ImGuiKey_NamedKey_BEGIN)
1291#define ImGuiKey_Keyboard_END (ImGuiKey_GamepadStart)
1292#define ImGuiKey_Gamepad_BEGIN (ImGuiKey_GamepadStart)
1293#define ImGuiKey_Gamepad_END (ImGuiKey_GamepadRStickDown + 1)
1294#define ImGuiKey_Mouse_BEGIN (ImGuiKey_MouseLeft)
1295#define ImGuiKey_Mouse_END (ImGuiKey_MouseWheelY + 1)
1296#define ImGuiKey_Aliases_BEGIN (ImGuiKey_Mouse_BEGIN)
1297#define ImGuiKey_Aliases_END (ImGuiKey_Mouse_END)
1298
1299// [Internal] Named shortcuts for Navigation
1300#define ImGuiKey_NavKeyboardTweakSlow ImGuiMod_Ctrl
1301#define ImGuiKey_NavKeyboardTweakFast ImGuiMod_Shift
1302#define ImGuiKey_NavGamepadTweakSlow ImGuiKey_GamepadL1
1303#define ImGuiKey_NavGamepadTweakFast ImGuiKey_GamepadR1
1304#define ImGuiKey_NavGamepadActivate ImGuiKey_GamepadFaceDown
1305#define ImGuiKey_NavGamepadCancel ImGuiKey_GamepadFaceRight
1306#define ImGuiKey_NavGamepadMenu ImGuiKey_GamepadFaceLeft
1307#define ImGuiKey_NavGamepadInput ImGuiKey_GamepadFaceUp
1308
1309enum ImGuiInputEventType
1310{
1311 ImGuiInputEventType_None = 0,
1312 ImGuiInputEventType_MousePos,
1313 ImGuiInputEventType_MouseWheel,
1314 ImGuiInputEventType_MouseButton,
1315 ImGuiInputEventType_Key,
1316 ImGuiInputEventType_Text,
1317 ImGuiInputEventType_Focus,
1318 ImGuiInputEventType_COUNT
1319};
1320
1321enum ImGuiInputSource
1322{
1323 ImGuiInputSource_None = 0,
1324 ImGuiInputSource_Mouse, // Note: may be Mouse or TouchScreen or Pen. See io.MouseSource to distinguish them.
1325 ImGuiInputSource_Keyboard,
1326 ImGuiInputSource_Gamepad,
1327 ImGuiInputSource_Clipboard, // Currently only used by InputText()
1328 ImGuiInputSource_COUNT
1329};
1330
1331// FIXME: Structures in the union below need to be declared as anonymous unions appears to be an extension?
1332// Using ImVec2() would fail on Clang 'union member 'MousePos' has a non-trivial default constructor'
1333struct ImGuiInputEventMousePos { float PosX, PosY; ImGuiMouseSource MouseSource; };
1334struct ImGuiInputEventMouseWheel { float WheelX, WheelY; ImGuiMouseSource MouseSource; };
1335struct ImGuiInputEventMouseButton { int Button; bool Down; ImGuiMouseSource MouseSource; };
1336struct ImGuiInputEventKey { ImGuiKey Key; bool Down; float AnalogValue; };
1337struct ImGuiInputEventText { unsigned int Char; };
1338struct ImGuiInputEventAppFocused { bool Focused; };
1339
1340struct ImGuiInputEvent
1341{
1342 ImGuiInputEventType Type;
1343 ImGuiInputSource Source;
1344 ImU32 EventId; // Unique, sequential increasing integer to identify an event (if you need to correlate them to other data).
1345 union
1346 {
1347 ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
1348 ImGuiInputEventMouseWheel MouseWheel; // if Type == ImGuiInputEventType_MouseWheel
1349 ImGuiInputEventMouseButton MouseButton; // if Type == ImGuiInputEventType_MouseButton
1350 ImGuiInputEventKey Key; // if Type == ImGuiInputEventType_Key
1351 ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
1352 ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
1353 };
1354 bool AddedByTestEngine;
1355
1356 ImGuiInputEvent() { memset(s: this, c: 0, n: sizeof(*this)); }
1357};
1358
1359// Input function taking an 'ImGuiID owner_id' argument defaults to (ImGuiKeyOwner_Any == 0) aka don't test ownership, which matches legacy behavior.
1360#define ImGuiKeyOwner_Any ((ImGuiID)0) // Accept key that have an owner, UNLESS a call to SetKeyOwner() explicitly used ImGuiInputFlags_LockThisFrame or ImGuiInputFlags_LockUntilRelease.
1361#define ImGuiKeyOwner_None ((ImGuiID)-1) // Require key to have no owner.
1362
1363typedef ImS16 ImGuiKeyRoutingIndex;
1364
1365// Routing table entry (sizeof() == 16 bytes)
1366struct ImGuiKeyRoutingData
1367{
1368 ImGuiKeyRoutingIndex NextEntryIndex;
1369 ImU16 Mods; // Technically we'd only need 4-bits but for simplify we store ImGuiMod_ values which need 16-bits. ImGuiMod_Shortcut is already translated to Ctrl/Super.
1370 ImU8 RoutingNextScore; // Lower is better (0: perfect score)
1371 ImGuiID RoutingCurr;
1372 ImGuiID RoutingNext;
1373
1374 ImGuiKeyRoutingData() { NextEntryIndex = -1; Mods = 0; RoutingNextScore = 255; RoutingCurr = RoutingNext = ImGuiKeyOwner_None; }
1375};
1376
1377// Routing table: maintain a desired owner for each possible key-chord (key + mods), and setup owner in NewFrame() when mods are matching.
1378// Stored in main context (1 instance)
1379struct ImGuiKeyRoutingTable
1380{
1381 ImGuiKeyRoutingIndex Index[ImGuiKey_NamedKey_COUNT]; // Index of first entry in Entries[]
1382 ImVector<ImGuiKeyRoutingData> Entries;
1383 ImVector<ImGuiKeyRoutingData> EntriesNext; // Double-buffer to avoid reallocation (could use a shared buffer)
1384
1385 ImGuiKeyRoutingTable() { Clear(); }
1386 void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Index); n++) Index[n] = -1; Entries.clear(); EntriesNext.clear(); }
1387};
1388
1389// This extends ImGuiKeyData but only for named keys (legacy keys don't support the new features)
1390// Stored in main context (1 per named key). In the future it might be merged into ImGuiKeyData.
1391struct ImGuiKeyOwnerData
1392{
1393 ImGuiID OwnerCurr;
1394 ImGuiID OwnerNext;
1395 bool LockThisFrame; // Reading this key requires explicit owner id (until end of frame). Set by ImGuiInputFlags_LockThisFrame.
1396 bool LockUntilRelease; // Reading this key requires explicit owner id (until key is released). Set by ImGuiInputFlags_LockUntilRelease. When this is true LockThisFrame is always true as well.
1397
1398 ImGuiKeyOwnerData() { OwnerCurr = OwnerNext = ImGuiKeyOwner_None; LockThisFrame = LockUntilRelease = false; }
1399};
1400
1401// Flags for extended versions of IsKeyPressed(), IsMouseClicked(), Shortcut(), SetKeyOwner(), SetItemKeyOwner()
1402// Don't mistake with ImGuiInputTextFlags! (for ImGui::InputText() function)
1403enum ImGuiInputFlags_
1404{
1405 // Flags for IsKeyPressed(), IsMouseClicked(), Shortcut()
1406 ImGuiInputFlags_None = 0,
1407 ImGuiInputFlags_Repeat = 1 << 0, // Return true on successive repeats. Default for legacy IsKeyPressed(). NOT Default for legacy IsMouseClicked(). MUST BE == 1.
1408 ImGuiInputFlags_RepeatRateDefault = 1 << 1, // Repeat rate: Regular (default)
1409 ImGuiInputFlags_RepeatRateNavMove = 1 << 2, // Repeat rate: Fast
1410 ImGuiInputFlags_RepeatRateNavTweak = 1 << 3, // Repeat rate: Faster
1411 ImGuiInputFlags_RepeatRateMask_ = ImGuiInputFlags_RepeatRateDefault | ImGuiInputFlags_RepeatRateNavMove | ImGuiInputFlags_RepeatRateNavTweak,
1412
1413 // Flags for SetItemKeyOwner()
1414 ImGuiInputFlags_CondHovered = 1 << 4, // Only set if item is hovered (default to both)
1415 ImGuiInputFlags_CondActive = 1 << 5, // Only set if item is active (default to both)
1416 ImGuiInputFlags_CondDefault_ = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,
1417 ImGuiInputFlags_CondMask_ = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,
1418
1419 // Flags for SetKeyOwner(), SetItemKeyOwner()
1420 ImGuiInputFlags_LockThisFrame = 1 << 6, // Access to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared at end of frame. This is useful to make input-owner-aware code steal keys from non-input-owner-aware code.
1421 ImGuiInputFlags_LockUntilRelease = 1 << 7, // Access to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared when the key is released or at end of each frame if key is released. This is useful to make input-owner-aware code steal keys from non-input-owner-aware code.
1422
1423 // Routing policies for Shortcut() + low-level SetShortcutRouting()
1424 // - The general idea is that several callers register interest in a shortcut, and only one owner gets it.
1425 // - When a policy (other than _RouteAlways) is set, Shortcut() will register itself with SetShortcutRouting(),
1426 // allowing the system to decide where to route the input among other route-aware calls.
1427 // - Shortcut() uses ImGuiInputFlags_RouteFocused by default: meaning that a simple Shortcut() poll
1428 // will register a route and only succeed when parent window is in the focus stack and if no-one
1429 // with a higher priority is claiming the shortcut.
1430 // - Using ImGuiInputFlags_RouteAlways is roughly equivalent to doing e.g. IsKeyPressed(key) + testing mods.
1431 // - Priorities: GlobalHigh > Focused (when owner is active item) > Global > Focused (when focused window) > GlobalLow.
1432 // - Can select only 1 policy among all available.
1433 ImGuiInputFlags_RouteFocused = 1 << 8, // (Default) Register focused route: Accept inputs if window is in focus stack. Deep-most focused window takes inputs. ActiveId takes inputs over deep-most focused window.
1434 ImGuiInputFlags_RouteGlobalLow = 1 << 9, // Register route globally (lowest priority: unless a focused window or active item registered the route) -> recommended Global priority.
1435 ImGuiInputFlags_RouteGlobal = 1 << 10, // Register route globally (medium priority: unless an active item registered the route, e.g. CTRL+A registered by InputText).
1436 ImGuiInputFlags_RouteGlobalHigh = 1 << 11, // Register route globally (highest priority: unlikely you need to use that: will interfere with every active items)
1437 ImGuiInputFlags_RouteMask_ = ImGuiInputFlags_RouteFocused | ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteGlobalLow | ImGuiInputFlags_RouteGlobalHigh, // _Always not part of this!
1438 ImGuiInputFlags_RouteAlways = 1 << 12, // Do not register route, poll keys directly.
1439 ImGuiInputFlags_RouteUnlessBgFocused= 1 << 13, // Global routes will not be applied if underlying background/void is focused (== no Dear ImGui windows are focused). Useful for overlay applications.
1440 ImGuiInputFlags_RouteExtraMask_ = ImGuiInputFlags_RouteAlways | ImGuiInputFlags_RouteUnlessBgFocused,
1441
1442 // [Internal] Mask of which function support which flags
1443 ImGuiInputFlags_SupportedByIsKeyPressed = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateMask_,
1444 ImGuiInputFlags_SupportedByShortcut = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateMask_ | ImGuiInputFlags_RouteMask_ | ImGuiInputFlags_RouteExtraMask_,
1445 ImGuiInputFlags_SupportedBySetKeyOwner = ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease,
1446 ImGuiInputFlags_SupportedBySetItemKeyOwner = ImGuiInputFlags_SupportedBySetKeyOwner | ImGuiInputFlags_CondMask_,
1447};
1448
1449//-----------------------------------------------------------------------------
1450// [SECTION] Clipper support
1451//-----------------------------------------------------------------------------
1452
1453// Note that Max is exclusive, so perhaps should be using a Begin/End convention.
1454struct ImGuiListClipperRange
1455{
1456 int Min;
1457 int Max;
1458 bool PosToIndexConvert; // Begin/End are absolute position (will be converted to indices later)
1459 ImS8 PosToIndexOffsetMin; // Add to Min after converting to indices
1460 ImS8 PosToIndexOffsetMax; // Add to Min after converting to indices
1461
1462 static ImGuiListClipperRange FromIndices(int min, int max) { ImGuiListClipperRange r = { .Min: min, .Max: max, .PosToIndexConvert: false, .PosToIndexOffsetMin: 0, .PosToIndexOffsetMax: 0 }; return r; }
1463 static ImGuiListClipperRange FromPositions(float y1, float y2, int off_min, int off_max) { ImGuiListClipperRange r = { .Min: (int)y1, .Max: (int)y2, .PosToIndexConvert: true, .PosToIndexOffsetMin: (ImS8)off_min, .PosToIndexOffsetMax: (ImS8)off_max }; return r; }
1464};
1465
1466// Temporary clipper data, buffers shared/reused between instances
1467struct ImGuiListClipperData
1468{
1469 ImGuiListClipper* ListClipper;
1470 float LossynessOffset;
1471 int StepNo;
1472 int ItemsFrozen;
1473 ImVector<ImGuiListClipperRange> Ranges;
1474
1475 ImGuiListClipperData() { memset(s: this, c: 0, n: sizeof(*this)); }
1476 void Reset(ImGuiListClipper* clipper) { ListClipper = clipper; StepNo = ItemsFrozen = 0; Ranges.resize(new_size: 0); }
1477};
1478
1479//-----------------------------------------------------------------------------
1480// [SECTION] Navigation support
1481//-----------------------------------------------------------------------------
1482
1483enum ImGuiActivateFlags_
1484{
1485 ImGuiActivateFlags_None = 0,
1486 ImGuiActivateFlags_PreferInput = 1 << 0, // Favor activation that requires keyboard text input (e.g. for Slider/Drag). Default for Enter key.
1487 ImGuiActivateFlags_PreferTweak = 1 << 1, // Favor activation for tweaking with arrows or gamepad (e.g. for Slider/Drag). Default for Space key and if keyboard is not used.
1488 ImGuiActivateFlags_TryToPreserveState = 1 << 2, // Request widget to preserve state if it can (e.g. InputText will try to preserve cursor/selection)
1489};
1490
1491// Early work-in-progress API for ScrollToItem()
1492enum ImGuiScrollFlags_
1493{
1494 ImGuiScrollFlags_None = 0,
1495 ImGuiScrollFlags_KeepVisibleEdgeX = 1 << 0, // If item is not visible: scroll as little as possible on X axis to bring item back into view [default for X axis]
1496 ImGuiScrollFlags_KeepVisibleEdgeY = 1 << 1, // If item is not visible: scroll as little as possible on Y axis to bring item back into view [default for Y axis for windows that are already visible]
1497 ImGuiScrollFlags_KeepVisibleCenterX = 1 << 2, // If item is not visible: scroll to make the item centered on X axis [rarely used]
1498 ImGuiScrollFlags_KeepVisibleCenterY = 1 << 3, // If item is not visible: scroll to make the item centered on Y axis
1499 ImGuiScrollFlags_AlwaysCenterX = 1 << 4, // Always center the result item on X axis [rarely used]
1500 ImGuiScrollFlags_AlwaysCenterY = 1 << 5, // Always center the result item on Y axis [default for Y axis for appearing window)
1501 ImGuiScrollFlags_NoScrollParent = 1 << 6, // Disable forwarding scrolling to parent window if required to keep item/rect visible (only scroll window the function was applied to).
1502 ImGuiScrollFlags_MaskX_ = ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleCenterX | ImGuiScrollFlags_AlwaysCenterX,
1503 ImGuiScrollFlags_MaskY_ = ImGuiScrollFlags_KeepVisibleEdgeY | ImGuiScrollFlags_KeepVisibleCenterY | ImGuiScrollFlags_AlwaysCenterY,
1504};
1505
1506enum ImGuiNavHighlightFlags_
1507{
1508 ImGuiNavHighlightFlags_None = 0,
1509 ImGuiNavHighlightFlags_TypeDefault = 1 << 0,
1510 ImGuiNavHighlightFlags_TypeThin = 1 << 1,
1511 ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2, // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse.
1512 ImGuiNavHighlightFlags_NoRounding = 1 << 3,
1513};
1514
1515enum ImGuiNavMoveFlags_
1516{
1517 ImGuiNavMoveFlags_None = 0,
1518 ImGuiNavMoveFlags_LoopX = 1 << 0, // On failed request, restart from opposite side
1519 ImGuiNavMoveFlags_LoopY = 1 << 1,
1520 ImGuiNavMoveFlags_WrapX = 1 << 2, // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left)
1521 ImGuiNavMoveFlags_WrapY = 1 << 3, // This is not super useful but provided for completeness
1522 ImGuiNavMoveFlags_WrapMask_ = ImGuiNavMoveFlags_LoopX | ImGuiNavMoveFlags_LoopY | ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_WrapY,
1523 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)
1524 ImGuiNavMoveFlags_AlsoScoreVisibleSet = 1 << 5, // Store alternate result in NavMoveResultLocalVisible that only comprise elements that are already fully visible (used by PageUp/PageDown)
1525 ImGuiNavMoveFlags_ScrollToEdgeY = 1 << 6, // Force scrolling to min/max (used by Home/End) // FIXME-NAV: Aim to remove or reword, probably unnecessary
1526 ImGuiNavMoveFlags_Forwarded = 1 << 7,
1527 ImGuiNavMoveFlags_DebugNoResult = 1 << 8, // Dummy scoring for debug purpose, don't apply result
1528 ImGuiNavMoveFlags_FocusApi = 1 << 9, // Requests from focus API can land/focus/activate items even if they are marked with _NoTabStop (see NavProcessItemForTabbingRequest() for details)
1529 ImGuiNavMoveFlags_IsTabbing = 1 << 10, // == Focus + Activate if item is Inputable + DontChangeNavHighlight
1530 ImGuiNavMoveFlags_IsPageMove = 1 << 11, // Identify a PageDown/PageUp request.
1531 ImGuiNavMoveFlags_Activate = 1 << 12, // Activate/select target item.
1532 ImGuiNavMoveFlags_NoSelect = 1 << 13, // Don't trigger selection by not setting g.NavJustMovedTo
1533 ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 14, // Do not alter the visible state of keyboard vs mouse nav highlight
1534};
1535
1536enum ImGuiNavLayer
1537{
1538 ImGuiNavLayer_Main = 0, // Main scrolling layer
1539 ImGuiNavLayer_Menu = 1, // Menu layer (access with Alt)
1540 ImGuiNavLayer_COUNT
1541};
1542
1543struct ImGuiNavItemData
1544{
1545 ImGuiWindow* Window; // Init,Move // Best candidate window (result->ItemWindow->RootWindowForNav == request->Window)
1546 ImGuiID ID; // Init,Move // Best candidate item ID
1547 ImGuiID FocusScopeId; // Init,Move // Best candidate focus scope ID
1548 ImRect RectRel; // Init,Move // Best candidate bounding box in window relative space
1549 ImGuiItemFlags InFlags; // ????,Move // Best candidate item flags
1550 ImGuiSelectionUserData SelectionUserData;//I+Mov // Best candidate SetNextItemSelectionData() value.
1551 float DistBox; // Move // Best candidate box distance to current NavId
1552 float DistCenter; // Move // Best candidate center distance to current NavId
1553 float DistAxial; // Move // Best candidate axial distance to current NavId
1554
1555 ImGuiNavItemData() { Clear(); }
1556 void Clear() { Window = NULL; ID = FocusScopeId = 0; InFlags = 0; SelectionUserData = -1; DistBox = DistCenter = DistAxial = FLT_MAX; }
1557};
1558
1559//-----------------------------------------------------------------------------
1560// [SECTION] Typing-select support
1561//-----------------------------------------------------------------------------
1562
1563// Flags for GetTypingSelectRequest()
1564enum ImGuiTypingSelectFlags_
1565{
1566 ImGuiTypingSelectFlags_None = 0,
1567 ImGuiTypingSelectFlags_AllowBackspace = 1 << 0, // Backspace to delete character inputs. If using: ensure GetTypingSelectRequest() is not called more than once per frame (filter by e.g. focus state)
1568 ImGuiTypingSelectFlags_AllowSingleCharMode = 1 << 1, // Allow "single char" search mode which is activated when pressing the same character multiple times.
1569};
1570
1571// Returned by GetTypingSelectRequest(), designed to eventually be public.
1572struct IMGUI_API ImGuiTypingSelectRequest
1573{
1574 ImGuiTypingSelectFlags Flags; // Flags passed to GetTypingSelectRequest()
1575 int SearchBufferLen;
1576 const char* SearchBuffer; // Search buffer contents (use full string. unless SingleCharMode is set, in which case use SingleCharSize).
1577 bool SelectRequest; // Set when buffer was modified this frame, requesting a selection.
1578 bool SingleCharMode; // Notify when buffer contains same character repeated, to implement special mode. In this situation it preferred to not display any on-screen search indication.
1579 ImS8 SingleCharSize; // Length in bytes of first letter codepoint (1 for ascii, 2-4 for UTF-8). If (SearchBufferLen==RepeatCharSize) only 1 letter has been input.
1580};
1581
1582// Storage for GetTypingSelectRequest()
1583struct IMGUI_API ImGuiTypingSelectState
1584{
1585 ImGuiTypingSelectRequest Request; // User-facing data
1586 char SearchBuffer[64]; // Search buffer: no need to make dynamic as this search is very transient.
1587 ImGuiID FocusScope;
1588 int LastRequestFrame = 0;
1589 float LastRequestTime = 0.0f;
1590 bool SingleCharModeLock = false; // After a certain single char repeat count we lock into SingleCharMode. Two benefits: 1) buffer never fill, 2) we can provide an immediate SingleChar mode without timer elapsing.
1591
1592 ImGuiTypingSelectState() { memset(s: this, c: 0, n: sizeof(*this)); }
1593 void Clear() { SearchBuffer[0] = 0; SingleCharModeLock = false; } // We preserve remaining data for easier debugging
1594};
1595
1596//-----------------------------------------------------------------------------
1597// [SECTION] Columns support
1598//-----------------------------------------------------------------------------
1599
1600// Flags for internal's BeginColumns(). Prefix using BeginTable() nowadays!
1601enum ImGuiOldColumnFlags_
1602{
1603 ImGuiOldColumnFlags_None = 0,
1604 ImGuiOldColumnFlags_NoBorder = 1 << 0, // Disable column dividers
1605 ImGuiOldColumnFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers
1606 ImGuiOldColumnFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns
1607 ImGuiOldColumnFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window
1608 ImGuiOldColumnFlags_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.
1609
1610 // Obsolete names (will be removed)
1611#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1612 ImGuiColumnsFlags_None = ImGuiOldColumnFlags_None,
1613 ImGuiColumnsFlags_NoBorder = ImGuiOldColumnFlags_NoBorder,
1614 ImGuiColumnsFlags_NoResize = ImGuiOldColumnFlags_NoResize,
1615 ImGuiColumnsFlags_NoPreserveWidths = ImGuiOldColumnFlags_NoPreserveWidths,
1616 ImGuiColumnsFlags_NoForceWithinWindow = ImGuiOldColumnFlags_NoForceWithinWindow,
1617 ImGuiColumnsFlags_GrowParentContentsSize = ImGuiOldColumnFlags_GrowParentContentsSize,
1618#endif
1619};
1620
1621struct ImGuiOldColumnData
1622{
1623 float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
1624 float OffsetNormBeforeResize;
1625 ImGuiOldColumnFlags Flags; // Not exposed
1626 ImRect ClipRect;
1627
1628 ImGuiOldColumnData() { memset(s: this, c: 0, n: sizeof(*this)); }
1629};
1630
1631struct ImGuiOldColumns
1632{
1633 ImGuiID ID;
1634 ImGuiOldColumnFlags Flags;
1635 bool IsFirstFrame;
1636 bool IsBeingResized;
1637 int Current;
1638 int Count;
1639 float OffMinX, OffMaxX; // Offsets from HostWorkRect.Min.x
1640 float LineMinY, LineMaxY;
1641 float HostCursorPosY; // Backup of CursorPos at the time of BeginColumns()
1642 float HostCursorMaxPosX; // Backup of CursorMaxPos at the time of BeginColumns()
1643 ImRect HostInitialClipRect; // Backup of ClipRect at the time of BeginColumns()
1644 ImRect HostBackupClipRect; // Backup of ClipRect during PushColumnsBackground()/PopColumnsBackground()
1645 ImRect HostBackupParentWorkRect;//Backup of WorkRect at the time of BeginColumns()
1646 ImVector<ImGuiOldColumnData> Columns;
1647 ImDrawListSplitter Splitter;
1648
1649 ImGuiOldColumns() { memset(s: this, c: 0, n: sizeof(*this)); }
1650};
1651
1652//-----------------------------------------------------------------------------
1653// [SECTION] Multi-select support
1654//-----------------------------------------------------------------------------
1655
1656// We always assume that -1 is an invalid value (which works for indices and pointers)
1657#define ImGuiSelectionUserData_Invalid ((ImGuiSelectionUserData)-1)
1658
1659#ifdef IMGUI_HAS_MULTI_SELECT
1660// <this is filled in 'range_select' branch>
1661#endif // #ifdef IMGUI_HAS_MULTI_SELECT
1662
1663//-----------------------------------------------------------------------------
1664// [SECTION] Docking support
1665//-----------------------------------------------------------------------------
1666
1667#ifdef IMGUI_HAS_DOCK
1668// <this is filled in 'docking' branch>
1669#endif // #ifdef IMGUI_HAS_DOCK
1670
1671//-----------------------------------------------------------------------------
1672// [SECTION] Viewport support
1673//-----------------------------------------------------------------------------
1674
1675// ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!)
1676// Every instance of ImGuiViewport is in fact a ImGuiViewportP.
1677struct ImGuiViewportP : public ImGuiViewport
1678{
1679 int BgFgDrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used
1680 ImDrawList* BgFgDrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
1681 ImDrawData DrawDataP;
1682 ImDrawDataBuilder DrawDataBuilder; // Temporary data while building final ImDrawData
1683 ImVec2 WorkOffsetMin; // Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!)
1684 ImVec2 WorkOffsetMax; // Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height).
1685 ImVec2 BuildWorkOffsetMin; // Work Area: Offset being built during current frame. Generally >= 0.0f.
1686 ImVec2 BuildWorkOffsetMax; // Work Area: Offset being built during current frame. Generally <= 0.0f.
1687
1688 ImGuiViewportP() { BgFgDrawListsLastFrame[0] = BgFgDrawListsLastFrame[1] = -1; BgFgDrawLists[0] = BgFgDrawLists[1] = NULL; }
1689 ~ImGuiViewportP() { if (BgFgDrawLists[0]) IM_DELETE(p: BgFgDrawLists[0]); if (BgFgDrawLists[1]) IM_DELETE(p: BgFgDrawLists[1]); }
1690
1691 // Calculate work rect pos/size given a set of offset (we have 1 pair of offset for rect locked from last frame data, and 1 pair for currently building rect)
1692 ImVec2 CalcWorkRectPos(const ImVec2& off_min) const { return ImVec2(Pos.x + off_min.x, Pos.y + off_min.y); }
1693 ImVec2 CalcWorkRectSize(const ImVec2& off_min, const ImVec2& off_max) const { return ImVec2(ImMax(lhs: 0.0f, rhs: Size.x - off_min.x + off_max.x), ImMax(lhs: 0.0f, rhs: Size.y - off_min.y + off_max.y)); }
1694 void UpdateWorkRect() { WorkPos = CalcWorkRectPos(off_min: WorkOffsetMin); WorkSize = CalcWorkRectSize(off_min: WorkOffsetMin, off_max: WorkOffsetMax); } // Update public fields
1695
1696 // Helpers to retrieve ImRect (we don't need to store BuildWorkRect as every access tend to change it, hence the code asymmetry)
1697 ImRect GetMainRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
1698 ImRect GetWorkRect() const { return ImRect(WorkPos.x, WorkPos.y, WorkPos.x + WorkSize.x, WorkPos.y + WorkSize.y); }
1699 ImRect GetBuildWorkRect() const { ImVec2 pos = CalcWorkRectPos(off_min: BuildWorkOffsetMin); ImVec2 size = CalcWorkRectSize(off_min: BuildWorkOffsetMin, off_max: BuildWorkOffsetMax); return ImRect(pos.x, pos.y, pos.x + size.x, pos.y + size.y); }
1700};
1701
1702//-----------------------------------------------------------------------------
1703// [SECTION] Settings support
1704//-----------------------------------------------------------------------------
1705
1706// Windows data saved in imgui.ini file
1707// Because we never destroy or rename ImGuiWindowSettings, we can store the names in a separate buffer easily.
1708// (this is designed to be stored in a ImChunkStream buffer, with the variable-length Name following our structure)
1709struct ImGuiWindowSettings
1710{
1711 ImGuiID ID;
1712 ImVec2ih Pos;
1713 ImVec2ih Size;
1714 bool Collapsed;
1715 bool IsChild;
1716 bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context)
1717 bool WantDelete; // Set to invalidate/delete the settings entry
1718
1719 ImGuiWindowSettings() { memset(s: this, c: 0, n: sizeof(*this)); }
1720 char* GetName() { return (char*)(this + 1); }
1721};
1722
1723struct ImGuiSettingsHandler
1724{
1725 const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
1726 ImGuiID TypeHash; // == ImHashStr(TypeName)
1727 void (*ClearAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Clear all settings data
1728 void (*ReadInitFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Read: Called before reading (in registration order)
1729 void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
1730 void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
1731 void (*ApplyAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Read: Called after reading (in registration order)
1732 void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf'
1733 void* UserData;
1734
1735 ImGuiSettingsHandler() { memset(s: this, c: 0, n: sizeof(*this)); }
1736};
1737
1738//-----------------------------------------------------------------------------
1739// [SECTION] Localization support
1740//-----------------------------------------------------------------------------
1741
1742// This is experimental and not officially supported, it'll probably fall short of features, if/when it does we may backtrack.
1743enum ImGuiLocKey : int
1744{
1745 ImGuiLocKey_VersionStr,
1746 ImGuiLocKey_TableSizeOne,
1747 ImGuiLocKey_TableSizeAllFit,
1748 ImGuiLocKey_TableSizeAllDefault,
1749 ImGuiLocKey_TableResetOrder,
1750 ImGuiLocKey_WindowingMainMenuBar,
1751 ImGuiLocKey_WindowingPopup,
1752 ImGuiLocKey_WindowingUntitled,
1753 ImGuiLocKey_COUNT
1754};
1755
1756struct ImGuiLocEntry
1757{
1758 ImGuiLocKey Key;
1759 const char* Text;
1760};
1761
1762
1763//-----------------------------------------------------------------------------
1764// [SECTION] Metrics, Debug Tools
1765//-----------------------------------------------------------------------------
1766
1767enum ImGuiDebugLogFlags_
1768{
1769 // Event types
1770 ImGuiDebugLogFlags_None = 0,
1771 ImGuiDebugLogFlags_EventActiveId = 1 << 0,
1772 ImGuiDebugLogFlags_EventFocus = 1 << 1,
1773 ImGuiDebugLogFlags_EventPopup = 1 << 2,
1774 ImGuiDebugLogFlags_EventNav = 1 << 3,
1775 ImGuiDebugLogFlags_EventClipper = 1 << 4,
1776 ImGuiDebugLogFlags_EventSelection = 1 << 5,
1777 ImGuiDebugLogFlags_EventIO = 1 << 6,
1778 ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO,
1779 ImGuiDebugLogFlags_OutputToTTY = 1 << 10, // Also send output to TTY
1780 ImGuiDebugLogFlags_OutputToTestEngine = 1 << 11, // Also send output to Test Engine
1781};
1782
1783struct ImGuiDebugAllocEntry
1784{
1785 int FrameCount;
1786 ImS16 AllocCount;
1787 ImS16 FreeCount;
1788};
1789
1790struct ImGuiDebugAllocInfo
1791{
1792 int TotalAllocCount; // Number of call to MemAlloc().
1793 int TotalFreeCount;
1794 ImS16 LastEntriesIdx; // Current index in buffer
1795 ImGuiDebugAllocEntry LastEntriesBuf[6]; // Track last 6 frames that had allocations
1796
1797 ImGuiDebugAllocInfo() { memset(s: this, c: 0, n: sizeof(*this)); }
1798};
1799
1800struct ImGuiMetricsConfig
1801{
1802 bool ShowDebugLog = false;
1803 bool ShowIDStackTool = false;
1804 bool ShowWindowsRects = false;
1805 bool ShowWindowsBeginOrder = false;
1806 bool ShowTablesRects = false;
1807 bool ShowDrawCmdMesh = true;
1808 bool ShowDrawCmdBoundingBoxes = true;
1809 bool ShowAtlasTintedWithTextColor = false;
1810 int ShowWindowsRectsType = -1;
1811 int ShowTablesRectsType = -1;
1812};
1813
1814struct ImGuiStackLevelInfo
1815{
1816 ImGuiID ID;
1817 ImS8 QueryFrameCount; // >= 1: Query in progress
1818 bool QuerySuccess; // Obtained result from DebugHookIdInfo()
1819 ImGuiDataType DataType : 8;
1820 char Desc[57]; // Arbitrarily sized buffer to hold a result (FIXME: could replace Results[] with a chunk stream?) FIXME: Now that we added CTRL+C this should be fixed.
1821
1822 ImGuiStackLevelInfo() { memset(s: this, c: 0, n: sizeof(*this)); }
1823};
1824
1825// State for ID Stack tool queries
1826struct ImGuiIDStackTool
1827{
1828 int LastActiveFrame;
1829 int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level
1830 ImGuiID QueryId; // ID to query details for
1831 ImVector<ImGuiStackLevelInfo> Results;
1832 bool CopyToClipboardOnCtrlC;
1833 float CopyToClipboardLastTime;
1834
1835 ImGuiIDStackTool() { memset(s: this, c: 0, n: sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
1836};
1837
1838//-----------------------------------------------------------------------------
1839// [SECTION] Generic context hooks
1840//-----------------------------------------------------------------------------
1841
1842typedef void (*ImGuiContextHookCallback)(ImGuiContext* ctx, ImGuiContextHook* hook);
1843enum ImGuiContextHookType { ImGuiContextHookType_NewFramePre, ImGuiContextHookType_NewFramePost, ImGuiContextHookType_EndFramePre, ImGuiContextHookType_EndFramePost, ImGuiContextHookType_RenderPre, ImGuiContextHookType_RenderPost, ImGuiContextHookType_Shutdown, ImGuiContextHookType_PendingRemoval_ };
1844
1845struct ImGuiContextHook
1846{
1847 ImGuiID HookId; // A unique ID assigned by AddContextHook()
1848 ImGuiContextHookType Type;
1849 ImGuiID Owner;
1850 ImGuiContextHookCallback Callback;
1851 void* UserData;
1852
1853 ImGuiContextHook() { memset(s: this, c: 0, n: sizeof(*this)); }
1854};
1855
1856//-----------------------------------------------------------------------------
1857// [SECTION] ImGuiContext (main Dear ImGui context)
1858//-----------------------------------------------------------------------------
1859
1860struct ImGuiContext
1861{
1862 bool Initialized;
1863 bool FontAtlasOwnedByContext; // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
1864 ImGuiIO IO;
1865 ImGuiStyle Style;
1866 ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
1867 float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
1868 float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
1869 ImDrawListSharedData DrawListSharedData;
1870 double Time;
1871 int FrameCount;
1872 int FrameCountEnded;
1873 int FrameCountRendered;
1874 bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame()
1875 bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed
1876 bool WithinEndChild; // Set within EndChild()
1877 bool GcCompactAll; // Request full GC
1878 bool TestEngineHookItems; // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log()
1879 void* TestEngine; // Test engine user data
1880
1881 // Inputs
1882 ImVector<ImGuiInputEvent> InputEventsQueue; // Input events which will be trickled/written into IO structure.
1883 ImVector<ImGuiInputEvent> InputEventsTrail; // Past input events processed in NewFrame(). This is to allow domain-specific application to access e.g mouse/pen trail.
1884 ImGuiMouseSource InputEventsNextMouseSource;
1885 ImU32 InputEventsNextEventId;
1886
1887 // Windows state
1888 ImVector<ImGuiWindow*> Windows; // Windows, sorted in display order, back to front
1889 ImVector<ImGuiWindow*> WindowsFocusOrder; // Root windows, sorted in focus order, back to front.
1890 ImVector<ImGuiWindow*> WindowsTempSortBuffer; // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child
1891 ImVector<ImGuiWindowStackData> CurrentWindowStack;
1892 ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow*
1893 int WindowsActiveCount; // Number of unique windows submitted by frame
1894 ImVec2 WindowsHoverPadding; // Padding around resizable windows for which hovering on counts as hovering the window == ImMax(style.TouchExtraPadding, WINDOWS_HOVER_PADDING)
1895 ImGuiWindow* CurrentWindow; // Window being drawn into
1896 ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs.
1897 ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
1898 ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindow.
1899 ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
1900 ImVec2 WheelingWindowRefMousePos;
1901 int WheelingWindowStartFrame; // This may be set one frame before WheelingWindow is != NULL
1902 int WheelingWindowScrolledFrame;
1903 float WheelingWindowReleaseTimer;
1904 ImVec2 WheelingWindowWheelRemainder;
1905 ImVec2 WheelingAxisAvg;
1906
1907 // Item/widgets state and tracking information
1908 ImGuiID DebugHookIdInfo; // Will call core hooks: DebugHookIdInfo() from GetID functions, used by ID Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line]
1909 ImGuiID HoveredId; // Hovered widget, filled during the frame
1910 ImGuiID HoveredIdPreviousFrame;
1911 bool HoveredIdAllowOverlap;
1912 bool HoveredIdDisabled; // At least one widget passed the rect test, but has been discarded by disabled flag or popup inhibit. May be true even if HoveredId == 0.
1913 float HoveredIdTimer; // Measure contiguous hovering time
1914 float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active
1915 ImGuiID ActiveId; // Active widget
1916 ImGuiID ActiveIdIsAlive; // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
1917 float ActiveIdTimer;
1918 bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
1919 bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
1920 bool ActiveIdNoClearOnFocusLoss; // Disable losing active id if the active id window gets unfocused.
1921 bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
1922 bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
1923 bool ActiveIdHasBeenEditedThisFrame;
1924 ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
1925 ImGuiWindow* ActiveIdWindow;
1926 ImGuiInputSource ActiveIdSource; // Activating source: ImGuiInputSource_Mouse OR ImGuiInputSource_Keyboard OR ImGuiInputSource_Gamepad
1927 int ActiveIdMouseButton;
1928 ImGuiID ActiveIdPreviousFrame;
1929 bool ActiveIdPreviousFrameIsAlive;
1930 bool ActiveIdPreviousFrameHasBeenEditedBefore;
1931 ImGuiWindow* ActiveIdPreviousFrameWindow;
1932 ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
1933 float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
1934
1935 // [EXPERIMENTAL] Key/Input Ownership + Shortcut Routing system
1936 // - The idea is that instead of "eating" a given key, we can link to an owner.
1937 // - Input query can then read input by specifying ImGuiKeyOwner_Any (== 0), ImGuiKeyOwner_None (== -1) or a custom ID.
1938 // - Routing is requested ahead of time for a given chord (Key + Mods) and granted in NewFrame().
1939 ImGuiKeyOwnerData KeysOwnerData[ImGuiKey_NamedKey_COUNT];
1940 ImGuiKeyRoutingTable KeysRoutingTable;
1941 ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
1942 bool ActiveIdUsingAllKeyboardKeys; // Active widget will want to read all keyboard keys inputs. (FIXME: This is a shortcut for not taking ownership of 100+ keys but perhaps best to not have the inconsistency)
1943#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
1944 ImU32 ActiveIdUsingNavInputMask; // If you used this. Since (IMGUI_VERSION_NUM >= 18804) : 'g.ActiveIdUsingNavInputMask |= (1 << ImGuiNavInput_Cancel);' becomes 'SetKeyOwner(ImGuiKey_Escape, g.ActiveId) and/or SetKeyOwner(ImGuiKey_NavGamepadCancel, g.ActiveId);'
1945#endif
1946
1947 // Next window/item data
1948 ImGuiID CurrentFocusScopeId; // == g.FocusScopeStack.back()
1949 ImGuiItemFlags CurrentItemFlags; // == g.ItemFlagsStack.back()
1950 ImGuiID DebugLocateId; // Storage for DebugLocateItemOnHover() feature: this is read by ItemAdd() so we keep it in a hot/cached location
1951 ImGuiNextItemData NextItemData; // Storage for SetNextItem** functions
1952 ImGuiLastItemData LastItemData; // Storage for last submitted item (setup by ItemAdd)
1953 ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
1954 bool DebugShowGroupRects;
1955
1956 // Shared stacks
1957 ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
1958 ImVector<ImGuiStyleMod> StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
1959 ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() - inherited by Begin()
1960 ImVector<ImGuiID> FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
1961 ImVector<ImGuiItemFlags> ItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin()
1962 ImVector<ImGuiGroupData> GroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
1963 ImVector<ImGuiPopupData> OpenPopupStack; // Which popups are open (persistent)
1964 ImVector<ImGuiPopupData> BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
1965 ImVector<ImGuiNavTreeNodeData> NavTreeNodeStack; // Stack for TreeNode() when a NavLeft requested is emitted.
1966
1967 int BeginMenuCount;
1968
1969 // Viewports
1970 ImVector<ImGuiViewportP*> Viewports; // Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData.
1971
1972 // Gamepad/keyboard Navigation
1973 ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow'
1974 ImGuiID NavId; // Focused item for navigation
1975 ImGuiID NavFocusScopeId; // Identify a selection scope (selection code often wants to "clear other items" when landing on an item of the selection set)
1976 ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && (IsKeyPressed(ImGuiKey_Space) || IsKeyDown(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate)) ? NavId : 0, also set when calling ActivateItem()
1977 ImGuiID NavActivateDownId; // ~~ IsKeyDown(ImGuiKey_Space) || IsKeyDown(ImGuiKey_Enter) || IsKeyDown(ImGuiKey_NavGamepadActivate) ? NavId : 0
1978 ImGuiID NavActivatePressedId; // ~~ IsKeyPressed(ImGuiKey_Space) || IsKeyPressed(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate) ? NavId : 0 (no repeat)
1979 ImGuiActivateFlags NavActivateFlags;
1980 ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest).
1981 ImGuiID NavJustMovedToFocusScopeId; // Just navigated to this focus scope id (result of a successfully MoveRequest).
1982 ImGuiKeyChord NavJustMovedToKeyMods;
1983 ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame.
1984 ImGuiActivateFlags NavNextActivateFlags;
1985 ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS CAN ONLY BE ImGuiInputSource_Keyboard or ImGuiInputSource_Mouse
1986 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.
1987 ImGuiSelectionUserData NavLastValidSelectionUserData; // Last valid data passed to SetNextItemSelectionUser(), or -1. For current window. Not reset when focusing an item that doesn't have selection data.
1988 bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRectRel is valid
1989 bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
1990 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)
1991 bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
1992
1993 // Navigation: Init & Move Requests
1994 bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest this is to perform early out in ItemAdd()
1995 bool NavInitRequest; // Init request for appearing window to select first item
1996 bool NavInitRequestFromMove;
1997 ImGuiNavItemData NavInitResult; // Init request result (first item of the window, or one for which SetItemDefaultFocus() was called)
1998 bool NavMoveSubmitted; // Move request submitted, will process result on next NewFrame()
1999 bool NavMoveScoringItems; // Move request submitted, still scoring incoming items
2000 bool NavMoveForwardToNextFrame;
2001 ImGuiNavMoveFlags NavMoveFlags;
2002 ImGuiScrollFlags NavMoveScrollFlags;
2003 ImGuiKeyChord NavMoveKeyMods;
2004 ImGuiDir NavMoveDir; // Direction of the move request (left/right/up/down)
2005 ImGuiDir NavMoveDirForDebug;
2006 ImGuiDir NavMoveClipDir; // FIXME-NAV: Describe the purpose of this better. Might want to rename?
2007 ImRect NavScoringRect; // Rectangle used for scoring, in screen space. Based of window->NavRectRel[], modified for directional navigation scoring.
2008 ImRect NavScoringNoClipRect; // Some nav operations (such as PageUp/PageDown) enforce a region which clipper will attempt to always keep submitted
2009 int NavScoringDebugCount; // Metrics for debugging
2010 int NavTabbingDir; // Generally -1 or +1, 0 when tabbing without a nav id
2011 int NavTabbingCounter; // >0 when counting items for tabbing
2012 ImGuiNavItemData NavMoveResultLocal; // Best move request candidate within NavWindow
2013 ImGuiNavItemData NavMoveResultLocalVisible; // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
2014 ImGuiNavItemData NavMoveResultOther; // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
2015 ImGuiNavItemData NavTabbingResultFirst; // First tabbing request candidate within NavWindow and flattened hierarchy
2016
2017 // Navigation: Windowing (CTRL+TAB for list, or Menu button + keys or directional pads to move/resize)
2018 ImGuiKeyChord ConfigNavWindowingKeyNext; // = ImGuiMod_Ctrl | ImGuiKey_Tab, for reconfiguration (see #4828)
2019 ImGuiKeyChord ConfigNavWindowingKeyPrev; // = ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab
2020 ImGuiWindow* NavWindowingTarget; // Target window when doing CTRL+Tab (or Pad Menu + FocusPrev/Next), this window is temporarily displayed top-most!
2021 ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f, so the fade-out can stay on it.
2022 ImGuiWindow* NavWindowingListWindow; // Internal window actually listing the CTRL+Tab contents
2023 float NavWindowingTimer;
2024 float NavWindowingHighlightAlpha;
2025 bool NavWindowingToggleLayer;
2026 ImVec2 NavWindowingAccumDeltaPos;
2027 ImVec2 NavWindowingAccumDeltaSize;
2028
2029 // Render
2030 float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
2031
2032 // Drag and Drop
2033 bool DragDropActive;
2034 bool DragDropWithinSource; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag source.
2035 bool DragDropWithinTarget; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag target.
2036 ImGuiDragDropFlags DragDropSourceFlags;
2037 int DragDropSourceFrameCount;
2038 int DragDropMouseButton;
2039 ImGuiPayload DragDropPayload;
2040 ImRect DragDropTargetRect; // Store rectangle of current target candidate (we favor small targets when overlapping)
2041 ImGuiID DragDropTargetId;
2042 ImGuiDragDropFlags DragDropAcceptFlags;
2043 float DragDropAcceptIdCurrRectSurface; // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
2044 ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload)
2045 ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
2046 int DragDropAcceptFrameCount; // Last time a target expressed a desire to accept the source
2047 ImGuiID DragDropHoldJustPressedId; // Set when holding a payload just made ButtonBehavior() return a press.
2048 ImVector<unsigned char> DragDropPayloadBufHeap; // We don't expose the ImVector<> directly, ImGuiPayload only holds pointer+size
2049 unsigned char DragDropPayloadBufLocal[16]; // Local buffer for small payloads
2050
2051 // Clipper
2052 int ClipperTempDataStacked;
2053 ImVector<ImGuiListClipperData> ClipperTempData;
2054
2055 // Tables
2056 ImGuiTable* CurrentTable;
2057 int TablesTempDataStacked; // Temporary table data size (because we leave previous instances undestructed, we generally don't use TablesTempData.Size)
2058 ImVector<ImGuiTableTempData> TablesTempData; // Temporary table data (buffers reused/shared across instances, support nesting)
2059 ImPool<ImGuiTable> Tables; // Persistent table data
2060 ImVector<float> TablesLastTimeActive; // Last used timestamp of each tables (SOA, for efficient GC)
2061 ImVector<ImDrawChannel> DrawChannelsTempMergeBuffer;
2062
2063 // Tab bars
2064 ImGuiTabBar* CurrentTabBar;
2065 ImPool<ImGuiTabBar> TabBars;
2066 ImVector<ImGuiPtrOrIndex> CurrentTabBarStack;
2067 ImVector<ImGuiShrinkWidthItem> ShrinkWidthBuffer;
2068
2069 // Hover Delay system
2070 ImGuiID HoverItemDelayId;
2071 ImGuiID HoverItemDelayIdPreviousFrame;
2072 float HoverItemDelayTimer; // Currently used by IsItemHovered()
2073 float HoverItemDelayClearTimer; // Currently used by IsItemHovered(): grace time before g.TooltipHoverTimer gets cleared.
2074 ImGuiID HoverItemUnlockedStationaryId; // Mouse has once been stationary on this item. Only reset after departing the item.
2075 ImGuiID HoverWindowUnlockedStationaryId; // Mouse has once been stationary on this window. Only reset after departing the window.
2076
2077 // Mouse state
2078 ImGuiMouseCursor MouseCursor;
2079 float MouseStationaryTimer; // Time the mouse has been stationary (with some loose heuristic)
2080 ImVec2 MouseLastValidPos;
2081
2082 // Widget state
2083 ImGuiInputTextState InputTextState;
2084 ImGuiInputTextDeactivatedState InputTextDeactivatedState;
2085 ImFont InputTextPasswordFont;
2086 ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc.
2087 ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
2088 ImGuiID ColorEditCurrentID; // Set temporarily while inside of the parent-most ColorEdit4/ColorPicker4 (because they call each others).
2089 ImGuiID ColorEditSavedID; // ID we are saving/restoring HS for
2090 float ColorEditSavedHue; // Backup of last Hue associated to LastColor, so we can restore Hue in lossy RGB<>HSV round trips
2091 float ColorEditSavedSat; // Backup of last Saturation associated to LastColor, so we can restore Saturation in lossy RGB<>HSV round trips
2092 ImU32 ColorEditSavedColor; // RGB value with alpha set to 0.
2093 ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker.
2094 ImGuiComboPreviewData ComboPreviewData;
2095 ImRect WindowResizeBorderExpectedRect; // Expected border rect, switch to relative edit if moving
2096 bool WindowResizeRelativeMode;
2097 float SliderGrabClickOffset;
2098 float SliderCurrentAccum; // Accumulated slider delta when using navigation controls.
2099 bool SliderCurrentAccumDirty; // Has the accumulated slider delta changed since last time we tried to apply it?
2100 bool DragCurrentAccumDirty;
2101 float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
2102 float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
2103 float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
2104 float DisabledAlphaBackup; // Backup for style.Alpha for BeginDisabled()
2105 short DisabledStackSize;
2106 short LockMarkEdited;
2107 short TooltipOverrideCount;
2108 ImVector<char> ClipboardHandlerData; // If no custom clipboard handler is defined
2109 ImVector<ImGuiID> MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once
2110 ImGuiTypingSelectState TypingSelectState; // State for GetTypingSelectRequest()
2111
2112 // Platform support
2113 ImGuiPlatformImeData PlatformImeData; // Data updated by current frame
2114 ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data (when changing we will call io.SetPlatformImeDataFn
2115
2116 // Settings
2117 bool SettingsLoaded;
2118 float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero
2119 ImGuiTextBuffer SettingsIniData; // In memory .ini settings
2120 ImVector<ImGuiSettingsHandler> SettingsHandlers; // List of .ini settings handlers
2121 ImChunkStream<ImGuiWindowSettings> SettingsWindows; // ImGuiWindow .ini settings entries
2122 ImChunkStream<ImGuiTableSettings> SettingsTables; // ImGuiTable .ini settings entries
2123 ImVector<ImGuiContextHook> Hooks; // Hooks for extensions (e.g. test engine)
2124 ImGuiID HookIdNext; // Next available HookId
2125
2126 // Localization
2127 const char* LocalizationTable[ImGuiLocKey_COUNT];
2128
2129 // Capture/Logging
2130 bool LogEnabled; // Currently capturing
2131 ImGuiLogType LogType; // Capture target
2132 ImFileHandle LogFile; // If != NULL log to stdout/ file
2133 ImGuiTextBuffer LogBuffer; // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
2134 const char* LogNextPrefix;
2135 const char* LogNextSuffix;
2136 float LogLinePosY;
2137 bool LogLineFirstItem;
2138 int LogDepthRef;
2139 int LogDepthToExpand;
2140 int LogDepthToExpandDefault; // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call.
2141
2142 // Debug Tools
2143 ImGuiDebugLogFlags DebugLogFlags;
2144 ImGuiTextBuffer DebugLogBuf;
2145 ImGuiTextIndex DebugLogIndex;
2146 ImU8 DebugLogClipperAutoDisableFrames;
2147 ImU8 DebugLocateFrames; // For DebugLocateItemOnHover(). This is used together with DebugLocateId which is in a hot/cached spot above.
2148 ImS8 DebugBeginReturnValueCullDepth; // Cycle between 0..9 then wrap around.
2149 bool DebugItemPickerActive; // Item picker is active (started with DebugStartItemPicker())
2150 ImU8 DebugItemPickerMouseButton;
2151 ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this ID
2152 ImGuiMetricsConfig DebugMetricsConfig;
2153 ImGuiIDStackTool DebugIDStackTool;
2154 ImGuiDebugAllocInfo DebugAllocInfo;
2155
2156 // Misc
2157 float FramerateSecPerFrame[60]; // Calculate estimate of framerate for user over the last 60 frames..
2158 int FramerateSecPerFrameIdx;
2159 int FramerateSecPerFrameCount;
2160 float FramerateSecPerFrameAccum;
2161 int WantCaptureMouseNextFrame; // Explicit capture override via SetNextFrameWantCaptureMouse()/SetNextFrameWantCaptureKeyboard(). Default to -1.
2162 int WantCaptureKeyboardNextFrame; // "
2163 int WantTextInputNextFrame;
2164 ImVector<char> TempBuffer; // Temporary text buffer
2165
2166 ImGuiContext(ImFontAtlas* shared_font_atlas)
2167 {
2168 IO.Ctx = this;
2169 InputTextState.Ctx = this;
2170
2171 Initialized = false;
2172 FontAtlasOwnedByContext = shared_font_atlas ? false : true;
2173 Font = NULL;
2174 FontSize = FontBaseSize = 0.0f;
2175 IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
2176 Time = 0.0f;
2177 FrameCount = 0;
2178 FrameCountEnded = FrameCountRendered = -1;
2179 WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false;
2180 GcCompactAll = false;
2181 TestEngineHookItems = false;
2182 TestEngine = NULL;
2183
2184 InputEventsNextMouseSource = ImGuiMouseSource_Mouse;
2185 InputEventsNextEventId = 1;
2186
2187 WindowsActiveCount = 0;
2188 CurrentWindow = NULL;
2189 HoveredWindow = NULL;
2190 HoveredWindowUnderMovingWindow = NULL;
2191 MovingWindow = NULL;
2192 WheelingWindow = NULL;
2193 WheelingWindowStartFrame = WheelingWindowScrolledFrame = -1;
2194 WheelingWindowReleaseTimer = 0.0f;
2195
2196 DebugHookIdInfo = 0;
2197 HoveredId = HoveredIdPreviousFrame = 0;
2198 HoveredIdAllowOverlap = false;
2199 HoveredIdDisabled = false;
2200 HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
2201 ActiveId = 0;
2202 ActiveIdIsAlive = 0;
2203 ActiveIdTimer = 0.0f;
2204 ActiveIdIsJustActivated = false;
2205 ActiveIdAllowOverlap = false;
2206 ActiveIdNoClearOnFocusLoss = false;
2207 ActiveIdHasBeenPressedBefore = false;
2208 ActiveIdHasBeenEditedBefore = false;
2209 ActiveIdHasBeenEditedThisFrame = false;
2210 ActiveIdClickOffset = ImVec2(-1, -1);
2211 ActiveIdWindow = NULL;
2212 ActiveIdSource = ImGuiInputSource_None;
2213 ActiveIdMouseButton = -1;
2214 ActiveIdPreviousFrame = 0;
2215 ActiveIdPreviousFrameIsAlive = false;
2216 ActiveIdPreviousFrameHasBeenEditedBefore = false;
2217 ActiveIdPreviousFrameWindow = NULL;
2218 LastActiveId = 0;
2219 LastActiveIdTimer = 0.0f;
2220
2221 ActiveIdUsingNavDirMask = 0x00;
2222 ActiveIdUsingAllKeyboardKeys = false;
2223#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
2224 ActiveIdUsingNavInputMask = 0x00;
2225#endif
2226
2227 CurrentFocusScopeId = 0;
2228 CurrentItemFlags = ImGuiItemFlags_None;
2229 DebugShowGroupRects = false;
2230 BeginMenuCount = 0;
2231
2232 NavWindow = NULL;
2233 NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
2234 NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
2235 NavActivateFlags = NavNextActivateFlags = ImGuiActivateFlags_None;
2236 NavJustMovedToKeyMods = ImGuiMod_None;
2237 NavInputSource = ImGuiInputSource_Keyboard;
2238 NavLayer = ImGuiNavLayer_Main;
2239 NavLastValidSelectionUserData = ImGuiSelectionUserData_Invalid;
2240 NavIdIsAlive = false;
2241 NavMousePosDirty = false;
2242 NavDisableHighlight = true;
2243 NavDisableMouseHover = false;
2244 NavAnyRequest = false;
2245 NavInitRequest = false;
2246 NavInitRequestFromMove = false;
2247 NavMoveSubmitted = false;
2248 NavMoveScoringItems = false;
2249 NavMoveForwardToNextFrame = false;
2250 NavMoveFlags = ImGuiNavMoveFlags_None;
2251 NavMoveScrollFlags = ImGuiScrollFlags_None;
2252 NavMoveKeyMods = ImGuiMod_None;
2253 NavMoveDir = NavMoveDirForDebug = NavMoveClipDir = ImGuiDir_None;
2254 NavScoringDebugCount = 0;
2255 NavTabbingDir = 0;
2256 NavTabbingCounter = 0;
2257
2258 ConfigNavWindowingKeyNext = ImGuiMod_Ctrl | ImGuiKey_Tab;
2259 ConfigNavWindowingKeyPrev = ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab;
2260 NavWindowingTarget = NavWindowingTargetAnim = NavWindowingListWindow = NULL;
2261 NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
2262 NavWindowingToggleLayer = false;
2263
2264 DimBgRatio = 0.0f;
2265
2266 DragDropActive = DragDropWithinSource = DragDropWithinTarget = false;
2267 DragDropSourceFlags = ImGuiDragDropFlags_None;
2268 DragDropSourceFrameCount = -1;
2269 DragDropMouseButton = -1;
2270 DragDropTargetId = 0;
2271 DragDropAcceptFlags = ImGuiDragDropFlags_None;
2272 DragDropAcceptIdCurrRectSurface = 0.0f;
2273 DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
2274 DragDropAcceptFrameCount = -1;
2275 DragDropHoldJustPressedId = 0;
2276 memset(s: DragDropPayloadBufLocal, c: 0, n: sizeof(DragDropPayloadBufLocal));
2277
2278 ClipperTempDataStacked = 0;
2279
2280 CurrentTable = NULL;
2281 TablesTempDataStacked = 0;
2282 CurrentTabBar = NULL;
2283
2284 HoverItemDelayId = HoverItemDelayIdPreviousFrame = HoverItemUnlockedStationaryId = HoverWindowUnlockedStationaryId = 0;
2285 HoverItemDelayTimer = HoverItemDelayClearTimer = 0.0f;
2286
2287 MouseCursor = ImGuiMouseCursor_Arrow;
2288 MouseStationaryTimer = 0.0f;
2289
2290 TempInputId = 0;
2291 ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_;
2292 ColorEditCurrentID = ColorEditSavedID = 0;
2293 ColorEditSavedHue = ColorEditSavedSat = 0.0f;
2294 ColorEditSavedColor = 0;
2295 WindowResizeRelativeMode = false;
2296 SliderGrabClickOffset = 0.0f;
2297 SliderCurrentAccum = 0.0f;
2298 SliderCurrentAccumDirty = false;
2299 DragCurrentAccumDirty = false;
2300 DragCurrentAccum = 0.0f;
2301 DragSpeedDefaultRatio = 1.0f / 100.0f;
2302 ScrollbarClickDeltaToGrabCenter = 0.0f;
2303 DisabledAlphaBackup = 0.0f;
2304 DisabledStackSize = 0;
2305 LockMarkEdited = 0;
2306 TooltipOverrideCount = 0;
2307
2308 PlatformImeData.InputPos = ImVec2(0.0f, 0.0f);
2309 PlatformImeDataPrev.InputPos = ImVec2(-1.0f, -1.0f); // Different to ensure initial submission
2310
2311 SettingsLoaded = false;
2312 SettingsDirtyTimer = 0.0f;
2313 HookIdNext = 0;
2314
2315 memset(s: LocalizationTable, c: 0, n: sizeof(LocalizationTable));
2316
2317 LogEnabled = false;
2318 LogType = ImGuiLogType_None;
2319 LogNextPrefix = LogNextSuffix = NULL;
2320 LogFile = NULL;
2321 LogLinePosY = FLT_MAX;
2322 LogLineFirstItem = false;
2323 LogDepthRef = 0;
2324 LogDepthToExpand = LogDepthToExpandDefault = 2;
2325
2326 DebugLogFlags = ImGuiDebugLogFlags_OutputToTTY;
2327 DebugLocateId = 0;
2328 DebugLogClipperAutoDisableFrames = 0;
2329 DebugLocateFrames = 0;
2330 DebugBeginReturnValueCullDepth = -1;
2331 DebugItemPickerActive = false;
2332 DebugItemPickerMouseButton = ImGuiMouseButton_Left;
2333 DebugItemPickerBreakId = 0;
2334
2335 memset(s: FramerateSecPerFrame, c: 0, n: sizeof(FramerateSecPerFrame));
2336 FramerateSecPerFrameIdx = FramerateSecPerFrameCount = 0;
2337 FramerateSecPerFrameAccum = 0.0f;
2338 WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
2339 }
2340};
2341
2342//-----------------------------------------------------------------------------
2343// [SECTION] ImGuiWindowTempData, ImGuiWindow
2344//-----------------------------------------------------------------------------
2345
2346// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
2347// (That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered..)
2348// (This doesn't need a constructor because we zero-clear it as part of ImGuiWindow and all frame-temporary data are setup on Begin)
2349struct IMGUI_API ImGuiWindowTempData
2350{
2351 // Layout
2352 ImVec2 CursorPos; // Current emitting position, in absolute coordinates.
2353 ImVec2 CursorPosPrevLine;
2354 ImVec2 CursorStartPos; // Initial position after Begin(), generally ~ window position + WindowPadding.
2355 ImVec2 CursorMaxPos; // Used to implicitly calculate ContentSize at the beginning of next frame, for scrolling range and auto-resize. Always growing during the frame.
2356 ImVec2 IdealMaxPos; // Used to implicitly calculate ContentSizeIdeal at the beginning of next frame, for auto-resize only. Always growing during the frame.
2357 ImVec2 CurrLineSize;
2358 ImVec2 PrevLineSize;
2359 float CurrLineTextBaseOffset; // Baseline offset (0.0f by default on a new line, generally == style.FramePadding.y when a framed item has been added).
2360 float PrevLineTextBaseOffset;
2361 bool IsSameLine;
2362 bool IsSetPos;
2363 ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
2364 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.
2365 ImVec1 GroupOffset;
2366 ImVec2 CursorStartPosLossyness;// Record the loss of precision of CursorStartPos due to really large scrolling amount. This is used by clipper to compensate and fix the most common use case of large scroll area.
2367
2368 // Keyboard/Gamepad navigation
2369 ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
2370 short NavLayersActiveMask; // Which layers have been written to (result from previous frame)
2371 short NavLayersActiveMaskNext;// Which layers have been written to (accumulator for current frame)
2372 bool NavIsScrollPushableX; // Set when current work location may be scrolled horizontally when moving left / right. This is generally always true UNLESS within a column.
2373 bool NavHideHighlightOneFrame;
2374 bool NavWindowHasScrollY; // Set per window when scrolling can be used (== ScrollMax.y > 0.0f)
2375
2376 // Miscellaneous
2377 bool MenuBarAppending; // FIXME: Remove this
2378 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.
2379 ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items measurement
2380 int TreeDepth; // Current tree depth.
2381 ImU32 TreeJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary.
2382 ImVector<ImGuiWindow*> ChildWindows;
2383 ImGuiStorage* StateStorage; // Current persistent per-window storage (store e.g. tree node open/close state)
2384 ImGuiOldColumns* CurrentColumns; // Current columns set
2385 int CurrentTableIdx; // Current table index (into g.Tables)
2386 ImGuiLayoutType LayoutType;
2387 ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin()
2388
2389 // Local parameters stacks
2390 // 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.
2391 float ItemWidth; // Current item width (>0.0: width in pixels, <0.0: align xx pixels to the right of window).
2392 float TextWrapPos; // Current text wrap pos.
2393 ImVector<float> ItemWidthStack; // Store item widths to restore (attention: .back() is not == ItemWidth)
2394 ImVector<float> TextWrapPosStack; // Store text wrap pos to restore (attention: .back() is not == TextWrapPos)
2395};
2396
2397// Storage for one window
2398struct IMGUI_API ImGuiWindow
2399{
2400 ImGuiContext* Ctx; // Parent UI context (needs to be set explicitly by parent).
2401 char* Name; // Window name, owned by the window.
2402 ImGuiID ID; // == ImHashStr(Name)
2403 ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
2404 ImGuiChildFlags ChildFlags; // Set when window is a child window. See enum ImGuiChildFlags_
2405 ImGuiViewportP* Viewport; // Always set in Begin(). Inactive windows may have a NULL value here if their viewport was discarded.
2406 ImVec2 Pos; // Position (always rounded-up to nearest pixel)
2407 ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
2408 ImVec2 SizeFull; // Size when non collapsed
2409 ImVec2 ContentSize; // Size of contents/scrollable client area (calculated from the extents reach of the cursor) from previous frame. Does not include window decoration or window padding.
2410 ImVec2 ContentSizeIdeal;
2411 ImVec2 ContentSizeExplicit; // Size of contents/scrollable client area explicitly request by the user via SetNextWindowContentSize().
2412 ImVec2 WindowPadding; // Window padding at the time of Begin().
2413 float WindowRounding; // Window rounding at the time of Begin(). May be clamped lower to avoid rendering artifacts with title bar, menu bar etc.
2414 float WindowBorderSize; // Window border size at the time of Begin().
2415 float DecoOuterSizeX1, DecoOuterSizeY1; // Left/Up offsets. Sum of non-scrolling outer decorations (X1 generally == 0.0f. Y1 generally = TitleBarHeight + MenuBarHeight). Locked during Begin().
2416 float DecoOuterSizeX2, DecoOuterSizeY2; // Right/Down offsets (X2 generally == ScrollbarSize.x, Y2 == ScrollbarSizes.y).
2417 float DecoInnerSizeX1, DecoInnerSizeY1; // Applied AFTER/OVER InnerRect. Specialized for Tables as they use specialized form of clipping and frozen rows/columns are inside InnerRect (and not part of regular decoration sizes).
2418 int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)!
2419 ImGuiID MoveId; // == window->GetID("#MOVE")
2420 ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window)
2421 ImVec2 Scroll;
2422 ImVec2 ScrollMax;
2423 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)
2424 ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
2425 ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold
2426 ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
2427 bool ScrollbarX, ScrollbarY; // Are scrollbars visible?
2428 bool Active; // Set to true on Begin(), unless Collapsed
2429 bool WasActive;
2430 bool WriteAccessed; // Set to true when any widget access the current window
2431 bool Collapsed; // Set when collapsing window to become only title-bar
2432 bool WantCollapseToggle;
2433 bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
2434 bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
2435 bool Hidden; // Do not display (== HiddenFrames*** > 0)
2436 bool IsFallbackWindow; // Set on the "Debug##Default" window.
2437 bool IsExplicitChild; // Set when passed _ChildWindow, left to false by BeginDocked()
2438 bool HasCloseButton; // Set when the window has a close button (p_open != NULL)
2439 signed char ResizeBorderHovered; // Current border being hovered for resize (-1: none, otherwise 0-3)
2440 signed char ResizeBorderHeld; // Current border being held for resize (-1: none, otherwise 0-3)
2441 short BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
2442 short BeginCountPreviousFrame; // Number of Begin() during the previous frame
2443 short BeginOrderWithinParent; // Begin() order within immediate parent window, if we are a child window. Otherwise 0.
2444 short BeginOrderWithinContext; // Begin() order within entire imgui context. This is mostly used for debugging submission order related issues.
2445 short FocusOrder; // Order within WindowsFocusOrder[], altered when windows are focused.
2446 ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
2447 ImS8 AutoFitFramesX, AutoFitFramesY;
2448 bool AutoFitOnlyGrows;
2449 ImGuiDir AutoPosLastDirection;
2450 ImS8 HiddenFramesCanSkipItems; // Hide the window for N frames
2451 ImS8 HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size
2452 ImS8 HiddenFramesForRenderOnly; // Hide the window until frame N at Render() time only
2453 ImS8 DisableInputsFrames; // Disable window interactions for N frames
2454 ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use.
2455 ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use.
2456 ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use.
2457 ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
2458 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.
2459
2460 ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack. (In theory this should be in the TempData structure)
2461 ImGuiWindowTempData DC; // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name.
2462
2463 // The best way to understand what those rectangles are is to use the 'Metrics->Tools->Show Windows Rectangles' viewer.
2464 // The main 'OuterRect', omitted as a field, is window->Rect().
2465 ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
2466 ImRect InnerRect; // Inner rectangle (omit title bar, menu bar, scroll bar)
2467 ImRect InnerClipRect; // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect.
2468 ImRect WorkRect; // Initially covers the whole scrolling region. Reduced by containers e.g columns/tables when active. Shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward).
2469 ImRect ParentWorkRect; // Backup of WorkRect before entering a container such as columns/tables. Used by e.g. SpanAllColumns functions to easily access. Stacked containers are responsible for maintaining this. // FIXME-WORKRECT: Could be a stack?
2470 ImRect ClipRect; // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back().
2471 ImRect ContentRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
2472 ImVec2ih HitTestHoleSize; // Define an optional rectangular hole where mouse will pass-through the window.
2473 ImVec2ih HitTestHoleOffset;
2474
2475 int LastFrameActive; // Last frame number the window was Active.
2476 float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there)
2477 float ItemWidthDefault;
2478 ImGuiStorage StateStorage;
2479 ImVector<ImGuiOldColumns> ColumnsStorage;
2480 float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale()
2481 int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back)
2482
2483 ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
2484 ImDrawList DrawListInst;
2485 ImGuiWindow* ParentWindow; // If we are a child _or_ popup _or_ docked window, this is pointing to our parent. Otherwise NULL.
2486 ImGuiWindow* ParentWindowInBeginStack;
2487 ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. Doesn't cross through popups/dock nodes.
2488 ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child.
2489 ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
2490 ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
2491
2492 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.)
2493 ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1)
2494 ImRect NavRectRel[ImGuiNavLayer_COUNT]; // Reference rectangle, in window relative space
2495 ImVec2 NavPreferredScoringPosRel[ImGuiNavLayer_COUNT]; // Preferred X/Y position updated when moving on a given axis, reset to FLT_MAX.
2496 ImGuiID NavRootFocusScopeId; // Focus Scope ID at the time of Begin()
2497
2498 int MemoryDrawListIdxCapacity; // Backup of last idx/vtx count, so when waking up the window we can preallocate and avoid iterative alloc/copy
2499 int MemoryDrawListVtxCapacity;
2500 bool MemoryCompacted; // Set when window extraneous data have been garbage collected
2501
2502public:
2503 ImGuiWindow(ImGuiContext* context, const char* name);
2504 ~ImGuiWindow();
2505
2506 ImGuiID GetID(const char* str, const char* str_end = NULL);
2507 ImGuiID GetID(const void* ptr);
2508 ImGuiID GetID(int n);
2509 ImGuiID GetIDFromRectangle(const ImRect& r_abs);
2510
2511 // We don't use g.FontSize because the window may be != g.CurrentWindow.
2512 ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
2513 float CalcFontSize() const { ImGuiContext& g = *Ctx; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
2514 float TitleBarHeight() const { ImGuiContext& g = *Ctx; return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + g.Style.FramePadding.y * 2.0f; }
2515 ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
2516 float MenuBarHeight() const { ImGuiContext& g = *Ctx; return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + g.Style.FramePadding.y * 2.0f : 0.0f; }
2517 ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
2518};
2519
2520//-----------------------------------------------------------------------------
2521// [SECTION] Tab bar, Tab item support
2522//-----------------------------------------------------------------------------
2523
2524// Extend ImGuiTabBarFlags_
2525enum ImGuiTabBarFlagsPrivate_
2526{
2527 ImGuiTabBarFlags_DockNode = 1 << 20, // Part of a dock node [we don't use this in the master branch but it facilitate branch syncing to keep this around]
2528 ImGuiTabBarFlags_IsFocused = 1 << 21,
2529 ImGuiTabBarFlags_SaveSettings = 1 << 22, // FIXME: Settings are handled by the docking system, this only request the tab bar to mark settings dirty when reordering tabs
2530};
2531
2532// Extend ImGuiTabItemFlags_
2533enum ImGuiTabItemFlagsPrivate_
2534{
2535 ImGuiTabItemFlags_SectionMask_ = ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing,
2536 ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
2537 ImGuiTabItemFlags_Button = 1 << 21, // Used by TabItemButton, change the tab item behavior to mimic a button
2538};
2539
2540// Storage for one active tab item (sizeof() 40 bytes)
2541struct ImGuiTabItem
2542{
2543 ImGuiID ID;
2544 ImGuiTabItemFlags Flags;
2545 int LastFrameVisible;
2546 int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance
2547 float Offset; // Position relative to beginning of tab
2548 float Width; // Width currently displayed
2549 float ContentWidth; // Width of label, stored during BeginTabItem() call
2550 float RequestedWidth; // Width optionally requested by caller, -1.0f is unused
2551 ImS32 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
2552 ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
2553 ImS16 IndexDuringLayout; // Index only used during TabBarLayout(). Tabs gets reordered so 'Tabs[n].IndexDuringLayout == n' but may mismatch during additions.
2554 bool WantClose; // Marked as closed by SetTabItemClosed()
2555
2556 ImGuiTabItem() { memset(s: this, c: 0, n: sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; RequestedWidth = -1.0f; NameOffset = -1; BeginOrder = IndexDuringLayout = -1; }
2557};
2558
2559// Storage for a tab bar (sizeof() 152 bytes)
2560struct IMGUI_API ImGuiTabBar
2561{
2562 ImVector<ImGuiTabItem> Tabs;
2563 ImGuiTabBarFlags Flags;
2564 ImGuiID ID; // Zero for tab-bars used by docking
2565 ImGuiID SelectedTabId; // Selected tab/window
2566 ImGuiID NextSelectedTabId; // Next selected tab/window. Will also trigger a scrolling animation
2567 ImGuiID VisibleTabId; // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview)
2568 int CurrFrameVisible;
2569 int PrevFrameVisible;
2570 ImRect BarRect;
2571 float CurrTabsContentsHeight;
2572 float PrevTabsContentsHeight; // Record the height of contents submitted below the tab bar
2573 float WidthAllTabs; // Actual width of all tabs (locked during layout)
2574 float WidthAllTabsIdeal; // Ideal width if all tabs were visible and not clipped
2575 float ScrollingAnim;
2576 float ScrollingTarget;
2577 float ScrollingTargetDistToVisibility;
2578 float ScrollingSpeed;
2579 float ScrollingRectMinX;
2580 float ScrollingRectMaxX;
2581 float SeparatorMinX;
2582 float SeparatorMaxX;
2583 ImGuiID ReorderRequestTabId;
2584 ImS16 ReorderRequestOffset;
2585 ImS8 BeginCount;
2586 bool WantLayout;
2587 bool VisibleTabWasSubmitted;
2588 bool TabsAddedNew; // Set to true when a new tab item or button has been added to the tab bar during last frame
2589 ImS16 TabsActiveCount; // Number of tabs submitted this frame.
2590 ImS16 LastTabItemIdx; // Index of last BeginTabItem() tab for use by EndTabItem()
2591 float ItemSpacingY;
2592 ImVec2 FramePadding; // style.FramePadding locked at the time of BeginTabBar()
2593 ImVec2 BackupCursorPos;
2594 ImGuiTextBuffer TabsNames; // For non-docking tab bar we re-append names in a contiguous buffer.
2595
2596 ImGuiTabBar();
2597};
2598
2599//-----------------------------------------------------------------------------
2600// [SECTION] Table support
2601//-----------------------------------------------------------------------------
2602
2603#define IM_COL32_DISABLE IM_COL32(0,0,0,1) // Special sentinel code which cannot be used as a regular color.
2604#define IMGUI_TABLE_MAX_COLUMNS 512 // May be further lifted
2605
2606// Our current column maximum is 64 but we may raise that in the future.
2607typedef ImS16 ImGuiTableColumnIdx;
2608typedef ImU16 ImGuiTableDrawChannelIdx;
2609
2610// [Internal] sizeof() ~ 112
2611// We use the terminology "Enabled" to refer to a column that is not Hidden by user/api.
2612// We use the terminology "Clipped" to refer to a column that is out of sight because of scrolling/clipping.
2613// This is in contrast with some user-facing api such as IsItemVisible() / IsRectVisible() which use "Visible" to mean "not clipped".
2614struct ImGuiTableColumn
2615{
2616 ImGuiTableColumnFlags Flags; // Flags after some patching (not directly same as provided by user). See ImGuiTableColumnFlags_
2617 float WidthGiven; // Final/actual width visible == (MaxX - MinX), locked in TableUpdateLayout(). May be > WidthRequest to honor minimum width, may be < WidthRequest to honor shrinking columns down in tight space.
2618 float MinX; // Absolute positions
2619 float MaxX;
2620 float WidthRequest; // Master width absolute value when !(Flags & _WidthStretch). When Stretch this is derived every frame from StretchWeight in TableUpdateLayout()
2621 float WidthAuto; // Automatic width
2622 float StretchWeight; // Master width weight when (Flags & _WidthStretch). Often around ~1.0f initially.
2623 float InitStretchWeightOrWidth; // Value passed to TableSetupColumn(). For Width it is a content width (_without padding_).
2624 ImRect ClipRect; // Clipping rectangle for the column
2625 ImGuiID UserID; // Optional, value passed to TableSetupColumn()
2626 float WorkMinX; // Contents region min ~(MinX + CellPaddingX + CellSpacingX1) == cursor start position when entering column
2627 float WorkMaxX; // Contents region max ~(MaxX - CellPaddingX - CellSpacingX2)
2628 float ItemWidth; // Current item width for the column, preserved across rows
2629 float ContentMaxXFrozen; // Contents maximum position for frozen rows (apart from headers), from which we can infer content width.
2630 float ContentMaxXUnfrozen;
2631 float ContentMaxXHeadersUsed; // Contents maximum position for headers rows (regardless of freezing). TableHeader() automatically softclip itself + report ideal desired size, to avoid creating extraneous draw calls
2632 float ContentMaxXHeadersIdeal;
2633 ImS16 NameOffset; // Offset into parent ColumnsNames[]
2634 ImGuiTableColumnIdx DisplayOrder; // Index within Table's IndexToDisplayOrder[] (column may be reordered by users)
2635 ImGuiTableColumnIdx IndexWithinEnabledSet; // Index within enabled/visible set (<= IndexToDisplayOrder)
2636 ImGuiTableColumnIdx PrevEnabledColumn; // Index of prev enabled/visible column within Columns[], -1 if first enabled/visible column
2637 ImGuiTableColumnIdx NextEnabledColumn; // Index of next enabled/visible column within Columns[], -1 if last enabled/visible column
2638 ImGuiTableColumnIdx SortOrder; // Index of this column within sort specs, -1 if not sorting on this column, 0 for single-sort, may be >0 on multi-sort
2639 ImGuiTableDrawChannelIdx DrawChannelCurrent; // Index within DrawSplitter.Channels[]
2640 ImGuiTableDrawChannelIdx DrawChannelFrozen; // Draw channels for frozen rows (often headers)
2641 ImGuiTableDrawChannelIdx DrawChannelUnfrozen; // Draw channels for unfrozen rows
2642 bool IsEnabled; // IsUserEnabled && (Flags & ImGuiTableColumnFlags_Disabled) == 0
2643 bool IsUserEnabled; // Is the column not marked Hidden by the user? (unrelated to being off view, e.g. clipped by scrolling).
2644 bool IsUserEnabledNextFrame;
2645 bool IsVisibleX; // Is actually in view (e.g. overlapping the host window clipping rectangle, not scrolled).
2646 bool IsVisibleY;
2647 bool IsRequestOutput; // Return value for TableSetColumnIndex() / TableNextColumn(): whether we request user to output contents or not.
2648 bool IsSkipItems; // Do we want item submissions to this column to be completely ignored (no layout will happen).
2649 bool IsPreserveWidthAuto;
2650 ImS8 NavLayerCurrent; // ImGuiNavLayer in 1 byte
2651 ImU8 AutoFitQueue; // Queue of 8 values for the next 8 frames to request auto-fit
2652 ImU8 CannotSkipItemsQueue; // Queue of 8 values for the next 8 frames to disable Clipped/SkipItem
2653 ImU8 SortDirection : 2; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending
2654 ImU8 SortDirectionsAvailCount : 2; // Number of available sort directions (0 to 3)
2655 ImU8 SortDirectionsAvailMask : 4; // Mask of available sort directions (1-bit each)
2656 ImU8 SortDirectionsAvailList; // Ordered list of available sort directions (2-bits each, total 8-bits)
2657
2658 ImGuiTableColumn()
2659 {
2660 memset(s: this, c: 0, n: sizeof(*this));
2661 StretchWeight = WidthRequest = -1.0f;
2662 NameOffset = -1;
2663 DisplayOrder = IndexWithinEnabledSet = -1;
2664 PrevEnabledColumn = NextEnabledColumn = -1;
2665 SortOrder = -1;
2666 SortDirection = ImGuiSortDirection_None;
2667 DrawChannelCurrent = DrawChannelFrozen = DrawChannelUnfrozen = (ImU8)-1;
2668 }
2669};
2670
2671// Transient cell data stored per row.
2672// sizeof() ~ 6
2673struct ImGuiTableCellData
2674{
2675 ImU32 BgColor; // Actual color
2676 ImGuiTableColumnIdx Column; // Column number
2677};
2678
2679// Per-instance data that needs preserving across frames (seemingly most others do not need to be preserved aside from debug needs. Does that means they could be moved to ImGuiTableTempData?)
2680// sizeof() ~ 24 bytes
2681struct ImGuiTableInstanceData
2682{
2683 ImGuiID TableInstanceID;
2684 float LastOuterHeight; // Outer height from last frame
2685 float LastTopHeadersRowHeight; // Height of first consecutive header rows from last frame (FIXME: this is used assuming consecutive headers are in same frozen set)
2686 float LastFrozenHeight; // Height of frozen section from last frame
2687 int HoveredRowLast; // Index of row which was hovered last frame.
2688 int HoveredRowNext; // Index of row hovered this frame, set after encountering it.
2689
2690 ImGuiTableInstanceData() { TableInstanceID = 0; LastOuterHeight = LastTopHeadersRowHeight = LastFrozenHeight = 0.0f; HoveredRowLast = HoveredRowNext = -1; }
2691};
2692
2693// FIXME-TABLE: more transient data could be stored in a stacked ImGuiTableTempData: e.g. SortSpecs, incoming RowData
2694// sizeof() ~ 580 bytes + heap allocs described in TableBeginInitMemory()
2695struct IMGUI_API ImGuiTable
2696{
2697 ImGuiID ID;
2698 ImGuiTableFlags Flags;
2699 void* RawData; // Single allocation to hold Columns[], DisplayOrderToIndex[] and RowCellData[]
2700 ImGuiTableTempData* TempData; // Transient data while table is active. Point within g.CurrentTableStack[]
2701 ImSpan<ImGuiTableColumn> Columns; // Point within RawData[]
2702 ImSpan<ImGuiTableColumnIdx> DisplayOrderToIndex; // Point within RawData[]. Store display order of columns (when not reordered, the values are 0...Count-1)
2703 ImSpan<ImGuiTableCellData> RowCellData; // Point within RawData[]. Store cells background requests for current row.
2704 ImBitArrayPtr EnabledMaskByDisplayOrder; // Column DisplayOrder -> IsEnabled map
2705 ImBitArrayPtr EnabledMaskByIndex; // Column Index -> IsEnabled map (== not hidden by user/api) in a format adequate for iterating column without touching cold data
2706 ImBitArrayPtr VisibleMaskByIndex; // Column Index -> IsVisibleX|IsVisibleY map (== not hidden by user/api && not hidden by scrolling/cliprect)
2707 ImGuiTableFlags SettingsLoadedFlags; // Which data were loaded from the .ini file (e.g. when order is not altered we won't save order)
2708 int SettingsOffset; // Offset in g.SettingsTables
2709 int LastFrameActive;
2710 int ColumnsCount; // Number of columns declared in BeginTable()
2711 int CurrentRow;
2712 int CurrentColumn;
2713 ImS16 InstanceCurrent; // Count of BeginTable() calls with same ID in the same frame (generally 0). This is a little bit similar to BeginCount for a window, but multiple table with same ID look are multiple tables, they are just synched.
2714 ImS16 InstanceInteracted; // Mark which instance (generally 0) of the same ID is being interacted with
2715 float RowPosY1;
2716 float RowPosY2;
2717 float RowMinHeight; // Height submitted to TableNextRow()
2718 float RowCellPaddingY; // Top and bottom padding. Reloaded during row change.
2719 float RowTextBaseline;
2720 float RowIndentOffsetX;
2721 ImGuiTableRowFlags RowFlags : 16; // Current row flags, see ImGuiTableRowFlags_
2722 ImGuiTableRowFlags LastRowFlags : 16;
2723 int RowBgColorCounter; // Counter for alternating background colors (can be fast-forwarded by e.g clipper), not same as CurrentRow because header rows typically don't increase this.
2724 ImU32 RowBgColor[2]; // Background color override for current row.
2725 ImU32 BorderColorStrong;
2726 ImU32 BorderColorLight;
2727 float BorderX1;
2728 float BorderX2;
2729 float HostIndentX;
2730 float MinColumnWidth;
2731 float OuterPaddingX;
2732 float CellPaddingX; // Padding from each borders. Locked in BeginTable()/Layout.
2733 float CellSpacingX1; // Spacing between non-bordered cells. Locked in BeginTable()/Layout.
2734 float CellSpacingX2;
2735 float InnerWidth; // User value passed to BeginTable(), see comments at the top of BeginTable() for details.
2736 float ColumnsGivenWidth; // Sum of current column width
2737 float ColumnsAutoFitWidth; // Sum of ideal column width in order nothing to be clipped, used for auto-fitting and content width submission in outer window
2738 float ColumnsStretchSumWeights; // Sum of weight of all enabled stretching columns
2739 float ResizedColumnNextWidth;
2740 float ResizeLockMinContentsX2; // Lock minimum contents width while resizing down in order to not create feedback loops. But we allow growing the table.
2741 float RefScale; // Reference scale to be able to rescale columns on font/dpi changes.
2742 float AngledHeadersHeight; // Set by TableAngledHeadersRow(), used in TableUpdateLayout()
2743 float AngledHeadersSlope; // Set by TableAngledHeadersRow(), used in TableUpdateLayout()
2744 ImRect OuterRect; // Note: for non-scrolling table, OuterRect.Max.y is often FLT_MAX until EndTable(), unless a height has been specified in BeginTable().
2745 ImRect InnerRect; // InnerRect but without decoration. As with OuterRect, for non-scrolling tables, InnerRect.Max.y is
2746 ImRect WorkRect;
2747 ImRect InnerClipRect;
2748 ImRect BgClipRect; // We use this to cpu-clip cell background color fill, evolve during the frame as we cross frozen rows boundaries
2749 ImRect Bg0ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG0/1 channel. This tends to be == OuterWindow->ClipRect at BeginTable() because output in BG0/BG1 is cpu-clipped
2750 ImRect Bg2ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG2 channel. This tends to be a correct, tight-fit, because output to BG2 are done by widgets relying on regular ClipRect.
2751 ImRect HostClipRect; // This is used to check if we can eventually merge our columns draw calls into the current draw call of the current window.
2752 ImRect HostBackupInnerClipRect; // Backup of InnerWindow->ClipRect during PushTableBackground()/PopTableBackground()
2753 ImGuiWindow* OuterWindow; // Parent window for the table
2754 ImGuiWindow* InnerWindow; // Window holding the table data (== OuterWindow or a child window)
2755 ImGuiTextBuffer ColumnsNames; // Contiguous buffer holding columns names
2756 ImDrawListSplitter* DrawSplitter; // Shortcut to TempData->DrawSplitter while in table. Isolate draw commands per columns to avoid switching clip rect constantly
2757 ImGuiTableInstanceData InstanceDataFirst;
2758 ImVector<ImGuiTableInstanceData> InstanceDataExtra; // FIXME-OPT: Using a small-vector pattern would be good.
2759 ImGuiTableColumnSortSpecs SortSpecsSingle;
2760 ImVector<ImGuiTableColumnSortSpecs> SortSpecsMulti; // FIXME-OPT: Using a small-vector pattern would be good.
2761 ImGuiTableSortSpecs SortSpecs; // Public facing sorts specs, this is what we return in TableGetSortSpecs()
2762 ImGuiTableColumnIdx SortSpecsCount;
2763 ImGuiTableColumnIdx ColumnsEnabledCount; // Number of enabled columns (<= ColumnsCount)
2764 ImGuiTableColumnIdx ColumnsEnabledFixedCount; // Number of enabled columns (<= ColumnsCount)
2765 ImGuiTableColumnIdx DeclColumnsCount; // Count calls to TableSetupColumn()
2766 ImGuiTableColumnIdx AngledHeadersCount; // Count columns with angled headers
2767 ImGuiTableColumnIdx HoveredColumnBody; // Index of column whose visible region is being hovered. Important: == ColumnsCount when hovering empty region after the right-most column!
2768 ImGuiTableColumnIdx HoveredColumnBorder; // Index of column whose right-border is being hovered (for resizing).
2769 ImGuiTableColumnIdx HighlightColumnHeader; // Index of column which should be highlighted.
2770 ImGuiTableColumnIdx AutoFitSingleColumn; // Index of single column requesting auto-fit.
2771 ImGuiTableColumnIdx ResizedColumn; // Index of column being resized. Reset when InstanceCurrent==0.
2772 ImGuiTableColumnIdx LastResizedColumn; // Index of column being resized from previous frame.
2773 ImGuiTableColumnIdx HeldHeaderColumn; // Index of column header being held.
2774 ImGuiTableColumnIdx ReorderColumn; // Index of column being reordered. (not cleared)
2775 ImGuiTableColumnIdx ReorderColumnDir; // -1 or +1
2776 ImGuiTableColumnIdx LeftMostEnabledColumn; // Index of left-most non-hidden column.
2777 ImGuiTableColumnIdx RightMostEnabledColumn; // Index of right-most non-hidden column.
2778 ImGuiTableColumnIdx LeftMostStretchedColumn; // Index of left-most stretched column.
2779 ImGuiTableColumnIdx RightMostStretchedColumn; // Index of right-most stretched column.
2780 ImGuiTableColumnIdx ContextPopupColumn; // Column right-clicked on, of -1 if opening context menu from a neutral/empty spot
2781 ImGuiTableColumnIdx FreezeRowsRequest; // Requested frozen rows count
2782 ImGuiTableColumnIdx FreezeRowsCount; // Actual frozen row count (== FreezeRowsRequest, or == 0 when no scrolling offset)
2783 ImGuiTableColumnIdx FreezeColumnsRequest; // Requested frozen columns count
2784 ImGuiTableColumnIdx FreezeColumnsCount; // Actual frozen columns count (== FreezeColumnsRequest, or == 0 when no scrolling offset)
2785 ImGuiTableColumnIdx RowCellDataCurrent; // Index of current RowCellData[] entry in current row
2786 ImGuiTableDrawChannelIdx DummyDrawChannel; // Redirect non-visible columns here.
2787 ImGuiTableDrawChannelIdx Bg2DrawChannelCurrent; // For Selectable() and other widgets drawing across columns after the freezing line. Index within DrawSplitter.Channels[]
2788 ImGuiTableDrawChannelIdx Bg2DrawChannelUnfrozen;
2789 bool IsLayoutLocked; // Set by TableUpdateLayout() which is called when beginning the first row.
2790 bool IsInsideRow; // Set when inside TableBeginRow()/TableEndRow().
2791 bool IsInitializing;
2792 bool IsSortSpecsDirty;
2793 bool IsUsingHeaders; // Set when the first row had the ImGuiTableRowFlags_Headers flag.
2794 bool IsContextPopupOpen; // Set when default context menu is open (also see: ContextPopupColumn, InstanceInteracted).
2795 bool DisableDefaultContextMenu; // Disable default context menu contents. You may submit your own using TableBeginContextMenuPopup()/EndPopup()
2796 bool IsSettingsRequestLoad;
2797 bool IsSettingsDirty; // Set when table settings have changed and needs to be reported into ImGuiTableSetttings data.
2798 bool IsDefaultDisplayOrder; // Set when display order is unchanged from default (DisplayOrder contains 0...Count-1)
2799 bool IsResetAllRequest;
2800 bool IsResetDisplayOrderRequest;
2801 bool IsUnfrozenRows; // Set when we got past the frozen row.
2802 bool IsDefaultSizingPolicy; // Set if user didn't explicitly set a sizing policy in BeginTable()
2803 bool IsActiveIdAliveBeforeTable;
2804 bool IsActiveIdInTable;
2805 bool HasScrollbarYCurr; // Whether ANY instance of this table had a vertical scrollbar during the current frame.
2806 bool HasScrollbarYPrev; // Whether ANY instance of this table had a vertical scrollbar during the previous.
2807 bool MemoryCompacted;
2808 bool HostSkipItems; // Backup of InnerWindow->SkipItem at the end of BeginTable(), because we will overwrite InnerWindow->SkipItem on a per-column basis
2809
2810 ImGuiTable() { memset(s: this, c: 0, n: sizeof(*this)); LastFrameActive = -1; }
2811 ~ImGuiTable() { IM_FREE(RawData); }
2812};
2813
2814// Transient data that are only needed between BeginTable() and EndTable(), those buffers are shared (1 per level of stacked table).
2815// - Accessing those requires chasing an extra pointer so for very frequently used data we leave them in the main table structure.
2816// - We also leave out of this structure data that tend to be particularly useful for debugging/metrics.
2817// sizeof() ~ 120 bytes.
2818struct IMGUI_API ImGuiTableTempData
2819{
2820 int TableIndex; // Index in g.Tables.Buf[] pool
2821 float LastTimeActive; // Last timestamp this structure was used
2822 float AngledheadersExtraWidth; // Used in EndTable()
2823
2824 ImVec2 UserOuterSize; // outer_size.x passed to BeginTable()
2825 ImDrawListSplitter DrawSplitter;
2826
2827 ImRect HostBackupWorkRect; // Backup of InnerWindow->WorkRect at the end of BeginTable()
2828 ImRect HostBackupParentWorkRect; // Backup of InnerWindow->ParentWorkRect at the end of BeginTable()
2829 ImVec2 HostBackupPrevLineSize; // Backup of InnerWindow->DC.PrevLineSize at the end of BeginTable()
2830 ImVec2 HostBackupCurrLineSize; // Backup of InnerWindow->DC.CurrLineSize at the end of BeginTable()
2831 ImVec2 HostBackupCursorMaxPos; // Backup of InnerWindow->DC.CursorMaxPos at the end of BeginTable()
2832 ImVec1 HostBackupColumnsOffset; // Backup of OuterWindow->DC.ColumnsOffset at the end of BeginTable()
2833 float HostBackupItemWidth; // Backup of OuterWindow->DC.ItemWidth at the end of BeginTable()
2834 int HostBackupItemWidthStackSize;//Backup of OuterWindow->DC.ItemWidthStack.Size at the end of BeginTable()
2835
2836 ImGuiTableTempData() { memset(s: this, c: 0, n: sizeof(*this)); LastTimeActive = -1.0f; }
2837};
2838
2839// sizeof() ~ 12
2840struct ImGuiTableColumnSettings
2841{
2842 float WidthOrWeight;
2843 ImGuiID UserID;
2844 ImGuiTableColumnIdx Index;
2845 ImGuiTableColumnIdx DisplayOrder;
2846 ImGuiTableColumnIdx SortOrder;
2847 ImU8 SortDirection : 2;
2848 ImU8 IsEnabled : 1; // "Visible" in ini file
2849 ImU8 IsStretch : 1;
2850
2851 ImGuiTableColumnSettings()
2852 {
2853 WidthOrWeight = 0.0f;
2854 UserID = 0;
2855 Index = -1;
2856 DisplayOrder = SortOrder = -1;
2857 SortDirection = ImGuiSortDirection_None;
2858 IsEnabled = 1;
2859 IsStretch = 0;
2860 }
2861};
2862
2863// This is designed to be stored in a single ImChunkStream (1 header followed by N ImGuiTableColumnSettings, etc.)
2864struct ImGuiTableSettings
2865{
2866 ImGuiID ID; // Set to 0 to invalidate/delete the setting
2867 ImGuiTableFlags SaveFlags; // Indicate data we want to save using the Resizable/Reorderable/Sortable/Hideable flags (could be using its own flags..)
2868 float RefScale; // Reference scale to be able to rescale columns on font/dpi changes.
2869 ImGuiTableColumnIdx ColumnsCount;
2870 ImGuiTableColumnIdx ColumnsCountMax; // Maximum number of columns this settings instance can store, we can recycle a settings instance with lower number of columns but not higher
2871 bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context)
2872
2873 ImGuiTableSettings() { memset(s: this, c: 0, n: sizeof(*this)); }
2874 ImGuiTableColumnSettings* GetColumnSettings() { return (ImGuiTableColumnSettings*)(this + 1); }
2875};
2876
2877//-----------------------------------------------------------------------------
2878// [SECTION] ImGui internal API
2879// No guarantee of forward compatibility here!
2880//-----------------------------------------------------------------------------
2881
2882namespace ImGui
2883{
2884 // Windows
2885 // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
2886 // If this ever crash because g.CurrentWindow is NULL it means that either
2887 // - ImGui::NewFrame() has never been called, which is illegal.
2888 // - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
2889 inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
2890 inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
2891 IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id);
2892 IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
2893 IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
2894 IMGUI_API ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow* window);
2895 IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy);
2896 IMGUI_API bool IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
2897 IMGUI_API bool IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below);
2898 IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
2899 IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0);
2900 IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0);
2901 IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
2902 IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
2903 IMGUI_API void SetWindowHiddendAndSkipItemsForCurrentFrame(ImGuiWindow* window);
2904 inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
2905 inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
2906 inline ImVec2 WindowPosRelToAbs(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x + off.x, p.y + off.y); }
2907
2908 // Windows: Display Order and Focus Order
2909 IMGUI_API void FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags = 0);
2910 IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window, ImGuiViewport* filter_viewport, ImGuiFocusRequestFlags flags);
2911 IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window);
2912 IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window);
2913 IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window);
2914 IMGUI_API void BringWindowToDisplayBehind(ImGuiWindow* window, ImGuiWindow* above_window);
2915 IMGUI_API int FindWindowDisplayIndex(ImGuiWindow* window);
2916 IMGUI_API ImGuiWindow* FindBottomMostVisibleWindowWithinBeginStack(ImGuiWindow* window);
2917
2918 // Fonts, drawing
2919 IMGUI_API void SetCurrentFont(ImFont* font);
2920 inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
2921 inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { IM_UNUSED(window); return GetForegroundDrawList(); } // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches.
2922 IMGUI_API ImDrawList* GetBackgroundDrawList(ImGuiViewport* viewport); // get background draw list for the given viewport. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
2923 IMGUI_API ImDrawList* GetForegroundDrawList(ImGuiViewport* viewport); // get foreground draw list for the given viewport. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
2924 IMGUI_API void AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
2925
2926 // Init
2927 IMGUI_API void Initialize();
2928 IMGUI_API void Shutdown(); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
2929
2930 // NewFrame
2931 IMGUI_API void UpdateInputEvents(bool trickle_fast_inputs);
2932 IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
2933 IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
2934 IMGUI_API void UpdateMouseMovingWindowNewFrame();
2935 IMGUI_API void UpdateMouseMovingWindowEndFrame();
2936
2937 // Generic context hooks
2938 IMGUI_API ImGuiID AddContextHook(ImGuiContext* context, const ImGuiContextHook* hook);
2939 IMGUI_API void RemoveContextHook(ImGuiContext* context, ImGuiID hook_to_remove);
2940 IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);
2941
2942 // Viewports
2943 IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
2944
2945 // Settings
2946 IMGUI_API void MarkIniSettingsDirty();
2947 IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window);
2948 IMGUI_API void ClearIniSettings();
2949 IMGUI_API void AddSettingsHandler(const ImGuiSettingsHandler* handler);
2950 IMGUI_API void RemoveSettingsHandler(const char* type_name);
2951 IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
2952
2953 // Settings - Windows
2954 IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(const char* name);
2955 IMGUI_API ImGuiWindowSettings* FindWindowSettingsByID(ImGuiID id);
2956 IMGUI_API ImGuiWindowSettings* FindWindowSettingsByWindow(ImGuiWindow* window);
2957 IMGUI_API void ClearWindowSettings(const char* name);
2958
2959 // Localization
2960 IMGUI_API void LocalizeRegisterEntries(const ImGuiLocEntry* entries, int count);
2961 inline const char* LocalizeGetMsg(ImGuiLocKey key) { ImGuiContext& g = *GImGui; const char* msg = g.LocalizationTable[key]; return msg ? msg : "*Missing Text*"; }
2962
2963 // Scrolling
2964 IMGUI_API void SetScrollX(ImGuiWindow* window, float scroll_x);
2965 IMGUI_API void SetScrollY(ImGuiWindow* window, float scroll_y);
2966 IMGUI_API void SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio);
2967 IMGUI_API void SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio);
2968
2969 // Early work-in-progress API (ScrollToItem() will become public)
2970 IMGUI_API void ScrollToItem(ImGuiScrollFlags flags = 0);
2971 IMGUI_API void ScrollToRect(ImGuiWindow* window, const ImRect& rect, ImGuiScrollFlags flags = 0);
2972 IMGUI_API ImVec2 ScrollToRectEx(ImGuiWindow* window, const ImRect& rect, ImGuiScrollFlags flags = 0);
2973//#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
2974 inline void ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& rect) { ScrollToRect(window, rect, flags: ImGuiScrollFlags_KeepVisibleEdgeY); }
2975//#endif
2976
2977 // Basic Accessors
2978 inline ImGuiItemStatusFlags GetItemStatusFlags(){ ImGuiContext& g = *GImGui; return g.LastItemData.StatusFlags; }
2979 inline ImGuiItemFlags GetItemFlags() { ImGuiContext& g = *GImGui; return g.LastItemData.InFlags; }
2980 inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; }
2981 inline ImGuiID GetFocusID() { ImGuiContext& g = *GImGui; return g.NavId; }
2982 IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
2983 IMGUI_API void SetFocusID(ImGuiID id, ImGuiWindow* window);
2984 IMGUI_API void ClearActiveID();
2985 IMGUI_API ImGuiID GetHoveredID();
2986 IMGUI_API void SetHoveredID(ImGuiID id);
2987 IMGUI_API void KeepAliveID(ImGuiID id);
2988 IMGUI_API void MarkItemEdited(ImGuiID id); // Mark data associated to given item as "edited", used by IsItemDeactivatedAfterEdit() function.
2989 IMGUI_API void PushOverrideID(ImGuiID id); // Push given value as-is at the top of the ID stack (whereas PushID combines old and new hashes)
2990 IMGUI_API ImGuiID GetIDWithSeed(const char* str_id_begin, const char* str_id_end, ImGuiID seed);
2991 IMGUI_API ImGuiID GetIDWithSeed(int n, ImGuiID seed);
2992
2993 // Basic Helpers for widget code
2994 IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = -1.0f);
2995 inline void ItemSize(const ImRect& bb, float text_baseline_y = -1.0f) { ItemSize(size: bb.GetSize(), text_baseline_y); } // FIXME: This is a misleading API since we expect CursorPos to be bb.Min.
2996 IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL, ImGuiItemFlags extra_flags = 0);
2997 IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flags);
2998 IMGUI_API bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags = 0);
2999 IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id);
3000 IMGUI_API void SetLastItemData(ImGuiID item_id, ImGuiItemFlags in_flags, ImGuiItemStatusFlags status_flags, const ImRect& item_rect);
3001 IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
3002 IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
3003 IMGUI_API void PushMultiItemsWidths(int components, float width_full);
3004 IMGUI_API bool IsItemToggledSelection(); // Was the last item selection toggled? (after Selectable(), TreeNode() etc. We only returns toggle _event_ in order to handle clipping correctly)
3005 IMGUI_API ImVec2 GetContentRegionMaxAbs();
3006 IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess);
3007
3008 // Parameter stacks (shared)
3009 IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
3010 IMGUI_API void PopItemFlag();
3011 IMGUI_API const ImGuiDataVarInfo* GetStyleVarInfo(ImGuiStyleVar idx);
3012
3013 // Logging/Capture
3014 IMGUI_API void LogBegin(ImGuiLogType type, int auto_open_depth); // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name.
3015 IMGUI_API void LogToBuffer(int auto_open_depth = -1); // Start logging/capturing to internal buffer
3016 IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
3017 IMGUI_API void LogSetNextTextDecoration(const char* prefix, const char* suffix);
3018
3019 // Popups, Modals, Tooltips
3020 IMGUI_API bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags);
3021 IMGUI_API void OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags = ImGuiPopupFlags_None);
3022 IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
3023 IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
3024 IMGUI_API void ClosePopupsExceptModals();
3025 IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags);
3026 IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
3027 IMGUI_API bool BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags extra_window_flags);
3028 IMGUI_API bool BeginTooltipHidden();
3029 IMGUI_API ImRect GetPopupAllowedExtentRect(ImGuiWindow* window);
3030 IMGUI_API ImGuiWindow* GetTopMostPopupModal();
3031 IMGUI_API ImGuiWindow* GetTopMostAndVisiblePopupModal();
3032 IMGUI_API ImGuiWindow* FindBlockingModal(ImGuiWindow* window);
3033 IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
3034 IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
3035
3036 // Menus
3037 IMGUI_API bool BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
3038 IMGUI_API bool BeginMenuEx(const char* label, const char* icon, bool enabled = true);
3039 IMGUI_API bool MenuItemEx(const char* label, const char* icon, const char* shortcut = NULL, bool selected = false, bool enabled = true);
3040
3041 // Combos
3042 IMGUI_API bool BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags flags);
3043 IMGUI_API bool BeginComboPreview();
3044 IMGUI_API void EndComboPreview();
3045
3046 // Gamepad/Keyboard Navigation
3047 IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
3048 IMGUI_API void NavInitRequestApplyResult();
3049 IMGUI_API bool NavMoveRequestButNoResultYet();
3050 IMGUI_API void NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags);
3051 IMGUI_API void NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags);
3052 IMGUI_API void NavMoveRequestResolveWithLastItem(ImGuiNavItemData* result);
3053 IMGUI_API void NavMoveRequestResolveWithPastTreeNode(ImGuiNavItemData* result, ImGuiNavTreeNodeData* tree_node_data);
3054 IMGUI_API void NavMoveRequestCancel();
3055 IMGUI_API void NavMoveRequestApplyResult();
3056 IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
3057 IMGUI_API void NavClearPreferredPosForAxis(ImGuiAxis axis);
3058 IMGUI_API void NavRestoreHighlightAfterMove();
3059 IMGUI_API void NavUpdateCurrentWindowIsScrollPushableX();
3060 IMGUI_API void SetNavWindow(ImGuiWindow* window);
3061 IMGUI_API void SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel);
3062
3063 // Focus/Activation
3064 // This should be part of a larger set of API: FocusItem(offset = -1), FocusItemByID(id), ActivateItem(offset = -1), ActivateItemByID(id) etc. which are
3065 // much harder to design and implement than expected. I have a couple of private branches on this matter but it's not simple. For now implementing the easy ones.
3066 IMGUI_API void FocusItem(); // Focus last item (no selection/activation).
3067 IMGUI_API void ActivateItemByID(