// THIS FILE HAS BEEN AUTO-GENERATED BY THE 'DEAR BINDINGS' GENERATOR.
// **DO NOT EDIT DIRECTLY**
// https://github.com/dearimgui/dear_bindings

// dear imgui, v1.92.5
struct ImVector_ImFontBakedPtr_t { int Size; int Capacity; ImFontBaked** Data; };  // Instantiation of ImVector<ImFontBaked*>
struct ImVector_ImFontAtlasPtr_t { int Size; int Capacity; ImFontAtlas** Data; };  // Instantiation of ImVector<ImFontAtlas*>
// (internal structures/api)

// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.

/*

Index of this file:

// [SECTION] Header mess
// [SECTION] Forward declarations
// [SECTION] Context pointer
// [SECTION] STB libraries includes
// [SECTION] Macros
// [SECTION] Generic helpers
// [SECTION] ImDrawList support
// [SECTION] Style support
// [SECTION] Data types support
// [SECTION] Widgets support: flags, enums, data structures
// [SECTION] Popup support
// [SECTION] Inputs support
// [SECTION] Clipper support
// [SECTION] Navigation support
// [SECTION] Typing-select support
// [SECTION] Columns support
// [SECTION] Box-select support
// [SECTION] Multi-select support
// [SECTION] Docking support
// [SECTION] Viewport support
// [SECTION] Settings support
// [SECTION] Localization support
// [SECTION] Error handling, State recovery support
// [SECTION] Metrics, Debug tools
// [SECTION] Generic context hooks
// [SECTION] ImGuiContext (main imgui context)
// [SECTION] ImGuiWindowTempData, ImGuiWindow
// [SECTION] Tab bar, Tab item support
// [SECTION] Table support
// [SECTION] ImGui internal API
// [SECTION] ImFontLoader
// [SECTION] ImFontAtlas internal API
// [SECTION] Test Engine specific hooks (imgui_test_engine)

*/

#pragma once

#ifdef __cplusplus
extern "C"
{
#endif
#ifndef IMGUI_DISABLE
//-----------------------------------------------------------------------------
// [SECTION] Header mess
//-----------------------------------------------------------------------------

#ifndef IMGUI_VERSION
#include "imgui.h"
#endif // #ifndef IMGUI_VERSION
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
// Enable SSE intrinsics if available
#if (defined __SSE__ || defined __x86_64__ || defined _M_X64 ||(defined(_M_IX86_FP)&&(_M_IX86_FP >= 1)))&&!defined(IMGUI_DISABLE_SSE)
#define IMGUI_ENABLE_SSE
#include <immintrin.h>
#if (defined __AVX__ || defined __SSE4_2__)
#define IMGUI_ENABLE_SSE4_2
#include <nmmintrin.h>
#endif // #if (defined __AVX__ || defined __SSE4_2__)
#endif // #if (defined __SSE__ || defined __x86_64__ || defined _M_X64 ||(defined(_M_IX86_FP)&&(_M_IX86_FP >= 1)))&&!defined(IMGUI_DISABLE_SSE)
// Emscripten has partial SSE 4.2 support where _mm_crc32_u32 is not available. See https://emscripten.org/docs/porting/simd.html#id11 and #8213
#if defined(IMGUI_ENABLE_SSE4_2)&&!defined(IMGUI_USE_LEGACY_CRC32_ADLER)&&!defined(__EMSCRIPTEN__)
#define IMGUI_ENABLE_SSE4_2_CRC
#endif // #if defined(IMGUI_ENABLE_SSE4_2)&&!defined(IMGUI_USE_LEGACY_CRC32_ADLER)&&!defined(__EMSCRIPTEN__)
// Visual Studio warnings
#ifdef _MSC_VER
#pragma warning (push)
#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)
#pragma warning (disable: 26495)     // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
#pragma warning (disable: 26812)     // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
#if defined(_MSC_VER)&& _MSC_VER >= 1922
#pragma warning (disable: 5054)      // operator '|': deprecated between enumerations of different types
#endif// MSVC 2019 16.2 or later
#endif // #ifdef _MSC_VER
// Clang/GCC warnings with -Weverything
#if defined(__clang__)
#pragma clang diagnostic push
#if __has_warning("-Wunknown-warning-option")
#pragma clang diagnostic ignored "-Wunknown-warning-option"          // warning: unknown warning group 'xxx'
#endif // #if __has_warning("-Wunknown-warning-option")
#pragma clang diagnostic ignored "-Wunknown-pragmas"                  // warning: unknown warning group 'xxx'
#pragma clang diagnostic ignored "-Wfloat-equal"                      // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants ok, for ImFloor()
#pragma clang diagnostic ignored "-Wold-style-cast"                   // warning: use of old-style cast
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"    // warning: zero as null pointer constant
#pragma clang diagnostic ignored "-Wdouble-promotion"                 // warning: implicit conversion from 'float' to 'double' when passing argument to function
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"    // warning: implicit conversion from 'xxx' to 'float' may lose precision
#pragma clang diagnostic ignored "-Wmissing-noreturn"                 // warning: function 'xxx' could be declared with attribute 'noreturn'
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"  // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"              // warning: 'xxx' is an unsafe pointer used for buffer access
#pragma clang diagnostic ignored "-Wnontrivial-memaccess"             // warning: first argument in call to 'memset' is a pointer to non-trivially copyable type
#else
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"                           // warning: unknown option after '#pragma GCC diagnostic' kind
#pragma GCC diagnostic ignored "-Wfloat-equal"                       // warning: comparing floating-point with '==' or '!=' is unsafe
#pragma GCC diagnostic ignored "-Wclass-memaccess"                   // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"   // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
#endif // #if defined(__GNUC__)
#endif // #if defined(__clang__)
// In 1.89.4, we moved the implementation of "courtesy maths operators" from imgui_internal.h in imgui.h
// As they are frequently requested, we do not want to encourage to many people using imgui_internal.h
#if defined(IMGUI_DEFINE_MATH_OPERATORS)&&!defined(IMGUI_DEFINE_MATH_OPERATORS_IMPLEMENTED)
#error Please '#define IMGUI_DEFINE_MATH_OPERATORS' _BEFORE_ including imgui.h!
#endif // #if defined(IMGUI_DEFINE_MATH_OPERATORS)&&!defined(IMGUI_DEFINE_MATH_OPERATORS_IMPLEMENTED)
// Legacy defines
#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
#endif// Renamed in 1.74
#ifdef IMGUI_DISABLE_MATH_FUNCTIONS
#error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
#endif// Renamed in 1.74
// Enable stb_truetype by default unless FreeType is enabled.
// You can compile with both by defining both IMGUI_ENABLE_FREETYPE and IMGUI_ENABLE_STB_TRUETYPE together.
#ifndef IMGUI_ENABLE_FREETYPE
#define IMGUI_ENABLE_STB_TRUETYPE
#endif // #ifndef IMGUI_ENABLE_FREETYPE
//-----------------------------------------------------------------------------
// [SECTION] Forward declarations
// Auto-generated forward declarations for C header
typedef struct ImVector_ImFontBakedPtr_t ImVector_ImFontBakedPtr;
typedef struct ImVector_ImFontAtlasPtr_t ImVector_ImFontAtlasPtr;
typedef struct ImVec1_t ImVec1;
typedef struct ImVec2i_t ImVec2i;
typedef struct ImVec2ih_t ImVec2ih;
typedef struct ImSpan_ImGuiTableColumn_t ImSpan_ImGuiTableColumn;
typedef struct ImSpan_ImGuiTableColumnIdx_t ImSpan_ImGuiTableColumnIdx;
typedef struct ImSpan_ImGuiTableCellData_t ImSpan_ImGuiTableCellData;
typedef struct ImStableVector_ImFontBaked_32_t ImStableVector_ImFontBaked_32;
typedef struct ImFontStackData_t ImFontStackData;
typedef struct ImVector_ImFontStackData_t ImVector_ImFontStackData;
typedef struct ImGuiDataTypeStorage_t ImGuiDataTypeStorage;
typedef struct ImChunkStream_ImGuiTableSettings_t ImChunkStream_ImGuiTableSettings;
typedef struct ImChunkStream_ImGuiWindowSettings_t ImChunkStream_ImGuiWindowSettings;
typedef struct ImVector_unsigned_char_t ImVector_unsigned_char;
typedef struct ImVector_ImGuiWindowStackData_t ImVector_ImGuiWindowStackData;
typedef struct ImVector_ImGuiWindowPtr_t ImVector_ImGuiWindowPtr;
typedef struct ImVector_ImGuiViewportPPtr_t ImVector_ImGuiViewportPPtr;
typedef struct ImVector_ImGuiTreeNodeStackData_t ImVector_ImGuiTreeNodeStackData;
typedef struct ImVector_ImGuiTableTempData_t ImVector_ImGuiTableTempData;
typedef struct ImVector_ImGuiTableInstanceData_t ImVector_ImGuiTableInstanceData;
typedef struct ImVector_ImGuiTableHeaderData_t ImVector_ImGuiTableHeaderData;
typedef struct ImVector_ImGuiTableColumnSortSpecs_t ImVector_ImGuiTableColumnSortSpecs;
typedef struct ImVector_ImGuiTable_t ImVector_ImGuiTable;
typedef struct ImVector_ImGuiTabItem_t ImVector_ImGuiTabItem;
typedef struct ImVector_ImGuiTabBar_t ImVector_ImGuiTabBar;
typedef struct ImVector_ImGuiStyleMod_t ImVector_ImGuiStyleMod;
typedef struct ImVector_ImGuiStackLevelInfo_t ImVector_ImGuiStackLevelInfo;
typedef struct ImVector_ImGuiShrinkWidthItem_t ImVector_ImGuiShrinkWidthItem;
typedef struct ImVector_ImGuiSettingsHandler_t ImVector_ImGuiSettingsHandler;
typedef struct ImVector_ImGuiPtrOrIndex_t ImVector_ImGuiPtrOrIndex;
typedef struct ImVector_ImGuiPopupData_t ImVector_ImGuiPopupData;
typedef struct ImVector_ImGuiOldColumns_t ImVector_ImGuiOldColumns;
typedef struct ImVector_ImGuiOldColumnData_t ImVector_ImGuiOldColumnData;
typedef struct ImVector_ImGuiMultiSelectTempData_t ImVector_ImGuiMultiSelectTempData;
typedef struct ImVector_ImGuiMultiSelectState_t ImVector_ImGuiMultiSelectState;
typedef struct ImVector_ImGuiListClipperRange_t ImVector_ImGuiListClipperRange;
typedef struct ImVector_ImGuiListClipperData_t ImVector_ImGuiListClipperData;
typedef struct ImVector_ImGuiKeyRoutingData_t ImVector_ImGuiKeyRoutingData;
typedef struct ImVector_ImGuiItemFlags_t ImVector_ImGuiItemFlags;
typedef struct ImVector_ImGuiInputEvent_t ImVector_ImGuiInputEvent;
typedef struct ImVector_ImGuiID_t ImVector_ImGuiID;
typedef struct ImVector_ImGuiGroupData_t ImVector_ImGuiGroupData;
typedef struct ImVector_ImGuiFocusScopeData_t ImVector_ImGuiFocusScopeData;
typedef struct ImVector_ImGuiDockRequest_t ImVector_ImGuiDockRequest;
typedef struct ImVector_ImGuiDockNodeSettings_t ImVector_ImGuiDockNodeSettings;
typedef struct ImVector_ImGuiContextHook_t ImVector_ImGuiContextHook;
typedef struct ImVector_ImGuiColorMod_t ImVector_ImGuiColorMod;
typedef struct ImVector_const_charPtr_t ImVector_const_charPtr;
typedef struct ImVector_int_t ImVector_int;
typedef struct ImPool_ImGuiMultiSelectState_t ImPool_ImGuiMultiSelectState;
typedef struct ImPool_ImGuiTabBar_t ImPool_ImGuiTabBar;
typedef struct ImPool_ImGuiTable_t ImPool_ImGuiTable;
typedef struct ImGuiTextIndex_t ImGuiTextIndex;
typedef struct ImGuiComboPreviewData_t ImGuiComboPreviewData;
typedef struct ImGuiInputTextDeactivatedState_t ImGuiInputTextDeactivatedState;
typedef struct ImGuiWindowStackData_t ImGuiWindowStackData;
typedef struct ImGuiShrinkWidthItem_t ImGuiShrinkWidthItem;
typedef struct ImGuiPtrOrIndex_t ImGuiPtrOrIndex;
typedef struct ImGuiInputEventMousePos_t ImGuiInputEventMousePos;
typedef struct ImGuiInputEventMouseWheel_t ImGuiInputEventMouseWheel;
typedef struct ImGuiInputEventMouseButton_t ImGuiInputEventMouseButton;
typedef struct ImGuiInputEventMouseViewport_t ImGuiInputEventMouseViewport;
typedef struct ImGuiInputEventKey_t ImGuiInputEventKey;
typedef struct ImGuiInputEventText_t ImGuiInputEventText;
typedef struct ImGuiInputEventAppFocused_t ImGuiInputEventAppFocused;
typedef struct ImGuiInputEvent_t ImGuiInputEvent;
typedef struct ImGuiKeyRoutingData_t ImGuiKeyRoutingData;
typedef struct ImGuiKeyRoutingTable_t ImGuiKeyRoutingTable;
typedef struct ImGuiKeyOwnerData_t ImGuiKeyOwnerData;
typedef struct ImGuiListClipperRange_t ImGuiListClipperRange;
typedef struct ImGuiListClipperData_t ImGuiListClipperData;
typedef struct ImGuiFocusScopeData_t ImGuiFocusScopeData;
typedef struct ImGuiViewportP_t ImGuiViewportP;
typedef struct ImGuiDebugAllocEntry_t ImGuiDebugAllocEntry;
typedef struct ImGuiDebugAllocInfo_t ImGuiDebugAllocInfo;
typedef struct ImGuiStackLevelInfo_t ImGuiStackLevelInfo;
typedef struct ImGuiDebugItemPathQuery_t ImGuiDebugItemPathQuery;
typedef struct ImGuiIDStackTool_t ImGuiIDStackTool;
typedef struct ImGuiTableCellData_t ImGuiTableCellData;
typedef struct ImGuiTableColumnSettings_t ImGuiTableColumnSettings;
typedef struct ImVector_ImFontAtlasRectEntry_t ImVector_ImFontAtlasRectEntry;
typedef struct ImVector_stbrp_node_im_t ImVector_stbrp_node_im;
typedef struct stbrp_context_opaque_t stbrp_context_opaque;
// Table column indexing
typedef ImS16 ImGuiTableColumnIdx;
//-----------------------------------------------------------------------------

// Utilities
// (other types which are not forwarded declared are: ImBitArray<>, ImSpan<>, ImSpanAllocator<>, ImStableVector<>, ImPool<>, ImChunkStream<>)
typedef struct ImBitVector_t ImBitVector;  // Store 1-bit per value
typedef struct ImRect_t ImRect;            // An axis-aligned rectangle (2 points)

// ImDrawList/ImFontAtlas
typedef struct ImDrawDataBuilder_t ImDrawDataBuilder;                    // Helper to build a ImDrawData instance
typedef struct ImDrawListSharedData_t ImDrawListSharedData;              // Data shared between all ImDrawList instances
typedef struct ImFontAtlasBuilder_t ImFontAtlasBuilder;                  // Internal storage for incrementally packing and building a ImFontAtlas
typedef struct ImFontAtlasPostProcessData_t ImFontAtlasPostProcessData;  // Data available to potential texture post-processing functions
typedef struct ImFontAtlasRectEntry_t ImFontAtlasRectEntry;              // Packed rectangle lookup entry

// ImGui
typedef struct ImGuiBoxSelectState_t ImGuiBoxSelectState;                    // Box-selection state (currently used by multi-selection, could potentially be used by others)
typedef struct ImGuiColorMod_t ImGuiColorMod;                                // Stacked color modifier, backup of modified data so we can restore it
typedef struct ImGuiContext_t ImGuiContext;                                  // Main Dear ImGui context
typedef struct ImGuiContextHook_t ImGuiContextHook;                          // Hook for extensions like ImGuiTestEngine
typedef struct ImGuiDataTypeInfo_t ImGuiDataTypeInfo;                        // Type information associated to a ImGuiDataType enum
typedef struct ImGuiDeactivatedItemData_t ImGuiDeactivatedItemData;          // Data for IsItemDeactivated()/IsItemDeactivatedAfterEdit() function.
typedef struct ImGuiDockContext_t ImGuiDockContext;                          // Docking system context
typedef struct ImGuiDockRequest_t ImGuiDockRequest;                          // Docking system dock/undock queued request
typedef struct ImGuiDockNode_t ImGuiDockNode;                                // Docking system node (hold a list of Windows OR two child dock nodes)
typedef struct ImGuiDockNodeSettings_t ImGuiDockNodeSettings;                // Storage for a dock node in .ini file (we preserve those even if the associated dock node isn't active during the session)
typedef struct ImGuiErrorRecoveryState_t ImGuiErrorRecoveryState;            // Storage of stack sizes for error handling and recovery
typedef struct ImGuiGroupData_t ImGuiGroupData;                              // Stacked storage data for BeginGroup()/EndGroup()
typedef struct ImGuiInputTextState_t ImGuiInputTextState;                    // Internal state of the currently focused/edited text input box
typedef struct ImGuiInputTextDeactivateData_t ImGuiInputTextDeactivateData;  // Short term storage to backup text of a deactivating InputText() while another is stealing active id
typedef struct ImGuiLastItemData_t ImGuiLastItemData;                        // Status storage for last submitted items
typedef struct ImGuiLocEntry_t ImGuiLocEntry;                                // A localization entry.
typedef struct ImGuiMenuColumns_t ImGuiMenuColumns;                          // Simple column measurement, currently used for MenuItem() only
typedef struct ImGuiMultiSelectState_t ImGuiMultiSelectState;                // Multi-selection persistent state (for focused selection).
typedef struct ImGuiMultiSelectTempData_t ImGuiMultiSelectTempData;          // Multi-selection temporary state (while traversing).
typedef struct ImGuiNavItemData_t ImGuiNavItemData;                          // Result of a keyboard/gamepad directional navigation move query result
typedef struct ImGuiMetricsConfig_t ImGuiMetricsConfig;                      // Storage for ShowMetricsWindow() and DebugNodeXXX() functions
typedef struct ImGuiNextWindowData_t ImGuiNextWindowData;                    // Storage for SetNextWindow** functions
typedef struct ImGuiNextItemData_t ImGuiNextItemData;                        // Storage for SetNextItem** functions
typedef struct ImGuiOldColumnData_t ImGuiOldColumnData;                      // Storage data for a single column for legacy Columns() api
typedef struct ImGuiOldColumns_t ImGuiOldColumns;                            // Storage data for a columns set for legacy Columns() api
typedef struct ImGuiPopupData_t ImGuiPopupData;                              // Storage for current popup stack
typedef struct ImGuiSettingsHandler_t ImGuiSettingsHandler;                  // Storage for one type registered in the .ini file
typedef struct ImGuiStyleMod_t ImGuiStyleMod;                                // Stacked style modifier, backup of modified data so we can restore it
typedef struct ImGuiStyleVarInfo_t ImGuiStyleVarInfo;                        // Style variable information (e.g. to access style variables from an enum)
typedef struct ImGuiTabBar_t ImGuiTabBar;                                    // Storage for a tab bar
typedef struct ImGuiTabItem_t ImGuiTabItem;                                  // Storage for a tab item (within a tab bar)
typedef struct ImGuiTable_t ImGuiTable;                                      // Storage for a table
typedef struct ImGuiTableHeaderData_t ImGuiTableHeaderData;                  // Storage for TableAngledHeadersRow()
typedef struct ImGuiTableColumn_t ImGuiTableColumn;                          // Storage for one column of a table
typedef struct ImGuiTableInstanceData_t ImGuiTableInstanceData;              // Storage for one instance of a same table
typedef struct ImGuiTableTempData_t ImGuiTableTempData;                      // Temporary storage for one table (one per table in the stack), shared between tables.
typedef struct ImGuiTableSettings_t ImGuiTableSettings;                      // Storage for a table .ini settings
typedef struct ImGuiTableColumnsSettings_t ImGuiTableColumnsSettings;        // Storage for a column .ini settings
typedef struct ImGuiTreeNodeStackData_t ImGuiTreeNodeStackData;              // Temporary storage for TreeNode().
typedef struct ImGuiTypingSelectState_t ImGuiTypingSelectState;              // Storage for GetTypingSelectRequest()
typedef struct ImGuiTypingSelectRequest_t ImGuiTypingSelectRequest;          // Storage for GetTypingSelectRequest() (aimed to be public)
typedef struct ImGuiWindow_t ImGuiWindow;                                    // Storage for one window
typedef struct ImGuiWindowDockStyle_t ImGuiWindowDockStyle;                  // Storage for window-style data which needs to be stored for docking purpose
typedef struct ImGuiWindowTempData_t ImGuiWindowTempData;                    // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame, in practice we currently keep it for each window)
typedef struct ImGuiWindowSettings_t ImGuiWindowSettings;                    // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)

// Enumerations
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
typedef int ImGuiLocKey;         // -> enum ImGuiLocKey              // Enum: a localization entry for translation.
typedef int ImGuiDataAuthority;  // -> enum ImGuiDataAuthority_      // Enum: for storing the source authority (dock node vs window) of a field
typedef int ImGuiLayoutType;     // -> enum ImGuiLayoutType_         // Enum: Horizontal or vertical

// Flags
typedef int ImDrawTextFlags;            // -> enum ImDrawTextFlags_         // Flags: for ImTextCalcWordWrapPositionEx()
typedef int ImGuiActivateFlags;         // -> enum ImGuiActivateFlags_      // Flags: for navigation/focus function (will be for ActivateItem() later)
typedef int ImGuiDebugLogFlags;         // -> enum ImGuiDebugLogFlags_      // Flags: for ShowDebugLogWindow(), g.DebugLogFlags
typedef int ImGuiFocusRequestFlags;     // -> enum ImGuiFocusRequestFlags_  // Flags: for FocusWindow()
typedef int ImGuiItemStatusFlags;       // -> enum ImGuiItemStatusFlags_    // Flags: for g.LastItemData.StatusFlags
typedef int ImGuiOldColumnFlags;        // -> enum ImGuiOldColumnFlags_     // Flags: for BeginColumns()
typedef int ImGuiLogFlags;              // -> enum ImGuiLogFlags_           // Flags: for LogBegin() text capturing function
typedef int ImGuiNavRenderCursorFlags;  // -> enum ImGuiNavRenderCursorFlags_//Flags: for RenderNavCursor()
typedef int ImGuiNavMoveFlags;          // -> enum ImGuiNavMoveFlags_       // Flags: for navigation requests
typedef int ImGuiNextItemDataFlags;     // -> enum ImGuiNextItemDataFlags_  // Flags: for SetNextItemXXX() functions
typedef int ImGuiNextWindowDataFlags;   // -> enum ImGuiNextWindowDataFlags_// Flags: for SetNextWindowXXX() functions
typedef int ImGuiScrollFlags;           // -> enum ImGuiScrollFlags_        // Flags: for ScrollToItem() and navigation requests
typedef int ImGuiSeparatorFlags;        // -> enum ImGuiSeparatorFlags_     // Flags: for SeparatorEx()
typedef int ImGuiTextFlags;             // -> enum ImGuiTextFlags_          // Flags: for TextEx()
typedef int ImGuiTooltipFlags;          // -> enum ImGuiTooltipFlags_       // Flags: for BeginTooltipEx()
typedef int ImGuiTypingSelectFlags;     // -> enum ImGuiTypingSelectFlags_  // Flags: for GetTypingSelectRequest()
typedef int ImGuiWindowBgClickFlags;    // -> enum ImGuiWindowBgClickFlags_ // Flags: for overriding behavior of clicking on window background/void.
typedef int ImGuiWindowRefreshFlags;    // -> enum ImGuiWindowRefreshFlags_ // Flags: for SetNextWindowRefreshPolicy()

typedef ImU16 ImGuiTableDrawChannelIdx;

//-----------------------------------------------------------------------------
// [SECTION] Context pointer
// See implementation of this variable in imgui.cpp for comments and details.
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// [SECTION] Macros
//-----------------------------------------------------------------------------

// Internal Drag and Drop payload types. String starting with '_' are reserved for Dear ImGui.
#define IMGUI_PAYLOAD_TYPE_WINDOW       "_IMWINDOW"      // Payload == ImGuiWindow*

// Debug Printing Into TTY
// (since IMGUI_VERSION_NUM >= 18729: IMGUI_DEBUG_LOG was reworked into IMGUI_DEBUG_PRINTF (and removed framecount from it). If you were using a #define IMGUI_DEBUG_LOG please rename)
#ifndef IMGUI_DEBUG_PRINTF
#ifndef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
#define IMGUI_DEBUG_PRINTF(_FMT,...)    printf(_FMT, __VA_ARGS__)
#else
#define IMGUI_DEBUG_PRINTF(_FMT,...)    ((void)0)
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
#endif // #ifndef IMGUI_DEBUG_PRINTF
// Debug Logging for ShowDebugLogWindow(). This is designed for relatively rare events so please don't spam.
#define IMGUI_DEBUG_LOG_ERROR(...)      do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventError)       IMGUI_DEBUG_LOG(__VA_ARGS__); else g.DebugLogSkippedErrors++; } while (0)
#define IMGUI_DEBUG_LOG_ACTIVEID(...)   do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventActiveId)    IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_FOCUS(...)      do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventFocus)       IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_POPUP(...)      do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup)       IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_NAV(...)        do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventNav)         IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_SELECTION(...)  do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection)   IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_CLIPPER(...)    do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper)     IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_IO(...)         do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO)          IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_FONT(...)       do { ImGuiContext* g2 = GImGui; if (g2 && g2->DebugLogFlags & ImGuiDebugLogFlags_EventFont) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)  // Called from ImFontAtlas function which may operate without a context.
#define IMGUI_DEBUG_LOG_INPUTROUTING(...) do{if (g.DebugLogFlags & ImGuiDebugLogFlags_EventInputRouting)IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_DOCKING(...)    do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventDocking)     IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
#define IMGUI_DEBUG_LOG_VIEWPORT(...)   do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventViewport)    IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)

// Static Asserts
#define IM_STATIC_ASSERT(_COND)         static_assert(_COND, "")

// "Paranoid" Debug Asserts are meant to only be enabled during specific debugging/work, otherwise would slow down the code too much.
// We currently don't have many of those so the effect is currently negligible, but onward intent to add more aggressive ones in the code.
//#define IMGUI_DEBUG_PARANOID
#ifdef IMGUI_DEBUG_PARANOID
#define IM_ASSERT_PARANOID(_EXPR)       IM_ASSERT(_EXPR)
#else
#define IM_ASSERT_PARANOID(_EXPR)
#endif // #ifdef IMGUI_DEBUG_PARANOID
// Misc Macros
#define IM_PI                           3.14159265358979323846f
#ifdef _WIN32
#define IM_NEWLINE                      "\r\n"    // Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!)
#else
#define IM_NEWLINE                      "\n"
#endif // #ifdef _WIN32
#ifndef IM_TABSIZE
#define IM_TABSIZE                      (4)
#endif// Until we move this to runtime and/or add proper tab support, at least allow users to compile-time override
#define IM_MEMALIGN(_OFF,_ALIGN)        (((_OFF) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1))                           // Memory align e.g. IM_ALIGN(0,4)=0, IM_ALIGN(1,4)=4, IM_ALIGN(4,4)=4, IM_ALIGN(5,4)=8
#define IM_F32_TO_INT8_UNBOUND(_VAL)    ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f)))                   // Unsaturated, for display purpose
#define IM_F32_TO_INT8_SAT(_VAL)        ((int)(ImSaturate(_VAL) * 255.0f + 0.5f))                               // Saturated, always output 0..255
#define IM_TRUNC(_VAL)                  ((float)(int)(_VAL))                                                    // ImTrunc() is not inlined in MSVC debug builds
#define IM_ROUND(_VAL)                  ((float)(int)((_VAL) + 0.5f))                                           //
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
#define IM_FLOOR IM_TRUNC                // [OBSOLETE] Renamed in 1.90.0 (Sept 2023)
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
// Hint for branch prediction
#if (defined(__cplusplus)&&(__cplusplus >= 202002L))||(defined(_MSVC_LANG)&&(_MSVC_LANG >= 202002L))
#define IM_LIKELY   [[likely]]
#define IM_UNLIKELY [[unlikely]]
#else
#define IM_LIKELY
#define IM_UNLIKELY
#endif // #if (defined(__cplusplus)&&(__cplusplus >= 202002L))||(defined(_MSVC_LANG)&&(_MSVC_LANG >= 202002L))
// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall
#ifdef _MSC_VER
#define IMGUI_CDECL __cdecl
#else
#define IMGUI_CDECL
#endif // #ifdef _MSC_VER
// Warnings
#if defined(_MSC_VER)&&!defined(__clang__)
#define IM_MSVC_WARNING_SUPPRESS(XXXX)  __pragma(warning(suppress: XXXX))
#else
#define IM_MSVC_WARNING_SUPPRESS(XXXX)
#endif // #if defined(_MSC_VER)&&!defined(__clang__)
// Debug Tools
// Use 'Metrics/Debugger->Tools->Item Picker' to break into the call-stack of a specific item.
// This will call IM_DEBUG_BREAK() which you may redefine yourself. See https://github.com/scottt/debugbreak for more reference.
#ifndef IM_DEBUG_BREAK
#if defined(_MSC_VER)
#define IM_DEBUG_BREAK()    __debugbreak()
#else
#if defined(__clang__)
#define IM_DEBUG_BREAK()    __builtin_debugtrap()
#else
#if defined(__GNUC__)&&(defined(__i386__)|| defined(__x86_64__))
#define IM_DEBUG_BREAK()    __asm__ volatile("int3;nop")
#else
#if defined(__GNUC__)&& defined(__thumb__)
#define IM_DEBUG_BREAK()    __asm__ volatile(".inst 0xde01")
#else
#if defined(__GNUC__)&& defined(__arm__)&&!defined(__thumb__)
#define IM_DEBUG_BREAK()    __asm__ volatile(".inst 0xe7f001f0")
#else
#define IM_DEBUG_BREAK()    IM_ASSERT(0)     // It is expected that you define IM_DEBUG_BREAK() into something that will break nicely in a debugger!
#endif // #if defined(__GNUC__)&& defined(__arm__)&&!defined(__thumb__)
#endif // #if defined(__GNUC__)&& defined(__thumb__)
#endif // #if defined(__GNUC__)&&(defined(__i386__)|| defined(__x86_64__))
#endif // #if defined(__clang__)
#endif // #if defined(_MSC_VER)
#endif// #ifndef IM_DEBUG_BREAK
// Format specifiers, printing 64-bit hasn't been decently standardized...
// In a real application you should be using PRId64 and PRIu64 from <inttypes.h> (non-windows) and on Windows define them yourself.
#if defined(_MSC_VER)&&!defined(__clang__)
#define IM_PRId64   "I64d"
#define IM_PRIu64   "I64u"
#define IM_PRIX64   "I64X"
#else
#define IM_PRId64   "lld"
#define IM_PRIu64   "llu"
#define IM_PRIX64   "llX"
#endif // #if defined(_MSC_VER)&&!defined(__clang__)
#define IM_TEXTUREID_TO_U64(_TEXID) ((ImU64)(intptr_t)(_TEXID))

//-----------------------------------------------------------------------------
// [SECTION] Generic helpers
// Note that the ImXXX helpers functions are lower-level than ImGui functions.
// ImGui functions or the ImGui context are never called/used from other ImXXX functions.
//-----------------------------------------------------------------------------
// - Helpers: Hashing
// - Helpers: Sorting
// - Helpers: Bit manipulation
// - Helpers: String
// - Helpers: Formatting
// - Helpers: UTF-8 <> wchar conversions
// - Helpers: ImVec2/ImVec4 operators
// - Helpers: Maths
// - Helpers: Geometry
// - Helper: ImVec1
// - Helper: ImVec2ih
// - Helper: ImRect
// - Helper: ImBitArray
// - Helper: ImBitVector
// - Helper: ImSpan<>, ImSpanAllocator<>
// - Helper: ImStableVector<>
// - Helper: ImPool<>
// - Helper: ImChunkStream<>
// - Helper: ImGuiTextIndex
// - Helper: ImGuiStorage
//-----------------------------------------------------------------------------

// Helpers: Hashing
CIMGUI_API ImGuiID     cImHashData(const void* data, size_t data_size, ImGuiID seed /* = 0 */);
CIMGUI_API ImGuiID     cImHashStr(const char* data, size_t data_size /* = 0 */, ImGuiID seed /* = 0 */);
CIMGUI_API const char* cImHashSkipUncontributingPrefix(const char* label);

// Helpers: Color Blending
CIMGUI_API ImU32 cImAlphaBlendColors(ImU32 col_a, ImU32 col_b);

// Helpers: Bit manipulation
CIMGUI_API bool         cImIsPowerOfTwo(int v);
CIMGUI_API bool         cImIsPowerOfTwoImU64(ImU64 v);
CIMGUI_API int          cImUpperPowerOfTwo(int v);
CIMGUI_API unsigned int cImCountSetBits(unsigned int v);

// Helpers: String
#define ImStrlen strlen
#define ImMemchr memchr
CIMGUI_API int         cImStricmp(const char* str1, const char* str2);                      // Case insensitive compare.
CIMGUI_API int         cImStrnicmp(const char* str1, const char* str2, size_t count);       // Case insensitive compare to a certain count.
CIMGUI_API void        cImStrncpy(char* dst, const char* src, size_t count);                // Copy to a certain count and always zero terminate (strncpy doesn't).
CIMGUI_API char*       cImStrdup(const char* str);                                          // Duplicate a string.
CIMGUI_API void*       cImMemdup(const void* src, size_t size);                             // Duplicate a chunk of memory.
CIMGUI_API char*       cImStrdupcpy(char* dst, size_t* p_dst_size, const char* str);        // Copy in provided buffer, recreate buffer if needed.
CIMGUI_API const char* cImStrchrRange(const char* str_begin, const char* str_end, char c);  // Find first occurrence of 'c' in string range.
CIMGUI_API const char* cImStreolRange(const char* str, const char* str_end);                // End end-of-line
CIMGUI_API const char* cImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end); // Find a substring in a string range.
CIMGUI_API void        cImStrTrimBlanks(char* str);                                         // Remove leading and trailing blanks from a buffer.
CIMGUI_API const char* cImStrSkipBlank(const char* str);                                    // Find first non-blank character.
CIMGUI_API int         cImStrlenW(const ImWchar* str);                                      // Computer string length (ImWchar string)
CIMGUI_API const char* cImStrbol(const char* buf_mid_line, const char* buf_begin);          // Find beginning-of-line
IM_MSVC_RUNTIME_CHECKS_OFF
CIMGUI_API char        cImToUpper(char c);
CIMGUI_API bool        cImCharIsBlankA(char c);
CIMGUI_API bool        cImCharIsBlankW(unsigned int c);
CIMGUI_API bool        cImCharIsXdigitA(char c);
IM_MSVC_RUNTIME_CHECKS_RESTORE

// Helpers: Formatting
CIMGUI_API int         cImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
// Helpers: Formatting
CIMGUI_API int         cImFormatStringUnformatted(char* buf, size_t buf_size, const char* text);
CIMGUI_API int         cImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
CIMGUI_API void        cImFormatStringToTempBuffer(const char** out_buf, const char** out_buf_end, const char* fmt, ...) IM_FMTARGS(3);
CIMGUI_API void        cImFormatStringToTempBufferUnformatted(const char** out_buf, const char** out_buf_end, const char* text);
CIMGUI_API void        cImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end, const char* fmt, va_list args) IM_FMTLIST(3);
CIMGUI_API const char* cImParseFormatFindStart(const char* format);
CIMGUI_API const char* cImParseFormatFindEnd(const char* format);
CIMGUI_API const char* cImParseFormatTrimDecorations(const char* format, char* buf, size_t buf_size);
CIMGUI_API void        cImParseFormatSanitizeForPrinting(const char* fmt_in, char* fmt_out, size_t fmt_out_size);
CIMGUI_API const char* cImParseFormatSanitizeForScanning(const char* fmt_in, char* fmt_out, size_t fmt_out_size);
CIMGUI_API int         cImParseFormatPrecision(const char* format, int default_value);

// Helpers: UTF-8 <> wchar conversions
CIMGUI_API int         cImTextCharToUtf8(char out_buf[5], unsigned int c);                                                      // return output UTF-8 bytes count
CIMGUI_API int         cImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, const ImWchar* in_text_end);   // return output UTF-8 bytes count
CIMGUI_API int         cImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end);               // read one character. return input UTF-8 bytes count
CIMGUI_API int         cImTextStrFromUtf8(ImWchar* out_buf, int out_buf_size, const char* in_text, const char* in_text_end, const char** in_remaining /* = NULL */); // return input UTF-8 bytes count
CIMGUI_API int         cImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end);                                 // return number of UTF-8 code-points (NOT bytes count)
CIMGUI_API int         cImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end);                             // return number of bytes to express one char in UTF-8
CIMGUI_API int         cImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end);                        // return number of bytes to express string in UTF-8
CIMGUI_API const char* cImTextFindPreviousUtf8Codepoint(const char* in_text_start, const char* in_p);                           // return previous UTF-8 code-point.
CIMGUI_API const char* cImTextFindValidUtf8CodepointEnd(const char* in_text_start, const char* in_text_end, const char* in_p);  // return previous UTF-8 code-point if 'in_p' is not the end of a valid one.
CIMGUI_API int         cImTextCountLines(const char* in_text, const char* in_text_end);                                         // return number of lines taken by text. trailing carriage return doesn't count as an extra line.

