19f464c52Smaya// dear imgui, v1.68 WIP
29f464c52Smaya// (internal structures/api)
39f464c52Smaya
49f464c52Smaya// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
59f464c52Smaya// Set:
69f464c52Smaya//   #define IMGUI_DEFINE_MATH_OPERATORS
79f464c52Smaya// 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)
89f464c52Smaya
99f464c52Smaya/*
109f464c52Smaya
119f464c52SmayaIndex of this file:
129f464c52Smaya// Header mess
139f464c52Smaya// Forward declarations
149f464c52Smaya// STB libraries includes
159f464c52Smaya// Context pointer
169f464c52Smaya// Generic helpers
179f464c52Smaya// Misc data structures
189f464c52Smaya// Main imgui context
199f464c52Smaya// Tab bar, tab item
209f464c52Smaya// Internal API
219f464c52Smaya
229f464c52Smaya*/
239f464c52Smaya
249f464c52Smaya#pragma once
259f464c52Smaya
269f464c52Smaya//-----------------------------------------------------------------------------
279f464c52Smaya// Header mess
289f464c52Smaya//-----------------------------------------------------------------------------
299f464c52Smaya
309f464c52Smaya#ifndef IMGUI_VERSION
319f464c52Smaya#error Must include imgui.h before imgui_internal.h
329f464c52Smaya#endif
339f464c52Smaya
349f464c52Smaya#include <stdio.h>      // FILE*
359f464c52Smaya#include <stdlib.h>     // NULL, malloc, free, qsort, atoi, atof
369f464c52Smaya#include <math.h>       // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
379f464c52Smaya#include <limits.h>     // INT_MIN, INT_MAX
389f464c52Smaya
399f464c52Smaya#ifdef _MSC_VER
409f464c52Smaya#pragma warning (push)
419f464c52Smaya#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)
429f464c52Smaya#endif
439f464c52Smaya
449f464c52Smaya#ifdef __clang__
459f464c52Smaya#pragma clang diagnostic push
469f464c52Smaya#pragma clang diagnostic ignored "-Wunused-function"                // for stb_textedit.h
479f464c52Smaya#pragma clang diagnostic ignored "-Wmissing-prototypes"             // for stb_textedit.h
489f464c52Smaya#pragma clang diagnostic ignored "-Wold-style-cast"
499f464c52Smaya#if __has_warning("-Wzero-as-null-pointer-constant")
509f464c52Smaya#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
519f464c52Smaya#endif
529f464c52Smaya#if __has_warning("-Wdouble-promotion")
539f464c52Smaya#pragma clang diagnostic ignored "-Wdouble-promotion"
549f464c52Smaya#endif
559f464c52Smaya#endif
569f464c52Smaya
579f464c52Smaya//-----------------------------------------------------------------------------
589f464c52Smaya// Forward declarations
599f464c52Smaya//-----------------------------------------------------------------------------
609f464c52Smaya
619f464c52Smayastruct ImRect;                      // An axis-aligned rectangle (2 points)
629f464c52Smayastruct ImDrawDataBuilder;           // Helper to build a ImDrawData instance
639f464c52Smayastruct ImDrawListSharedData;        // Data shared between all ImDrawList instances
649f464c52Smayastruct ImGuiColorMod;               // Stacked color modifier, backup of modified data so we can restore it
659f464c52Smayastruct ImGuiColumnData;             // Storage data for a single column
669f464c52Smayastruct ImGuiColumnsSet;             // Storage data for a columns set
679f464c52Smayastruct ImGuiContext;                // Main imgui context
689f464c52Smayastruct ImGuiGroupData;              // Stacked storage data for BeginGroup()/EndGroup()
699f464c52Smayastruct ImGuiInputTextState;         // Internal state of the currently focused/edited text input box
709f464c52Smayastruct ImGuiItemHoveredDataBackup;  // Backup and restore IsItemHovered() internal data
719f464c52Smayastruct ImGuiMenuColumns;            // Simple column measurement, currently used for MenuItem() only
729f464c52Smayastruct ImGuiNavMoveResult;          // Result of a directional navigation move query result
739f464c52Smayastruct ImGuiNextWindowData;         // Storage for SetNexWindow** functions
749f464c52Smayastruct ImGuiPopupRef;               // Storage for current popup stack
759f464c52Smayastruct ImGuiSettingsHandler;        // Storage for one type registered in the .ini file
769f464c52Smayastruct ImGuiStyleMod;               // Stacked style modifier, backup of modified data so we can restore it
779f464c52Smayastruct ImGuiTabBar;                 // Storage for a tab bar
789f464c52Smayastruct ImGuiTabItem;                // Storage for a tab item (within a tab bar)
799f464c52Smayastruct ImGuiWindow;                 // Storage for one window
809f464c52Smayastruct ImGuiWindowTempData;         // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame)
819f464c52Smayastruct ImGuiWindowSettings;         // Storage for window settings stored in .ini file (we keep one of those even if the actual window wasn't instanced during this session)
829f464c52Smaya
839f464c52Smaya// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
849f464c52Smayatypedef int ImGuiLayoutType;        // -> enum ImGuiLayoutType_        // Enum: Horizontal or vertical
859f464c52Smayatypedef int ImGuiButtonFlags;       // -> enum ImGuiButtonFlags_       // Flags: for ButtonEx(), ButtonBehavior()
869f464c52Smayatypedef int ImGuiItemFlags;         // -> enum ImGuiItemFlags_         // Flags: for PushItemFlag()
879f464c52Smayatypedef int ImGuiItemStatusFlags;   // -> enum ImGuiItemStatusFlags_   // Flags: for DC.LastItemStatusFlags
889f464c52Smayatypedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
899f464c52Smayatypedef int ImGuiNavDirSourceFlags; // -> enum ImGuiNavDirSourceFlags_ // Flags: for GetNavInputAmount2d()
909f464c52Smayatypedef int ImGuiNavMoveFlags;      // -> enum ImGuiNavMoveFlags_      // Flags: for navigation requests
919f464c52Smayatypedef int ImGuiSeparatorFlags;    // -> enum ImGuiSeparatorFlags_    // Flags: for Separator() - internal
929f464c52Smayatypedef int ImGuiSliderFlags;       // -> enum ImGuiSliderFlags_       // Flags: for SliderBehavior()
939f464c52Smayatypedef int ImGuiDragFlags;         // -> enum ImGuiDragFlags_         // Flags: for DragBehavior()
949f464c52Smaya
959f464c52Smaya//-------------------------------------------------------------------------
969f464c52Smaya// STB libraries includes
979f464c52Smaya//-------------------------------------------------------------------------
989f464c52Smaya
999f464c52Smayanamespace ImGuiStb
1009f464c52Smaya{
1019f464c52Smaya
1029f464c52Smaya#undef STB_TEXTEDIT_STRING
1039f464c52Smaya#undef STB_TEXTEDIT_CHARTYPE
1049f464c52Smaya#define STB_TEXTEDIT_STRING             ImGuiInputTextState
1059f464c52Smaya#define STB_TEXTEDIT_CHARTYPE           ImWchar
1069f464c52Smaya#define STB_TEXTEDIT_GETWIDTH_NEWLINE   -1.0f
1079f464c52Smaya#include "imstb_textedit.h"
1089f464c52Smaya
1099f464c52Smaya} // namespace ImGuiStb
1109f464c52Smaya
1119f464c52Smaya//-----------------------------------------------------------------------------
1129f464c52Smaya// Context pointer
1139f464c52Smaya//-----------------------------------------------------------------------------
1149f464c52Smaya
1159f464c52Smaya#ifndef GImGui
1169f464c52Smayaextern IMGUI_API ImGuiContext* GImGui;  // Current implicit ImGui context pointer
1179f464c52Smaya#endif
1189f464c52Smaya
1199f464c52Smaya//-----------------------------------------------------------------------------
1209f464c52Smaya// Generic helpers
1219f464c52Smaya//-----------------------------------------------------------------------------
1229f464c52Smaya
1239f464c52Smaya#define IM_PI           3.14159265358979323846f
1249f464c52Smaya#ifdef _WIN32
1259f464c52Smaya#define IM_NEWLINE      "\r\n"   // Play it nice with Windows users (2018/05 news: Microsoft announced that Notepad will finally display Unix-style carriage returns!)
1269f464c52Smaya#else
1279f464c52Smaya#define IM_NEWLINE      "\n"
1289f464c52Smaya#endif
1299f464c52Smaya
1309f464c52Smaya#define IMGUI_DEBUG_LOG(_FMT,...)       printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
1319f464c52Smaya#define IM_STATIC_ASSERT(_COND)         typedef char static_assertion_##__line__[(_COND)?1:-1]
1329f464c52Smaya#define IM_F32_TO_INT8_UNBOUND(_VAL)    ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f)))   // Unsaturated, for display purpose
1339f464c52Smaya#define IM_F32_TO_INT8_SAT(_VAL)        ((int)(ImSaturate(_VAL) * 255.0f + 0.5f))               // Saturated, always output 0..255
1349f464c52Smaya
1359f464c52Smaya// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
1369f464c52Smaya#ifdef _MSC_VER
1379f464c52Smaya#define IMGUI_CDECL __cdecl
1389f464c52Smaya#else
1399f464c52Smaya#define IMGUI_CDECL
1409f464c52Smaya#endif
1419f464c52Smaya
1429f464c52Smaya// Helpers: UTF-8 <> wchar
1439f464c52SmayaIMGUI_API int           ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end);      // return output UTF-8 bytes count
1449f464c52SmayaIMGUI_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
1459f464c52SmayaIMGUI_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
1469f464c52SmayaIMGUI_API int           ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end);                            // return number of UTF-8 code-points (NOT bytes count)
1479f464c52SmayaIMGUI_API int           ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end);                        // return number of bytes to express one char in UTF-8
1489f464c52SmayaIMGUI_API int           ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end);                   // return number of bytes to express string in UTF-8
1499f464c52Smaya
1509f464c52Smaya// Helpers: Misc
1519f464c52SmayaIMGUI_API ImU32         ImHashData(const void* data, size_t data_size, ImU32 seed = 0);
1529f464c52SmayaIMGUI_API ImU32         ImHashStr(const char* data, size_t data_size, ImU32 seed = 0);
1539f464c52SmayaIMGUI_API void*         ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0);
1549f464c52SmayaIMGUI_API FILE*         ImFileOpen(const char* filename, const char* file_open_mode);
1559f464c52Smayastatic inline bool      ImCharIsBlankA(char c)          { return c == ' ' || c == '\t'; }
1569f464c52Smayastatic inline bool      ImCharIsBlankW(unsigned int c)  { return c == ' ' || c == '\t' || c == 0x3000; }
1579f464c52Smayastatic inline bool      ImIsPowerOfTwo(int v)           { return v != 0 && (v & (v - 1)) == 0; }
1589f464c52Smayastatic inline int       ImUpperPowerOfTwo(int v)        { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
1599f464c52Smaya#define ImQsort         qsort
1609f464c52Smaya#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1619f464c52Smayastatic 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]
1629f464c52Smaya#endif
1639f464c52Smaya
1649f464c52Smaya// Helpers: Geometry
1659f464c52SmayaIMGUI_API ImVec2        ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
1669f464c52SmayaIMGUI_API bool          ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
1679f464c52SmayaIMGUI_API ImVec2        ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
1689f464c52SmayaIMGUI_API void          ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
1699f464c52SmayaIMGUI_API ImGuiDir      ImGetDirQuadrantFromDelta(float dx, float dy);
1709f464c52Smaya
1719f464c52Smaya// Helpers: String
1729f464c52SmayaIMGUI_API int           ImStricmp(const char* str1, const char* str2);
1739f464c52SmayaIMGUI_API int           ImStrnicmp(const char* str1, const char* str2, size_t count);
1749f464c52SmayaIMGUI_API void          ImStrncpy(char* dst, const char* src, size_t count);
1759f464c52SmayaIMGUI_API char*         ImStrdup(const char* str);
1769f464c52SmayaIMGUI_API char*         ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str);
1779f464c52SmayaIMGUI_API const char*   ImStrchrRange(const char* str_begin, const char* str_end, char c);
1789f464c52SmayaIMGUI_API int           ImStrlenW(const ImWchar* str);
1799f464c52SmayaIMGUI_API const char*   ImStreolRange(const char* str, const char* str_end);                // End end-of-line
1809f464c52SmayaIMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin);   // Find beginning-of-line
1819f464c52SmayaIMGUI_API const char*   ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
1829f464c52SmayaIMGUI_API void          ImStrTrimBlanks(char* str);
1839f464c52SmayaIMGUI_API int           ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
1849f464c52SmayaIMGUI_API int           ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
1859f464c52SmayaIMGUI_API const char*   ImParseFormatFindStart(const char* format);
1869f464c52SmayaIMGUI_API const char*   ImParseFormatFindEnd(const char* format);
1879f464c52SmayaIMGUI_API const char*   ImParseFormatTrimDecorations(const char* format, char* buf, size_t buf_size);
1889f464c52SmayaIMGUI_API int           ImParseFormatPrecision(const char* format, int default_value);
1899f464c52Smaya
1909f464c52Smaya// Helpers: ImVec2/ImVec4 operators
1919f464c52Smaya// 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.)
1929f464c52Smaya// We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself.
1939f464c52Smaya#ifdef IMGUI_DEFINE_MATH_OPERATORS
1949f464c52Smayastatic inline ImVec2 operator*(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
1959f464c52Smayastatic inline ImVec2 operator/(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x/rhs, lhs.y/rhs); }
1969f464c52Smayastatic inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
1979f464c52Smayastatic inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
1989f464c52Smayastatic inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
1999f464c52Smayastatic inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
2009f464c52Smayastatic inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
2019f464c52Smayastatic inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs)                { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
2029f464c52Smayastatic inline ImVec2& operator*=(ImVec2& lhs, const float rhs)                  { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
2039f464c52Smayastatic inline ImVec2& operator/=(ImVec2& lhs, const float rhs)                  { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
2049f464c52Smayastatic 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); }
2059f464c52Smayastatic 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); }
2069f464c52Smayastatic 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); }
2079f464c52Smaya#endif
2089f464c52Smaya
2099f464c52Smaya// Helpers: Maths
2109f464c52Smaya// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
2119f464c52Smaya#ifndef IMGUI_DISABLE_MATH_FUNCTIONS
2129f464c52Smayastatic inline float  ImFabs(float x)                                            { return fabsf(x); }
2139f464c52Smayastatic inline float  ImSqrt(float x)                                            { return sqrtf(x); }
2149f464c52Smayastatic inline float  ImPow(float x, float y)                                    { return powf(x, y); }
2159f464c52Smayastatic inline double ImPow(double x, double y)                                  { return pow(x, y); }
2169f464c52Smayastatic inline float  ImFmod(float x, float y)                                   { return fmodf(x, y); }
2179f464c52Smayastatic inline double ImFmod(double x, double y)                                 { return fmod(x, y); }
2189f464c52Smayastatic inline float  ImCos(float x)                                             { return cosf(x); }
2199f464c52Smayastatic inline float  ImSin(float x)                                             { return sinf(x); }
2209f464c52Smayastatic inline float  ImAcos(float x)                                            { return acosf(x); }
2219f464c52Smayastatic inline float  ImAtan2(float y, float x)                                  { return atan2f(y, x); }
2229f464c52Smayastatic inline double ImAtof(const char* s)                                      { return atof(s); }
2239f464c52Smayastatic inline float  ImFloorStd(float x)                                        { return floorf(x); }   // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype)
2249f464c52Smayastatic inline float  ImCeil(float x)                                            { return ceilf(x); }
2259f464c52Smaya#endif
2269f464c52Smaya// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double, using templates here but we could also redefine them 6 times
2279f464c52Smayatemplate<typename T> static inline T ImMin(T lhs, T rhs)                        { return lhs < rhs ? lhs : rhs; }
2289f464c52Smayatemplate<typename T> static inline T ImMax(T lhs, T rhs)                        { return lhs >= rhs ? lhs : rhs; }
2299f464c52Smayatemplate<typename T> static inline T ImClamp(T v, T mn, T mx)                   { return (v < mn) ? mn : (v > mx) ? mx : v; }
2309f464c52Smayatemplate<typename T> static inline T ImLerp(T a, T b, float t)                  { return (T)(a + (b - a) * t); }
2319f464c52Smayatemplate<typename T> static inline void ImSwap(T& a, T& b)                      { T tmp = a; a = b; b = tmp; }
2329f464c52Smaya// - Misc maths helpers
2339f464c52Smayastatic 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); }
2349f464c52Smayastatic 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); }
2359f464c52Smayastatic 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); }
2369f464c52Smayastatic 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); }
2379f464c52Smayastatic 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); }
2389f464c52Smayastatic 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); }
2399f464c52Smayastatic inline float  ImSaturate(float f)                                        { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
2409f464c52Smayastatic inline float  ImLengthSqr(const ImVec2& lhs)                             { return lhs.x*lhs.x + lhs.y*lhs.y; }
2419f464c52Smayastatic inline float  ImLengthSqr(const ImVec4& lhs)                             { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
2429f464c52Smayastatic 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; }
2439f464c52Smayastatic inline float  ImFloor(float f)                                           { return (float)(int)f; }
2449f464c52Smayastatic inline ImVec2 ImFloor(const ImVec2& v)                                   { return ImVec2((float)(int)v.x, (float)(int)v.y); }
2459f464c52Smayastatic inline float  ImDot(const ImVec2& a, const ImVec2& b)                    { return a.x * b.x + a.y * b.y; }
2469f464c52Smayastatic 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); }
2479f464c52Smayastatic 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; }
2489f464c52Smayastatic inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs)                { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
2499f464c52Smaya
2509f464c52Smaya// Helper: ImBoolVector. Store 1-bit per value.
2519f464c52Smaya// Note that Resize() currently clears the whole vector.
2529f464c52Smayastruct ImBoolVector
2539f464c52Smaya{
2549f464c52Smaya    ImVector<int>   Storage;
2559f464c52Smaya    ImBoolVector()  { }
2569f464c52Smaya    void            Resize(int sz)          { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
2579f464c52Smaya    void            Clear()                 { Storage.clear(); }
2589f464c52Smaya    bool            GetBit(int n) const     { int off = (n >> 5); int mask = 1 << (n & 31); return (Storage[off] & mask) != 0; }
2599f464c52Smaya    void            SetBit(int n, bool v)   { int off = (n >> 5); int mask = 1 << (n & 31); if (v) Storage[off] |= mask; else Storage[off] &= ~mask; }
2609f464c52Smaya};
2619f464c52Smaya
2629f464c52Smaya// Helper: ImPool<>. Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer,
2639f464c52Smaya// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
2649f464c52Smayatypedef int ImPoolIdx;
2659f464c52Smayatemplate<typename T>
2669f464c52Smayastruct IMGUI_API ImPool
2679f464c52Smaya{
2689f464c52Smaya    ImVector<T>     Data;       // Contiguous data
2699f464c52Smaya    ImGuiStorage    Map;        // ID->Index
2709f464c52Smaya    ImPoolIdx       FreeIdx;    // Next free idx to use
2719f464c52Smaya
2729f464c52Smaya    ImPool()    { FreeIdx = 0; }
2739f464c52Smaya    ~ImPool()   { Clear(); }
2749f464c52Smaya    T*          GetByKey(ImGuiID key)               { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; }
2759f464c52Smaya    T*          GetByIndex(ImPoolIdx n)             { return &Data[n]; }
2769f464c52Smaya    ImPoolIdx   GetIndex(const T* p) const          { IM_ASSERT(p >= Data.Data && p < Data.Data + Data.Size); return (ImPoolIdx)(p - Data.Data); }
2779f464c52Smaya    T*          GetOrAddByKey(ImGuiID key)          { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); }
2789f464c52Smaya    void        Clear()                             { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Data[idx].~T(); }  Map.Clear(); Data.clear(); FreeIdx = 0; }
2799f464c52Smaya    T*          Add()                               { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; }
2809f464c52Smaya    void        Remove(ImGuiID key, const T* p)     { Remove(key, GetIndex(p)); }
2819f464c52Smaya    void        Remove(ImGuiID key, ImPoolIdx idx)  { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); }
2829f464c52Smaya    void        Reserve(int capacity)               { Data.reserve(capacity); Map.Data.reserve(capacity); }
2839f464c52Smaya    int         GetSize() const                     { return Data.Size; }
2849f464c52Smaya};
2859f464c52Smaya
2869f464c52Smaya//-----------------------------------------------------------------------------
2879f464c52Smaya// Misc data structures
2889f464c52Smaya//-----------------------------------------------------------------------------
2899f464c52Smaya
2909f464c52Smayaenum ImGuiButtonFlags_
2919f464c52Smaya{
2929f464c52Smaya    ImGuiButtonFlags_None                   = 0,
2939f464c52Smaya    ImGuiButtonFlags_Repeat                 = 1 << 0,   // hold to repeat
2949f464c52Smaya    ImGuiButtonFlags_PressedOnClickRelease  = 1 << 1,   // return true on click + release on same item [DEFAULT if no PressedOn* flag is set]
2959f464c52Smaya    ImGuiButtonFlags_PressedOnClick         = 1 << 2,   // return true on click (default requires click+release)
2969f464c52Smaya    ImGuiButtonFlags_PressedOnRelease       = 1 << 3,   // return true on release (default requires click+release)
2979f464c52Smaya    ImGuiButtonFlags_PressedOnDoubleClick   = 1 << 4,   // return true on double-click (default requires click+release)
2989f464c52Smaya    ImGuiButtonFlags_FlattenChildren        = 1 << 5,   // allow interactions even if a child window is overlapping
2999f464c52Smaya    ImGuiButtonFlags_AllowItemOverlap       = 1 << 6,   // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
3009f464c52Smaya    ImGuiButtonFlags_DontClosePopups        = 1 << 7,   // disable automatically closing parent popup on press // [UNUSED]
3019f464c52Smaya    ImGuiButtonFlags_Disabled               = 1 << 8,   // disable interactions
3029f464c52Smaya    ImGuiButtonFlags_AlignTextBaseLine      = 1 << 9,   // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
3039f464c52Smaya    ImGuiButtonFlags_NoKeyModifiers         = 1 << 10,  // disable interaction if a key modifier is held
3049f464c52Smaya    ImGuiButtonFlags_NoHoldingActiveID      = 1 << 11,  // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
3059f464c52Smaya    ImGuiButtonFlags_PressedOnDragDropHold  = 1 << 12,  // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
3069f464c52Smaya    ImGuiButtonFlags_NoNavFocus             = 1 << 13   // don't override navigation focus when activated
3079f464c52Smaya};
3089f464c52Smaya
3099f464c52Smayaenum ImGuiSliderFlags_
3109f464c52Smaya{
3119f464c52Smaya    ImGuiSliderFlags_None                   = 0,
3129f464c52Smaya    ImGuiSliderFlags_Vertical               = 1 << 0
3139f464c52Smaya};
3149f464c52Smaya
3159f464c52Smayaenum ImGuiDragFlags_
3169f464c52Smaya{
3179f464c52Smaya    ImGuiDragFlags_None                     = 0,
3189f464c52Smaya    ImGuiDragFlags_Vertical                 = 1 << 0
3199f464c52Smaya};
3209f464c52Smaya
3219f464c52Smayaenum ImGuiColumnsFlags_
3229f464c52Smaya{
3239f464c52Smaya    // Default: 0
3249f464c52Smaya    ImGuiColumnsFlags_None                  = 0,
3259f464c52Smaya    ImGuiColumnsFlags_NoBorder              = 1 << 0,   // Disable column dividers
3269f464c52Smaya    ImGuiColumnsFlags_NoResize              = 1 << 1,   // Disable resizing columns when clicking on the dividers
3279f464c52Smaya    ImGuiColumnsFlags_NoPreserveWidths      = 1 << 2,   // Disable column width preservation when adjusting columns
3289f464c52Smaya    ImGuiColumnsFlags_NoForceWithinWindow   = 1 << 3,   // Disable forcing columns to fit within window
3299f464c52Smaya    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.
3309f464c52Smaya};
3319f464c52Smaya
3329f464c52Smayaenum ImGuiSelectableFlagsPrivate_
3339f464c52Smaya{
3349f464c52Smaya    // NB: need to be in sync with last value of ImGuiSelectableFlags_
3359f464c52Smaya    ImGuiSelectableFlags_NoHoldingActiveID  = 1 << 10,
3369f464c52Smaya    ImGuiSelectableFlags_PressedOnClick     = 1 << 11,
3379f464c52Smaya    ImGuiSelectableFlags_PressedOnRelease   = 1 << 12,
3389f464c52Smaya    ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 13
3399f464c52Smaya};
3409f464c52Smaya
3419f464c52Smayaenum ImGuiSeparatorFlags_
3429f464c52Smaya{
3439f464c52Smaya    ImGuiSeparatorFlags_None                = 0,
3449f464c52Smaya    ImGuiSeparatorFlags_Horizontal          = 1 << 0,   // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
3459f464c52Smaya    ImGuiSeparatorFlags_Vertical            = 1 << 1
3469f464c52Smaya};
3479f464c52Smaya
3489f464c52Smaya// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
3499f464c52Smaya// This is going to be exposed in imgui.h when stabilized enough.
3509f464c52Smayaenum ImGuiItemFlags_
3519f464c52Smaya{
3529f464c52Smaya    ImGuiItemFlags_NoTabStop                = 1 << 0,  // false
3539f464c52Smaya    ImGuiItemFlags_ButtonRepeat             = 1 << 1,  // false    // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
3549f464c52Smaya    ImGuiItemFlags_Disabled                 = 1 << 2,  // false    // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
3559f464c52Smaya    ImGuiItemFlags_NoNav                    = 1 << 3,  // false
3569f464c52Smaya    ImGuiItemFlags_NoNavDefaultFocus        = 1 << 4,  // false
3579f464c52Smaya    ImGuiItemFlags_SelectableDontClosePopup = 1 << 5,  // false    // MenuItem/Selectable() automatically closes current Popup window
3589f464c52Smaya    ImGuiItemFlags_Default_                 = 0
3599f464c52Smaya};
3609f464c52Smaya
3619f464c52Smaya// Storage for LastItem data
3629f464c52Smayaenum ImGuiItemStatusFlags_
3639f464c52Smaya{
3649f464c52Smaya    ImGuiItemStatusFlags_None               = 0,
3659f464c52Smaya    ImGuiItemStatusFlags_HoveredRect        = 1 << 0,
3669f464c52Smaya    ImGuiItemStatusFlags_HasDisplayRect     = 1 << 1,
3679f464c52Smaya    ImGuiItemStatusFlags_Edited             = 1 << 2    // Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
3689f464c52Smaya
3699f464c52Smaya#ifdef IMGUI_ENABLE_TEST_ENGINE
3709f464c52Smaya    , // [imgui-test only]
3719f464c52Smaya    ImGuiItemStatusFlags_Openable           = 1 << 10,  //
3729f464c52Smaya    ImGuiItemStatusFlags_Opened             = 1 << 11,  //
3739f464c52Smaya    ImGuiItemStatusFlags_Checkable          = 1 << 12,  //
3749f464c52Smaya    ImGuiItemStatusFlags_Checked            = 1 << 13   //
3759f464c52Smaya#endif
3769f464c52Smaya};
3779f464c52Smaya
3789f464c52Smaya// FIXME: this is in development, not exposed/functional as a generic feature yet.
3799f464c52Smaya// Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2
3809f464c52Smayaenum ImGuiLayoutType_
3819f464c52Smaya{
3829f464c52Smaya    ImGuiLayoutType_Horizontal = 0,
3839f464c52Smaya    ImGuiLayoutType_Vertical = 1
3849f464c52Smaya};
3859f464c52Smaya
3869f464c52Smaya// X/Y enums are fixed to 0/1 so they may be used to index ImVec2
3879f464c52Smayaenum ImGuiAxis
3889f464c52Smaya{
3899f464c52Smaya    ImGuiAxis_None = -1,
3909f464c52Smaya    ImGuiAxis_X = 0,
3919f464c52Smaya    ImGuiAxis_Y = 1
3929f464c52Smaya};
3939f464c52Smaya
3949f464c52Smayaenum ImGuiPlotType
3959f464c52Smaya{
3969f464c52Smaya    ImGuiPlotType_Lines,
3979f464c52Smaya    ImGuiPlotType_Histogram
3989f464c52Smaya};
3999f464c52Smaya
4009f464c52Smayaenum ImGuiInputSource
4019f464c52Smaya{
4029f464c52Smaya    ImGuiInputSource_None = 0,
4039f464c52Smaya    ImGuiInputSource_Mouse,
4049f464c52Smaya    ImGuiInputSource_Nav,
4059f464c52Smaya    ImGuiInputSource_NavKeyboard,   // Only used occasionally for storage, not tested/handled by most code
4069f464c52Smaya    ImGuiInputSource_NavGamepad,    // "
4079f464c52Smaya    ImGuiInputSource_COUNT
4089f464c52Smaya};
4099f464c52Smaya
4109f464c52Smaya// FIXME-NAV: Clarify/expose various repeat delay/rate
4119f464c52Smayaenum ImGuiInputReadMode
4129f464c52Smaya{
4139f464c52Smaya    ImGuiInputReadMode_Down,
4149f464c52Smaya    ImGuiInputReadMode_Pressed,
4159f464c52Smaya    ImGuiInputReadMode_Released,
4169f464c52Smaya    ImGuiInputReadMode_Repeat,
4179f464c52Smaya    ImGuiInputReadMode_RepeatSlow,
4189f464c52Smaya    ImGuiInputReadMode_RepeatFast
4199f464c52Smaya};
4209f464c52Smaya
4219f464c52Smayaenum ImGuiNavHighlightFlags_
4229f464c52Smaya{
4239f464c52Smaya    ImGuiNavHighlightFlags_None         = 0,
4249f464c52Smaya    ImGuiNavHighlightFlags_TypeDefault  = 1 << 0,
4259f464c52Smaya    ImGuiNavHighlightFlags_TypeThin     = 1 << 1,
4269f464c52Smaya    ImGuiNavHighlightFlags_AlwaysDraw   = 1 << 2,       // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse.
4279f464c52Smaya    ImGuiNavHighlightFlags_NoRounding   = 1 << 3
4289f464c52Smaya};
4299f464c52Smaya
4309f464c52Smayaenum ImGuiNavDirSourceFlags_
4319f464c52Smaya{
4329f464c52Smaya    ImGuiNavDirSourceFlags_None         = 0,
4339f464c52Smaya    ImGuiNavDirSourceFlags_Keyboard     = 1 << 0,
4349f464c52Smaya    ImGuiNavDirSourceFlags_PadDPad      = 1 << 1,
4359f464c52Smaya    ImGuiNavDirSourceFlags_PadLStick    = 1 << 2
4369f464c52Smaya};
4379f464c52Smaya
4389f464c52Smayaenum ImGuiNavMoveFlags_
4399f464c52Smaya{
4409f464c52Smaya    ImGuiNavMoveFlags_None                  = 0,
4419f464c52Smaya    ImGuiNavMoveFlags_LoopX                 = 1 << 0,   // On failed request, restart from opposite side
4429f464c52Smaya    ImGuiNavMoveFlags_LoopY                 = 1 << 1,
4439f464c52Smaya    ImGuiNavMoveFlags_WrapX                 = 1 << 2,   // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left)
4449f464c52Smaya    ImGuiNavMoveFlags_WrapY                 = 1 << 3,   // This is not super useful for provided for completeness
4459f464c52Smaya    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)
4469f464c52Smaya    ImGuiNavMoveFlags_AlsoScoreVisibleSet   = 1 << 5    // Store alternate result in NavMoveResultLocalVisibleSet that only comprise elements that are already fully visible.
4479f464c52Smaya};
4489f464c52Smaya
4499f464c52Smayaenum ImGuiNavForward
4509f464c52Smaya{
4519f464c52Smaya    ImGuiNavForward_None,
4529f464c52Smaya    ImGuiNavForward_ForwardQueued,
4539f464c52Smaya    ImGuiNavForward_ForwardActive
4549f464c52Smaya};
4559f464c52Smaya
4569f464c52Smayaenum ImGuiNavLayer
4579f464c52Smaya{
4589f464c52Smaya    ImGuiNavLayer_Main  = 0,    // Main scrolling layer
4599f464c52Smaya    ImGuiNavLayer_Menu  = 1,    // Menu layer (access with Alt/ImGuiNavInput_Menu)
4609f464c52Smaya    ImGuiNavLayer_COUNT
4619f464c52Smaya};
4629f464c52Smaya
4639f464c52Smayaenum ImGuiPopupPositionPolicy
4649f464c52Smaya{
4659f464c52Smaya    ImGuiPopupPositionPolicy_Default,
4669f464c52Smaya    ImGuiPopupPositionPolicy_ComboBox
4679f464c52Smaya};
4689f464c52Smaya
4699f464c52Smaya// 1D vector (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
4709f464c52Smayastruct ImVec1
4719f464c52Smaya{
4729f464c52Smaya    float   x;
4739f464c52Smaya    ImVec1()         { x = 0.0f; }
4749f464c52Smaya    ImVec1(float _x) { x = _x; }
4759f464c52Smaya};
4769f464c52Smaya
4779f464c52Smaya
4789f464c52Smaya// 2D axis aligned bounding-box
4799f464c52Smaya// NB: we can't rely on ImVec2 math operators being available here
4809f464c52Smayastruct IMGUI_API ImRect
4819f464c52Smaya{
4829f464c52Smaya    ImVec2      Min;    // Upper-left
4839f464c52Smaya    ImVec2      Max;    // Lower-right
4849f464c52Smaya
4859f464c52Smaya    ImRect()                                        : Min(FLT_MAX,FLT_MAX), Max(-FLT_MAX,-FLT_MAX)  {}
4869f464c52Smaya    ImRect(const ImVec2& min, const ImVec2& max)    : Min(min), Max(max)                            {}
4879f464c52Smaya    ImRect(const ImVec4& v)                         : Min(v.x, v.y), Max(v.z, v.w)                  {}
4889f464c52Smaya    ImRect(float x1, float y1, float x2, float y2)  : Min(x1, y1), Max(x2, y2)                      {}
4899f464c52Smaya
4909f464c52Smaya    ImVec2      GetCenter() const                   { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
4919f464c52Smaya    ImVec2      GetSize() const                     { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
4929f464c52Smaya    float       GetWidth() const                    { return Max.x - Min.x; }
4939f464c52Smaya    float       GetHeight() const                   { return Max.y - Min.y; }
4949f464c52Smaya    ImVec2      GetTL() const                       { return Min; }                   // Top-left
4959f464c52Smaya    ImVec2      GetTR() const                       { return ImVec2(Max.x, Min.y); }  // Top-right
4969f464c52Smaya    ImVec2      GetBL() const                       { return ImVec2(Min.x, Max.y); }  // Bottom-left
4979f464c52Smaya    ImVec2      GetBR() const                       { return Max; }                   // Bottom-right
4989f464c52Smaya    bool        Contains(const ImVec2& p) const     { return p.x     >= Min.x && p.y     >= Min.y && p.x     <  Max.x && p.y     <  Max.y; }
4999f464c52Smaya    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; }
5009f464c52Smaya    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; }
5019f464c52Smaya    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; }
5029f464c52Smaya    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; }
5039f464c52Smaya    void        Expand(const float amount)          { Min.x -= amount;   Min.y -= amount;   Max.x += amount;   Max.y += amount; }
5049f464c52Smaya    void        Expand(const ImVec2& amount)        { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
5059f464c52Smaya    void        Translate(const ImVec2& d)          { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; }
5069f464c52Smaya    void        TranslateX(float dx)                { Min.x += dx; Max.x += dx; }
5079f464c52Smaya    void        TranslateY(float dy)                { Min.y += dy; Max.y += dy; }
5089f464c52Smaya    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.
5099f464c52Smaya    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.
5109f464c52Smaya    void        Floor()                             { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
5119f464c52Smaya    bool        IsInverted() const                  { return Min.x > Max.x || Min.y > Max.y; }
5129f464c52Smaya};
5139f464c52Smaya
5149f464c52Smaya// Stacked color modifier, backup of modified data so we can restore it
5159f464c52Smayastruct ImGuiColorMod
5169f464c52Smaya{
5179f464c52Smaya    ImGuiCol    Col;
5189f464c52Smaya    ImVec4      BackupValue;
5199f464c52Smaya};
5209f464c52Smaya
5219f464c52Smaya// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
5229f464c52Smayastruct ImGuiStyleMod
5239f464c52Smaya{
5249f464c52Smaya    ImGuiStyleVar   VarIdx;
5259f464c52Smaya    union           { int BackupInt[2]; float BackupFloat[2]; };
5269f464c52Smaya    ImGuiStyleMod(ImGuiStyleVar idx, int v)     { VarIdx = idx; BackupInt[0] = v; }
5279f464c52Smaya    ImGuiStyleMod(ImGuiStyleVar idx, float v)   { VarIdx = idx; BackupFloat[0] = v; }
5289f464c52Smaya    ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v)  { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
5299f464c52Smaya};
5309f464c52Smaya
5319f464c52Smaya// Stacked storage data for BeginGroup()/EndGroup()
5329f464c52Smayastruct ImGuiGroupData
5339f464c52Smaya{
5349f464c52Smaya    ImVec2      BackupCursorPos;
5359f464c52Smaya    ImVec2      BackupCursorMaxPos;
5369f464c52Smaya    ImVec1      BackupIndent;
5379f464c52Smaya    ImVec1      BackupGroupOffset;
5389f464c52Smaya    ImVec2      BackupCurrentLineSize;
5399f464c52Smaya    float       BackupCurrentLineTextBaseOffset;
5409f464c52Smaya    float       BackupLogLinePosY;
5419f464c52Smaya    ImGuiID     BackupActiveIdIsAlive;
5429f464c52Smaya    bool        BackupActiveIdPreviousFrameIsAlive;
5439f464c52Smaya    bool        AdvanceCursor;
5449f464c52Smaya};
5459f464c52Smaya
5469f464c52Smaya// Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper.
5479f464c52Smayastruct IMGUI_API ImGuiMenuColumns
5489f464c52Smaya{
5499f464c52Smaya    int         Count;
5509f464c52Smaya    float       Spacing;
5519f464c52Smaya    float       Width, NextWidth;
5529f464c52Smaya    float       Pos[4], NextWidths[4];
5539f464c52Smaya
5549f464c52Smaya    ImGuiMenuColumns();
5559f464c52Smaya    void        Update(int count, float spacing, bool clear);
5569f464c52Smaya    float       DeclColumns(float w0, float w1, float w2);
5579f464c52Smaya    float       CalcExtraSpace(float avail_w);
5589f464c52Smaya};
5599f464c52Smaya
5609f464c52Smaya// Internal state of the currently focused/edited text input box
5619f464c52Smayastruct IMGUI_API ImGuiInputTextState
5629f464c52Smaya{
5639f464c52Smaya    ImGuiID                 ID;                     // widget id owning the text state
5649f464c52Smaya    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.
5659f464c52Smaya    ImVector<char>          InitialText;            // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
5669f464c52Smaya    ImVector<char>          TempBuffer;             // temporary buffer for callback and other other operations. size=capacity.
5679f464c52Smaya    int                     CurLenA, CurLenW;       // we need to maintain our buffer length in both UTF-8 and wchar format.
5689f464c52Smaya    int                     BufCapacityA;           // end-user buffer capacity
5699f464c52Smaya    float                   ScrollX;
5709f464c52Smaya    ImGuiStb::STB_TexteditState StbState;
5719f464c52Smaya    float                   CursorAnim;
5729f464c52Smaya    bool                    CursorFollow;
5739f464c52Smaya    bool                    SelectedAllMouseLock;
5749f464c52Smaya
5759f464c52Smaya    // Temporarily set when active
5769f464c52Smaya    ImGuiInputTextFlags     UserFlags;
5779f464c52Smaya    ImGuiInputTextCallback  UserCallback;
5789f464c52Smaya    void*                   UserCallbackData;
5799f464c52Smaya
5809f464c52Smaya    ImGuiInputTextState()                           { memset(this, 0, sizeof(*this)); }
5819f464c52Smaya    void                CursorAnimReset()           { CursorAnim = -0.30f; }                                   // After a user-input the cursor stays on for a while without blinking
5829f464c52Smaya    void                CursorClamp()               { StbState.cursor = ImMin(StbState.cursor, CurLenW); StbState.select_start = ImMin(StbState.select_start, CurLenW); StbState.select_end = ImMin(StbState.select_end, CurLenW); }
5839f464c52Smaya    bool                HasSelection() const        { return StbState.select_start != StbState.select_end; }
5849f464c52Smaya    void                ClearSelection()            { StbState.select_start = StbState.select_end = StbState.cursor; }
5859f464c52Smaya    void                SelectAll()                 { StbState.select_start = 0; StbState.cursor = StbState.select_end = CurLenW; StbState.has_preferred_x = 0; }
5869f464c52Smaya    void                OnKeyPressed(int key);      // Cannot be inline because we call in code in stb_textedit.h implementation
5879f464c52Smaya};
5889f464c52Smaya
5899f464c52Smaya// Windows data saved in imgui.ini file
5909f464c52Smayastruct ImGuiWindowSettings
5919f464c52Smaya{
5929f464c52Smaya    char*       Name;
5939f464c52Smaya    ImGuiID     ID;
5949f464c52Smaya    ImVec2      Pos;
5959f464c52Smaya    ImVec2      Size;
5969f464c52Smaya    bool        Collapsed;
5979f464c52Smaya
5989f464c52Smaya    ImGuiWindowSettings() { Name = NULL; ID = 0; Pos = Size = ImVec2(0,0); Collapsed = false; }
5999f464c52Smaya};
6009f464c52Smaya
6019f464c52Smayastruct ImGuiSettingsHandler
6029f464c52Smaya{
6039f464c52Smaya    const char* TypeName;       // Short description stored in .ini file. Disallowed characters: '[' ']'
6049f464c52Smaya    ImGuiID     TypeHash;       // == ImHashStr(TypeName, 0, 0)
6059f464c52Smaya    void*       (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name);              // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
6069f464c52Smaya    void        (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
6079f464c52Smaya    void        (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf);      // Write: Output every entries into 'out_buf'
6089f464c52Smaya    void*       UserData;
6099f464c52Smaya
6109f464c52Smaya    ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); }
6119f464c52Smaya};
6129f464c52Smaya
6139f464c52Smaya// Storage for current popup stack
6149f464c52Smayastruct ImGuiPopupRef
6159f464c52Smaya{
6169f464c52Smaya    ImGuiID             PopupId;        // Set on OpenPopup()
6179f464c52Smaya    ImGuiWindow*        Window;         // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
6189f464c52Smaya    ImGuiWindow*        ParentWindow;   // Set on OpenPopup()
6199f464c52Smaya    int                 OpenFrameCount; // Set on OpenPopup()
6209f464c52Smaya    ImGuiID             OpenParentId;   // Set on OpenPopup(), we need this to differenciate multiple menu sets from each others (e.g. inside menu bar vs loose menu items)
6219f464c52Smaya    ImVec2              OpenPopupPos;   // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse)
6229f464c52Smaya    ImVec2              OpenMousePos;   // Set on OpenPopup(), copy of mouse position at the time of opening popup
6239f464c52Smaya};
6249f464c52Smaya
6259f464c52Smayastruct ImGuiColumnData
6269f464c52Smaya{
6279f464c52Smaya    float               OffsetNorm;         // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
6289f464c52Smaya    float               OffsetNormBeforeResize;
6299f464c52Smaya    ImGuiColumnsFlags   Flags;              // Not exposed
6309f464c52Smaya    ImRect              ClipRect;
6319f464c52Smaya
6329f464c52Smaya    ImGuiColumnData()   { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = 0; }
6339f464c52Smaya};
6349f464c52Smaya
6359f464c52Smayastruct ImGuiColumnsSet
6369f464c52Smaya{
6379f464c52Smaya    ImGuiID             ID;
6389f464c52Smaya    ImGuiColumnsFlags   Flags;
6399f464c52Smaya    bool                IsFirstFrame;
6409f464c52Smaya    bool                IsBeingResized;
6419f464c52Smaya    int                 Current;
6429f464c52Smaya    int                 Count;
6439f464c52Smaya    float               MinX, MaxX;
6449f464c52Smaya    float               LineMinY, LineMaxY;
6459f464c52Smaya    float               StartPosY;          // Copy of CursorPos
6469f464c52Smaya    float               StartMaxPosX;       // Copy of CursorMaxPos
6479f464c52Smaya    ImVector<ImGuiColumnData> Columns;
6489f464c52Smaya
6499f464c52Smaya    ImGuiColumnsSet()   { Clear(); }
6509f464c52Smaya    void Clear()
6519f464c52Smaya    {
6529f464c52Smaya        ID = 0;
6539f464c52Smaya        Flags = 0;
6549f464c52Smaya        IsFirstFrame = false;
6559f464c52Smaya        IsBeingResized = false;
6569f464c52Smaya        Current = 0;
6579f464c52Smaya        Count = 1;
6589f464c52Smaya        MinX = MaxX = 0.0f;
6599f464c52Smaya        LineMinY = LineMaxY = 0.0f;
6609f464c52Smaya        StartPosY = 0.0f;
6619f464c52Smaya        StartMaxPosX = 0.0f;
6629f464c52Smaya        Columns.clear();
6639f464c52Smaya    }
6649f464c52Smaya};
6659f464c52Smaya
6669f464c52Smaya// Data shared between all ImDrawList instances
6679f464c52Smayastruct IMGUI_API ImDrawListSharedData
6689f464c52Smaya{
6699f464c52Smaya    ImVec2          TexUvWhitePixel;            // UV of white pixel in the atlas
6709f464c52Smaya    ImFont*         Font;                       // Current/default font (optional, for simplified AddText overload)
6719f464c52Smaya    float           FontSize;                   // Current/default font size (optional, for simplified AddText overload)
6729f464c52Smaya    float           CurveTessellationTol;
6739f464c52Smaya    ImVec4          ClipRectFullscreen;         // Value for PushClipRectFullscreen()
6749f464c52Smaya
6759f464c52Smaya    // Const data
6769f464c52Smaya    // FIXME: Bake rounded corners fill/borders in atlas
6779f464c52Smaya    ImVec2          CircleVtx12[12];
6789f464c52Smaya
6799f464c52Smaya    ImDrawListSharedData();
6809f464c52Smaya};
6819f464c52Smaya
6829f464c52Smayastruct ImDrawDataBuilder
6839f464c52Smaya{
6849f464c52Smaya    ImVector<ImDrawList*>   Layers[2];           // Global layers for: regular, tooltip
6859f464c52Smaya
6869f464c52Smaya    void Clear()            { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
6879f464c52Smaya    void ClearFreeMemory()  { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
6889f464c52Smaya    IMGUI_API void FlattenIntoSingleLayer();
6899f464c52Smaya};
6909f464c52Smaya
6919f464c52Smayastruct ImGuiNavMoveResult
6929f464c52Smaya{
6939f464c52Smaya    ImGuiID       ID;           // Best candidate
6949f464c52Smaya    ImGuiID       SelectScopeId;// Best candidate window current selectable group ID
6959f464c52Smaya    ImGuiWindow*  Window;       // Best candidate window
6969f464c52Smaya    float         DistBox;      // Best candidate box distance to current NavId
6979f464c52Smaya    float         DistCenter;   // Best candidate center distance to current NavId
6989f464c52Smaya    float         DistAxial;
6999f464c52Smaya    ImRect        RectRel;      // Best candidate bounding box in window relative space
7009f464c52Smaya
7019f464c52Smaya    ImGuiNavMoveResult() { Clear(); }
7029f464c52Smaya    void Clear()         { ID = SelectScopeId = 0; Window = NULL; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); }
7039f464c52Smaya};
7049f464c52Smaya
7059f464c52Smaya// Storage for SetNexWindow** functions
7069f464c52Smayastruct ImGuiNextWindowData
7079f464c52Smaya{
7089f464c52Smaya    ImGuiCond               PosCond;
7099f464c52Smaya    ImGuiCond               SizeCond;
7109f464c52Smaya    ImGuiCond               ContentSizeCond;
7119f464c52Smaya    ImGuiCond               CollapsedCond;
7129f464c52Smaya    ImGuiCond               SizeConstraintCond;
7139f464c52Smaya    ImGuiCond               FocusCond;
7149f464c52Smaya    ImGuiCond               BgAlphaCond;
7159f464c52Smaya    ImVec2                  PosVal;
7169f464c52Smaya    ImVec2                  PosPivotVal;
7179f464c52Smaya    ImVec2                  SizeVal;
7189f464c52Smaya    ImVec2                  ContentSizeVal;
7199f464c52Smaya    bool                    CollapsedVal;
7209f464c52Smaya    ImRect                  SizeConstraintRect;
7219f464c52Smaya    ImGuiSizeCallback       SizeCallback;
7229f464c52Smaya    void*                   SizeCallbackUserData;
7239f464c52Smaya    float                   BgAlphaVal;
7249f464c52Smaya    ImVec2                  MenuBarOffsetMinVal;                // This is not exposed publicly, so we don't clear it.
7259f464c52Smaya
7269f464c52Smaya    ImGuiNextWindowData()
7279f464c52Smaya    {
7289f464c52Smaya        PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
7299f464c52Smaya        PosVal = PosPivotVal = SizeVal = ImVec2(0.0f, 0.0f);
7309f464c52Smaya        ContentSizeVal = ImVec2(0.0f, 0.0f);
7319f464c52Smaya        CollapsedVal = false;
7329f464c52Smaya        SizeConstraintRect = ImRect();
7339f464c52Smaya        SizeCallback = NULL;
7349f464c52Smaya        SizeCallbackUserData = NULL;
7359f464c52Smaya        BgAlphaVal = FLT_MAX;
7369f464c52Smaya        MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
7379f464c52Smaya    }
7389f464c52Smaya
7399f464c52Smaya    void    Clear()
7409f464c52Smaya    {
7419f464c52Smaya        PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
7429f464c52Smaya    }
7439f464c52Smaya};
7449f464c52Smaya
7459f464c52Smaya//-----------------------------------------------------------------------------
7469f464c52Smaya// Tabs
7479f464c52Smaya//-----------------------------------------------------------------------------
7489f464c52Smaya
7499f464c52Smayastruct ImGuiTabBarSortItem
7509f464c52Smaya{
7519f464c52Smaya    int         Index;
7529f464c52Smaya    float       Width;
7539f464c52Smaya};
7549f464c52Smaya
7559f464c52Smaya//-----------------------------------------------------------------------------
7569f464c52Smaya// Main imgui context
7579f464c52Smaya//-----------------------------------------------------------------------------
7589f464c52Smaya
7599f464c52Smayastruct ImGuiContext
7609f464c52Smaya{
7619f464c52Smaya    bool                    Initialized;
7629f464c52Smaya    bool                    FrameScopeActive;                   // Set by NewFrame(), cleared by EndFrame()
7639f464c52Smaya    bool                    FrameScopePushedImplicitWindow;     // Set by NewFrame(), cleared by EndFrame()
7649f464c52Smaya    bool                    FontAtlasOwnedByContext;            // Io.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
7659f464c52Smaya    ImGuiIO                 IO;
7669f464c52Smaya    ImGuiStyle              Style;
7679f464c52Smaya    ImFont*                 Font;                               // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
7689f464c52Smaya    float                   FontSize;                           // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
7699f464c52Smaya    float                   FontBaseSize;                       // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
7709f464c52Smaya    ImDrawListSharedData    DrawListSharedData;
7719f464c52Smaya
7729f464c52Smaya    double                  Time;
7739f464c52Smaya    int                     FrameCount;
7749f464c52Smaya    int                     FrameCountEnded;
7759f464c52Smaya    int                     FrameCountRendered;
7769f464c52Smaya    ImVector<ImGuiWindow*>  Windows;                            // Windows, sorted in display order, back to front
7779f464c52Smaya    ImVector<ImGuiWindow*>  WindowsFocusOrder;                  // Windows, sorted in focus order, back to front
7789f464c52Smaya    ImVector<ImGuiWindow*>  WindowsSortBuffer;
7799f464c52Smaya    ImVector<ImGuiWindow*>  CurrentWindowStack;
7809f464c52Smaya    ImGuiStorage            WindowsById;
7819f464c52Smaya    int                     WindowsActiveCount;
7829f464c52Smaya    ImGuiWindow*            CurrentWindow;                      // Being drawn into
7839f464c52Smaya    ImGuiWindow*            HoveredWindow;                      // Will catch mouse inputs
7849f464c52Smaya    ImGuiWindow*            HoveredRootWindow;                  // Will catch mouse inputs (for focus/move only)
7859f464c52Smaya    ImGuiID                 HoveredId;                          // Hovered widget
7869f464c52Smaya    bool                    HoveredIdAllowOverlap;
7879f464c52Smaya    ImGuiID                 HoveredIdPreviousFrame;
7889f464c52Smaya    float                   HoveredIdTimer;                     // Measure contiguous hovering time
7899f464c52Smaya    float                   HoveredIdNotActiveTimer;            // Measure contiguous hovering time where the item has not been active
7909f464c52Smaya    ImGuiID                 ActiveId;                           // Active widget
7919f464c52Smaya    ImGuiID                 ActiveIdPreviousFrame;
7929f464c52Smaya    ImGuiID                 ActiveIdIsAlive;                    // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
7939f464c52Smaya    float                   ActiveIdTimer;
7949f464c52Smaya    bool                    ActiveIdIsJustActivated;            // Set at the time of activation for one frame
7959f464c52Smaya    bool                    ActiveIdAllowOverlap;               // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
7969f464c52Smaya    bool                    ActiveIdHasBeenPressed;             // 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.
7979f464c52Smaya    bool                    ActiveIdHasBeenEdited;              // Was the value associated to the widget Edited over the course of the Active state.
7989f464c52Smaya    bool                    ActiveIdPreviousFrameIsAlive;
7999f464c52Smaya    bool                    ActiveIdPreviousFrameHasBeenEdited;
8009f464c52Smaya    int                     ActiveIdAllowNavDirFlags;           // Active widget allows using directional navigation (e.g. can activate a button and move away from it)
8019f464c52Smaya    int                     ActiveIdBlockNavInputFlags;
8029f464c52Smaya    ImVec2                  ActiveIdClickOffset;                // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
8039f464c52Smaya    ImGuiWindow*            ActiveIdWindow;
8049f464c52Smaya    ImGuiWindow*            ActiveIdPreviousFrameWindow;
8059f464c52Smaya    ImGuiInputSource        ActiveIdSource;                     // Activating with mouse or nav (gamepad/keyboard)
8069f464c52Smaya    ImGuiID                 LastActiveId;                       // Store the last non-zero ActiveId, useful for animation.
8079f464c52Smaya    float                   LastActiveIdTimer;                  // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
8089f464c52Smaya    ImVec2                  LastValidMousePos;
8099f464c52Smaya    ImGuiWindow*            MovingWindow;                       // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
8109f464c52Smaya    ImVector<ImGuiColorMod> ColorModifiers;                     // Stack for PushStyleColor()/PopStyleColor()
8119f464c52Smaya    ImVector<ImGuiStyleMod> StyleModifiers;                     // Stack for PushStyleVar()/PopStyleVar()
8129f464c52Smaya    ImVector<ImFont*>       FontStack;                          // Stack for PushFont()/PopFont()
8139f464c52Smaya    ImVector<ImGuiPopupRef> OpenPopupStack;                     // Which popups are open (persistent)
8149f464c52Smaya    ImVector<ImGuiPopupRef> BeginPopupStack;                    // Which level of BeginPopup() we are in (reset every frame)
8159f464c52Smaya    ImGuiNextWindowData     NextWindowData;                     // Storage for SetNextWindow** functions
8169f464c52Smaya    bool                    NextTreeNodeOpenVal;                // Storage for SetNextTreeNode** functions
8179f464c52Smaya    ImGuiCond               NextTreeNodeOpenCond;
8189f464c52Smaya
8199f464c52Smaya    // Navigation data (for gamepad/keyboard)
8209f464c52Smaya    ImGuiWindow*            NavWindow;                          // Focused window for navigation. Could be called 'FocusWindow'
8219f464c52Smaya    ImGuiID                 NavId;                              // Focused item for navigation
8229f464c52Smaya    ImGuiID                 NavActivateId;                      // ~~ (g.ActiveId == 0) && IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0, also set when calling ActivateItem()
8239f464c52Smaya    ImGuiID                 NavActivateDownId;                  // ~~ IsNavInputDown(ImGuiNavInput_Activate) ? NavId : 0
8249f464c52Smaya    ImGuiID                 NavActivatePressedId;               // ~~ IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0
8259f464c52Smaya    ImGuiID                 NavInputId;                         // ~~ IsNavInputPressed(ImGuiNavInput_Input) ? NavId : 0
8269f464c52Smaya    ImGuiID                 NavJustTabbedId;                    // Just tabbed to this id.
8279f464c52Smaya    ImGuiID                 NavJustMovedToId;                   // Just navigated to this id (result of a successfully MoveRequest).
8289f464c52Smaya    ImGuiID                 NavJustMovedToSelectScopeId;        // Just navigated to this select scope id (result of a successfully MoveRequest).
8299f464c52Smaya    ImGuiID                 NavNextActivateId;                  // Set by ActivateItem(), queued until next frame.
8309f464c52Smaya    ImGuiInputSource        NavInputSource;                     // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard.
8319f464c52Smaya    ImRect                  NavScoringRectScreen;               // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring.
8329f464c52Smaya    int                     NavScoringCount;                    // Metrics for debugging
8339f464c52Smaya    ImGuiWindow*            NavWindowingTarget;                 // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed front-most.
8349f464c52Smaya    ImGuiWindow*            NavWindowingTargetAnim;             // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f
8359f464c52Smaya    ImGuiWindow*            NavWindowingList;
8369f464c52Smaya    float                   NavWindowingTimer;
8379f464c52Smaya    float                   NavWindowingHighlightAlpha;
8389f464c52Smaya    bool                    NavWindowingToggleLayer;
8399f464c52Smaya    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.
8409f464c52Smaya    int                     NavIdTabCounter;                    // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
8419f464c52Smaya    bool                    NavIdIsAlive;                       // Nav widget has been seen this frame ~~ NavRefRectRel is valid
8429f464c52Smaya    bool                    NavMousePosDirty;                   // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
8439f464c52Smaya    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)
8449f464c52Smaya    bool                    NavDisableMouseHover;               // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
8459f464c52Smaya    bool                    NavAnyRequest;                      // ~~ NavMoveRequest || NavInitRequest
8469f464c52Smaya    bool                    NavInitRequest;                     // Init request for appearing window to select first item
8479f464c52Smaya    bool                    NavInitRequestFromMove;
8489f464c52Smaya    ImGuiID                 NavInitResultId;
8499f464c52Smaya    ImRect                  NavInitResultRectRel;
8509f464c52Smaya    bool                    NavMoveFromClampedRefRect;          // Set by manual scrolling, if we scroll to a point where NavId isn't visible we reset navigation from visible items
8519f464c52Smaya    bool                    NavMoveRequest;                     // Move request for this frame
8529f464c52Smaya    ImGuiNavMoveFlags       NavMoveRequestFlags;
8539f464c52Smaya    ImGuiNavForward         NavMoveRequestForward;              // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu)
8549f464c52Smaya    ImGuiDir                NavMoveDir, NavMoveDirLast;         // Direction of the move request (left/right/up/down), direction of the previous move request
8559f464c52Smaya    ImGuiDir                NavMoveClipDir;
8569f464c52Smaya    ImGuiNavMoveResult      NavMoveResultLocal;                 // Best move request candidate within NavWindow
8579f464c52Smaya    ImGuiNavMoveResult      NavMoveResultLocalVisibleSet;       // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
8589f464c52Smaya    ImGuiNavMoveResult      NavMoveResultOther;                 // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
8599f464c52Smaya
8609f464c52Smaya    // Render
8619f464c52Smaya    ImDrawData              DrawData;                           // Main ImDrawData instance to pass render information to the user
8629f464c52Smaya    ImDrawDataBuilder       DrawDataBuilder;
8639f464c52Smaya    float                   DimBgRatio;                         // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
8649f464c52Smaya    ImDrawList              OverlayDrawList;                    // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays
8659f464c52Smaya    ImGuiMouseCursor        MouseCursor;
8669f464c52Smaya
8679f464c52Smaya    // Drag and Drop
8689f464c52Smaya    bool                    DragDropActive;
8699f464c52Smaya    bool                    DragDropWithinSourceOrTarget;
8709f464c52Smaya    ImGuiDragDropFlags      DragDropSourceFlags;
8719f464c52Smaya    int                     DragDropSourceFrameCount;
8729f464c52Smaya    int                     DragDropMouseButton;
8739f464c52Smaya    ImGuiPayload            DragDropPayload;
8749f464c52Smaya    ImRect                  DragDropTargetRect;
8759f464c52Smaya    ImGuiID                 DragDropTargetId;
8769f464c52Smaya    ImGuiDragDropFlags      DragDropAcceptFlags;
8779f464c52Smaya    float                   DragDropAcceptIdCurrRectSurface;    // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
8789f464c52Smaya    ImGuiID                 DragDropAcceptIdCurr;               // Target item id (set at the time of accepting the payload)
8799f464c52Smaya    ImGuiID                 DragDropAcceptIdPrev;               // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
8809f464c52Smaya    int                     DragDropAcceptFrameCount;           // Last time a target expressed a desire to accept the source
8819f464c52Smaya    ImVector<unsigned char> DragDropPayloadBufHeap;             // We don't expose the ImVector<> directly
8829f464c52Smaya    unsigned char           DragDropPayloadBufLocal[8];         // Local buffer for small payloads
8839f464c52Smaya
8849f464c52Smaya    // Tab bars
8859f464c52Smaya    ImPool<ImGuiTabBar>     TabBars;
8869f464c52Smaya    ImVector<ImGuiTabBar*>  CurrentTabBar;
8879f464c52Smaya    ImVector<ImGuiTabBarSortItem>   TabSortByWidthBuffer;
8889f464c52Smaya
8899f464c52Smaya    // Widget state
8909f464c52Smaya    ImGuiInputTextState     InputTextState;
8919f464c52Smaya    ImFont                  InputTextPasswordFont;
8929f464c52Smaya    ImGuiID                 ScalarAsInputTextId;                // Temporary text input when CTRL+clicking on a slider, etc.
8939f464c52Smaya    ImGuiColorEditFlags     ColorEditOptions;                   // Store user options for color edit widgets
8949f464c52Smaya    ImVec4                  ColorPickerRef;
8959f464c52Smaya    bool                    DragCurrentAccumDirty;
8969f464c52Smaya    float                   DragCurrentAccum;                   // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
8979f464c52Smaya    float                   DragSpeedDefaultRatio;              // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
8989f464c52Smaya    ImVec2                  ScrollbarClickDeltaToGrabCenter;    // Distance between mouse and center of grab box, normalized in parent space. Use storage?
8999f464c52Smaya    int                     TooltipOverrideCount;
9009f464c52Smaya    ImVector<char>          PrivateClipboard;                   // If no custom clipboard handler is defined
9019f464c52Smaya
9029f464c52Smaya    // Range-Select/Multi-Select
9039f464c52Smaya    // [This is unused in this branch, but left here to facilitate merging/syncing multiple branches]
9049f464c52Smaya    ImGuiID                 MultiSelectScopeId;
9059f464c52Smaya
9069f464c52Smaya    // Platform support
9079f464c52Smaya    ImVec2                  PlatformImePos;                     // Cursor position request & last passed to the OS Input Method Editor
9089f464c52Smaya    ImVec2                  PlatformImeLastPos;
9099f464c52Smaya
9109f464c52Smaya    // Settings
9119f464c52Smaya    bool                           SettingsLoaded;
9129f464c52Smaya    float                          SettingsDirtyTimer;          // Save .ini Settings to memory when time reaches zero
9139f464c52Smaya    ImGuiTextBuffer                SettingsIniData;             // In memory .ini settings
9149f464c52Smaya    ImVector<ImGuiSettingsHandler> SettingsHandlers;            // List of .ini settings handlers
9159f464c52Smaya    ImVector<ImGuiWindowSettings>  SettingsWindows;             // ImGuiWindow .ini settings entries (parsed from the last loaded .ini file and maintained on saving)
9169f464c52Smaya
9179f464c52Smaya    // Logging
9189f464c52Smaya    bool                    LogEnabled;
9199f464c52Smaya    FILE*                   LogFile;                            // If != NULL log to stdout/ file
9209f464c52Smaya    ImGuiTextBuffer         LogClipboard;                       // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
9219f464c52Smaya    int                     LogStartDepth;
9229f464c52Smaya    int                     LogAutoExpandMaxDepth;
9239f464c52Smaya
9249f464c52Smaya    // Misc
9259f464c52Smaya    float                   FramerateSecPerFrame[120];          // Calculate estimate of framerate for user over the last 2 seconds.
9269f464c52Smaya    int                     FramerateSecPerFrameIdx;
9279f464c52Smaya    float                   FramerateSecPerFrameAccum;
9289f464c52Smaya    int                     WantCaptureMouseNextFrame;          // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags
9299f464c52Smaya    int                     WantCaptureKeyboardNextFrame;
9309f464c52Smaya    int                     WantTextInputNextFrame;
9319f464c52Smaya    char                    TempBuffer[1024*3+1];               // Temporary text buffer
9329f464c52Smaya
9339f464c52Smaya    ImGuiContext(ImFontAtlas* shared_font_atlas) : OverlayDrawList(NULL)
9349f464c52Smaya    {
9359f464c52Smaya        Initialized = false;
9369f464c52Smaya        FrameScopeActive = FrameScopePushedImplicitWindow = false;
9379f464c52Smaya        Font = NULL;
9389f464c52Smaya        FontSize = FontBaseSize = 0.0f;
9399f464c52Smaya        FontAtlasOwnedByContext = shared_font_atlas ? false : true;
9409f464c52Smaya        IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
9419f464c52Smaya
9429f464c52Smaya        Time = 0.0f;
9439f464c52Smaya        FrameCount = 0;
9449f464c52Smaya        FrameCountEnded = FrameCountRendered = -1;
9459f464c52Smaya        WindowsActiveCount = 0;
9469f464c52Smaya        CurrentWindow = NULL;
9479f464c52Smaya        HoveredWindow = NULL;
9489f464c52Smaya        HoveredRootWindow = NULL;
9499f464c52Smaya        HoveredId = 0;
9509f464c52Smaya        HoveredIdAllowOverlap = false;
9519f464c52Smaya        HoveredIdPreviousFrame = 0;
9529f464c52Smaya        HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
9539f464c52Smaya        ActiveId = 0;
9549f464c52Smaya        ActiveIdPreviousFrame = 0;
9559f464c52Smaya        ActiveIdIsAlive = 0;
9569f464c52Smaya        ActiveIdTimer = 0.0f;
9579f464c52Smaya        ActiveIdIsJustActivated = false;
9589f464c52Smaya        ActiveIdAllowOverlap = false;
9599f464c52Smaya        ActiveIdHasBeenPressed = false;
9609f464c52Smaya        ActiveIdHasBeenEdited = false;
9619f464c52Smaya        ActiveIdPreviousFrameIsAlive = false;
9629f464c52Smaya        ActiveIdPreviousFrameHasBeenEdited = false;
9639f464c52Smaya        ActiveIdAllowNavDirFlags = 0x00;
9649f464c52Smaya        ActiveIdBlockNavInputFlags = 0x00;
9659f464c52Smaya        ActiveIdClickOffset = ImVec2(-1,-1);
9669f464c52Smaya        ActiveIdWindow = ActiveIdPreviousFrameWindow = NULL;
9679f464c52Smaya        ActiveIdSource = ImGuiInputSource_None;
9689f464c52Smaya        LastActiveId = 0;
9699f464c52Smaya        LastActiveIdTimer = 0.0f;
9709f464c52Smaya        LastValidMousePos = ImVec2(0.0f, 0.0f);
9719f464c52Smaya        MovingWindow = NULL;
9729f464c52Smaya        NextTreeNodeOpenVal = false;
9739f464c52Smaya        NextTreeNodeOpenCond = 0;
9749f464c52Smaya
9759f464c52Smaya        NavWindow = NULL;
9769f464c52Smaya        NavId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
9779f464c52Smaya        NavJustTabbedId = NavJustMovedToId = NavJustMovedToSelectScopeId = NavNextActivateId = 0;
9789f464c52Smaya        NavInputSource = ImGuiInputSource_None;
9799f464c52Smaya        NavScoringRectScreen = ImRect();
9809f464c52Smaya        NavScoringCount = 0;
9819f464c52Smaya        NavWindowingTarget = NavWindowingTargetAnim = NavWindowingList = NULL;
9829f464c52Smaya        NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
9839f464c52Smaya        NavWindowingToggleLayer = false;
9849f464c52Smaya        NavLayer = ImGuiNavLayer_Main;
9859f464c52Smaya        NavIdTabCounter = INT_MAX;
9869f464c52Smaya        NavIdIsAlive = false;
9879f464c52Smaya        NavMousePosDirty = false;
9889f464c52Smaya        NavDisableHighlight = true;
9899f464c52Smaya        NavDisableMouseHover = false;
9909f464c52Smaya        NavAnyRequest = false;
9919f464c52Smaya        NavInitRequest = false;
9929f464c52Smaya        NavInitRequestFromMove = false;
9939f464c52Smaya        NavInitResultId = 0;
9949f464c52Smaya        NavMoveFromClampedRefRect = false;
9959f464c52Smaya        NavMoveRequest = false;
9969f464c52Smaya        NavMoveRequestFlags = 0;
9979f464c52Smaya        NavMoveRequestForward = ImGuiNavForward_None;
9989f464c52Smaya        NavMoveDir = NavMoveDirLast = NavMoveClipDir = ImGuiDir_None;
9999f464c52Smaya
10009f464c52Smaya        DimBgRatio = 0.0f;
10019f464c52Smaya        OverlayDrawList._Data = &DrawListSharedData;
10029f464c52Smaya        OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
10039f464c52Smaya        MouseCursor = ImGuiMouseCursor_Arrow;
10049f464c52Smaya
10059f464c52Smaya        DragDropActive = DragDropWithinSourceOrTarget = false;
10069f464c52Smaya        DragDropSourceFlags = 0;
10079f464c52Smaya        DragDropSourceFrameCount = -1;
10089f464c52Smaya        DragDropMouseButton = -1;
10099f464c52Smaya        DragDropTargetId = 0;
10109f464c52Smaya        DragDropAcceptFlags = 0;
10119f464c52Smaya        DragDropAcceptIdCurrRectSurface = 0.0f;
10129f464c52Smaya        DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
10139f464c52Smaya        DragDropAcceptFrameCount = -1;
10149f464c52Smaya        memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal));
10159f464c52Smaya
10169f464c52Smaya        ScalarAsInputTextId = 0;
10179f464c52Smaya        ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
10189f464c52Smaya        DragCurrentAccumDirty = false;
10199f464c52Smaya        DragCurrentAccum = 0.0f;
10209f464c52Smaya        DragSpeedDefaultRatio = 1.0f / 100.0f;
10219f464c52Smaya        ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
10229f464c52Smaya        TooltipOverrideCount = 0;
10239f464c52Smaya
10249f464c52Smaya        MultiSelectScopeId = 0;
10259f464c52Smaya
10269f464c52Smaya        PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX);
10279f464c52Smaya
10289f464c52Smaya        SettingsLoaded = false;
10299f464c52Smaya        SettingsDirtyTimer = 0.0f;
10309f464c52Smaya
10319f464c52Smaya        LogEnabled = false;
10329f464c52Smaya        LogFile = NULL;
10339f464c52Smaya        LogStartDepth = 0;
10349f464c52Smaya        LogAutoExpandMaxDepth = 2;
10359f464c52Smaya
10369f464c52Smaya        memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
10379f464c52Smaya        FramerateSecPerFrameIdx = 0;
10389f464c52Smaya        FramerateSecPerFrameAccum = 0.0f;
10399f464c52Smaya        WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
10409f464c52Smaya        memset(TempBuffer, 0, sizeof(TempBuffer));
10419f464c52Smaya    }
10429f464c52Smaya};
10439f464c52Smaya
10449f464c52Smaya//-----------------------------------------------------------------------------
10459f464c52Smaya// ImGuiWindow
10469f464c52Smaya//-----------------------------------------------------------------------------
10479f464c52Smaya
10489f464c52Smaya// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
10499f464c52Smaya// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered.
10509f464c52Smayastruct IMGUI_API ImGuiWindowTempData
10519f464c52Smaya{
10529f464c52Smaya    ImVec2                  CursorPos;
10539f464c52Smaya    ImVec2                  CursorPosPrevLine;
10549f464c52Smaya    ImVec2                  CursorStartPos;         // Initial position in client area with padding
10559f464c52Smaya    ImVec2                  CursorMaxPos;           // Used to implicitly calculate the size of our contents, always growing during the frame. Turned into window->SizeContents at the beginning of next frame
10569f464c52Smaya    ImVec2                  CurrentLineSize;
10579f464c52Smaya    float                   CurrentLineTextBaseOffset;
10589f464c52Smaya    ImVec2                  PrevLineSize;
10599f464c52Smaya    float                   PrevLineTextBaseOffset;
10609f464c52Smaya    float                   LogLinePosY;
10619f464c52Smaya    int                     TreeDepth;
10629f464c52Smaya    ImU32                   TreeDepthMayJumpToParentOnPop; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31
10639f464c52Smaya    ImGuiID                 LastItemId;
10649f464c52Smaya    ImGuiItemStatusFlags    LastItemStatusFlags;
10659f464c52Smaya    ImRect                  LastItemRect;           // Interaction rect
10669f464c52Smaya    ImRect                  LastItemDisplayRect;    // End-user display rect (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect)
10679f464c52Smaya    ImGuiNavLayer           NavLayerCurrent;        // Current layer, 0..31 (we currently only use 0..1)
10689f464c52Smaya    int                     NavLayerCurrentMask;    // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping.
10699f464c52Smaya    int                     NavLayerActiveMask;     // Which layer have been written to (result from previous frame)
10709f464c52Smaya    int                     NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame)
10719f464c52Smaya    bool                    NavHideHighlightOneFrame;
10729f464c52Smaya    bool                    NavHasScroll;           // Set when scrolling can be used (ScrollMax > 0.0f)
10739f464c52Smaya    bool                    MenuBarAppending;       // FIXME: Remove this
10749f464c52Smaya    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.
10759f464c52Smaya    ImVector<ImGuiWindow*>  ChildWindows;
10769f464c52Smaya    ImGuiStorage*           StateStorage;
10779f464c52Smaya    ImGuiLayoutType         LayoutType;
10789f464c52Smaya    ImGuiLayoutType         ParentLayoutType;       // Layout type of parent window at the time of Begin()
10799f464c52Smaya
10809f464c52Smaya    // 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.
10819f464c52Smaya    ImGuiItemFlags          ItemFlags;              // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
10829f464c52Smaya    float                   ItemWidth;              // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
10839f464c52Smaya    float                   TextWrapPos;            // == TextWrapPosStack.back() [empty == -1.0f]
10849f464c52Smaya    ImVector<ImGuiItemFlags>ItemFlagsStack;
10859f464c52Smaya    ImVector<float>         ItemWidthStack;
10869f464c52Smaya    ImVector<float>         TextWrapPosStack;
10879f464c52Smaya    ImVector<ImGuiGroupData>GroupStack;
10889f464c52Smaya    short                   StackSizesBackup[6];    // Store size of various stacks for asserting
10899f464c52Smaya
10909f464c52Smaya    ImVec1                  Indent;                 // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
10919f464c52Smaya    ImVec1                  GroupOffset;
10929f464c52Smaya    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.
10939f464c52Smaya    ImGuiColumnsSet*        ColumnsSet;             // Current columns set
10949f464c52Smaya
10959f464c52Smaya    ImGuiWindowTempData()
10969f464c52Smaya    {
10979f464c52Smaya        CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
10989f464c52Smaya        CurrentLineSize = PrevLineSize = ImVec2(0.0f, 0.0f);
10999f464c52Smaya        CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
11009f464c52Smaya        LogLinePosY = -1.0f;
11019f464c52Smaya        TreeDepth = 0;
11029f464c52Smaya        TreeDepthMayJumpToParentOnPop = 0x00;
11039f464c52Smaya        LastItemId = 0;
11049f464c52Smaya        LastItemStatusFlags = 0;
11059f464c52Smaya        LastItemRect = LastItemDisplayRect = ImRect();
11069f464c52Smaya        NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
11079f464c52Smaya        NavLayerCurrent = ImGuiNavLayer_Main;
11089f464c52Smaya        NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
11099f464c52Smaya        NavHideHighlightOneFrame = false;
11109f464c52Smaya        NavHasScroll = false;
11119f464c52Smaya        MenuBarAppending = false;
11129f464c52Smaya        MenuBarOffset = ImVec2(0.0f, 0.0f);
11139f464c52Smaya        StateStorage = NULL;
11149f464c52Smaya        LayoutType = ParentLayoutType = ImGuiLayoutType_Vertical;
11159f464c52Smaya        ItemWidth = 0.0f;
11169f464c52Smaya        ItemFlags = ImGuiItemFlags_Default_;
11179f464c52Smaya        TextWrapPos = -1.0f;
11189f464c52Smaya        memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
11199f464c52Smaya
11209f464c52Smaya        Indent = ImVec1(0.0f);
11219f464c52Smaya        GroupOffset = ImVec1(0.0f);
11229f464c52Smaya        ColumnsOffset = ImVec1(0.0f);
11239f464c52Smaya        ColumnsSet = NULL;
11249f464c52Smaya    }
11259f464c52Smaya};
11269f464c52Smaya
11279f464c52Smaya// Storage for one window
11289f464c52Smayastruct IMGUI_API ImGuiWindow
11299f464c52Smaya{
11309f464c52Smaya    char*                   Name;
11319f464c52Smaya    ImGuiID                 ID;                                 // == ImHash(Name)
11329f464c52Smaya    ImGuiWindowFlags        Flags;                              // See enum ImGuiWindowFlags_
11339f464c52Smaya    ImVec2                  Pos;                                // Position (always rounded-up to nearest pixel)
11349f464c52Smaya    ImVec2                  Size;                               // Current size (==SizeFull or collapsed title bar size)
11359f464c52Smaya    ImVec2                  SizeFull;                           // Size when non collapsed
11369f464c52Smaya    ImVec2                  SizeFullAtLastBegin;                // Copy of SizeFull at the end of Begin. This is the reference value we'll use on the next frame to decide if we need scrollbars.
11379f464c52Smaya    ImVec2                  SizeContents;                       // Size of contents (== extents reach of the drawing cursor) from previous frame. Include decoration, window title, border, menu, etc.
11389f464c52Smaya    ImVec2                  SizeContentsExplicit;               // Size of contents explicitly set by the user via SetNextWindowContentSize()
11399f464c52Smaya    ImVec2                  WindowPadding;                      // Window padding at the time of begin.
11409f464c52Smaya    float                   WindowRounding;                     // Window rounding at the time of begin.
11419f464c52Smaya    float                   WindowBorderSize;                   // Window border size at the time of begin.
11429f464c52Smaya    int                     NameBufLen;                         // Size of buffer storing Name. May be larger than strlen(Name)!
11439f464c52Smaya    ImGuiID                 MoveId;                             // == window->GetID("#MOVE")
11449f464c52Smaya    ImGuiID                 ChildId;                            // ID of corresponding item in parent window (for navigation to return from child window to parent window)
11459f464c52Smaya    ImVec2                  Scroll;
11469f464c52Smaya    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)
11479f464c52Smaya    ImVec2                  ScrollTargetCenterRatio;            // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
11489f464c52Smaya    ImVec2                  ScrollbarSizes;                     // Size taken by scrollbars on each axis
11499f464c52Smaya    bool                    ScrollbarX, ScrollbarY;
11509f464c52Smaya    bool                    Active;                             // Set to true on Begin(), unless Collapsed
11519f464c52Smaya    bool                    WasActive;
11529f464c52Smaya    bool                    WriteAccessed;                      // Set to true when any widget access the current window
11539f464c52Smaya    bool                    Collapsed;                          // Set when collapsing window to become only title-bar
11549f464c52Smaya    bool                    WantCollapseToggle;
11559f464c52Smaya    bool                    SkipItems;                          // Set when items can safely be all clipped (e.g. window not visible or collapsed)
11569f464c52Smaya    bool                    Appearing;                          // Set during the frame where the window is appearing (or re-appearing)
11579f464c52Smaya    bool                    Hidden;                             // Do not display (== (HiddenFramesForResize > 0) ||
11589f464c52Smaya    bool                    HasCloseButton;                     // Set when the window has a close button (p_open != NULL)
11599f464c52Smaya    signed char             ResizeBorderHeld;                   // Current border being held for resize (-1: none, otherwise 0-3)
11609f464c52Smaya    short                   BeginCount;                         // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
11619f464c52Smaya    short                   BeginOrderWithinParent;             // Order within immediate parent window, if we are a child window. Otherwise 0.
11629f464c52Smaya    short                   BeginOrderWithinContext;            // Order within entire imgui context. This is mostly used for debugging submission order related issues.
11639f464c52Smaya    ImGuiID                 PopupId;                            // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
11649f464c52Smaya    int                     AutoFitFramesX, AutoFitFramesY;
11659f464c52Smaya    bool                    AutoFitOnlyGrows;
11669f464c52Smaya    int                     AutoFitChildAxises;
11679f464c52Smaya    ImGuiDir                AutoPosLastDirection;
11689f464c52Smaya    int                     HiddenFramesRegular;                // Hide the window for N frames
11699f464c52Smaya    int                     HiddenFramesForResize;              // Hide the window for N frames while allowing items to be submitted so we can measure their size
11709f464c52Smaya    ImGuiCond               SetWindowPosAllowFlags;             // store acceptable condition flags for SetNextWindowPos() use.
11719f464c52Smaya    ImGuiCond               SetWindowSizeAllowFlags;            // store acceptable condition flags for SetNextWindowSize() use.
11729f464c52Smaya    ImGuiCond               SetWindowCollapsedAllowFlags;       // store acceptable condition flags for SetNextWindowCollapsed() use.
11739f464c52Smaya    ImVec2                  SetWindowPosVal;                    // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
11749f464c52Smaya    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.
11759f464c52Smaya
11769f464c52Smaya    ImGuiWindowTempData     DC;                                 // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name.
11779f464c52Smaya    ImVector<ImGuiID>       IDStack;                            // ID stack. ID are hashes seeded with the value at the top of the stack
11789f464c52Smaya    ImRect                  ClipRect;                           // Current clipping rectangle. = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
11799f464c52Smaya    ImRect                  OuterRectClipped;                   // = WindowRect just after setup in Begin(). == window->Rect() for root window.
11809f464c52Smaya    ImRect                  InnerMainRect, InnerClipRect;
11819f464c52Smaya    ImRect                  ContentsRegionRect;                 // FIXME: This is currently confusing/misleading. Maximum visible content position ~~ Pos + (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
11829f464c52Smaya    int                     LastFrameActive;                    // Last frame number the window was Active.
11839f464c52Smaya    float                   ItemWidthDefault;
11849f464c52Smaya    ImGuiMenuColumns        MenuColumns;                        // Simplified columns storage for menu items
11859f464c52Smaya    ImGuiStorage            StateStorage;
11869f464c52Smaya    ImVector<ImGuiColumnsSet> ColumnsStorage;
11879f464c52Smaya    float                   FontWindowScale;                    // User scale multiplier per-window
11889f464c52Smaya    int                     SettingsIdx;                        // Index into SettingsWindow[] (indices are always valid as we only grow the array from the back)
11899f464c52Smaya
11909f464c52Smaya    ImDrawList*             DrawList;                           // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
11919f464c52Smaya    ImDrawList              DrawListInst;
11929f464c52Smaya    ImGuiWindow*            ParentWindow;                       // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
11939f464c52Smaya    ImGuiWindow*            RootWindow;                         // Point to ourself or first ancestor that is not a child window.
11949f464c52Smaya    ImGuiWindow*            RootWindowForTitleBarHighlight;     // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
11959f464c52Smaya    ImGuiWindow*            RootWindowForNav;                   // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
11969f464c52Smaya
11979f464c52Smaya    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.)
11989f464c52Smaya    ImGuiID                 NavLastIds[ImGuiNavLayer_COUNT];    // Last known NavId for this window, per layer (0/1)
11999f464c52Smaya    ImRect                  NavRectRel[ImGuiNavLayer_COUNT];    // Reference rectangle, in window relative space
12009f464c52Smaya
12019f464c52Smaya    // Navigation / Focus
12029f464c52Smaya    // FIXME-NAV: Merge all this with the new Nav system, at least the request variables should be moved to ImGuiContext
12039f464c52Smaya    int                     FocusIdxAllCounter;                 // Start at -1 and increase as assigned via FocusItemRegister()
12049f464c52Smaya    int                     FocusIdxTabCounter;                 // (same, but only count widgets which you can Tab through)
12059f464c52Smaya    int                     FocusIdxAllRequestCurrent;          // Item being requested for focus
12069f464c52Smaya    int                     FocusIdxTabRequestCurrent;          // Tab-able item being requested for focus
12079f464c52Smaya    int                     FocusIdxAllRequestNext;             // Item being requested for focus, for next update (relies on layout to be stable between the frame pressing TAB and the next frame)
12089f464c52Smaya    int                     FocusIdxTabRequestNext;             // "
12099f464c52Smaya
12109f464c52Smayapublic:
12119f464c52Smaya    ImGuiWindow(ImGuiContext* context, const char* name);
12129f464c52Smaya    ~ImGuiWindow();
12139f464c52Smaya
12149f464c52Smaya    ImGuiID     GetID(const char* str, const char* str_end = NULL);
12159f464c52Smaya    ImGuiID     GetID(const void* ptr);
12169f464c52Smaya    ImGuiID     GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
12179f464c52Smaya    ImGuiID     GetIDNoKeepAlive(const void* ptr);
12189f464c52Smaya    ImGuiID     GetIDFromRectangle(const ImRect& r_abs);
12199f464c52Smaya
12209f464c52Smaya    // We don't use g.FontSize because the window may be != g.CurrentWidow.
12219f464c52Smaya    ImRect      Rect() const                            { return ImRect(Pos.x, Pos.y, Pos.x+Size.x, Pos.y+Size.y); }
12229f464c52Smaya    float       CalcFontSize() const                    { return GImGui->FontBaseSize * FontWindowScale; }
12239f464c52Smaya    float       TitleBarHeight() const                  { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; }
12249f464c52Smaya    ImRect      TitleBarRect() const                    { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
12259f464c52Smaya    float       MenuBarHeight() const                   { return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
12269f464c52Smaya    ImRect      MenuBarRect() const                     { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
12279f464c52Smaya};
12289f464c52Smaya
12299f464c52Smaya// 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.
12309f464c52Smayastruct ImGuiItemHoveredDataBackup
12319f464c52Smaya{
12329f464c52Smaya    ImGuiID                 LastItemId;
12339f464c52Smaya    ImGuiItemStatusFlags    LastItemStatusFlags;
12349f464c52Smaya    ImRect                  LastItemRect;
12359f464c52Smaya    ImRect                  LastItemDisplayRect;
12369f464c52Smaya
12379f464c52Smaya    ImGuiItemHoveredDataBackup() { Backup(); }
12389f464c52Smaya    void Backup()           { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; }
12399f464c52Smaya    void Restore() const    { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; }
12409f464c52Smaya};
12419f464c52Smaya
12429f464c52Smaya//-----------------------------------------------------------------------------
12439f464c52Smaya// Tab bar, tab item
12449f464c52Smaya//-----------------------------------------------------------------------------
12459f464c52Smaya
12469f464c52Smayaenum ImGuiTabBarFlagsPrivate_
12479f464c52Smaya{
12489f464c52Smaya    ImGuiTabBarFlags_DockNode                   = 1 << 20,  // Part of a dock node
12499f464c52Smaya    ImGuiTabBarFlags_IsFocused                  = 1 << 21,
12509f464c52Smaya    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
12519f464c52Smaya};
12529f464c52Smaya
12539f464c52Smayaenum ImGuiTabItemFlagsPrivate_
12549f464c52Smaya{
12559f464c52Smaya    ImGuiTabItemFlags_NoCloseButton             = 1 << 20   // Store whether p_open is set or not, which we need to recompute WidthContents during layout.
12569f464c52Smaya};
12579f464c52Smaya
12589f464c52Smaya// Storage for one active tab item (sizeof() 26~32 bytes)
12599f464c52Smayastruct ImGuiTabItem
12609f464c52Smaya{
12619f464c52Smaya    ImGuiID             ID;
12629f464c52Smaya    ImGuiTabItemFlags   Flags;
12639f464c52Smaya    int                 LastFrameVisible;
12649f464c52Smaya    int                 LastFrameSelected;      // This allows us to infer an ordered list of the last activated tabs with little maintenance
12659f464c52Smaya    int                 NameOffset;             // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
12669f464c52Smaya    float               Offset;                 // Position relative to beginning of tab
12679f464c52Smaya    float               Width;                  // Width currently displayed
12689f464c52Smaya    float               WidthContents;          // Width of actual contents, stored during BeginTabItem() call
12699f464c52Smaya
12709f464c52Smaya    ImGuiTabItem()      { ID = Flags = 0; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = WidthContents = 0.0f; }
12719f464c52Smaya};
12729f464c52Smaya
12739f464c52Smaya// Storage for a tab bar (sizeof() 92~96 bytes)
12749f464c52Smayastruct ImGuiTabBar
12759f464c52Smaya{
12769f464c52Smaya    ImVector<ImGuiTabItem> Tabs;
12779f464c52Smaya    ImGuiID             ID;                     // Zero for tab-bars used by docking
12789f464c52Smaya    ImGuiID             SelectedTabId;          // Selected tab
12799f464c52Smaya    ImGuiID             NextSelectedTabId;
12809f464c52Smaya    ImGuiID             VisibleTabId;           // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview)
12819f464c52Smaya    int                 CurrFrameVisible;
12829f464c52Smaya    int                 PrevFrameVisible;
12839f464c52Smaya    ImRect              BarRect;
12849f464c52Smaya    float               ContentsHeight;
12859f464c52Smaya    float               OffsetMax;              // Distance from BarRect.Min.x, locked during layout
12869f464c52Smaya    float               OffsetNextTab;          // Distance from BarRect.Min.x, incremented with each BeginTabItem() call, not used if ImGuiTabBarFlags_Reorderable if set.
12879f464c52Smaya    float               ScrollingAnim;
12889f464c52Smaya    float               ScrollingTarget;
12899f464c52Smaya    ImGuiTabBarFlags    Flags;
12909f464c52Smaya    ImGuiID             ReorderRequestTabId;
12919f464c52Smaya    int                 ReorderRequestDir;
12929f464c52Smaya    bool                WantLayout;
12939f464c52Smaya    bool                VisibleTabWasSubmitted;
12949f464c52Smaya    short               LastTabItemIdx;         // For BeginTabItem()/EndTabItem()
12959f464c52Smaya    ImVec2              FramePadding;           // style.FramePadding locked at the time of BeginTabBar()
12969f464c52Smaya    ImGuiTextBuffer     TabsNames;              // For non-docking tab bar we re-append names in a contiguous buffer.
12979f464c52Smaya
12989f464c52Smaya    ImGuiTabBar();
12999f464c52Smaya    int                 GetTabOrder(const ImGuiTabItem* tab) const  { return Tabs.index_from_ptr(tab); }
13009f464c52Smaya    const char*         GetTabName(const ImGuiTabItem* tab) const
13019f464c52Smaya    {
13029f464c52Smaya        IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size);
13039f464c52Smaya        return TabsNames.Buf.Data + tab->NameOffset;
13049f464c52Smaya    }
13059f464c52Smaya};
13069f464c52Smaya
13079f464c52Smaya//-----------------------------------------------------------------------------
13089f464c52Smaya// Internal API
13099f464c52Smaya// No guarantee of forward compatibility here.
13109f464c52Smaya//-----------------------------------------------------------------------------
13119f464c52Smaya
13129f464c52Smayanamespace ImGui
13139f464c52Smaya{
13149f464c52Smaya    // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
13159f464c52Smaya    // If this ever crash because g.CurrentWindow is NULL it means that either
13169f464c52Smaya    // - ImGui::NewFrame() has never been called, which is illegal.
13179f464c52Smaya    // - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
13189f464c52Smaya    inline    ImGuiWindow*  GetCurrentWindowRead()      { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
13199f464c52Smaya    inline    ImGuiWindow*  GetCurrentWindow()          { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
13209f464c52Smaya    IMGUI_API ImGuiWindow*  FindWindowByID(ImGuiID id);
13219f464c52Smaya    IMGUI_API ImGuiWindow*  FindWindowByName(const char* name);
13229f464c52Smaya    IMGUI_API void          FocusWindow(ImGuiWindow* window);
13239f464c52Smaya    IMGUI_API void          FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window);
13249f464c52Smaya    IMGUI_API void          BringWindowToFocusFront(ImGuiWindow* window);
13259f464c52Smaya    IMGUI_API void          BringWindowToDisplayFront(ImGuiWindow* window);
13269f464c52Smaya    IMGUI_API void          BringWindowToDisplayBack(ImGuiWindow* window);
13279f464c52Smaya    IMGUI_API void          UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
13289f464c52Smaya    IMGUI_API ImVec2        CalcWindowExpectedSize(ImGuiWindow* window);
13299f464c52Smaya    IMGUI_API bool          IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
13309f464c52Smaya    IMGUI_API bool          IsWindowNavFocusable(ImGuiWindow* window);
13319f464c52Smaya    IMGUI_API void          SetWindowScrollX(ImGuiWindow* window, float new_scroll_x);
13329f464c52Smaya    IMGUI_API void          SetWindowScrollY(ImGuiWindow* window, float new_scroll_y);
13339f464c52Smaya    IMGUI_API float         GetWindowScrollMaxX(ImGuiWindow* window);
13349f464c52Smaya    IMGUI_API float         GetWindowScrollMaxY(ImGuiWindow* window);
13359f464c52Smaya    IMGUI_API ImRect        GetWindowAllowedExtentRect(ImGuiWindow* window);
13369f464c52Smaya    IMGUI_API void          SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond);
13379f464c52Smaya    IMGUI_API void          SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond);
13389f464c52Smaya    IMGUI_API void          SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond);
13399f464c52Smaya
13409f464c52Smaya    IMGUI_API void          SetCurrentFont(ImFont* font);
13419f464c52Smaya    inline ImFont*          GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
13429f464c52Smaya
13439f464c52Smaya    // Init
13449f464c52Smaya    IMGUI_API void          Initialize(ImGuiContext* context);
13459f464c52Smaya    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().
13469f464c52Smaya
13479f464c52Smaya    // NewFrame
13489f464c52Smaya    IMGUI_API void          UpdateHoveredWindowAndCaptureFlags();
13499f464c52Smaya    IMGUI_API void          StartMouseMovingWindow(ImGuiWindow* window);
13509f464c52Smaya    IMGUI_API void          UpdateMouseMovingWindowNewFrame();
13519f464c52Smaya    IMGUI_API void          UpdateMouseMovingWindowEndFrame();
13529f464c52Smaya
13539f464c52Smaya    // Settings
13549f464c52Smaya    IMGUI_API void                  MarkIniSettingsDirty();
13559f464c52Smaya    IMGUI_API void                  MarkIniSettingsDirty(ImGuiWindow* window);
13569f464c52Smaya    IMGUI_API ImGuiWindowSettings*  CreateNewWindowSettings(const char* name);
13579f464c52Smaya    IMGUI_API ImGuiWindowSettings*  FindWindowSettings(ImGuiID id);
13589f464c52Smaya    IMGUI_API ImGuiWindowSettings*  FindOrCreateWindowSettings(const char* name);
13599f464c52Smaya    IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
13609f464c52Smaya
13619f464c52Smaya    // Basic Accessors
13629f464c52Smaya    inline ImGuiID          GetItemID()     { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; }
13639f464c52Smaya    inline ImGuiID          GetActiveID()   { ImGuiContext& g = *GImGui; return g.ActiveId; }
13649f464c52Smaya    inline ImGuiID          GetFocusID()    { ImGuiContext& g = *GImGui; return g.NavId; }
13659f464c52Smaya    IMGUI_API void          SetActiveID(ImGuiID id, ImGuiWindow* window);
13669f464c52Smaya    IMGUI_API void          SetFocusID(ImGuiID id, ImGuiWindow* window);
13679f464c52Smaya    IMGUI_API void          ClearActiveID();
13689f464c52Smaya    IMGUI_API ImGuiID       GetHoveredID();
13699f464c52Smaya    IMGUI_API void          SetHoveredID(ImGuiID id);
13709f464c52Smaya    IMGUI_API void          KeepAliveID(ImGuiID id);
13719f464c52Smaya    IMGUI_API void          MarkItemEdited(ImGuiID id);
13729f464c52Smaya
13739f464c52Smaya    // Basic Helpers for widget code
13749f464c52Smaya    IMGUI_API void          ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
13759f464c52Smaya    IMGUI_API void          ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
13769f464c52Smaya    IMGUI_API bool          ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
13779f464c52Smaya    IMGUI_API bool          ItemHoverable(const ImRect& bb, ImGuiID id);
13789f464c52Smaya    IMGUI_API bool          IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
13799f464c52Smaya    IMGUI_API bool          FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop = true);   // Return true if focus is requested
13809f464c52Smaya    IMGUI_API void          FocusableItemUnregister(ImGuiWindow* window);
13819f464c52Smaya    IMGUI_API ImVec2        CalcItemSize(ImVec2 size, float default_x, float default_y);
13829f464c52Smaya    IMGUI_API float         CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
13839f464c52Smaya    IMGUI_API void          PushMultiItemsWidths(int components, float width_full = 0.0f);
13849f464c52Smaya    IMGUI_API void          PushItemFlag(ImGuiItemFlags option, bool enabled);
13859f464c52Smaya    IMGUI_API void          PopItemFlag();
13869f464c52Smaya
13879f464c52Smaya    // Popups, Modals, Tooltips
13889f464c52Smaya    IMGUI_API void          OpenPopupEx(ImGuiID id);
13899f464c52Smaya    IMGUI_API void          ClosePopupToLevel(int remaining, bool apply_focus_to_window_under);
13909f464c52Smaya    IMGUI_API void          ClosePopupsOverWindow(ImGuiWindow* ref_window);
13919f464c52Smaya    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!
13929f464c52Smaya    IMGUI_API bool          BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
13939f464c52Smaya    IMGUI_API void          BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
13949f464c52Smaya    IMGUI_API ImGuiWindow*  GetFrontMostPopupModal();
13959f464c52Smaya    IMGUI_API ImVec2        FindBestWindowPosForPopup(ImGuiWindow* window);
13969f464c52Smaya    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);
13979f464c52Smaya
13989f464c52Smaya    // Navigation
13999f464c52Smaya    IMGUI_API void          NavInitWindow(ImGuiWindow* window, bool force_reinit);
14009f464c52Smaya    IMGUI_API bool          NavMoveRequestButNoResultYet();
14019f464c52Smaya    IMGUI_API void          NavMoveRequestCancel();
14029f464c52Smaya    IMGUI_API void          NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags);
14039f464c52Smaya    IMGUI_API void          NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
14049f464c52Smaya    IMGUI_API float         GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode);
14059f464c52Smaya    IMGUI_API ImVec2        GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f);
14069f464c52Smaya    IMGUI_API int           CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
14079f464c52Smaya    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.
14089f464c52Smaya    IMGUI_API void          SetNavID(ImGuiID id, int nav_layer);
14099f464c52Smaya    IMGUI_API void          SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_rel);
14109f464c52Smaya
14119f464c52Smaya    // Inputs
14129f464c52Smaya    inline bool             IsKeyPressedMap(ImGuiKey key, bool repeat = true)           { const int key_index = GImGui->IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; }
14139f464c52Smaya    inline bool             IsNavInputDown(ImGuiNavInput n)                             { return GImGui->IO.NavInputs[n] > 0.0f; }
14149f464c52Smaya    inline bool             IsNavInputPressed(ImGuiNavInput n, ImGuiInputReadMode mode) { return GetNavInputAmount(n, mode) > 0.0f; }
14159f464c52Smaya    inline bool             IsNavInputPressedAnyOfTwo(ImGuiNavInput n1, ImGuiNavInput n2, ImGuiInputReadMode mode) { return (GetNavInputAmount(n1, mode) + GetNavInputAmount(n2, mode)) > 0.0f; }
14169f464c52Smaya
14179f464c52Smaya    // Drag and Drop
14189f464c52Smaya    IMGUI_API bool          BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
14199f464c52Smaya    IMGUI_API void          ClearDragDrop();
14209f464c52Smaya    IMGUI_API bool          IsDragDropPayloadBeingAccepted();
14219f464c52Smaya
14229f464c52Smaya    // New Columns API (FIXME-WIP)
14239f464c52Smaya    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().
14249f464c52Smaya    IMGUI_API void          EndColumns();                                                             // close columns
14259f464c52Smaya    IMGUI_API void          PushColumnClipRect(int column_index = -1);
14269f464c52Smaya
14279f464c52Smaya    // Tab Bars
14289f464c52Smaya    IMGUI_API bool          BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags);
14299f464c52Smaya    IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
14309f464c52Smaya    IMGUI_API void          TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
14319f464c52Smaya    IMGUI_API void          TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
14329f464c52Smaya    IMGUI_API void          TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir);
14339f464c52Smaya    IMGUI_API bool          TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags);
14349f464c52Smaya    IMGUI_API ImVec2        TabItemCalcSize(const char* label, bool has_close_button);
14359f464c52Smaya    IMGUI_API void          TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col);
14369f464c52Smaya    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);
14379f464c52Smaya
14389f464c52Smaya    // Render helpers
14399f464c52Smaya    // 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.
14409f464c52Smaya    // NB: All position are in absolute pixels coordinates (we are never using window coordinates internally)
14419f464c52Smaya    IMGUI_API void          RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
14429f464c52Smaya    IMGUI_API void          RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
14439f464c52Smaya    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);
14449f464c52Smaya    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);
14459f464c52Smaya    IMGUI_API void          RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
14469f464c52Smaya    IMGUI_API void          RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
14479f464c52Smaya    IMGUI_API void          RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
14489f464c52Smaya    IMGUI_API void          RenderArrow(ImVec2 pos, ImGuiDir dir, float scale = 1.0f);
14499f464c52Smaya    IMGUI_API void          RenderBullet(ImVec2 pos);
14509f464c52Smaya    IMGUI_API void          RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
14519f464c52Smaya    IMGUI_API void          RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
14529f464c52Smaya    IMGUI_API const char*   FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
14539f464c52Smaya    IMGUI_API void          LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
14549f464c52Smaya
14559f464c52Smaya    // Render helpers (those functions don't access any ImGui state!)
14569f464c52Smaya    IMGUI_API void          RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor = ImGuiMouseCursor_Arrow);
14579f464c52Smaya    IMGUI_API void          RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
14589f464c52Smaya    IMGUI_API void          RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
14599f464c52Smaya    IMGUI_API void          RenderPixelEllipsis(ImDrawList* draw_list, ImVec2 pos, int count, ImU32 col);
14609f464c52Smaya
14619f464c52Smaya    // Widgets
14629f464c52Smaya    IMGUI_API bool          ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0);
14639f464c52Smaya    IMGUI_API bool          CloseButton(ImGuiID id, const ImVec2& pos, float radius);
14649f464c52Smaya    IMGUI_API bool          CollapseButton(ImGuiID id, const ImVec2& pos);
14659f464c52Smaya    IMGUI_API bool          ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags);
14669f464c52Smaya    IMGUI_API void          Scrollbar(ImGuiLayoutType direction);
14679f464c52Smaya    IMGUI_API ImGuiID       GetScrollbarID(ImGuiLayoutType direction);
14689f464c52Smaya    IMGUI_API void          VerticalSeparator();        // Vertical separator, for menu bars (use current line height). Not exposed because it is misleading and it doesn't have an effect on regular layout.
14699f464c52Smaya
14709f464c52Smaya    // Widgets low-level behaviors
14719f464c52Smaya    IMGUI_API bool          ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
14729f464c52Smaya    IMGUI_API bool          DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power, ImGuiDragFlags flags);
14739f464c52Smaya    IMGUI_API bool          SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
14749f464c52Smaya    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);
14759f464c52Smaya    IMGUI_API bool          TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
14769f464c52Smaya    IMGUI_API bool          TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0);                     // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
14779f464c52Smaya    IMGUI_API void          TreePushRawID(ImGuiID id);
14789f464c52Smaya
14799f464c52Smaya    // Template functions are instantiated in imgui_widgets.cpp for a finite number of types.
14809f464c52Smaya    // 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).
14819f464c52Smaya    // e.g. " extern template IMGUI_API float RoundScalarWithFormatT<float, float>(const char* format, ImGuiDataType data_type, float v); "
14829f464c52Smaya    template<typename T, typename SIGNED_T, typename FLOAT_T>   IMGUI_API bool  DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, const T v_min, const T v_max, const char* format, float power, ImGuiDragFlags flags);
14839f464c52Smaya    template<typename T, typename SIGNED_T, typename FLOAT_T>   IMGUI_API bool  SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, const T v_min, const T v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb);
14849f464c52Smaya    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);
14859f464c52Smaya    template<typename T, typename SIGNED_T>                     IMGUI_API T     RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v);
14869f464c52Smaya
14879f464c52Smaya    // InputText
14889f464c52Smaya    IMGUI_API bool          InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
14899f464c52Smaya    IMGUI_API bool          InputScalarAsWidgetReplacement(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* data_ptr, const char* format);
14909f464c52Smaya
14919f464c52Smaya    // Color
14929f464c52Smaya    IMGUI_API void          ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
14939f464c52Smaya    IMGUI_API void          ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
14949f464c52Smaya    IMGUI_API void          ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags);
14959f464c52Smaya
14969f464c52Smaya    // Plot
14979f464c52Smaya    IMGUI_API void          PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size);
14989f464c52Smaya
14999f464c52Smaya    // Shade functions (write over already created vertices)
15009f464c52Smaya    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);
15019f464c52Smaya    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);
15029f464c52Smaya
15039f464c52Smaya} // namespace ImGui
15049f464c52Smaya
15059f464c52Smaya// ImFontAtlas internals
15069f464c52SmayaIMGUI_API bool              ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
15079f464c52SmayaIMGUI_API void              ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
15089f464c52SmayaIMGUI_API void              ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
15099f464c52SmayaIMGUI_API void              ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
15109f464c52SmayaIMGUI_API void              ImFontAtlasBuildFinish(ImFontAtlas* atlas);
15119f464c52SmayaIMGUI_API void              ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
15129f464c52SmayaIMGUI_API void              ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
15139f464c52Smaya
15149f464c52Smaya// Test engine hooks (imgui-test)
15159f464c52Smaya//#define IMGUI_ENABLE_TEST_ENGINE
15169f464c52Smaya#ifdef IMGUI_ENABLE_TEST_ENGINE
15179f464c52Smayaextern void                 ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx);
15189f464c52Smayaextern void                 ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx);
15199f464c52Smayaextern void                 ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
15209f464c52Smayaextern void                 ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags);
15219f464c52Smaya#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS)  ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS)   // Register status flags
15229f464c52Smaya#else
15239f464c52Smaya#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS)  do { } while (0)
15249f464c52Smaya#endif
15259f464c52Smaya
15269f464c52Smaya#ifdef __clang__
15279f464c52Smaya#pragma clang diagnostic pop
15289f464c52Smaya#endif
15299f464c52Smaya
15309f464c52Smaya#ifdef _MSC_VER
15319f464c52Smaya#pragma warning (pop)
15329f464c52Smaya#endif
1533