3307 lines
235 KiB
C
3307 lines
235 KiB
C
|
// dear imgui, v1.89.6
|
||
|
// (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.
|
||
|
// To implement maths operators for ImVec2 (disabled by default to not conflict with using IM_VEC2_CLASS_EXTRA with your own math types+operators), use:
|
||
|
/*
|
||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||
|
#include "imgui_internal.h"
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
|
||
|
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] Widgets support: flags, enums, data structures
|
||
|
// [SECTION] Inputs support
|
||
|
// [SECTION] Clipper support
|
||
|
// [SECTION] Navigation support
|
||
|
// [SECTION] Columns support
|
||
|
// [SECTION] Multi-select support
|
||
|
// [SECTION] Docking support
|
||
|
// [SECTION] Viewport support
|
||
|
// [SECTION] Settings support
|
||
|
// [SECTION] Localization 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] ImFontAtlas internal API
|
||
|
// [SECTION] Test Engine specific hooks (imgui_test_engine)
|
||
|
|
||
|
*/
|
||
|
|
||
|
#pragma once
|
||
|
#ifndef IMGUI_DISABLE
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
// [SECTION] Header mess
|
||
|
//-----------------------------------------------------------------------------
|
||
|
|
||
|
#ifndef IMGUI_VERSION
|
||
|
#include "imgui.h"
|
||
|
#endif
|
||
|
|
||
|
#include <stdio.h> // FILE*, sscanf
|
||
|
#include <stdlib.h> // NULL, malloc, free, qsort, atoi, atof
|
||
|
#include <math.h> // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
|
||
|
#include <limits.h> // INT_MIN, INT_MAX
|
||
|
|
||
|
// 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>
|
||
|
#endif
|
||
|
|
||
|
// 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: 26812) // The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer)
|
||
|
#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
|
||
|
#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
|
||
|
#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
|
||
|
#endif
|
||
|
#endif
|
||
|
|
||
|
// 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
|
||
|
#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 ImFloorSigned()
|
||
|
#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h
|
||
|
#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h
|
||
|
#pragma clang diagnostic ignored "-Wold-style-cast"
|
||
|
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||
|
#pragma clang diagnostic ignored "-Wdouble-promotion"
|
||
|
#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'
|
||
|
#elif defined(__GNUC__)
|
||
|
#pragma GCC diagnostic push
|
||
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||
|
#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
|
||
|
#endif
|
||
|
|
||
|
// 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
|
||
|
|
||
|
// Legacy defines
|
||
|
#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74
|
||
|
#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
|
||
|
#endif
|
||
|
#ifdef IMGUI_DISABLE_MATH_FUNCTIONS // Renamed in 1.74
|
||
|
#error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
|
||
|
#endif
|
||
|
|
||
|
// 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
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
// [SECTION] Forward declarations
|
||
|
//-----------------------------------------------------------------------------
|
||
|
|
||
|
struct ImBitVector; // Store 1-bit per value
|
||
|
struct ImRect; // An axis-aligned rectangle (2 points)
|
||
|
struct ImDrawDataBuilder; // Helper to build a ImDrawData instance
|
||
|
struct ImDrawListSharedData; // Data shared between all ImDrawList instances
|
||
|
struct ImGuiColorMod; // Stacked color modifier, backup of modified data so we can restore it
|
||
|
struct ImGuiContext; // Main Dear ImGui context
|
||
|
struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine
|
||
|
struct ImGuiDataVarInfo; // Variable information (e.g. to avoid style variables from an enum)
|
||
|
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
|
||
|
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
||
|
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
||
|
struct ImGuiInputTextDeactivateData;// Short term storage to backup text of a deactivating InputText() while another is stealing active id
|
||
|
struct ImGuiLastItemData; // Status storage for last submitted items
|
||
|
struct ImGuiLocEntry; // A localization entry.
|
||
|
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
|
||
|
struct ImGuiNavItemData; // Result of a gamepad/keyboard directional navigation move query result
|
||
|
struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions
|
||
|
struct ImGuiNextWindowData; // Storage for SetNextWindow** functions
|
||
|
struct ImGuiNextItemData; // Storage for SetNextItem** functions
|
||
|
struct ImGuiOldColumnData; // Storage data for a single column for legacy Columns() api
|
||
|
struct ImGuiOldColumns; // Storage data for a columns set for legacy Columns() api
|
||
|
struct ImGuiPopupData; // Storage for current popup stack
|
||
|
struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file
|
||
|
struct ImGuiStackSizes; // Storage of stack sizes for debugging/asserting
|
||
|
struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it
|
||
|
struct ImGuiTabBar; // Storage for a tab bar
|
||
|
struct ImGuiTabItem; // Storage for a tab item (within a tab bar)
|
||
|
struct ImGuiTable; // Storage for a table
|
||
|
struct ImGuiTableColumn; // Storage for one column of a table
|
||
|
struct ImGuiTableInstanceData; // Storage for one instance of a same table
|
||
|
struct ImGuiTableTempData; // Temporary storage for one table (one per table in the stack), shared between tables.
|
||
|
struct ImGuiTableSettings; // Storage for a table .ini settings
|
||
|
struct ImGuiTableColumnsSettings; // Storage for a column .ini settings
|
||
|
struct ImGuiWindow; // Storage for one window
|
||
|
struct 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)
|
||
|
struct 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.
|
||
|
enum ImGuiLocKey : int; // -> enum ImGuiLocKey // Enum: a localization entry for translation.
|
||
|
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
||
|
|
||
|
// Flags
|
||
|
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 ImGuiInputFlags; // -> enum ImGuiInputFlags_ // Flags: for IsKeyPressed(), IsMouseClicked(), SetKeyOwner(), SetItemKeyOwner() etc.
|
||
|
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), g.LastItemData.InFlags
|
||
|
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for g.LastItemData.StatusFlags
|
||
|
typedef int ImGuiOldColumnFlags; // -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns()
|
||
|
typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
|
||
|
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 void (*ImGuiErrorLogCallback)(void* user_data, const char* fmt, ...);
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
// [SECTION] Context pointer
|
||
|
// See implementation of this variable in imgui.cpp for comments and details.
|
||
|
//-----------------------------------------------------------------------------
|
||
|
|
||
|
#ifndef GImGui
|
||
|
extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
|
||
|
#endif
|
||
|
|
||
|
//-------------------------------------------------------------------------
|
||
|
// [SECTION] STB libraries includes
|
||
|
//-------------------------------------------------------------------------
|
||
|
|
||
|
namespace ImStb
|
||
|
{
|
||
|
|
||
|
#undef STB_TEXTEDIT_STRING
|
||
|
#undef STB_TEXTEDIT_CHARTYPE
|
||
|
#define STB_TEXTEDIT_STRING ImGuiInputTextState
|
||
|
#define STB_TEXTEDIT_CHARTYPE ImWchar
|
||
|
#define STB_TEXTEDIT_GETWIDTH_NEWLINE (-1.0f)
|
||
|
#define STB_TEXTEDIT_UNDOSTATECOUNT 99
|
||
|
#define STB_TEXTEDIT_UNDOCHARCOUNT 999
|
||
|
#include "imstb_textedit.h"
|
||
|
|
||
|
} // namespace ImStb
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
// [SECTION] Macros
|
||
|
//-----------------------------------------------------------------------------
|
||
|
|
||
|
// 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
|
||
|
#endif
|
||
|
|
||
|
// Debug Logging for ShowDebugLogWindow(). This is designed for relatively rare events so please don't spam.
|
||
|
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
||
|
#define IMGUI_DEBUG_LOG(...) ImGui::DebugLog(__VA_ARGS__)
|
||
|
#else
|
||
|
#define IMGUI_DEBUG_LOG(...) ((void)0)
|
||
|
#endif
|
||
|
#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)
|
||
|
|
||
|
// 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
|
||
|
|
||
|
// Error handling
|
||
|
// Down the line in some frameworks/languages we would like to have a way to redirect those to the programmer and recover from more faults.
|
||
|
#ifndef IM_ASSERT_USER_ERROR
|
||
|
#define IM_ASSERT_USER_ERROR(_EXP,_MSG) IM_ASSERT((_EXP) && _MSG) // Recoverable User Error
|
||
|
#endif
|
||
|
|
||
|
// 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
|
||
|
#ifndef IM_TABSIZE // Until we move this to runtime and/or add proper tab support, at least allow users to compile-time override
|
||
|
#define IM_TABSIZE (4)
|
||
|
#endif
|
||
|
#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_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds
|
||
|
#define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) //
|
||
|
|
||
|
// 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
|
||
|
|
||
|
// 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
|
||
|
|
||
|
// 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()
|
||
|
#elif defined(__clang__)
|
||
|
#define IM_DEBUG_BREAK() __builtin_debugtrap()
|
||
|
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||
|
#define IM_DEBUG_BREAK() __asm__ volatile("int $0x03")
|
||
|
#elif defined(__GNUC__) && defined(__thumb__)
|
||
|
#define IM_DEBUG_BREAK() __asm__ volatile(".inst 0xde01")
|
||
|
#elif 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
|
||
|
#endif // #ifndef IM_DEBUG_BREAK
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
// [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: ImPool<>
|
||
|
// - Helper: ImChunkStream<>
|
||
|
// - Helper: ImGuiTextIndex
|
||
|
//-----------------------------------------------------------------------------
|
||
|
|
||
|
// Helpers: Hashing
|
||
|
IMGUI_API ImGuiID ImHashData(const void* data, size_t data_size, ImGuiID seed = 0);
|
||
|
IMGUI_API ImGuiID ImHashStr(const char* data, size_t data_size = 0, ImGuiID seed = 0);
|
||
|
|
||
|
// Helpers: Sorting
|
||
|
#ifndef ImQsort
|
||
|
static inline void ImQsort(void* base, size_t count, size_t size_of_element, int(IMGUI_CDECL *compare_func)(void const*, void const*)) { if (count > 1) qsort(base, count, size_of_element, compare_func); }
|
||
|
#endif
|
||
|
|
||
|
// Helpers: Color Blending
|
||
|
IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b);
|
||
|
|
||
|
// Helpers: Bit manipulation
|
||
|
static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
|
||
|
static inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v & (v - 1)) == 0; }
|
||
|
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
|
||
|
|
||
|
// Helpers: String
|
||
|
IMGUI_API int ImStricmp(const char* str1, const char* str2);
|
||
|
IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count);
|
||
|
IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count);
|
||
|
IMGUI_API char* ImStrdup(const char* str);
|
||
|
IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str);
|
||
|
IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c);
|
||
|
IMGUI_API int ImStrlenW(const ImWchar* str);
|
||
|
IMGUI_API const char* ImStreolRange(const char* str, const char* str_end); // End end-of-line
|
||
|
IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
||
|
IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
|
||
|
IMGUI_API void ImStrTrimBlanks(char* str);
|
||
|
IMGUI_API const char* ImStrSkipBlank(const char* str);
|
||
|
IM_MSVC_RUNTIME_CHECKS_OFF
|
||
|
static inline char ImToUpper(char c) { return (c >= 'a' && c <= 'z') ? c &= ~32 : c; }
|
||
|
static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; }
|
||
|
static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
||
|
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||
|
|
||
|
// Helpers: Formatting
|
||
|
IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
|
||
|
IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
|
||
|
IMGUI_API void ImFormatStringToTempBuffer(const char** out_buf, const char** out_buf_end, const char* fmt, ...) IM_FMTARGS(3);
|
||
|
IMGUI_API void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end, const char* fmt, va_list args) IM_FMTLIST(3);
|
||
|
IMGUI_API const char* ImParseFormatFindStart(const char* format);
|
||
|
IMGUI_API const char* ImParseFormatFindEnd(const char* format);
|
||
|
IMGUI_API const char* ImParseFormatTrimDecorations(const char* format, char* buf, size_t buf_size);
|
||
|
IMGUI_API void ImParseFormatSanitizeForPrinting(const char* fmt_in, char* fmt_out, size_t fmt_out_size);
|
||
|
IMGUI_API const char* ImParseFormatSanitizeForScanning(const char* fmt_in, char* fmt_out, size_t fmt_out_size);
|
||
|
IMGUI_API int ImParseFormatPrecision(const char* format, int default_value);
|
||
|
|
||
|
// Helpers: UTF-8 <> wchar conversions
|
||
|
IMGUI_API const char* ImTextCharToUtf8(char out_buf[5], unsigned int c); // return out_buf
|
||
|
IMGUI_API int ImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
||
|
IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count
|
||
|
IMGUI_API int ImTextStrFromUtf8(ImWchar* out_buf, int out_buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
|
||
|
IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
|
||
|
IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
|
||
|
IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
|
||
|
|
||
|
// Helpers: File System
|
||
|
#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
|
||
|
#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
||
|
typedef void* ImFileHandle;
|
||
|
static inline ImFileHandle ImFileOpen(const char*, const char*) { return NULL; }
|
||
|
static inline bool ImFileClose(ImFileHandle) { return false; }
|
||
|
static inline ImU64 ImFileGetSize(ImFileHandle) { return (ImU64)-1; }
|
||
|
static inline ImU64 ImFileRead(void*, ImU64, ImU64, ImFileHandle) { return 0; }
|
||
|
static inline ImU64 ImFileWrite(const void*, ImU64, ImU64, ImFileHandle) { return 0; }
|
||
|
#endif
|
||
|
#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
||
|
typedef FILE* ImFileHandle;
|
||
|
IMGUI_API ImFileHandle ImFileOpen(const char* filename, const char* mode);
|
||
|
IMGUI_API bool ImFileClose(ImFileHandle file);
|
||
|
IMGUI_API ImU64 ImFileGetSize(ImFileHandle file);
|
||
|
IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
|
||
|
IMGUI_API ImU64 ImFileWrite(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
|
||
|
IMGUI_API void* ImFileLoadToMemory(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 ImFloorStd(X) floorf(X) // We use our own, see ImFloor() and ImFloorSigned()
|
||
|
#define ImCeil(X) ceilf(X)
|
||
|
static inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision
|
||
|
static inline double ImPow(double x, double y) { return pow(x, y); }
|
||
|
static inline float ImLog(float x) { return logf(x); } // DragBehaviorT/SliderBehaviorT uses ImLog with either float/double and need the precision
|
||
|
static inline double ImLog(double x) { return log(x); }
|
||
|
static inline int ImAbs(int x) { return x < 0 ? -x : x; }
|
||
|
static inline float ImAbs(float x) { return fabsf(x); }
|
||
|
static inline double ImAbs(double x) { return fabs(x); }
|
||
|
static inline float ImSign(float x) { return (x < 0.0f) ? -1.0f : (x > 0.0f) ? 1.0f : 0.0f; } // Sign operator - returns -1, 0 or 1 based on sign of argument
|
||
|
static inline double ImSign(double x) { return (x < 0.0) ? -1.0 : (x > 0.0) ? 1.0 : 0.0; }
|
||
|
#ifdef IMGUI_ENABLE_SSE
|
||
|
static inline float ImRsqrt(float x) { return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x))); }
|
||
|
#else
|
||
|
static inline float ImRsqrt(float x) { return 1.0f / sqrtf(x); }
|
||
|
#endif
|
||
|
static inline double ImRsqrt(double x) { return 1.0 / sqrt(x); }
|
||
|
#endif
|
||
|
// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double
|
||
|
// (Exceptionally using templates here but we could also redefine them for those types)
|
||
|
template<typename T> static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; }
|
||
|
template<typename T> static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; }
|
||
|
template<typename T> static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||
|
template<typename T> static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); }
|
||
|
template<typename T> static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
||
|
template<typename T> static inline T ImAddClampOverflow(T a, T b, T mn, T mx) { if (b < 0 && (a < mn - b)) return mn; if (b > 0 && (a > mx - b)) return mx; return a + b; }
|
||
|
template<typename T> static inline T ImSubClampOverflow(T a, T b, T mn, T mx) { if (b > 0 && (a < mn + b)) return mn; if (b < 0 && (a > mx + b)) return mx; return a - b; }
|
||
|
// - Misc maths helpers
|
||
|
static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
|
||
|
static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
|
||
|
static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
|
||
|
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
||
|
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
||
|
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
||
|
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
||
|
static inline float ImLengthSqr(const ImVec2& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y); }
|
||
|
static inline float ImLengthSqr(const ImVec4& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); }
|
||
|
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return ImRsqrt(d); return fail_value; }
|
||
|
static inline float ImFloor(float f) { return (float)(int)(f); }
|
||
|
static inline float ImFloorSigned(float f) { return (float)((f >= 0 || (float)(int)f == f) ? (int)f : (int)f - 1); } // Decent replacement for floorf()
|
||
|
static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); }
|
||
|
static inline ImVec2 ImFloorSigned(const ImVec2& v) { return ImVec2(ImFloorSigned(v.x), ImFloorSigned(v.y)); }
|
||
|
static inline int ImModPositive(int a, int b) { return (a + b) % b; }
|
||
|
static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
|
||
|
static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
|
||
|
static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
|
||
|
static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
|
||
|
static inline bool ImIsFloatAboveGuaranteedIntegerPrecision(float f) { return f <= -16777216 || f >= 16777216; }
|
||
|
static inline float ImExponentialMovingAverage(float avg, float sample, int n) { avg -= avg / n; avg += sample / n; return avg; }
|
||
|
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||
|
|
||
|
// Helpers: Geometry
|
||
|
IMGUI_API ImVec2 ImBezierCubicCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t);
|
||
|
IMGUI_API ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments); // For curves with explicit number of segments
|
||
|
IMGUI_API ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol);// For auto-tessellated curves you can use tess_tol = style.CurveTessellationTol
|
||
|
IMGUI_API ImVec2 ImBezierQuadraticCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, float t);
|
||
|
IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
|
||
|
IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
|
||
|
IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
|
||
|
IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
|
||
|
inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; }
|
||
|
|
||
|
// 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
|
||
|
{
|
||
|
float x;
|
||
|
constexpr ImVec1() : x(0.0f) { }
|
||
|
constexpr ImVec1(float _x) : x(_x) { }
|
||
|
};
|
||
|
|
||
|
// Helper: ImVec2ih (2D vector, half-size integer, for long-term packed storage)
|
||
|
struct ImVec2ih
|
||
|
{
|
||
|
short x, y;
|
||
|
constexpr ImVec2ih() : x(0), y(0) {}
|
||
|
constexpr ImVec2ih(short _x, short _y) : x(_x), y(_y) {}
|
||
|
constexpr explicit ImVec2ih(const ImVec2& rhs) : x((short)rhs.x), y((short)rhs.y) {}
|
||
|
};
|
||
|
|
||
|
// Helper: ImRect (2D axis aligned bounding-box)
|
||
|
// NB: we can't rely on ImVec2 math operators being available here!
|
||
|
struct IMGUI_API ImRect
|
||
|
{
|
||
|
ImVec2 Min; // Upper-left
|
||
|
ImVec2 Max; // Lower-right
|
||
|
|
||
|
constexpr ImRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {}
|
||
|
constexpr ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {}
|
||
|
constexpr ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
|
||
|
constexpr ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {}
|
||
|
|
||
|
ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
|
||
|
ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
|
||
|
float GetWidth() const { return Max.x - Min.x; }
|
||
|
float GetHeight() const { return Max.y - Min.y; }
|
||
|
float GetArea() const { return (Max.x - Min.x) * (Max.y - Min.y); }
|
||
|
ImVec2 GetTL() const { return Min; } // Top-left
|
||
|
ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right
|
||
|
ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left
|
||
|
ImVec2 GetBR() const { return Max; } // Bottom-right
|
||
|
bool Contains(const ImVec2& p) const { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; }
|
||
|
bool Contains(const ImRect& r) const { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x <= Max.x && r.Max.y <= Max.y; }
|
||
|
bool Overlaps(const ImRect& r) const { return r.Min.y < Max.y && r.Max.y > Min.y && r.Min.x < Max.x && r.Max.x > Min.x; }
|
||
|
void Add(const ImVec2& p) { if (Min.x > p.x) Min.x = p.x; if (Min.y > p.y) Min.y = p.y; if (Max.x < p.x) Max.x = p.x; if (Max.y < p.y) Max.y = p.y; }
|
||
|
void Add(const ImRect& r) { if (Min.x > r.Min.x) Min.x = r.Min.x; if (Min.y > r.Min.y) Min.y = r.Min.y; if (Max.x < r.Max.x) Max.x = r.Max.x; if (Max.y < r.Max.y) Max.y = r.Max.y; }
|
||
|
void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
|
||
|
void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
|
||
|
void Translate(const ImVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; }
|
||
|
void TranslateX(float dx) { Min.x += dx; Max.x += dx; }
|
||
|
void TranslateY(float dy) { Min.y += dy; Max.y += dy; }
|
||
|
void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
|
||
|
void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped.
|
||
|
void Floor() { Min.x = IM_FLOOR(Min.x); Min.y = IM_FLOOR(Min.y); Max.x = IM_FLOOR(Max.x); Max.y = IM_FLOOR(Max.y); }
|
||
|
bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; }
|
||
|
ImVec4 ToVec4() const { return ImVec4(Min.x, Min.y, Max.x, Max.y); }
|
||
|
};
|
||
|
|
||
|
// 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!
|
||
|
inline size_t ImBitArrayGetStorageSizeInBytes(int bitcount) { return (size_t)((bitcount + 31) >> 5) << 2; }
|
||
|
inline void ImBitArrayClearAllBits(ImU32* arr, int bitcount){ memset(arr, 0, ImBitArrayGetStorageSizeInBytes(bitcount)); }
|
||
|
inline bool ImBitArrayTestBit(const ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); return (arr[n >> 5] & mask) != 0; }
|
||
|
inline void ImBitArrayClearBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] &= ~mask; }
|
||
|
inline void ImBitArraySetBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] |= mask; }
|
||
|
inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2) // Works on range [n..n2)
|
||
|
{
|
||
|
n2--;
|
||
|
while (n <= n2)
|
||
|
{
|
||
|
int a_mod = (n & 31);
|
||
|
int b_mod = (n2 > (n | 31) ? 31 : (n2 & 31)) + 1;
|
||
|
ImU32 mask = (ImU32)(((ImU64)1 << b_mod) - 1) & ~(ImU32)(((ImU64)1 << a_mod) - 1);
|
||
|
arr[n >> 5] |= mask;
|
||
|
n = (n + 32) & ~31;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
typedef ImU32* ImBitArrayPtr; // Name for use in structs
|
||
|
|
||
|
// Helper: ImBitArray class (wrapper over ImBitArray functions)
|
||
|
// Store 1-bit per value.
|
||
|
template<int BITCOUNT, int OFFSET = 0>
|
||
|
struct ImBitArray
|
||
|
{
|
||
|
ImU32 Storage[(BITCOUNT + 31) >> 5];
|
||
|
ImBitArray() { ClearAllBits(); }
|
||
|
void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
|
||
|
void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
|
||
|
bool TestBit(int n) const { n += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT); return IM_BITARRAY_TESTBIT(Storage, n); }
|
||
|
void SetBit(int n) { n += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT); ImBitArraySetBit(Storage, n); }
|
||
|
void ClearBit(int n) { n += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT); ImBitArrayClearBit(Storage, n); }
|
||
|
void SetBitRange(int n, int n2) { n += OFFSET; n2 += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT && n2 > n && n2 <= BITCOUNT); ImBitArraySetBitRange(Storage, n, n2); } // Works on range [n..n2)
|
||
|
bool operator[](int n) const { n += OFFSET; IM_ASSERT(n >= 0 && n < BITCOUNT); return IM_BITARRAY_TESTBIT(Storage, n); }
|
||
|
};
|
||
|
|
||
|
// Helper: ImBitVector
|
||
|
// Store 1-bit per value.
|
||
|
struct IMGUI_API ImBitVector
|
||
|
{
|
||
|
ImVector<ImU32> Storage;
|
||
|
void Create(int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); }
|
||
|
void Clear() { Storage.clear(); }
|
||
|
bool TestBit(int n) const { IM_ASSERT(n < (Storage.Size << 5)); return IM_BITARRAY_TESTBIT(Storage.Data, n); }
|
||
|
void SetBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArraySetBit(Storage.Data, n); }
|
||
|
void ClearBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArrayClearBit(Storage.Data, n); }
|
||
|
};
|
||
|
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||
|
|
||
|
// Helper: ImSpan<>
|
||
|
// Pointing to a span of data we don't own.
|
||
|
template<typename T>
|
||
|
struct ImSpan
|
||
|
{
|
||
|
T* Data;
|
||
|
T* DataEnd;
|
||
|
|
||
|
// Constructors, destructor
|
||
|
inline ImSpan() { Data = DataEnd = NULL; }
|
||
|
inline ImSpan(T* data, int size) { Data = data; DataEnd = data + size; }
|
||
|
inline ImSpan(T* data, T* data_end) { Data = data; DataEnd = data_end; }
|
||
|
|
||
|
inline void set(T* data, int size) { Data = data; DataEnd = data + size; }
|
||
|
inline void set(T* data, T* data_end) { Data = data; DataEnd = data_end; }
|
||
|
inline int size() const { return (int)(ptrdiff_t)(DataEnd - Data); }
|
||
|
inline int size_in_bytes() const { return (int)(ptrdiff_t)(DataEnd - Data) * (int)sizeof(T); }
|
||
|
inline T& operator[](int i) { T* p = Data + i; IM_ASSERT(p >= Data && p < DataEnd); return *p; }
|
||
|
inline const T& operator[](int i) const { const T* p = Data + i; IM_ASSERT(p >= Data && p < DataEnd); return *p; }
|
||
|
|
||
|
inline T* begin() { return Data; }
|
||
|
inline const T* begin() const { return Data; }
|
||
|
inline T* end() { return DataEnd; }
|
||
|
inline const T* end() const { return DataEnd; }
|
||
|
|
||
|
// Utilities
|
||
|
inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it < DataEnd); const ptrdiff_t off = it - Data; return (int)off; }
|
||
|
};
|
||
|
|
||
|
// Helper: ImSpanAllocator<>
|
||
|
// Facilitate storing multiple chunks into a single large block (the "arena")
|
||
|
// - Usage: call Reserve() N times, allocate GetArenaSizeInBytes() worth, pass it to SetArenaBasePtr(), call GetSpan() N times to retrieve the aligned ranges.
|
||
|
template<int CHUNKS>
|
||
|
struct ImSpanAllocator
|
||
|
{
|
||
|
char* BasePtr;
|
||
|
int CurrOff;
|
||
|
int CurrIdx;
|
||
|
int Offsets[CHUNKS];
|
||
|
int Sizes[CHUNKS];
|
||
|
|
||
|
ImSpanAllocator() { memset(this, 0, sizeof(*this)); }
|
||
|
inline void Reserve(int n, size_t sz, int a=4) { IM_ASSERT(n == CurrIdx && n < CHUNKS); CurrOff = IM_MEMALIGN(CurrOff, a); Offsets[n] = CurrOff; Sizes[n] = (int)sz; CurrIdx++; CurrOff += (int)sz; }
|
||
|
inline int GetArenaSizeInBytes() { return CurrOff; }
|
||
|
inline void SetArenaBasePtr(void* base_ptr) { BasePtr = (char*)base_ptr; }
|
||
|
inline void* GetSpanPtrBegin(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrIdx == CHUNKS); return (void*)(BasePtr + Offsets[n]); }
|
||
|
inline void* GetSpanPtrEnd(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrIdx == CHUNKS); return (void*)(BasePtr + Offsets[n] + Sizes[n]); }
|
||
|
template<typename T>
|
||
|
inline void GetSpan(int n, ImSpan<T>* span) { span->set((T*)GetSpanPtrBegin(n), (T*)GetSpanPtrEnd(n)); }
|
||
|
};
|
||
|
|
||
|
// 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;
|
||
|
template<typename T>
|
||
|
struct ImPool
|
||
|
{
|
||
|
ImVector<T> Buf; // Contiguous data
|
||
|
ImGuiStorage Map; // ID->Index
|
||
|
ImPoolIdx FreeIdx; // Next free idx to use
|
||
|
ImPoolIdx AliveCount; // Number of active/alive items (for display purpose)
|
||
|
|
||
|
ImPool() { FreeIdx = AliveCount = 0; }
|
||
|
~ImPool() { Clear(); }
|
||
|
T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; }
|
||
|
T* GetByIndex(ImPoolIdx n) { return &Buf[n]; }
|
||
|
ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); }
|
||
|
T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); }
|
||
|
bool Contains(const T* p) const { return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
|
||
|
void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = AliveCount = 0; }
|
||
|
T* Add() { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); AliveCount++; return &Buf[idx]; }
|
||
|
void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); }
|
||
|
void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); AliveCount--; }
|
||
|
void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); }
|
||
|
|
||
|
// To iterate a ImPool: for (int n = 0; n < pool.GetMapSize(); n++) if (T* t = pool.TryGetMapData(n)) { ... }
|
||
|
// Can be avoided if you know .Remove() has never been called on the pool, or AliveCount == GetMapSize()
|
||
|
int GetAliveCount() const { return AliveCount; } // Number of active/alive items in the pool (for display purpose)
|
||
|
int GetBufSize() const { return Buf.Size; }
|
||
|
int GetMapSize() const { return Map.Data.Size; } // It is the map we need iterate to find valid items, since we don't have "alive" storage anywhere
|
||
|
T* TryGetMapData(ImPoolIdx n) { int idx = Map.Data[n].val_i; if (idx == -1) return NULL; return GetByIndex(idx); }
|
||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||
|
int GetSize() { return GetMapSize(); } // For ImPlot: should use GetMapSize() from (IMGUI_VERSION_NUM >= 18304)
|
||
|
#endif
|
||
|
};
|
||
|
|
||
|
// Helper: ImChunkStream<>
|
||
|
// Build and iterate a contiguous stream of variable-sized structures.
|
||
|
// This is used by Settings to store persistent data while reducing allocation count.
|
||
|
// We store the chunk size first, and align the final size on 4 bytes boundaries.
|
||
|
// The tedious/zealous amount of casting is to avoid -Wcast-align warnings.
|
||
|
template<typename T>
|
||
|
struct ImChunkStream
|
||
|
{
|
||
|
ImVector<char> Buf;
|
||
|
|
||
|
void clear() { Buf.clear(); }
|
||
|
bool empty() const { return Buf.Size == 0; }
|
||
|
int size() const { return Buf.Size; }
|
||
|
T* alloc_chunk(size_t sz) { size_t HDR_SZ = 4; sz = IM_MEMALIGN(HDR_SZ + sz, 4u); int off = Buf.Size; Buf.resize(off + (int)sz); ((int*)(void*)(Buf.Data + off))[0] = (int)sz; return (T*)(void*)(Buf.Data + off + (int)HDR_SZ); }
|
||
|
T* begin() { size_t HDR_SZ = 4; if (!Buf.Data) return NULL; return (T*)(void*)(Buf.Data + HDR_SZ); }
|
||
|
T* next_chunk(T* p) { size_t HDR_SZ = 4; IM_ASSERT(p >= begin() && p < end()); p = (T*)(void*)((char*)(void*)p + chunk_size(p)); if (p == (T*)(void*)((char*)end() + HDR_SZ)) return (T*)0; IM_ASSERT(p < end()); return p; }
|
||
|
int chunk_size(const T* p) { return ((const int*)p)[-1]; }
|
||
|
T* end() { return (T*)(void*)(Buf.Data + Buf.Size); }
|
||
|
int offset_from_ptr(const T* p) { IM_ASSERT(p >= begin() && p < end()); const ptrdiff_t off = (const char*)p - Buf.Data; return (int)off; }
|
||
|
T* ptr_from_offset(int off) { IM_ASSERT(off >= 4 && off < Buf.Size); return (T*)(void*)(Buf.Data + off); }
|
||
|
void swap(ImChunkStream<T>& rhs) { rhs.Buf.swap(Buf); }
|
||
|
|
||
|
};
|
||
|
|
||
|
// Helper: ImGuiTextIndex<>
|
||
|
// Maintain a line index for a text buffer. This is a strong candidate to be moved into the public API.
|
||
|
struct ImGuiTextIndex
|
||
|
{
|
||
|
ImVector<int> LineOffsets;
|
||
|
int EndOffset = 0; // Because we don't own text buffer we need to maintain EndOffset (may bake in LineOffsets?)
|
||
|
|
||
|
void clear() { LineOffsets.clear(); EndOffset = 0; }
|
||
|
int size() { return LineOffsets.Size; }
|
||
|
const char* get_line_begin(const char* base, int n) { return base + LineOffsets[n]; }
|
||
|
const char* get_line_end(const char* base, int n) { return base + (n + 1 < LineOffsets.Size ? (LineOffsets[n + 1] - 1) : EndOffset); }
|
||
|
void append(const char* base, int old_size, int new_size);
|
||
|
};
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
// [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
|
||
|
#define IM_DRAWLIST_ARCFAST_SAMPLE_MAX IM_DRAWLIST_ARCFAST_TABLE_SIZE // Sample index _PathArcToFastEx() for 360 angle.
|
||
|
|
||
|
// Data shared between all ImDrawList instances
|
||
|
// You may want to create your own instance of this if you want to use ImDrawList completely without ImGui. In that case, watch out for future changes to this structure.
|
||
|
struct IMGUI_API ImDrawListSharedData
|
||
|
{
|
||
|
ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas
|
||
|
ImFont* Font; // Current/default font (optional, for simplified AddText overload)
|
||
|
float FontSize; // Current/default font size (optional, for simplified AddText overload)
|
||
|
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo()
|
||
|
float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc
|
||
|
ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen()
|
||
|
ImDrawListFlags InitialFlags; // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards)
|
||
|
|
||
|
// [Internal] Temp write buffer
|
||
|
ImVector<ImVec2> TempBuffer;
|
||
|
|
||
|
// [Internal] 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)
|
||
|
const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas
|
||
|
|
||
|
ImDrawListSharedData();
|
||
|
void SetCircleTessellationMaxError(float max_error);
|
||
|
};
|
||
|
|
||
|
struct ImDrawDataBuilder
|
||
|
{
|
||
|
ImVector<ImDrawList*> Layers[2]; // Global layers for: regular, tooltip
|
||
|
|
||
|
void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
|
||
|
void ClearFreeMemory() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
|
||
|
int GetDrawListCount() const { int count = 0; for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) count += Layers[n].Size; return count; }
|
||
|
IMGUI_API void FlattenIntoSingleLayer();
|
||
|
};
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
// [SECTION] Widgets support: flags, enums, data structures
|
||
|
//-----------------------------------------------------------------------------
|
||
|
|
||
|
// Flags used by upcoming items
|
||
|
// - input: PushItemFlag() manipulates g.CurrentItemFlags, ItemAdd() calls may add extra flags.
|
||
|
// - output: stored in g.LastItemData.InFlags
|
||
|
// Current window shared by all windows.
|
||
|
// This is going to be exposed in imgui.h when stabilized enough.
|
||
|
enum ImGuiItemFlags_
|
||
|
{
|
||
|
// Controlled by user
|
||
|
ImGuiItemFlags_None = 0,
|
||
|
ImGuiItemFlags_NoTabStop = 1 << 0, // false // Disable keyboard tabbing. This is a "lighter" version of ImGuiItemFlags_NoNav.
|
||
|
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||
|
ImGuiItemFlags_Disabled = 1 << 2, // false // Disable interactions but doesn't affect visuals. See BeginDisabled()/EndDisabled(). See github.com/ocornut/imgui/issues/211
|
||
|
ImGuiItemFlags_NoNav = 1 << 3, // false // Disable any form of focusing (keyboard/gamepad directional navigation and SetKeyboardFocusHere() calls)
|
||
|
ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false // Disable item being a candidate for default focus (e.g. used by title bar items)
|
||
|
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // Disable MenuItem/Selectable() automatically closing their popup window
|
||
|
ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
||
|
ImGuiItemFlags_ReadOnly = 1 << 7, // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
|
||
|
ImGuiItemFlags_NoWindowHoverableCheck = 1 << 8, // false // Disable hoverable check in ItemHoverable()
|
||
|
|
||
|
// Controlled by widget code
|
||
|
ImGuiItemFlags_Inputable = 1 << 10, // false // [WIP] Auto-activate input mode when tab focused. Currently only used and supported by a few items before it becomes a generic feature.
|
||
|
};
|
||
|
|
||
|
// Status flags for an already submitted item
|
||
|
// - output: stored in g.LastItemData.StatusFlags
|
||
|
enum ImGuiItemStatusFlags_
|
||
|
{
|
||
|
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_FocusedByTabbing = 1 << 8, // Set when the Focusable item just got focused by Tabbing (FIXME: to be removed soon)
|
||
|
ImGuiItemStatusFlags_Visible = 1 << 9, // [WIP] Set when item is overlapping the current clipping rectangle (Used internally. Please don't use yet: API/system will change as we refactor Itemadd()).
|
||
|
|
||
|
// 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
|
||
|
};
|
||
|
|
||
|
// Extend ImGuiInputTextFlags_
|
||
|
enum ImGuiInputTextFlagsPrivate_
|
||
|
{
|
||
|
// [Internal]
|
||
|
ImGuiInputTextFlags_Multiline = 1 << 26, // For internal use by InputTextMultiline()
|
||
|
ImGuiInputTextFlags_NoMarkEdited = 1 << 27, // For internal use by functions using InputText() before reformatting data
|
||
|
ImGuiInputTextFlags_MergedItem = 1 << 28, // For internal use by TempInputText(), will skip calling ItemAdd(). Require bounding-box to strictly match.
|
||
|
};
|
||
|
|
||
|
// Extend ImGuiButtonFlags_
|
||
|
enum ImGuiButtonFlagsPrivate_
|
||
|
{
|
||
|
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
|
||
|
ImGuiButtonFlags_FlattenChildren = 1 << 11, // allow interactions even if a child window is overlapping
|
||
|
ImGuiButtonFlags_AllowItemOverlap = 1 << 12, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
|
||
|
ImGuiButtonFlags_DontClosePopups = 1 << 13, // disable automatically closing parent popup on press // [UNUSED]
|
||
|
//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_NoKeyModifiers = 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 everytime an item uses ImGuiItemFlags_NoNav, but because legacy specs don't requires LastItemData to be set ButtonBehavior(), we can't poll g.LastItemData.InFlags)
|
||
|
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_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold,
|
||
|
ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease,
|
||
|
};
|
||
|
|
||
|
// Extend ImGuiComboFlags_
|
||
|
enum ImGuiComboFlagsPrivate_
|
||
|
{
|
||
|
ImGuiComboFlags_CustomPreview = 1 << 20, // enable BeginComboPreview()
|
||
|
};
|
||
|
|
||
|
// Extend ImGuiSliderFlags_
|
||
|
enum ImGuiSliderFlagsPrivate_
|
||
|
{
|
||
|
ImGuiSliderFlags_Vertical = 1 << 20, // Should this slider be orientated vertically?
|
||
|
ImGuiSliderFlags_ReadOnly = 1 << 21,
|
||
|
};
|
||
|
|
||
|
// Extend ImGuiSelectableFlags_
|
||
|
enum ImGuiSelectableFlagsPrivate_
|
||
|
{
|
||
|
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
||
|
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
|
||
|
ImGuiSelectableFlags_SelectOnNav = 1 << 21, // (WIP) Auto-select when moved into. This is not exposed in public API as to handle multi-select and modifiers we will need user to explicitly control focus scope. May be replaced with a BeginSelection() API.
|
||
|
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!)
|
||
|
};
|
||
|
|
||
|
// Extend ImGuiTreeNodeFlags_
|
||
|
enum ImGuiTreeNodeFlagsPrivate_
|
||
|
{
|
||
|
ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20,
|
||
|
};
|
||
|
|
||
|
enum ImGuiSeparatorFlags_
|
||
|
{
|
||
|
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.
|
||
|
};
|
||
|
|
||
|
// 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.
|
||
|
enum ImGuiFocusRequestFlags_
|
||
|
{
|
||
|
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.
|
||
|
};
|
||
|
|
||
|
enum ImGuiTextFlags_
|
||
|
{
|
||
|
ImGuiTextFlags_None = 0,
|
||
|
ImGuiTextFlags_NoWidthForLargeClippedText = 1 << 0,
|
||
|
};
|
||
|
|
||
|
enum ImGuiTooltipFlags_
|
||
|
{
|
||
|
ImGuiTooltipFlags_None = 0,
|
||
|
ImGuiTooltipFlags_OverridePreviousTooltip = 1 << 0, // Override will clear/ignore previously submitted tooltip (defaults to append)
|
||
|
};
|
||
|
|
||
|
// 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
|
||
|
enum ImGuiLayoutType_
|
||
|
{
|
||
|
ImGuiLayoutType_Horizontal = 0,
|
||
|
ImGuiLayoutType_Vertical = 1
|
||
|
};
|
||
|
|
||
|
enum ImGuiLogType
|
||
|
{
|
||
|
ImGuiLogType_None = 0,
|
||
|
ImGuiLogType_TTY,
|
||
|
ImGuiLogType_File,
|
||
|
ImGuiLogType_Buffer,
|
||
|
ImGuiLogType_Clipboard,
|
||
|
};
|
||
|
|
||
|
// X/Y enums are fixed to 0/1 so they may be used to index ImVec2
|
||
|
enum ImGuiAxis
|
||
|
{
|
||
|
ImGuiAxis_None = -1,
|
||
|
ImGuiAxis_X = 0,
|
||
|
ImGuiAxis_Y = 1
|
||
|
};
|
||
|
|
||
|
enum ImGuiPlotType
|
||
|
{
|
||
|
ImGuiPlotType_Lines,
|
||
|
ImGuiPlotType_Histogram,
|
||
|
};
|
||
|
|
||
|
enum ImGuiPopupPositionPolicy
|
||
|
{
|
||
|
ImGuiPopupPositionPolicy_Default,
|
||
|
ImGuiPopupPositionPolicy_ComboBox,
|
||
|
ImGuiPopupPositionPolicy_Tooltip,
|
||
|
};
|
||
|
|
||
|
struct ImGuiDataVarInfo
|
||
|
{
|
||
|
ImGuiDataType Type;
|
||
|
ImU32 Count; // 1+
|
||
|
ImU32 Offset; // Offset in parent structure
|
||
|
void* GetVarPtr(void* parent) const { return (void*)((unsigned char*)parent + Offset); }
|
||
|
};
|
||
|
|
||
|
struct ImGuiDataTypeTempStorage
|
||
|
{
|
||
|
ImU8 Data[8]; // Can fit any data up to ImGuiDataType_COUNT
|
||
|
};
|
||
|
|
||
|
// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo().
|
||
|
struct ImGuiDataTypeInfo
|
||
|
{
|
||
|
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_
|
||
|
enum ImGuiDataTypePrivate_
|
||
|
{
|
||
|
ImGuiDataType_String = ImGuiDataType_COUNT + 1,
|
||
|
ImGuiDataType_Pointer,
|
||
|
ImGuiDataType_ID,
|
||
|
};
|
||
|
|
||
|
// Stacked color modifier, backup of modified data so we can restore it
|
||
|
struct ImGuiColorMod
|
||
|
{
|
||
|
ImGuiCol Col;
|
||
|
ImVec4 BackupValue;
|
||
|
};
|
||
|
|
||
|
// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
|
||