// Helpers: High-level text functions (DO NOT USE!!! THIS IS A MINIMAL SUBSET OF LARGER UPCOMING CHANGES)
typedef enum
{
    ImDrawTextFlags_None           = 0,
    ImDrawTextFlags_CpuFineClip    = 1<<0,  // Must be == 1/true for legacy with 'bool cpu_fine_clip' arg to RenderText()
    ImDrawTextFlags_WrapKeepBlanks = 1<<1,
    ImDrawTextFlags_StopOnNewLine  = 1<<2,
} ImDrawTextFlags_;
CIMGUI_API ImVec2      cImFontCalcTextSizeEx(ImFont* font, float size, float max_width, float wrap_width, const char* text_begin, const char* text_end_display, const char* text_end, const char** out_remaining, ImVec2* out_offset, ImDrawTextFlags flags);
CIMGUI_API const char* cImFontCalcWordWrapPositionEx(ImFont* font, float size, const char* text, const char* text_end, float wrap_width, ImDrawTextFlags flags /* = 0 */);
CIMGUI_API const char* cImTextCalcWordWrapNextLineStart(const char* text, const char* text_end, ImDrawTextFlags flags /* = 0 */);  // trim trailing space and find beginning of next line

// Helpers: File System
#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
typedef void* ImFileHandle;
CIMGUI_API ImFileHandle cImFileOpen(const char*, const char*);
CIMGUI_API bool         cImFileClose(ImFileHandle);
CIMGUI_API ImU64        cImFileGetSize(ImFileHandle);
CIMGUI_API ImU64        cImFileRead(void*, ImU64, ImU64, ImFileHandle);
CIMGUI_API ImU64        cImFileWrite(const void*, ImU64, ImU64, ImFileHandle);
#endif // #ifdef IMGUI_DISABLE_FILE_FUNCTIONS
#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
typedef FILE* ImFileHandle;
CIMGUI_API ImFileHandle cImFileOpen(const char* filename, const char* mode);
CIMGUI_API bool         cImFileClose(ImFileHandle file);
CIMGUI_API ImU64        cImFileGetSize(ImFileHandle file);
CIMGUI_API ImU64        cImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
CIMGUI_API ImU64        cImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file);
#else
#define IMGUI_DISABLE_TTY_FUNCTIONS  // Can't use stdout, fflush if we are not using default file functions
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
CIMGUI_API void* cImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size /* = NULL */, int padding_bytes /* = 0 */);

// Helpers: Maths
IM_MSVC_RUNTIME_CHECKS_OFF
// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy)
#ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
#define ImFabs(X)           fabsf(X)
#define ImSqrt(X)           sqrtf(X)
#define ImFmod(X, Y)        fmodf((X), (Y))
#define ImCos(X)            cosf(X)
#define ImSin(X)            sinf(X)
#define ImAcos(X)           acosf(X)
#define ImAtan2(Y, X)       atan2f((Y), (X))
#define ImAtof(STR)         atof(STR)
#define ImCeil(X)           ceilf(X)
CIMGUI_API float  cImPow(float x, float y);          // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
CIMGUI_API double cImPowDouble(double x, double y);
CIMGUI_API float  cImLog(float x);                   // DragBehaviorT/SliderBehaviorT uses ImLog with either float/double and need the precision
CIMGUI_API double cImLogDouble(double x);
CIMGUI_API int    cImAbs(int x);
CIMGUI_API float  cImAbsFloat(float x);
CIMGUI_API double cImAbsDouble(double x);
CIMGUI_API float  cImSign(float x);                  // Sign operator - returns -1, 0 or 1 based on sign of argument
CIMGUI_API double cImSignDouble(double x);
#ifdef IMGUI_ENABLE_SSE
CIMGUI_API float cImRsqrt(float x);
#else
CIMGUI_API float cImRsqrtFloat(float x);
#endif // #ifdef IMGUI_ENABLE_SSE
CIMGUI_API double cImRsqrtDouble(double x);
#endif // #ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
// - Misc maths helpers
CIMGUI_API ImVec2 cImMin(ImVec2 lhs, ImVec2 rhs);
CIMGUI_API ImVec2 cImMax(ImVec2 lhs, ImVec2 rhs);
CIMGUI_API ImVec2 cImClamp(ImVec2 v, ImVec2 mn, ImVec2 mx);
CIMGUI_API ImVec2 cImLerp(ImVec2 a, ImVec2 b, float t);
CIMGUI_API ImVec2 cImLerpImVec2(ImVec2 a, ImVec2 b, ImVec2 t);
CIMGUI_API ImVec4 cImLerpImVec4(ImVec4 a, ImVec4 b, float t);
CIMGUI_API float  cImSaturate(float f);
CIMGUI_API float  cImLengthSqr(ImVec2 lhs);
CIMGUI_API float  cImLengthSqrImVec4(ImVec4 lhs);
CIMGUI_API float  cImInvLength(ImVec2 lhs, float fail_value);
CIMGUI_API float  cImTrunc(float f);
CIMGUI_API ImVec2 cImTruncImVec2(ImVec2 v);
CIMGUI_API float  cImFloor(float f);                                                     // Decent replacement for floorf()
CIMGUI_API ImVec2 cImFloorImVec2(ImVec2 v);
CIMGUI_API float  cImTrunc64(float f);
CIMGUI_API float  cImRound64(float f);
CIMGUI_API int    cImModPositive(int a, int b);
CIMGUI_API float  cImDot(ImVec2 a, ImVec2 b);
CIMGUI_API ImVec2 cImRotate(ImVec2 v, float cos_a, float sin_a);
CIMGUI_API float  cImLinearSweep(float current, float target, float speed);
CIMGUI_API float  cImLinearRemapClamp(float s0, float s1, float d0, float d1, float x);
CIMGUI_API ImVec2 cImMul(ImVec2 lhs, ImVec2 rhs);
CIMGUI_API bool   cImIsFloatAboveGuaranteedIntegerPrecision(float f);
CIMGUI_API float  cImExponentialMovingAverage(float avg, float sample, int n);
IM_MSVC_RUNTIME_CHECKS_RESTORE

// Helpers: Geometry
CIMGUI_API ImVec2 cImBezierCubicCalc(ImVec2 p1, ImVec2 p2, ImVec2 p3, ImVec2 p4, float t);
CIMGUI_API ImVec2 cImBezierCubicClosestPoint(ImVec2 p1, ImVec2 p2, ImVec2 p3, ImVec2 p4, ImVec2 p, int num_segments);              // For curves with explicit number of segments
CIMGUI_API ImVec2 cImBezierCubicClosestPointCasteljau(ImVec2 p1, ImVec2 p2, ImVec2 p3, ImVec2 p4, ImVec2 p, float tess_tol);       // For auto-tessellated curves you can use tess_tol = style.CurveTessellationTol
CIMGUI_API ImVec2 cImBezierQuadraticCalc(ImVec2 p1, ImVec2 p2, ImVec2 p3, float t);
CIMGUI_API ImVec2 cImLineClosestPoint(ImVec2 a, ImVec2 b, ImVec2 p);
CIMGUI_API bool   cImTriangleContainsPoint(ImVec2 a, ImVec2 b, ImVec2 c, ImVec2 p);
CIMGUI_API ImVec2 cImTriangleClosestPoint(ImVec2 a, ImVec2 b, ImVec2 c, ImVec2 p);
CIMGUI_API void   cImTriangleBarycentricCoords(ImVec2 a, ImVec2 b, ImVec2 c, ImVec2 p, float* out_u, float* out_v, float* out_w);
CIMGUI_API float  cImTriangleArea(ImVec2 a, ImVec2 b, ImVec2 c);
CIMGUI_API bool   cImTriangleIsClockwise(ImVec2 a, ImVec2 b, ImVec2 c);

// Helper: ImVec1 (1D vector)
// (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
IM_MSVC_RUNTIME_CHECKS_OFF
struct ImVec1_t
{
    float x;
};

// Helper: ImVec2i (2D vector, integer)
struct ImVec2i_t
{
    int x, y;
};

// Helper: ImVec2ih (2D vector, half-size integer, for long-term packed storage)
struct ImVec2ih_t
{
    short x, y;
};

// Helper: ImRect (2D axis aligned bounding-box)
// NB: we can't rely on ImVec2 math operators being available here!
struct ImRect_t
{
    ImVec2 Min;  // Upper-left
    ImVec2 Max;  // Lower-right
};
CIMGUI_API ImVec2 ImRect_GetCenter(const ImRect* self);
CIMGUI_API ImVec2 ImRect_GetSize(const ImRect* self);
CIMGUI_API float  ImRect_GetWidth(const ImRect* self);
CIMGUI_API float  ImRect_GetHeight(const ImRect* self);
CIMGUI_API float  ImRect_GetArea(const ImRect* self);
CIMGUI_API ImVec2 ImRect_GetTL(const ImRect* self);                                  // Top-left
CIMGUI_API ImVec2 ImRect_GetTR(const ImRect* self);                                  // Top-right
CIMGUI_API ImVec2 ImRect_GetBL(const ImRect* self);                                  // Bottom-left
CIMGUI_API ImVec2 ImRect_GetBR(const ImRect* self);                                  // Bottom-right
CIMGUI_API bool   ImRect_Contains(const ImRect* self, ImVec2 p);
CIMGUI_API bool   ImRect_ContainsImRect(const ImRect* self, ImRect r);
CIMGUI_API bool   ImRect_ContainsWithPad(const ImRect* self, ImVec2 p, ImVec2 pad);
CIMGUI_API bool   ImRect_Overlaps(const ImRect* self, ImRect r);
CIMGUI_API void   ImRect_Add(ImRect* self, ImVec2 p);
CIMGUI_API void   ImRect_AddImRect(ImRect* self, ImRect r);
CIMGUI_API void   ImRect_Expand(ImRect* self, const float amount);
CIMGUI_API void   ImRect_ExpandImVec2(ImRect* self, ImVec2 amount);
CIMGUI_API void   ImRect_Translate(ImRect* self, ImVec2 d);
CIMGUI_API void   ImRect_TranslateX(ImRect* self, float dx);
CIMGUI_API void   ImRect_TranslateY(ImRect* self, float dy);
CIMGUI_API void   ImRect_ClipWith(ImRect* self, ImRect r);                           // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
CIMGUI_API void   ImRect_ClipWithFull(ImRect* self, ImRect r);                       // Full version, ensure both points are fully clipped.
CIMGUI_API void   ImRect_Floor(ImRect* self);
CIMGUI_API bool   ImRect_IsInverted(const ImRect* self);
CIMGUI_API ImVec4 ImRect_ToVec4(const ImRect* self);

// Helper: ImBitArray
#define         IM_BITARRAY_TESTBIT(_ARRAY, _N)                 ((_ARRAY[(_N) >> 5] & ((ImU32)1 << ((_N) & 31))) != 0)  // Macro version of ImBitArrayTestBit(): ensure args have side-effect or are costly!
#define         IM_BITARRAY_CLEARBIT(_ARRAY, _N)                ((_ARRAY[(_N) >> 5] &= ~((ImU32)1 << ((_N) & 31))))     // Macro version of ImBitArrayClearBit(): ensure args have side-effect or are costly!
CIMGUI_API size_t cImBitArrayGetStorageSizeInBytes(int bitcount);
CIMGUI_API void   cImBitArrayClearAllBits(ImU32* arr, int bitcount);
CIMGUI_API bool   cImBitArrayTestBit(const ImU32* arr, int n);
CIMGUI_API void   cImBitArrayClearBit(ImU32* arr, int n);
CIMGUI_API void   cImBitArraySetBit(ImU32* arr, int n);
CIMGUI_API void   cImBitArraySetBitRange(ImU32* arr, int n, int n2);                                                 // Works on range [n..n2)

typedef ImU32* ImBitArrayPtr;  // Name for use in structs

// Helper: ImBitVector
// Store 1-bit per value.
struct ImBitVector_t
{
    ImVector_ImU32 Storage;
};
CIMGUI_API void ImBitVector_Create(ImBitVector* self, int sz);
CIMGUI_API void ImBitVector_Clear(ImBitVector* self);
CIMGUI_API bool ImBitVector_TestBit(const ImBitVector* self, int n);
CIMGUI_API void ImBitVector_SetBit(ImBitVector* self, int n);
CIMGUI_API void ImBitVector_ClearBit(ImBitVector* self, int n);
IM_MSVC_RUNTIME_CHECKS_RESTORE

// Instantiation of ImSpan<ImGuiTableColumn>
struct ImSpan_ImGuiTableColumn_t
{
    ImGuiTableColumn* Data;
    ImGuiTableColumn* DataEnd;
};
// Instantiation of ImSpan<ImGuiTableColumnIdx>
struct ImSpan_ImGuiTableColumnIdx_t
{
    ImGuiTableColumnIdx* Data;
    ImGuiTableColumnIdx* DataEnd;
};
// Instantiation of ImSpan<ImGuiTableCellData>
struct ImSpan_ImGuiTableCellData_t
{
    ImGuiTableCellData* Data;
    ImGuiTableCellData* DataEnd;
};

// Instantiation of ImStableVector<ImFontBaked, 32>
struct ImStableVector_ImFontBaked_32_t
{
    int                     Size /* = 0 */;
    int                     Capacity /* = 0 */;
    ImVector_ImFontBakedPtr Blocks;
};
CIMGUI_API void ImStableVector_ImFontBaked_32_clear(ImStableVector_ImFontBaked_32* self);
CIMGUI_API void ImStableVector_ImFontBaked_32_resize(ImStableVector_ImFontBaked_32* self, int new_size);
CIMGUI_API void ImStableVector_ImFontBaked_32_reserve(ImStableVector_ImFontBaked_32* self, int new_cap);

// 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,
// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object.
typedef int ImPoolIdx;

CIMGUI_API void        ImGuiTextIndex_clear(ImGuiTextIndex* self);
CIMGUI_API int         ImGuiTextIndex_size(ImGuiTextIndex* self);
CIMGUI_API const char* ImGuiTextIndex_get_line_begin(ImGuiTextIndex* self, const char* base, int n);
CIMGUI_API const char* ImGuiTextIndex_get_line_end(ImGuiTextIndex* self, const char* base, int n);
CIMGUI_API void        ImGuiTextIndex_append(ImGuiTextIndex* self, const char* base, int old_size, int new_size);

// Helper: ImGuiStorage
CIMGUI_API ImGuiStoragePair* cImLowerBound(ImGuiStoragePair* in_begin, ImGuiStoragePair* in_end, ImGuiID key);

//-----------------------------------------------------------------------------
// [SECTION] ImDrawList support
//-----------------------------------------------------------------------------

// ImDrawList: Helper function to calculate a circle's segment count given its radius and a "maximum error" value.
// Estimation of number of circle segment based on error is derived using method described in https://stackoverflow.com/a/2244088/15194693
// Number of segments (N) is calculated using equation:
//   N = ceil ( pi / acos(1 - error / r) )     where r > 0, error <= r
// Our equation is significantly simpler that one in the post thanks for choosing segment that is
// perpendicular to X axis. Follow steps in the article from this starting condition and you will
// will get this result.
//
// Rendering circles with an odd number of segments, while mathematically correct will produce
// asymmetrical results on the raster grid. Therefore we're rounding N to next even number (7->8, 8->8, 9->10 etc.)
#define IM_ROUNDUP_TO_EVEN(_V)                                  ((((_V) + 1) / 2) * 2)
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN                     4
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX                     512
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR)    ImClamp(IM_ROUNDUP_TO_EVEN((int)ImCeil(IM_PI / ImAcos(1 - ImMin((_MAXERROR), (_RAD)) / (_RAD)))), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX)

// Raw equation from IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC rewritten for 'r' and 'error'.
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(_N,_MAXERROR)    ((_MAXERROR) / (1 - ImCos(IM_PI / ImMax((float)(_N), IM_PI))))
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_ERROR(_N,_RAD)     ((1 - ImCos(IM_PI / ImMax((float)(_N), IM_PI))) / (_RAD))

// ImDrawList: Lookup table size for adaptive arc drawing, cover full circle.
#ifndef IM_DRAWLIST_ARCFAST_TABLE_SIZE
#define IM_DRAWLIST_ARCFAST_TABLE_SIZE                          48  // Number of samples in lookup table.
#endif // #ifndef IM_DRAWLIST_ARCFAST_TABLE_SIZE
#define IM_DRAWLIST_ARCFAST_SAMPLE_MAX                          IM_DRAWLIST_ARCFAST_TABLE_SIZE  // Sample index _PathArcToFastEx() for 360 angle.

// Data shared between all ImDrawList instances
// Conceptually this could have been called e.g. ImDrawListSharedContext
// Typically one ImGui context would create and maintain one of this.
// You may want to create your own instance of you try to ImDrawList completely without ImGui. In that case, watch out for future changes to this structure.
struct ImDrawListSharedData_t
{
    ImVec2                 TexUvWhitePixel;                             // UV of white pixel in the atlas (== FontAtlas->TexUvWhitePixel)
    const ImVec4*          TexUvLines;                                  // UV of anti-aliased lines in the atlas (== FontAtlas->TexUvLines)
    ImFontAtlas*           FontAtlas;                                   // Current font atlas
    ImFont*                Font;                                        // Current font (used for simplified AddText overload)
    float                  FontSize;                                    // Current font size (used for for simplified AddText overload)
    float                  FontScale;                                   // Current font scale (== FontSize / Font->FontSize)
    float                  CurveTessellationTol;                        // Tessellation tolerance when using PathBezierCurveTo()
    float                  CircleSegmentMaxError;                       // Number of circle segments to use per pixel of radius for AddCircle() etc
    float                  InitialFringeScale;                          // Initial scale to apply to AA fringe
    ImDrawListFlags        InitialFlags;                                // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards)
    ImVec4                 ClipRectFullscreen;                          // Value for PushClipRectFullscreen()
    ImVector_ImVec2        TempBuffer;                                  // Temporary write buffer
    ImVector_ImDrawListPtr DrawLists;                                   // All draw lists associated to this ImDrawListSharedData
    ImGuiContext*          Context;                                     // [OPTIONAL] Link to Dear ImGui context. 99% of ImDrawList/ImFontAtlas can function without an ImGui context, but this facilitate handling one legacy edge case.

    // Lookup tables
    ImVec2                 ArcFastVtx[IM_DRAWLIST_ARCFAST_TABLE_SIZE];  // Sample points on the quarter of the circle.
    float                  ArcFastRadiusCutoff;                         // Cutoff radius after which arc drawing will fallback to slower PathArcTo()
    ImU8                   CircleSegmentCounts[64];                     // Precomputed segment count for given radius before we calculate it dynamically (to avoid calculation overhead)
};
CIMGUI_API void ImDrawListSharedData_SetCircleTessellationMaxError(ImDrawListSharedData* self, float max_error);

struct ImDrawDataBuilder_t
{
    ImVector_ImDrawListPtr* Layers[2];  // Pointers to global layers for: regular, tooltip. LayersP[0] is owned by DrawData.
    ImVector_ImDrawListPtr  LayerData1;
};

struct ImFontStackData_t
{
    ImFont* Font;
    float   FontSizeBeforeScaling;  // ~~ style.FontSizeBase
    float   FontSizeAfterScaling;   // ~~ g.FontSize
};
struct ImVector_ImFontStackData_t { int Size; int Capacity; ImFontStackData* Data; };  // Instantiation of ImVector<ImFontStackData>

//-----------------------------------------------------------------------------
// [SECTION] Style support
//-----------------------------------------------------------------------------

struct ImGuiStyleVarInfo_t
{
    ImU32         Count : 8;    // 1+
    ImGuiDataType DataType : 8;
    ImU32         Offset : 16;  // Offset in parent structure
};
CIMGUI_API void* ImGuiStyleVarInfo_GetVarPtr(const ImGuiStyleVarInfo* self, void* parent);

// Stacked color modifier, backup of modified data so we can restore it
struct ImGuiColorMod_t
{
    ImGuiCol Col;
    ImVec4   BackupValue;
};

// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
struct ImGuiStyleMod_t
{
    ImGuiStyleVar VarIdx;
    union
    {
        int   BackupInt[2];
        float BackupFloat[2];
    };
};

//-----------------------------------------------------------------------------
// [SECTION] Data types support
//-----------------------------------------------------------------------------

struct ImGuiDataTypeStorage_t
{
    ImU8 Data[8];  // Opaque storage to fit any data up to ImGuiDataType_COUNT
};

// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo().
struct ImGuiDataTypeInfo_t
{
    size_t      Size;      // Size in bytes
    const char* Name;      // Short descriptive name for the type, for debugging
    const char* PrintFmt;  // Default printf format for the type
    const char* ScanFmt;   // Default scanf format for the type
};

// Extend ImGuiDataType_
typedef enum
{
    ImGuiDataType_Pointer = ImGuiDataType_COUNT,
    ImGuiDataType_ID,
} ImGuiDataTypePrivate_;

//-----------------------------------------------------------------------------
// [SECTION] Widgets support: flags, enums, data structures
// Instantiation of ImChunkStream<ImGuiTableSettings>
struct ImChunkStream_ImGuiTableSettings_t
{
    ImVector_char Buf;
};
// Instantiation of ImChunkStream<ImGuiWindowSettings>
struct ImChunkStream_ImGuiWindowSettings_t
{
    ImVector_char Buf;
};
struct ImVector_unsigned_char_t { int Size; int Capacity; unsigned char* Data; };  // Instantiation of ImVector<unsigned char>
struct ImVector_ImGuiWindowStackData_t { int Size; int Capacity; ImGuiWindowStackData* Data; };  // Instantiation of ImVector<ImGuiWindowStackData>
struct ImVector_ImGuiWindowPtr_t { int Size; int Capacity; ImGuiWindow** Data; };  // Instantiation of ImVector<ImGuiWindow*>
struct ImVector_ImGuiViewportPPtr_t { int Size; int Capacity; ImGuiViewportP** Data; };  // Instantiation of ImVector<ImGuiViewportP*>
struct ImVector_ImGuiTreeNodeStackData_t { int Size; int Capacity; ImGuiTreeNodeStackData* Data; };  // Instantiation of ImVector<ImGuiTreeNodeStackData>
struct ImVector_ImGuiTableTempData_t { int Size; int Capacity; ImGuiTableTempData* Data; };  // Instantiation of ImVector<ImGuiTableTempData>
struct ImVector_ImGuiTableInstanceData_t { int Size; int Capacity; ImGuiTableInstanceData* Data; };  // Instantiation of ImVector<ImGuiTableInstanceData>
struct ImVector_ImGuiTableHeaderData_t { int Size; int Capacity; ImGuiTableHeaderData* Data; };  // Instantiation of ImVector<ImGuiTableHeaderData>
struct ImVector_ImGuiTableColumnSortSpecs_t { int Size; int Capacity; ImGuiTableColumnSortSpecs* Data; };  // Instantiation of ImVector<ImGuiTableColumnSortSpecs>
struct ImVector_ImGuiTable_t { int Size; int Capacity; ImGuiTable* Data; };  // Instantiation of ImVector<ImGuiTable>
struct ImVector_ImGuiTabItem_t { int Size; int Capacity; ImGuiTabItem* Data; };  // Instantiation of ImVector<ImGuiTabItem>
struct ImVector_ImGuiTabBar_t { int Size; int Capacity; ImGuiTabBar* Data; };  // Instantiation of ImVector<ImGuiTabBar>
struct ImVector_ImGuiStyleMod_t { int Size; int Capacity; ImGuiStyleMod* Data; };  // Instantiation of ImVector<ImGuiStyleMod>
struct ImVector_ImGuiStackLevelInfo_t { int Size; int Capacity; ImGuiStackLevelInfo* Data; };  // Instantiation of ImVector<ImGuiStackLevelInfo>
struct ImVector_ImGuiShrinkWidthItem_t { int Size; int Capacity; ImGuiShrinkWidthItem* Data; };  // Instantiation of ImVector<ImGuiShrinkWidthItem>
struct ImVector_ImGuiSettingsHandler_t { int Size; int Capacity; ImGuiSettingsHandler* Data; };  // Instantiation of ImVector<ImGuiSettingsHandler>
struct ImVector_ImGuiPtrOrIndex_t { int Size; int Capacity; ImGuiPtrOrIndex* Data; };  // Instantiation of ImVector<ImGuiPtrOrIndex>
struct ImVector_ImGuiPopupData_t { int Size; int Capacity; ImGuiPopupData* Data; };  // Instantiation of ImVector<ImGuiPopupData>
struct ImVector_ImGuiOldColumns_t { int Size; int Capacity; ImGuiOldColumns* Data; };  // Instantiation of ImVector<ImGuiOldColumns>
struct ImVector_ImGuiOldColumnData_t { int Size; int Capacity; ImGuiOldColumnData* Data; };  // Instantiation of ImVector<ImGuiOldColumnData>
struct ImVector_ImGuiMultiSelectTempData_t { int Size; int Capacity; ImGuiMultiSelectTempData* Data; };  // Instantiation of ImVector<ImGuiMultiSelectTempData>
struct ImVector_ImGuiMultiSelectState_t { int Size; int Capacity; ImGuiMultiSelectState* Data; };  // Instantiation of ImVector<ImGuiMultiSelectState>
struct ImVector_ImGuiListClipperRange_t { int Size; int Capacity; ImGuiListClipperRange* Data; };  // Instantiation of ImVector<ImGuiListClipperRange>
struct ImVector_ImGuiListClipperData_t { int Size; int Capacity; ImGuiListClipperData* Data; };  // Instantiation of ImVector<ImGuiListClipperData>
struct ImVector_ImGuiKeyRoutingData_t { int Size; int Capacity; ImGuiKeyRoutingData* Data; };  // Instantiation of ImVector<ImGuiKeyRoutingData>
struct ImVector_ImGuiItemFlags_t { int Size; int Capacity; ImGuiItemFlags* Data; };  // Instantiation of ImVector<ImGuiItemFlags>
struct ImVector_ImGuiInputEvent_t { int Size; int Capacity; ImGuiInputEvent* Data; };  // Instantiation of ImVector<ImGuiInputEvent>
struct ImVector_ImGuiID_t { int Size; int Capacity; ImGuiID* Data; };  // Instantiation of ImVector<ImGuiID>
struct ImVector_ImGuiGroupData_t { int Size; int Capacity; ImGuiGroupData* Data; };  // Instantiation of ImVector<ImGuiGroupData>
struct ImVector_ImGuiFocusScopeData_t { int Size; int Capacity; ImGuiFocusScopeData* Data; };  // Instantiation of ImVector<ImGuiFocusScopeData>
struct ImVector_ImGuiDockRequest_t { int Size; int Capacity; ImGuiDockRequest* Data; };  // Instantiation of ImVector<ImGuiDockRequest>
struct ImVector_ImGuiDockNodeSettings_t { int Size; int Capacity; ImGuiDockNodeSettings* Data; };  // Instantiation of ImVector<ImGuiDockNodeSettings>
struct ImVector_ImGuiContextHook_t { int Size; int Capacity; ImGuiContextHook* Data; };  // Instantiation of ImVector<ImGuiContextHook>
struct ImVector_ImGuiColorMod_t { int Size; int Capacity; ImGuiColorMod* Data; };  // Instantiation of ImVector<ImGuiColorMod>
struct ImVector_const_charPtr_t { int Size; int Capacity; const char** Data; };  // Instantiation of ImVector<const char*>
struct ImVector_int_t { int Size; int Capacity; int* Data; };  // Instantiation of ImVector<int>
// Instantiation of ImPool<ImGuiMultiSelectState>
struct ImPool_ImGuiMultiSelectState_t
{
    ImVector_ImGuiMultiSelectState Buf;         // Contiguous data
    ImGuiStorage                   Map;         // ID->Index
    ImPoolIdx                      FreeIdx;     // Next free idx to use
    ImPoolIdx                      AliveCount;  // Number of active/alive items (for display purpose)
};
// Instantiation of ImPool<ImGuiTabBar>
struct ImPool_ImGuiTabBar_t
{
    ImVector_ImGuiTabBar Buf;         // Contiguous data
    ImGuiStorage         Map;         // ID->Index
    ImPoolIdx            FreeIdx;     // Next free idx to use
    ImPoolIdx            AliveCount;  // Number of active/alive items (for display purpose)
};
// Instantiation of ImPool<ImGuiTable>
struct ImPool_ImGuiTable_t
{
    ImVector_ImGuiTable Buf;         // Contiguous data
    ImGuiStorage        Map;         // ID->Index
    ImPoolIdx           FreeIdx;     // Next free idx to use
    ImPoolIdx           AliveCount;  // Number of active/alive items (for display purpose)
};
// Helper: ImGuiTextIndex
// Maintain a line index for a text buffer. This is a strong candidate to be moved into the public API.
struct ImGuiTextIndex_t
{
    ImVector_int Offsets;
    int          EndOffset /* = 0 */;  // Because we don't own text buffer we need to maintain EndOffset (may bake in LineOffsets?)
};
typedef struct ImGuiTextIndex_t ImGuiTextIndex;  // Maintain a line index for a text buffer.
//-----------------------------------------------------------------------------

// Extend ImGuiItemFlags
// - input: PushItemFlag() manipulates g.CurrentItemFlags, g.NextItemData.ItemFlags, ItemAdd() calls may add extra flags too.
// - output: stored in g.LastItemData.ItemFlags
typedef enum
{
    // Controlled by user
    ImGuiItemFlags_Disabled               = 1<<10,                           // false     // Disable interactions (DOES NOT affect visuals. DO NOT mix direct use of this with BeginDisabled(). See BeginDisabled()/EndDisabled() for full disable feature, and github #211).
    ImGuiItemFlags_ReadOnly               = 1<<11,                           // false     // [ALPHA] Allow hovering interactions but underlying value is not changed.
    ImGuiItemFlags_MixedValue             = 1<<12,                           // false     // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
    ImGuiItemFlags_NoWindowHoverableCheck = 1<<13,                           // false     // Disable hoverable check in ItemHoverable()
    ImGuiItemFlags_AllowOverlap           = 1<<14,                           // false     // Allow being overlapped by another widget. Not-hovered to Hovered transition deferred by a frame.
    ImGuiItemFlags_NoNavDisableMouseHover = 1<<15,                           // false     // Nav keyboard/gamepad mode doesn't disable hover highlight (behave as if NavHighlightItemUnderNav==false).
    ImGuiItemFlags_NoMarkEdited           = 1<<16,                           // false     // Skip calling MarkItemEdited()
    ImGuiItemFlags_NoFocus                = 1<<17,                           // false     // [EXPERIMENTAL: Not very well specced] Clicking doesn't take focus. Automatically sets ImGuiButtonFlags_NoFocus + ImGuiButtonFlags_NoNavFocus in ButtonBehavior().

    // Controlled by widget code
    ImGuiItemFlags_Inputable              = 1<<20,                           // false     // [WIP] Auto-activate input mode when tab focused. Currently only used and supported by a few items before it becomes a generic feature.
    ImGuiItemFlags_HasSelectionUserData   = 1<<21,                           // false     // Set by SetNextItemSelectionUserData()
    ImGuiItemFlags_IsMultiSelect          = 1<<22,                           // false     // Set by SetNextItemSelectionUserData()

    ImGuiItemFlags_Default_               = ImGuiItemFlags_AutoClosePopups,  // Please don't change, use PushItemFlag() instead.

    // Obsolete
    //ImGuiItemFlags_SelectableDontClosePopup = !ImGuiItemFlags_AutoClosePopups, // Can't have a redirect as we inverted the behavior
} ImGuiItemFlagsPrivate_;

// Status flags for an already submitted item
// - output: stored in g.LastItemData.StatusFlags
typedef enum
{
    ImGuiItemStatusFlags_None             = 0,
    ImGuiItemStatusFlags_HoveredRect      = 1<<0,   // Mouse position is within item rectangle (does NOT mean that the window is in correct z-order and can be hovered!, this is only one part of the most-common IsItemHovered test)
    ImGuiItemStatusFlags_HasDisplayRect   = 1<<1,   // g.LastItemData.DisplayRect is valid
    ImGuiItemStatusFlags_Edited           = 1<<2,   // Value exposed by item was edited in the current frame (should match the bool return value of most widgets)
    ImGuiItemStatusFlags_ToggledSelection = 1<<3,   // Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected", only state changes, in order to easily handle clipping with less issues.
    ImGuiItemStatusFlags_ToggledOpen      = 1<<4,   // Set when TreeNode() reports toggling their open state.
    ImGuiItemStatusFlags_HasDeactivated   = 1<<5,   // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag.
    ImGuiItemStatusFlags_Deactivated      = 1<<6,   // Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
    ImGuiItemStatusFlags_HoveredWindow    = 1<<7,   // Override the HoveredWindow test to allow cross-window hover testing.
    ImGuiItemStatusFlags_Visible          = 1<<8,   // [WIP] Set when item is overlapping the current clipping rectangle (Used internally. Please don't use yet: API/system will change as we refactor Itemadd()).
    ImGuiItemStatusFlags_HasClipRect      = 1<<9,   // g.LastItemData.ClipRect is valid.
    ImGuiItemStatusFlags_HasShortcut      = 1<<10,  // g.LastItemData.Shortcut valid. Set by SetNextItemShortcut() -> ItemAdd().
    //ImGuiItemStatusFlags_FocusedByTabbing = 1 << 8,   // Removed IN 1.90.1 (Dec 2023). The trigger is part of g.NavActivateId. See commit 54c1bdeceb.

    // Additional status + semantic for ImGuiTestEngine
#ifdef IMGUI_ENABLE_TEST_ENGINE
    ImGuiItemStatusFlags_Openable         = 1<<20,  // Item is an openable (e.g. TreeNode)
    ImGuiItemStatusFlags_Opened           = 1<<21,  // Opened status
    ImGuiItemStatusFlags_Checkable        = 1<<22,  // Item is a checkable (e.g. CheckBox, MenuItem)
    ImGuiItemStatusFlags_Checked          = 1<<23,  // Checked status
    ImGuiItemStatusFlags_Inputable        = 1<<24,  // Item is a text-inputable (e.g. InputText, SliderXXX, DragXXX)
#endif // #ifdef IMGUI_ENABLE_TEST_ENGINE
} ImGuiItemStatusFlags_;

// Extend ImGuiHoveredFlags_
typedef enum
{
    ImGuiHoveredFlags_DelayMask_                    = ImGuiHoveredFlags_DelayNone | ImGuiHoveredFlags_DelayShort | ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_NoSharedDelay,
    ImGuiHoveredFlags_AllowedMaskForIsWindowHovered = ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_DockHierarchy | ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary,
    ImGuiHoveredFlags_AllowedMaskForIsItemHovered   = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled | ImGuiHoveredFlags_NoNavOverride | ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayMask_,
} ImGuiHoveredFlagsPrivate_;

// Extend ImGuiInputTextFlags_
typedef enum
{
    // [Internal]
    ImGuiInputTextFlags_Multiline            = 1<<26,  // For internal use by InputTextMultiline()
    ImGuiInputTextFlags_MergedItem           = 1<<27,  // For internal use by TempInputText(), will skip calling ItemAdd(). Require bounding-box to strictly match.
    ImGuiInputTextFlags_LocalizeDecimalPoint = 1<<28,  // For internal use by InputScalar() and TempInputScalar()
} ImGuiInputTextFlagsPrivate_;

// Extend ImGuiButtonFlags_
typedef enum
{
    ImGuiButtonFlags_PressedOnClick                = 1<<4,   // return true on click (mouse down event)
    ImGuiButtonFlags_PressedOnClickRelease         = 1<<5,   // [Default] return true on click + release on same item <-- this is what the majority of Button are using
    ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1<<6,   // return true on click + release even if the release event is not done while hovering the item
    ImGuiButtonFlags_PressedOnRelease              = 1<<7,   // return true on release (default requires click+release)
    ImGuiButtonFlags_PressedOnDoubleClick          = 1<<8,   // return true on double-click (default requires click+release)
    ImGuiButtonFlags_PressedOnDragDropHold         = 1<<9,   // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
    //ImGuiButtonFlags_Repeat               = 1 << 10,  // hold to repeat -> use ImGuiItemFlags_ButtonRepeat instead.
    ImGuiButtonFlags_FlattenChildren               = 1<<11,  // allow interactions even if a child window is overlapping
    ImGuiButtonFlags_AllowOverlap                  = 1<<12,  // require previous frame HoveredId to either match id or be null before being usable.
    //ImGuiButtonFlags_DontClosePopups      = 1 << 13,  // disable automatically closing parent popup on press
    //ImGuiButtonFlags_Disabled             = 1 << 14,  // disable interactions -> use BeginDisabled() or ImGuiItemFlags_Disabled
    ImGuiButtonFlags_AlignTextBaseLine             = 1<<15,  // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
    ImGuiButtonFlags_NoKeyModsAllowed              = 1<<16,  // disable mouse interaction if a key modifier is held
    ImGuiButtonFlags_NoHoldingActiveId             = 1<<17,  // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
    ImGuiButtonFlags_NoNavFocus                    = 1<<18,  // don't override navigation focus when activated (FIXME: this is essentially used every time an item uses ImGuiItemFlags_NoNav, but because legacy specs don't requires LastItemData to be set ButtonBehavior(), we can't poll g.LastItemData.ItemFlags)
    ImGuiButtonFlags_NoHoveredOnFocus              = 1<<19,  // don't report as hovered when nav focus is on this item
    ImGuiButtonFlags_NoSetKeyOwner                 = 1<<20,  // don't set key/input owner on the initial click (note: mouse buttons are keys! often, the key in question will be ImGuiKey_MouseLeft!)
    ImGuiButtonFlags_NoTestKeyOwner                = 1<<21,  // don't test key/input owner when polling the key (note: mouse buttons are keys! often, the key in question will be ImGuiKey_MouseLeft!)
    ImGuiButtonFlags_NoFocus                       = 1<<22,  // [EXPERIMENTAL: Not very well specced]. Don't focus parent window when clicking.
    ImGuiButtonFlags_PressedOnMask_                = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold,
    ImGuiButtonFlags_PressedOnDefault_             = ImGuiButtonFlags_PressedOnClickRelease,
    //ImGuiButtonFlags_NoKeyModifiers       = ImGuiButtonFlags_NoKeyModsAllowed, // Renamed in 1.91.4
} ImGuiButtonFlagsPrivate_;

