cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

imgui_internal.h (133777B)


      1// dear imgui, v1.76
      2// (internal structures/api)
      3
      4// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
      5// Set:
      6//   #define IMGUI_DEFINE_MATH_OPERATORS
      7// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators)
      8
      9/*
     10
     11Index of this file:
     12// Header mess
     13// Forward declarations
     14// STB libraries includes
     15// Context pointer
     16// Generic helpers
     17// Misc data structures
     18// Main imgui context
     19// Tab bar, tab item
     20// Internal API
     21
     22*/
     23
     24#pragma once
     25#ifndef IMGUI_DISABLE
     26
     27//-----------------------------------------------------------------------------
     28// Header mess
     29//-----------------------------------------------------------------------------
     30
     31#ifndef IMGUI_VERSION
     32#error Must include imgui.h before imgui_internal.h
     33#endif
     34
     35#include <stdio.h>      // FILE*, sscanf
     36#include <stdlib.h>     // NULL, malloc, free, qsort, atoi, atof
     37#include <math.h>       // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
     38#include <limits.h>     // INT_MIN, INT_MAX
     39
     40// Visual Studio warnings
     41#ifdef _MSC_VER
     42#pragma warning (push)
     43#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)
     44#endif
     45
     46// Clang/GCC warnings with -Weverything
     47#if defined(__clang__)
     48#pragma clang diagnostic push
     49#pragma clang diagnostic ignored "-Wunused-function"        // for stb_textedit.h
     50#pragma clang diagnostic ignored "-Wmissing-prototypes"     // for stb_textedit.h
     51#pragma clang diagnostic ignored "-Wold-style-cast"
     52#if __has_warning("-Wzero-as-null-pointer-constant")
     53#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
     54#endif
     55#if __has_warning("-Wdouble-promotion")
     56#pragma clang diagnostic ignored "-Wdouble-promotion"
     57#endif
     58#elif defined(__GNUC__)
     59#pragma GCC diagnostic push
     60#pragma GCC diagnostic ignored "-Wpragmas"                  // warning: unknown option after '#pragma GCC diagnostic' kind
     61#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
     62#endif
     63
     64// Legacy defines
     65#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS                // Renamed in 1.74
     66#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
     67#endif
     68#ifdef IMGUI_DISABLE_MATH_FUNCTIONS                         // Renamed in 1.74
     69#error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
     70#endif
     71
     72//-----------------------------------------------------------------------------
     73// Forward declarations
     74//-----------------------------------------------------------------------------
     75
     76struct ImBitVector;                 // Store 1-bit per value
     77struct ImRect;                      // An axis-aligned rectangle (2 points)
     78struct ImDrawDataBuilder;           // Helper to build a ImDrawData instance
     79struct ImDrawListSharedData;        // Data shared between all ImDrawList instances
     80struct ImGuiColorMod;               // Stacked color modifier, backup of modified data so we can restore it
     81struct ImGuiColumnData;             // Storage data for a single column
     82struct ImGuiColumns;                // Storage data for a columns set
     83struct ImGuiContext;                // Main Dear ImGui context
     84struct ImGuiDataTypeInfo;           // Type information associated to a ImGuiDataType enum
     85struct ImGuiGroupData;              // Stacked storage data for BeginGroup()/EndGroup()
     86struct ImGuiInputTextState;         // Internal state of the currently focused/edited text input box
     87struct ImGuiItemHoveredDataBackup;  // Backup and restore IsItemHovered() internal data
     88struct ImGuiMenuColumns;            // Simple column measurement, currently used for MenuItem() only
     89struct ImGuiNavMoveResult;          // Result of a gamepad/keyboard directional navigation move query result
     90struct ImGuiNextWindowData;         // Storage for SetNextWindow** functions
     91struct ImGuiNextItemData;           // Storage for SetNextItem** functions
     92struct ImGuiPopupData;              // Storage for current popup stack
     93struct ImGuiSettingsHandler;        // Storage for one type registered in the .ini file
     94struct ImGuiStyleMod;               // Stacked style modifier, backup of modified data so we can restore it
     95struct ImGuiTabBar;                 // Storage for a tab bar
     96struct ImGuiTabItem;                // Storage for a tab item (within a tab bar)
     97struct ImGuiWindow;                 // Storage for one window
     98struct ImGuiWindowTempData;         // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame)
     99struct ImGuiWindowSettings;         // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
    100
    101// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
    102typedef int ImGuiLayoutType;            // -> enum ImGuiLayoutType_         // Enum: Horizontal or vertical
    103typedef int ImGuiButtonFlags;           // -> enum ImGuiButtonFlags_        // Flags: for ButtonEx(), ButtonBehavior()
    104typedef int ImGuiColumnsFlags;          // -> enum ImGuiColumnsFlags_       // Flags: BeginColumns()
    105typedef int ImGuiDragFlags;             // -> enum ImGuiDragFlags_          // Flags: for DragBehavior()
    106typedef int ImGuiItemFlags;             // -> enum ImGuiItemFlags_          // Flags: for PushItemFlag()
    107typedef int ImGuiItemStatusFlags;       // -> enum ImGuiItemStatusFlags_    // Flags: for DC.LastItemStatusFlags
    108typedef int ImGuiNavHighlightFlags;     // -> enum ImGuiNavHighlightFlags_  // Flags: for RenderNavHighlight()
    109typedef int ImGuiNavDirSourceFlags;     // -> enum ImGuiNavDirSourceFlags_  // Flags: for GetNavInputAmount2d()
    110typedef int ImGuiNavMoveFlags;          // -> enum ImGuiNavMoveFlags_       // Flags: for navigation requests
    111typedef int ImGuiNextItemDataFlags;     // -> enum ImGuiNextItemDataFlags_  // Flags: for SetNextItemXXX() functions
    112typedef int ImGuiNextWindowDataFlags;   // -> enum ImGuiNextWindowDataFlags_// Flags: for SetNextWindowXXX() functions
    113typedef int ImGuiSeparatorFlags;        // -> enum ImGuiSeparatorFlags_     // Flags: for SeparatorEx()
    114typedef int ImGuiSliderFlags;           // -> enum ImGuiSliderFlags_        // Flags: for SliderBehavior()
    115typedef int ImGuiTextFlags;             // -> enum ImGuiTextFlags_          // Flags: for TextEx()
    116typedef int ImGuiTooltipFlags;          // -> enum ImGuiTooltipFlags_       // Flags: for BeginTooltipEx()
    117
    118//-------------------------------------------------------------------------
    119// STB libraries includes
    120//-------------------------------------------------------------------------
    121
    122namespace ImStb
    123{
    124
    125#undef STB_TEXTEDIT_STRING
    126#undef STB_TEXTEDIT_CHARTYPE
    127#define STB_TEXTEDIT_STRING             ImGuiInputTextState
    128#define STB_TEXTEDIT_CHARTYPE           ImWchar
    129#define STB_TEXTEDIT_GETWIDTH_NEWLINE   -1.0f
    130#define STB_TEXTEDIT_UNDOSTATECOUNT     99
    131#define STB_TEXTEDIT_UNDOCHARCOUNT      999
    132#include "imstb_textedit.h"
    133
    134} // namespace ImStb
    135
    136//-----------------------------------------------------------------------------
    137// Context pointer
    138//-----------------------------------------------------------------------------
    139
    140#ifndef GImGui
    141extern IMGUI_API ImGuiContext* GImGui;  // Current implicit context pointer
    142#endif
    143
    144//-----------------------------------------------------------------------------
    145// Macros
    146//-----------------------------------------------------------------------------
    147
    148// Debug Logging
    149#ifndef IMGUI_DEBUG_LOG
    150#define IMGUI_DEBUG_LOG(_FMT,...)       printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
    151#endif
    152
    153// Static Asserts
    154#if (__cplusplus >= 201100)
    155#define IM_STATIC_ASSERT(_COND)         static_assert(_COND, "")
    156#else
    157#define IM_STATIC_ASSERT(_COND)         typedef char static_assertion_##__line__[(_COND)?1:-1]
    158#endif
    159
    160// "Paranoid" Debug Asserts are meant to only be enabled during specific debugging/work, otherwise would slow down the code too much.
    161// 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.
    162//#define IMGUI_DEBUG_PARANOID
    163#ifdef IMGUI_DEBUG_PARANOID
    164#define IM_ASSERT_PARANOID(_EXPR)       IM_ASSERT(_EXPR)
    165#else
    166#define IM_ASSERT_PARANOID(_EXPR)
    167#endif
    168
    169// Error handling
    170// 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.
    171#ifndef IM_ASSERT_USER_ERROR
    172#define IM_ASSERT_USER_ERROR(_EXP,_MSG) IM_ASSERT((_EXP) && _MSG)   // Recoverable User Error
    173#endif
    174
    175// Misc Macros
    176#define IM_PI                           3.14159265358979323846f
    177#ifdef _WIN32
    178#define IM_NEWLINE                      "\r\n"   // Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!)
    179#else
    180#define IM_NEWLINE                      "\n"
    181#endif
    182#define IM_TABSIZE                      (4)
    183#define IM_F32_TO_INT8_UNBOUND(_VAL)    ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f)))   // Unsaturated, for display purpose
    184#define IM_F32_TO_INT8_SAT(_VAL)        ((int)(ImSaturate(_VAL) * 255.0f + 0.5f))               // Saturated, always output 0..255
    185#define IM_FLOOR(_VAL)                  ((float)(int)(_VAL))                                    // ImFloor() is not inlined in MSVC debug builds
    186#define IM_ROUND(_VAL)                  ((float)(int)((_VAL) + 0.5f))                           //
    187
    188// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
    189#ifdef _MSC_VER
    190#define IMGUI_CDECL __cdecl
    191#else
    192#define IMGUI_CDECL
    193#endif
    194
    195//-----------------------------------------------------------------------------
    196// Generic helpers
    197// Note that the ImXXX helpers functions are lower-level than ImGui functions.
    198// ImGui functions or the ImGui context are never called/used from other ImXXX functions.
    199//-----------------------------------------------------------------------------
    200// - Helpers: Misc
    201// - Helpers: Bit manipulation
    202// - Helpers: String, Formatting
    203// - Helpers: UTF-8 <> wchar conversions
    204// - Helpers: ImVec2/ImVec4 operators
    205// - Helpers: Maths
    206// - Helpers: Geometry
    207// - Helpers: Bit arrays
    208// - Helper: ImBitVector
    209// - Helper: ImPool<>
    210// - Helper: ImChunkStream<>
    211//-----------------------------------------------------------------------------
    212
    213// Helpers: Misc
    214#define ImQsort         qsort
    215IMGUI_API ImU32         ImHashData(const void* data, size_t data_size, ImU32 seed = 0);
    216IMGUI_API ImU32         ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0);
    217#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
    218static inline ImU32     ImHash(const void* data, int size, ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68]
    219#endif
    220
    221// Helpers: Color Blending
    222IMGUI_API ImU32         ImAlphaBlendColors(ImU32 col_a, ImU32 col_b);
    223
    224// Helpers: Bit manipulation
    225static inline bool      ImIsPowerOfTwo(int v)           { return v != 0 && (v & (v - 1)) == 0; }
    226static inline int       ImUpperPowerOfTwo(int v)        { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
    227
    228// Helpers: String, Formatting
    229IMGUI_API int           ImStricmp(const char* str1, const char* str2);
    230IMGUI_API int           ImStrnicmp(const char* str1, const char* str2, size_t count);
    231IMGUI_API void          ImStrncpy(char* dst, const char* src, size_t count);
    232IMGUI_API char*         ImStrdup(const char* str);
    233IMGUI_API char*         ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str);
    234IMGUI_API const char*   ImStrchrRange(const char* str_begin, const char* str_end, char c);
    235IMGUI_API int           ImStrlenW(const ImWchar* str);
    236IMGUI_API const char*   ImStreolRange(const char* str, const char* str_end);                // End end-of-line
    237IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin);   // Find beginning-of-line
    238IMGUI_API const char*   ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
    239IMGUI_API void          ImStrTrimBlanks(char* str);
    240IMGUI_API const char*   ImStrSkipBlank(const char* str);
    241IMGUI_API int           ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
    242IMGUI_API int           ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
    243IMGUI_API const char*   ImParseFormatFindStart(const char* format);
    244IMGUI_API const char*   ImParseFormatFindEnd(const char* format);
    245IMGUI_API const char*   ImParseFormatTrimDecorations(const char* format, char* buf, size_t buf_size);
    246IMGUI_API int           ImParseFormatPrecision(const char* format, int default_value);
    247static inline bool      ImCharIsBlankA(char c)          { return c == ' ' || c == '\t'; }
    248static inline bool      ImCharIsBlankW(unsigned int c)  { return c == ' ' || c == '\t' || c == 0x3000; }
    249
    250// Helpers: UTF-8 <> wchar conversions
    251IMGUI_API int           ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end);      // return output UTF-8 bytes count
    252IMGUI_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
    253IMGUI_API int           ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL);   // return input UTF-8 bytes count
    254IMGUI_API int           ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end);                            // return number of UTF-8 code-points (NOT bytes count)
    255IMGUI_API int           ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end);                        // return number of bytes to express one char in UTF-8
    256IMGUI_API int           ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end);                   // return number of bytes to express string in UTF-8
    257
    258// Helpers: ImVec2/ImVec4 operators
    259// We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.)
    260// We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself.
    261#ifdef IMGUI_DEFINE_MATH_OPERATORS
    262static inline ImVec2 operator*(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
    263static inline ImVec2 operator/(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x/rhs, lhs.y/rhs); }
    264static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
    265static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
    266static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
    267static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
    268static inline ImVec2& operator*=(ImVec2& lhs, const float rhs)                  { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
    269static inline ImVec2& operator/=(ImVec2& lhs, const float rhs)                  { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
    270static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
    271static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
    272static inline ImVec2& operator*=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x *= rhs.x; lhs.y *= rhs.y; return lhs; }
    273static inline ImVec2& operator/=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x /= rhs.x; lhs.y /= rhs.y; return lhs; }
    274static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs)            { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
    275static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs)            { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
    276static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs)            { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
    277#endif
    278
    279// Helpers: File System
    280#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
    281#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
    282typedef void* ImFileHandle;
    283static inline ImFileHandle  ImFileOpen(const char*, const char*)                    { return NULL; }
    284static inline bool          ImFileClose(ImFileHandle)                               { return false; }
    285static inline ImU64         ImFileGetSize(ImFileHandle)                             { return (ImU64)-1; }
    286static inline ImU64         ImFileRead(void*, ImU64, ImU64, ImFileHandle)           { return 0; }
    287static inline ImU64         ImFileWrite(const void*, ImU64, ImU64, ImFileHandle)    { return 0; }
    288#endif
    289
    290#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
    291typedef FILE* ImFileHandle;
    292IMGUI_API ImFileHandle      ImFileOpen(const char* filename, const char* mode);
    293IMGUI_API bool              ImFileClose(ImFileHandle file);
    294IMGUI_API ImU64             ImFileGetSize(ImFileHandle file);
    295IMGUI_API ImU64             ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
    296IMGUI_API ImU64             ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file);
    297#else
    298#define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions
    299#endif
    300IMGUI_API void*             ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size = NULL, int padding_bytes = 0);
    301
    302// Helpers: Maths
    303// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
    304#ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
    305#define ImFabs(X)           fabsf(X)
    306#define ImSqrt(X)           sqrtf(X)
    307#define ImFmod(X, Y)        fmodf((X), (Y))
    308#define ImCos(X)            cosf(X)
    309#define ImSin(X)            sinf(X)
    310#define ImAcos(X)           acosf(X)
    311#define ImAtan2(Y, X)       atan2f((Y), (X))
    312#define ImAtof(STR)         atof(STR)
    313#define ImFloorStd(X)       floorf(X)           // We already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by e.g. stb_truetype)
    314#define ImCeil(X)           ceilf(X)
    315static inline float  ImPow(float x, float y)    { return powf(x, y); }          // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
    316static inline double ImPow(double x, double y)  { return pow(x, y); }
    317#endif
    318// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double
    319// (Exceptionally using templates here but we could also redefine them for those types)
    320template<typename T> static inline T ImMin(T lhs, T rhs)                        { return lhs < rhs ? lhs : rhs; }
    321template<typename T> static inline T ImMax(T lhs, T rhs)                        { return lhs >= rhs ? lhs : rhs; }
    322template<typename T> static inline T ImClamp(T v, T mn, T mx)                   { return (v < mn) ? mn : (v > mx) ? mx : v; }
    323template<typename T> static inline T ImLerp(T a, T b, float t)                  { return (T)(a + (b - a) * t); }
    324template<typename T> static inline void ImSwap(T& a, T& b)                      { T tmp = a; a = b; b = tmp; }
    325template<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; }
    326template<typename T> static inline T ImSubClampOverflow(T a, T b, T mn, T mx)   { if (b > 0 && (a < mn + b)) return mn; if (b < 0 && (a > mx + b)) return mx; return a - b; }
    327// - Misc maths helpers
    328static 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); }
    329static 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); }
    330static 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); }
    331static 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); }
    332static 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); }
    333static 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); }
    334static inline float  ImSaturate(float f)                                        { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
    335static inline float  ImLengthSqr(const ImVec2& lhs)                             { return lhs.x*lhs.x + lhs.y*lhs.y; }
    336static inline float  ImLengthSqr(const ImVec4& lhs)                             { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
    337static inline float  ImInvLength(const ImVec2& lhs, float fail_value)           { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / ImSqrt(d); return fail_value; }
    338static inline float  ImFloor(float f)                                           { return (float)(int)(f); }
    339static inline ImVec2 ImFloor(const ImVec2& v)                                   { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); }
    340static inline int    ImModPositive(int a, int b)                                { return (a + b) % b; }
    341static inline float  ImDot(const ImVec2& a, const ImVec2& b)                    { return a.x * b.x + a.y * b.y; }
    342static 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); }
    343static inline float  ImLinearSweep(float current, float target, float speed)    { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
    344static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs)                { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
    345
    346// Helpers: Geometry
    347IMGUI_API ImVec2     ImBezierCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t);                                         // Cubic Bezier
    348IMGUI_API ImVec2     ImBezierClosestPoint(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
    349IMGUI_API ImVec2     ImBezierClosestPointCasteljau(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
    350IMGUI_API ImVec2     ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
    351IMGUI_API bool       ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
    352IMGUI_API ImVec2     ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
    353IMGUI_API void       ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
    354inline 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; }
    355IMGUI_API ImGuiDir   ImGetDirQuadrantFromDelta(float dx, float dy);
    356
    357// Helpers: Bit arrays
    358inline bool          ImBitArrayTestBit(const ImU32* arr, int n)         { ImU32 mask = (ImU32)1 << (n & 31); return (arr[n >> 5] & mask) != 0; }
    359inline void          ImBitArrayClearBit(ImU32* arr, int n)              { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] &= ~mask; }
    360inline void          ImBitArraySetBit(ImU32* arr, int n)                { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] |= mask; }
    361inline void          ImBitArraySetBitRange(ImU32* arr, int n, int n2)
    362{
    363    while (n <= n2)
    364    {
    365        int a_mod = (n & 31);
    366        int b_mod = ((n2 >= n + 31) ? 31 : (n2 & 31)) + 1;
    367        ImU32 mask = (ImU32)(((ImU64)1 << b_mod) - 1) & ~(ImU32)(((ImU64)1 << a_mod) - 1);
    368        arr[n >> 5] |= mask;
    369        n = (n + 32) & ~31;
    370    }
    371}
    372
    373// Helper: ImBitVector
    374// Store 1-bit per value.
    375struct IMGUI_API ImBitVector
    376{
    377    ImVector<ImU32> Storage;
    378    void            Create(int sz)              { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
    379    void            Clear()                     { Storage.clear(); }
    380    bool            TestBit(int n) const        { IM_ASSERT(n < (Storage.Size << 5)); return ImBitArrayTestBit(Storage.Data, n); }
    381    void            SetBit(int n)               { IM_ASSERT(n < (Storage.Size << 5)); ImBitArraySetBit(Storage.Data, n); }
    382    void            ClearBit(int n)             { IM_ASSERT(n < (Storage.Size << 5)); ImBitArrayClearBit(Storage.Data, n); }
    383};
    384
    385// Helper: ImPool<>
    386// Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer,
    387// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
    388typedef int ImPoolIdx;
    389template<typename T>
    390struct IMGUI_API ImPool
    391{
    392    ImVector<T>     Buf;        // Contiguous data
    393    ImGuiStorage    Map;        // ID->Index
    394    ImPoolIdx       FreeIdx;    // Next free idx to use
    395
    396    ImPool()    { FreeIdx = 0; }
    397    ~ImPool()   { Clear(); }
    398    T*          GetByKey(ImGuiID key)               { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; }
    399    T*          GetByIndex(ImPoolIdx n)             { return &Buf[n]; }
    400    ImPoolIdx   GetIndex(const T* p) const          { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); }
    401    T*          GetOrAddByKey(ImGuiID key)          { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); }
    402    bool        Contains(const T* p) const          { return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
    403    void        Clear()                             { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = 0; }
    404    T*          Add()                               { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); return &Buf[idx]; }
    405    void        Remove(ImGuiID key, const T* p)     { Remove(key, GetIndex(p)); }
    406    void        Remove(ImGuiID key, ImPoolIdx idx)  { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
    407    void        Reserve(int capacity)               { Buf.reserve(capacity); Map.Data.reserve(capacity); }
    408    int         GetSize() const                     { return Buf.Size; }
    409};
    410
    411// Helper: ImChunkStream<>
    412// Build and iterate a contiguous stream of variable-sized structures.
    413// This is used by Settings to store persistent data while reducing allocation count.
    414// We store the chunk size first, and align the final size on 4 bytes boundaries (this what the '(X + 3) & ~3' statement is for)
    415// The tedious/zealous amount of casting is to avoid -Wcast-align warnings.
    416template<typename T>
    417struct IMGUI_API ImChunkStream
    418{
    419    ImVector<char>  Buf;
    420
    421    void    clear()                     { Buf.clear(); }
    422    bool    empty() const               { return Buf.Size == 0; }
    423    int     size() const                { return Buf.Size; }
    424    T*      alloc_chunk(size_t sz)      { size_t HDR_SZ = 4; sz = ((HDR_SZ + sz) + 3u) & ~3u; int off = Buf.Size; Buf.resize(off + (int)sz); ((int*)(void*)(Buf.Data + off))[0] = (int)sz; return (T*)(void*)(Buf.Data + off + (int)HDR_SZ); }
    425    T*      begin()                     { size_t HDR_SZ = 4; if (!Buf.Data) return NULL; return (T*)(void*)(Buf.Data + HDR_SZ); }
    426    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; }
    427    int     chunk_size(const T* p)      { return ((const int*)p)[-1]; }
    428    T*      end()                       { return (T*)(void*)(Buf.Data + Buf.Size); }
    429    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; }
    430    T*      ptr_from_offset(int off)    { IM_ASSERT(off >= 4 && off < Buf.Size); return (T*)(void*)(Buf.Data + off); }
    431};
    432
    433//-----------------------------------------------------------------------------
    434// Misc data structures
    435//-----------------------------------------------------------------------------
    436
    437enum ImGuiButtonFlags_
    438{
    439    ImGuiButtonFlags_None                   = 0,
    440    ImGuiButtonFlags_Repeat                 = 1 << 0,   // hold to repeat
    441    ImGuiButtonFlags_PressedOnClick         = 1 << 1,   // return true on click (mouse down event)
    442    ImGuiButtonFlags_PressedOnClickRelease  = 1 << 2,   // [Default] return true on click + release on same item <-- this is what the majority of Button are using
    443    ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 3, // return true on click + release even if the release event is not done while hovering the item
    444    ImGuiButtonFlags_PressedOnRelease       = 1 << 4,   // return true on release (default requires click+release)
    445    ImGuiButtonFlags_PressedOnDoubleClick   = 1 << 5,   // return true on double-click (default requires click+release)
    446    ImGuiButtonFlags_PressedOnDragDropHold  = 1 << 6,   // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
    447    ImGuiButtonFlags_FlattenChildren        = 1 << 7,   // allow interactions even if a child window is overlapping
    448    ImGuiButtonFlags_AllowItemOverlap       = 1 << 8,   // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
    449    ImGuiButtonFlags_DontClosePopups        = 1 << 9,   // disable automatically closing parent popup on press // [UNUSED]
    450    ImGuiButtonFlags_Disabled               = 1 << 10,  // disable interactions
    451    ImGuiButtonFlags_AlignTextBaseLine      = 1 << 11,  // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
    452    ImGuiButtonFlags_NoKeyModifiers         = 1 << 12,  // disable mouse interaction if a key modifier is held
    453    ImGuiButtonFlags_NoHoldingActiveId      = 1 << 13,  // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
    454    ImGuiButtonFlags_NoNavFocus             = 1 << 14,  // don't override navigation focus when activated
    455    ImGuiButtonFlags_NoHoveredOnFocus       = 1 << 15,  // don't report as hovered when nav focus is on this item
    456    ImGuiButtonFlags_MouseButtonLeft        = 1 << 16,  // [Default] react on left mouse button
    457    ImGuiButtonFlags_MouseButtonRight       = 1 << 17,  // react on right mouse button
    458    ImGuiButtonFlags_MouseButtonMiddle      = 1 << 18,  // react on center mouse button
    459
    460    ImGuiButtonFlags_MouseButtonMask_       = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle,
    461    ImGuiButtonFlags_MouseButtonShift_      = 16,
    462    ImGuiButtonFlags_MouseButtonDefault_    = ImGuiButtonFlags_MouseButtonLeft,
    463    ImGuiButtonFlags_PressedOnMask_         = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold,
    464    ImGuiButtonFlags_PressedOnDefault_      = ImGuiButtonFlags_PressedOnClickRelease
    465};
    466
    467enum ImGuiSliderFlags_
    468{
    469    ImGuiSliderFlags_None                   = 0,
    470    ImGuiSliderFlags_Vertical               = 1 << 0
    471};
    472
    473enum ImGuiDragFlags_
    474{
    475    ImGuiDragFlags_None                     = 0,
    476    ImGuiDragFlags_Vertical                 = 1 << 0
    477};
    478
    479enum ImGuiColumnsFlags_
    480{
    481    // Default: 0
    482    ImGuiColumnsFlags_None                  = 0,
    483    ImGuiColumnsFlags_NoBorder              = 1 << 0,   // Disable column dividers
    484    ImGuiColumnsFlags_NoResize              = 1 << 1,   // Disable resizing columns when clicking on the dividers
    485    ImGuiColumnsFlags_NoPreserveWidths      = 1 << 2,   // Disable column width preservation when adjusting columns
    486    ImGuiColumnsFlags_NoForceWithinWindow   = 1 << 3,   // Disable forcing columns to fit within window
    487    ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4    // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
    488};
    489
    490// Extend ImGuiSelectableFlags_
    491enum ImGuiSelectableFlagsPrivate_
    492{
    493    // NB: need to be in sync with last value of ImGuiSelectableFlags_
    494    ImGuiSelectableFlags_NoHoldingActiveID  = 1 << 20,
    495    ImGuiSelectableFlags_SelectOnClick      = 1 << 21,  // Override button behavior to react on Click (default is Click+Release)
    496    ImGuiSelectableFlags_SelectOnRelease    = 1 << 22,  // Override button behavior to react on Release (default is Click+Release)
    497    ImGuiSelectableFlags_SpanAvailWidth     = 1 << 23,  // 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)
    498    ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 24,  // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
    499    ImGuiSelectableFlags_SetNavIdOnHover    = 1 << 25
    500};
    501
    502// Extend ImGuiTreeNodeFlags_
    503enum ImGuiTreeNodeFlagsPrivate_
    504{
    505    ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20
    506};
    507
    508enum ImGuiSeparatorFlags_
    509{
    510    ImGuiSeparatorFlags_None                = 0,
    511    ImGuiSeparatorFlags_Horizontal          = 1 << 0,   // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
    512    ImGuiSeparatorFlags_Vertical            = 1 << 1,
    513    ImGuiSeparatorFlags_SpanAllColumns      = 1 << 2
    514};
    515
    516// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
    517// This is going to be exposed in imgui.h when stabilized enough.
    518enum ImGuiItemFlags_
    519{
    520    ImGuiItemFlags_None                     = 0,
    521    ImGuiItemFlags_NoTabStop                = 1 << 0,  // false
    522    ImGuiItemFlags_ButtonRepeat             = 1 << 1,  // false    // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
    523    ImGuiItemFlags_Disabled                 = 1 << 2,  // false    // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
    524    ImGuiItemFlags_NoNav                    = 1 << 3,  // false
    525    ImGuiItemFlags_NoNavDefaultFocus        = 1 << 4,  // false
    526    ImGuiItemFlags_SelectableDontClosePopup = 1 << 5,  // false    // MenuItem/Selectable() automatically closes current Popup window
    527    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)
    528    ImGuiItemFlags_Default_                 = 0
    529};
    530
    531// Storage for LastItem data
    532enum ImGuiItemStatusFlags_
    533{
    534    ImGuiItemStatusFlags_None               = 0,
    535    ImGuiItemStatusFlags_HoveredRect        = 1 << 0,
    536    ImGuiItemStatusFlags_HasDisplayRect     = 1 << 1,
    537    ImGuiItemStatusFlags_Edited             = 1 << 2,   // Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
    538    ImGuiItemStatusFlags_ToggledSelection   = 1 << 3,   // Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected" because reporting the change allows us to handle clipping with less issues.
    539    ImGuiItemStatusFlags_ToggledOpen        = 1 << 4,   // Set when TreeNode() reports toggling their open state.
    540    ImGuiItemStatusFlags_HasDeactivated     = 1 << 5,   // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag.
    541    ImGuiItemStatusFlags_Deactivated        = 1 << 6    // Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
    542
    543#ifdef IMGUI_ENABLE_TEST_ENGINE
    544    , // [imgui_tests only]
    545    ImGuiItemStatusFlags_Openable           = 1 << 10,  //
    546    ImGuiItemStatusFlags_Opened             = 1 << 11,  //
    547    ImGuiItemStatusFlags_Checkable          = 1 << 12,  //
    548    ImGuiItemStatusFlags_Checked            = 1 << 13   //
    549#endif
    550};
    551
    552enum ImGuiTextFlags_
    553{
    554    ImGuiTextFlags_None = 0,
    555    ImGuiTextFlags_NoWidthForLargeClippedText = 1 << 0
    556};
    557
    558enum ImGuiTooltipFlags_
    559{
    560    ImGuiTooltipFlags_None = 0,
    561    ImGuiTooltipFlags_OverridePreviousTooltip = 1 << 0      // Override will clear/ignore previously submitted tooltip (defaults to append)
    562};
    563
    564// FIXME: this is in development, not exposed/functional as a generic feature yet.
    565// Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2
    566enum ImGuiLayoutType_
    567{
    568    ImGuiLayoutType_Horizontal = 0,
    569    ImGuiLayoutType_Vertical = 1
    570};
    571
    572enum ImGuiLogType
    573{
    574    ImGuiLogType_None = 0,
    575    ImGuiLogType_TTY,
    576    ImGuiLogType_File,
    577    ImGuiLogType_Buffer,
    578    ImGuiLogType_Clipboard
    579};
    580
    581// X/Y enums are fixed to 0/1 so they may be used to index ImVec2
    582enum ImGuiAxis
    583{
    584    ImGuiAxis_None = -1,
    585    ImGuiAxis_X = 0,
    586    ImGuiAxis_Y = 1
    587};
    588
    589enum ImGuiPlotType
    590{
    591    ImGuiPlotType_Lines,
    592    ImGuiPlotType_Histogram
    593};
    594
    595enum ImGuiInputSource
    596{
    597    ImGuiInputSource_None = 0,
    598    ImGuiInputSource_Mouse,
    599    ImGuiInputSource_Nav,
    600    ImGuiInputSource_NavKeyboard,   // Only used occasionally for storage, not tested/handled by most code
    601    ImGuiInputSource_NavGamepad,    // "
    602    ImGuiInputSource_COUNT
    603};
    604
    605// FIXME-NAV: Clarify/expose various repeat delay/rate
    606enum ImGuiInputReadMode
    607{
    608    ImGuiInputReadMode_Down,
    609    ImGuiInputReadMode_Pressed,
    610    ImGuiInputReadMode_Released,
    611    ImGuiInputReadMode_Repeat,
    612    ImGuiInputReadMode_RepeatSlow,
    613    ImGuiInputReadMode_RepeatFast
    614};
    615
    616enum ImGuiNavHighlightFlags_
    617{
    618    ImGuiNavHighlightFlags_None         = 0,
    619    ImGuiNavHighlightFlags_TypeDefault  = 1 << 0,
    620    ImGuiNavHighlightFlags_TypeThin     = 1 << 1,
    621    ImGuiNavHighlightFlags_AlwaysDraw   = 1 << 2,       // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse.
    622    ImGuiNavHighlightFlags_NoRounding   = 1 << 3
    623};
    624
    625enum ImGuiNavDirSourceFlags_
    626{
    627    ImGuiNavDirSourceFlags_None         = 0,
    628    ImGuiNavDirSourceFlags_Keyboard     = 1 << 0,
    629    ImGuiNavDirSourceFlags_PadDPad      = 1 << 1,
    630    ImGuiNavDirSourceFlags_PadLStick    = 1 << 2
    631};
    632
    633enum ImGuiNavMoveFlags_
    634{
    635    ImGuiNavMoveFlags_None                  = 0,
    636    ImGuiNavMoveFlags_LoopX                 = 1 << 0,   // On failed request, restart from opposite side
    637    ImGuiNavMoveFlags_LoopY                 = 1 << 1,
    638    ImGuiNavMoveFlags_WrapX                 = 1 << 2,   // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left)
    639    ImGuiNavMoveFlags_WrapY                 = 1 << 3,   // This is not super useful for provided for completeness
    640    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)
    641    ImGuiNavMoveFlags_AlsoScoreVisibleSet   = 1 << 5,   // Store alternate result in NavMoveResultLocalVisibleSet that only comprise elements that are already fully visible.
    642    ImGuiNavMoveFlags_ScrollToEdge          = 1 << 6
    643};
    644
    645enum ImGuiNavForward
    646{
    647    ImGuiNavForward_None,
    648    ImGuiNavForward_ForwardQueued,
    649    ImGuiNavForward_ForwardActive
    650};
    651
    652enum ImGuiNavLayer
    653{
    654    ImGuiNavLayer_Main  = 0,    // Main scrolling layer
    655    ImGuiNavLayer_Menu  = 1,    // Menu layer (access with Alt/ImGuiNavInput_Menu)
    656    ImGuiNavLayer_COUNT
    657};
    658
    659enum ImGuiPopupPositionPolicy
    660{
    661    ImGuiPopupPositionPolicy_Default,
    662    ImGuiPopupPositionPolicy_ComboBox
    663};
    664
    665// 1D vector (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
    666struct ImVec1
    667{
    668    float   x;
    669    ImVec1()         { x = 0.0f; }
    670    ImVec1(float _x) { x = _x; }
    671};
    672
    673// 2D vector (half-size integer)
    674struct ImVec2ih
    675{
    676    short   x, y;
    677    ImVec2ih()                           { x = y = 0; }
    678    ImVec2ih(short _x, short _y)         { x = _x; y = _y; }
    679    explicit ImVec2ih(const ImVec2& rhs) { x = (short)rhs.x; y = (short)rhs.y; }
    680};
    681
    682// 2D axis aligned bounding-box
    683// NB: we can't rely on ImVec2 math operators being available here
    684struct IMGUI_API ImRect
    685{
    686    ImVec2      Min;    // Upper-left
    687    ImVec2      Max;    // Lower-right
    688
    689    ImRect()                                        : Min(0.0f, 0.0f), Max(0.0f, 0.0f)              {}
    690    ImRect(const ImVec2& min, const ImVec2& max)    : Min(min), Max(max)                            {}
    691    ImRect(const ImVec4& v)                         : Min(v.x, v.y), Max(v.z, v.w)                  {}
    692    ImRect(float x1, float y1, float x2, float y2)  : Min(x1, y1), Max(x2, y2)                      {}
    693
    694    ImVec2      GetCenter() const                   { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
    695    ImVec2      GetSize() const                     { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
    696    float       GetWidth() const                    { return Max.x - Min.x; }
    697    float       GetHeight() const                   { return Max.y - Min.y; }
    698    ImVec2      GetTL() const                       { return Min; }                   // Top-left
    699    ImVec2      GetTR() const                       { return ImVec2(Max.x, Min.y); }  // Top-right
    700    ImVec2      GetBL() const                       { return ImVec2(Min.x, Max.y); }  // Bottom-left
    701    ImVec2      GetBR() const                       { return Max; }                   // Bottom-right
    702    bool        Contains(const ImVec2& p) const     { return p.x     >= Min.x && p.y     >= Min.y && p.x     <  Max.x && p.y     <  Max.y; }
    703    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; }
    704    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; }
    705    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; }
    706    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; }
    707    void        Expand(const float amount)          { Min.x -= amount;   Min.y -= amount;   Max.x += amount;   Max.y += amount; }
    708    void        Expand(const ImVec2& amount)        { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
    709    void        Translate(const ImVec2& d)          { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; }
    710    void        TranslateX(float dx)                { Min.x += dx; Max.x += dx; }
    711    void        TranslateY(float dy)                { Min.y += dy; Max.y += dy; }
    712    void        ClipWith(const ImRect& r)           { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); }                   // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
    713    void        ClipWithFull(const ImRect& r)       { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped.
    714    void        Floor()                             { Min.x = IM_FLOOR(Min.x); Min.y = IM_FLOOR(Min.y); Max.x = IM_FLOOR(Max.x); Max.y = IM_FLOOR(Max.y); }
    715    bool        IsInverted() const                  { return Min.x > Max.x || Min.y > Max.y; }
    716};
    717
    718// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo().
    719struct ImGuiDataTypeInfo
    720{
    721    size_t      Size;           // Size in byte
    722    const char* PrintFmt;       // Default printf format for the type
    723    const char* ScanFmt;        // Default scanf format for the type
    724};
    725
    726// Stacked color modifier, backup of modified data so we can restore it
    727struct ImGuiColorMod
    728{
    729    ImGuiCol    Col;
    730    ImVec4      BackupValue;
    731};
    732
    733// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
    734struct ImGuiStyleMod
    735{
    736    ImGuiStyleVar   VarIdx;
    737    union           { int BackupInt[2]; float BackupFloat[2]; };
    738    ImGuiStyleMod(ImGuiStyleVar idx, int v)     { VarIdx = idx; BackupInt[0] = v; }
    739    ImGuiStyleMod(ImGuiStyleVar idx, float v)   { VarIdx = idx; BackupFloat[0] = v; }
    740    ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v)  { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
    741};
    742
    743// Stacked storage data for BeginGroup()/EndGroup()
    744struct ImGuiGroupData
    745{
    746    ImVec2      BackupCursorPos;
    747    ImVec2      BackupCursorMaxPos;
    748    ImVec1      BackupIndent;
    749    ImVec1      BackupGroupOffset;
    750    ImVec2      BackupCurrLineSize;
    751    float       BackupCurrLineTextBaseOffset;
    752    ImGuiID     BackupActiveIdIsAlive;
    753    bool        BackupActiveIdPreviousFrameIsAlive;
    754    bool        EmitItem;
    755};
    756
    757// Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper.
    758struct IMGUI_API ImGuiMenuColumns
    759{
    760    float       Spacing;
    761    float       Width, NextWidth;
    762    float       Pos[3], NextWidths[3];
    763
    764    ImGuiMenuColumns();
    765    void        Update(int count, float spacing, bool clear);
    766    float       DeclColumns(float w0, float w1, float w2);
    767    float       CalcExtraSpace(float avail_w) const;
    768};
    769
    770// Internal state of the currently focused/edited text input box
    771// For a given item ID, access with ImGui::GetInputTextState()
    772struct IMGUI_API ImGuiInputTextState
    773{
    774    ImGuiID                 ID;                     // widget id owning the text state
    775    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.
    776    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.
    777    ImVector<char>          TextA;                  // temporary UTF8 buffer for callbacks and other operations. this is not updated in every code-path! size=capacity.
    778    ImVector<char>          InitialTextA;           // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
    779    bool                    TextAIsValid;           // temporary UTF8 buffer is not initially valid before we make the widget active (until then we pull the data from user argument)
    780    int                     BufCapacityA;           // end-user buffer capacity
    781    float                   ScrollX;                // horizontal scrolling/offset
    782    ImStb::STB_TexteditState Stb;                   // state for stb_textedit.h
    783    float                   CursorAnim;             // timer for cursor blink, reset on every user action so the cursor reappears immediately
    784    bool                    CursorFollow;           // set when we want scrolling to follow the current cursor position (not always!)
    785    bool                    SelectedAllMouseLock;   // after a double-click to select all, we ignore further mouse drags to update selection
    786    ImGuiInputTextFlags     UserFlags;              // Temporarily set while we call user's callback
    787    ImGuiInputTextCallback  UserCallback;           // "
    788    void*                   UserCallbackData;       // "
    789
    790    ImGuiInputTextState()                   { memset(this, 0, sizeof(*this)); }
    791    void        ClearText()                 { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); }
    792    void        ClearFreeMemory()           { TextW.clear(); TextA.clear(); InitialTextA.clear(); }
    793    int         GetUndoAvailCount() const   { return Stb.undostate.undo_point; }
    794    int         GetRedoAvailCount() const   { return STB_TEXTEDIT_UNDOSTATECOUNT - Stb.undostate.redo_point; }
    795    void        OnKeyPressed(int key);      // Cannot be inline because we call in code in stb_textedit.h implementation
    796
    797    // Cursor & Selection
    798    void        CursorAnimReset()           { CursorAnim = -0.30f; }                                   // After a user-input the cursor stays on for a while without blinking
    799    void        CursorClamp()               { Stb.cursor = ImMin(Stb.cursor, CurLenW); Stb.select_start = ImMin(Stb.select_start, CurLenW); Stb.select_end = ImMin(Stb.select_end, CurLenW); }
    800    bool        HasSelection() const        { return Stb.select_start != Stb.select_end; }
    801    void        ClearSelection()            { Stb.select_start = Stb.select_end = Stb.cursor; }
    802    void        SelectAll()                 { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
    803};
    804
    805// Windows data saved in imgui.ini file
    806// Because we never destroy or rename ImGuiWindowSettings, we can store the names in a separate buffer easily.
    807// (this is designed to be stored in a ImChunkStream buffer, with the variable-length Name following our structure)
    808struct ImGuiWindowSettings
    809{
    810    ImGuiID     ID;
    811    ImVec2ih    Pos;
    812    ImVec2ih    Size;
    813    bool        Collapsed;
    814
    815    ImGuiWindowSettings()       { ID = 0; Pos = Size = ImVec2ih(0, 0); Collapsed = false; }
    816    char* GetName()             { return (char*)(this + 1); }
    817};
    818
    819struct ImGuiSettingsHandler
    820{
    821    const char* TypeName;       // Short description stored in .ini file. Disallowed characters: '[' ']'
    822    ImGuiID     TypeHash;       // == ImHashStr(TypeName)
    823    void*       (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name);              // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
    824    void        (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
    825    void        (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf);      // Write: Output every entries into 'out_buf'
    826    void*       UserData;
    827
    828    ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); }
    829};
    830
    831// Storage for current popup stack
    832struct ImGuiPopupData
    833{
    834    ImGuiID             PopupId;        // Set on OpenPopup()
    835    ImGuiWindow*        Window;         // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
    836    ImGuiWindow*        SourceWindow;   // Set on OpenPopup() copy of NavWindow at the time of opening the popup
    837    int                 OpenFrameCount; // Set on OpenPopup()
    838    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)
    839    ImVec2              OpenPopupPos;   // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse)
    840    ImVec2              OpenMousePos;   // Set on OpenPopup(), copy of mouse position at the time of opening popup
    841
    842    ImGuiPopupData() { PopupId = 0; Window = SourceWindow = NULL; OpenFrameCount = -1; OpenParentId = 0; }
    843};
    844
    845struct ImGuiColumnData
    846{
    847    float               OffsetNorm;         // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
    848    float               OffsetNormBeforeResize;
    849    ImGuiColumnsFlags   Flags;              // Not exposed
    850    ImRect              ClipRect;
    851
    852    ImGuiColumnData()   { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = ImGuiColumnsFlags_None; }
    853};
    854
    855struct ImGuiColumns
    856{
    857    ImGuiID             ID;
    858    ImGuiColumnsFlags   Flags;
    859    bool                IsFirstFrame;
    860    bool                IsBeingResized;
    861    int                 Current;
    862    int                 Count;
    863    float               OffMinX, OffMaxX;       // Offsets from HostWorkRect.Min.x
    864    float               LineMinY, LineMaxY;
    865    float               HostCursorPosY;         // Backup of CursorPos at the time of BeginColumns()
    866    float               HostCursorMaxPosX;      // Backup of CursorMaxPos at the time of BeginColumns()
    867    ImRect              HostClipRect;           // Backup of ClipRect at the time of BeginColumns()
    868    ImRect              HostWorkRect;           // Backup of WorkRect at the time of BeginColumns()
    869    ImVector<ImGuiColumnData> Columns;
    870    ImDrawListSplitter  Splitter;
    871
    872    ImGuiColumns()      { Clear(); }
    873    void Clear()
    874    {
    875        ID = 0;
    876        Flags = ImGuiColumnsFlags_None;
    877        IsFirstFrame = false;
    878        IsBeingResized = false;
    879        Current = 0;
    880        Count = 1;
    881        OffMinX = OffMaxX = 0.0f;
    882        LineMinY = LineMaxY = 0.0f;
    883        HostCursorPosY = 0.0f;
    884        HostCursorMaxPosX = 0.0f;
    885        Columns.clear();
    886    }
    887};
    888
    889// ImDrawList: Helper function to calculate a circle's segment count given its radius and a "maximum error" value.
    890#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN                     12
    891#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX                     512
    892#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR)    ImClamp((int)((IM_PI * 2.0f) / ImAcos(((_RAD) - (_MAXERROR)) / (_RAD))), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX)
    893
    894// ImDrawList: You may set this to higher values (e.g. 2 or 3) to increase tessellation of fast rounded corners path.
    895#ifndef IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER
    896#define IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER             1
    897#endif
    898
    899// Data shared between all ImDrawList instances
    900// 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.
    901struct IMGUI_API ImDrawListSharedData
    902{
    903    ImVec2          TexUvWhitePixel;            // UV of white pixel in the atlas
    904    ImFont*         Font;                       // Current/default font (optional, for simplified AddText overload)
    905    float           FontSize;                   // Current/default font size (optional, for simplified AddText overload)
    906    float           CurveTessellationTol;       // Tessellation tolerance when using PathBezierCurveTo()
    907    float           CircleSegmentMaxError;      // Number of circle segments to use per pixel of radius for AddCircle() etc
    908    ImVec4          ClipRectFullscreen;         // Value for PushClipRectFullscreen()
    909    ImDrawListFlags InitialFlags;               // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards)
    910
    911    // [Internal] Lookup tables
    912    ImVec2          ArcFastVtx[12 * IM_DRAWLIST_ARCFAST_TESSELLATION_MULTIPLIER];  // FIXME: Bake rounded corners fill/borders in atlas
    913    ImU8            CircleSegmentCounts[64];    // Precomputed segment count for given radius (array index + 1) before we calculate it dynamically (to avoid calculation overhead)
    914
    915    ImDrawListSharedData();
    916    void SetCircleSegmentMaxError(float max_error);
    917};
    918
    919struct ImDrawDataBuilder
    920{
    921    ImVector<ImDrawList*>   Layers[2];           // Global layers for: regular, tooltip
    922
    923    void Clear()            { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
    924    void ClearFreeMemory()  { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
    925    IMGUI_API void FlattenIntoSingleLayer();
    926};
    927
    928struct ImGuiNavMoveResult
    929{
    930    ImGuiWindow*    Window;             // Best candidate window
    931    ImGuiID         ID;                 // Best candidate ID
    932    ImGuiID         FocusScopeId;       // Best candidate focus scope ID
    933    float           DistBox;            // Best candidate box distance to current NavId
    934    float           DistCenter;         // Best candidate center distance to current NavId
    935    float           DistAxial;
    936    ImRect          RectRel;            // Best candidate bounding box in window relative space
    937
    938    ImGuiNavMoveResult() { Clear(); }
    939    void Clear()         { Window = NULL; ID = FocusScopeId = 0; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); }
    940};
    941
    942enum ImGuiNextWindowDataFlags_
    943{
    944    ImGuiNextWindowDataFlags_None               = 0,
    945    ImGuiNextWindowDataFlags_HasPos             = 1 << 0,
    946    ImGuiNextWindowDataFlags_HasSize            = 1 << 1,
    947    ImGuiNextWindowDataFlags_HasContentSize     = 1 << 2,
    948    ImGuiNextWindowDataFlags_HasCollapsed       = 1 << 3,
    949    ImGuiNextWindowDataFlags_HasSizeConstraint  = 1 << 4,
    950    ImGuiNextWindowDataFlags_HasFocus           = 1 << 5,
    951    ImGuiNextWindowDataFlags_HasBgAlpha         = 1 << 6
    952};
    953
    954// Storage for SetNexWindow** functions
    955struct ImGuiNextWindowData
    956{
    957    ImGuiNextWindowDataFlags    Flags;
    958    ImGuiCond                   PosCond;
    959    ImGuiCond                   SizeCond;
    960    ImGuiCond                   CollapsedCond;
    961    ImVec2                      PosVal;
    962    ImVec2                      PosPivotVal;
    963    ImVec2                      SizeVal;
    964    ImVec2                      ContentSizeVal;
    965    bool                        CollapsedVal;
    966    ImRect                      SizeConstraintRect;
    967    ImGuiSizeCallback           SizeCallback;
    968    void*                       SizeCallbackUserData;
    969    float                       BgAlphaVal;             // Override background alpha
    970    ImVec2                      MenuBarOffsetMinVal;    // *Always on* This is not exposed publicly, so we don't clear it.
    971
    972    ImGuiNextWindowData()       { memset(this, 0, sizeof(*this)); }
    973    inline void ClearFlags()    { Flags = ImGuiNextWindowDataFlags_None; }
    974};
    975
    976enum ImGuiNextItemDataFlags_
    977{
    978    ImGuiNextItemDataFlags_None     = 0,
    979    ImGuiNextItemDataFlags_HasWidth = 1 << 0,
    980    ImGuiNextItemDataFlags_HasOpen  = 1 << 1
    981};
    982
    983struct ImGuiNextItemData
    984{
    985    ImGuiNextItemDataFlags      Flags;
    986    float                       Width;          // Set by SetNextItemWidth()
    987    ImGuiID                     FocusScopeId;   // Set by SetNextItemMultiSelectData() (!= 0 signify value has been set, so it's an alternate version of HasSelectionData, we don't use Flags for this because they are cleared too early. This is mostly used for debugging)
    988    ImGuiCond                   OpenCond;
    989    bool                        OpenVal;        // Set by SetNextItemOpen()
    990
    991    ImGuiNextItemData()         { memset(this, 0, sizeof(*this)); }
    992    inline void ClearFlags()    { Flags = ImGuiNextItemDataFlags_None; } // Also cleared manually by ItemAdd()!
    993};
    994
    995//-----------------------------------------------------------------------------
    996// Tabs
    997//-----------------------------------------------------------------------------
    998
    999struct ImGuiShrinkWidthItem
   1000{
   1001    int             Index;
   1002    float           Width;
   1003};
   1004
   1005struct ImGuiPtrOrIndex
   1006{
   1007    void*           Ptr;                // Either field can be set, not both. e.g. Dock node tab bars are loose while BeginTabBar() ones are in a pool.
   1008    int             Index;              // Usually index in a main pool.
   1009
   1010    ImGuiPtrOrIndex(void* ptr)          { Ptr = ptr; Index = -1; }
   1011    ImGuiPtrOrIndex(int index)          { Ptr = NULL; Index = index; }
   1012};
   1013
   1014//-----------------------------------------------------------------------------
   1015// Main Dear ImGui context
   1016//-----------------------------------------------------------------------------
   1017
   1018struct ImGuiContext
   1019{
   1020    bool                    Initialized;
   1021    bool                    FontAtlasOwnedByContext;            // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
   1022    ImGuiIO                 IO;
   1023    ImGuiStyle              Style;
   1024    ImFont*                 Font;                               // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
   1025    float                   FontSize;                           // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
   1026    float                   FontBaseSize;                       // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
   1027    ImDrawListSharedData    DrawListSharedData;
   1028    double                  Time;
   1029    int                     FrameCount;
   1030    int                     FrameCountEnded;
   1031    int                     FrameCountRendered;
   1032    bool                    WithinFrameScope;                   // Set by NewFrame(), cleared by EndFrame()
   1033    bool                    WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed
   1034    bool                    WithinEndChild;                     // Set within EndChild()
   1035
   1036    // Windows state
   1037    ImVector<ImGuiWindow*>  Windows;                            // Windows, sorted in display order, back to front
   1038    ImVector<ImGuiWindow*>  WindowsFocusOrder;                  // Windows, sorted in focus order, back to front. (FIXME: We could only store root windows here! Need to sort out the Docking equivalent which is RootWindowDockStop and is unfortunately a little more dynamic)
   1039    ImVector<ImGuiWindow*>  WindowsTempSortBuffer;              // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child
   1040    ImVector<ImGuiWindow*>  CurrentWindowStack;
   1041    ImGuiStorage            WindowsById;                        // Map window's ImGuiID to ImGuiWindow*
   1042    int                     WindowsActiveCount;                 // Number of unique windows submitted by frame
   1043    ImGuiWindow*            CurrentWindow;                      // Window being drawn into
   1044    ImGuiWindow*            HoveredWindow;                      // Will catch mouse inputs
   1045    ImGuiWindow*            HoveredRootWindow;                  // Will catch mouse inputs (for focus/move only)
   1046    ImGuiWindow*            MovingWindow;                       // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
   1047    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.
   1048    ImVec2                  WheelingWindowRefMousePos;
   1049    float                   WheelingWindowTimer;
   1050
   1051    // Item/widgets state and tracking information
   1052    ImGuiID                 HoveredId;                          // Hovered widget
   1053    bool                    HoveredIdAllowOverlap;
   1054    ImGuiID                 HoveredIdPreviousFrame;
   1055    float                   HoveredIdTimer;                     // Measure contiguous hovering time
   1056    float                   HoveredIdNotActiveTimer;            // Measure contiguous hovering time where the item has not been active
   1057    ImGuiID                 ActiveId;                           // Active widget
   1058    ImGuiID                 ActiveIdIsAlive;                    // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
   1059    float                   ActiveIdTimer;
   1060    bool                    ActiveIdIsJustActivated;            // Set at the time of activation for one frame
   1061    bool                    ActiveIdAllowOverlap;               // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
   1062    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.
   1063    bool                    ActiveIdHasBeenEditedBefore;        // Was the value associated to the widget Edited over the course of the Active state.
   1064    bool                    ActiveIdHasBeenEditedThisFrame;
   1065    ImU32                   ActiveIdUsingNavDirMask;            // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
   1066    ImU32                   ActiveIdUsingNavInputMask;          // Active widget will want to read those nav inputs.
   1067    ImU64                   ActiveIdUsingKeyInputMask;          // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
   1068    ImVec2                  ActiveIdClickOffset;                // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
   1069    ImGuiWindow*            ActiveIdWindow;
   1070    ImGuiInputSource        ActiveIdSource;                     // Activating with mouse or nav (gamepad/keyboard)
   1071    int                     ActiveIdMouseButton;
   1072    ImGuiID                 ActiveIdPreviousFrame;
   1073    bool                    ActiveIdPreviousFrameIsAlive;
   1074    bool                    ActiveIdPreviousFrameHasBeenEditedBefore;
   1075    ImGuiWindow*            ActiveIdPreviousFrameWindow;
   1076    ImGuiID                 LastActiveId;                       // Store the last non-zero ActiveId, useful for animation.
   1077    float                   LastActiveIdTimer;                  // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
   1078
   1079    // Next window/item data
   1080    ImGuiNextWindowData     NextWindowData;                     // Storage for SetNextWindow** functions
   1081    ImGuiNextItemData       NextItemData;                       // Storage for SetNextItem** functions
   1082
   1083    // Shared stacks
   1084    ImVector<ImGuiColorMod> ColorModifiers;                     // Stack for PushStyleColor()/PopStyleColor()
   1085    ImVector<ImGuiStyleMod> StyleModifiers;                     // Stack for PushStyleVar()/PopStyleVar()
   1086    ImVector<ImFont*>       FontStack;                          // Stack for PushFont()/PopFont()
   1087    ImVector<ImGuiPopupData>OpenPopupStack;                     // Which popups are open (persistent)
   1088    ImVector<ImGuiPopupData>BeginPopupStack;                    // Which level of BeginPopup() we are in (reset every frame)
   1089
   1090    // Gamepad/keyboard Navigation
   1091    ImGuiWindow*            NavWindow;                          // Focused window for navigation. Could be called 'FocusWindow'
   1092    ImGuiID                 NavId;                              // Focused item for navigation
   1093    ImGuiID                 NavFocusScopeId;
   1094    ImGuiID                 NavActivateId;                      // ~~ (g.ActiveId == 0) && IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0, also set when calling ActivateItem()
   1095    ImGuiID                 NavActivateDownId;                  // ~~ IsNavInputDown(ImGuiNavInput_Activate) ? NavId : 0
   1096    ImGuiID                 NavActivatePressedId;               // ~~ IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0
   1097    ImGuiID                 NavInputId;                         // ~~ IsNavInputPressed(ImGuiNavInput_Input) ? NavId : 0
   1098    ImGuiID                 NavJustTabbedId;                    // Just tabbed to this id.
   1099    ImGuiID                 NavJustMovedToId;                   // Just navigated to this id (result of a successfully MoveRequest).
   1100    ImGuiID                 NavJustMovedToFocusScopeId;         // Just navigated to this focus scope id (result of a successfully MoveRequest).
   1101    ImGuiKeyModFlags        NavJustMovedToKeyMods;
   1102    ImGuiID                 NavNextActivateId;                  // Set by ActivateItem(), queued until next frame.
   1103    ImGuiInputSource        NavInputSource;                     // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
   1104    ImRect                  NavScoringRect;                     // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring.
   1105    int                     NavScoringCount;                    // Metrics for debugging
   1106    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.
   1107    int                     NavIdTabCounter;                    // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
   1108    bool                    NavIdIsAlive;                       // Nav widget has been seen this frame ~~ NavRefRectRel is valid
   1109    bool                    NavMousePosDirty;                   // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
   1110    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)
   1111    bool                    NavDisableMouseHover;               // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
   1112    bool                    NavAnyRequest;                      // ~~ NavMoveRequest || NavInitRequest
   1113    bool                    NavInitRequest;                     // Init request for appearing window to select first item
   1114    bool                    NavInitRequestFromMove;
   1115    ImGuiID                 NavInitResultId;
   1116    ImRect                  NavInitResultRectRel;
   1117    bool                    NavMoveFromClampedRefRect;          // Set by manual scrolling, if we scroll to a point where NavId isn't visible we reset navigation from visible items
   1118    bool                    NavMoveRequest;                     // Move request for this frame
   1119    ImGuiNavMoveFlags       NavMoveRequestFlags;
   1120    ImGuiNavForward         NavMoveRequestForward;              // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu)
   1121    ImGuiKeyModFlags        NavMoveRequestKeyMods;
   1122    ImGuiDir                NavMoveDir, NavMoveDirLast;         // Direction of the move request (left/right/up/down), direction of the previous move request
   1123    ImGuiDir                NavMoveClipDir;                     // FIXME-NAV: Describe the purpose of this better. Might want to rename?
   1124    ImGuiNavMoveResult      NavMoveResultLocal;                 // Best move request candidate within NavWindow
   1125    ImGuiNavMoveResult      NavMoveResultLocalVisibleSet;       // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
   1126    ImGuiNavMoveResult      NavMoveResultOther;                 // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
   1127
   1128    // Navigation: Windowing (CTRL+TAB, holding Menu button + directional pads to move/resize)
   1129    ImGuiWindow*            NavWindowingTarget;                 // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed top-most.
   1130    ImGuiWindow*            NavWindowingTargetAnim;             // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f
   1131    ImGuiWindow*            NavWindowingList;
   1132    float                   NavWindowingTimer;
   1133    float                   NavWindowingHighlightAlpha;
   1134    bool                    NavWindowingToggleLayer;
   1135
   1136    // Legacy Focus/Tabbing system (older than Nav, active even if Nav is disabled, misnamed. FIXME-NAV: This needs a redesign!)
   1137    ImGuiWindow*            FocusRequestCurrWindow;             //
   1138    ImGuiWindow*            FocusRequestNextWindow;             //
   1139    int                     FocusRequestCurrCounterRegular;     // Any item being requested for focus, stored as an index (we on layout to be stable between the frame pressing TAB and the next frame, semi-ouch)
   1140    int                     FocusRequestCurrCounterTabStop;     // Tab item being requested for focus, stored as an index
   1141    int                     FocusRequestNextCounterRegular;     // Stored for next frame
   1142    int                     FocusRequestNextCounterTabStop;     // "
   1143    bool                    FocusTabPressed;                    //
   1144
   1145    // Render
   1146    ImDrawData              DrawData;                           // Main ImDrawData instance to pass render information to the user
   1147    ImDrawDataBuilder       DrawDataBuilder;
   1148    float                   DimBgRatio;                         // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
   1149    ImDrawList              BackgroundDrawList;                 // First draw list to be rendered.
   1150    ImDrawList              ForegroundDrawList;                 // Last draw list to be rendered. This is where we the render software mouse cursor (if io.MouseDrawCursor is set) and most debug overlays.
   1151    ImGuiMouseCursor        MouseCursor;
   1152
   1153    // Drag and Drop
   1154    bool                    DragDropActive;
   1155    bool                    DragDropWithinSource;               // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag source.
   1156    bool                    DragDropWithinTarget;               // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag target.
   1157    ImGuiDragDropFlags      DragDropSourceFlags;
   1158    int                     DragDropSourceFrameCount;
   1159    int                     DragDropMouseButton;
   1160    ImGuiPayload            DragDropPayload;
   1161    ImRect                  DragDropTargetRect;                 // Store rectangle of current target candidate (we favor small targets when overlapping)
   1162    ImGuiID                 DragDropTargetId;
   1163    ImGuiDragDropFlags      DragDropAcceptFlags;
   1164    float                   DragDropAcceptIdCurrRectSurface;    // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
   1165    ImGuiID                 DragDropAcceptIdCurr;               // Target item id (set at the time of accepting the payload)
   1166    ImGuiID                 DragDropAcceptIdPrev;               // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
   1167    int                     DragDropAcceptFrameCount;           // Last time a target expressed a desire to accept the source
   1168    ImVector<unsigned char> DragDropPayloadBufHeap;             // We don't expose the ImVector<> directly, ImGuiPayload only holds pointer+size
   1169    unsigned char           DragDropPayloadBufLocal[16];        // Local buffer for small payloads
   1170
   1171    // Tab bars
   1172    ImGuiTabBar*                    CurrentTabBar;
   1173    ImPool<ImGuiTabBar>             TabBars;
   1174    ImVector<ImGuiPtrOrIndex>       CurrentTabBarStack;
   1175    ImVector<ImGuiShrinkWidthItem>  ShrinkWidthBuffer;
   1176
   1177    // Widget state
   1178    ImVec2                  LastValidMousePos;
   1179    ImGuiInputTextState     InputTextState;
   1180    ImFont                  InputTextPasswordFont;
   1181    ImGuiID                 TempInputId;                        // Temporary text input when CTRL+clicking on a slider, etc.
   1182    ImGuiColorEditFlags     ColorEditOptions;                   // Store user options for color edit widgets
   1183    float                   ColorEditLastHue;                   // Backup of last Hue associated to LastColor[3], so we can restore Hue in lossy RGB<>HSV round trips
   1184    float                   ColorEditLastSat;                   // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips
   1185    float                   ColorEditLastColor[3];
   1186    ImVec4                  ColorPickerRef;                     // Initial/reference color at the time of opening the color picker.
   1187    bool                    DragCurrentAccumDirty;
   1188    float                   DragCurrentAccum;                   // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
   1189    float                   DragSpeedDefaultRatio;              // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
   1190    float                   ScrollbarClickDeltaToGrabCenter;    // Distance between mouse and center of grab box, normalized in parent space. Use storage?
   1191    int                     TooltipOverrideCount;
   1192    ImVector<char>          ClipboardHandlerData;               // If no custom clipboard handler is defined
   1193    ImVector<ImGuiID>       MenusIdSubmittedThisFrame;          // A list of menu IDs that were rendered at least once
   1194
   1195    // Platform support
   1196    ImVec2                  PlatformImePos;                     // Cursor position request & last passed to the OS Input Method Editor
   1197    ImVec2                  PlatformImeLastPos;
   1198
   1199    // Settings
   1200    bool                    SettingsLoaded;
   1201    float                   SettingsDirtyTimer;                 // Save .ini Settings to memory when time reaches zero
   1202    ImGuiTextBuffer         SettingsIniData;                    // In memory .ini settings
   1203    ImVector<ImGuiSettingsHandler>      SettingsHandlers;       // List of .ini settings handlers
   1204    ImChunkStream<ImGuiWindowSettings>  SettingsWindows;        // ImGuiWindow .ini settings entries
   1205
   1206    // Capture/Logging
   1207    bool                    LogEnabled;
   1208    ImGuiLogType            LogType;
   1209    ImFileHandle            LogFile;                            // If != NULL log to stdout/ file
   1210    ImGuiTextBuffer         LogBuffer;                          // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
   1211    float                   LogLinePosY;
   1212    bool                    LogLineFirstItem;
   1213    int                     LogDepthRef;
   1214    int                     LogDepthToExpand;
   1215    int                     LogDepthToExpandDefault;            // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call.
   1216
   1217    // Debug Tools
   1218    bool                    DebugItemPickerActive;
   1219    ImGuiID                 DebugItemPickerBreakId;             // Will call IM_DEBUG_BREAK() when encountering this id
   1220
   1221    // Misc
   1222    float                   FramerateSecPerFrame[120];          // Calculate estimate of framerate for user over the last 2 seconds.
   1223    int                     FramerateSecPerFrameIdx;
   1224    float                   FramerateSecPerFrameAccum;
   1225    int                     WantCaptureMouseNextFrame;          // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags
   1226    int                     WantCaptureKeyboardNextFrame;
   1227    int                     WantTextInputNextFrame;
   1228    char                    TempBuffer[1024*3+1];               // Temporary text buffer
   1229
   1230    ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(&DrawListSharedData), ForegroundDrawList(&DrawListSharedData)
   1231    {
   1232        Initialized = false;
   1233        Font = NULL;
   1234        FontSize = FontBaseSize = 0.0f;
   1235        FontAtlasOwnedByContext = shared_font_atlas ? false : true;
   1236        IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
   1237        Time = 0.0f;
   1238        FrameCount = 0;
   1239        FrameCountEnded = FrameCountRendered = -1;
   1240        WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false;
   1241
   1242        WindowsActiveCount = 0;
   1243        CurrentWindow = NULL;
   1244        HoveredWindow = NULL;
   1245        HoveredRootWindow = NULL;
   1246        MovingWindow = NULL;
   1247        WheelingWindow = NULL;
   1248        WheelingWindowTimer = 0.0f;
   1249
   1250        HoveredId = 0;
   1251        HoveredIdAllowOverlap = false;
   1252        HoveredIdPreviousFrame = 0;
   1253        HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
   1254        ActiveId = 0;
   1255        ActiveIdIsAlive = 0;
   1256        ActiveIdTimer = 0.0f;
   1257        ActiveIdIsJustActivated = false;
   1258        ActiveIdAllowOverlap = false;
   1259        ActiveIdHasBeenPressedBefore = false;
   1260        ActiveIdHasBeenEditedBefore = false;
   1261        ActiveIdHasBeenEditedThisFrame = false;
   1262        ActiveIdUsingNavDirMask = 0x00;
   1263        ActiveIdUsingNavInputMask = 0x00;
   1264        ActiveIdUsingKeyInputMask = 0x00;
   1265        ActiveIdClickOffset = ImVec2(-1,-1);
   1266        ActiveIdWindow = NULL;
   1267        ActiveIdSource = ImGuiInputSource_None;
   1268        ActiveIdMouseButton = 0;
   1269        ActiveIdPreviousFrame = 0;
   1270        ActiveIdPreviousFrameIsAlive = false;
   1271        ActiveIdPreviousFrameHasBeenEditedBefore = false;
   1272        ActiveIdPreviousFrameWindow = NULL;
   1273        LastActiveId = 0;
   1274        LastActiveIdTimer = 0.0f;
   1275
   1276        NavWindow = NULL;
   1277        NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
   1278        NavJustTabbedId = NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
   1279        NavJustMovedToKeyMods = ImGuiKeyModFlags_None;
   1280        NavInputSource = ImGuiInputSource_None;
   1281        NavScoringRect = ImRect();
   1282        NavScoringCount = 0;
   1283        NavLayer = ImGuiNavLayer_Main;
   1284        NavIdTabCounter = INT_MAX;
   1285        NavIdIsAlive = false;
   1286        NavMousePosDirty = false;
   1287        NavDisableHighlight = true;
   1288        NavDisableMouseHover = false;
   1289        NavAnyRequest = false;
   1290        NavInitRequest = false;
   1291        NavInitRequestFromMove = false;
   1292        NavInitResultId = 0;
   1293        NavMoveFromClampedRefRect = false;
   1294        NavMoveRequest = false;
   1295        NavMoveRequestFlags = ImGuiNavMoveFlags_None;
   1296        NavMoveRequestForward = ImGuiNavForward_None;
   1297        NavMoveRequestKeyMods = ImGuiKeyModFlags_None;
   1298        NavMoveDir = NavMoveDirLast = NavMoveClipDir = ImGuiDir_None;
   1299
   1300        NavWindowingTarget = NavWindowingTargetAnim = NavWindowingList = NULL;
   1301        NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
   1302        NavWindowingToggleLayer = false;
   1303
   1304        FocusRequestCurrWindow = FocusRequestNextWindow = NULL;
   1305        FocusRequestCurrCounterRegular = FocusRequestCurrCounterTabStop = INT_MAX;
   1306        FocusRequestNextCounterRegular = FocusRequestNextCounterTabStop = INT_MAX;
   1307        FocusTabPressed = false;
   1308
   1309        DimBgRatio = 0.0f;
   1310        BackgroundDrawList._OwnerName = "##Background"; // Give it a name for debugging
   1311        ForegroundDrawList._OwnerName = "##Foreground"; // Give it a name for debugging
   1312        MouseCursor = ImGuiMouseCursor_Arrow;
   1313
   1314        DragDropActive = DragDropWithinSource = DragDropWithinTarget = false;
   1315        DragDropSourceFlags = ImGuiDragDropFlags_None;
   1316        DragDropSourceFrameCount = -1;
   1317        DragDropMouseButton = -1;
   1318        DragDropTargetId = 0;
   1319        DragDropAcceptFlags = ImGuiDragDropFlags_None;
   1320        DragDropAcceptIdCurrRectSurface = 0.0f;
   1321        DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
   1322        DragDropAcceptFrameCount = -1;
   1323        memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal));
   1324
   1325        CurrentTabBar = NULL;
   1326
   1327        LastValidMousePos = ImVec2(0.0f, 0.0f);
   1328        TempInputId = 0;
   1329        ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
   1330        ColorEditLastHue = ColorEditLastSat = 0.0f;
   1331        ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX;
   1332        DragCurrentAccumDirty = false;
   1333        DragCurrentAccum = 0.0f;
   1334        DragSpeedDefaultRatio = 1.0f / 100.0f;
   1335        ScrollbarClickDeltaToGrabCenter = 0.0f;
   1336        TooltipOverrideCount = 0;
   1337
   1338        PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX);
   1339
   1340        SettingsLoaded = false;
   1341        SettingsDirtyTimer = 0.0f;
   1342
   1343        LogEnabled = false;
   1344        LogType = ImGuiLogType_None;
   1345        LogFile = NULL;
   1346        LogLinePosY = FLT_MAX;
   1347        LogLineFirstItem = false;
   1348        LogDepthRef = 0;
   1349        LogDepthToExpand = LogDepthToExpandDefault = 2;
   1350
   1351        DebugItemPickerActive = false;
   1352        DebugItemPickerBreakId = 0;
   1353
   1354        memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
   1355        FramerateSecPerFrameIdx = 0;
   1356        FramerateSecPerFrameAccum = 0.0f;
   1357        WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
   1358        memset(TempBuffer, 0, sizeof(TempBuffer));
   1359    }
   1360};
   1361
   1362//-----------------------------------------------------------------------------
   1363// ImGuiWindow
   1364//-----------------------------------------------------------------------------
   1365
   1366// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
   1367// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered.
   1368struct IMGUI_API ImGuiWindowTempData
   1369{
   1370    // Layout
   1371    ImVec2                  CursorPos;              // Current emitting position, in absolute coordinates.
   1372    ImVec2                  CursorPosPrevLine;
   1373    ImVec2                  CursorStartPos;         // Initial position after Begin(), generally ~ window position + WindowPadding.
   1374    ImVec2                  CursorMaxPos;           // Used to implicitly calculate the size of our contents, always growing during the frame. Used to calculate window->ContentSize at the beginning of next frame
   1375    ImVec2                  CurrLineSize;
   1376    ImVec2                  PrevLineSize;
   1377    float                   CurrLineTextBaseOffset; // Baseline offset (0.0f by default on a new line, generally == style.FramePadding.y when a framed item has been added).
   1378    float                   PrevLineTextBaseOffset;
   1379    ImVec1                  Indent;                 // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
   1380    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.
   1381    ImVec1                  GroupOffset;
   1382
   1383    // Last item status
   1384    ImGuiID                 LastItemId;             // ID for last item
   1385    ImGuiItemStatusFlags    LastItemStatusFlags;    // Status flags for last item (see ImGuiItemStatusFlags_)
   1386    ImRect                  LastItemRect;           // Interaction rect for last item
   1387    ImRect                  LastItemDisplayRect;    // End-user display rect for last item (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect)
   1388
   1389    // Keyboard/Gamepad navigation
   1390    ImGuiNavLayer           NavLayerCurrent;        // Current layer, 0..31 (we currently only use 0..1)
   1391    int                     NavLayerCurrentMask;    // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping.
   1392    int                     NavLayerActiveMask;     // Which layer have been written to (result from previous frame)
   1393    int                     NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame)
   1394    ImGuiID                 NavFocusScopeIdCurrent; // Current focus scope ID while appending
   1395    bool                    NavHideHighlightOneFrame;
   1396    bool                    NavHasScroll;           // Set when scrolling can be used (ScrollMax > 0.0f)
   1397
   1398    // Miscellaneous
   1399    bool                    MenuBarAppending;       // FIXME: Remove this
   1400    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.
   1401    ImGuiMenuColumns        MenuColumns;            // Simplified columns storage for menu items measurement
   1402    int                     TreeDepth;              // Current tree depth.
   1403    ImU32                   TreeJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary.
   1404    ImVector<ImGuiWindow*>  ChildWindows;
   1405    ImGuiStorage*           StateStorage;           // Current persistent per-window storage (store e.g. tree node open/close state)
   1406    ImGuiColumns*           CurrentColumns;         // Current columns set
   1407    ImGuiLayoutType         LayoutType;
   1408    ImGuiLayoutType         ParentLayoutType;       // Layout type of parent window at the time of Begin()
   1409    int                     FocusCounterRegular;    // (Legacy Focus/Tabbing system) Sequential counter, start at -1 and increase as assigned via FocusableItemRegister() (FIXME-NAV: Needs redesign)
   1410    int                     FocusCounterTabStop;    // (Legacy Focus/Tabbing system) Same, but only count widgets which you can Tab through.
   1411
   1412    // Local parameters stacks
   1413    // 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.
   1414    ImGuiItemFlags          ItemFlags;              // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
   1415    float                   ItemWidth;              // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
   1416    float                   TextWrapPos;            // == TextWrapPosStack.back() [empty == -1.0f]
   1417    ImVector<ImGuiItemFlags>ItemFlagsStack;
   1418    ImVector<float>         ItemWidthStack;
   1419    ImVector<float>         TextWrapPosStack;
   1420    ImVector<ImGuiGroupData>GroupStack;
   1421    short                   StackSizesBackup[6];    // Store size of various stacks for asserting
   1422
   1423    ImGuiWindowTempData()
   1424    {
   1425        CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
   1426        CurrLineSize = PrevLineSize = ImVec2(0.0f, 0.0f);
   1427        CurrLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
   1428        Indent = ImVec1(0.0f);
   1429        ColumnsOffset = ImVec1(0.0f);
   1430        GroupOffset = ImVec1(0.0f);
   1431
   1432        LastItemId = 0;
   1433        LastItemStatusFlags = ImGuiItemStatusFlags_None;
   1434        LastItemRect = LastItemDisplayRect = ImRect();
   1435
   1436        NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
   1437        NavLayerCurrent = ImGuiNavLayer_Main;
   1438        NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
   1439        NavFocusScopeIdCurrent = 0;
   1440        NavHideHighlightOneFrame = false;
   1441        NavHasScroll = false;
   1442
   1443        MenuBarAppending = false;
   1444        MenuBarOffset = ImVec2(0.0f, 0.0f);
   1445        TreeDepth = 0;
   1446        TreeJumpToParentOnPopMask = 0x00;
   1447        StateStorage = NULL;
   1448        CurrentColumns = NULL;
   1449        LayoutType = ParentLayoutType = ImGuiLayoutType_Vertical;
   1450        FocusCounterRegular = FocusCounterTabStop = -1;
   1451
   1452        ItemFlags = ImGuiItemFlags_Default_;
   1453        ItemWidth = 0.0f;
   1454        TextWrapPos = -1.0f;
   1455        memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
   1456    }
   1457};
   1458
   1459// Storage for one window
   1460struct IMGUI_API ImGuiWindow
   1461{
   1462    char*                   Name;                               // Window name, owned by the window.
   1463    ImGuiID                 ID;                                 // == ImHashStr(Name)
   1464    ImGuiWindowFlags        Flags;                              // See enum ImGuiWindowFlags_
   1465    ImVec2                  Pos;                                // Position (always rounded-up to nearest pixel)
   1466    ImVec2                  Size;                               // Current size (==SizeFull or collapsed title bar size)
   1467    ImVec2                  SizeFull;                           // Size when non collapsed
   1468    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.
   1469    ImVec2                  ContentSizeExplicit;                // Size of contents/scrollable client area explicitly request by the user via SetNextWindowContentSize().
   1470    ImVec2                  WindowPadding;                      // Window padding at the time of Begin().
   1471    float                   WindowRounding;                     // Window rounding at the time of Begin().
   1472    float                   WindowBorderSize;                   // Window border size at the time of Begin().
   1473    int                     NameBufLen;                         // Size of buffer storing Name. May be larger than strlen(Name)!
   1474    ImGuiID                 MoveId;                             // == window->GetID("#MOVE")
   1475    ImGuiID                 ChildId;                            // ID of corresponding item in parent window (for navigation to return from child window to parent window)
   1476    ImVec2                  Scroll;
   1477    ImVec2                  ScrollMax;
   1478    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)
   1479    ImVec2                  ScrollTargetCenterRatio;            // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
   1480    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.
   1481    bool                    ScrollbarX, ScrollbarY;             // Are scrollbars visible?
   1482    bool                    Active;                             // Set to true on Begin(), unless Collapsed
   1483    bool                    WasActive;
   1484    bool                    WriteAccessed;                      // Set to true when any widget access the current window
   1485    bool                    Collapsed;                          // Set when collapsing window to become only title-bar
   1486    bool                    WantCollapseToggle;
   1487    bool                    SkipItems;                          // Set when items can safely be all clipped (e.g. window not visible or collapsed)
   1488    bool                    Appearing;                          // Set during the frame where the window is appearing (or re-appearing)
   1489    bool                    Hidden;                             // Do not display (== (HiddenFrames*** > 0))
   1490    bool                    IsFallbackWindow;                   // Set on the "Debug##Default" window.
   1491    bool                    HasCloseButton;                     // Set when the window has a close button (p_open != NULL)
   1492    signed char             ResizeBorderHeld;                   // Current border being held for resize (-1: none, otherwise 0-3)
   1493    short                   BeginCount;                         // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
   1494    short                   BeginOrderWithinParent;             // Order within immediate parent window, if we are a child window. Otherwise 0.
   1495    short                   BeginOrderWithinContext;            // Order within entire imgui context. This is mostly used for debugging submission order related issues.
   1496    ImGuiID                 PopupId;                            // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
   1497    ImS8                    AutoFitFramesX, AutoFitFramesY;
   1498    ImS8                    AutoFitChildAxises;
   1499    bool                    AutoFitOnlyGrows;
   1500    ImGuiDir                AutoPosLastDirection;
   1501    int                     HiddenFramesCanSkipItems;           // Hide the window for N frames
   1502    int                     HiddenFramesCannotSkipItems;        // Hide the window for N frames while allowing items to be submitted so we can measure their size
   1503    ImGuiCond               SetWindowPosAllowFlags;             // store acceptable condition flags for SetNextWindowPos() use.
   1504    ImGuiCond               SetWindowSizeAllowFlags;            // store acceptable condition flags for SetNextWindowSize() use.
   1505    ImGuiCond               SetWindowCollapsedAllowFlags;       // store acceptable condition flags for SetNextWindowCollapsed() use.
   1506    ImVec2                  SetWindowPosVal;                    // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
   1507    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.
   1508
   1509    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)
   1510    ImGuiWindowTempData     DC;                                 // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name.
   1511
   1512    // The best way to understand what those rectangles are is to use the 'Metrics -> Tools -> Show windows rectangles' viewer.
   1513    // The main 'OuterRect', omitted as a field, is window->Rect().
   1514    ImRect                  OuterRectClipped;                   // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
   1515    ImRect                  InnerRect;                          // Inner rectangle (omit title bar, menu bar, scroll bar)
   1516    ImRect                  InnerClipRect;                      // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect.
   1517    ImRect                  WorkRect;                           // Cover the whole scrolling region, shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward).
   1518    ImRect                  ClipRect;                           // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back().
   1519    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.
   1520
   1521    int                     LastFrameActive;                    // Last frame number the window was Active.
   1522    float                   LastTimeActive;                     // Last timestamp the window was Active (using float as we don't need high precision there)
   1523    float                   ItemWidthDefault;
   1524    ImGuiStorage            StateStorage;
   1525    ImVector<ImGuiColumns>  ColumnsStorage;
   1526    float                   FontWindowScale;                    // User scale multiplier per-window, via SetWindowFontScale()
   1527    int                     SettingsOffset;                     // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back)
   1528
   1529    ImDrawList*             DrawList;                           // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
   1530    ImDrawList              DrawListInst;
   1531    ImGuiWindow*            ParentWindow;                       // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
   1532    ImGuiWindow*            RootWindow;                         // Point to ourself or first ancestor that is not a child window.
   1533    ImGuiWindow*            RootWindowForTitleBarHighlight;     // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
   1534    ImGuiWindow*            RootWindowForNav;                   // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
   1535
   1536    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.)
   1537    ImGuiID                 NavLastIds[ImGuiNavLayer_COUNT];    // Last known NavId for this window, per layer (0/1)
   1538    ImRect                  NavRectRel[ImGuiNavLayer_COUNT];    // Reference rectangle, in window relative space
   1539
   1540    bool                    MemoryCompacted;
   1541    int                     MemoryDrawListIdxCapacity;
   1542    int                     MemoryDrawListVtxCapacity;
   1543
   1544public:
   1545    ImGuiWindow(ImGuiContext* context, const char* name);
   1546    ~ImGuiWindow();
   1547
   1548    ImGuiID     GetID(const char* str, const char* str_end = NULL);
   1549    ImGuiID     GetID(const void* ptr);
   1550    ImGuiID     GetID(int n);
   1551    ImGuiID     GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
   1552    ImGuiID     GetIDNoKeepAlive(const void* ptr);
   1553    ImGuiID     GetIDNoKeepAlive(int n);
   1554    ImGuiID     GetIDFromRectangle(const ImRect& r_abs);
   1555
   1556    // We don't use g.FontSize because the window may be != g.CurrentWidow.
   1557    ImRect      Rect() const                { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
   1558    float       CalcFontSize() const        { ImGuiContext& g = *GImGui; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
   1559    float       TitleBarHeight() const      { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + g.Style.FramePadding.y * 2.0f; }
   1560    ImRect      TitleBarRect() const        { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
   1561    float       MenuBarHeight() const       { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + g.Style.FramePadding.y * 2.0f : 0.0f; }
   1562    ImRect      MenuBarRect() const         { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
   1563};
   1564
   1565// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
   1566struct ImGuiItemHoveredDataBackup
   1567{
   1568    ImGuiID                 LastItemId;
   1569    ImGuiItemStatusFlags    LastItemStatusFlags;
   1570    ImRect                  LastItemRect;
   1571    ImRect                  LastItemDisplayRect;
   1572
   1573    ImGuiItemHoveredDataBackup() { Backup(); }
   1574    void Backup()           { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; }
   1575    void Restore() const    { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; }
   1576};
   1577
   1578//-----------------------------------------------------------------------------
   1579// Tab bar, tab item
   1580//-----------------------------------------------------------------------------
   1581
   1582// Extend ImGuiTabBarFlags_
   1583enum ImGuiTabBarFlagsPrivate_
   1584{
   1585    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]
   1586    ImGuiTabBarFlags_IsFocused                  = 1 << 21,
   1587    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
   1588};
   1589
   1590// Extend ImGuiTabItemFlags_
   1591enum ImGuiTabItemFlagsPrivate_
   1592{
   1593    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)
   1594};
   1595
   1596// Storage for one active tab item (sizeof() 26~32 bytes)
   1597struct ImGuiTabItem
   1598{
   1599    ImGuiID             ID;
   1600    ImGuiTabItemFlags   Flags;
   1601    int                 LastFrameVisible;
   1602    int                 LastFrameSelected;      // This allows us to infer an ordered list of the last activated tabs with little maintenance
   1603    int                 NameOffset;             // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
   1604    float               Offset;                 // Position relative to beginning of tab
   1605    float               Width;                  // Width currently displayed
   1606    float               ContentWidth;           // Width of actual contents, stored during BeginTabItem() call
   1607
   1608    ImGuiTabItem()      { ID = 0; Flags = ImGuiTabItemFlags_None; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = ContentWidth = 0.0f; }
   1609};
   1610
   1611// Storage for a tab bar (sizeof() 92~96 bytes)
   1612struct ImGuiTabBar
   1613{
   1614    ImVector<ImGuiTabItem> Tabs;
   1615    ImGuiID             ID;                     // Zero for tab-bars used by docking
   1616    ImGuiID             SelectedTabId;          // Selected tab/window
   1617    ImGuiID             NextSelectedTabId;
   1618    ImGuiID             VisibleTabId;           // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview)
   1619    int                 CurrFrameVisible;
   1620    int                 PrevFrameVisible;
   1621    ImRect              BarRect;
   1622    float               LastTabContentHeight;   // Record the height of contents submitted below the tab bar
   1623    float               OffsetMax;              // Distance from BarRect.Min.x, locked during layout
   1624    float               OffsetMaxIdeal;         // Ideal offset if all tabs were visible and not clipped
   1625    float               OffsetNextTab;          // Distance from BarRect.Min.x, incremented with each BeginTabItem() call, not used if ImGuiTabBarFlags_Reorderable if set.
   1626    float               ScrollingAnim;
   1627    float               ScrollingTarget;
   1628    float               ScrollingTargetDistToVisibility;
   1629    float               ScrollingSpeed;
   1630    ImGuiTabBarFlags    Flags;
   1631    ImGuiID             ReorderRequestTabId;
   1632    ImS8                ReorderRequestDir;
   1633    bool                WantLayout;
   1634    bool                VisibleTabWasSubmitted;
   1635    short               LastTabItemIdx;         // For BeginTabItem()/EndTabItem()
   1636    ImVec2              FramePadding;           // style.FramePadding locked at the time of BeginTabBar()
   1637    ImGuiTextBuffer     TabsNames;              // For non-docking tab bar we re-append names in a contiguous buffer.
   1638
   1639    ImGuiTabBar();
   1640    int                 GetTabOrder(const ImGuiTabItem* tab) const  { return Tabs.index_from_ptr(tab); }
   1641    const char*         GetTabName(const ImGuiTabItem* tab) const
   1642    {
   1643        IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size);
   1644        return TabsNames.Buf.Data + tab->NameOffset;
   1645    }
   1646};
   1647
   1648//-----------------------------------------------------------------------------
   1649// Internal API
   1650// No guarantee of forward compatibility here.
   1651//-----------------------------------------------------------------------------
   1652
   1653namespace ImGui
   1654{
   1655    // Windows
   1656    // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
   1657    // If this ever crash because g.CurrentWindow is NULL it means that either
   1658    // - ImGui::NewFrame() has never been called, which is illegal.
   1659    // - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
   1660    inline    ImGuiWindow*  GetCurrentWindowRead()      { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
   1661    inline    ImGuiWindow*  GetCurrentWindow()          { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
   1662    IMGUI_API ImGuiWindow*  FindWindowByID(ImGuiID id);
   1663    IMGUI_API ImGuiWindow*  FindWindowByName(const char* name);
   1664    IMGUI_API void          UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
   1665    IMGUI_API ImVec2        CalcWindowExpectedSize(ImGuiWindow* window);
   1666    IMGUI_API bool          IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
   1667    IMGUI_API bool          IsWindowNavFocusable(ImGuiWindow* window);
   1668    IMGUI_API ImRect        GetWindowAllowedExtentRect(ImGuiWindow* window);
   1669    IMGUI_API void          SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0);
   1670    IMGUI_API void          SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0);
   1671    IMGUI_API void          SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
   1672
   1673    // Windows: Display Order and Focus Order
   1674    IMGUI_API void          FocusWindow(ImGuiWindow* window);
   1675    IMGUI_API void          FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window);
   1676    IMGUI_API void          BringWindowToFocusFront(ImGuiWindow* window);
   1677    IMGUI_API void          BringWindowToDisplayFront(ImGuiWindow* window);
   1678    IMGUI_API void          BringWindowToDisplayBack(ImGuiWindow* window);
   1679
   1680    // Fonts, drawing
   1681    IMGUI_API void          SetCurrentFont(ImFont* font);
   1682    inline ImFont*          GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
   1683    inline ImDrawList*      GetForegroundDrawList(ImGuiWindow* window) { IM_UNUSED(window); ImGuiContext& g = *GImGui; return &g.ForegroundDrawList; } // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches.
   1684
   1685    // Init
   1686    IMGUI_API void          Initialize(ImGuiContext* context);
   1687    IMGUI_API void          Shutdown(ImGuiContext* context);    // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
   1688
   1689    // NewFrame
   1690    IMGUI_API void          UpdateHoveredWindowAndCaptureFlags();
   1691    IMGUI_API void          StartMouseMovingWindow(ImGuiWindow* window);
   1692    IMGUI_API void          UpdateMouseMovingWindowNewFrame();
   1693    IMGUI_API void          UpdateMouseMovingWindowEndFrame();
   1694
   1695    // Settings
   1696    IMGUI_API void                  MarkIniSettingsDirty();
   1697    IMGUI_API void                  MarkIniSettingsDirty(ImGuiWindow* window);
   1698    IMGUI_API ImGuiWindowSettings*  CreateNewWindowSettings(const char* name);
   1699    IMGUI_API ImGuiWindowSettings*  FindWindowSettings(ImGuiID id);
   1700    IMGUI_API ImGuiWindowSettings*  FindOrCreateWindowSettings(const char* name);
   1701    IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
   1702
   1703    // Scrolling
   1704    IMGUI_API void          SetScrollX(ImGuiWindow* window, float new_scroll_x);
   1705    IMGUI_API void          SetScrollY(ImGuiWindow* window, float new_scroll_y);
   1706    IMGUI_API void          SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio = 0.5f);
   1707    IMGUI_API void          SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio = 0.5f);
   1708    IMGUI_API ImVec2        ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect);
   1709
   1710    // Basic Accessors
   1711    inline ImGuiID          GetItemID()     { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; }
   1712    inline ImGuiItemStatusFlags GetItemStatusFlags() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemStatusFlags; }
   1713    inline ImGuiID          GetActiveID()   { ImGuiContext& g = *GImGui; return g.ActiveId; }
   1714    inline ImGuiID          GetFocusID()    { ImGuiContext& g = *GImGui; return g.NavId; }
   1715    IMGUI_API void          SetActiveID(ImGuiID id, ImGuiWindow* window);
   1716    IMGUI_API void          SetFocusID(ImGuiID id, ImGuiWindow* window);
   1717    IMGUI_API void          ClearActiveID();
   1718    IMGUI_API ImGuiID       GetHoveredID();
   1719    IMGUI_API void          SetHoveredID(ImGuiID id);
   1720    IMGUI_API void          KeepAliveID(ImGuiID id);
   1721    IMGUI_API void          MarkItemEdited(ImGuiID id);     // Mark data associated to given item as "edited", used by IsItemDeactivatedAfterEdit() function.
   1722    IMGUI_API void          PushOverrideID(ImGuiID id);     // Push given value at the top of the ID stack (whereas PushID combines old and new hashes)
   1723
   1724    // Basic Helpers for widget code
   1725    IMGUI_API void          ItemSize(const ImVec2& size, float text_baseline_y = -1.0f);
   1726    IMGUI_API void          ItemSize(const ImRect& bb, float text_baseline_y = -1.0f);
   1727    IMGUI_API bool          ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
   1728    IMGUI_API bool          ItemHoverable(const ImRect& bb, ImGuiID id);
   1729    IMGUI_API bool          IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
   1730    IMGUI_API bool          FocusableItemRegister(ImGuiWindow* window, ImGuiID id);   // Return true if focus is requested
   1731    IMGUI_API void          FocusableItemUnregister(ImGuiWindow* window);
   1732    IMGUI_API ImVec2        CalcItemSize(ImVec2 size, float default_w, float default_h);
   1733    IMGUI_API float         CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
   1734    IMGUI_API void          PushMultiItemsWidths(int components, float width_full);
   1735    IMGUI_API void          PushItemFlag(ImGuiItemFlags option, bool enabled);
   1736    IMGUI_API void          PopItemFlag();
   1737    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)
   1738    IMGUI_API ImVec2        GetContentRegionMaxAbs();
   1739    IMGUI_API void          ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess);
   1740
   1741    // Logging/Capture
   1742    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.
   1743    IMGUI_API void          LogToBuffer(int auto_open_depth = -1);              // Start logging/capturing to internal buffer
   1744
   1745    // Popups, Modals, Tooltips
   1746    IMGUI_API bool          BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags);
   1747    IMGUI_API void          OpenPopupEx(ImGuiID id);
   1748    IMGUI_API void          ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
   1749    IMGUI_API void          ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
   1750    IMGUI_API bool          IsPopupOpen(ImGuiID id); // Test for id within current popup stack level (currently begin-ed into); this doesn't scan the whole popup stack!
   1751    IMGUI_API bool          BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
   1752    IMGUI_API void          BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags);
   1753    IMGUI_API ImGuiWindow*  GetTopMostPopupModal();
   1754    IMGUI_API ImVec2        FindBestWindowPosForPopup(ImGuiWindow* window);
   1755    IMGUI_API ImVec2        FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy = ImGuiPopupPositionPolicy_Default);
   1756
   1757    // Navigation
   1758    IMGUI_API void          NavInitWindow(ImGuiWindow* window, bool force_reinit);
   1759    IMGUI_API bool          NavMoveRequestButNoResultYet();
   1760    IMGUI_API void          NavMoveRequestCancel();
   1761    IMGUI_API void          NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags);
   1762    IMGUI_API void          NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
   1763    IMGUI_API float         GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode);
   1764    IMGUI_API ImVec2        GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f);
   1765    IMGUI_API int           CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate);
   1766    IMGUI_API void          ActivateItem(ImGuiID id);   // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again.
   1767    IMGUI_API void          SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id);
   1768    IMGUI_API void          SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel);
   1769
   1770    // Focus scope (WIP)
   1771    IMGUI_API void          PushFocusScope(ImGuiID id);     // Note: this is storing in same stack as IDStack, so Push/Pop mismatch will be reported there.
   1772    IMGUI_API void          PopFocusScope();
   1773    inline ImGuiID          GetFocusScopeID()               { ImGuiContext& g = *GImGui; return g.NavFocusScopeId; }
   1774
   1775    // Inputs
   1776    // FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
   1777    inline bool             IsActiveIdUsingNavDir(ImGuiDir dir)                         { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
   1778    inline bool             IsActiveIdUsingNavInput(ImGuiNavInput input)                { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
   1779    inline bool             IsActiveIdUsingKey(ImGuiKey key)                            { ImGuiContext& g = *GImGui; IM_ASSERT(key < 64); return (g.ActiveIdUsingKeyInputMask & ((ImU64)1 << key)) != 0; }
   1780    IMGUI_API bool          IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
   1781    inline bool             IsKeyPressedMap(ImGuiKey key, bool repeat = true)           { ImGuiContext& g = *GImGui; const int key_index = g.IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; }
   1782    inline bool             IsNavInputDown(ImGuiNavInput n)                             { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; }
   1783    inline bool             IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm)      { return (GetNavInputAmount(n, rm) > 0.0f); }
   1784    IMGUI_API ImGuiKeyModFlags GetMergedKeyModFlags();
   1785
   1786    // Drag and Drop
   1787    IMGUI_API bool          BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
   1788    IMGUI_API void          ClearDragDrop();
   1789    IMGUI_API bool          IsDragDropPayloadBeingAccepted();
   1790
   1791    // Internal Columns API (this is not exposed because we will encourage transitioning to the Tables api)
   1792    IMGUI_API void          BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
   1793    IMGUI_API void          EndColumns();                                                             // close columns
   1794    IMGUI_API void          PushColumnClipRect(int column_index);
   1795    IMGUI_API void          PushColumnsBackground();
   1796    IMGUI_API void          PopColumnsBackground();
   1797    IMGUI_API ImGuiID       GetColumnsID(const char* str_id, int count);
   1798    IMGUI_API ImGuiColumns* FindOrCreateColumns(ImGuiWindow* window, ImGuiID id);
   1799    IMGUI_API float         GetColumnOffsetFromNorm(const ImGuiColumns* columns, float offset_norm);
   1800    IMGUI_API float         GetColumnNormFromOffset(const ImGuiColumns* columns, float offset);
   1801
   1802    // Tab Bars
   1803    IMGUI_API bool          BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags);
   1804    IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
   1805    IMGUI_API void          TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
   1806    IMGUI_API void          TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
   1807    IMGUI_API void          TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir);
   1808    IMGUI_API bool          TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags);
   1809    IMGUI_API ImVec2        TabItemCalcSize(const char* label, bool has_close_button);
   1810    IMGUI_API void          TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col);
   1811    IMGUI_API bool          TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id);
   1812
   1813    // Render helpers
   1814    // AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT.
   1815    // NB: All position are in absolute pixels coordinates (we are never using window coordinates internally)
   1816    IMGUI_API void          RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
   1817    IMGUI_API void          RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
   1818    IMGUI_API void          RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0,0), const ImRect* clip_rect = NULL);
   1819    IMGUI_API void          RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL);
   1820    IMGUI_API void          RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end, const ImVec2* text_size_if_known);
   1821    IMGUI_API void          RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
   1822    IMGUI_API void          RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
   1823    IMGUI_API void          RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
   1824    IMGUI_API void          RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
   1825    IMGUI_API const char*   FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
   1826    IMGUI_API void          LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
   1827
   1828    // Render helpers (those functions don't access any ImGui state!)
   1829    IMGUI_API void          RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale = 1.0f);
   1830    IMGUI_API void          RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col);
   1831    IMGUI_API void          RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz);
   1832    IMGUI_API void          RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);
   1833    IMGUI_API void          RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
   1834    IMGUI_API void          RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
   1835
   1836#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
   1837    // [1.71: 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while]
   1838    inline void RenderArrow(ImVec2 pos, ImGuiDir dir, float scale=1.0f) { ImGuiWindow* window = GetCurrentWindow(); RenderArrow(window->DrawList, pos, GetColorU32(ImGuiCol_Text), dir, scale); }
   1839    inline void RenderBullet(ImVec2 pos)                                { ImGuiWindow* window = GetCurrentWindow(); RenderBullet(window->DrawList, pos, GetColorU32(ImGuiCol_Text)); }
   1840#endif
   1841
   1842    // Widgets
   1843    IMGUI_API void          TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0);
   1844    IMGUI_API bool          ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0);
   1845    IMGUI_API bool          CloseButton(ImGuiID id, const ImVec2& pos);
   1846    IMGUI_API bool          CollapseButton(ImGuiID id, const ImVec2& pos);
   1847    IMGUI_API bool          ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
   1848    IMGUI_API void          Scrollbar(ImGuiAxis axis);
   1849    IMGUI_API bool          ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float avail_v, float contents_v, ImDrawCornerFlags rounding_corners);
   1850    IMGUI_API ImRect        GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
   1851    IMGUI_API ImGuiID       GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis);
   1852    IMGUI_API ImGuiID       GetWindowResizeID(ImGuiWindow* window, int n); // 0..3: corners, 4..7: borders
   1853    IMGUI_API void          SeparatorEx(ImGuiSeparatorFlags flags);
   1854
   1855    // Widgets low-level behaviors
   1856    IMGUI_API bool          ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
   1857    IMGUI_API bool          DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, float power, ImGuiDragFlags flags);
   1858    IMGUI_API bool          SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
   1859    IMGUI_API bool          SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f);
   1860    IMGUI_API bool          TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
   1861    IMGUI_API bool          TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0);                     // Consume previous SetNextItemOpen() data, if any. May return true when logging
   1862    IMGUI_API void          TreePushOverrideID(ImGuiID id);
   1863
   1864    // Template functions are instantiated in imgui_widgets.cpp for a finite number of types.
   1865    // To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036).
   1866    // e.g. " extern template IMGUI_API float RoundScalarWithFormatT<float, float>(const char* format, ImGuiDataType data_type, float v); "
   1867    template<typename T, typename SIGNED_T, typename FLOAT_T>   IMGUI_API bool  DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, T v_min, T v_max, const char* format, float power, ImGuiDragFlags flags);
   1868    template<typename T, typename SIGNED_T, typename FLOAT_T>   IMGUI_API bool  SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, T v_min, T v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
   1869    template<typename T, typename FLOAT_T>                      IMGUI_API float SliderCalcRatioFromValueT(ImGuiDataType data_type, T v, T v_min, T v_max, float power, float linear_zero_pos);
   1870    template<typename T, typename SIGNED_T>                     IMGUI_API T     RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v);
   1871
   1872    // Data type helpers
   1873    IMGUI_API const ImGuiDataTypeInfo*  DataTypeGetInfo(ImGuiDataType data_type);
   1874    IMGUI_API int           DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format);
   1875    IMGUI_API void          DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg_1, const void* arg_2);
   1876    IMGUI_API bool          DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format);
   1877
   1878    // InputText
   1879    IMGUI_API bool          InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
   1880    IMGUI_API bool          TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags);
   1881    IMGUI_API bool          TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format);
   1882    inline bool             TempInputIsActive(ImGuiID id)       { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputId == id); }
   1883    inline ImGuiInputTextState* GetInputTextState(ImGuiID id)   { ImGuiContext& g = *GImGui; return (g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active
   1884
   1885    // Color
   1886    IMGUI_API void          ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
   1887    IMGUI_API void          ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
   1888    IMGUI_API void          ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags);
   1889
   1890    // Plot
   1891    IMGUI_API int           PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size);
   1892
   1893    // Shade functions (write over already created vertices)
   1894    IMGUI_API void          ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
   1895    IMGUI_API void          ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
   1896
   1897    // Garbage collection
   1898    IMGUI_API void          GcCompactTransientWindowBuffers(ImGuiWindow* window);
   1899    IMGUI_API void          GcAwakeTransientWindowBuffers(ImGuiWindow* window);
   1900
   1901    // Debug Tools
   1902    inline void             DebugDrawItemRect(ImU32 col = IM_COL32(255,0,0,255))    { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max, col); }
   1903    inline void             DebugStartItemPicker()                                  { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; }
   1904
   1905} // namespace ImGui
   1906
   1907// ImFontAtlas internals
   1908IMGUI_API bool              ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
   1909IMGUI_API void              ImFontAtlasBuildInit(ImFontAtlas* atlas);
   1910IMGUI_API void              ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
   1911IMGUI_API void              ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
   1912IMGUI_API void              ImFontAtlasBuildFinish(ImFontAtlas* atlas);
   1913IMGUI_API void              ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
   1914IMGUI_API void              ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
   1915
   1916// Debug Tools
   1917// Use 'Metrics->Tools->Item Picker' to break into the call-stack of a specific item.
   1918#ifndef IM_DEBUG_BREAK
   1919#if defined(__clang__)
   1920#define IM_DEBUG_BREAK()    __builtin_debugtrap()
   1921#elif defined (_MSC_VER)
   1922#define IM_DEBUG_BREAK()    __debugbreak()
   1923#else
   1924#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!
   1925#endif
   1926#endif // #ifndef IM_DEBUG_BREAK
   1927
   1928// Test Engine Hooks (imgui_tests)
   1929//#define IMGUI_ENABLE_TEST_ENGINE
   1930#ifdef IMGUI_ENABLE_TEST_ENGINE
   1931extern void                 ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx);
   1932extern void                 ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx);
   1933extern void                 ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
   1934extern void                 ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags);
   1935extern void                 ImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt, ...);
   1936#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB, _ID)                ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID)               // Register item bounding box
   1937#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS)    ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS)   // Register item label and status flags (optional)
   1938#define IMGUI_TEST_ENGINE_LOG(_FMT, ...)                    ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__)          // Custom log entry from user land into test log
   1939#else
   1940#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB, _ID)                do { } while (0)
   1941#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS)    do { } while (0)
   1942#define IMGUI_TEST_ENGINE_LOG(_FMT, ...)                    do { } while (0)
   1943#endif
   1944
   1945#if defined(__clang__)
   1946#pragma clang diagnostic pop
   1947#elif defined(__GNUC__)
   1948#pragma GCC diagnostic pop
   1949#endif
   1950
   1951#ifdef _MSC_VER
   1952#pragma warning (pop)
   1953#endif
   1954
   1955#endif // #ifndef IMGUI_DISABLE