// Extend ImGuiComboFlags_
typedef enum
{
    ImGuiComboFlags_CustomPreview = 1<<20,  // enable BeginComboPreview()
} ImGuiComboFlagsPrivate_;

// Extend ImGuiSliderFlags_
typedef enum
{
    ImGuiSliderFlags_Vertical = 1<<20,  // Should this slider be orientated vertically?
    ImGuiSliderFlags_ReadOnly = 1<<21,  // Consider using g.NextItemData.ItemFlags |= ImGuiItemFlags_ReadOnly instead.
} ImGuiSliderFlagsPrivate_;

// Extend ImGuiSelectableFlags_
typedef enum
{
    // NB: need to be in sync with last value of ImGuiSelectableFlags_
    ImGuiSelectableFlags_NoHoldingActiveID    = 1<<20,
    ImGuiSelectableFlags_SelectOnClick        = 1<<22,  // Override button behavior to react on Click (default is Click+Release)
    ImGuiSelectableFlags_SelectOnRelease      = 1<<23,  // Override button behavior to react on Release (default is Click+Release)
    ImGuiSelectableFlags_SpanAvailWidth       = 1<<24,  // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus)
    ImGuiSelectableFlags_SetNavIdOnHover      = 1<<25,  // Set Nav/Focus ID on mouse hover (used by MenuItem)
    ImGuiSelectableFlags_NoPadWithHalfSpacing = 1<<26,  // Disable padding each side with ItemSpacing * 0.5f
    ImGuiSelectableFlags_NoSetKeyOwner        = 1<<27,  // Don't set key/input owner on the initial click (note: mouse buttons are keys! often, the key in question will be ImGuiKey_MouseLeft!)
} ImGuiSelectableFlagsPrivate_;

// Extend ImGuiTreeNodeFlags_
typedef enum
{
    ImGuiTreeNodeFlags_NoNavFocus                 = 1<<27,  // Don't claim nav focus when interacting with this item (#8551)
    ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1<<28,  // FIXME-WIP: Hard-coded for CollapsingHeader()
    ImGuiTreeNodeFlags_UpsideDownArrow            = 1<<29,  // FIXME-WIP: Turn Down arrow into an Up arrow, for reversed trees (#6517)
    ImGuiTreeNodeFlags_OpenOnMask_                = ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_OpenOnArrow,
    ImGuiTreeNodeFlags_DrawLinesMask_             = ImGuiTreeNodeFlags_DrawLinesNone | ImGuiTreeNodeFlags_DrawLinesFull | ImGuiTreeNodeFlags_DrawLinesToNodes,
} ImGuiTreeNodeFlagsPrivate_;

typedef enum
{
    ImGuiSeparatorFlags_None           = 0,
    ImGuiSeparatorFlags_Horizontal     = 1<<0,  // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
    ImGuiSeparatorFlags_Vertical       = 1<<1,
    ImGuiSeparatorFlags_SpanAllColumns = 1<<2,  // Make separator cover all columns of a legacy Columns() set.
} ImGuiSeparatorFlags_;

// Flags for FocusWindow(). This is not called ImGuiFocusFlags to avoid confusion with public-facing ImGuiFocusedFlags.
// FIXME: Once we finishing replacing more uses of GetTopMostPopupModal()+IsWindowWithinBeginStackOf()
// and FindBlockingModal() with this, we may want to change the flag to be opt-out instead of opt-in.
typedef enum
{
    ImGuiFocusRequestFlags_None                = 0,
    ImGuiFocusRequestFlags_RestoreFocusedChild = 1<<0,  // Find last focused child (if any) and focus it instead.
    ImGuiFocusRequestFlags_UnlessBelowModal    = 1<<1,  // Do not set focus if the window is below a modal.
} ImGuiFocusRequestFlags_;

typedef enum
{
    ImGuiTextFlags_None                       = 0,
    ImGuiTextFlags_NoWidthForLargeClippedText = 1<<0,
} ImGuiTextFlags_;

typedef enum
{
    ImGuiTooltipFlags_None             = 0,
    ImGuiTooltipFlags_OverridePrevious = 1<<1,  // Clear/ignore previously submitted tooltip (defaults to append)
} ImGuiTooltipFlags_;

// FIXME: this is in development, not exposed/functional as a generic feature yet.
// Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2
typedef enum
{
    ImGuiLayoutType_Horizontal = 0,
    ImGuiLayoutType_Vertical   = 1,
} ImGuiLayoutType_;

// Flags for LogBegin() text capturing function
typedef enum
{
    ImGuiLogFlags_None            = 0,

    ImGuiLogFlags_OutputTTY       = 1<<0,
    ImGuiLogFlags_OutputFile      = 1<<1,
    ImGuiLogFlags_OutputBuffer    = 1<<2,
    ImGuiLogFlags_OutputClipboard = 1<<3,
    ImGuiLogFlags_OutputMask_     = ImGuiLogFlags_OutputTTY | ImGuiLogFlags_OutputFile | ImGuiLogFlags_OutputBuffer | ImGuiLogFlags_OutputClipboard,
} ImGuiLogFlags_;

// X/Y enums are fixed to 0/1 so they may be used to index ImVec2
typedef enum
{
    ImGuiAxis_None = -1,
    ImGuiAxis_X    = 0,
    ImGuiAxis_Y    = 1,
} ImGuiAxis;

typedef enum
{
    ImGuiPlotType_Lines,
    ImGuiPlotType_Histogram,
} ImGuiPlotType;

// Storage data for BeginComboPreview()/EndComboPreview()
struct ImGuiComboPreviewData_t
{
    ImRect          PreviewRect;
    ImVec2          BackupCursorPos;
    ImVec2          BackupCursorMaxPos;
    ImVec2          BackupCursorPosPrevLine;
    float           BackupPrevLineTextBaseOffset;
    ImGuiLayoutType BackupLayout;
};

// Stacked storage data for BeginGroup()/EndGroup()
struct ImGuiGroupData_t
{
    ImGuiID WindowID;
    ImVec2  BackupCursorPos;
    ImVec2  BackupCursorMaxPos;
    ImVec2  BackupCursorPosPrevLine;
    ImVec1  BackupIndent;
    ImVec1  BackupGroupOffset;
    ImVec2  BackupCurrLineSize;
    float   BackupCurrLineTextBaseOffset;
    ImGuiID BackupActiveIdIsAlive;
    bool    BackupActiveIdHasBeenEditedThisFrame;
    bool    BackupDeactivatedIdIsAlive;
    bool    BackupHoveredIdIsAlive;
    bool    BackupIsSameLine;
    bool    EmitItem;
};

// Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper.
struct ImGuiMenuColumns_t
{
    ImU32 TotalWidth;
    ImU32 NextTotalWidth;
    ImU16 Spacing;
    ImU16 OffsetIcon;   // Always zero for now
    ImU16 OffsetLabel;  // Offsets are locked in Update()
    ImU16 OffsetShortcut;
    ImU16 OffsetMark;
    ImU16 Widths[4];    // Width of:   Icon, Label, Shortcut, Mark  (accumulators for current frame)
};
CIMGUI_API void  ImGuiMenuColumns_Update(ImGuiMenuColumns* self, float spacing, bool window_reappearing);
CIMGUI_API float ImGuiMenuColumns_DeclColumns(ImGuiMenuColumns* self, float w_icon, float w_label, float w_shortcut, float w_mark);
CIMGUI_API void  ImGuiMenuColumns_CalcNextTotalWidth(ImGuiMenuColumns* self, bool update_offsets);

// Internal temporary state for deactivating InputText() instances.
struct ImGuiInputTextDeactivatedState_t
{
    ImGuiID       ID;     // widget id owning the text state (which just got deactivated)
    ImVector_char TextA;  // text buffer
};
CIMGUI_API void ImGuiInputTextDeactivatedState_ClearFreeMemory(ImGuiInputTextDeactivatedState* self);

// Forward declare imstb_textedit.h structure + make its main configuration define accessible
#undef IMSTB_TEXTEDIT_STRING
#undef IMSTB_TEXTEDIT_CHARTYPE
#define IMSTB_TEXTEDIT_STRING             ImGuiInputTextState
#define IMSTB_TEXTEDIT_CHARTYPE           char
#define IMSTB_TEXTEDIT_GETWIDTH_NEWLINE   (-1.0f)
#define IMSTB_TEXTEDIT_UNDOSTATECOUNT     99
#define IMSTB_TEXTEDIT_UNDOCHARCOUNT      999
typedef struct ImStb_STB_TexteditState_t ImStb_STB_TexteditState;

// Internal state of the currently focused/edited text input box
// For a given item ID, access with ImGui::GetInputTextState()
struct ImGuiInputTextState_t
{
    ImGuiContext*       Ctx;                   // parent UI context (needs to be set explicitly by parent).
    void*               Stb;                   // State for stb_textedit.h
    ImGuiInputTextFlags Flags;                 // copy of InputText() flags. may be used to check if e.g. ImGuiInputTextFlags_Password is set.
    ImGuiID             ID;                    // widget id owning the text state
    int                 TextLen;               // UTF-8 length of the string in TextA (in bytes)
    const char*         TextSrc;               // == TextA.Data unless read-only, in which case == buf passed to InputText(). Field only set and valid _inside_ the call InputText() call.
    ImVector_char       TextA;                 // main UTF8 buffer. TextA.Size is a buffer size! Should always be >= buf_size passed by user (and of course >= CurLenA + 1).
    ImVector_char       TextToRevertTo;        // value to revert to when pressing Escape = backup of end-user buffer at the time of focus (in UTF-8, unaltered)
    ImVector_char       CallbackTextBackup;    // temporary storage for callback to support automatic reconcile of undo-stack
    int                 BufCapacity;           // end-user buffer capacity (include zero terminator)
    ImVec2              Scroll;                // horizontal offset (managed manually) + vertical scrolling (pulled from child window's own Scroll.y)
    int                 LineCount;             // last line count (solely for debugging)
    float               WrapWidth;             // word-wrapping width
    float               CursorAnim;            // timer for cursor blink, reset on every user action so the cursor reappears immediately
    bool                CursorFollow;          // set when we want scrolling to follow the current cursor position (not always!)
    bool                CursorCenterY;         // set when we want scrolling to be centered over the cursor position (while resizing a word-wrapping field)
    bool                SelectedAllMouseLock;  // after a double-click to select all, we ignore further mouse drags to update selection
    bool                Edited;                // edited this frame
    bool                WantReloadUserBuf;     // force a reload of user buf so it may be modified externally. may be automatic in future version.
    ImS8                LastMoveDirectionLR;   // ImGuiDir_Left or ImGuiDir_Right. track last movement direction so when cursor cross over a word-wrapping boundaries we can display it on either line depending on last move.s
    int                 ReloadSelectionStart;
    int                 ReloadSelectionEnd;
};
CIMGUI_API void  ImGuiInputTextState_ClearText(ImGuiInputTextState* self);
CIMGUI_API void  ImGuiInputTextState_ClearFreeMemory(ImGuiInputTextState* self);
CIMGUI_API void  ImGuiInputTextState_OnKeyPressed(ImGuiInputTextState* self, int key);          // Cannot be inline because we call in code in stb_textedit.h implementation
CIMGUI_API void  ImGuiInputTextState_OnCharPressed(ImGuiInputTextState* self, unsigned int c);
CIMGUI_API float ImGuiInputTextState_GetPreferredOffsetX(const ImGuiInputTextState* self);
// Cursor & Selection
CIMGUI_API void  ImGuiInputTextState_CursorAnimReset(ImGuiInputTextState* self);
CIMGUI_API void  ImGuiInputTextState_CursorClamp(ImGuiInputTextState* self);
CIMGUI_API bool  ImGuiInputTextState_HasSelection(const ImGuiInputTextState* self);
CIMGUI_API void  ImGuiInputTextState_ClearSelection(ImGuiInputTextState* self);
CIMGUI_API int   ImGuiInputTextState_GetCursorPos(const ImGuiInputTextState* self);
CIMGUI_API int   ImGuiInputTextState_GetSelectionStart(const ImGuiInputTextState* self);
CIMGUI_API int   ImGuiInputTextState_GetSelectionEnd(const ImGuiInputTextState* self);
CIMGUI_API void  ImGuiInputTextState_SelectAll(ImGuiInputTextState* self);
// Reload user buf (WIP #2890)
// If you modify underlying user-passed const char* while active you need to call this (InputText V2 may lift this)
//   strcpy(my_buf, "hello");
//   if (ImGuiInputTextState* state = ImGui::GetInputTextState(id)) // id may be ImGui::GetItemID() is last item
//       state->ReloadUserBufAndSelectAll();
CIMGUI_API void  ImGuiInputTextState_ReloadUserBufAndSelectAll(ImGuiInputTextState* self);
CIMGUI_API void  ImGuiInputTextState_ReloadUserBufAndKeepSelection(ImGuiInputTextState* self);
CIMGUI_API void  ImGuiInputTextState_ReloadUserBufAndMoveToEnd(ImGuiInputTextState* self);

typedef enum
{
    ImGuiWindowRefreshFlags_None              = 0,
    ImGuiWindowRefreshFlags_TryToAvoidRefresh = 1<<0,  // [EXPERIMENTAL] Try to keep existing contents, USER MUST NOT HONOR BEGIN() RETURNING FALSE AND NOT APPEND.
    ImGuiWindowRefreshFlags_RefreshOnHover    = 1<<1,  // [EXPERIMENTAL] Always refresh on hover
    ImGuiWindowRefreshFlags_RefreshOnFocus    = 1<<2,  // [EXPERIMENTAL] Always refresh on focus
    // Refresh policy/frequency, Load Balancing etc.
} ImGuiWindowRefreshFlags_;

typedef enum
{
    ImGuiWindowBgClickFlags_None = 0,
    ImGuiWindowBgClickFlags_Move = 1<<0,  // Click on bg/void + drag to move window. Cleared by default when using io.ConfigWindowsMoveFromTitleBarOnly.
} ImGuiWindowBgClickFlags_;

typedef enum
{
    ImGuiNextWindowDataFlags_None              = 0,
    ImGuiNextWindowDataFlags_HasPos            = 1<<0,
    ImGuiNextWindowDataFlags_HasSize           = 1<<1,
    ImGuiNextWindowDataFlags_HasContentSize    = 1<<2,
    ImGuiNextWindowDataFlags_HasCollapsed      = 1<<3,
    ImGuiNextWindowDataFlags_HasSizeConstraint = 1<<4,
    ImGuiNextWindowDataFlags_HasFocus          = 1<<5,
    ImGuiNextWindowDataFlags_HasBgAlpha        = 1<<6,
    ImGuiNextWindowDataFlags_HasScroll         = 1<<7,
    ImGuiNextWindowDataFlags_HasWindowFlags    = 1<<8,
    ImGuiNextWindowDataFlags_HasChildFlags     = 1<<9,
    ImGuiNextWindowDataFlags_HasRefreshPolicy  = 1<<10,
    ImGuiNextWindowDataFlags_HasViewport       = 1<<11,
    ImGuiNextWindowDataFlags_HasDock           = 1<<12,
    ImGuiNextWindowDataFlags_HasWindowClass    = 1<<13,
} ImGuiNextWindowDataFlags_;

// Storage for SetNexWindow** functions
struct ImGuiNextWindowData_t
{
    ImGuiNextWindowDataFlags HasFlags;

    // Members below are NOT cleared. Always rely on HasFlags.
    ImGuiCond                PosCond;
    ImGuiCond                SizeCond;
    ImGuiCond                CollapsedCond;
    ImGuiCond                DockCond;
    ImVec2                   PosVal;
    ImVec2                   PosPivotVal;
    ImVec2                   SizeVal;
    ImVec2                   ContentSizeVal;
    ImVec2                   ScrollVal;
    ImGuiWindowFlags         WindowFlags;          // Only honored by BeginTable()
    ImGuiChildFlags          ChildFlags;
    bool                     PosUndock;
    bool                     CollapsedVal;
    ImRect                   SizeConstraintRect;
    ImGuiSizeCallback        SizeCallback;
    void*                    SizeCallbackUserData;
    float                    BgAlphaVal;           // Override background alpha
    ImGuiID                  ViewportId;
    ImGuiID                  DockId;
    ImGuiWindowClass         WindowClass;
    ImVec2                   MenuBarOffsetMinVal;  // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?)
    ImGuiWindowRefreshFlags  RefreshFlagsVal;
};
CIMGUI_API void ImGuiNextWindowData_ClearFlags(ImGuiNextWindowData* self);

typedef enum
{
    ImGuiNextItemDataFlags_None         = 0,
    ImGuiNextItemDataFlags_HasWidth     = 1<<0,
    ImGuiNextItemDataFlags_HasOpen      = 1<<1,
    ImGuiNextItemDataFlags_HasShortcut  = 1<<2,
    ImGuiNextItemDataFlags_HasRefVal    = 1<<3,
    ImGuiNextItemDataFlags_HasStorageID = 1<<4,
} ImGuiNextItemDataFlags_;

struct ImGuiNextItemData_t
{
    ImGuiNextItemDataFlags HasFlags;           // Called HasFlags instead of Flags to avoid mistaking this
    ImGuiItemFlags         ItemFlags;          // Currently only tested/used for ImGuiItemFlags_AllowOverlap and ImGuiItemFlags_HasSelectionUserData.

    // Members below are NOT cleared by ItemAdd() meaning they are still valid during e.g. NavProcessItem(). Always rely on HasFlags.
    ImGuiID                FocusScopeId;       // Set by SetNextItemSelectionUserData()
    ImGuiSelectionUserData SelectionUserData;  // Set by SetNextItemSelectionUserData() (note that NULL/0 is a valid value, we use -1 == ImGuiSelectionUserData_Invalid to mark invalid values)
    float                  Width;              // Set by SetNextItemWidth()
    ImGuiKeyChord          Shortcut;           // Set by SetNextItemShortcut()
    ImGuiInputFlags        ShortcutFlags;      // Set by SetNextItemShortcut()
    bool                   OpenVal;            // Set by SetNextItemOpen()
    ImU8                   OpenCond;           // Set by SetNextItemOpen()
    ImGuiDataTypeStorage   RefVal;             // Not exposed yet, for ImGuiInputTextFlags_ParseEmptyAsRefVal
    ImGuiID                StorageId;          // Set by SetNextItemStorageID()
};
CIMGUI_API void ImGuiNextItemData_ClearFlags(ImGuiNextItemData* self);  // Also cleared manually by ItemAdd()!

// Status storage for the last submitted item
struct ImGuiLastItemData_t
{
    ImGuiID              ID;
    ImGuiItemFlags       ItemFlags;    // See ImGuiItemFlags_ (called 'InFlags' before v1.91.4).
    ImGuiItemStatusFlags StatusFlags;  // See ImGuiItemStatusFlags_
    ImRect               Rect;         // Full rectangle
    ImRect               NavRect;      // Navigation scoring rectangle (not displayed)
    // Rarely used fields are not explicitly cleared, only valid when the corresponding ImGuiItemStatusFlags are set.
    ImRect               DisplayRect;  // Display rectangle. ONLY VALID IF (StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) is set.
    ImRect               ClipRect;     // Clip rectangle at the time of submitting item. ONLY VALID IF (StatusFlags & ImGuiItemStatusFlags_HasClipRect) is set..
    ImGuiKeyChord        Shortcut;     // Shortcut at the time of submitting item. ONLY VALID IF (StatusFlags & ImGuiItemStatusFlags_HasShortcut) is set..
};

// Store data emitted by TreeNode() for usage by TreePop()
// - To implement ImGuiTreeNodeFlags_NavLeftJumpsToParent: store the minimum amount of data
//   which we can't infer in TreePop(), to perform the equivalent of NavApplyItemToResult().
//   Only stored when the node is a potential candidate for landing on a Left arrow jump.
struct ImGuiTreeNodeStackData_t
{
    ImGuiID             ID;
    ImGuiTreeNodeFlags  TreeFlags;
    ImGuiItemFlags      ItemFlags;  // Used for nav landing
    ImRect              NavRect;    // Used for nav landing
    float               DrawLinesX1;
    float               DrawLinesToNodesY2;
    ImGuiTableColumnIdx DrawLinesTableColumn;
};

// sizeof() = 20
struct ImGuiErrorRecoveryState_t
{
    short SizeOfWindowStack;
    short SizeOfIDStack;
    short SizeOfTreeStack;
    short SizeOfColorStack;
    short SizeOfStyleVarStack;
    short SizeOfFontStack;
    short SizeOfFocusScopeStack;
    short SizeOfGroupStack;
    short SizeOfItemFlagsStack;
    short SizeOfBeginPopupStack;
    short SizeOfDisabledStack;
};

// Data saved for each window pushed into the stack
struct ImGuiWindowStackData_t
{
    ImGuiWindow*            Window;
    ImGuiLastItemData       ParentLastItemDataBackup;
    ImGuiErrorRecoveryState StackSizesInBegin;         // Store size of various stacks for asserting
    bool                    DisabledOverrideReenable;  // Non-child window override disabled flag
    float                   DisabledOverrideReenableAlphaBackup;
};

struct ImGuiShrinkWidthItem_t
{
    int   Index;
    float Width;
    float InitialWidth;
};

struct ImGuiPtrOrIndex_t
{
    void* Ptr;    // Either field can be set, not both. e.g. Dock node tab bars are loose while BeginTabBar() ones are in a pool.
    int   Index;  // Usually index in a main pool.
};

// Data used by IsItemDeactivated()/IsItemDeactivatedAfterEdit() functions
struct ImGuiDeactivatedItemData_t
{
    ImGuiID ID;
    int     ElapseFrame;
    bool    HasBeenEditedBefore;
    bool    IsAlive;
};

//-----------------------------------------------------------------------------
// [SECTION] Popup support
//-----------------------------------------------------------------------------

typedef enum
{
    ImGuiPopupPositionPolicy_Default,
    ImGuiPopupPositionPolicy_ComboBox,
    ImGuiPopupPositionPolicy_Tooltip,
} ImGuiPopupPositionPolicy;

// Storage for popup stacks (g.OpenPopupStack and g.BeginPopupStack)
struct ImGuiPopupData_t
{
    ImGuiID      PopupId;           // Set on OpenPopup()
    ImGuiWindow* Window;            // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
    ImGuiWindow* RestoreNavWindow;  // Set on OpenPopup(), a NavWindow that will be restored on popup close
    int          ParentNavLayer;    // Resolved on BeginPopup(). Actually a ImGuiNavLayer type (declared down below), initialized to -1 which is not part of an enum, but serves well-enough as "not any of layers" value
    int          OpenFrameCount;    // Set on OpenPopup()
    ImGuiID      OpenParentId;      // Set on OpenPopup(), we need this to differentiate multiple menu sets from each others (e.g. inside menu bar vs loose menu items)
    ImVec2       OpenPopupPos;      // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse)
    ImVec2       OpenMousePos;      // Set on OpenPopup(), copy of mouse position at the time of opening popup
};

//-----------------------------------------------------------------------------
// [SECTION] Inputs support
//-----------------------------------------------------------------------------

typedef struct ImBitArrayForNamedKeys_t
{
    char __dummy[20];
} ImBitArrayForNamedKeys;

// [Internal] Key ranges
#define ImGuiKey_LegacyNativeKey_BEGIN  0
#define ImGuiKey_LegacyNativeKey_END    512
#define ImGuiKey_Keyboard_BEGIN         (ImGuiKey_NamedKey_BEGIN)
#define ImGuiKey_Keyboard_END           (ImGuiKey_GamepadStart)
#define ImGuiKey_Gamepad_BEGIN          (ImGuiKey_GamepadStart)
#define ImGuiKey_Gamepad_END            (ImGuiKey_GamepadRStickDown + 1)
#define ImGuiKey_Mouse_BEGIN            (ImGuiKey_MouseLeft)
#define ImGuiKey_Mouse_END              (ImGuiKey_MouseWheelY + 1)
#define ImGuiKey_Aliases_BEGIN          (ImGuiKey_Mouse_BEGIN)
#define ImGuiKey_Aliases_END            (ImGuiKey_Mouse_END)

// [Internal] Named shortcuts for Navigation
#define ImGuiKey_NavKeyboardTweakSlow   ImGuiMod_Ctrl
#define ImGuiKey_NavKeyboardTweakFast   ImGuiMod_Shift
#define ImGuiKey_NavGamepadTweakSlow    ImGuiKey_GamepadL1
#define ImGuiKey_NavGamepadTweakFast    ImGuiKey_GamepadR1
#define ImGuiKey_NavGamepadActivate     (g.IO.ConfigNavSwapGamepadButtons ? ImGuiKey_GamepadFaceRight : ImGuiKey_GamepadFaceDown)
#define ImGuiKey_NavGamepadCancel       (g.IO.ConfigNavSwapGamepadButtons ? ImGuiKey_GamepadFaceDown : ImGuiKey_GamepadFaceRight)
#define ImGuiKey_NavGamepadMenu         ImGuiKey_GamepadFaceLeft
#define ImGuiKey_NavGamepadInput        ImGuiKey_GamepadFaceUp

typedef enum
{
    ImGuiInputEventType_None          = 0,
    ImGuiInputEventType_MousePos,
    ImGuiInputEventType_MouseWheel,
    ImGuiInputEventType_MouseButton,
    ImGuiInputEventType_MouseViewport,
    ImGuiInputEventType_Key,
    ImGuiInputEventType_Text,
    ImGuiInputEventType_Focus,
    ImGuiInputEventType_COUNT,
} ImGuiInputEventType;

typedef enum
{
    ImGuiInputSource_None     = 0,
    ImGuiInputSource_Mouse,  // Note: may be Mouse or TouchScreen or Pen. See io.MouseSource to distinguish them.
    ImGuiInputSource_Keyboard,
    ImGuiInputSource_Gamepad,
    ImGuiInputSource_COUNT,
} ImGuiInputSource;

// FIXME: Structures in the union below need to be declared as anonymous unions appears to be an extension?
// Using ImVec2() would fail on Clang 'union member 'MousePos' has a non-trivial default constructor'
struct ImGuiInputEventMousePos_t
{
    float            PosX, PosY;
    ImGuiMouseSource MouseSource;
};
struct ImGuiInputEventMouseWheel_t
{
    float            WheelX, WheelY;
    ImGuiMouseSource MouseSource;
};
struct ImGuiInputEventMouseButton_t
{
    int              Button;
    bool             Down;
    ImGuiMouseSource MouseSource;
};
struct ImGuiInputEventMouseViewport_t
{
    ImGuiID HoveredViewportID;
};
struct ImGuiInputEventKey_t
{
    ImGuiKey Key;
    bool     Down;
    float    AnalogValue;
};
struct ImGuiInputEventText_t
{
    unsigned int Char;
};
struct ImGuiInputEventAppFocused_t
{
    bool Focused;
};

struct ImGuiInputEvent_t
{
    ImGuiInputEventType          Type;
    ImGuiInputSource             Source;
    ImU32                        EventId;        // Unique, sequential increasing integer to identify an event (if you need to correlate them to other data).
    union
    {
        ImGuiInputEventMousePos      MousePos;       // if Type == ImGuiInputEventType_MousePos
        ImGuiInputEventMouseWheel    MouseWheel;     // if Type == ImGuiInputEventType_MouseWheel
        ImGuiInputEventMouseButton   MouseButton;    // if Type == ImGuiInputEventType_MouseButton
        ImGuiInputEventMouseViewport MouseViewport;  // if Type == ImGuiInputEventType_MouseViewport
        ImGuiInputEventKey           Key;            // if Type == ImGuiInputEventType_Key
        ImGuiInputEventText          Text;           // if Type == ImGuiInputEventType_Text
        ImGuiInputEventAppFocused    AppFocused;     // if Type == ImGuiInputEventType_Focus
    };
    bool                         AddedByTestEngine;
};

// Input function taking an 'ImGuiID owner_id' argument defaults to (ImGuiKeyOwner_Any == 0) aka don't test ownership, which matches legacy behavior.
#define ImGuiKeyOwner_Any           ((ImGuiID)0)     // Accept key that have an owner, UNLESS a call to SetKeyOwner() explicitly used ImGuiInputFlags_LockThisFrame or ImGuiInputFlags_LockUntilRelease.
#define ImGuiKeyOwner_NoOwner       ((ImGuiID)-1)    // Require key to have no owner.
//#define ImGuiKeyOwner_None ImGuiKeyOwner_NoOwner  // We previously called this 'ImGuiKeyOwner_None' but it was inconsistent with our pattern that _None values == 0 and quite dangerous. Also using _NoOwner makes the IsKeyPressed() calls more explicit.

typedef ImS16 ImGuiKeyRoutingIndex;

// Routing table entry (sizeof() == 16 bytes)
struct ImGuiKeyRoutingData_t
{
    ImGuiKeyRoutingIndex NextEntryIndex;
    ImU16                Mods;              // Technically we'd only need 4-bits but for simplify we store ImGuiMod_ values which need 16-bits.
    ImU16                RoutingCurrScore;  // [DEBUG] For debug display
    ImU16                RoutingNextScore;  // Lower is better (0: perfect score)
    ImGuiID              RoutingCurr;
    ImGuiID              RoutingNext;
};

// Routing table: maintain a desired owner for each possible key-chord (key + mods), and setup owner in NewFrame() when mods are matching.
// Stored in main context (1 instance)
struct ImGuiKeyRoutingTable_t
{
    ImGuiKeyRoutingIndex         Index[ImGuiKey_NamedKey_COUNT];  // Index of first entry in Entries[]
    ImVector_ImGuiKeyRoutingData Entries;
    ImVector_ImGuiKeyRoutingData EntriesNext;                     // Double-buffer to avoid reallocation (could use a shared buffer)
};
CIMGUI_API void ImGuiKeyRoutingTable_Clear(ImGuiKeyRoutingTable* self);

// This extends ImGuiKeyData but only for named keys (legacy keys don't support the new features)
// Stored in main context (1 per named key). In the future it might be merged into ImGuiKeyData.
struct ImGuiKeyOwnerData_t
{
    ImGuiID OwnerCurr;
    ImGuiID OwnerNext;
    bool    LockThisFrame;     // Reading this key requires explicit owner id (until end of frame). Set by ImGuiInputFlags_LockThisFrame.
    bool    LockUntilRelease;  // Reading this key requires explicit owner id (until key is released). Set by ImGuiInputFlags_LockUntilRelease. When this is true LockThisFrame is always true as well.
};

// Extend ImGuiInputFlags_
// Flags for extended versions of IsKeyPressed(), IsMouseClicked(), Shortcut(), SetKeyOwner(), SetItemKeyOwner()
// Don't mistake with ImGuiInputTextFlags! (which is for ImGui::InputText() function)
typedef enum
{
    // Flags for IsKeyPressed(), IsKeyChordPressed(), IsMouseClicked(), Shortcut()
    // - Repeat mode: Repeat rate selection
    ImGuiInputFlags_RepeatRateDefault                = 1<<1,   // Repeat rate: Regular (default)
    ImGuiInputFlags_RepeatRateNavMove                = 1<<2,   // Repeat rate: Fast
    ImGuiInputFlags_RepeatRateNavTweak               = 1<<3,   // Repeat rate: Faster
    // - Repeat mode: Specify when repeating key pressed can be interrupted.
    // - In theory ImGuiInputFlags_RepeatUntilOtherKeyPress may be a desirable default, but it would break too many behavior so everything is opt-in.
    ImGuiInputFlags_RepeatUntilRelease               = 1<<4,   // Stop repeating when released (default for all functions except Shortcut). This only exists to allow overriding Shortcut() default behavior.
    ImGuiInputFlags_RepeatUntilKeyModsChange         = 1<<5,   // Stop repeating when released OR if keyboard mods are changed (default for Shortcut)
    ImGuiInputFlags_RepeatUntilKeyModsChangeFromNone = 1<<6,   // Stop repeating when released OR if keyboard mods are leaving the None state. Allows going from Mod+Key to Key by releasing Mod.
    ImGuiInputFlags_RepeatUntilOtherKeyPress         = 1<<7,   // Stop repeating when released OR if any other keyboard key is pressed during the repeat

    // Flags for SetKeyOwner(), SetItemKeyOwner()
    // - Locking key away from non-input aware code. Locking is useful to make input-owner-aware code steal keys from non-input-owner-aware code. If all code is input-owner-aware locking would never be necessary.
    ImGuiInputFlags_LockThisFrame                    = 1<<20,  // Further accesses to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared at end of frame.
    ImGuiInputFlags_LockUntilRelease                 = 1<<21,  // Further accesses to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared when the key is released or at end of each frame if key is released.

    // - Condition for SetItemKeyOwner()
    ImGuiInputFlags_CondHovered                      = 1<<22,  // Only set if item is hovered (default to both)
    ImGuiInputFlags_CondActive                       = 1<<23,  // Only set if item is active (default to both)
    ImGuiInputFlags_CondDefault_                     = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,

    // [Internal] Mask of which function support which flags
    ImGuiInputFlags_RepeatRateMask_                  = ImGuiInputFlags_RepeatRateDefault | ImGuiInputFlags_RepeatRateNavMove | ImGuiInputFlags_RepeatRateNavTweak,
    ImGuiInputFlags_RepeatUntilMask_                 = ImGuiInputFlags_RepeatUntilRelease | ImGuiInputFlags_RepeatUntilKeyModsChange | ImGuiInputFlags_RepeatUntilKeyModsChangeFromNone | ImGuiInputFlags_RepeatUntilOtherKeyPress,
    ImGuiInputFlags_RepeatMask_                      = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateMask_ | ImGuiInputFlags_RepeatUntilMask_,
    ImGuiInputFlags_CondMask_                        = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,
    ImGuiInputFlags_RouteTypeMask_                   = ImGuiInputFlags_RouteActive | ImGuiInputFlags_RouteFocused | ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteAlways,
    ImGuiInputFlags_RouteOptionsMask_                = ImGuiInputFlags_RouteOverFocused | ImGuiInputFlags_RouteOverActive | ImGuiInputFlags_RouteUnlessBgFocused | ImGuiInputFlags_RouteFromRootWindow,
    ImGuiInputFlags_SupportedByIsKeyPressed          = ImGuiInputFlags_RepeatMask_,
    ImGuiInputFlags_SupportedByIsMouseClicked        = ImGuiInputFlags_Repeat,
    ImGuiInputFlags_SupportedByShortcut              = ImGuiInputFlags_RepeatMask_ | ImGuiInputFlags_RouteTypeMask_ | ImGuiInputFlags_RouteOptionsMask_,
    ImGuiInputFlags_SupportedBySetNextItemShortcut   = ImGuiInputFlags_RepeatMask_ | ImGuiInputFlags_RouteTypeMask_ | ImGuiInputFlags_RouteOptionsMask_ | ImGuiInputFlags_Tooltip,
    ImGuiInputFlags_SupportedBySetKeyOwner           = ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease,
    ImGuiInputFlags_SupportedBySetItemKeyOwner       = ImGuiInputFlags_SupportedBySetKeyOwner | ImGuiInputFlags_CondMask_,
} ImGuiInputFlagsPrivate_;

//-----------------------------------------------------------------------------
// [SECTION] Clipper support
//-----------------------------------------------------------------------------

// Note that Max is exclusive, so perhaps should be using a Begin/End convention.
struct ImGuiListClipperRange_t
{
    int  Min;
    int  Max;
    bool PosToIndexConvert;    // Begin/End are absolute position (will be converted to indices later)
    ImS8 PosToIndexOffsetMin;  // Add to Min after converting to indices
    ImS8 PosToIndexOffsetMax;  // Add to Min after converting to indices
};
CIMGUI_API ImGuiListClipperRange ImGuiListClipperRange_FromIndices(int min, int max);
CIMGUI_API ImGuiListClipperRange ImGuiListClipperRange_FromPositions(float y1, float y2, int off_min, int off_max);

// Temporary clipper data, buffers shared/reused between instances
struct ImGuiListClipperData_t
{
    ImGuiListClipper*              ListClipper;
    float                          LossynessOffset;
    int                            StepNo;
    int                            ItemsFrozen;
    ImVector_ImGuiListClipperRange Ranges;
};
CIMGUI_API void ImGuiListClipperData_Reset(ImGuiListClipperData* self, ImGuiListClipper* clipper);

//-----------------------------------------------------------------------------
// [SECTION] Navigation support
//-----------------------------------------------------------------------------

typedef enum
{
    ImGuiActivateFlags_None               = 0,
    ImGuiActivateFlags_PreferInput        = 1<<0,  // Favor activation that requires keyboard text input (e.g. for Slider/Drag). Default for Enter key.
    ImGuiActivateFlags_PreferTweak        = 1<<1,  // Favor activation for tweaking with arrows or gamepad (e.g. for Slider/Drag). Default for Space key and if keyboard is not used.
    ImGuiActivateFlags_TryToPreserveState = 1<<2,  // Request widget to preserve state if it can (e.g. InputText will try to preserve cursor/selection)
    ImGuiActivateFlags_FromTabbing        = 1<<3,  // Activation requested by a tabbing request (ImGuiNavMoveFlags_IsTabbing)
    ImGuiActivateFlags_FromShortcut       = 1<<4,  // Activation requested by an item shortcut via SetNextItemShortcut() function.
    ImGuiActivateFlags_FromFocusApi       = 1<<5,  // Activation requested by an api request (ImGuiNavMoveFlags_FocusApi)
} ImGuiActivateFlags_;

// Early work-in-progress API for ScrollToItem()
typedef enum
{
    ImGuiScrollFlags_None               = 0,
    ImGuiScrollFlags_KeepVisibleEdgeX   = 1<<0,  // If item is not visible: scroll as little as possible on X axis to bring item back into view [default for X axis]
    ImGuiScrollFlags_KeepVisibleEdgeY   = 1<<1,  // If item is not visible: scroll as little as possible on Y axis to bring item back into view [default for Y axis for windows that are already visible]
    ImGuiScrollFlags_KeepVisibleCenterX = 1<<2,  // If item is not visible: scroll to make the item centered on X axis [rarely used]
    ImGuiScrollFlags_KeepVisibleCenterY = 1<<3,  // If item is not visible: scroll to make the item centered on Y axis
    ImGuiScrollFlags_AlwaysCenterX      = 1<<4,  // Always center the result item on X axis [rarely used]
    ImGuiScrollFlags_AlwaysCenterY      = 1<<5,  // Always center the result item on Y axis [default for Y axis for appearing window)
    ImGuiScrollFlags_NoScrollParent     = 1<<6,  // Disable forwarding scrolling to parent window if required to keep item/rect visible (only scroll window the function was applied to).
    ImGuiScrollFlags_MaskX_             = ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleCenterX | ImGuiScrollFlags_AlwaysCenterX,
    ImGuiScrollFlags_MaskY_             = ImGuiScrollFlags_KeepVisibleEdgeY | ImGuiScrollFlags_KeepVisibleCenterY | ImGuiScrollFlags_AlwaysCenterY,
} ImGuiScrollFlags_;

typedef enum
{
    ImGuiNavRenderCursorFlags_None       = 0,
    ImGuiNavRenderCursorFlags_Compact    = 1<<1,                                  // Compact highlight, no padding/distance from focused item
    ImGuiNavRenderCursorFlags_AlwaysDraw = 1<<2,                                  // Draw rectangular highlight if (g.NavId == id) even when g.NavCursorVisible == false, aka even when using the mouse.
    ImGuiNavRenderCursorFlags_NoRounding = 1<<3,
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
    ImGuiNavHighlightFlags_None          = ImGuiNavRenderCursorFlags_None,        // Renamed in 1.91.4
    ImGuiNavHighlightFlags_Compact       = ImGuiNavRenderCursorFlags_Compact,     // Renamed in 1.91.4
    ImGuiNavHighlightFlags_AlwaysDraw    = ImGuiNavRenderCursorFlags_AlwaysDraw,  // Renamed in 1.91.4
    ImGuiNavHighlightFlags_NoRounding    = ImGuiNavRenderCursorFlags_NoRounding,  // Renamed in 1.91.4
    //ImGuiNavHighlightFlags_TypeThin       = ImGuiNavRenderCursorFlags_Compact,    // Renamed in 1.90.2
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
} ImGuiNavRenderCursorFlags_;

typedef enum
{
    ImGuiNavMoveFlags_None                  = 0,
    ImGuiNavMoveFlags_LoopX                 = 1<<0,   // On failed request, restart from opposite side
    ImGuiNavMoveFlags_LoopY                 = 1<<1,
    ImGuiNavMoveFlags_WrapX                 = 1<<2,   // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left)
    ImGuiNavMoveFlags_WrapY                 = 1<<3,   // This is not super useful but provided for completeness
    ImGuiNavMoveFlags_WrapMask_             = ImGuiNavMoveFlags_LoopX | ImGuiNavMoveFlags_LoopY | ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_WrapY,
    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)
    ImGuiNavMoveFlags_AlsoScoreVisibleSet   = 1<<5,   // Store alternate result in NavMoveResultLocalVisible that only comprise elements that are already fully visible (used by PageUp/PageDown)
    ImGuiNavMoveFlags_ScrollToEdgeY         = 1<<6,   // Force scrolling to min/max (used by Home/End) // FIXME-NAV: Aim to remove or reword as ImGuiScrollFlags
    ImGuiNavMoveFlags_Forwarded             = 1<<7,
    ImGuiNavMoveFlags_DebugNoResult         = 1<<8,   // Dummy scoring for debug purpose, don't apply result
    ImGuiNavMoveFlags_FocusApi              = 1<<9,   // Requests from focus API can land/focus/activate items even if they are marked with _NoTabStop (see NavProcessItemForTabbingRequest() for details)
    ImGuiNavMoveFlags_IsTabbing             = 1<<10,  // == Focus + Activate if item is Inputable + DontChangeNavHighlight
    ImGuiNavMoveFlags_IsPageMove            = 1<<11,  // Identify a PageDown/PageUp request.
    ImGuiNavMoveFlags_Activate              = 1<<12,  // Activate/select target item.
    ImGuiNavMoveFlags_NoSelect              = 1<<13,  // Don't trigger selection by not setting g.NavJustMovedTo
    ImGuiNavMoveFlags_NoSetNavCursorVisible = 1<<14,  // Do not alter the nav cursor visible state
    ImGuiNavMoveFlags_NoClearActiveId       = 1<<15,  // (Experimental) Do not clear active id when applying move result
} ImGuiNavMoveFlags_;

typedef enum
{
    ImGuiNavLayer_Main  = 0,  // Main scrolling layer
    ImGuiNavLayer_Menu  = 1,  // Menu layer (access with Alt)
    ImGuiNavLayer_COUNT,
} ImGuiNavLayer;

// Storage for navigation query/results
struct ImGuiNavItemData_t
{
    ImGuiWindow*           Window;             // Init,Move    // Best candidate window (result->ItemWindow->RootWindowForNav == request->Window)
    ImGuiID                ID;                 // Init,Move    // Best candidate item ID
    ImGuiID                FocusScopeId;       // Init,Move    // Best candidate focus scope ID
    ImRect                 RectRel;            // Init,Move    // Best candidate bounding box in window relative space
    ImGuiItemFlags         ItemFlags;          // ????,Move    // Best candidate item flags
    float                  DistBox;            //      Move    // Best candidate box distance to current NavId
    float                  DistCenter;         //      Move    // Best candidate center distance to current NavId
    float                  DistAxial;          //      Move    // Best candidate axial distance to current NavId
    ImGuiSelectionUserData SelectionUserData;  //I+Mov    // Best candidate SetNextItemSelectionUserData() value. Valid if (ItemFlags & ImGuiItemFlags_HasSelectionUserData)
};
CIMGUI_API void ImGuiNavItemData_Clear(ImGuiNavItemData* self);

// Storage for PushFocusScope(), g.FocusScopeStack[], g.NavFocusRoute[]
struct ImGuiFocusScopeData_t
{
    ImGuiID ID;
    ImGuiID WindowID;
};

//-----------------------------------------------------------------------------
// [SECTION] Typing-select support
//-----------------------------------------------------------------------------

// Flags for GetTypingSelectRequest()
typedef enum
{
    ImGuiTypingSelectFlags_None                = 0,
    ImGuiTypingSelectFlags_AllowBackspace      = 1<<0,  // Backspace to delete character inputs. If using: ensure GetTypingSelectRequest() is not called more than once per frame (filter by e.g. focus state)
    ImGuiTypingSelectFlags_AllowSingleCharMode = 1<<1,  // Allow "single char" search mode which is activated when pressing the same character multiple times.
} ImGuiTypingSelectFlags_;

// Returned by GetTypingSelectRequest(), designed to eventually be public.
struct ImGuiTypingSelectRequest_t
{
    ImGuiTypingSelectFlags Flags;           // Flags passed to GetTypingSelectRequest()
    int                    SearchBufferLen;
    const char*            SearchBuffer;    // Search buffer contents (use full string. unless SingleCharMode is set, in which case use SingleCharSize).
    bool                   SelectRequest;   // Set when buffer was modified this frame, requesting a selection.
    bool                   SingleCharMode;  // Notify when buffer contains same character repeated, to implement special mode. In this situation it preferred to not display any on-screen search indication.
    ImS8                   SingleCharSize;  // Length in bytes of first letter codepoint (1 for ascii, 2-4 for UTF-8). If (SearchBufferLen==RepeatCharSize) only 1 letter has been input.
};

// Storage for GetTypingSelectRequest()
struct ImGuiTypingSelectState_t
{
    ImGuiTypingSelectRequest Request;                           // User-facing data
    char                     SearchBuffer[64];                  // Search buffer: no need to make dynamic as this search is very transient.
    ImGuiID                  FocusScope;
    int                      LastRequestFrame /* = 0 */;
    float                    LastRequestTime /* = 0.0f */;
    bool                     SingleCharModeLock /* = false */;  // After a certain single char repeat count we lock into SingleCharMode. Two benefits: 1) buffer never fill, 2) we can provide an immediate SingleChar mode without timer elapsing.
};
CIMGUI_API void ImGuiTypingSelectState_Clear(ImGuiTypingSelectState* self);  // We preserve remaining data for easier debugging

//-----------------------------------------------------------------------------
// [SECTION] Columns support
//-----------------------------------------------------------------------------

// Flags for internal's BeginColumns(). This is an obsolete API. Prefer using BeginTable() nowadays!
typedef enum
{
    ImGuiOldColumnFlags_None                   = 0,
    ImGuiOldColumnFlags_NoBorder               = 1<<0,  // Disable column dividers
    ImGuiOldColumnFlags_NoResize               = 1<<1,  // Disable resizing columns when clicking on the dividers
    ImGuiOldColumnFlags_NoPreserveWidths       = 1<<2,  // Disable column width preservation when adjusting columns
    ImGuiOldColumnFlags_NoForceWithinWindow    = 1<<3,  // Disable forcing columns to fit within window
    ImGuiOldColumnFlags_GrowParentContentsSize = 1<<4,  // Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
} ImGuiOldColumnFlags_;

struct ImGuiOldColumnData_t
{
    float               OffsetNorm;  // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
    float               OffsetNormBeforeResize;
    ImGuiOldColumnFlags Flags;       // Not exposed
    ImRect              ClipRect;
};

struct ImGuiOldColumns_t
{
    ImGuiID                     ID;
    ImGuiOldColumnFlags         Flags;
    bool                        IsFirstFrame;
    bool                        IsBeingResized;
    int                         Current;
    int                         Count;
    float                       OffMinX, OffMaxX;          // Offsets from HostWorkRect.Min.x
    float                       LineMinY, LineMaxY;
    float                       HostCursorPosY;            // Backup of CursorPos at the time of BeginColumns()
    float                       HostCursorMaxPosX;         // Backup of CursorMaxPos at the time of BeginColumns()
    ImRect                      HostInitialClipRect;       // Backup of ClipRect at the time of BeginColumns()
    ImRect                      HostBackupClipRect;        // Backup of ClipRect during PushColumnsBackground()/PopColumnsBackground()
    ImRect                      HostBackupParentWorkRect;  //Backup of WorkRect at the time of BeginColumns()
    ImVector_ImGuiOldColumnData Columns;
    ImDrawListSplitter          Splitter;
};

//-----------------------------------------------------------------------------
// [SECTION] Box-select support
//-----------------------------------------------------------------------------

struct ImGuiBoxSelectState_t
{
    // Active box-selection data (persistent, 1 active at a time)
    ImGuiID       ID;
    bool          IsActive;
    bool          IsStarting;
    bool          IsStartedFromVoid;  // Starting click was not from an item.
    bool          IsStartedSetNavIdOnce;
    bool          RequestClear;
    ImGuiKeyChord KeyMods : 16;       // Latched key-mods for box-select logic.
    ImVec2        StartPosRel;        // Start position in window-contents relative space (to support scrolling)
    ImVec2        EndPosRel;          // End position in window-contents relative space
    ImVec2        ScrollAccum;        // Scrolling accumulator (to behave at high-frame spaces)
    ImGuiWindow*  Window;

    // Temporary/Transient data
    bool          UnclipMode;         // (Temp/Transient, here in hot area). Set/cleared by the BeginMultiSelect()/EndMultiSelect() owning active box-select.
    ImRect        UnclipRect;         // Rectangle where ItemAdd() clipping may be temporarily disabled. Need support by multi-select supporting widgets.
    ImRect        BoxSelectRectPrev;  // Selection rectangle in absolute coordinates (derived every frame from BoxSelectStartPosRel and MousePos)
    ImRect        BoxSelectRectCurr;
};

//-----------------------------------------------------------------------------
// [SECTION] Multi-select support
//-----------------------------------------------------------------------------

// We always assume that -1 is an invalid value (which works for indices and pointers)
#define ImGuiSelectionUserData_Invalid        ((ImGuiSelectionUserData)-1)

// Temporary storage for multi-select
struct ImGuiMultiSelectTempData_t
{
    ImGuiMultiSelectIO     IO;                  // MUST BE FIRST FIELD. Requests are set and returned by BeginMultiSelect()/EndMultiSelect() + written to by user during the loop.
    ImGuiMultiSelectState* Storage;
    ImGuiID                FocusScopeId;        // Copied from g.CurrentFocusScopeId (unless another selection scope was pushed manually)
    ImGuiMultiSelectFlags  Flags;
    ImVec2                 ScopeRectMin;
    ImVec2                 BackupCursorMaxPos;
    ImGuiSelectionUserData LastSubmittedItem;   // Copy of last submitted item data, used to merge output ranges.
    ImGuiID                BoxSelectId;
    ImGuiKeyChord          KeyMods;
    ImS8                   LoopRequestSetAll;   // -1: no operation, 0: clear all, 1: select all.
    bool                   IsEndIO;             // Set when switching IO from BeginMultiSelect() to EndMultiSelect() state.
    bool                   IsFocused;           // Set if currently focusing the selection scope (any item of the selection). May be used if you have custom shortcut associated to selection.
    bool                   IsKeyboardSetRange;  // Set by BeginMultiSelect() when using Shift+Navigation. Because scrolling may be affected we can't afford a frame of lag with Shift+Navigation.
    bool                   NavIdPassedBy;
    bool                   RangeSrcPassedBy;    // Set by the item that matches RangeSrcItem.
    bool                   RangeDstPassedBy;    // Set by the item that matches NavJustMovedToId when IsSetRange is set.
};
CIMGUI_API void ImGuiMultiSelectTempData_Clear(ImGuiMultiSelectTempData* self);    // Zero-clear except IO as we preserve IO.Requests[] buffer allocation.
CIMGUI_API void ImGuiMultiSelectTempData_ClearIO(ImGuiMultiSelectTempData* self);

// Persistent storage for multi-select (as long as selection is alive)
struct ImGuiMultiSelectState_t
{
    ImGuiWindow*           Window;
    ImGuiID                ID;
    int                    LastFrameActive;    // Last used frame-count, for GC.
    int                    LastSelectionSize;  // Set by BeginMultiSelect() based on optional info provided by user. May be -1 if unknown.
    ImS8                   RangeSelected;      // -1 (don't have) or true/false
    ImS8                   NavIdSelected;      // -1 (don't have) or true/false
    ImGuiSelectionUserData RangeSrcItem;       //
    ImGuiSelectionUserData NavIdItem;          // SetNextItemSelectionUserData() value for NavId (if part of submitted items)
};

//-----------------------------------------------------------------------------
// [SECTION] Docking support
//-----------------------------------------------------------------------------

#define DOCKING_HOST_DRAW_CHANNEL_BG 0   // Dock host: background fill
#define DOCKING_HOST_DRAW_CHANNEL_FG 1   // Dock host: decorations and contents

#ifdef IMGUI_HAS_DOCK
// Extend ImGuiDockNodeFlags_
typedef enum
{
    // [Internal]
    ImGuiDockNodeFlags_DockSpace                 = 1<<10,  // Saved // A dockspace is a node that occupy space within an existing user window. Otherwise the node is floating and create its own window.
    ImGuiDockNodeFlags_CentralNode               = 1<<11,  // Saved // The central node has 2 main properties: stay visible when empty, only use "remaining" spaces from its neighbor.
    ImGuiDockNodeFlags_NoTabBar                  = 1<<12,  // Saved // Tab bar is completely unavailable. No triangle in the corner to enable it back.
    ImGuiDockNodeFlags_HiddenTabBar              = 1<<13,  // Saved // Tab bar is hidden, with a triangle in the corner to show it again (NB: actual tab-bar instance may be destroyed as this is only used for single-window tab bar)
    ImGuiDockNodeFlags_NoWindowMenuButton        = 1<<14,  // Saved // Disable window/docking menu (that one that appears instead of the collapse button)
    ImGuiDockNodeFlags_NoCloseButton             = 1<<15,  // Saved // Disable close button
    ImGuiDockNodeFlags_NoResizeX                 = 1<<16,  //       //
    ImGuiDockNodeFlags_NoResizeY                 = 1<<17,  //       //
    ImGuiDockNodeFlags_DockedWindowsInFocusRoute = 1<<18,  //       // Any docked window will be automatically be focus-route chained (window->ParentWindowForFocusRoute set to this) so Shortcut() in this window can run when any docked window is focused.

    // Disable docking/undocking actions in this dockspace or individual node (existing docked nodes will be preserved)
    // Those are not exposed in public because the desirable sharing/inheriting/copy-flag-on-split behaviors are quite difficult to design and understand.
    // The two public flags ImGuiDockNodeFlags_NoDockingOverCentralNode/ImGuiDockNodeFlags_NoDockingSplit don't have those issues.
    ImGuiDockNodeFlags_NoDockingSplitOther       = 1<<19,  //       // Disable this node from splitting other windows/nodes.
    ImGuiDockNodeFlags_NoDockingOverMe           = 1<<20,  //       // Disable other windows/nodes from being docked over this node.
    ImGuiDockNodeFlags_NoDockingOverOther        = 1<<21,  //       // Disable this node from being docked over another window or non-empty node.
    ImGuiDockNodeFlags_NoDockingOverEmpty        = 1<<22,  //       // Disable this node from being docked over an empty node (e.g. DockSpace with no other windows)
    ImGuiDockNodeFlags_NoDocking                 = ImGuiDockNodeFlags_NoDockingOverMe | ImGuiDockNodeFlags_NoDockingOverOther | ImGuiDockNodeFlags_NoDockingOverEmpty | ImGuiDockNodeFlags_NoDockingSplit | ImGuiDockNodeFlags_NoDockingSplitOther,

    // Masks
    ImGuiDockNodeFlags_SharedFlagsInheritMask_   = ~0,
    ImGuiDockNodeFlags_NoResizeFlagsMask_        = (int)ImGuiDockNodeFlags_NoResize | ImGuiDockNodeFlags_NoResizeX | ImGuiDockNodeFlags_NoResizeY,

    // When splitting, those local flags are moved to the inheriting child, never duplicated
    ImGuiDockNodeFlags_LocalFlagsTransferMask_   = (int)ImGuiDockNodeFlags_NoDockingSplit | ImGuiDockNodeFlags_NoResizeFlagsMask_ |(int)ImGuiDockNodeFlags_AutoHideTabBar | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton,
    ImGuiDockNodeFlags_SavedFlagsMask_           = ImGuiDockNodeFlags_NoResizeFlagsMask_ | ImGuiDockNodeFlags_DockSpace | ImGuiDockNodeFlags_CentralNode | ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_HiddenTabBar | ImGuiDockNodeFlags_NoWindowMenuButton | ImGuiDockNodeFlags_NoCloseButton,
} ImGuiDockNodeFlagsPrivate_;

// Store the source authority (dock node vs window) of a field
typedef enum
{
    ImGuiDataAuthority_Auto,
    ImGuiDataAuthority_DockNode,
    ImGuiDataAuthority_Window,
} ImGuiDataAuthority_;

typedef enum
{
    ImGuiDockNodeState_Unknown,
    ImGuiDockNodeState_HostWindowHiddenBecauseSingleWindow,
    ImGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing,
    ImGuiDockNodeState_HostWindowVisible,
} ImGuiDockNodeState;

// sizeof() 156~192
struct ImGuiDockNode_t
{
    ImGuiID                 ID;
    ImGuiDockNodeFlags      SharedFlags;           // (Write) Flags shared by all nodes of a same dockspace hierarchy (inherited from the root node)
    ImGuiDockNodeFlags      LocalFlags;            // (Write) Flags specific to this node
    ImGuiDockNodeFlags      LocalFlagsInWindows;   // (Write) Flags specific to this node, applied from windows
    ImGuiDockNodeFlags      MergedFlags;           // (Read)  Effective flags (== SharedFlags | LocalFlagsInNode | LocalFlagsInWindows)
    ImGuiDockNodeState      State;
    ImGuiDockNode*          ParentNode;
    ImGuiDockNode*          ChildNodes[2];         // [Split node only] Child nodes (left/right or top/bottom). Consider switching to an array.
    ImVector_ImGuiWindowPtr Windows;               // Note: unordered list! Iterate TabBar->Tabs for user-order.
    ImGuiTabBar*            TabBar;
    ImVec2                  Pos;                   // Current position
    ImVec2                  Size;                  // Current size
    ImVec2                  SizeRef;               // [Split node only] Last explicitly written-to size (overridden when using a splitter affecting the node), used to calculate Size.
    ImGuiAxis               SplitAxis;             // [Split node only] Split axis (X or Y)
    ImGuiWindowClass        WindowClass;           // [Root node only]
    ImU32                   LastBgColor;

    ImGuiWindow*            HostWindow;
    ImGuiWindow*            VisibleWindow;         // Generally point to window which is ID is == SelectedTabID, but when CTRL+Tabbing this can be a different window.
    ImGuiDockNode*          CentralNode;           // [Root node only] Pointer to central node.
    ImGuiDockNode*          OnlyNodeWithWindows;   // [Root node only] Set when there is a single visible node within the hierarchy.
    int                     CountNodeWithWindows;  // [Root node only]
    int                     LastFrameAlive;        // Last frame number the node was updated or kept alive explicitly with DockSpace() + ImGuiDockNodeFlags_KeepAliveOnly
    int                     LastFrameActive;       // Last frame number the node was updated.
    int                     LastFrameFocused;      // Last frame number the node was focused.
    ImGuiID                 LastFocusedNodeId;     // [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
    ImGuiID                 SelectedTabId;         // [Leaf node only] Which of our tab/window is selected.
    ImGuiID                 WantCloseTabId;        // [Leaf node only] Set when closing a specific tab/window.
    ImGuiID                 RefViewportId;         // Reference viewport ID from visible window when HostWindow == NULL.
    ImGuiDataAuthority      AuthorityForPos : 3;
    ImGuiDataAuthority      AuthorityForSize : 3;
    ImGuiDataAuthority      AuthorityForViewport : 3;
    bool                    IsVisible : 1;         // Set to false when the node is hidden (usually disabled as it has no active window)
    bool                    IsFocused : 1;
    bool                    IsBgDrawnThisFrame : 1;
    bool                    HasCloseButton : 1;    // Provide space for a close button (if any of the docked window has one). Note that button may be hidden on window without one.
    bool                    HasWindowMenuButton : 1;
    bool                    HasCentralNodeChild : 1;
    bool                    WantCloseAll : 1;      // Set when closing all tabs at once.
    bool                    WantLockSizeOnce : 1;
    bool                    WantMouseMove : 1;     // After a node extraction we need to transition toward moving the newly created host window
    bool                    WantHiddenTabBarUpdate : 1;
    bool                    WantHiddenTabBarToggle : 1;
};
CIMGUI_API bool   ImGuiDockNode_IsRootNode(const ImGuiDockNode* self);
CIMGUI_API bool   ImGuiDockNode_IsDockSpace(const ImGuiDockNode* self);
CIMGUI_API bool   ImGuiDockNode_IsFloatingNode(const ImGuiDockNode* self);
CIMGUI_API bool   ImGuiDockNode_IsCentralNode(const ImGuiDockNode* self);
CIMGUI_API bool   ImGuiDockNode_IsHiddenTabBar(const ImGuiDockNode* self);                     // Hidden tab bar can be shown back by clicking the small triangle
CIMGUI_API bool   ImGuiDockNode_IsNoTabBar(const ImGuiDockNode* self);                         // Never show a tab bar
CIMGUI_API bool   ImGuiDockNode_IsSplitNode(const ImGuiDockNode* self);
CIMGUI_API bool   ImGuiDockNode_IsLeafNode(const ImGuiDockNode* self);
CIMGUI_API bool   ImGuiDockNode_IsEmpty(const ImGuiDockNode* self);
CIMGUI_API ImRect ImGuiDockNode_Rect(const ImGuiDockNode* self);
CIMGUI_API void   ImGuiDockNode_SetLocalFlags(ImGuiDockNode* self, ImGuiDockNodeFlags flags);
CIMGUI_API void   ImGuiDockNode_UpdateMergedFlags(ImGuiDockNode* self);

// List of colors that are stored at the time of Begin() into Docked Windows.
// We currently store the packed colors in a simple array window->DockStyle.Colors[].
// A better solution may involve appending into a log of colors in ImGuiContext + store offsets into those arrays in ImGuiWindow,
// but it would be more complex as we'd need to double-buffer both as e.g. drop target may refer to window from last frame.
typedef enum
{
    ImGuiWindowDockStyleCol_Text,
    ImGuiWindowDockStyleCol_TabHovered,
    ImGuiWindowDockStyleCol_TabFocused,
    ImGuiWindowDockStyleCol_TabSelected,
    ImGuiWindowDockStyleCol_TabSelectedOverline,
    ImGuiWindowDockStyleCol_TabDimmed,
    ImGuiWindowDockStyleCol_TabDimmedSelected,
    ImGuiWindowDockStyleCol_TabDimmedSelectedOverline,
    ImGuiWindowDockStyleCol_UnsavedMarker,
    ImGuiWindowDockStyleCol_COUNT,
} ImGuiWindowDockStyleCol;

// We don't store style.Alpha: dock_node->LastBgColor embeds it and otherwise it would only affect the docking tab, which intuitively I would say we don't want to.
struct ImGuiWindowDockStyle_t
{
    ImU32 Colors[ImGuiWindowDockStyleCol_COUNT];
};

struct ImGuiDockContext_t
{
    ImGuiStorage                   Nodes;  // Map ID -> ImGuiDockNode*: Active nodes
    ImVector_ImGuiDockRequest      Requests;
    ImVector_ImGuiDockNodeSettings NodesSettings;
    bool                           WantFullRebuild;
};
#endif// #ifdef IMGUI_HAS_DOCK
//-----------------------------------------------------------------------------
// [SECTION] Viewport support
//-----------------------------------------------------------------------------

// ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!)
// Every instance of ImGuiViewport is in fact a ImGuiViewportP.
struct ImGuiViewportP_t
{
    // Appended from parent type ImGuiViewport
    ImGuiID            ID;                         // Unique identifier for the viewport
    ImGuiViewportFlags Flags;                      // See ImGuiViewportFlags_
    ImVec2             Pos;                        // Main Area: Position of the viewport (Dear ImGui coordinates are the same as OS desktop/native coordinates)
    ImVec2             Size;                       // Main Area: Size of the viewport.
    ImVec2             FramebufferScale;           // Density of the viewport for Retina display (always 1,1 on Windows, may be 2,2 etc on macOS/iOS). This will affect font rasterizer density.
    ImVec2             WorkPos;                    // Work Area: Position of the viewport minus task bars, menus bars, status bars (>= Pos)
    ImVec2             WorkSize;                   // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size)
    float              DpiScale;                   // 1.0f = 96 DPI = No extra scale.
    ImGuiID            ParentViewportId;           // (Advanced) 0: no parent. Instruct the platform backend to setup a parent/child relationship between platform windows.
    ImGuiViewport*     ParentViewport;             // (Advanced) Direct shortcut to ImGui::FindViewportByID(ParentViewportId). NULL: no parent.
    ImDrawData*        DrawData;                   // The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame().
    // Platform/Backend Dependent Data
    // Our design separate the Renderer and Platform backends to facilitate combining default backends with each others.
    // When our create your own backend for a custom engine, it is possible that both Renderer and Platform will be handled
    // by the same system and you may not need to use all the UserData/Handle fields.
    // The library never uses those fields, they are merely storage to facilitate backend implementation.
    void*              RendererUserData;           // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function.
    void*              PlatformUserData;           // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function.
    void*              PlatformHandle;             // void* to hold higher-level, platform window handle (e.g. HWND for Win32 backend, Uint32 WindowID for SDL, GLFWWindow* for GLFW), for FindViewportByPlatformHandle().
    void*              PlatformHandleRaw;          // void* to hold lower-level, platform-native window handle (always HWND on Win32 platform, unused for other platforms).
    bool               PlatformWindowCreated;      // Platform window has been created (Platform_CreateWindow() has been called). This is false during the first frame where a viewport is being created.
    bool               PlatformRequestMove;        // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)
    bool               PlatformRequestResize;      // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size)
    bool               PlatformRequestClose;       // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)

    ImGuiWindow*       Window;                     // Set when the viewport is owned by a window (and ImGuiViewportFlags_CanHostOtherWindows is NOT set)
    int                Idx;
    int                LastFrameActive;            // Last frame number this viewport was activated by a window
    int                LastFocusedStampCount;      // Last stamp number from when a window hosted by this viewport was focused (by comparing this value between two viewport we have an implicit viewport z-order we use as fallback)
    ImGuiID            LastNameHash;
    ImVec2             LastPos;
    ImVec2             LastSize;
    float              Alpha;                      // Window opacity (when dragging dockable windows/viewports we make them transparent)
    float              LastAlpha;
    bool               LastFocusedHadNavWindow;    // Instead of maintaining a LastFocusedWindow (which may harder to correctly maintain), we merely store weither NavWindow != NULL last time the viewport was focused.
    short              PlatformMonitor;
    int                BgFgDrawListsLastFrame[2];  // Last frame number the background (0) and foreground (1) draw lists were used
    ImDrawList*        BgFgDrawLists[2];           // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
    ImDrawData         DrawDataP;
    ImDrawDataBuilder  DrawDataBuilder;            // Temporary data while building final ImDrawData
    ImVec2             LastPlatformPos;
    ImVec2             LastPlatformSize;
    ImVec2             LastRendererSize;

    // Per-viewport work area
    // - Insets are >= 0.0f values, distance from viewport corners to work area.
    // - BeginMainMenuBar() and DockspaceOverViewport() tend to use work area to avoid stepping over existing contents.
    // - Generally 'safeAreaInsets' in iOS land, 'DisplayCutout' in Android land.
    ImVec2             WorkInsetMin;               // Work Area inset locked for the frame. GetWorkRect() always fits within GetMainRect().
    ImVec2             WorkInsetMax;               // "
    ImVec2             BuildWorkInsetMin;          // Work Area inset accumulator for current frame, to become next frame's WorkInset
    ImVec2             BuildWorkInsetMax;          // "
};
CIMGUI_API void   ImGuiViewportP_ClearRequestFlags(ImGuiViewportP* self);
// Calculate work rect pos/size given a set of offset (we have 1 pair of offset for rect locked from last frame data, and 1 pair for currently building rect)
CIMGUI_API ImVec2 ImGuiViewportP_CalcWorkRectPos(const ImGuiViewportP* self, ImVec2 inset_min);
CIMGUI_API ImVec2 ImGuiViewportP_CalcWorkRectSize(const ImGuiViewportP* self, ImVec2 inset_min, ImVec2 inset_max);
CIMGUI_API void   ImGuiViewportP_UpdateWorkRect(ImGuiViewportP* self);          // Update public fields
// Helpers to retrieve ImRect (we don't need to store BuildWorkRect as every access tend to change it, hence the code asymmetry)
CIMGUI_API ImRect ImGuiViewportP_GetMainRect(const ImGuiViewportP* self);
CIMGUI_API ImRect ImGuiViewportP_GetWorkRect(const ImGuiViewportP* self);
CIMGUI_API ImRect ImGuiViewportP_GetBuildWorkRect(const ImGuiViewportP* self);

//-----------------------------------------------------------------------------
// [SECTION] Settings support
//-----------------------------------------------------------------------------

// Windows data saved in imgui.ini file
// Because we never destroy or rename ImGuiWindowSettings, we can store the names in a separate buffer easily.
// (this is designed to be stored in a ImChunkStream buffer, with the variable-length Name following our structure)
struct ImGuiWindowSettings_t
{
    ImGuiID  ID;
    ImVec2ih Pos;         // NB: Settings position are stored RELATIVE to the viewport! Whereas runtime ones are absolute positions.
    ImVec2ih Size;
    ImVec2ih ViewportPos;
    ImGuiID  ViewportId;
    ImGuiID  DockId;      // ID of last known DockNode (even if the DockNode is invisible because it has only 1 active window), or 0 if none.
    ImGuiID  ClassId;     // ID of window class if specified
    short    DockOrder;   // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
    bool     Collapsed;
    bool     IsChild;
    bool     WantApply;   // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context)
    bool     WantDelete;  // Set to invalidate/delete the settings entry
};
CIMGUI_API char* ImGuiWindowSettings_GetName(ImGuiWindowSettings* self);

struct ImGuiSettingsHandler_t
{
    const char*                                                          TypeName;                        // Short description stored in .ini file. Disallowed characters: '[' ']'
    ImGuiID                                                              TypeHash;                        // == ImHashStr(TypeName)
    void (*ClearAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler);                                 // Clear all settings data
    void (*ReadInitFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler);                                 // Read: Called before reading (in registration order)
    void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name);              // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
    void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line);  // Read: Called for every line of text within an ini entry
    void (*ApplyAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler);                                 // Read: Called after reading (in registration order)
    void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf);       // Write: Output every entries into 'out_buf'
    void*                                                                UserData;
};

//-----------------------------------------------------------------------------
// [SECTION] Localization support
//-----------------------------------------------------------------------------

// This is experimental and not officially supported, it'll probably fall short of features, if/when it does we may backtrack.
enum                                            // Forward declared enum type ImGuiLocKey
{
    ImGuiLocKey_VersionStr,
    ImGuiLocKey_TableSizeOne,
    ImGuiLocKey_TableSizeAllFit,
    ImGuiLocKey_TableSizeAllDefault,
    ImGuiLocKey_TableResetOrder,
    ImGuiLocKey_WindowingMainMenuBar,
    ImGuiLocKey_WindowingPopup,
    ImGuiLocKey_WindowingUntitled,
    ImGuiLocKey_OpenLink_s,
    ImGuiLocKey_CopyLink,
    ImGuiLocKey_DockingHideTabBar,
    ImGuiLocKey_DockingHoldShiftToDock,
    ImGuiLocKey_DockingDragToUndockOrMoveNode,
    ImGuiLocKey_COUNT,
};

struct ImGuiLocEntry_t
{
    ImGuiLocKey Key;
    const char* Text;
};

//-----------------------------------------------------------------------------
// [SECTION] Error handling, State recovery support
//-----------------------------------------------------------------------------

// Macros used by Recoverable Error handling
// - Only dispatch error if _EXPR: evaluate as assert (similar to an assert macro).
// - The message will always be a string literal, in order to increase likelihood of being display by an assert handler.
// - See 'Demo->Configuration->Error Handling' and ImGuiIO definitions for details on error handling.
// - Read https://github.com/ocornut/imgui/wiki/Error-Handling for details on error handling.
#ifndef IM_ASSERT_USER_ERROR
#define IM_ASSERT_USER_ERROR(_EXPR,_MSG)    do { if (!(_EXPR) && ImGui::ErrorLog(_MSG)) { IM_ASSERT((_EXPR) && _MSG); } } while (0)     // Recoverable User Error
#endif // #ifndef IM_ASSERT_USER_ERROR
// The error callback is currently not public, as it is expected that only advanced users will rely on it.
typedef void (*ImGuiErrorCallback)(ImGuiContext* ctx, void* user_data, const char* msg);  // Function signature for g.ErrorCallback

//-----------------------------------------------------------------------------
// [SECTION] Metrics, Debug Tools
//-----------------------------------------------------------------------------

// See IMGUI_DEBUG_LOG() and IMGUI_DEBUG_LOG_XXX() macros.
typedef enum
{
    // Event types
    ImGuiDebugLogFlags_None               = 0,
    ImGuiDebugLogFlags_EventError         = 1<<0,   // Error submitted by IM_ASSERT_USER_ERROR()
    ImGuiDebugLogFlags_EventActiveId      = 1<<1,
    ImGuiDebugLogFlags_EventFocus         = 1<<2,
    ImGuiDebugLogFlags_EventPopup         = 1<<3,
    ImGuiDebugLogFlags_EventNav           = 1<<4,
    ImGuiDebugLogFlags_EventClipper       = 1<<5,
    ImGuiDebugLogFlags_EventSelection     = 1<<6,
    ImGuiDebugLogFlags_EventIO            = 1<<7,
    ImGuiDebugLogFlags_EventFont          = 1<<8,
    ImGuiDebugLogFlags_EventInputRouting  = 1<<9,
    ImGuiDebugLogFlags_EventDocking       = 1<<10,
    ImGuiDebugLogFlags_EventViewport      = 1<<11,

    ImGuiDebugLogFlags_EventMask_         = ImGuiDebugLogFlags_EventError | ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO | ImGuiDebugLogFlags_EventFont | ImGuiDebugLogFlags_EventInputRouting | ImGuiDebugLogFlags_EventDocking | ImGuiDebugLogFlags_EventViewport,
    ImGuiDebugLogFlags_OutputToTTY        = 1<<20,  // Also send output to TTY
    ImGuiDebugLogFlags_OutputToTestEngine = 1<<21,  // Also send output to Test Engine
} ImGuiDebugLogFlags_;

struct ImGuiDebugAllocEntry_t
{
    int   FrameCount;
    ImS16 AllocCount;
    ImS16 FreeCount;
};

struct ImGuiDebugAllocInfo_t
{
    int                  TotalAllocCount;    // Number of call to MemAlloc().
    int                  TotalFreeCount;
    ImS16                LastEntriesIdx;     // Current index in buffer
    ImGuiDebugAllocEntry LastEntriesBuf[6];  // Track last 6 frames that had allocations
};

struct ImGuiMetricsConfig_t
{
    bool    ShowDebugLog /* = false */;
    bool    ShowIDStackTool /* = false */;
    bool    ShowWindowsRects /* = false */;
    bool    ShowWindowsBeginOrder /* = false */;
    bool    ShowTablesRects /* = false */;
    bool    ShowDrawCmdMesh /* = true */;
    bool    ShowDrawCmdBoundingBoxes /* = true */;
    bool    ShowTextEncodingViewer /* = false */;
    bool    ShowTextureUsedRect /* = false */;
    bool    ShowDockingNodes /* = false */;
    int     ShowWindowsRectsType /* = -1 */;
    int     ShowTablesRectsType /* = -1 */;
    int     HighlightMonitorIdx /* = -1 */;
    ImGuiID HighlightViewportID /* = 0 */;
    bool    ShowFontPreview /* = true */;
};

struct ImGuiStackLevelInfo_t
{
    ImGuiID ID;
    ImS8    QueryFrameCount;  // >= 1: Sub-query in progress
    bool    QuerySuccess;     // Sub-query obtained result from DebugHookIdInfo()
    ImS8    DataType;         // ImGuiDataType
    int     DescOffset;       // -1 or offset into parent's ResultsPathsBuf
};

struct ImGuiDebugItemPathQuery_t
{
    ImGuiID                      MainID;    // ID to query details for.
    bool                         Active;    // Used to disambiguate the case when ID == 0 and e.g. some code calls PushOverrideID(0).
    bool                         Complete;  // All sub-queries are finished (some may have failed).
    ImS8                         Step;      // -1: query stack + init Results, >= 0: filling individual stack level.
    ImVector_ImGuiStackLevelInfo Results;
    ImGuiTextBuffer              ResultsDescBuf;
    ImGuiTextBuffer              ResultPathBuf;
};

// State for ID Stack tool queries
struct ImGuiIDStackTool_t
{
    bool  OptHexEncodeNonAsciiChars;
    bool  OptCopyToClipboardOnCtrlC;
    int   LastActiveFrame;
    float CopyToClipboardLastTime;
};

//-----------------------------------------------------------------------------
// [SECTION] Generic context hooks
//-----------------------------------------------------------------------------

typedef void (*ImGuiContextHookCallback)(ImGuiContext* ctx, ImGuiContextHook* hook);
typedef enum
{
    ImGuiContextHookType_NewFramePre,
    ImGuiContextHookType_NewFramePost,
    ImGuiContextHookType_EndFramePre,
    ImGuiContextHookType_EndFramePost,
    ImGuiContextHookType_RenderPre,
    ImGuiContextHookType_RenderPost,
    ImGuiContextHookType_Shutdown,
    ImGuiContextHookType_PendingRemoval_,
} ImGuiContextHookType;

struct ImGuiContextHook_t
{
    ImGuiID                  HookId;  // A unique ID assigned by AddContextHook()
    ImGuiContextHookType     Type;
    ImGuiID                  Owner;
    ImGuiContextHookCallback Callback;
    void*                    UserData;
};

//-----------------------------------------------------------------------------
// [SECTION] ImGuiContext (main Dear ImGui context)
//-----------------------------------------------------------------------------

struct ImGuiContext_t
{
    bool                           Initialized;
    bool                           WithinFrameScope;                    // Set by NewFrame(), cleared by EndFrame()
    bool                           WithinFrameScopeWithImplicitWindow;  // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed
    bool                           TestEngineHookItems;                 // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log()
    int                            FrameCount;
    int                            FrameCountEnded;
    int                            FrameCountPlatformEnded;
    int                            FrameCountRendered;
    double                         Time;
    char                           ContextName[16];                     // Storage for a context name (to facilitate debugging multi-context setups)
    ImGuiIO                        IO;
    ImGuiPlatformIO                PlatformIO;
    ImGuiStyle                     Style;
    ImGuiConfigFlags               ConfigFlagsCurrFrame;                // = g.IO.ConfigFlags at the time of NewFrame()
    ImGuiConfigFlags               ConfigFlagsLastFrame;
    ImVector_ImFontAtlasPtr        FontAtlases;                         // List of font atlases used by the context (generally only contains g.IO.Fonts aka the main font atlas)
    ImFont*                        Font;                                // Currently bound font. (== FontStack.back().Font)
    ImFontBaked*                   FontBaked;                           // Currently bound font at currently bound size. (== Font->GetFontBaked(FontSize))
    float                          FontSize;                            // Currently bound font size == line height (== FontSizeBase + externals scales applied in the UpdateCurrentFontSize() function).
    float                          FontSizeBase;                        // Font size before scaling == style.FontSizeBase == value passed to PushFont() when specified.
    float                          FontBakedScale;                      // == FontBaked->Size / FontSize. Scale factor over baked size. Rarely used nowadays, very often == 1.0f.
    float                          FontRasterizerDensity;               // Current font density. Used by all calls to GetFontBaked().
    float                          CurrentDpiScale;                     // Current window/viewport DpiScale == CurrentViewport->DpiScale
    ImDrawListSharedData           DrawListSharedData;
    ImGuiID                        WithinEndChildID;                    // Set within EndChild()
    void*                          TestEngine;                          // Test engine user data

    // Inputs
    ImVector_ImGuiInputEvent       InputEventsQueue;                    // Input events which will be trickled/written into IO structure.
    ImVector_ImGuiInputEvent       InputEventsTrail;                    // Past input events processed in NewFrame(). This is to allow domain-specific application to access e.g mouse/pen trail.
    ImGuiMouseSource               InputEventsNextMouseSource;
    ImU32                          InputEventsNextEventId;

    // Windows state
    ImVector_ImGuiWindowPtr        Windows;                             // Windows, sorted in display order, back to front
    ImVector_ImGuiWindowPtr        WindowsFocusOrder;                   // Root windows, sorted in focus order, back to front.
    ImVector_ImGuiWindowPtr        WindowsTempSortBuffer;               // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child
    ImVector_ImGuiWindowStackData  CurrentWindowStack;
    ImGuiStorage                   WindowsById;                         // Map window's ImGuiID to ImGuiWindow*
    int                            WindowsActiveCount;                  // Number of unique windows submitted by frame
    float                          WindowsBorderHoverPadding;           // Padding around resizable windows for which hovering on counts as hovering the window == ImMax(style.TouchExtraPadding, style.WindowBorderHoverPadding). This isn't so multi-dpi friendly.
    ImGuiID                        DebugBreakInWindow;                  // Set to break in Begin() call.
    ImGuiWindow*                   CurrentWindow;                       // Window being drawn into
    ImGuiWindow*                   HoveredWindow;                       // Window the mouse is hovering. Will typically catch mouse inputs.
    ImGuiWindow*                   HoveredWindowUnderMovingWindow;      // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
    ImGuiWindow*                   HoveredWindowBeforeClear;            // Window the mouse is hovering. Filled even with _NoMouse. This is currently useful for multi-context compositors.
    ImGuiWindow*                   MovingWindow;                        // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindowDockTree.
    ImGuiWindow*                   WheelingWindow;                      // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
    ImVec2                         WheelingWindowRefMousePos;
    int                            WheelingWindowStartFrame;            // This may be set one frame before WheelingWindow is != NULL
    int                            WheelingWindowScrolledFrame;
    float                          WheelingWindowReleaseTimer;
    ImVec2                         WheelingWindowWheelRemainder;
    ImVec2                         WheelingAxisAvg;

    // Item/widgets state and tracking information
    ImGuiID                        DebugDrawIdConflictsId;              // Set when we detect multiple items with the same identifier
    ImGuiID                        DebugHookIdInfoId;                   // Will call core hooks: DebugHookIdInfo() from GetID functions, used by ID Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line]
    ImGuiID                        HoveredId;                           // Hovered widget, filled during the frame
    ImGuiID                        HoveredIdPreviousFrame;
    int                            HoveredIdPreviousFrameItemCount;     // Count numbers of items using the same ID as last frame's hovered id
    float                          HoveredIdTimer;                      // Measure contiguous hovering time
    float                          HoveredIdNotActiveTimer;             // Measure contiguous hovering time where the item has not been active
    bool                           HoveredIdAllowOverlap;
    bool                           HoveredIdIsDisabled;                 // At least one widget passed the rect test, but has been discarded by disabled flag or popup inhibit. May be true even if HoveredId == 0.
    bool                           ItemUnclipByLog;                     // Disable ItemAdd() clipping, essentially a memory-locality friendly copy of LogEnabled
    ImGuiID                        ActiveId;                            // Active widget
    ImGuiID                        ActiveIdIsAlive;                     // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
    float                          ActiveIdTimer;
    bool                           ActiveIdIsJustActivated;             // Set at the time of activation for one frame
    bool                           ActiveIdAllowOverlap;                // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
    bool                           ActiveIdNoClearOnFocusLoss;          // Disable losing active id if the active id window gets unfocused.
    bool                           ActiveIdHasBeenPressedBefore;        // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
    bool                           ActiveIdHasBeenEditedBefore;         // Was the value associated to the widget Edited over the course of the Active state.
    bool                           ActiveIdHasBeenEditedThisFrame;
    bool                           ActiveIdFromShortcut;
    ImS8                           ActiveIdMouseButton;
    ImGuiID                        ActiveIdDisabledId;                  // When clicking a disabled item we set ActiveId=window->MoveId to avoid interference with widget code. Actual item ID is stored here.
    ImVec2                         ActiveIdClickOffset;                 // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
    ImGuiInputSource               ActiveIdSource;                      // Activating source: ImGuiInputSource_Mouse OR ImGuiInputSource_Keyboard OR ImGuiInputSource_Gamepad
    ImGuiWindow*                   ActiveIdWindow;
    ImGuiID                        ActiveIdPreviousFrame;
    ImGuiDeactivatedItemData       DeactivatedItemData;
    ImGuiDataTypeStorage           ActiveIdValueOnActivation;           // Backup of initial value at the time of activation. ONLY SET BY SPECIFIC WIDGETS: DragXXX and SliderXXX.
    ImGuiID                        LastActiveId;                        // Store the last non-zero ActiveId, useful for animation.
    float                          LastActiveIdTimer;                   // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.

    // Key/Input Ownership + Shortcut Routing system
    // - The idea is that instead of "eating" a given key, we can link to an owner.
    // - Input query can then read input by specifying ImGuiKeyOwner_Any (== 0), ImGuiKeyOwner_NoOwner (== -1) or a custom ID.
    // - Routing is requested ahead of time for a given chord (Key + Mods) and granted in NewFrame().
    double                         LastKeyModsChangeTime;               // Record the last time key mods changed (affect repeat delay when using shortcut logic)
    double                         LastKeyModsChangeFromNoneTime;       // Record the last time key mods changed away from being 0 (affect repeat delay when using shortcut logic)
    double                         LastKeyboardKeyPressTime;            // Record the last time a keyboard key (ignore mouse/gamepad ones) was pressed.
    ImBitArrayForNamedKeys         KeysMayBeCharInput;                  // Lookup to tell if a key can emit char input, see IsKeyChordPotentiallyCharInput(). sizeof() = 20 bytes
    ImGuiKeyOwnerData              KeysOwnerData[ImGuiKey_NamedKey_COUNT];
    ImGuiKeyRoutingTable           KeysRoutingTable;
    ImU32                          ActiveIdUsingNavDirMask;             // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
    bool                           ActiveIdUsingAllKeyboardKeys;        // Active widget will want to read all keyboard keys inputs. (this is a shortcut for not taking ownership of 100+ keys, frequently used by drag operations)
    ImGuiKeyChord                  DebugBreakInShortcutRouting;         // Set to break in SetShortcutRouting()/Shortcut() calls.
    //ImU32                 ActiveIdUsingNavInputMask;          // [OBSOLETE] Since (IMGUI_VERSION_NUM >= 18804) : 'g.ActiveIdUsingNavInputMask |= (1 << ImGuiNavInput_Cancel);' becomes --> 'SetKeyOwner(ImGuiKey_Escape, g.ActiveId) and/or SetKeyOwner(ImGuiKey_NavGamepadCancel, g.ActiveId);'

    // Next window/item data
    ImGuiID                        CurrentFocusScopeId;                 // Value for currently appending items == g.FocusScopeStack.back(). Not to be mistaken with g.NavFocusScopeId.
    ImGuiItemFlags                 CurrentItemFlags;                    // Value for currently appending items == g.ItemFlagsStack.back()
    ImGuiID                        DebugLocateId;                       // Storage for DebugLocateItemOnHover() feature: this is read by ItemAdd() so we keep it in a hot/cached location
    ImGuiNextItemData              NextItemData;                        // Storage for SetNextItem** functions
    ImGuiLastItemData              LastItemData;                        // Storage for last submitted item (setup by ItemAdd)
    ImGuiNextWindowData            NextWindowData;                      // Storage for SetNextWindow** functions
    bool                           DebugShowGroupRects;
    bool                           GcCompactAll;                        // Request full GC

    // Shared stacks
    ImGuiCol                       DebugFlashStyleColorIdx;             // (Keep close to ColorStack to share cache line)
    ImVector_ImGuiColorMod         ColorStack;                          // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
    ImVector_ImGuiStyleMod         StyleVarStack;                       // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
    ImVector_ImFontStackData       FontStack;                           // Stack for PushFont()/PopFont() - inherited by Begin()
    ImVector_ImGuiFocusScopeData   FocusScopeStack;                     // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
    ImVector_ImGuiItemFlags        ItemFlagsStack;                      // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin()
    ImVector_ImGuiGroupData        GroupStack;                          // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
    ImVector_ImGuiPopupData        OpenPopupStack;                      // Which popups are open (persistent)
    ImVector_ImGuiPopupData        BeginPopupStack;                     // Which level of BeginPopup() we are in (reset every frame)
    ImVector_ImGuiTreeNodeStackData TreeNodeStack;                      // Stack for TreeNode()

    // Viewports
    ImVector_ImGuiViewportPPtr     Viewports;                           // Active viewports (always 1+, and generally 1 unless multi-viewports are enabled). Each viewports hold their copy of ImDrawData.
    ImGuiViewportP*                CurrentViewport;                     // We track changes of viewport (happening in Begin) so we can call Platform_OnChangedViewport()
    ImGuiViewportP*                MouseViewport;
    ImGuiViewportP*                MouseLastHoveredViewport;            // Last known viewport that was hovered by mouse (even if we are not hovering any viewport any more) + honoring the _NoInputs flag.
    ImGuiID                        PlatformLastFocusedViewportId;
    ImGuiPlatformMonitor           FallbackMonitor;                     // Virtual monitor used as fallback if backend doesn't provide monitor information.
    ImRect                         PlatformMonitorsFullWorkRect;        // Bounding box of all platform monitors
    int                            ViewportCreatedCount;                // Unique sequential creation counter (mostly for testing/debugging)
    int                            PlatformWindowsCreatedCount;         // Unique sequential creation counter (mostly for testing/debugging)
    int                            ViewportFocusedStampCount;           // Every time the front-most window changes, we stamp its viewport with an incrementing counter

    // Keyboard/Gamepad Navigation
    bool                           NavCursorVisible;                    // Nav focus cursor/rectangle is visible? We hide it after a mouse click. We show it after a nav move.
    bool                           NavHighlightItemUnderNav;            // Disable mouse hovering highlight. Highlight navigation focused item instead of mouse hovered item.
    //bool                  NavDisableHighlight;                // Old name for !g.NavCursorVisible before 1.91.4 (2024/10/18). OPPOSITE VALUE (g.NavDisableHighlight == !g.NavCursorVisible)
    //bool                  NavDisableMouseHover;               // Old name for g.NavHighlightItemUnderNav before 1.91.1 (2024/10/18) this was called When user starts using keyboard/gamepad, we hide mouse hovering highlight until mouse is touched again.
    bool                           NavMousePosDirty;                    // When set we will update mouse position if io.ConfigNavMoveSetMousePos is set (not enabled by default)
    bool                           NavIdIsAlive;                        // Nav widget has been seen this frame ~~ NavRectRel is valid
    ImGuiID                        NavId;                               // Focused item for navigation
    ImGuiWindow*                   NavWindow;                           // Focused window for navigation. Could be called 'FocusedWindow'
    ImGuiID                        NavFocusScopeId;                     // Focused focus scope (e.g. selection code often wants to "clear other items" when landing on an item of the same scope)
    ImGuiNavLayer                  NavLayer;                            // Focused layer (main scrolling layer, or menu/title bar layer)
    ImGuiID                        NavActivateId;                       // ~~ (g.ActiveId == 0) && (IsKeyPressed(ImGuiKey_Space) || IsKeyDown(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate)) ? NavId : 0, also set when calling ActivateItemByID()
    ImGuiID                        NavActivateDownId;                   // ~~ IsKeyDown(ImGuiKey_Space) || IsKeyDown(ImGuiKey_Enter) || IsKeyDown(ImGuiKey_NavGamepadActivate) ? NavId : 0
    ImGuiID                        NavActivatePressedId;                // ~~ IsKeyPressed(ImGuiKey_Space) || IsKeyPressed(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate) ? NavId : 0 (no repeat)
    ImGuiActivateFlags             NavActivateFlags;
    ImVector_ImGuiFocusScopeData   NavFocusRoute;                       // Reversed copy focus scope stack for NavId (should contains NavFocusScopeId). This essentially follow the window->ParentWindowForFocusRoute chain.
    ImGuiID                        NavHighlightActivatedId;
    float                          NavHighlightActivatedTimer;
    ImGuiID                        NavNextActivateId;                   // Set by ActivateItemByID(), queued until next frame.
    ImGuiActivateFlags             NavNextActivateFlags;
    ImGuiInputSource               NavInputSource;                      // Keyboard or Gamepad mode? THIS CAN ONLY BE ImGuiInputSource_Keyboard or ImGuiInputSource_Gamepad
    ImGuiSelectionUserData         NavLastValidSelectionUserData;       // Last valid data passed to SetNextItemSelectionUser(), or -1. For current window. Not reset when focusing an item that doesn't have selection data.
    ImS8                           NavCursorHideFrames;
    //ImGuiID               NavActivateInputId;                 // Removed in 1.89.4 (July 2023). This is now part of g.NavActivateId and sets g.NavActivateFlags |= ImGuiActivateFlags_PreferInput. See commit c9a53aa74, issue #5606.

    // Navigation: Init & Move Requests
    bool                           NavAnyRequest;                       // ~~ NavMoveRequest || NavInitRequest this is to perform early out in ItemAdd()
    bool                           NavInitRequest;                      // Init request for appearing window to select first item
    bool                           NavInitRequestFromMove;
    ImGuiNavItemData               NavInitResult;                       // Init request result (first item of the window, or one for which SetItemDefaultFocus() was called)
    bool                           NavMoveSubmitted;                    // Move request submitted, will process result on next NewFrame()
    bool                           NavMoveScoringItems;                 // Move request submitted, still scoring incoming items
    bool                           NavMoveForwardToNextFrame;
    ImGuiNavMoveFlags              NavMoveFlags;
    ImGuiScrollFlags               NavMoveScrollFlags;
    ImGuiKeyChord                  NavMoveKeyMods;
    ImGuiDir                       NavMoveDir;                          // Direction of the move request (left/right/up/down)
    ImGuiDir                       NavMoveDirForDebug;
    ImGuiDir                       NavMoveClipDir;                      // FIXME-NAV: Describe the purpose of this better. Might want to rename?
    ImRect                         NavScoringRect;                      // Rectangle used for scoring, in screen space. Based of window->NavRectRel[], modified for directional navigation scoring.
    ImRect                         NavScoringNoClipRect;                // Some nav operations (such as PageUp/PageDown) enforce a region which clipper will attempt to always keep submitted
    int                            NavScoringDebugCount;                // Metrics for debugging
    int                            NavTabbingDir;                       // Generally -1 or +1, 0 when tabbing without a nav id
    int                            NavTabbingCounter;                   // >0 when counting items for tabbing
    ImGuiNavItemData               NavMoveResultLocal;                  // Best move request candidate within NavWindow
    ImGuiNavItemData               NavMoveResultLocalVisible;           // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag)
    ImGuiNavItemData               NavMoveResultOther;                  // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
    ImGuiNavItemData               NavTabbingResultFirst;               // First tabbing request candidate within NavWindow and flattened hierarchy

    // Navigation: record of last move request
    ImGuiID                        NavJustMovedFromFocusScopeId;        // Just navigated from this focus scope id (result of a successfully MoveRequest).
    ImGuiID                        NavJustMovedToId;                    // Just navigated to this id (result of a successfully MoveRequest).
    ImGuiID                        NavJustMovedToFocusScopeId;          // Just navigated to this focus scope id (result of a successfully MoveRequest).
    ImGuiKeyChord                  NavJustMovedToKeyMods;
    bool                           NavJustMovedToIsTabbing;             // Copy of ImGuiNavMoveFlags_IsTabbing. Maybe we should store whole flags.
    bool                           NavJustMovedToHasSelectionData;      // Copy of move result's ItemFlags & ImGuiItemFlags_HasSelectionUserData). Maybe we should just store ImGuiNavItemData.

    // Navigation: Windowing (Ctrl+Tab for list, or Menu button + keys or directional pads to move/resize)
    bool                           ConfigNavWindowingWithGamepad;       // = true. Enable Ctrl+Tab by holding ImGuiKey_GamepadFaceLeft (== ImGuiKey_NavGamepadMenu). When false, the button may still be used to toggle Menu layer.
    ImGuiKeyChord                  ConfigNavWindowingKeyNext;           // = ImGuiMod_Ctrl | ImGuiKey_Tab (or ImGuiMod_Super | ImGuiKey_Tab on OS X). For reconfiguration (see #4828)
    ImGuiKeyChord                  ConfigNavWindowingKeyPrev;           // = ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab (or ImGuiMod_Super | ImGuiMod_Shift | ImGuiKey_Tab on OS X)
    ImGuiWindow*                   NavWindowingTarget;                  // Target window when doing Ctrl+Tab (or Pad Menu + FocusPrev/Next), this window is temporarily displayed top-most!
    ImGuiWindow*                   NavWindowingTargetAnim;              // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f, so the fade-out can stay on it.
    ImGuiWindow*                   NavWindowingListWindow;              // Internal window actually listing the Ctrl+Tab contents
    float                          NavWindowingTimer;
    float                          NavWindowingHighlightAlpha;
    ImGuiInputSource               NavWindowingInputSource;
    bool                           NavWindowingToggleLayer;             // Set while Alt or GamepadMenu is held, may be cleared by other operations, and processed when releasing the key.
    ImGuiKey                       NavWindowingToggleKey;               // Keyboard/gamepad key used when toggling to menu layer.
    ImVec2                         NavWindowingAccumDeltaPos;
    ImVec2                         NavWindowingAccumDeltaSize;

    // Render
    float                          DimBgRatio;                          // 0.0..1.0 animation when fading in a dimming background (for modal window and Ctrl+Tab list)

    // Drag and Drop
    bool                           DragDropActive;
    bool                           DragDropWithinSource;                // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag source.
    bool                           DragDropWithinTarget;                // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag target.
    ImGuiDragDropFlags             DragDropSourceFlags;
    int                            DragDropSourceFrameCount;
    int                            DragDropMouseButton;
    ImGuiPayload                   DragDropPayload;
    ImRect                         DragDropTargetRect;                  // Store rectangle of current target candidate (we favor small targets when overlapping)
    ImRect                         DragDropTargetClipRect;              // Store ClipRect at the time of item's drawing
    ImGuiID                        DragDropTargetId;
    ImGuiID                        DragDropTargetFullViewport;
    ImGuiDragDropFlags             DragDropAcceptFlagsCurr;
    ImGuiDragDropFlags             DragDropAcceptFlagsPrev;
    float                          DragDropAcceptIdCurrRectSurface;     // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
    ImGuiID                        DragDropAcceptIdCurr;                // Target item id (set at the time of accepting the payload)
    ImGuiID                        DragDropAcceptIdPrev;                // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
    int                            DragDropAcceptFrameCount;            // Last time a target expressed a desire to accept the source
    ImGuiID                        DragDropHoldJustPressedId;           // Set when holding a payload just made ButtonBehavior() return a press.
    ImVector_unsigned_char         DragDropPayloadBufHeap;              // We don't expose the ImVector<> directly, ImGuiPayload only holds pointer+size
    unsigned char                  DragDropPayloadBufLocal[16];         // Local buffer for small payloads

    // Clipper
    int                            ClipperTempDataStacked;
    ImVector_ImGuiListClipperData  ClipperTempData;

    // Tables
    ImGuiTable*                    CurrentTable;
    ImGuiID                        DebugBreakInTable;                   // Set to break in BeginTable() call.
    int                            TablesTempDataStacked;               // Temporary table data size (because we leave previous instances undestructed, we generally don't use TablesTempData.Size)
    ImVector_ImGuiTableTempData    TablesTempData;                      // Temporary table data (buffers reused/shared across instances, support nesting)
    ImPool_ImGuiTable              Tables;                              // Persistent table data
    ImVector_float                 TablesLastTimeActive;                // Last used timestamp of each tables (SOA, for efficient GC)
    ImVector_ImDrawChannel         DrawChannelsTempMergeBuffer;

    // Tab bars
    ImGuiTabBar*                   CurrentTabBar;
    ImPool_ImGuiTabBar             TabBars;
    ImVector_ImGuiPtrOrIndex       CurrentTabBarStack;
    ImVector_ImGuiShrinkWidthItem  ShrinkWidthBuffer;

    // Multi-Select state
    ImGuiBoxSelectState            BoxSelectState;
    ImGuiMultiSelectTempData*      CurrentMultiSelect;
    int                            MultiSelectTempDataStacked;          // Temporary multi-select data size (because we leave previous instances undestructed, we generally don't use MultiSelectTempData.Size)
    ImVector_ImGuiMultiSelectTempData MultiSelectTempData;
    ImPool_ImGuiMultiSelectState   MultiSelectStorage;

    // Hover Delay system
    ImGuiID                        HoverItemDelayId;
    ImGuiID                        HoverItemDelayIdPreviousFrame;
    float                          HoverItemDelayTimer;                 // Currently used by IsItemHovered()
    float                          HoverItemDelayClearTimer;            // Currently used by IsItemHovered(): grace time before g.TooltipHoverTimer gets cleared.
    ImGuiID                        HoverItemUnlockedStationaryId;       // Mouse has once been stationary on this item. Only reset after departing the item.
    ImGuiID                        HoverWindowUnlockedStationaryId;     // Mouse has once been stationary on this window. Only reset after departing the window.

    // Mouse state
    ImGuiMouseCursor               MouseCursor;
    float                          MouseStationaryTimer;                // Time the mouse has been stationary (with some loose heuristic)
    ImVec2                         MouseLastValidPos;

    // Widget state
    ImGuiInputTextState            InputTextState;
    ImGuiTextIndex                 InputTextLineIndex;                  // Temporary storage
    ImGuiInputTextDeactivatedState InputTextDeactivatedState;
    ImFontBaked                    InputTextPasswordFontBackupBaked;
    ImFontFlags                    InputTextPasswordFontBackupFlags;
    ImGuiID                        TempInputId;                         // Temporary text input when using Ctrl+Click on a slider, etc.
    ImGuiDataTypeStorage           DataTypeZeroValue;                   // 0 for all data types
    int                            BeginMenuDepth;
    int                            BeginComboDepth;
    ImGuiColorEditFlags            ColorEditOptions;                    // Store user options for color edit widgets
    ImGuiID                        ColorEditCurrentID;                  // Set temporarily while inside of the parent-most ColorEdit4/ColorPicker4 (because they call each others).
    ImGuiID                        ColorEditSavedID;                    // ID we are saving/restoring HS for
    float                          ColorEditSavedHue;                   // Backup of last Hue associated to LastColor, so we can restore Hue in lossy RGB<>HSV round trips
    float                          ColorEditSavedSat;                   // Backup of last Saturation associated to LastColor, so we can restore Saturation in lossy RGB<>HSV round trips
    ImU32                          ColorEditSavedColor;                 // RGB value with alpha set to 0.
    ImVec4                         ColorPickerRef;                      // Initial/reference color at the time of opening the color picker.
    ImGuiComboPreviewData          ComboPreviewData;
    ImRect                         WindowResizeBorderExpectedRect;      // Expected border rect, switch to relative edit if moving
    bool                           WindowResizeRelativeMode;
    short                          ScrollbarSeekMode;                   // 0: scroll to clicked location, -1/+1: prev/next page.
    float                          ScrollbarClickDeltaToGrabCenter;     // When scrolling to mouse location: distance between mouse and center of grab box, normalized in parent space.
    float                          SliderGrabClickOffset;
    float                          SliderCurrentAccum;                  // Accumulated slider delta when using navigation controls.
    bool                           SliderCurrentAccumDirty;             // Has the accumulated slider delta changed since last time we tried to apply it?
    bool                           DragCurrentAccumDirty;
    float                          DragCurrentAccum;                    // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
    float                          DragSpeedDefaultRatio;               // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
    float                          DisabledAlphaBackup;                 // Backup for style.Alpha for BeginDisabled()
    short                          DisabledStackSize;
    short                          TooltipOverrideCount;
    ImGuiWindow*                   TooltipPreviousWindow;               // Window of last tooltip submitted during the frame
    ImVector_char                  ClipboardHandlerData;                // If no custom clipboard handler is defined
    ImVector_ImGuiID               MenusIdSubmittedThisFrame;           // A list of menu IDs that were rendered at least once
    ImGuiTypingSelectState         TypingSelectState;                   // State for GetTypingSelectRequest()

    // Platform support
    ImGuiPlatformImeData           PlatformImeData;                     // Data updated by current frame. Will be applied at end of the frame. For some backends, this is required to have WantVisible=true in order to receive text message.
    ImGuiPlatformImeData           PlatformImeDataPrev;                 // Previous frame data. When changed we call the platform_io.Platform_SetImeDataFn() handler.

    // Extensions
    // FIXME: We could provide an API to register one slot in an array held in ImGuiContext?
    ImVector_ImTextureDataPtr      UserTextures;                        // List of textures created/managed by user or third-party extension. Automatically appended into platform_io.Textures[].
    ImGuiDockContext               DockContext;
    void (*DockNodeWindowMenuHandler)(ImGuiContext* ctx, ImGuiDockNode* node, ImGuiTabBar* tab_bar);

    // Settings
    bool                           SettingsLoaded;
    float                          SettingsDirtyTimer;                  // Save .ini Settings to memory when time reaches zero
    ImGuiTextBuffer                SettingsIniData;                     // In memory .ini settings
    ImVector_ImGuiSettingsHandler  SettingsHandlers;                    // List of .ini settings handlers
    ImChunkStream_ImGuiWindowSettings SettingsWindows;                  // ImGuiWindow .ini settings entries
    ImChunkStream_ImGuiTableSettings SettingsTables;                    // ImGuiTable .ini settings entries
    ImVector_ImGuiContextHook      Hooks;                               // Hooks for extensions (e.g. test engine)
    ImGuiID                        HookIdNext;                          // Next available HookId

    // Localization
    const char*                    LocalizationTable[ImGuiLocKey_COUNT];

    // Capture/Logging
    bool                           LogEnabled;                          // Currently capturing
    bool                           LogLineFirstItem;
    ImGuiLogFlags                  LogFlags;                            // Capture flags/type
    ImGuiWindow*                   LogWindow;
    ImFileHandle                   LogFile;                             // If != NULL log to stdout/ file
    ImGuiTextBuffer                LogBuffer;                           // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
    const char*                    LogNextPrefix;                       // See comment in LogSetNextTextDecoration(): doesn't copy underlying data, use carefully!
    const char*                    LogNextSuffix;
    float                          LogLinePosY;
    int                            LogDepthRef;
    int                            LogDepthToExpand;
    int                            LogDepthToExpandDefault;             // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call.

    // Error Handling
    ImGuiErrorCallback             ErrorCallback;                       // = NULL. May be exposed in public API eventually.
    void*                          ErrorCallbackUserData;               // = NULL
    ImVec2                         ErrorTooltipLockedPos;
    bool                           ErrorFirst;
    int                            ErrorCountCurrentFrame;              // [Internal] Number of errors submitted this frame.
    ImGuiErrorRecoveryState        StackSizesInNewFrame;                // [Internal]
    ImGuiErrorRecoveryState*       StackSizesInBeginForCurrentWindow;   // [Internal]

    // Debug Tools
    // (some of the highly frequently used data are interleaved in other structures above: DebugBreakXXX fields, DebugHookIdInfo, DebugLocateId etc.)
    int                            DebugDrawIdConflictsCount;           // Locked count (preserved when holding Ctrl)
    ImGuiDebugLogFlags             DebugLogFlags;
    ImGuiTextBuffer                DebugLogBuf;
    ImGuiTextIndex                 DebugLogIndex;
    int                            DebugLogSkippedErrors;
    ImGuiDebugLogFlags             DebugLogAutoDisableFlags;
    ImU8                           DebugLogAutoDisableFrames;
    ImU8                           DebugLocateFrames;                   // For DebugLocateItemOnHover(). This is used together with DebugLocateId which is in a hot/cached spot above.
    bool                           DebugBreakInLocateId;                // Debug break in ItemAdd() call for g.DebugLocateId.
    ImGuiKeyChord                  DebugBreakKeyChord;                  // = ImGuiKey_Pause
    ImS8                           DebugBeginReturnValueCullDepth;      // Cycle between 0..9 then wrap around.
    bool                           DebugItemPickerActive;               // Item picker is active (started with DebugStartItemPicker())
    ImU8                           DebugItemPickerMouseButton;
    ImGuiID                        DebugItemPickerBreakId;              // Will call IM_DEBUG_BREAK() when encountering this ID
    float                          DebugFlashStyleColorTime;
    ImVec4                         DebugFlashStyleColorBackup;
    ImGuiMetricsConfig             DebugMetricsConfig;
    ImGuiDebugItemPathQuery        DebugItemPathQuery;
    ImGuiIDStackTool               DebugIDStackTool;
    ImGuiDebugAllocInfo            DebugAllocInfo;
    ImGuiDockNode*                 DebugHoveredDockNode;                // Hovered dock node.
#if defined(IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS)&&!defined(IMGUI_DISABLE_DEBUG_TOOLS)
    ImGuiStorage                   DebugDrawIdConflictsAliveCount;
    ImGuiStorage                   DebugDrawIdConflictsHighlightSet;
#endif // #if defined(IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS)&&!defined(IMGUI_DISABLE_DEBUG_TOOLS)
    // Misc
    float                          FramerateSecPerFrame[60];            // Calculate estimate of framerate for user over the last 60 frames..
    int                            FramerateSecPerFrameIdx;
    int                            FramerateSecPerFrameCount;
    float                          FramerateSecPerFrameAccum;
    int                            WantCaptureMouseNextFrame;           // Explicit capture override via SetNextFrameWantCaptureMouse()/SetNextFrameWantCaptureKeyboard(). Default to -1.
    int                            WantCaptureKeyboardNextFrame;        // "
    int                            WantTextInputNextFrame;              // Copied in EndFrame() from g.PlatformImeData.WantTextInput. Needs to be set for some backends (SDL3) to emit character inputs.
    ImVector_char                  TempBuffer;                          // Temporary text buffer
    char                           TempKeychordName[64];
};

//-----------------------------------------------------------------------------
// [SECTION] ImGuiWindowTempData, ImGuiWindow
//-----------------------------------------------------------------------------

// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
// (That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered..)
// (This doesn't need a constructor because we zero-clear it as part of ImGuiWindow and all frame-temporary data are setup on Begin)
struct ImGuiWindowTempData_t
{
    // Layout
    ImVec2                  CursorPos;                      // Current emitting position, in absolute coordinates.
    ImVec2                  CursorPosPrevLine;
    ImVec2                  CursorStartPos;                 // Initial position after Begin(), generally ~ window position + WindowPadding.
    ImVec2                  CursorMaxPos;                   // Used to implicitly calculate ContentSize at the beginning of next frame, for scrolling range and auto-resize. Always growing during the frame.
    ImVec2                  IdealMaxPos;                    // Used to implicitly calculate ContentSizeIdeal at the beginning of next frame, for auto-resize only. Always growing during the frame.
    ImVec2                  CurrLineSize;
    ImVec2                  PrevLineSize;
    float                   CurrLineTextBaseOffset;         // Baseline offset (0.0f by default on a new line, generally == style.FramePadding.y when a framed item has been added).
    float                   PrevLineTextBaseOffset;
    bool                    IsSameLine;
    bool                    IsSetPos;
    ImVec1                  Indent;                         // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
    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.
    ImVec1                  GroupOffset;
    ImVec2                  CursorStartPosLossyness;        // Record the loss of precision of CursorStartPos due to really large scrolling amount. This is used by clipper to compensate and fix the most common use case of large scroll area.

    // Keyboard/Gamepad navigation
    ImGuiNavLayer           NavLayerCurrent;                // Current layer, 0..31 (we currently only use 0..1)
    short                   NavLayersActiveMask;            // Which layers have been written to (result from previous frame)
    short                   NavLayersActiveMaskNext;        // Which layers have been written to (accumulator for current frame)
    bool                    NavIsScrollPushableX;           // Set when current work location may be scrolled horizontally when moving left / right. This is generally always true UNLESS within a column.
    bool                    NavHideHighlightOneFrame;
    bool                    NavWindowHasScrollY;            // Set per window when scrolling can be used (== ScrollMax.y > 0.0f)

    // Miscellaneous
    bool                    MenuBarAppending;               // FIXME: Remove this
    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.
    ImGuiMenuColumns        MenuColumns;                    // Simplified columns storage for menu items measurement
    int                     TreeDepth;                      // Current tree depth.
    ImU32                   TreeHasStackDataDepthMask;      // Store whether given depth has ImGuiTreeNodeStackData data. Could be turned into a ImU64 if necessary.
    ImU32                   TreeRecordsClippedNodesY2Mask;  // Store whether we should keep recording Y2. Cleared when passing clip max. Equivalent TreeHasStackDataDepthMask value should always be set.
    ImVector_ImGuiWindowPtr ChildWindows;
    ImGuiStorage*           StateStorage;                   // Current persistent per-window storage (store e.g. tree node open/close state)
    ImGuiOldColumns*        CurrentColumns;                 // Current columns set
    int                     CurrentTableIdx;                // Current table index (into g.Tables)
    ImGuiLayoutType         LayoutType;
    ImGuiLayoutType         ParentLayoutType;               // Layout type of parent window at the time of Begin()
    ImU32                   ModalDimBgColor;

    // Status flags
    ImGuiItemStatusFlags    WindowItemStatusFlags;
    ImGuiItemStatusFlags    ChildItemStatusFlags;
    ImGuiItemStatusFlags    DockTabItemStatusFlags;
    ImRect                  DockTabItemRect;

    // Local parameters stacks
    // 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.
    float                   ItemWidth;                      // Current item width (>0.0: width in pixels, <0.0: align xx pixels to the right of window).
    float                   TextWrapPos;                    // Current text wrap pos.
    ImVector_float          ItemWidthStack;                 // Store item widths to restore (attention: .back() is not == ItemWidth)
    ImVector_float          TextWrapPosStack;               // Store text wrap pos to restore (attention: .back() is not == TextWrapPos)
};

// Storage for one window
struct ImGuiWindow_t
{
    ImGuiContext*            Ctx;                                             // Parent UI context (needs to be set explicitly by parent).
    char*                    Name;                                            // Window name, owned by the window.
    ImGuiID                  ID;                                              // == ImHashStr(Name)
    ImGuiWindowFlags         Flags, FlagsPreviousFrame;                       // See enum ImGuiWindowFlags_
    ImGuiChildFlags          ChildFlags;                                      // Set when window is a child window. See enum ImGuiChildFlags_
    ImGuiWindowClass         WindowClass;                                     // Advanced users only. Set with SetNextWindowClass()
    ImGuiViewportP*          Viewport;                                        // Always set in Begin(). Inactive windows may have a NULL value here if their viewport was discarded.
    ImGuiID                  ViewportId;                                      // We backup the viewport id (since the viewport may disappear or never be created if the window is inactive)
    ImVec2                   ViewportPos;                                     // We backup the viewport position (since the viewport may disappear or never be created if the window is inactive)
    int                      ViewportAllowPlatformMonitorExtend;              // Reset to -1 every frame (index is guaranteed to be valid between NewFrame..EndFrame), only used in the Appearing frame of a tooltip/popup to enforce clamping to a given monitor
    ImVec2                   Pos;                                             // Position (always rounded-up to nearest pixel)
    ImVec2                   Size;                                            // Current size (==SizeFull or collapsed title bar size)
    ImVec2                   SizeFull;                                        // Size when non collapsed
    ImVec2                   ContentSize;                                     // Size of contents/scrollable client area (calculated from the extents reach of the cursor) from previous frame. Does not include window decoration or window padding.
    ImVec2                   ContentSizeIdeal;
    ImVec2                   ContentSizeExplicit;                             // Size of contents/scrollable client area explicitly request by the user via SetNextWindowContentSize().
    ImVec2                   WindowPadding;                                   // Window padding at the time of Begin().
    float                    WindowRounding;                                  // Window rounding at the time of Begin(). May be clamped lower to avoid rendering artifacts with title bar, menu bar etc.
    float                    WindowBorderSize;                                // Window border size at the time of Begin().
    float                    TitleBarHeight, MenuBarHeight;                   // Note that those used to be function before 2024/05/28. If you have old code calling TitleBarHeight() you can change it to TitleBarHeight.
    float                    DecoOuterSizeX1, DecoOuterSizeY1;                // Left/Up offsets. Sum of non-scrolling outer decorations (X1 generally == 0.0f. Y1 generally = TitleBarHeight + MenuBarHeight). Locked during Begin().
    float                    DecoOuterSizeX2, DecoOuterSizeY2;                // Right/Down offsets (X2 generally == ScrollbarSize.x, Y2 == ScrollbarSizes.y).
    float                    DecoInnerSizeX1, DecoInnerSizeY1;                // Applied AFTER/OVER InnerRect. Specialized for Tables as they use specialized form of clipping and frozen rows/columns are inside InnerRect (and not part of regular decoration sizes).
    int                      NameBufLen;                                      // Size of buffer storing Name. May be larger than strlen(Name)!
    ImGuiID                  MoveId;                                          // == window->GetID("#MOVE")
    ImGuiID                  TabId;                                           // == window->GetID("#TAB")
    ImGuiID                  ChildId;                                         // ID of corresponding item in parent window (for navigation to return from child window to parent window)
    ImGuiID                  PopupId;                                         // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
    ImVec2                   Scroll;
    ImVec2                   ScrollMax;
    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)
    ImVec2                   ScrollTargetCenterRatio;                         // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
    ImVec2                   ScrollTargetEdgeSnapDist;                        // 0.0f = no snapping, >0.0f snapping threshold
    ImVec2                   ScrollbarSizes;                                  // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar.
    bool                     ScrollbarX, ScrollbarY;                          // Are scrollbars visible?
    bool                     ScrollbarXStabilizeEnabled;                      // Was ScrollbarX previously auto-stabilized?
    ImU8                     ScrollbarXStabilizeToggledHistory;               // Used to stabilize scrollbar visibility in case of feedback loops
    bool                     ViewportOwned;
    bool                     Active;                                          // Set to true on Begin(), unless Collapsed
    bool                     WasActive;
    bool                     WriteAccessed;                                   // Set to true when any widget access the current window
    bool                     Collapsed;                                       // Set when collapsing window to become only title-bar
    bool                     WantCollapseToggle;
    bool                     SkipItems;                                       // Set when items can safely be all clipped (e.g. window not visible or collapsed)
    bool                     SkipRefresh;                                     // [EXPERIMENTAL] Reuse previous frame drawn contents, Begin() returns false.
    bool                     Appearing;                                       // Set during the frame where the window is appearing (or re-appearing)
    bool                     Hidden;                                          // Do not display (== HiddenFrames*** > 0)
    bool                     IsFallbackWindow;                                // Set on the "Debug##Default" window.
    bool                     IsExplicitChild;                                 // Set when passed _ChildWindow, left to false by BeginDocked()
    bool                     HasCloseButton;                                  // Set when the window has a close button (p_open != NULL)
    signed char              ResizeBorderHovered;                             // Current border being hovered for resize (-1: none, otherwise 0-3)
    signed char              ResizeBorderHeld;                                // Current border being held for resize (-1: none, otherwise 0-3)
    short                    BeginCount;                                      // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
    short                    BeginCountPreviousFrame;                         // Number of Begin() during the previous frame
    short                    BeginOrderWithinParent;                          // Begin() order within immediate parent window, if we are a child window. Otherwise 0.
    short                    BeginOrderWithinContext;                         // Begin() order within entire imgui context. This is mostly used for debugging submission order related issues.
    short                    FocusOrder;                                      // Order within WindowsFocusOrder[], altered when windows are focused.
    ImGuiDir                 AutoPosLastDirection;
    ImS8                     AutoFitFramesX, AutoFitFramesY;
    bool                     AutoFitOnlyGrows;
    ImS8                     HiddenFramesCanSkipItems;                        // Hide the window for N frames
    ImS8                     HiddenFramesCannotSkipItems;                     // Hide the window for N frames while allowing items to be submitted so we can measure their size
    ImS8                     HiddenFramesForRenderOnly;                       // Hide the window until frame N at Render() time only
    ImS8                     DisableInputsFrames;                             // Disable window interactions for N frames
    ImGuiWindowBgClickFlags  BgClickFlags : 8;                                // Configure behavior of click+dragging on window bg/void or over items. Default sets by io.ConfigWindowsMoveFromTitleBarOnly. If you use this please report in #3379.
    ImGuiCond                SetWindowPosAllowFlags : 8;                      // store acceptable condition flags for SetNextWindowPos() use.
    ImGuiCond                SetWindowSizeAllowFlags : 8;                     // store acceptable condition flags for SetNextWindowSize() use.
    ImGuiCond                SetWindowCollapsedAllowFlags : 8;                // store acceptable condition flags for SetNextWindowCollapsed() use.
    ImGuiCond                SetWindowDockAllowFlags : 8;                     // store acceptable condition flags for SetNextWindowDock() use.
    ImVec2                   SetWindowPosVal;                                 // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
    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.

    ImVector_ImGuiID         IDStack;                                         // ID stack. ID are hashes seeded with the value at the top of the stack. (In theory this should be in the TempData structure)
    ImGuiWindowTempData      DC;                                              // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name.

    // The best way to understand what those rectangles are is to use the 'Metrics->Tools->Show Windows Rectangles' viewer.
    // The main 'OuterRect', omitted as a field, is window->Rect().
    ImRect                   OuterRectClipped;                                // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
    ImRect                   InnerRect;                                       // Inner rectangle (omit title bar, menu bar, scroll bar)
    ImRect                   InnerClipRect;                                   // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect.
    ImRect                   WorkRect;                                        // Initially covers the whole scrolling region. Reduced by containers e.g columns/tables when active. Shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward).
    ImRect                   ParentWorkRect;                                  // Backup of WorkRect before entering a container such as columns/tables. Used by e.g. SpanAllColumns functions to easily access. Stacked containers are responsible for maintaining this. // FIXME-WORKRECT: Could be a stack?
    ImRect                   ClipRect;                                        // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back().
    ImRect                   ContentRegionRect;                               // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
    ImVec2ih                 HitTestHoleSize;                                 // Define an optional rectangular hole where mouse will pass-through the window.
    ImVec2ih                 HitTestHoleOffset;

    int                      LastFrameActive;                                 // Last frame number the window was Active.
    int                      LastFrameJustFocused;                            // Last frame number the window was made Focused.
    float                    LastTimeActive;                                  // Last timestamp the window was Active (using float as we don't need high precision there)
    float                    ItemWidthDefault;
    ImGuiStorage             StateStorage;
    ImVector_ImGuiOldColumns ColumnsStorage;
    float                    FontWindowScale;                                 // User scale multiplier per-window, via SetWindowFontScale()
    float                    FontWindowScaleParents;
    float                    FontRefSize;                                     // This is a copy of window->CalcFontSize() at the time of Begin(), trying to phase out CalcFontSize() especially as it may be called on non-current window.
    int                      SettingsOffset;                                  // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back)

    ImDrawList*              DrawList;                                        // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
    ImDrawList               DrawListInst;
    ImGuiWindow*             ParentWindow;                                    // If we are a child _or_ popup _or_ docked window, this is pointing to our parent. Otherwise NULL.
    ImGuiWindow*             ParentWindowInBeginStack;
    ImGuiWindow*             RootWindow;                                      // Point to ourself or first ancestor that is not a child window. Doesn't cross through popups/dock nodes.
    ImGuiWindow*             RootWindowPopupTree;                             // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child.
    ImGuiWindow*             RootWindowDockTree;                              // Point to ourself or first ancestor that is not a child window. Cross through dock nodes.
    ImGuiWindow*             RootWindowForTitleBarHighlight;                  // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
    ImGuiWindow*             RootWindowForNav;                                // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
    ImGuiWindow*             ParentWindowForFocusRoute;                       // Set to manual link a window to its logical parent so that Shortcut() chain are honored (e.g. Tool linked to Document)

    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.)
    ImGuiID                  NavLastIds[ImGuiNavLayer_COUNT];                 // Last known NavId for this window, per layer (0/1)
    ImRect                   NavRectRel[ImGuiNavLayer_COUNT];                 // Reference rectangle, in window relative space
    ImVec2                   NavPreferredScoringPosRel[ImGuiNavLayer_COUNT];  // Preferred X/Y position updated when moving on a given axis, reset to FLT_MAX.
    ImGuiID                  NavRootFocusScopeId;                             // Focus Scope ID at the time of Begin()

    int                      MemoryDrawListIdxCapacity;                       // Backup of last idx/vtx count, so when waking up the window we can preallocate and avoid iterative alloc/copy
    int                      MemoryDrawListVtxCapacity;
    bool                     MemoryCompacted;                                 // Set when window extraneous data have been garbage collected

    // Docking
    bool                     DockIsActive : 1;                                // When docking artifacts are actually visible. When this is set, DockNode is guaranteed to be != NULL. ~~ (DockNode != NULL) && (DockNode->Windows.Size > 1).
    bool                     DockNodeIsVisible : 1;
    bool                     DockTabIsVisible : 1;                            // Is our window visible this frame? ~~ is the corresponding tab selected?
    bool                     DockTabWantClose : 1;
    short                    DockOrder;                                       // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
    ImGuiWindowDockStyle     DockStyle;
    ImGuiDockNode*           DockNode;                                        // Which node are we docked into. Important: Prefer testing DockIsActive in many cases as this will still be set when the dock node is hidden.
    ImGuiDockNode*           DockNodeAsHost;                                  // Which node are we owning (for parent windows)
    ImGuiID                  DockId;                                          // Backup of last valid DockNode->ID, so single window remember their dock node id even when they are not bound any more

    // [OBSOLETE] ImGuiWindow::CalcFontSize() was removed in 1.92.0 because error-prone/misleading. You can use window->FontRefSize for a copy of g.FontSize at the time of the last Begin() call for this window.
    //float     CalcFontSize() const    { ImGuiContext& g = *Ctx; return g.FontSizeBase * FontWindowScale * FontDpiScale * FontWindowScaleParents;
};
CIMGUI_API ImGuiID ImGuiWindow_GetIDStr(ImGuiWindow* self, const char* str, const char* str_end /* = NULL */);
CIMGUI_API ImGuiID ImGuiWindow_GetID(ImGuiWindow* self, const void* ptr);
CIMGUI_API ImGuiID ImGuiWindow_GetIDInt(ImGuiWindow* self, int n);
CIMGUI_API ImGuiID ImGuiWindow_GetIDFromPos(ImGuiWindow* self, ImVec2 p_abs);
CIMGUI_API ImGuiID ImGuiWindow_GetIDFromRectangle(ImGuiWindow* self, ImRect r_abs);
// We don't use g.FontSize because the window may be != g.CurrentWindow.
CIMGUI_API ImRect  ImGuiWindow_Rect(const ImGuiWindow* self);
CIMGUI_API ImRect  ImGuiWindow_TitleBarRect(const ImGuiWindow* self);
CIMGUI_API ImRect  ImGuiWindow_MenuBarRect(const ImGuiWindow* self);

//-----------------------------------------------------------------------------
// [SECTION] Tab bar, Tab item support
//-----------------------------------------------------------------------------

// Extend ImGuiTabBarFlags_
typedef enum
{
    ImGuiTabBarFlags_DockNode     = 1<<20,  // Part of a dock node [we don't use this in the master branch but it facilitate branch syncing to keep this around]
    ImGuiTabBarFlags_IsFocused    = 1<<21,
    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
} ImGuiTabBarFlagsPrivate_;

// Extend ImGuiTabItemFlags_
typedef enum
{
    ImGuiTabItemFlags_SectionMask_  = ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing,
    ImGuiTabItemFlags_NoCloseButton = 1<<20,  // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
    ImGuiTabItemFlags_Button        = 1<<21,  // Used by TabItemButton, change the tab item behavior to mimic a button
    ImGuiTabItemFlags_Invisible     = 1<<22,  // To reserve space e.g. with ImGuiTabItemFlags_Leading
    ImGuiTabItemFlags_Unsorted      = 1<<23,  // [Docking] Trailing tabs with the _Unsorted flag will be sorted based on the DockOrder of their Window.
} ImGuiTabItemFlagsPrivate_;

// Storage for one active tab item (sizeof() 48 bytes)
struct ImGuiTabItem_t
{
    ImGuiID           ID;
    ImGuiTabItemFlags Flags;
    ImGuiWindow*      Window;             // When TabItem is part of a DockNode's TabBar, we hold on to a window.
    int               LastFrameVisible;
    int               LastFrameSelected;  // This allows us to infer an ordered list of the last activated tabs with little maintenance
    float             Offset;             // Position relative to beginning of tab
    float             Width;              // Width currently displayed
    float             ContentWidth;       // Width of label + padding, stored during BeginTabItem() call (misnamed as "Content" would normally imply width of label only)
    float             RequestedWidth;     // Width optionally requested by caller, -1.0f is unused
    ImS32             NameOffset;         // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
    ImS16             BeginOrder;         // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
    ImS16             IndexDuringLayout;  // Index only used during TabBarLayout(). Tabs gets reordered so 'Tabs[n].IndexDuringLayout == n' but may mismatch during additions.
    bool              WantClose;          // Marked as closed by SetTabItemClosed()
};

// Storage for a tab bar (sizeof() 160 bytes)
struct ImGuiTabBar_t
{
    ImGuiWindow*          Window;
    ImVector_ImGuiTabItem Tabs;
    ImGuiTabBarFlags      Flags;
    ImGuiID               ID;                      // Zero for tab-bars used by docking
    ImGuiID               SelectedTabId;           // Selected tab/window
    ImGuiID               NextSelectedTabId;       // Next selected tab/window. Will also trigger a scrolling animation
    ImGuiID               VisibleTabId;            // Can occasionally be != SelectedTabId (e.g. when previewing contents for Ctrl+Tab preview)
    int                   CurrFrameVisible;
    int                   PrevFrameVisible;
    ImRect                BarRect;
    float                 BarRectPrevWidth;        // Backup of previous width. When width change we enforce keep horizontal scroll on focused tab.
    float                 CurrTabsContentsHeight;
    float                 PrevTabsContentsHeight;  // Record the height of contents submitted below the tab bar
    float                 WidthAllTabs;            // Actual width of all tabs (locked during layout)
    float                 WidthAllTabsIdeal;       // Ideal width if all tabs were visible and not clipped
    float                 ScrollingAnim;
    float                 ScrollingTarget;
    float                 ScrollingTargetDistToVisibility;
    float                 ScrollingSpeed;
    float                 ScrollingRectMinX;
    float                 ScrollingRectMaxX;
    float                 SeparatorMinX;
    float                 SeparatorMaxX;
    ImGuiID               ReorderRequestTabId;
    ImS16                 ReorderRequestOffset;
    ImS8                  BeginCount;
    bool                  WantLayout;
    bool                  VisibleTabWasSubmitted;
    bool                  TabsAddedNew;            // Set to true when a new tab item or button has been added to the tab bar during last frame
    bool                  ScrollButtonEnabled;
    ImS16                 TabsActiveCount;         // Number of tabs submitted this frame.
    ImS16                 LastTabItemIdx;          // Index of last BeginTabItem() tab for use by EndTabItem()
    float                 ItemSpacingY;
    ImVec2                FramePadding;            // style.FramePadding locked at the time of BeginTabBar()
    ImVec2                BackupCursorPos;
    ImGuiTextBuffer       TabsNames;               // For non-docking tab bar we re-append names in a contiguous buffer.
};

//-----------------------------------------------------------------------------
// [SECTION] Table support
//-----------------------------------------------------------------------------

#define IM_COL32_DISABLE                IM_COL32(0,0,0,1)    // Special sentinel code which cannot be used as a regular color.
#define IMGUI_TABLE_MAX_COLUMNS         512                  // Arbitrary "safety" maximum, may be lifted in the future if needed. Must fit in ImGuiTableColumnIdx/ImGuiTableDrawChannelIdx.

// [Internal] sizeof() ~ 112
// We use the terminology "Enabled" to refer to a column that is not Hidden by user/api.
// We use the terminology "Clipped" to refer to a column that is out of sight because of scrolling/clipping.
// This is in contrast with some user-facing api such as IsItemVisible() / IsRectVisible() which use "Visible" to mean "not clipped".
struct ImGuiTableColumn_t
{
    ImGuiTableColumnFlags    Flags;                         // Flags after some patching (not directly same as provided by user). See ImGuiTableColumnFlags_
    float                    WidthGiven;                    // Final/actual width visible == (MaxX - MinX), locked in TableUpdateLayout(). May be > WidthRequest to honor minimum width, may be < WidthRequest to honor shrinking columns down in tight space.
    float                    MinX;                          // Absolute positions
    float                    MaxX;
    float                    WidthRequest;                  // Master width absolute value when !(Flags & _WidthStretch). When Stretch this is derived every frame from StretchWeight in TableUpdateLayout()
    float                    WidthAuto;                     // Automatic width
    float                    WidthMax;                      // Maximum width (FIXME: overwritten by each instance)
    float                    StretchWeight;                 // Master width weight when (Flags & _WidthStretch). Often around ~1.0f initially.
    float                    InitStretchWeightOrWidth;      // Value passed to TableSetupColumn(). For Width it is a content width (_without padding_).
    ImRect                   ClipRect;                      // Clipping rectangle for the column
    ImGuiID                  UserID;                        // Optional, value passed to TableSetupColumn()
    float                    WorkMinX;                      // Contents region min ~(MinX + CellPaddingX + CellSpacingX1) == cursor start position when entering column
    float                    WorkMaxX;                      // Contents region max ~(MaxX - CellPaddingX - CellSpacingX2)
    float                    ItemWidth;                     // Current item width for the column, preserved across rows
    float                    ContentMaxXFrozen;             // Contents maximum position for frozen rows (apart from headers), from which we can infer content width.
    float                    ContentMaxXUnfrozen;
    float                    ContentMaxXHeadersUsed;        // Contents maximum position for headers rows (regardless of freezing). TableHeader() automatically softclip itself + report ideal desired size, to avoid creating extraneous draw calls
    float                    ContentMaxXHeadersIdeal;
    ImS16                    NameOffset;                    // Offset into parent ColumnsNames[]
    ImGuiTableColumnIdx      DisplayOrder;                  // Index within Table's IndexToDisplayOrder[] (column may be reordered by users)
    ImGuiTableColumnIdx      IndexWithinEnabledSet;         // Index within enabled/visible set (<= IndexToDisplayOrder)
    ImGuiTableColumnIdx      PrevEnabledColumn;             // Index of prev enabled/visible column within Columns[], -1 if first enabled/visible column
    ImGuiTableColumnIdx      NextEnabledColumn;             // Index of next enabled/visible column within Columns[], -1 if last enabled/visible column
    ImGuiTableColumnIdx      SortOrder;                     // Index of this column within sort specs, -1 if not sorting on this column, 0 for single-sort, may be >0 on multi-sort
    ImGuiTableDrawChannelIdx DrawChannelCurrent;            // Index within DrawSplitter.Channels[]
    ImGuiTableDrawChannelIdx DrawChannelFrozen;             // Draw channels for frozen rows (often headers)
    ImGuiTableDrawChannelIdx DrawChannelUnfrozen;           // Draw channels for unfrozen rows
    bool                     IsEnabled;                     // IsUserEnabled && (Flags & ImGuiTableColumnFlags_Disabled) == 0
    bool                     IsUserEnabled;                 // Is the column not marked Hidden by the user? (unrelated to being off view, e.g. clipped by scrolling).
    bool                     IsUserEnabledNextFrame;
    bool                     IsVisibleX;                    // Is actually in view (e.g. overlapping the host window clipping rectangle, not scrolled).
    bool                     IsVisibleY;
    bool                     IsRequestOutput;               // Return value for TableSetColumnIndex() / TableNextColumn(): whether we request user to output contents or not.
    bool                     IsSkipItems;                   // Do we want item submissions to this column to be completely ignored (no layout will happen).
    bool                     IsPreserveWidthAuto;
    ImS8                     NavLayerCurrent;               // ImGuiNavLayer in 1 byte
    ImU8                     AutoFitQueue;                  // Queue of 8 values for the next 8 frames to request auto-fit
    ImU8                     CannotSkipItemsQueue;          // Queue of 8 values for the next 8 frames to disable Clipped/SkipItem
    ImU8                     SortDirection : 2;             // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending
    ImU8                     SortDirectionsAvailCount : 2;  // Number of available sort directions (0 to 3)
    ImU8                     SortDirectionsAvailMask : 4;   // Mask of available sort directions (1-bit each)
    ImU8                     SortDirectionsAvailList;       // Ordered list of available sort directions (2-bits each, total 8-bits)
};

// Transient cell data stored per row.
// sizeof() ~ 6 bytes
struct ImGuiTableCellData_t
{
    ImU32               BgColor;  // Actual color
    ImGuiTableColumnIdx Column;   // Column number
};

// Parameters for TableAngledHeadersRowEx()
// This may end up being refactored for more general purpose.
// sizeof() ~ 12 bytes
struct ImGuiTableHeaderData_t
{
    ImGuiTableColumnIdx Index;  // Column index
    ImU32               TextColor;
    ImU32               BgColor0;
    ImU32               BgColor1;
};

// Per-instance data that needs preserving across frames (seemingly most others do not need to be preserved aside from debug needs. Does that means they could be moved to ImGuiTableTempData?)
// sizeof() ~ 24 bytes
struct ImGuiTableInstanceData_t
{
    ImGuiID TableInstanceID;
    float   LastOuterHeight;          // Outer height from last frame
    float   LastTopHeadersRowHeight;  // Height of first consecutive header rows from last frame (FIXME: this is used assuming consecutive headers are in same frozen set)
    float   LastFrozenHeight;         // Height of frozen section from last frame
    int     HoveredRowLast;           // Index of row which was hovered last frame.
    int     HoveredRowNext;           // Index of row hovered this frame, set after encountering it.
};

// sizeof() ~ 592 bytes + heap allocs described in TableBeginInitMemory()
struct ImGuiTable_t
{
    ImGuiID                    ID;
    ImGuiTableFlags            Flags;
    void*                      RawData;                    // Single allocation to hold Columns[], DisplayOrderToIndex[], and RowCellData[]
    ImGuiTableTempData*        TempData;                   // Transient data while table is active. Point within g.CurrentTableStack[]
    ImSpan_ImGuiTableColumn    Columns;                    // Point within RawData[]
    ImSpan_ImGuiTableColumnIdx DisplayOrderToIndex;        // Point within RawData[]. Store display order of columns (when not reordered, the values are 0...Count-1)
    ImSpan_ImGuiTableCellData  RowCellData;                // Point within RawData[]. Store cells background requests for current row.
    ImBitArrayPtr              EnabledMaskByDisplayOrder;  // Column DisplayOrder -> IsEnabled map
    ImBitArrayPtr              EnabledMaskByIndex;         // Column Index -> IsEnabled map (== not hidden by user/api) in a format adequate for iterating column without touching cold data
    ImBitArrayPtr              VisibleMaskByIndex;         // Column Index -> IsVisibleX|IsVisibleY map (== not hidden by user/api && not hidden by scrolling/cliprect)
    ImGuiTableFlags            SettingsLoadedFlags;        // Which data were loaded from the .ini file (e.g. when order is not altered we won't save order)
    int                        SettingsOffset;             // Offset in g.SettingsTables
    int                        LastFrameActive;
    int                        ColumnsCount;               // Number of columns declared in BeginTable()
    int                        CurrentRow;
    int                        CurrentColumn;
    ImS16                      InstanceCurrent;            // Count of BeginTable() calls with same ID in the same frame (generally 0). This is a little bit similar to BeginCount for a window, but multiple tables with the same ID are multiple tables, they are just synced.
    ImS16                      InstanceInteracted;         // Mark which instance (generally 0) of the same ID is being interacted with
    float                      RowPosY1;
    float                      RowPosY2;
    float                      RowMinHeight;               // Height submitted to TableNextRow()
    float                      RowCellPaddingY;            // Top and bottom padding. Reloaded during row change.
    float                      RowTextBaseline;
    float                      RowIndentOffsetX;
    ImGuiTableRowFlags         RowFlags : 16;              // Current row flags, see ImGuiTableRowFlags_
    ImGuiTableRowFlags         LastRowFlags : 16;
    int                        RowBgColorCounter;          // Counter for alternating background colors (can be fast-forwarded by e.g clipper), not same as CurrentRow because header rows typically don't increase this.
    ImU32                      RowBgColor[2];              // Background color override for current row.
    ImU32                      BorderColorStrong;
    ImU32                      BorderColorLight;
    float                      BorderX1;
    float                      BorderX2;
    float                      HostIndentX;
    float                      MinColumnWidth;
    float                      OuterPaddingX;
    float                      CellPaddingX;               // Padding from each borders. Locked in BeginTable()/Layout.
    float                      CellSpacingX1;              // Spacing between non-bordered cells. Locked in BeginTable()/Layout.
    float                      CellSpacingX2;
    float                      InnerWidth;                 // User value passed to BeginTable(), see comments at the top of BeginTable() for details.
    float                      ColumnsGivenWidth;          // Sum of current column width
    float                      ColumnsAutoFitWidth;        // Sum of ideal column width in order nothing to be clipped, used for auto-fitting and content width submission in outer window
    float                      ColumnsStretchSumWeights;   // Sum of weight of all enabled stretching columns
    float                      ResizedColumnNextWidth;
    float                      ResizeLockMinContentsX2;    // Lock minimum contents width while resizing down in order to not create feedback loops. But we allow growing the table.
    float                      RefScale;                   // Reference scale to be able to rescale columns on font/dpi changes.
    float                      AngledHeadersHeight;        // Set by TableAngledHeadersRow(), used in TableUpdateLayout()
    float                      AngledHeadersSlope;         // Set by TableAngledHeadersRow(), used in TableUpdateLayout()
    ImRect                     OuterRect;                  // Note: for non-scrolling table, OuterRect.Max.y is often FLT_MAX until EndTable(), unless a height has been specified in BeginTable().
    ImRect                     InnerRect;                  // InnerRect but without decoration. As with OuterRect, for non-scrolling tables, InnerRect.Max.y is "
    ImRect                     WorkRect;
    ImRect                     InnerClipRect;
    ImRect                     BgClipRect;                 // We use this to cpu-clip cell background color fill, evolve during the frame as we cross frozen rows boundaries
    ImRect                     Bg0ClipRectForDrawCmd;      // Actual ImDrawCmd clip rect for BG0/1 channel. This tends to be == OuterWindow->ClipRect at BeginTable() because output in BG0/BG1 is cpu-clipped
    ImRect                     Bg2ClipRectForDrawCmd;      // Actual ImDrawCmd clip rect for BG2 channel. This tends to be a correct, tight-fit, because output to BG2 are done by widgets relying on regular ClipRect.
    ImRect                     HostClipRect;               // This is used to check if we can eventually merge our columns draw calls into the current draw call of the current window.
    ImRect                     HostBackupInnerClipRect;    // Backup of InnerWindow->ClipRect during PushTableBackground()/PopTableBackground()
    ImGuiWindow*               OuterWindow;                // Parent window for the table
    ImGuiWindow*               InnerWindow;                // Window holding the table data (== OuterWindow or a child window)
    ImGuiTextBuffer            ColumnsNames;               // Contiguous buffer holding columns names
    ImDrawListSplitter*        DrawSplitter;               // Shortcut to TempData->DrawSplitter while in table. Isolate draw commands per columns to avoid switching clip rect constantly
    ImGuiTableInstanceData     InstanceDataFirst;
    ImVector_ImGuiTableInstanceData InstanceDataExtra;     // FIXME-OPT: Using a small-vector pattern would be good.
    ImGuiTableColumnSortSpecs  SortSpecsSingle;
    ImVector_ImGuiTableColumnSortSpecs SortSpecsMulti;     // FIXME-OPT: Using a small-vector pattern would be good.
    ImGuiTableSortSpecs        SortSpecs;                  // Public facing sorts specs, this is what we return in TableGetSortSpecs()
    ImGuiTableColumnIdx        SortSpecsCount;
    ImGuiTableColumnIdx        ColumnsEnabledCount;        // Number of enabled columns (<= ColumnsCount)
    ImGuiTableColumnIdx        ColumnsEnabledFixedCount;   // Number of enabled columns using fixed width (<= ColumnsCount)
    ImGuiTableColumnIdx        DeclColumnsCount;           // Count calls to TableSetupColumn()
    ImGuiTableColumnIdx        AngledHeadersCount;         // Count columns with angled headers
    ImGuiTableColumnIdx        HoveredColumnBody;          // Index of column whose visible region is being hovered. Important: == ColumnsCount when hovering empty region after the right-most column!
    ImGuiTableColumnIdx        HoveredColumnBorder;        // Index of column whose right-border is being hovered (for resizing).
    ImGuiTableColumnIdx        HighlightColumnHeader;      // Index of column which should be highlighted.
    ImGuiTableColumnIdx        AutoFitSingleColumn;        // Index of single column requesting auto-fit.
    ImGuiTableColumnIdx        ResizedColumn;              // Index of column being resized. Reset when InstanceCurrent==0.
    ImGuiTableColumnIdx        LastResizedColumn;          // Index of column being resized from previous frame.
    ImGuiTableColumnIdx        HeldHeaderColumn;           // Index of column header being held.
    ImGuiTableColumnIdx        ReorderColumn;              // Index of column being reordered. (not cleared)
    ImGuiTableColumnIdx        ReorderColumnDir;           // -1 or +1
    ImGuiTableColumnIdx        LeftMostEnabledColumn;      // Index of left-most non-hidden column.
    ImGuiTableColumnIdx        RightMostEnabledColumn;     // Index of right-most non-hidden column.
    ImGuiTableColumnIdx        LeftMostStretchedColumn;    // Index of left-most stretched column.
    ImGuiTableColumnIdx        RightMostStretchedColumn;   // Index of right-most stretched column.
    ImGuiTableColumnIdx        ContextPopupColumn;         // Column right-clicked on, of -1 if opening context menu from a neutral/empty spot
    ImGuiTableColumnIdx        FreezeRowsRequest;          // Requested frozen rows count
    ImGuiTableColumnIdx        FreezeRowsCount;            // Actual frozen row count (== FreezeRowsRequest, or == 0 when no scrolling offset)
    ImGuiTableColumnIdx        FreezeColumnsRequest;       // Requested frozen columns count
    ImGuiTableColumnIdx        FreezeColumnsCount;         // Actual frozen columns count (== FreezeColumnsRequest, or == 0 when no scrolling offset)
    ImGuiTableColumnIdx        RowCellDataCurrent;         // Index of current RowCellData[] entry in current row
    ImGuiTableDrawChannelIdx   DummyDrawChannel;           // Redirect non-visible columns here.
    ImGuiTableDrawChannelIdx   Bg2DrawChannelCurrent;      // For Selectable() and other widgets drawing across columns after the freezing line. Index within DrawSplitter.Channels[]
    ImGuiTableDrawChannelIdx   Bg2DrawChannelUnfrozen;
    ImS8                       NavLayer;                   // ImGuiNavLayer at the time of BeginTable().
    bool                       IsLayoutLocked;             // Set by TableUpdateLayout() which is called when beginning the first row.
    bool                       IsInsideRow;                // Set when inside TableBeginRow()/TableEndRow().
    bool                       IsInitializing;
    bool                       IsSortSpecsDirty;
    bool                       IsUsingHeaders;             // Set when the first row had the ImGuiTableRowFlags_Headers flag.
    bool                       IsContextPopupOpen;         // Set when default context menu is open (also see: ContextPopupColumn, InstanceInteracted).
    bool                       DisableDefaultContextMenu;  // Disable default context menu. You may submit your own using TableBeginContextMenuPopup()/EndPopup()
    bool                       IsSettingsRequestLoad;
    bool                       IsSettingsDirty;            // Set when table settings have changed and needs to be reported into ImGuiTableSettings data.
    bool                       IsDefaultDisplayOrder;      // Set when display order is unchanged from default (DisplayOrder contains 0...Count-1)
    bool                       IsResetAllRequest;
    bool                       IsResetDisplayOrderRequest;
    bool                       IsUnfrozenRows;             // Set when we got past the frozen row.
    bool                       IsDefaultSizingPolicy;      // Set if user didn't explicitly set a sizing policy in BeginTable()
    bool                       IsActiveIdAliveBeforeTable;
    bool                       IsActiveIdInTable;
    bool                       HasScrollbarYCurr;          // Whether ANY instance of this table had a vertical scrollbar during the current frame.
    bool                       HasScrollbarYPrev;          // Whether ANY instance of this table had a vertical scrollbar during the previous.
    bool                       MemoryCompacted;
    bool                       HostSkipItems;              // Backup of InnerWindow->SkipItem at the end of BeginTable(), because we will overwrite InnerWindow->SkipItem on a per-column basis
};

// Transient data that are only needed between BeginTable() and EndTable(), those buffers are shared (1 per level of stacked table).
// - Accessing those requires chasing an extra pointer so for very frequently used data we leave them in the main table structure.
// - We also leave out of this structure data that tend to be particularly useful for debugging/metrics.
// FIXME-TABLE: more transient data could be stored in a stacked ImGuiTableTempData: e.g. SortSpecs.
// sizeof() ~ 136 bytes.
struct ImGuiTableTempData_t
{
    ImGuiID            WindowID;                          // Shortcut to g.Tables[TableIndex]->OuterWindow->ID.
    int                TableIndex;                        // Index in g.Tables.Buf[] pool
    float              LastTimeActive;                    // Last timestamp this structure was used
    float              AngledHeadersExtraWidth;           // Used in EndTable()
    ImVector_ImGuiTableHeaderData AngledHeadersRequests;  // Used in TableAngledHeadersRow()

    ImVec2             UserOuterSize;                     // outer_size.x passed to BeginTable()
    ImDrawListSplitter DrawSplitter;

    ImRect             HostBackupWorkRect;                // Backup of InnerWindow->WorkRect at the end of BeginTable()
    ImRect             HostBackupParentWorkRect;          // Backup of InnerWindow->ParentWorkRect at the end of BeginTable()
    ImVec2             HostBackupPrevLineSize;            // Backup of InnerWindow->DC.PrevLineSize at the end of BeginTable()
    ImVec2             HostBackupCurrLineSize;            // Backup of InnerWindow->DC.CurrLineSize at the end of BeginTable()
    ImVec2             HostBackupCursorMaxPos;            // Backup of InnerWindow->DC.CursorMaxPos at the end of BeginTable()
    ImVec1             HostBackupColumnsOffset;           // Backup of OuterWindow->DC.ColumnsOffset at the end of BeginTable()
    float              HostBackupItemWidth;               // Backup of OuterWindow->DC.ItemWidth at the end of BeginTable()
    int                HostBackupItemWidthStackSize;      //Backup of OuterWindow->DC.ItemWidthStack.Size at the end of BeginTable()
};

// sizeof() ~ 16
struct ImGuiTableColumnSettings_t
{
    float               WidthOrWeight;
    ImGuiID             UserID;
    ImGuiTableColumnIdx Index;
    ImGuiTableColumnIdx DisplayOrder;
    ImGuiTableColumnIdx SortOrder;
    ImU8                SortDirection : 2;
    ImS8                IsEnabled : 2;  // "Visible" in ini file
    ImU8                IsStretch : 1;
};

// This is designed to be stored in a single ImChunkStream (1 header followed by N ImGuiTableColumnSettings, etc.)
struct ImGuiTableSettings_t
{
    ImGuiID             ID;               // Set to 0 to invalidate/delete the setting
    ImGuiTableFlags     SaveFlags;        // Indicate data we want to save using the Resizable/Reorderable/Sortable/Hideable flags (could be using its own flags..)
    float               RefScale;         // Reference scale to be able to rescale columns on font/dpi changes.
    ImGuiTableColumnIdx ColumnsCount;
    ImGuiTableColumnIdx ColumnsCountMax;  // Maximum number of columns this settings instance can store, we can recycle a settings instance with lower number of columns but not higher
    bool                WantApply;        // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context)
};
CIMGUI_API ImGuiTableColumnSettings* ImGuiTableSettings_GetColumnSettings(ImGuiTableSettings* self);

//-----------------------------------------------------------------------------
// [SECTION] ImGui internal API
// No guarantee of forward compatibility here!
//-----------------------------------------------------------------------------

// Windows
// We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
// If this ever crashes because g.CurrentWindow is NULL, it means that either:
// - ImGui::NewFrame() has never been called, which is illegal.
// - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
CIMGUI_API ImGuiIO*         ImGui_GetIOImGuiContextPtr(ImGuiContext* ctx);
CIMGUI_API ImGuiPlatformIO* ImGui_GetPlatformIOImGuiContextPtr(ImGuiContext* ctx);
CIMGUI_API ImGuiWindow*     ImGui_GetCurrentWindowRead(void);
CIMGUI_API ImGuiWindow*     ImGui_GetCurrentWindow(void);
CIMGUI_API ImGuiWindow*     ImGui_FindWindowByID(ImGuiID id);
CIMGUI_API ImGuiWindow*     ImGui_FindWindowByName(const char* name);
CIMGUI_API void             ImGui_UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
CIMGUI_API void             ImGui_UpdateWindowSkipRefresh(ImGuiWindow* window);
CIMGUI_API ImVec2           ImGui_CalcWindowNextAutoFitSize(ImGuiWindow* window);
CIMGUI_API bool             ImGui_IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy, bool dock_hierarchy);
CIMGUI_API bool             ImGui_IsWindowInBeginStack(ImGuiWindow* window);
CIMGUI_API bool             ImGui_IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
CIMGUI_API bool             ImGui_IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below);
CIMGUI_API bool             ImGui_IsWindowNavFocusable(ImGuiWindow* window);
CIMGUI_API void             ImGui_SetWindowPosImGuiWindowPtr(ImGuiWindow* window, ImVec2 pos, ImGuiCond cond /* = 0 */);
CIMGUI_API void             ImGui_SetWindowSizeImGuiWindowPtr(ImGuiWindow* window, ImVec2 size, ImGuiCond cond /* = 0 */);
CIMGUI_API void             ImGui_SetWindowCollapsedImGuiWindowPtr(ImGuiWindow* window, bool collapsed, ImGuiCond cond /* = 0 */);
CIMGUI_API void             ImGui_SetWindowHitTestHole(ImGuiWindow* window, ImVec2 pos, ImVec2 size);
CIMGUI_API void             ImGui_SetWindowHiddenAndSkipItemsForCurrentFrame(ImGuiWindow* window);
CIMGUI_API void             ImGui_SetWindowParentWindowForFocusRoute(ImGuiWindow* window, ImGuiWindow* parent_window);  // You may also use SetNextWindowClass()'s FocusRouteParentWindowId field.
CIMGUI_API ImRect           ImGui_WindowRectAbsToRel(ImGuiWindow* window, ImRect r);
CIMGUI_API ImRect           ImGui_WindowRectRelToAbs(ImGuiWindow* window, ImRect r);
CIMGUI_API ImVec2           ImGui_WindowPosAbsToRel(ImGuiWindow* window, ImVec2 p);
CIMGUI_API ImVec2           ImGui_WindowPosRelToAbs(ImGuiWindow* window, ImVec2 p);

// Windows: Display Order and Focus Order
CIMGUI_API void         ImGui_FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags /* = 0 */);
CIMGUI_API void         ImGui_FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window, ImGuiViewport* filter_viewport, ImGuiFocusRequestFlags flags);
CIMGUI_API void         ImGui_BringWindowToFocusFront(ImGuiWindow* window);
CIMGUI_API void         ImGui_BringWindowToDisplayFront(ImGuiWindow* window);
CIMGUI_API void         ImGui_BringWindowToDisplayBack(ImGuiWindow* window);
CIMGUI_API void         ImGui_BringWindowToDisplayBehind(ImGuiWindow* window, ImGuiWindow* above_window);
CIMGUI_API int          ImGui_FindWindowDisplayIndex(ImGuiWindow* window);
CIMGUI_API ImGuiWindow* ImGui_FindBottomMostVisibleWindowWithinBeginStack(ImGuiWindow* window);

// Windows: Idle, Refresh Policies [EXPERIMENTAL]
CIMGUI_API void ImGui_SetNextWindowRefreshPolicy(ImGuiWindowRefreshFlags flags);

// Fonts, drawing
CIMGUI_API void        ImGui_RegisterUserTexture(ImTextureData* tex);                       // Register external texture. EXPERIMENTAL: DO NOT USE YET.
CIMGUI_API void        ImGui_UnregisterUserTexture(ImTextureData* tex);
CIMGUI_API void        ImGui_RegisterFontAtlas(ImFontAtlas* atlas);
CIMGUI_API void        ImGui_UnregisterFontAtlas(ImFontAtlas* atlas);
CIMGUI_API void        ImGui_SetCurrentFont(ImFont* font, float font_size_before_scaling, float font_size_after_scaling);
CIMGUI_API void        ImGui_UpdateCurrentFontSize(float restore_font_size_after_scaling);
CIMGUI_API void        ImGui_SetFontRasterizerDensity(float rasterizer_density);
CIMGUI_API float       ImGui_GetFontRasterizerDensity(void);
CIMGUI_API float       ImGui_GetRoundedFontSize(float size);
CIMGUI_API ImFont*     ImGui_GetDefaultFont(void);
CIMGUI_API void        ImGui_PushPasswordFont(void);
CIMGUI_API void        ImGui_PopPasswordFont(void);
CIMGUI_API ImDrawList* ImGui_GetForegroundDrawListImGuiWindowPtr(ImGuiWindow* window);
CIMGUI_API void        ImGui_AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector_ImDrawListPtr* out_list, ImDrawList* draw_list);

// Init
CIMGUI_API void ImGui_Initialize(void);
CIMGUI_API void ImGui_Shutdown(void);  // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().

// NewFrame
CIMGUI_API void ImGui_UpdateInputEvents(bool trickle_fast_inputs);
CIMGUI_API void ImGui_UpdateHoveredWindowAndCaptureFlags(ImVec2 mouse_pos);
CIMGUI_API void ImGui_FindHoveredWindowEx(ImVec2 pos, bool find_first_and_in_any_viewport, ImGuiWindow** out_hovered_window, ImGuiWindow** out_hovered_window_under_moving_window);
CIMGUI_API void ImGui_StartMouseMovingWindow(ImGuiWindow* window);
CIMGUI_API void ImGui_StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* node, bool undock);
CIMGUI_API void ImGui_StopMouseMovingWindow(void);
CIMGUI_API void ImGui_UpdateMouseMovingWindowNewFrame(void);
CIMGUI_API void ImGui_UpdateMouseMovingWindowEndFrame(void);

// Generic context hooks
CIMGUI_API ImGuiID ImGui_AddContextHook(ImGuiContext* context, const ImGuiContextHook* hook);
CIMGUI_API void    ImGui_RemoveContextHook(ImGuiContext* context, ImGuiID hook_to_remove);
CIMGUI_API void    ImGui_CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);

// Viewports
CIMGUI_API void                        ImGui_TranslateWindowsInViewport(ImGuiViewportP* viewport, ImVec2 old_pos, ImVec2 new_pos, ImVec2 old_size, ImVec2 new_size);
CIMGUI_API void                        ImGui_ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale);
CIMGUI_API void                        ImGui_DestroyPlatformWindow(ImGuiViewportP* viewport);
CIMGUI_API void                        ImGui_SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
CIMGUI_API void                        ImGui_SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
CIMGUI_API const ImGuiPlatformMonitor* ImGui_GetViewportPlatformMonitor(ImGuiViewport* viewport);
CIMGUI_API ImGuiViewportP*             ImGui_FindHoveredViewportFromPlatformWindowStack(ImVec2 mouse_platform_pos);

// Settings
CIMGUI_API void                  ImGui_MarkIniSettingsDirty(void);
CIMGUI_API void                  ImGui_MarkIniSettingsDirtyImGuiWindowPtr(ImGuiWindow* window);
CIMGUI_API void                  ImGui_ClearIniSettings(void);
CIMGUI_API void                  ImGui_AddSettingsHandler(const ImGuiSettingsHandler* handler);
CIMGUI_API void                  ImGui_RemoveSettingsHandler(const char* type_name);
CIMGUI_API ImGuiSettingsHandler* ImGui_FindSettingsHandler(const char* type_name);

// Settings - Windows
CIMGUI_API ImGuiWindowSettings* ImGui_CreateNewWindowSettings(const char* name);
CIMGUI_API ImGuiWindowSettings* ImGui_FindWindowSettingsByID(ImGuiID id);
CIMGUI_API ImGuiWindowSettings* ImGui_FindWindowSettingsByWindow(ImGuiWindow* window);
CIMGUI_API void                 ImGui_ClearWindowSettings(const char* name);

// Localization
CIMGUI_API void        ImGui_LocalizeRegisterEntries(const ImGuiLocEntry* entries, int count);
CIMGUI_API const char* ImGui_LocalizeGetMsg(ImGuiLocKey key);

// Scrolling
CIMGUI_API void ImGui_SetScrollXImGuiWindowPtr(ImGuiWindow* window, float scroll_x);
CIMGUI_API void ImGui_SetScrollYImGuiWindowPtr(ImGuiWindow* window, float scroll_y);
CIMGUI_API void ImGui_SetScrollFromPosXImGuiWindowPtr(ImGuiWindow* window, float local_x, float center_x_ratio);
CIMGUI_API void ImGui_SetScrollFromPosYImGuiWindowPtr(ImGuiWindow* window, float local_y, float center_y_ratio);

// Early work-in-progress API (ScrollToItem() will become public)
CIMGUI_API void   ImGui_ScrollToItem(ImGuiScrollFlags flags /* = 0 */);
CIMGUI_API void   ImGui_ScrollToRect(ImGuiWindow* window, ImRect rect, ImGuiScrollFlags flags /* = 0 */);
CIMGUI_API ImVec2 ImGui_ScrollToRectEx(ImGuiWindow* window, ImRect rect, ImGuiScrollFlags flags /* = 0 */);
//#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
CIMGUI_API void   ImGui_ScrollToBringRectIntoView(ImGuiWindow* window, ImRect rect);
//#endif

// Basic Accessors
CIMGUI_API ImGuiItemStatusFlags ImGui_GetItemStatusFlags(void);
CIMGUI_API ImGuiItemFlags       ImGui_GetItemFlags(void);
CIMGUI_API ImGuiID              ImGui_GetActiveID(void);
CIMGUI_API ImGuiID              ImGui_GetFocusID(void);
CIMGUI_API void                 ImGui_SetActiveID(ImGuiID id, ImGuiWindow* window);
CIMGUI_API void                 ImGui_SetFocusID(ImGuiID id, ImGuiWindow* window);
CIMGUI_API void                 ImGui_ClearActiveID(void);
CIMGUI_API ImGuiID              ImGui_GetHoveredID(void);
CIMGUI_API void                 ImGui_SetHoveredID(ImGuiID id);
CIMGUI_API void                 ImGui_KeepAliveID(ImGuiID id);
CIMGUI_API void                 ImGui_MarkItemEdited(ImGuiID id);                                                        // Mark data associated to given item as "edited", used by IsItemDeactivatedAfterEdit() function.
CIMGUI_API void                 ImGui_PushOverrideID(ImGuiID id);                                                        // Push given value as-is at the top of the ID stack (whereas PushID combines old and new hashes)
CIMGUI_API ImGuiID              ImGui_GetIDWithSeedStr(const char* str_id_begin, const char* str_id_end, ImGuiID seed);
CIMGUI_API ImGuiID              ImGui_GetIDWithSeed(int n, ImGuiID seed);

// Basic Helpers for widget code
CIMGUI_API void   ImGui_ItemSize(ImVec2 size, float text_baseline_y /* = -1.0f */);
CIMGUI_API void   ImGui_ItemSizeImRect(ImRect bb, float text_baseline_y /* = -1.0f */);                                                    // FIXME: This is a misleading API since we expect CursorPos to be bb.Min.
CIMGUI_API bool   ImGui_ItemAdd(ImRect bb, ImGuiID id, const ImRect* nav_bb /* = NULL */, ImGuiItemFlags extra_flags /* = 0 */);
CIMGUI_API bool   ImGui_ItemHoverable(ImRect bb, ImGuiID id, ImGuiItemFlags item_flags);
CIMGUI_API bool   ImGui_IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags /* = 0 */);
CIMGUI_API bool   ImGui_IsClippedEx(ImRect bb, ImGuiID id);
CIMGUI_API void   ImGui_SetLastItemData(ImGuiID item_id, ImGuiItemFlags item_flags, ImGuiItemStatusFlags status_flags, ImRect item_rect);
CIMGUI_API ImVec2 ImGui_CalcItemSize(ImVec2 size, float default_w, float default_h);
CIMGUI_API float  ImGui_CalcWrapWidthForPos(ImVec2 pos, float wrap_pos_x);
CIMGUI_API void   ImGui_PushMultiItemsWidths(int components, float width_full);
CIMGUI_API void   ImGui_ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess, float width_min);
CIMGUI_API void   ImGui_CalcClipRectVisibleItemsY(ImRect clip_rect, ImVec2 pos, float items_height, int* out_visible_start, int* out_visible_end);

// Parameter stacks (shared)
CIMGUI_API const ImGuiStyleVarInfo* ImGui_GetStyleVarInfo(ImGuiStyleVar idx);
CIMGUI_API void                     ImGui_BeginDisabledOverrideReenable(void);
CIMGUI_API void                     ImGui_EndDisabledOverrideReenable(void);

// Logging/Capture
CIMGUI_API void ImGui_LogBegin(ImGuiLogFlags flags, int auto_open_depth);                                           // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name.
CIMGUI_API void ImGui_LogToBuffer(int auto_open_depth /* = -1 */);                                                  // Start logging/capturing to internal buffer
CIMGUI_API void ImGui_LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end /* = NULL */);
CIMGUI_API void ImGui_LogSetNextTextDecoration(const char* prefix, const char* suffix);

// Childs
CIMGUI_API bool ImGui_BeginChildEx(const char* name, ImGuiID id, ImVec2 size_arg, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags);

// Popups, Modals
CIMGUI_API bool         ImGui_BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_window_flags);
CIMGUI_API bool         ImGui_BeginPopupMenuEx(ImGuiID id, const char* label, ImGuiWindowFlags extra_window_flags);
CIMGUI_API void         ImGui_OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags /* = ImGuiPopupFlags_None */);
CIMGUI_API void         ImGui_ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
CIMGUI_API void         ImGui_ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
CIMGUI_API void         ImGui_ClosePopupsExceptModals(void);
CIMGUI_API bool         ImGui_IsPopupOpenID(ImGuiID id, ImGuiPopupFlags popup_flags);
CIMGUI_API ImRect       ImGui_GetPopupAllowedExtentRect(ImGuiWindow* window);
CIMGUI_API ImGuiWindow* ImGui_GetTopMostPopupModal(void);
CIMGUI_API ImGuiWindow* ImGui_GetTopMostAndVisiblePopupModal(void);
CIMGUI_API ImGuiWindow* ImGui_FindBlockingModal(ImGuiWindow* window);
CIMGUI_API ImVec2       ImGui_FindBestWindowPosForPopup(ImGuiWindow* window);
CIMGUI_API ImVec2       ImGui_FindBestWindowPosForPopupEx(ImVec2 ref_pos, ImVec2 size, ImGuiDir* last_dir, ImRect r_outer, ImRect r_avoid, ImGuiPopupPositionPolicy policy);

// Tooltips
CIMGUI_API bool ImGui_BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags extra_window_flags);
CIMGUI_API bool ImGui_BeginTooltipHidden(void);

// Menus
CIMGUI_API bool ImGui_BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
CIMGUI_API bool ImGui_BeginMenuWithIcon(const char* label, const char* icon, bool enabled /* = true */);
CIMGUI_API bool ImGui_MenuItemWithIcon(const char* label, const char* icon, const char* shortcut /* = NULL */, bool selected /* = false */, bool enabled /* = true */);

// Combos
CIMGUI_API bool ImGui_BeginComboPopup(ImGuiID popup_id, ImRect bb, ImGuiComboFlags flags);
CIMGUI_API bool ImGui_BeginComboPreview(void);
CIMGUI_API void ImGui_EndComboPreview(void);

// Keyboard/Gamepad Navigation
CIMGUI_API void ImGui_NavInitWindow(ImGuiWindow* window, bool force_reinit);
CIMGUI_API void ImGui_NavInitRequestApplyResult(void);
CIMGUI_API bool ImGui_NavMoveRequestButNoResultYet(void);
CIMGUI_API void ImGui_NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags);
CIMGUI_API void ImGui_NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags);
CIMGUI_API void ImGui_NavMoveRequestResolveWithLastItem(ImGuiNavItemData* result);
CIMGUI_API void ImGui_NavMoveRequestResolveWithPastTreeNode(ImGuiNavItemData* result, const ImGuiTreeNodeStackData* tree_node_data);
CIMGUI_API void ImGui_NavMoveRequestCancel(void);
CIMGUI_API void ImGui_NavMoveRequestApplyResult(void);
CIMGUI_API void ImGui_NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
CIMGUI_API void ImGui_NavHighlightActivated(ImGuiID id);
CIMGUI_API void ImGui_NavClearPreferredPosForAxis(ImGuiAxis axis);
CIMGUI_API void ImGui_SetNavCursorVisibleAfterMove(void);
CIMGUI_API void ImGui_NavUpdateCurrentWindowIsScrollPushableX(void);
CIMGUI_API void ImGui_SetNavWindow(ImGuiWindow* window);
CIMGUI_API void ImGui_SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, ImRect rect_rel);
CIMGUI_API void ImGui_SetNavFocusScope(ImGuiID focus_scope_id);

// Focus/Activation
// This should be part of a larger set of API: FocusItem(offset = -1), FocusItemByID(id), ActivateItem(offset = -1), ActivateItemByID(id) etc. which are
// much harder to design and implement than expected. I have a couple of private branches on this matter but it's not simple. For now implementing the easy ones.
CIMGUI_API void ImGui_FocusItem(void);               // Focus last item (no selection/activation).
CIMGUI_API void ImGui_ActivateItemByID(ImGuiID id);  // Activate an item by ID (button, checkbox, tree node etc.). Activation is queued and processed on the next frame when the item is encountered again. Was called 'ActivateItem()' before 1.89.7.

// Inputs
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
CIMGUI_API bool          ImGui_IsNamedKey(ImGuiKey key);
CIMGUI_API bool          ImGui_IsNamedKeyOrMod(ImGuiKey key);
CIMGUI_API bool          ImGui_IsLegacyKey(ImGuiKey key);
CIMGUI_API bool          ImGui_IsKeyboardKey(ImGuiKey key);
CIMGUI_API bool          ImGui_IsGamepadKey(ImGuiKey key);
CIMGUI_API bool          ImGui_IsMouseKey(ImGuiKey key);
CIMGUI_API bool          ImGui_IsAliasKey(ImGuiKey key);
CIMGUI_API bool          ImGui_IsLRModKey(ImGuiKey key);
CIMGUI_API ImGuiKeyChord ImGui_FixupKeyChord(ImGuiKeyChord key_chord);
CIMGUI_API ImGuiKey      ImGui_ConvertSingleModFlagToKey(ImGuiKey key);

CIMGUI_API ImGuiKeyData* ImGui_GetKeyDataImGuiContextPtr(ImGuiContext* ctx, ImGuiKey key);
CIMGUI_API ImGuiKeyData* ImGui_GetKeyData(ImGuiKey key);
CIMGUI_API const char*   ImGui_GetKeyChordName(ImGuiKeyChord key_chord);
CIMGUI_API ImGuiKey      ImGui_MouseButtonToKey(ImGuiMouseButton button);
CIMGUI_API bool          ImGui_IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold /* = -1.0f */);
CIMGUI_API ImVec2        ImGui_GetKeyMagnitude2d(ImGuiKey key_left, ImGuiKey key_right, ImGuiKey key_up, ImGuiKey key_down);
CIMGUI_API float         ImGui_GetNavTweakPressedAmount(ImGuiAxis axis);
CIMGUI_API int           ImGui_CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate);
CIMGUI_API void          ImGui_GetTypematicRepeatRate(ImGuiInputFlags flags, float* repeat_delay, float* repeat_rate);
CIMGUI_API void          ImGui_TeleportMousePos(ImVec2 pos);
CIMGUI_API void          ImGui_SetActiveIdUsingAllKeyboardKeys(void);
CIMGUI_API bool          ImGui_IsActiveIdUsingNavDir(ImGuiDir dir);

// [EXPERIMENTAL] Low-Level: Key/Input Ownership
// - The idea is that instead of "eating" a given input, we can link to an owner id.
// - Ownership is most often claimed as a result of reacting to a press/down event (but occasionally may be claimed ahead).
// - Input queries can then read input by specifying ImGuiKeyOwner_Any (== 0), ImGuiKeyOwner_NoOwner (== -1) or a custom ID.
// - Legacy input queries (without specifying an owner or _Any or _None) are equivalent to using ImGuiKeyOwner_Any (== 0).
// - Input ownership is automatically released on the frame after a key is released. Therefore:
//   - for ownership registration happening as a result of a down/press event, the SetKeyOwner() call may be done once (common case).
//   - for ownership registration happening ahead of a down/press event, the SetKeyOwner() call needs to be made every frame (happens if e.g. claiming ownership on hover).
// - SetItemKeyOwner() is a shortcut for common simple case. A custom widget will probably want to call SetKeyOwner() multiple times directly based on its interaction state.
// - This is marked experimental because not all widgets are fully honoring the Set/Test idioms. We will need to move forward step by step.
//   Please open a GitHub Issue to submit your usage scenario or if there's a use case you need solved.
CIMGUI_API ImGuiID            ImGui_GetKeyOwner(ImGuiKey key);
CIMGUI_API void               ImGui_SetKeyOwner(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags /* = 0 */);
CIMGUI_API void               ImGui_SetKeyOwnersForKeyChord(ImGuiKeyChord key, ImGuiID owner_id, ImGuiInputFlags flags /* = 0 */);
CIMGUI_API void               ImGui_SetItemKeyOwnerImGuiInputFlags(ImGuiKey key, ImGuiInputFlags flags);  // Set key owner to last item if it is hovered or active. Equivalent to 'if (IsItemHovered() || IsItemActive()) { SetKeyOwner(key, GetItemID());'.
CIMGUI_API bool               ImGui_TestKeyOwner(ImGuiKey key, ImGuiID owner_id);                         // Test that key is either not owned, either owned by 'owner_id'
CIMGUI_API ImGuiKeyOwnerData* ImGui_GetKeyOwnerData(ImGuiContext* ctx, ImGuiKey key);

// [EXPERIMENTAL] High-Level: Input Access functions w/ support for Key/Input Ownership
// - Important: legacy IsKeyPressed(ImGuiKey, bool repeat=true) _DEFAULTS_ to repeat, new IsKeyPressed() requires _EXPLICIT_ ImGuiInputFlags_Repeat flag.
// - Expected to be later promoted to public API, the prototypes are designed to replace existing ones (since owner_id can default to Any == 0)
// - Specifying a value for 'ImGuiID owner' will test that EITHER the key is NOT owned (UNLESS locked), EITHER the key is owned by 'owner'.
//   Legacy functions use ImGuiKeyOwner_Any meaning that they typically ignore ownership, unless a call to SetKeyOwner() explicitly used ImGuiInputFlags_LockThisFrame or ImGuiInputFlags_LockUntilRelease.
// - Binding generators may want to ignore those for now, or suffix them with Ex() until we decide if this gets moved into public API.
CIMGUI_API bool ImGui_IsKeyDownID(ImGuiKey key, ImGuiID owner_id);
CIMGUI_API bool ImGui_IsKeyPressedImGuiInputFlags(ImGuiKey key, ImGuiInputFlags flags, ImGuiID owner_id /* = 0 */);                  // Important: when transitioning from old to new IsKeyPressed(): old API has "bool repeat = true", so would default to repeat. New API requires explicit ImGuiInputFlags_Repeat.
CIMGUI_API bool ImGui_IsKeyReleasedID(ImGuiKey key, ImGuiID owner_id);
CIMGUI_API bool ImGui_IsKeyChordPressedImGuiInputFlags(ImGuiKeyChord key_chord, ImGuiInputFlags flags, ImGuiID owner_id /* = 0 */);
CIMGUI_API bool ImGui_IsMouseDownID(ImGuiMouseButton button, ImGuiID owner_id);
CIMGUI_API bool ImGui_IsMouseClickedImGuiInputFlags(ImGuiMouseButton button, ImGuiInputFlags flags, ImGuiID owner_id /* = 0 */);
CIMGUI_API bool ImGui_IsMouseReleasedID(ImGuiMouseButton button, ImGuiID owner_id);
CIMGUI_API bool ImGui_IsMouseDoubleClickedID(ImGuiMouseButton button, ImGuiID owner_id);

// Shortcut Testing & Routing
// - Set Shortcut() and SetNextItemShortcut() in imgui.h
// - When a policy (except for ImGuiInputFlags_RouteAlways *) is set, Shortcut() will register itself with SetShortcutRouting(),
//   allowing the system to decide where to route the input among other route-aware calls.
//   (* using ImGuiInputFlags_RouteAlways is roughly equivalent to calling IsKeyChordPressed(key) and bypassing route registration and check)
// - When using one of the routing option:
//   - The default route is ImGuiInputFlags_RouteFocused (accept inputs if window is in focus stack. Deep-most focused window takes inputs. ActiveId takes inputs over deep-most focused window.)
//   - Routes are requested given a chord (key + modifiers) and a routing policy.
//   - Routes are resolved during NewFrame(): if keyboard modifiers are matching current ones: SetKeyOwner() is called + route is granted for the frame.
//   - Each route may be granted to a single owner. When multiple requests are made we have policies to select the winning route (e.g. deep most window).
//   - Multiple read sites may use the same owner id can all access the granted route.
//   - When owner_id is 0 we use the current Focus Scope ID as a owner ID in order to identify our location.
// - You can chain two unrelated windows in the focus stack using SetWindowParentWindowForFocusRoute()
//   e.g. if you have a tool window associated to a document, and you want document shortcuts to run when the tool is focused.
CIMGUI_API bool                 ImGui_ShortcutID(ImGuiKeyChord key_chord, ImGuiInputFlags flags, ImGuiID owner_id);
CIMGUI_API bool                 ImGui_SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiInputFlags flags, ImGuiID owner_id);  // owner_id needs to be explicit and cannot be 0
CIMGUI_API bool                 ImGui_TestShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id);
CIMGUI_API ImGuiKeyRoutingData* ImGui_GetShortcutRoutingData(ImGuiKeyChord key_chord);

// Docking
// (some functions are only declared in imgui.cpp, see Docking section)
CIMGUI_API void           ImGui_DockContextInitialize(ImGuiContext* ctx);
CIMGUI_API void           ImGui_DockContextShutdown(ImGuiContext* ctx);
CIMGUI_API void           ImGui_DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_settings_refs);              // Use root_id==0 to clear all
CIMGUI_API void           ImGui_DockContextRebuildNodes(ImGuiContext* ctx);
CIMGUI_API void           ImGui_DockContextNewFrameUpdateUndocking(ImGuiContext* ctx);
CIMGUI_API void           ImGui_DockContextNewFrameUpdateDocking(ImGuiContext* ctx);
CIMGUI_API void           ImGui_DockContextEndFrame(ImGuiContext* ctx);
CIMGUI_API ImGuiID        ImGui_DockContextGenNodeID(ImGuiContext* ctx);
CIMGUI_API void           ImGui_DockContextQueueDock(ImGuiContext* ctx, ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, float split_ratio, bool split_outer);
CIMGUI_API void           ImGui_DockContextQueueUndockWindow(ImGuiContext* ctx, ImGuiWindow* window);
CIMGUI_API void           ImGui_DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
CIMGUI_API void           ImGui_DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref /* = true */);
CIMGUI_API void           ImGui_DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
CIMGUI_API bool           ImGui_DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload_window, ImGuiDockNode* payload_node, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos);
CIMGUI_API ImGuiDockNode* ImGui_DockContextFindNodeByID(ImGuiContext* ctx, ImGuiID id);
CIMGUI_API void           ImGui_DockNodeWindowMenuHandler_Default(ImGuiContext* ctx, ImGuiDockNode* node, ImGuiTabBar* tab_bar);
CIMGUI_API bool           ImGui_DockNodeBeginAmendTabBar(ImGuiDockNode* node);
CIMGUI_API void           ImGui_DockNodeEndAmendTabBar(void);
CIMGUI_API ImGuiDockNode* ImGui_DockNodeGetRootNode(ImGuiDockNode* node);
CIMGUI_API bool           ImGui_DockNodeIsInHierarchyOf(ImGuiDockNode* node, ImGuiDockNode* parent);
CIMGUI_API int            ImGui_DockNodeGetDepth(const ImGuiDockNode* node);
CIMGUI_API ImGuiID        ImGui_DockNodeGetWindowMenuButtonId(const ImGuiDockNode* node);
CIMGUI_API ImGuiDockNode* ImGui_GetWindowDockNode(void);
CIMGUI_API bool           ImGui_GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window);
CIMGUI_API void           ImGui_BeginDocked(ImGuiWindow* window, bool* p_open);
CIMGUI_API void           ImGui_BeginDockableDragDropSource(ImGuiWindow* window);
CIMGUI_API void           ImGui_BeginDockableDragDropTarget(ImGuiWindow* window);
CIMGUI_API void           ImGui_SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond);

// Docking - Builder function needs to be generally called before the node is used/submitted.
// - The DockBuilderXXX functions are designed to _eventually_ become a public API, but it is too early to expose it and guarantee stability.
// - Do not hold on ImGuiDockNode* pointers! They may be invalidated by any split/merge/remove operation and every frame.
// - To create a DockSpace() node, make sure to set the ImGuiDockNodeFlags_DockSpace flag when calling DockBuilderAddNode().
//   You can create dockspace nodes (attached to a window) _or_ floating nodes (carry its own window) with this API.
// - DockBuilderSplitNode() create 2 child nodes within 1 node. The initial node becomes a parent node.
// - If you intend to split the node immediately after creation using DockBuilderSplitNode(), make sure
//   to call DockBuilderSetNodeSize() beforehand. If you don't, the resulting split sizes may not be reliable.
// - Call DockBuilderFinish() after you are done.
CIMGUI_API void           ImGui_DockBuilderDockWindow(const char* window_name, ImGuiID node_id);
CIMGUI_API ImGuiDockNode* ImGui_DockBuilderGetNode(ImGuiID node_id);
CIMGUI_API ImGuiDockNode* ImGui_DockBuilderGetCentralNode(ImGuiID node_id);
CIMGUI_API ImGuiID        ImGui_DockBuilderAddNode(ImGuiID node_id /* = 0 */, ImGuiDockNodeFlags flags /* = 0 */);
CIMGUI_API void           ImGui_DockBuilderRemoveNode(ImGuiID node_id);                                                                 // Remove node and all its child, undock all windows
CIMGUI_API void           ImGui_DockBuilderRemoveNodeDockedWindows(ImGuiID node_id, bool clear_settings_refs /* = true */);
CIMGUI_API void           ImGui_DockBuilderRemoveNodeChildNodes(ImGuiID node_id);                                                       // Remove all split/hierarchy. All remaining docked windows will be re-docked to the remaining root node (node_id).
CIMGUI_API void           ImGui_DockBuilderSetNodePos(ImGuiID node_id, ImVec2 pos);
CIMGUI_API void           ImGui_DockBuilderSetNodeSize(ImGuiID node_id, ImVec2 size);
CIMGUI_API ImGuiID        ImGui_DockBuilderSplitNode(ImGuiID node_id, ImGuiDir split_dir, float size_ratio_for_node_at_dir, ImGuiID* out_id_at_dir, ImGuiID* out_id_at_opposite_dir); // Create 2 child nodes in this parent node.
CIMGUI_API void           ImGui_DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_dockspace_id, ImVector_const_charPtr* in_window_remap_pairs);
CIMGUI_API void           ImGui_DockBuilderCopyNode(ImGuiID src_node_id, ImGuiID dst_node_id, ImVector_ImGuiID* out_node_remap_pairs);
CIMGUI_API void           ImGui_DockBuilderCopyWindowSettings(const char* src_name, const char* dst_name);
CIMGUI_API void           ImGui_DockBuilderFinish(ImGuiID node_id);

// [EXPERIMENTAL] Focus Scope
// This is generally used to identify a unique input location (for e.g. a selection set)
// There is one per window (automatically set in Begin), but:
// - Selection patterns generally need to react (e.g. clear a selection) when landing on one item of the set.
//   So in order to identify a set multiple lists in same window may each need a focus scope.
//   If you imagine an hypothetical BeginSelectionGroup()/EndSelectionGroup() api, it would likely call PushFocusScope()/EndFocusScope()
// - Shortcut routing also use focus scope as a default location identifier if an owner is not provided.
// We don't use the ID Stack for this as it is common to want them separate.
CIMGUI_API void    ImGui_PushFocusScope(ImGuiID id);
CIMGUI_API void    ImGui_PopFocusScope(void);
CIMGUI_API ImGuiID ImGui_GetCurrentFocusScope(void);  // Focus scope we are outputting into, set by PushFocusScope()

// Drag and Drop
CIMGUI_API bool ImGui_IsDragDropActive(void);
CIMGUI_API bool ImGui_BeginDragDropTargetCustom(ImRect bb, ImGuiID id);
CIMGUI_API bool ImGui_BeginDragDropTargetViewport(ImGuiViewport* viewport, const ImRect* p_bb /* = NULL */);
CIMGUI_API void ImGui_ClearDragDrop(void);
CIMGUI_API bool ImGui_IsDragDropPayloadBeingAccepted(void);
CIMGUI_API void ImGui_RenderDragDropTargetRectForItem(ImRect bb);
CIMGUI_API void ImGui_RenderDragDropTargetRectEx(ImDrawList* draw_list, ImRect bb);

// Typing-Select API
// (provide Windows Explorer style "select items by typing partial name" + "cycle through items by typing same letter" feature)
// (this is currently not documented nor used by main library, but should work. See "widgets_typingselect" in imgui_test_suite for usage code. Please let us know if you use this!)
CIMGUI_API ImGuiTypingSelectRequest* ImGui_GetTypingSelectRequest(ImGuiTypingSelectFlags flags /* = ImGuiTypingSelectFlags_None */);
CIMGUI_API int                       ImGui_TypingSelectFindMatch(ImGuiTypingSelectRequest* req, int items_count, const char* (*get_item_name_func)(void*, int), void* user_data, int nav_item_idx);
CIMGUI_API int                       ImGui_TypingSelectFindNextSingleCharMatch(ImGuiTypingSelectRequest* req, int items_count, const char* (*get_item_name_func)(void*, int), void* user_data, int nav_item_idx);
CIMGUI_API int                       ImGui_TypingSelectFindBestLeadingMatch(ImGuiTypingSelectRequest* req, int items_count, const char* (*get_item_name_func)(void*, int), void* user_data);

// Box-Select API
CIMGUI_API bool ImGui_BeginBoxSelect(ImRect scope_rect, ImGuiWindow* window, ImGuiID box_select_id, ImGuiMultiSelectFlags ms_flags);
CIMGUI_API void ImGui_EndBoxSelect(ImRect scope_rect, ImGuiMultiSelectFlags ms_flags);

// Multi-Select API
CIMGUI_API void                   ImGui_MultiSelectItemHeader(ImGuiID id, bool* p_selected, ImGuiButtonFlags* p_button_flags);
CIMGUI_API void                   ImGui_MultiSelectItemFooter(ImGuiID id, bool* p_selected, bool* p_pressed);
CIMGUI_API void                   ImGui_MultiSelectAddSetAll(ImGuiMultiSelectTempData* ms, bool selected);
CIMGUI_API void                   ImGui_MultiSelectAddSetRange(ImGuiMultiSelectTempData* ms, bool selected, int range_dir, ImGuiSelectionUserData first_item, ImGuiSelectionUserData last_item);
CIMGUI_API ImGuiBoxSelectState*   ImGui_GetBoxSelectState(ImGuiID id);
CIMGUI_API ImGuiMultiSelectState* ImGui_GetMultiSelectState(ImGuiID id);

// Internal Columns API (this is not exposed because we will encourage transitioning to the Tables API)
CIMGUI_API void             ImGui_SetWindowClipRectBeforeSetChannel(ImGuiWindow* window, ImRect clip_rect);
CIMGUI_API void             ImGui_BeginColumns(const char* str_id, int count, ImGuiOldColumnFlags flags /* = 0 */);  // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
CIMGUI_API void             ImGui_EndColumns(void);                                                                  // close columns
CIMGUI_API void             ImGui_PushColumnClipRect(int column_index);
CIMGUI_API void             ImGui_PushColumnsBackground(void);
CIMGUI_API void             ImGui_PopColumnsBackground(void);
CIMGUI_API ImGuiID          ImGui_GetColumnsID(const char* str_id, int count);
CIMGUI_API ImGuiOldColumns* ImGui_FindOrCreateColumns(ImGuiWindow* window, ImGuiID id);
CIMGUI_API float            ImGui_GetColumnOffsetFromNorm(const ImGuiOldColumns* columns, float offset_norm);
CIMGUI_API float            ImGui_GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset);

// Tables: Candidates for public API
CIMGUI_API void  ImGui_TableOpenContextMenu(int column_n /* = -1 */);
CIMGUI_API void  ImGui_TableSetColumnWidth(int column_n, float width);
CIMGUI_API void  ImGui_TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs);
CIMGUI_API int   ImGui_TableGetHoveredRow(void);                 // Retrieve *PREVIOUS FRAME* hovered row. This difference with TableGetHoveredColumn() is the reason why this is not public yet.
CIMGUI_API float ImGui_TableGetHeaderRowHeight(void);
CIMGUI_API float ImGui_TableGetHeaderAngledMaxLabelWidth(void);
CIMGUI_API void  ImGui_TablePushBackgroundChannel(void);
CIMGUI_API void  ImGui_TablePopBackgroundChannel(void);
CIMGUI_API void  ImGui_TablePushColumnChannel(int column_n);
CIMGUI_API void  ImGui_TablePopColumnChannel(void);
CIMGUI_API void  ImGui_TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label_width, const ImGuiTableHeaderData* data, int data_count);

// Tables: Internals
CIMGUI_API ImGuiTable*             ImGui_GetCurrentTable(void);
CIMGUI_API ImGuiTable*             ImGui_TableFindByID(ImGuiID id);
CIMGUI_API bool                    ImGui_BeginTableWithID(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags /* = 0 */, ImVec2 outer_size /* = ImVec2(0, 0) */, float inner_width /* = 0.0f */);
CIMGUI_API void                    ImGui_TableBeginInitMemory(ImGuiTable* table, int columns_count);
CIMGUI_API void                    ImGui_TableBeginApplyRequests(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableSetupDrawChannels(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableUpdateLayout(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableUpdateBorders(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableUpdateColumnsWeightFromWidth(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableDrawBorders(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableDrawDefaultContextMenu(ImGuiTable* table, ImGuiTableFlags flags_for_section_to_display);
CIMGUI_API bool                    ImGui_TableBeginContextMenuPopup(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableMergeDrawChannels(ImGuiTable* table);
CIMGUI_API ImGuiTableInstanceData* ImGui_TableGetInstanceData(ImGuiTable* table, int instance_no);
CIMGUI_API ImGuiID                 ImGui_TableGetInstanceID(ImGuiTable* table, int instance_no);
CIMGUI_API void                    ImGui_TableSortSpecsSanitize(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableSortSpecsBuild(ImGuiTable* table);
CIMGUI_API ImGuiSortDirection      ImGui_TableGetColumnNextSortDirection(ImGuiTableColumn* column);
CIMGUI_API void                    ImGui_TableFixColumnSortDirection(ImGuiTable* table, ImGuiTableColumn* column);
CIMGUI_API float                   ImGui_TableGetColumnWidthAuto(ImGuiTable* table, ImGuiTableColumn* column);
CIMGUI_API void                    ImGui_TableBeginRow(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableEndRow(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableBeginCell(ImGuiTable* table, int column_n);
CIMGUI_API void                    ImGui_TableEndCell(ImGuiTable* table);
CIMGUI_API ImRect                  ImGui_TableGetCellBgRect(const ImGuiTable* table, int column_n);
CIMGUI_API const char*             ImGui_TableGetColumnNameImGuiTablePtr(const ImGuiTable* table, int column_n);
CIMGUI_API ImGuiID                 ImGui_TableGetColumnResizeID(ImGuiTable* table, int column_n, int instance_no /* = 0 */);
CIMGUI_API float                   ImGui_TableCalcMaxColumnWidth(const ImGuiTable* table, int column_n);
CIMGUI_API void                    ImGui_TableSetColumnWidthAutoSingle(ImGuiTable* table, int column_n);
CIMGUI_API void                    ImGui_TableSetColumnWidthAutoAll(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableRemove(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableGcCompactTransientBuffers(ImGuiTable* table);
CIMGUI_API void                    ImGui_TableGcCompactTransientBuffersImGuiTableTempDataPtr(ImGuiTableTempData* table);
CIMGUI_API void                    ImGui_TableGcCompactSettings(void);

// Tables: Settings
CIMGUI_API void                ImGui_TableLoadSettings(ImGuiTable* table);
CIMGUI_API void                ImGui_TableSaveSettings(ImGuiTable* table);
CIMGUI_API void                ImGui_TableResetSettings(ImGuiTable* table);
CIMGUI_API ImGuiTableSettings* ImGui_TableGetBoundSettings(ImGuiTable* table);
CIMGUI_API void                ImGui_TableSettingsAddSettingsHandler(void);
CIMGUI_API ImGuiTableSettings* ImGui_TableSettingsCreate(ImGuiID id, int columns_count);
CIMGUI_API ImGuiTableSettings* ImGui_TableSettingsFindByID(ImGuiID id);

// Tab Bars
CIMGUI_API ImGuiTabBar*  ImGui_GetCurrentTabBar(void);
CIMGUI_API ImGuiTabBar*  ImGui_TabBarFindByID(ImGuiID id);
CIMGUI_API void          ImGui_TabBarRemove(ImGuiTabBar* tab_bar);
CIMGUI_API bool          ImGui_BeginTabBarEx(ImGuiTabBar* tab_bar, ImRect bb, ImGuiTabBarFlags flags);
CIMGUI_API ImGuiTabItem* ImGui_TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id);
CIMGUI_API ImGuiTabItem* ImGui_TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order);
CIMGUI_API ImGuiTabItem* ImGui_TabBarFindMostRecentlySelectedTabForActiveWindow(ImGuiTabBar* tab_bar);
CIMGUI_API ImGuiTabItem* ImGui_TabBarGetCurrentTab(ImGuiTabBar* tab_bar);
CIMGUI_API int           ImGui_TabBarGetTabOrder(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
CIMGUI_API const char*   ImGui_TabBarGetTabName(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
CIMGUI_API void          ImGui_TabBarAddTab(ImGuiTabBar* tab_bar, ImGuiTabItemFlags tab_flags, ImGuiWindow* window);
CIMGUI_API void          ImGui_TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id);
CIMGUI_API void          ImGui_TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
CIMGUI_API void          ImGui_TabBarQueueFocus(ImGuiTabBar* tab_bar, ImGuiTabItem* tab);
CIMGUI_API void          ImGui_TabBarQueueFocusStr(ImGuiTabBar* tab_bar, const char* tab_name);
CIMGUI_API void          ImGui_TabBarQueueReorder(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, int offset);
CIMGUI_API void          ImGui_TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, ImVec2 mouse_pos);
CIMGUI_API bool          ImGui_TabBarProcessReorder(ImGuiTabBar* tab_bar);
CIMGUI_API bool          ImGui_TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window);
CIMGUI_API void          ImGui_TabItemSpacing(const char* str_id, ImGuiTabItemFlags flags, float width);
CIMGUI_API ImVec2        ImGui_TabItemCalcSizeStr(const char* label, bool has_close_button_or_unsaved_marker);
CIMGUI_API ImVec2        ImGui_TabItemCalcSize(ImGuiWindow* window);
CIMGUI_API void          ImGui_TabItemBackground(ImDrawList* draw_list, ImRect bb, ImGuiTabItemFlags flags, ImU32 col);
CIMGUI_API void          ImGui_TabItemLabelAndCloseButton(ImDrawList* draw_list, ImRect bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible, bool* out_just_closed, bool* out_text_clipped);

// Render helpers
// 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.
// NB: All position are in absolute pixels coordinates (we are never using window coordinates internally)
CIMGUI_API void        ImGui_RenderText(ImVec2 pos, const char* text, const char* text_end /* = NULL */, bool hide_text_after_hash /* = true */);
CIMGUI_API void        ImGui_RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
CIMGUI_API void        ImGui_RenderTextClipped(ImVec2 pos_min, ImVec2 pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImVec2 align /* = ImVec2(0, 0) */, const ImRect* clip_rect /* = NULL */);
CIMGUI_API void        ImGui_RenderTextClippedWithDrawList(ImDrawList* draw_list, ImVec2 pos_min, ImVec2 pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImVec2 align /* = ImVec2(0, 0) */, const ImRect* clip_rect /* = NULL */);
CIMGUI_API void        ImGui_RenderTextEllipsis(ImDrawList* draw_list, ImVec2 pos_min, ImVec2 pos_max, float ellipsis_max_x, const char* text, const char* text_end, const ImVec2* text_size_if_known);
CIMGUI_API void        ImGui_RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool borders /* = true */, float rounding /* = 0.0f */);
CIMGUI_API void        ImGui_RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding /* = 0.0f */);
CIMGUI_API void        ImGui_RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding /* = 0.0f */, ImDrawFlags flags /* = 0 */);
CIMGUI_API void        ImGui_RenderNavCursor(ImRect bb, ImGuiID id, ImGuiNavRenderCursorFlags flags /* = ImGuiNavRenderCursorFlags_None */);                   // Navigation highlight
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
CIMGUI_API void ImGui_RenderNavHighlight(ImRect bb, ImGuiID id, ImGuiNavRenderCursorFlags flags /* = ImGuiNavRenderCursorFlags_None */);  // Renamed in 1.91.4
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
CIMGUI_API const char* ImGui_FindRenderedTextEnd(const char* text, const char* text_end /* = NULL */);                                                         // Find the optional ## from which we stop displaying text.
CIMGUI_API void        ImGui_RenderMouseCursor(ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);

// Render helpers (those functions don't access any ImGui state!)
CIMGUI_API void        ImGui_RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale /* = 1.0f */);
CIMGUI_API void        ImGui_RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col);
CIMGUI_API void        ImGui_RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz);
CIMGUI_API void        ImGui_RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
CIMGUI_API void        ImGui_RenderArrowDockMenu(ImDrawList* draw_list, ImVec2 p_min, float sz, ImU32 col);
CIMGUI_API void        ImGui_RenderRectFilledRangeH(ImDrawList* draw_list, ImRect rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
CIMGUI_API void        ImGui_RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding);
CIMGUI_API ImDrawFlags ImGui_CalcRoundingFlagsForRectInRect(ImRect r_in, ImRect r_outer, float threshold);

// Widgets: Text
CIMGUI_API void ImGui_TextEx(const char* text, const char* text_end /* = NULL */, ImGuiTextFlags flags /* = 0 */);
CIMGUI_API void ImGui_TextAligned(float align_x, float size_x, const char* fmt, ...);            // FIXME-WIP: Works but API is likely to be reworked. This is designed for 1 item on the line. (#7024)
CIMGUI_API void ImGui_TextAlignedV(float align_x, float size_x, const char* fmt, va_list args);

// Widgets
CIMGUI_API bool ImGui_ButtonWithFlags(const char* label, ImVec2 size_arg /* = ImVec2(0, 0) */, ImGuiButtonFlags flags /* = 0 */);
CIMGUI_API bool ImGui_ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags /* = 0 */);
CIMGUI_API bool ImGui_ImageButtonWithFlags(ImGuiID id, ImTextureRef tex_ref, ImVec2 image_size, ImVec2 uv0, ImVec2 uv1, ImVec4 bg_col, ImVec4 tint_col, ImGuiButtonFlags flags /* = 0 */);
CIMGUI_API void ImGui_SeparatorEx(ImGuiSeparatorFlags flags, float thickness /* = 1.0f */);
CIMGUI_API void ImGui_SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_width);
CIMGUI_API bool ImGui_CheckboxFlagsImS64Ptr(const char* label, ImS64* flags, ImS64 flags_value);
CIMGUI_API bool ImGui_CheckboxFlagsImU64Ptr(const char* label, ImU64* flags, ImU64 flags_value);

// Widgets: Window Decorations
CIMGUI_API bool    ImGui_CloseButton(ImGuiID id, ImVec2 pos);
CIMGUI_API bool    ImGui_CollapseButton(ImGuiID id, ImVec2 pos, ImGuiDockNode* dock_node);
CIMGUI_API void    ImGui_Scrollbar(ImGuiAxis axis);
CIMGUI_API bool    ImGui_ScrollbarEx(ImRect bb, ImGuiID id, ImGuiAxis axis, ImS64* p_scroll_v, ImS64 avail_v, ImS64 contents_v, ImDrawFlags draw_rounding_flags /* = 0 */);
CIMGUI_API ImRect  ImGui_GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis);
CIMGUI_API ImGuiID ImGui_GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis);
CIMGUI_API ImGuiID ImGui_GetWindowResizeCornerID(ImGuiWindow* window, int n);         // 0..3: corners
CIMGUI_API ImGuiID ImGui_GetWindowResizeBorderID(ImGuiWindow* window, ImGuiDir dir);

// Widgets low-level behaviors
CIMGUI_API bool ImGui_ButtonBehavior(ImRect bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags /* = 0 */);
CIMGUI_API bool ImGui_DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags);
CIMGUI_API bool ImGui_SliderBehavior(ImRect bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb);
CIMGUI_API bool ImGui_SplitterBehavior(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 */, ImU32 bg_col /* = 0 */);

// Widgets: Tree Nodes
CIMGUI_API bool ImGui_TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end /* = NULL */);
CIMGUI_API void ImGui_TreeNodeDrawLineToChildNode(ImVec2 target_pos);
CIMGUI_API void ImGui_TreeNodeDrawLineToTreePop(const ImGuiTreeNodeStackData* data);
CIMGUI_API void ImGui_TreePushOverrideID(ImGuiID id);
CIMGUI_API bool ImGui_TreeNodeGetOpen(ImGuiID storage_id);
CIMGUI_API void ImGui_TreeNodeSetOpen(ImGuiID storage_id, bool open);
CIMGUI_API bool ImGui_TreeNodeUpdateNextOpen(ImGuiID storage_id, ImGuiTreeNodeFlags flags);  // Return open state. Consume previous SetNextItemOpen() data, if any. May return true when logging.

// Data type helpers
CIMGUI_API const ImGuiDataTypeInfo* ImGui_DataTypeGetInfo(ImGuiDataType data_type);
CIMGUI_API int                      ImGui_DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format);
CIMGUI_API void                     ImGui_DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg_1, const void* arg_2);
CIMGUI_API bool                     ImGui_DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void* p_data, const char* format, void* p_data_when_empty /* = NULL */);
CIMGUI_API int                      ImGui_DataTypeCompare(ImGuiDataType data_type, const void* arg_1, const void* arg_2);
CIMGUI_API bool                     ImGui_DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max);
CIMGUI_API bool                     ImGui_DataTypeIsZero(ImGuiDataType data_type, const void* p_data);

// InputText
CIMGUI_API bool ImGui_InputTextWithHintAndSize(const char* label, const char* hint, char* buf, int buf_size, ImVec2 size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback /* = NULL */, void* user_data /* = NULL */);
CIMGUI_API void ImGui_InputTextDeactivateHook(ImGuiID id);
CIMGUI_API bool ImGui_TempInputText(ImRect bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags);
CIMGUI_API bool ImGui_TempInputScalar(ImRect bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min /* = NULL */, const void* p_clamp_max /* = NULL */);
CIMGUI_API bool ImGui_TempInputIsActive(ImGuiID id);
CIMGUI_API void ImGui_SetNextItemRefVal(ImGuiDataType data_type, void* p_data);
CIMGUI_API bool ImGui_IsItemActiveAsInputText(void);  // This may be useful to apply workaround that a based on distinguish whenever an item is active as a text input field.

// Color
CIMGUI_API void ImGui_ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
CIMGUI_API void ImGui_ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
CIMGUI_API void ImGui_ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags);

// Plot
CIMGUI_API int ImGui_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 size_arg);

// Shade functions (write over already created vertices)
CIMGUI_API void ImGui_ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
CIMGUI_API void ImGui_ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 a, ImVec2 b, ImVec2 uv_a, ImVec2 uv_b, bool clamp);
CIMGUI_API void ImGui_ShadeVertsTransformPos(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 pivot_in, float cos_a, float sin_a, ImVec2 pivot_out);

// Garbage collection
CIMGUI_API void ImGui_GcCompactTransientMiscBuffers(void);
CIMGUI_API void ImGui_GcCompactTransientWindowBuffers(ImGuiWindow* window);
CIMGUI_API void ImGui_GcAwakeTransientWindowBuffers(ImGuiWindow* window);

// Error handling, State Recovery
CIMGUI_API bool ImGui_ErrorLog(const char* msg);
CIMGUI_API void ImGui_ErrorRecoveryStoreState(ImGuiErrorRecoveryState* state_out);
CIMGUI_API void ImGui_ErrorRecoveryTryToRecoverState(const ImGuiErrorRecoveryState* state_in);
CIMGUI_API void ImGui_ErrorRecoveryTryToRecoverWindowState(const ImGuiErrorRecoveryState* state_in);
CIMGUI_API void ImGui_ErrorCheckUsingSetCursorPosToExtendParentBoundaries(void);
CIMGUI_API void ImGui_ErrorCheckEndFrameFinalizeErrorTooltip(void);
CIMGUI_API bool ImGui_BeginErrorTooltip(void);
CIMGUI_API void ImGui_EndErrorTooltip(void);

// Debug Tools
CIMGUI_API void ImGui_DebugAllocHook(ImGuiDebugAllocInfo* info, int frame_count, void* ptr, size_t size);                    // size >= 0 : alloc, size = -1 : free
CIMGUI_API void ImGui_DebugDrawCursorPos(ImU32 col /* = IM_COL32(255, 0, 0, 255) */);
CIMGUI_API void ImGui_DebugDrawLineExtents(ImU32 col /* = IM_COL32(255, 0, 0, 255) */);
CIMGUI_API void ImGui_DebugDrawItemRect(ImU32 col /* = IM_COL32(255, 0, 0, 255) */);
CIMGUI_API void ImGui_DebugTextUnformattedWithLocateItem(const char* line_begin, const char* line_end);
CIMGUI_API void ImGui_DebugLocateItem(ImGuiID target_id);                                                                    // Call sparingly: only 1 at the same time!
CIMGUI_API void ImGui_DebugLocateItemOnHover(ImGuiID target_id);                                                             // Only call on reaction to a mouse Hover: because only 1 at the same time!
CIMGUI_API void ImGui_DebugLocateItemResolveWithLastItem(void);
CIMGUI_API void ImGui_DebugBreakClearData(void);
CIMGUI_API bool ImGui_DebugBreakButton(const char* label, const char* description_of_location);
CIMGUI_API void ImGui_DebugBreakButtonTooltip(bool keyboard_only, const char* description_of_location);
CIMGUI_API void ImGui_ShowFontAtlas(ImFontAtlas* atlas);
CIMGUI_API void ImGui_DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end);
CIMGUI_API void ImGui_DebugNodeColumns(ImGuiOldColumns* columns);
CIMGUI_API void ImGui_DebugNodeDockNode(ImGuiDockNode* node, const char* label);
CIMGUI_API void ImGui_DebugNodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, const ImDrawList* draw_list, const char* label);
CIMGUI_API void ImGui_DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
CIMGUI_API void ImGui_DebugNodeFont(ImFont* font);
CIMGUI_API void ImGui_DebugNodeFontGlyphesForSrcMask(ImFont* font, ImFontBaked* baked, int src_mask);
CIMGUI_API void ImGui_DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph);
CIMGUI_API void ImGui_DebugNodeTexture(ImTextureData* tex, int int_id, const ImFontAtlasRect* highlight_rect /* = NULL */);  // ID used to facilitate persisting the "current" texture.
CIMGUI_API void ImGui_DebugNodeStorage(ImGuiStorage* storage, const char* label);
CIMGUI_API void ImGui_DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label);
CIMGUI_API void ImGui_DebugNodeTable(ImGuiTable* table);
CIMGUI_API void ImGui_DebugNodeTableSettings(ImGuiTableSettings* settings);
CIMGUI_API void ImGui_DebugNodeTypingSelectState(ImGuiTypingSelectState* state);
CIMGUI_API void ImGui_DebugNodeMultiSelectState(ImGuiMultiSelectState* state);
CIMGUI_API void ImGui_DebugNodeWindow(ImGuiWindow* window, const char* label);
CIMGUI_API void ImGui_DebugNodeWindowSettings(ImGuiWindowSettings* settings);
CIMGUI_API void ImGui_DebugNodeWindowsList(ImVector_ImGuiWindowPtr* windows, const char* label);
CIMGUI_API void ImGui_DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack);
CIMGUI_API void ImGui_DebugNodeViewport(ImGuiViewportP* viewport);
CIMGUI_API void ImGui_DebugNodePlatformMonitor(ImGuiPlatformMonitor* monitor, const char* label, int idx);
CIMGUI_API void ImGui_DebugRenderKeyboardPreview(ImDrawList* draw_list);
CIMGUI_API void ImGui_DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, ImRect bb);

//-----------------------------------------------------------------------------
// [SECTION] ImFontLoader
//-----------------------------------------------------------------------------

// Hooks and storage for a given font backend.
// This structure is likely to evolve as we add support for incremental atlas updates.
// Conceptually this could be public, but API is still going to be evolve.
struct ImFontLoader_t
{
    const char*                                                                            Name;
    bool (*LoaderInit)(ImFontAtlas* atlas);
    void (*LoaderShutdown)(ImFontAtlas* atlas);
    bool (*FontSrcInit)(ImFontAtlas* atlas, ImFontConfig* src);
    void (*FontSrcDestroy)(ImFontAtlas* atlas, ImFontConfig* src);
    bool (*FontSrcContainsGlyph)(ImFontAtlas* atlas, ImFontConfig* src, ImWchar codepoint);
    bool (*FontBakedInit)(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void* loader_data_for_baked_src);
    void (*FontBakedDestroy)(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void* loader_data_for_baked_src);
    bool (*FontBakedLoadGlyph)(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void* loader_data_for_baked_src, ImWchar codepoint, ImFontGlyph* out_glyph, float* out_advance_x);

    // Size of backend data, Per Baked * Per Source. Buffers are managed by core to avoid excessive allocations.
    // FIXME: At this point the two other types of buffers may be managed by core to be consistent?
    size_t                                                                                 FontBakedSrcLoaderDataSize;
};

#ifdef IMGUI_ENABLE_STB_TRUETYPE
CIMGUI_API const ImFontLoader* cImFontAtlasGetFontLoaderForStbTruetype(void);
#endif // #ifdef IMGUI_ENABLE_STB_TRUETYPE
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
typedef ImFontLoader ImFontBuilderIO;  // [renamed/changed in 1.92] The types are not actually compatible but we provide this as a compile-time error report helper.
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
//-----------------------------------------------------------------------------
// [SECTION] ImFontAtlas internal API
//-----------------------------------------------------------------------------

#define IMGUI_FONT_SIZE_MAX                                     (512.0f)
#define IMGUI_FONT_SIZE_THRESHOLD_FOR_LOADADVANCEXONLYMODE      (128.0f)

// Refer to ImFontAtlasPackGetRect() to better understand how this works.
#define ImFontAtlasRectId_IndexMask_        (0x0007FFFF)                              // 20-bits signed: index to access builder->RectsIndex[].
#define ImFontAtlasRectId_GenerationMask_   (0x3FF00000)                              // 10-bits: entry generation, so each ID is unique and get can safely detected old identifiers.
#define ImFontAtlasRectId_GenerationShift_  (20)
CIMGUI_API int               cImFontAtlasRectId_GetIndex(ImFontAtlasRectId id);
CIMGUI_API unsigned int      cImFontAtlasRectId_GetGeneration(ImFontAtlasRectId id);
CIMGUI_API ImFontAtlasRectId cImFontAtlasRectId_Make(int index_idx, int gen_idx);

// Packed rectangle lookup entry (we need an indirection to allow removing/reordering rectangles)
// User are returned ImFontAtlasRectId values which are meant to be persistent.
// We handle this with an indirection. While Rects[] may be in theory shuffled, compacted etc., RectsIndex[] cannot it is keyed by ImFontAtlasRectId.
// RectsIndex[] is used both as an index into Rects[] and an index into itself. This is basically a free-list. See ImFontAtlasBuildAllocRectIndexEntry() code.
// Having this also makes it easier to e.g. sort rectangles during repack.
struct ImFontAtlasRectEntry_t
{
    int          TargetIndex : 20;  // When Used: ImFontAtlasRectId -> into Rects[]. When unused: index to next unused RectsIndex[] slot to consume free-list.
    unsigned int Generation : 10;   // Increased each time the entry is reused for a new rectangle.
    unsigned int IsUsed : 1;
};
struct ImVector_ImFontAtlasRectEntry_t { int Size; int Capacity; ImFontAtlasRectEntry* Data; };  // Instantiation of ImVector<ImFontAtlasRectEntry>

// Data available to potential texture post-processing functions
struct ImFontAtlasPostProcessData_t
{
    ImFontAtlas*    FontAtlas;
    ImFont*         Font;
    ImFontConfig*   FontSrc;
    ImFontBaked*    FontBaked;
    ImFontGlyph*    Glyph;

    // Pixel data
    void*           Pixels;
    ImTextureFormat Format;
    int             Pitch;
    int             Width;
    int             Height;
};

// We avoid dragging imstb_rectpack.h into public header (partly because binding generators are having issues with it)
#ifdef IMGUI_STB_NAMESPACE
typedef struct IMGUI_STB_NAMESPACEstbrp_node_t IMGUI_STB_NAMESPACEstbrp_node;
typedef IMGUI_STB_NAMESPACE::stbrp_node stbrp_node_im;
#else
typedef struct stbrp_node_t stbrp_node;
typedef stbrp_node stbrp_node_im;
struct ImVector_stbrp_node_im_t { int Size; int Capacity; stbrp_node_im* Data; };  // Instantiation of ImVector<stbrp_node_im>
#endif // #ifdef IMGUI_STB_NAMESPACE
struct stbrp_context_opaque_t
{
    char data[80];
};

// Internal storage for incrementally packing and building a ImFontAtlas
struct ImFontAtlasBuilder_t
{
    stbrp_context_opaque          PackContext;               // Actually 'stbrp_context' but we don't want to define this in the header file.
    ImVector_stbrp_node_im        PackNodes;
    ImVector_ImTextureRect        Rects;
    ImVector_ImFontAtlasRectEntry RectsIndex;                // ImFontAtlasRectId -> index into Rects[]
    ImVector_unsigned_char        TempBuffer;                // Misc scratch buffer
    int                           RectsIndexFreeListStart;   // First unused entry
    int                           RectsPackedCount;          // Number of packed rectangles.
    int                           RectsPackedSurface;        // Number of packed pixels. Used when compacting to heuristically find the ideal texture size.
    int                           RectsDiscardedCount;
    int                           RectsDiscardedSurface;
    int                           FrameCount;                // Current frame count
    ImVec2i                       MaxRectSize;               // Largest rectangle to pack (de-facto used as a "minimum texture size")
    ImVec2i                       MaxRectBounds;             // Bottom-right most used pixels
    bool                          LockDisableResize;         // Disable resizing texture
    bool                          PreloadedAllGlyphsRanges;  // Set when missing ImGuiBackendFlags_RendererHasTextures features forces atlas to preload everything.

    // Cache of all ImFontBaked
    ImStableVector_ImFontBaked_32 BakedPool;
    ImGuiStorage                  BakedMap;                  // BakedId --> ImFontBaked*
    int                           BakedDiscardedCount;

    // Custom rectangle identifiers
    ImFontAtlasRectId             PackIdMouseCursors;        // White pixel + mouse cursors. Also happen to be fallback in case of packing failure.
    ImFontAtlasRectId             PackIdLinesTexData;
};

CIMGUI_API void cImFontAtlasBuildInit(ImFontAtlas* atlas);
CIMGUI_API void cImFontAtlasBuildDestroy(ImFontAtlas* atlas);
CIMGUI_API void cImFontAtlasBuildMain(ImFontAtlas* atlas);
CIMGUI_API void cImFontAtlasBuildSetupFontLoader(ImFontAtlas* atlas, const ImFontLoader* font_loader);
CIMGUI_API void cImFontAtlasBuildNotifySetFont(ImFontAtlas* atlas, ImFont* old_font, ImFont* new_font);
CIMGUI_API void cImFontAtlasBuildUpdatePointers(ImFontAtlas* atlas);
CIMGUI_API void cImFontAtlasBuildRenderBitmapFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char);
CIMGUI_API void cImFontAtlasBuildClear(ImFontAtlas* atlas);  // Clear output and custom rects

CIMGUI_API ImTextureData* cImFontAtlasTextureAdd(ImFontAtlas* atlas, int w, int h);
CIMGUI_API void           cImFontAtlasTextureMakeSpace(ImFontAtlas* atlas);
CIMGUI_API void           cImFontAtlasTextureRepack(ImFontAtlas* atlas, int w, int h);
CIMGUI_API void           cImFontAtlasTextureGrow(ImFontAtlas* atlas, int old_w /* = -1 */, int old_h /* = -1 */);
CIMGUI_API void           cImFontAtlasTextureCompact(ImFontAtlas* atlas);
CIMGUI_API ImVec2i        cImFontAtlasTextureGetSizeEstimate(ImFontAtlas* atlas);

CIMGUI_API void cImFontAtlasBuildSetupFontSpecialGlyphs(ImFontAtlas* atlas, ImFont* font, ImFontConfig* src);
CIMGUI_API void cImFontAtlasBuildLegacyPreloadAllGlyphRanges(ImFontAtlas* atlas);                                                            // Legacy
CIMGUI_API void cImFontAtlasBuildGetOversampleFactors(ImFontConfig* src, ImFontBaked* baked, int* out_oversample_h, int* out_oversample_v);
CIMGUI_API void cImFontAtlasBuildDiscardBakes(ImFontAtlas* atlas, int unused_frames);

CIMGUI_API bool cImFontAtlasFontSourceInit(ImFontAtlas* atlas, ImFontConfig* src);
CIMGUI_API void cImFontAtlasFontSourceAddToFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* src);
CIMGUI_API void cImFontAtlasFontDestroySourceData(ImFontAtlas* atlas, ImFontConfig* src);
CIMGUI_API bool cImFontAtlasFontInitOutput(ImFontAtlas* atlas, ImFont* font);                       // Using FontDestroyOutput/FontInitOutput sequence useful notably if font loader params have changed
CIMGUI_API void cImFontAtlasFontDestroyOutput(ImFontAtlas* atlas, ImFont* font);
CIMGUI_API void cImFontAtlasFontDiscardBakes(ImFontAtlas* atlas, ImFont* font, int unused_frames);

CIMGUI_API ImGuiID      cImFontAtlasBakedGetId(ImGuiID font_id, float baked_size, float rasterizer_density);
CIMGUI_API ImFontBaked* cImFontAtlasBakedGetOrAdd(ImFontAtlas* atlas, ImFont* font, float font_size, float font_rasterizer_density);
CIMGUI_API ImFontBaked* cImFontAtlasBakedGetClosestMatch(ImFontAtlas* atlas, ImFont* font, float font_size, float font_rasterizer_density);
CIMGUI_API ImFontBaked* cImFontAtlasBakedAdd(ImFontAtlas* atlas, ImFont* font, float font_size, float font_rasterizer_density, ImGuiID baked_id);
CIMGUI_API void         cImFontAtlasBakedDiscard(ImFontAtlas* atlas, ImFont* font, ImFontBaked* baked);
CIMGUI_API ImFontGlyph* cImFontAtlasBakedAddFontGlyph(ImFontAtlas* atlas, ImFontBaked* baked, ImFontConfig* src, const ImFontGlyph* in_glyph);
CIMGUI_API void         cImFontAtlasBakedAddFontGlyphAdvancedX(ImFontAtlas* atlas, ImFontBaked* baked, ImFontConfig* src, ImWchar codepoint, float advance_x);
CIMGUI_API void         cImFontAtlasBakedDiscardFontGlyph(ImFontAtlas* atlas, ImFont* font, ImFontBaked* baked, ImFontGlyph* glyph);
CIMGUI_API void         cImFontAtlasBakedSetFontGlyphBitmap(ImFontAtlas* atlas, ImFontBaked* baked, ImFontConfig* src, ImFontGlyph* glyph, ImTextureRect* r, const unsigned char* src_pixels, ImTextureFormat src_fmt, int src_pitch);

CIMGUI_API void              cImFontAtlasPackInit(ImFontAtlas* atlas);
CIMGUI_API ImFontAtlasRectId cImFontAtlasPackAddRect(ImFontAtlas* atlas, int w, int h, ImFontAtlasRectEntry* overwrite_entry /* = NULL */);
CIMGUI_API ImTextureRect*    cImFontAtlasPackGetRect(ImFontAtlas* atlas, ImFontAtlasRectId id);
CIMGUI_API ImTextureRect*    cImFontAtlasPackGetRectSafe(ImFontAtlas* atlas, ImFontAtlasRectId id);
CIMGUI_API void              cImFontAtlasPackDiscardRect(ImFontAtlas* atlas, ImFontAtlasRectId id);

CIMGUI_API void cImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, int frame_count, bool renderer_has_textures);
CIMGUI_API void cImFontAtlasAddDrawListSharedData(ImFontAtlas* atlas, ImDrawListSharedData* data);
CIMGUI_API void cImFontAtlasRemoveDrawListSharedData(ImFontAtlas* atlas, ImDrawListSharedData* data);
CIMGUI_API void cImFontAtlasUpdateDrawListsTextures(ImFontAtlas* atlas, ImTextureRef old_tex, ImTextureRef new_tex);
CIMGUI_API void cImFontAtlasUpdateDrawListsSharedData(ImFontAtlas* atlas);

CIMGUI_API void cImFontAtlasTextureBlockConvert(const unsigned char* src_pixels, ImTextureFormat src_fmt, int src_pitch, unsigned char* dst_pixels, ImTextureFormat dst_fmt, int dst_pitch, int w, int h);
CIMGUI_API void cImFontAtlasTextureBlockPostProcess(ImFontAtlasPostProcessData* data);
CIMGUI_API void cImFontAtlasTextureBlockPostProcessMultiply(ImFontAtlasPostProcessData* data, float multiply_factor);
CIMGUI_API void cImFontAtlasTextureBlockFill(ImTextureData* dst_tex, int dst_x, int dst_y, int w, int h, ImU32 col);
CIMGUI_API void cImFontAtlasTextureBlockCopy(ImTextureData* src_tex, int src_x, int src_y, ImTextureData* dst_tex, int dst_x, int dst_y, int w, int h);
CIMGUI_API void cImFontAtlasTextureBlockQueueUpload(ImFontAtlas* atlas, ImTextureData* tex, int x, int y, int w, int h);

CIMGUI_API int         cImTextureDataGetFormatBytesPerPixel(ImTextureFormat format);
CIMGUI_API const char* cImTextureDataGetStatusName(ImTextureStatus status);
CIMGUI_API const char* cImTextureDataGetFormatName(ImTextureFormat format);

#ifndef IMGUI_DISABLE_DEBUG_TOOLS
CIMGUI_API void cImFontAtlasDebugLogTextureRequests(ImFontAtlas* atlas);
#endif // #ifndef IMGUI_DISABLE_DEBUG_TOOLS
CIMGUI_API bool cImFontAtlasGetMouseCursorTexData(ImFontAtlas* atlas, ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]);

//-----------------------------------------------------------------------------
// [SECTION] Test Engine specific hooks (imgui_test_engine)
//-----------------------------------------------------------------------------

#ifdef IMGUI_ENABLE_TEST_ENGINE
extern
CIMGUI_API void        cImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, ImGuiID id, ImRect bb, const ImGuiLastItemData* item_data); // item_data may be NULL
extern
CIMGUI_API void        cImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags);
extern
CIMGUI_API void        cImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt, ...);
extern
CIMGUI_API const char* cImGuiTestEngine_FindItemDebugLabel(ImGuiContext* ctx, ImGuiID id);

// In IMGUI_VERSION_NUM >= 18934: changed IMGUI_TEST_ENGINE_ITEM_ADD(bb,id) to IMGUI_TEST_ENGINE_ITEM_ADD(id,bb,item_data);
#define IMGUI_TEST_ENGINE_ITEM_ADD(_ID,_BB,_ITEM_DATA)      if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemAdd(&g, _ID, _BB, _ITEM_DATA)     // Register item bounding box
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS)      if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS)     // Register item label and status flags (optional)
#define IMGUI_TEST_ENGINE_LOG(_FMT,...)                     ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__)                                       // Custom log entry from user land into test log
#else
#define IMGUI_TEST_ENGINE_ITEM_ADD(_ID,_BB,_ITEM_DATA)      ((void)0)
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS)      ((void)g)
#endif // #ifdef IMGUI_ENABLE_TEST_ENGINE
//-----------------------------------------------------------------------------

#if defined(__clang__)
#pragma clang diagnostic pop
#else
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif // #if defined(__GNUC__)
#endif // #if defined(__clang__)
#ifdef _MSC_VER
#pragma warning (pop)
#endif // #ifdef _MSC_VER
#endif// #ifndef IMGUI_DISABLE
#ifdef __cplusplus
} // End of extern "C" block
#endif
