797 #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
798 #define _CRT_SECURE_NO_WARNINGS
802 #ifndef IMGUI_DISABLE
804 #ifndef IMGUI_DEFINE_MATH_OPERATORS
805 #define IMGUI_DEFINE_MATH_OPERATORS
812 #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
819 #if defined(_WIN32) && defined(IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS) && defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) && defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
820 #define IMGUI_DISABLE_WIN32_FUNCTIONS
822 #if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
823 #ifndef WIN32_LEAN_AND_MEAN
824 #define WIN32_LEAN_AND_MEAN
834 #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) // UWP doesn't have all Win32 functions
835 #define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
836 #define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
841 #if defined(__APPLE__)
842 #include <TargetConditionals.h>
847 #pragma warning (disable: 4127) // condition expression is constant
848 #pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
849 #if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
850 #pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
855 #if defined(__clang__)
856 #pragma clang diagnostic ignored "-Wunknown-pragmas" // warning : unknown warning group '-Wformat-pedantic *' // not all warnings are known by all clang versions.. so ignoring warnings triggers new warnings on some configuration. great!
857 #pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
858 #pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok.
859 #pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code.
860 #pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
861 #pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference is.
862 #pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
863 #pragma clang diagnostic ignored "-Wformat-pedantic" // warning : format specifies type 'void *' but the argument has type 'xxxx *' // unreasonable, would lead to casting every %p arg to void*. probably enabled by -pedantic.
864 #pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
865 #if __has_warning("-Wzero-as-null-pointer-constant")
866 #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning : zero as null pointer constant // some standard header variations use #define NULL 0
868 #if __has_warning("-Wdouble-promotion")
869 #pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
871 #elif defined(__GNUC__)
873 #pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
874 #pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
875 #pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
876 #pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*'
877 #pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
878 #pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
879 #pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
880 #pragma GCC diagnostic ignored "-Wstrict-overflow" // warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false
881 #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
885 #define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL
886 #define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window
887 #define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower)
981 #ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS
1068 memset(
this, 0,
sizeof(*
this));
1114 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1139 if ((c & 0xFC00) == 0xD800)
1150 if ((c & 0xFC00) != 0xDC00)
1163 while (*utf8_chars != 0)
1186 float p_closest_dist2 = FLT_MAX;
1187 float t_step = 1.0f / (float)num_segments;
1188 for (
int i_step = 1; i_step <= num_segments; i_step++)
1193 if (dist2 < p_closest_dist2)
1196 p_closest_dist2 = dist2;
1204 static void BezierClosestPointCasteljauStep(
const ImVec2&
p,
ImVec2& p_closest,
ImVec2& p_last,
float& p_closest_dist2,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
float x4,
float y4,
float tess_tol,
int level)
1208 float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
1209 float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
1210 d2 = (d2 >= 0) ? d2 : -d2;
1211 d3 = (d3 >= 0) ? d3 : -d3;
1212 if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
1214 ImVec2 p_current(x4, y4);
1217 if (dist2 < p_closest_dist2)
1220 p_closest_dist2 = dist2;
1224 else if (
level < 10)
1226 float x12 = (x1+x2)*0.5
f, y12 = (y1+y2)*0.5f;
1227 float x23 = (x2+x3)*0.5
f, y23 = (y2+y3)*0.5f;
1228 float x34 = (x3+x4)*0.5
f, y34 = (y3+y4)*0.5f;
1229 float x123 = (x12+x23)*0.5
f, y123 = (y12+y23)*0.5f;
1230 float x234 = (x23+x34)*0.5
f, y234 = (y23+y34)*0.5f;
1231 float x1234 = (x123+x234)*0.5
f, y1234 = (y123+y234)*0.5f;
1232 BezierClosestPointCasteljauStep(
p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol,
level + 1);
1233 BezierClosestPointCasteljauStep(
p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol,
level + 1);
1244 float p_closest_dist2 = FLT_MAX;
1245 BezierClosestPointCasteljauStep(
p, p_closest, p_last, p_closest_dist2, p1.
x, p1.
y, p2.
x, p2.
y, p3.
x, p3.
y, p4.
x, p4.
y, tess_tol, 0);
1253 float dot = ap.
x * ab_dir.
x + ap.
y * ab_dir.
y;
1256 float ab_len_sqr = ab_dir.
x * ab_dir.
x + ab_dir.
y * ab_dir.
y;
1257 if (dot > ab_len_sqr)
1259 return a + ab_dir * dot / ab_len_sqr;
1264 bool b1 = ((
p.x -
b.x) * (
a.y -
b.y) - (
p.y -
b.y) * (
a.x -
b.x)) < 0.0
f;
1265 bool b2 = ((
p.x - c.
x) * (
b.y - c.
y) - (
p.y - c.
y) * (
b.x - c.
x)) < 0.0
f;
1266 bool b3 = ((
p.x -
a.x) * (c.
y -
a.y) - (
p.y -
a.y) * (c.
x -
a.x)) < 0.0
f;
1267 return ((b1 == b2) && (b2 == b3));
1275 const float denom =
v0.x *
v1.y -
v1.x *
v0.y;
1276 out_v = (
v2.x *
v1.y -
v1.x *
v2.y) / denom;
1277 out_w = (
v0.x *
v2.y -
v2.x *
v0.y) / denom;
1278 out_u = 1.0f - out_v - out_w;
1289 float m =
ImMin(dist2_ab,
ImMin(dist2_bc, dist2_ca));
1305 while ((
d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; }
1312 while (
count > 0 && (
d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++;
count--; }
1327 size_t len = strlen(
str);
1329 return (
char*)memcpy(
buf, (
const void*)
str,
len + 1);
1334 size_t dst_buf_size = p_dst_size ? *p_dst_size : strlen(
dst) + 1;
1335 size_t src_size = strlen(
src) + 1;
1336 if (dst_buf_size < src_size)
1341 *p_dst_size = src_size;
1343 return (
char*)memcpy(
dst, (
const void*)
src, src_size);
1348 const char*
p = (
const char*)memchr(
str, (
int)c, str_end -
str);
1363 const char*
p = (
const char*)memchr(
str,
'\n', str_end -
str);
1364 return p ?
p : str_end;
1369 while (buf_mid_line > buf_begin && buf_mid_line[-1] !=
'\n')
1371 return buf_mid_line;
1374 const char*
ImStristr(
const char* haystack,
const char* haystack_end,
const char* needle,
const char* needle_end)
1377 needle_end = needle + strlen(needle);
1379 const char un0 = (char)toupper(*needle);
1380 while ((!haystack_end && *haystack) || (haystack_end && haystack < haystack_end))
1382 if (toupper(*haystack) == un0)
1384 const char*
b = needle + 1;
1385 for (
const char*
a = haystack + 1;
b < needle_end;
a++,
b++)
1386 if (toupper(*
a) != toupper(*
b))
1388 if (
b == needle_end)
1400 while (
p[0] ==
' ' ||
p[0] ==
'\t')
1405 while (
p > p_start && (
p[-1] ==
' ' ||
p[-1] ==
'\t'))
1408 memmove(
buf, p_start,
p - p_start);
1409 buf[
p - p_start] = 0;
1414 while (
str[0] ==
' ' ||
str[0] ==
'\t')
1422 #ifndef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
1428 #ifdef IMGUI_USE_STB_SPRINTF
1429 #define STB_SPRINTF_IMPLEMENTATION
1430 #include "stb_sprintf.h"
1433 #if defined(_MSC_VER) && !defined(vsnprintf)
1434 #define vsnprintf _vsnprintf
1441 #ifdef IMGUI_USE_STB_SPRINTF
1442 int w = stbsp_vsnprintf(
buf, (
int)buf_size,
fmt,
args);
1449 if (
w == -1 ||
w >= (
int)buf_size)
1450 w = (int)buf_size - 1;
1457 #ifdef IMGUI_USE_STB_SPRINTF
1458 int w = stbsp_vsnprintf(
buf, (
int)buf_size,
fmt,
args);
1464 if (
w == -1 ||
w >= (
int)buf_size)
1465 w = (int)buf_size - 1;
1469 #endif // #ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
1476 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,
1477 0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5,
1478 0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59,
1479 0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,
1480 0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01,
1481 0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65,
1482 0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,
1483 0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD,
1484 0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1,
1485 0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,
1486 0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79,
1487 0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D,
1488 0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,
1489 0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45,
1490 0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9,
1491 0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D,
1500 const unsigned char*
data = (
const unsigned char*)data_p;
1502 while (data_size-- != 0)
1503 crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *
data++];
1517 const unsigned char*
data = (
const unsigned char*)data_p;
1521 while (data_size-- != 0)
1523 unsigned char c = *
data++;
1524 if (c ==
'#' && data_size >= 2 &&
data[0] ==
'#' &&
data[1] ==
'#')
1526 crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
1531 while (
unsigned char c = *
data++)
1533 if (c ==
'#' &&
data[0] ==
'#' &&
data[1] ==
'#')
1535 crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
1546 #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
1550 #if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__)
1553 const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename, -1,
NULL, 0);
1554 const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0,
mode, -1,
NULL, 0);
1556 buf.resize(filename_wsize + mode_wsize);
1557 ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (
wchar_t*)&
buf[0], filename_wsize);
1558 ::MultiByteToWideChar(CP_UTF8, 0,
mode, -1, (
wchar_t*)&
buf[filename_wsize], mode_wsize);
1559 return ::_wfopen((
const wchar_t*)&
buf[0], (
const wchar_t*)&
buf[filename_wsize]);
1561 return fopen(filename,
mode);
1570 #endif // #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
1586 if (file_size == (
size_t)-1)
1604 if (padding_bytes > 0)
1605 memset((
void*)(((
char*)
file_data) + file_size), 0, (
size_t)padding_bytes);
1609 *out_file_size = file_size;
1623 unsigned int c = (
unsigned int)-1;
1624 const unsigned char*
str = (
const unsigned char*)in_text;
1627 c = (
unsigned int)(*
str++);
1631 if ((*
str & 0xe0) == 0xc0)
1634 if (in_text_end && in_text_end - (
const char*)
str < 2)
return 1;
1635 if (*
str < 0xc2)
return 2;
1636 c = (
unsigned int)((*
str++ & 0x1f) << 6);
1637 if ((*
str & 0xc0) != 0x80)
return 2;
1638 c += (*
str++ & 0x3f);
1642 if ((*
str & 0xf0) == 0xe0)
1645 if (in_text_end && in_text_end - (
const char*)
str < 3)
return 1;
1646 if (*
str == 0xe0 && (
str[1] < 0xa0 ||
str[1] > 0xbf))
return 3;
1647 if (*
str == 0xed &&
str[1] > 0x9f)
return 3;
1648 c = (
unsigned int)((*
str++ & 0x0f) << 12);
1649 if ((*
str & 0xc0) != 0x80)
return 3;
1650 c += (
unsigned int)((*
str++ & 0x3f) << 6);
1651 if ((*
str & 0xc0) != 0x80)
return 3;
1652 c += (*
str++ & 0x3f);
1656 if ((*
str & 0xf8) == 0xf0)
1659 if (in_text_end && in_text_end - (
const char*)
str < 4)
return 1;
1660 if (*
str > 0xf4)
return 4;
1661 if (*
str == 0xf0 && (
str[1] < 0x90 ||
str[1] > 0xbf))
return 4;
1662 if (*
str == 0xf4 &&
str[1] > 0x8f)
return 4;
1663 c = (
unsigned int)((*
str++ & 0x07) << 18);
1664 if ((*
str & 0xc0) != 0x80)
return 4;
1665 c += (
unsigned int)((*
str++ & 0x3f) << 12);
1666 if ((*
str & 0xc0) != 0x80)
return 4;
1667 c += (
unsigned int)((*
str++ & 0x3f) << 6);
1668 if ((*
str & 0xc0) != 0x80)
return 4;
1669 c += (*
str++ & 0x3f);
1671 if ((c & 0xFFFFF800) == 0xD800)
return 4;
1685 while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text)
1694 if (in_text_remaining)
1695 *in_text_remaining = in_text;
1696 return (
int)(buf_out -
buf);
1702 while ((!in_text_end || in_text < in_text_end) && *in_text)
1723 if (buf_size < 2)
return 0;
1724 buf[0] = (char)(0xc0 + (c >> 6));
1725 buf[1] = (char)(0x80 + (c & 0x3f));
1730 if (buf_size < 3)
return 0;
1731 buf[0] = (char)(0xe0 + (c >> 12));
1732 buf[1] = (char)(0x80 + ((c>> 6) & 0x3f));
1733 buf[2] = (char)(0x80 + ((c ) & 0x3f));
1738 if (buf_size < 4)
return 0;
1739 buf[0] = (char)(0xf0 + (c >> 18));
1740 buf[1] = (char)(0x80 + ((c >> 12) & 0x3f));
1741 buf[2] = (char)(0x80 + ((c >> 6) & 0x3f));
1742 buf[3] = (char)(0x80 + ((c ) & 0x3f));
1752 unsigned int dummy = 0;
1758 if (c < 0x80)
return 1;
1759 if (c < 0x800)
return 2;
1760 if (c < 0x10000)
return 3;
1761 if (c <= 0x10FFFF)
return 4;
1767 char* buf_out =
buf;
1768 const char* buf_end =
buf + buf_size;
1769 while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text)
1771 unsigned int c = (
unsigned int)(*in_text++);
1773 *buf_out++ = (char)c;
1778 return (
int)(buf_out -
buf);
1783 int bytes_count = 0;
1784 while ((!in_text_end || in_text < in_text_end) && *in_text)
1786 unsigned int c = (
unsigned int)(*in_text++);
1811 float s = 1.0f/255.0f;
1845 const float chroma =
r - (
g <
b ?
g :
b);
1846 out_h =
ImFabs(
K + (
g -
b) / (6.
f * chroma + 1e-20
f));
1847 out_s = chroma / (
r + 1e-20
f);
1858 out_r = out_g = out_b =
v;
1864 float f =
h - (float)
i;
1865 float p =
v * (1.0f -
s);
1866 float q =
v * (1.0f -
s *
f);
1867 float t =
v * (1.0f -
s * (1.0f -
f));
1871 case 0: out_r =
v; out_g = t; out_b =
p;
break;
1872 case 1: out_r = q; out_g =
v; out_b =
p;
break;
1873 case 2: out_r =
p; out_g =
v; out_b = t;
break;
1874 case 3: out_r =
p; out_g = q; out_b =
v;
break;
1875 case 4: out_r = t; out_g =
p; out_b =
v;
break;
1876 case 5:
default: out_r =
v; out_g =
p; out_b = q;
break;
1893 size_t count2 =
count >> 1;
1898 count -= count2 + 1;
1913 static int IMGUI_CDECL PairCompareByID(
const void* lhs,
const void* rhs)
1935 return GetInt(
key, default_val ? 1 : 0) != 0;
2025 for (
int i = 0;
i <
Data.Size;
i++)
2055 return value_changed;
2062 const char* we = wb;
2065 if (*we == separator)
2138 #if defined(__GNUC__) || defined(__clang__)
2139 #define va_copy(dest, src) __builtin_va_copy(dest, src)
2141 #define va_copy(dest, src) (dest = src)
2149 int len = str_end ? (int)(str_end -
str) : (int)strlen(
str);
2152 const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
2153 const int needed_sz = write_off +
len;
2154 if (write_off +
len >= Buf.Capacity)
2156 int new_capacity = Buf.Capacity * 2;
2157 Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
2160 Buf.resize(needed_sz);
2161 memcpy(&Buf[write_off - 1],
str, (
size_t)
len);
2162 Buf[write_off - 1 +
len] = 0;
2187 const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
2188 const int needed_sz = write_off +
len;
2189 if (write_off +
len >= Buf.Capacity)
2191 int new_capacity = Buf.Capacity * 2;
2192 Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
2195 Buf.resize(needed_sz);
2216 *out_items_display_start = 0;
2217 *out_items_display_end = items_count;
2222 *out_items_display_start = *out_items_display_end = 0;
2228 if (
g.NavMoveRequest)
2229 unclipped_rect.
Add(
g.NavScoringRectScreen);
2232 int start = (int)((unclipped_rect.
Min.
y - pos.
y) / items_height);
2233 int end = (int)((unclipped_rect.
Max.
y - pos.
y) / items_height);
2243 *out_items_display_start =
start;
2244 *out_items_display_end =
end;
2271 ItemsHeight = items_height;
2274 DisplayEnd = DisplayStart = -1;
2275 if (ItemsHeight > 0.0
f)
2278 if (DisplayStart > 0)
2289 if (ItemsCount < INT_MAX)
2300 if (ItemsCount == 0 || window->
SkipItems)
2315 if (ItemsCount == 1) { ItemsCount = -1;
return false; }
2316 float items_height = window->
DC.
CursorPos.
y - StartPosY;
2318 Begin(ItemsCount - 1, items_height);
2326 IM_ASSERT(DisplayStart >= 0 && DisplayEnd >= 0);
2341 IM_ASSERT(
GImGui !=
NULL &&
"No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
2349 c.
w *= style.
Alpha * alpha_mul;
2370 if (style.
Alpha >= 1.0f)
2384 g.ColorModifiers.push_back(backup);
2394 g.ColorModifiers.push_back(backup);
2395 g.Style.Colors[
idx] = col;
2405 g.ColorModifiers.pop_back();
2458 float* pvar = (
float*)var_info->
GetVarPtr(&
g.Style);
2463 IM_ASSERT(0 &&
"Called PushStyleVar() float variant but variable is not a float!");
2477 IM_ASSERT(0 &&
"Called PushStyleVar() ImVec2 variant but variable is not a ImVec2!");
2491 g.StyleModifiers.pop_back();
2563 const char* text_display_end = text;
2565 text_end = (
const char*)-1;
2567 while (text_display_end < text_end && *text_display_end !=
'\0' && (text_display_end[0] !=
'#' || text_display_end[1] !=
'#'))
2569 return text_display_end;
2580 const char* text_display_end;
2581 if (hide_text_after_hash)
2588 text_end = text + strlen(text);
2589 text_display_end = text_end;
2592 if (text != text_display_end)
2606 text_end = text + strlen(text);
2608 if (text != text_end)
2622 const ImVec2 text_size = text_size_if_known ? *text_size_if_known :
CalcTextSize(text, text_display_end,
false, 0.0
f);
2624 const ImVec2* clip_min = clip_rect ? &clip_rect->
Min : &pos_min;
2625 const ImVec2* clip_max = clip_rect ? &clip_rect->
Max : &pos_max;
2626 bool need_clipping = (pos.
x + text_size.
x >= clip_max->
x) || (pos.
y + text_size.
y >= clip_max->
y);
2628 need_clipping |= (pos.
x < clip_min->
x) || (pos.
y < clip_min->
y);
2631 if (align.
x > 0.0f) pos.
x =
ImMax(pos.
x, pos.
x + (pos_max.
x - pos.
x - text_size.
x) * align.
x);
2632 if (align.
y > 0.0f) pos.
y =
ImMax(pos.
y, pos.
y + (pos_max.
y - pos.
y - text_size.
y) * align.
y);
2637 ImVec4 fine_clip_rect(clip_min->
x, clip_min->
y, clip_max->
x, clip_max->
y);
2650 const int text_len = (int)(text_display_end - text);
2668 if (text_end_full ==
NULL)
2670 const ImVec2 text_size = text_size_if_known ? *text_size_if_known :
CalcTextSize(text, text_end_full,
false, 0.0
f);
2676 if (text_size.
x > pos_max.
x - pos_min.
x)
2685 const char* text_end_ellipsis =
NULL;
2688 int ellipsis_char_count = 1;
2689 if (ellipsis_char == (
ImWchar)-1)
2692 ellipsis_char_count = 3;
2696 float ellipsis_glyph_width = glyph->
X1;
2697 float ellipsis_total_width = ellipsis_glyph_width;
2699 if (ellipsis_char_count > 1)
2703 ellipsis_glyph_width = glyph->
X1 - glyph->
X0 + spacing_between_dots;
2704 ellipsis_total_width = ellipsis_glyph_width * (float)ellipsis_char_count - spacing_between_dots;
2708 const float text_avail_width =
ImMax((
ImMax(pos_max.
x, ellipsis_max_x) - ellipsis_total_width) - pos_min.
x, 1.0f);
2709 float text_size_clipped_x = font->
CalcTextSizeA(font_size, text_avail_width, 0.0
f, text, text_end_full, &text_end_ellipsis).
x;
2710 if (text == text_end_ellipsis && text_end_ellipsis < text_end_full)
2714 text_size_clipped_x = font->
CalcTextSizeA(font_size, FLT_MAX, 0.0
f, text, text_end_ellipsis).
x;
2716 while (text_end_ellipsis > text &&
ImCharIsBlankA(text_end_ellipsis[-1]))
2719 text_end_ellipsis--;
2720 text_size_clipped_x -= font->
CalcTextSizeA(font_size, FLT_MAX, 0.0
f, text_end_ellipsis, text_end_ellipsis + 1).
x;
2725 float ellipsis_x = pos_min.
x + text_size_clipped_x;
2726 if (ellipsis_x + ellipsis_total_width <= ellipsis_max_x)
2727 for (
int i = 0;
i < ellipsis_char_count;
i++)
2730 ellipsis_x += ellipsis_glyph_width;
2748 const float border_size =
g.Style.FrameBorderSize;
2749 if (
border && border_size > 0.0
f)
2760 const float border_size =
g.Style.FrameBorderSize;
2761 if (border_size > 0.0
f)
2780 ImRect display_rect = bb;
2784 const float THICKNESS = 2.0f;
2785 const float DISTANCE = 3.0f + THICKNESS * 0.5f;
2786 display_rect.Expand(
ImVec2(DISTANCE,DISTANCE));
2806 : DrawListInst(&context->DrawListSharedData)
2912 return ImHashData(&ptr,
sizeof(
void*), seed);
2936 g.FontSize =
g.DrawListSharedData.FontSize = window->
CalcFontSize();
2973 if (
g.ActiveIdIsJustActivated)
2975 g.ActiveIdTimer = 0.0f;
2976 g.ActiveIdHasBeenPressedBefore =
false;
2977 g.ActiveIdHasBeenEditedBefore =
false;
2980 g.LastActiveId =
id;
2981 g.LastActiveIdTimer = 0.0f;
2985 g.ActiveIdAllowOverlap =
false;
2986 g.ActiveIdWindow = window;
2987 g.ActiveIdHasBeenEditedThisFrame =
false;
2990 g.ActiveIdIsAlive =
id;
2996 g.ActiveIdUsingNavDirMask = 0x00;
2997 g.ActiveIdUsingNavInputMask = 0x00;
2998 g.ActiveIdUsingKeyInputMask = 0x00;
3010 g.HoveredIdAllowOverlap =
false;
3011 if (
id != 0 &&
g.HoveredIdPreviousFrame !=
id)
3012 g.HoveredIdTimer =
g.HoveredIdNotActiveTimer = 0.0f;
3018 return g.
HoveredId ?
g.HoveredId :
g.HoveredIdPreviousFrame;
3024 if (
g.ActiveId ==
id)
3026 if (
g.ActiveIdPreviousFrame ==
id)
3027 g.ActiveIdPreviousFrameIsAlive =
true;
3035 IM_ASSERT(
g.ActiveId ==
id ||
g.ActiveId == 0 ||
g.DragDropActive);
3038 g.ActiveIdHasBeenEditedThisFrame =
true;
3039 g.ActiveIdHasBeenEditedBefore =
true;
3050 if (focused_root_window->WasActive && focused_root_window != window->
RootWindow)
3069 if (
g.NavDisableMouseHover && !
g.NavDisableHighlight)
3087 if (
g.ActiveId != 0 &&
g.ActiveId != window->
DC.
LastItemId && !
g.ActiveIdAllowOverlap &&
g.ActiveId != window->
MoveId)
3110 if (
g.HoveredId != 0 &&
g.HoveredId !=
id && !
g.HoveredIdAllowOverlap)
3114 if (
g.HoveredWindow != window)
3116 if (
g.ActiveId != 0 &&
g.ActiveId !=
id && !
g.ActiveIdAllowOverlap)
3132 if (
g.DebugItemPickerActive &&
g.HoveredIdPreviousFrame ==
id)
3134 if (
g.DebugItemPickerBreakId ==
id)
3145 if (
id == 0 ||
id !=
g.ActiveId)
3146 if (clip_even_when_logged || !
g.LogEnabled)
3166 g.FocusRequestNextWindow = window;
3167 g.FocusRequestNextCounterTabStop = window->
DC.
FocusCounterTabStop + (
g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1);
3171 if (
g.FocusRequestCurrWindow == window)
3177 g.NavJustTabbedId =
id;
3182 if (
g.ActiveId ==
id)
3197 if (wrap_pos_x < 0.0
f)
3201 if (wrap_pos_x == 0.0
f)
3203 else if (wrap_pos_x > 0.0
f)
3206 return ImMax(wrap_pos_x - pos.
x, 1.0f);
3213 ctx->IO.MetricsActiveAllocations++;
3222 ctx->IO.MetricsActiveAllocations--;
3235 if (
g.IO.SetClipboardTextFn)
3253 #ifdef IMGUI_SET_CURRENT_CONTEXT_FUNC
3254 IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx);
3288 IM_ASSERT(
GImGui !=
NULL &&
"No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
3332 g.NavDisableHighlight =
true;
3335 bool can_move_window =
true;
3337 can_move_window =
false;
3338 if (can_move_window)
3339 g.MovingWindow = window;
3350 if (
g.MovingWindow !=
NULL)
3355 IM_ASSERT(
g.MovingWindow &&
g.MovingWindow->RootWindow);
3359 ImVec2 pos =
g.IO.MousePos -
g.ActiveIdClickOffset;
3360 if (moving_window->
Pos.
x != pos.
x || moving_window->
Pos.
y != pos.
y)
3370 g.MovingWindow =
NULL;
3376 if (
g.ActiveIdWindow &&
g.ActiveIdWindow->MoveId ==
g.ActiveId)
3379 if (!
g.IO.MouseDown[0])
3390 if (
g.ActiveId != 0 ||
g.HoveredId != 0)
3394 if (
g.NavWindow &&
g.NavWindow->Appearing)
3398 if (
g.IO.MouseClicked[0])
3400 if (
g.HoveredRootWindow !=
NULL)
3404 if (!
g.HoveredRootWindow->TitleBarRect().Contains(
g.IO.MouseClickedPos[0]))
3405 g.MovingWindow =
NULL;
3417 if (
g.IO.MouseClicked[1])
3422 bool hovered_window_above_modal =
false;
3424 hovered_window_above_modal =
true;
3425 for (
int i =
g.Windows.Size - 1;
i >= 0 && hovered_window_above_modal ==
false;
i--)
3428 if (window == modal)
3430 if (window ==
g.HoveredWindow)
3431 hovered_window_above_modal =
true;
3452 g.IO.MouseDelta =
g.IO.MousePos -
g.IO.MousePosPrev;
3455 if (
g.IO.MouseDelta.x != 0.0f ||
g.IO.MouseDelta.y != 0.0f)
3456 g.NavDisableMouseHover =
false;
3458 g.IO.MousePosPrev =
g.IO.MousePos;
3461 g.IO.MouseClicked[
i] =
g.IO.MouseDown[
i] &&
g.IO.MouseDownDuration[
i] < 0.0f;
3462 g.IO.MouseReleased[
i] = !
g.IO.MouseDown[
i] &&
g.IO.MouseDownDuration[
i] >= 0.0f;
3463 g.IO.MouseDownDurationPrev[
i] =
g.IO.MouseDownDuration[
i];
3464 g.IO.MouseDownDuration[
i] =
g.IO.MouseDown[
i] ? (
g.IO.MouseDownDuration[
i] < 0.0f ? 0.0f :
g.IO.MouseDownDuration[
i] +
g.IO.DeltaTime) : -1.0
f;
3465 g.IO.MouseDoubleClicked[
i] =
false;
3466 if (
g.IO.MouseClicked[
i])
3468 if ((
float)(
g.Time -
g.IO.MouseClickedTime[
i]) <
g.IO.MouseDoubleClickTime)
3471 if (
ImLengthSqr(delta_from_click_pos) <
g.IO.MouseDoubleClickMaxDist *
g.IO.MouseDoubleClickMaxDist)
3472 g.IO.MouseDoubleClicked[
i] =
true;
3473 g.IO.MouseClickedTime[
i] = -DBL_MAX;
3477 g.IO.MouseClickedTime[
i] =
g.Time;
3479 g.IO.MouseClickedPos[
i] =
g.IO.MousePos;
3480 g.IO.MouseDownWasDoubleClick[
i] =
g.IO.MouseDoubleClicked[
i];
3481 g.IO.MouseDragMaxDistanceAbs[
i] =
ImVec2(0.0
f, 0.0
f);
3482 g.IO.MouseDragMaxDistanceSqr[
i] = 0.0f;
3484 else if (
g.IO.MouseDown[
i])
3488 g.IO.MouseDragMaxDistanceSqr[
i] =
ImMax(
g.IO.MouseDragMaxDistanceSqr[
i],
ImLengthSqr(delta_from_click_pos));
3489 g.IO.MouseDragMaxDistanceAbs[
i].x =
ImMax(
g.IO.MouseDragMaxDistanceAbs[
i].x, delta_from_click_pos.
x < 0.0f ? -delta_from_click_pos.
x : delta_from_click_pos.
x);
3490 g.IO.MouseDragMaxDistanceAbs[
i].y =
ImMax(
g.IO.MouseDragMaxDistanceAbs[
i].y, delta_from_click_pos.
y < 0.0f ? -delta_from_click_pos.
y : delta_from_click_pos.
y);
3492 if (!
g.IO.MouseDown[
i] && !
g.IO.MouseReleased[
i])
3493 g.IO.MouseDownWasDoubleClick[
i] =
false;
3494 if (
g.IO.MouseClicked[
i])
3495 g.NavDisableMouseHover =
false;
3502 if (
g.WheelingWindow == window)
3505 g.WheelingWindowRefMousePos =
g.IO.MousePos;
3514 if (
g.WheelingWindow !=
NULL)
3518 g.WheelingWindowTimer = 0.0f;
3519 if (
g.WheelingWindowTimer <= 0.0f)
3521 g.WheelingWindow =
NULL;
3522 g.WheelingWindowTimer = 0.0f;
3526 if (
g.IO.MouseWheel == 0.0f &&
g.IO.MouseWheelH == 0.0f)
3529 ImGuiWindow* window =
g.WheelingWindow ?
g.WheelingWindow :
g.HoveredWindow;
3535 if (
g.IO.MouseWheel != 0.0f &&
g.IO.KeyCtrl &&
g.IO.FontAllowUserScaling)
3555 const float wheel_y = (
g.IO.MouseWheel != 0.0f && !
g.IO.KeyShift) ?
g.IO.MouseWheel : 0.0f;
3556 if (wheel_y != 0.0
f && !
g.IO.KeyCtrl)
3570 const float wheel_x = (
g.IO.MouseWheelH != 0.0f && !
g.IO.KeyShift) ?
g.IO.MouseWheelH : (
g.IO.MouseWheel != 0.0f &&
g.IO.KeyShift) ?
g.IO.MouseWheel : 0.0f;
3571 if (wheel_x != 0.0
f && !
g.IO.KeyCtrl)
3591 if (
g.ActiveId == 0 &&
g.FocusTabPressed)
3595 g.FocusRequestNextWindow =
g.NavWindow;
3596 g.FocusRequestNextCounterRegular = INT_MAX;
3597 if (
g.NavId != 0 &&
g.NavIdTabCounter != INT_MAX)
3598 g.FocusRequestNextCounterTabStop =
g.NavIdTabCounter + 1 + (
g.IO.KeyShift ? -1 : 1);
3600 g.FocusRequestNextCounterTabStop =
g.IO.KeyShift ? -1 : 0;
3604 g.FocusRequestCurrWindow =
NULL;
3605 g.FocusRequestCurrCounterRegular =
g.FocusRequestCurrCounterTabStop = INT_MAX;
3606 if (
g.FocusRequestNextWindow !=
NULL)
3609 g.FocusRequestCurrWindow = window;
3614 g.FocusRequestNextWindow =
NULL;
3615 g.FocusRequestNextCounterRegular =
g.FocusRequestNextCounterTabStop = INT_MAX;
3618 g.NavIdTabCounter = INT_MAX;
3636 g.HoveredRootWindow =
g.HoveredWindow =
NULL;
3640 g.HoveredWindow =
g.HoveredRootWindow =
NULL;
3643 int mouse_earliest_button_down = -1;
3644 bool mouse_any_down =
false;
3647 if (
g.IO.MouseClicked[
i])
3648 g.IO.MouseDownOwned[
i] = (
g.HoveredWindow !=
NULL) || (!
g.OpenPopupStack.empty());
3649 mouse_any_down |=
g.IO.MouseDown[
i];
3650 if (
g.IO.MouseDown[
i])
3651 if (mouse_earliest_button_down == -1 ||
g.IO.MouseClickedTime[
i] <
g.IO.MouseClickedTime[mouse_earliest_button_down])
3652 mouse_earliest_button_down =
i;
3654 const bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) ||
g.IO.MouseDownOwned[mouse_earliest_button_down];
3659 if (!mouse_avail_to_imgui && !mouse_dragging_extern_payload)
3660 g.HoveredWindow =
g.HoveredRootWindow =
NULL;
3663 if (
g.WantCaptureMouseNextFrame != -1)
3664 g.IO.WantCaptureMouse = (
g.WantCaptureMouseNextFrame != 0);
3666 g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (
g.HoveredWindow !=
NULL || mouse_any_down)) || (!
g.OpenPopupStack.empty());
3669 if (
g.WantCaptureKeyboardNextFrame != -1)
3670 g.IO.WantCaptureKeyboard = (
g.WantCaptureKeyboardNextFrame != 0);
3672 g.IO.WantCaptureKeyboard = (
g.ActiveId != 0) || (modal_window !=
NULL);
3674 g.IO.WantCaptureKeyboard =
true;
3677 g.IO.WantTextInput = (
g.WantTextInputNextFrame != -1) ? (
g.WantTextInputNextFrame != 0) :
false;
3688 return key_mod_flags;
3693 IM_ASSERT(
GImGui !=
NULL &&
"No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
3696 #ifdef IMGUI_ENABLE_TEST_ENGINE
3697 ImGuiTestEngineHook_PreNewFrame(&
g);
3706 g.Time +=
g.IO.DeltaTime;
3707 g.WithinFrameScope =
true;
3709 g.TooltipOverrideCount = 0;
3710 g.WindowsActiveCount = 0;
3711 g.MenusIdSubmittedThisFrame.resize(0);
3714 g.FramerateSecPerFrameAccum +=
g.IO.DeltaTime -
g.FramerateSecPerFrame[
g.FramerateSecPerFrameIdx];
3715 g.FramerateSecPerFrame[
g.FramerateSecPerFrameIdx] =
g.IO.DeltaTime;
3716 g.FramerateSecPerFrameIdx = (
g.FramerateSecPerFrameIdx + 1) %
IM_ARRAYSIZE(
g.FramerateSecPerFrame);
3717 g.IO.Framerate = (
g.FramerateSecPerFrameAccum > 0.0f) ? (1.0
f / (
g.FramerateSecPerFrameAccum / (
float)
IM_ARRAYSIZE(
g.FramerateSecPerFrame))) : FLT_MAX;
3720 g.IO.Fonts->Locked =
true;
3723 g.DrawListSharedData.ClipRectFullscreen =
ImVec4(0.0
f, 0.0
f,
g.IO.DisplaySize.x,
g.IO.DisplaySize.y);
3724 g.DrawListSharedData.CurveTessellationTol =
g.Style.CurveTessellationTol;
3725 g.DrawListSharedData.SetCircleSegmentMaxError(
g.Style.CircleSegmentMaxError);
3727 if (
g.Style.AntiAliasedLines)
3729 if (
g.Style.AntiAliasedFill)
3734 g.BackgroundDrawList.Clear();
3735 g.BackgroundDrawList.PushTextureID(
g.IO.Fonts->TexID);
3736 g.BackgroundDrawList.PushClipRectFullScreen();
3738 g.ForegroundDrawList.Clear();
3739 g.ForegroundDrawList.PushTextureID(
g.IO.Fonts->TexID);
3740 g.ForegroundDrawList.PushClipRectFullScreen();
3746 if (
g.DragDropActive &&
g.DragDropPayload.SourceId ==
g.ActiveId)
3750 if (!
g.HoveredIdPreviousFrame)
3751 g.HoveredIdTimer = 0.0f;
3752 if (!
g.HoveredIdPreviousFrame || (
g.HoveredId &&
g.ActiveId ==
g.HoveredId))
3753 g.HoveredIdNotActiveTimer = 0.0f;
3755 g.HoveredIdTimer +=
g.IO.DeltaTime;
3756 if (
g.HoveredId &&
g.ActiveId !=
g.HoveredId)
3757 g.HoveredIdNotActiveTimer +=
g.IO.DeltaTime;
3758 g.HoveredIdPreviousFrame =
g.HoveredId;
3760 g.HoveredIdAllowOverlap =
false;
3763 if (
g.ActiveIdIsAlive !=
g.ActiveId &&
g.ActiveIdPreviousFrame ==
g.ActiveId &&
g.ActiveId != 0)
3766 g.ActiveIdTimer +=
g.IO.DeltaTime;
3767 g.LastActiveIdTimer +=
g.IO.DeltaTime;
3768 g.ActiveIdPreviousFrame =
g.ActiveId;
3769 g.ActiveIdPreviousFrameWindow =
g.ActiveIdWindow;
3770 g.ActiveIdPreviousFrameHasBeenEditedBefore =
g.ActiveIdHasBeenEditedBefore;
3771 g.ActiveIdIsAlive = 0;
3772 g.ActiveIdHasBeenEditedThisFrame =
false;
3773 g.ActiveIdPreviousFrameIsAlive =
false;
3774 g.ActiveIdIsJustActivated =
false;
3775 if (
g.TempInputId != 0 &&
g.ActiveId !=
g.TempInputId)
3777 if (
g.ActiveId == 0)
3779 g.ActiveIdUsingNavDirMask = 0x00;
3780 g.ActiveIdUsingNavInputMask = 0x00;
3781 g.ActiveIdUsingKeyInputMask = 0x00;
3785 g.DragDropAcceptIdPrev =
g.DragDropAcceptIdCurr;
3786 g.DragDropAcceptIdCurr = 0;
3787 g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
3788 g.DragDropWithinSource =
false;
3789 g.DragDropWithinTarget =
false;
3794 memcpy(
g.IO.KeysDownDurationPrev,
g.IO.KeysDownDuration,
sizeof(
g.IO.KeysDownDuration));
3796 g.IO.KeysDownDuration[
i] =
g.IO.KeysDown[
i] ? (
g.IO.KeysDownDuration[
i] < 0.0f ? 0.0f :
g.IO.KeysDownDuration[
i] +
g.IO.DeltaTime) : -1.0f;
3813 g.DimBgRatio =
ImMin(
g.DimBgRatio +
g.IO.DeltaTime * 6.0f, 1.0f);
3815 g.DimBgRatio =
ImMax(
g.DimBgRatio -
g.IO.DeltaTime * 10.0f, 0.0f);
3818 g.WantCaptureMouseNextFrame =
g.WantCaptureKeyboardNextFrame =
g.WantTextInputNextFrame = -1;
3828 IM_ASSERT(
g.WindowsFocusOrder.Size ==
g.Windows.Size);
3829 const float memory_compact_start_time = (
g.IO.ConfigWindowsMemoryCompactTimer >= 0.0f) ? (
float)
g.Time -
g.IO.ConfigWindowsMemoryCompactTimer : FLT_MAX;
3830 for (
int i = 0;
i !=
g.Windows.Size;
i++)
3844 if (
g.NavWindow && !
g.NavWindow->WasActive)
3849 g.CurrentWindowStack.resize(0);
3850 g.BeginPopupStack.resize(0);
3859 g.WithinFrameScopeWithImplicitWindow =
true;
3861 Begin(
"Debug##Default");
3862 IM_ASSERT(
g.CurrentWindow->IsFallbackWindow ==
true);
3864 #ifdef IMGUI_ENABLE_TEST_ENGINE
3865 ImGuiTestEngineHook_PostNewFrame(&
g);
3874 if (
g.DebugItemPickerActive)
3876 const ImGuiID hovered_id =
g.HoveredIdPreviousFrame;
3879 g.DebugItemPickerActive =
false;
3882 g.DebugItemPickerBreakId = hovered_id;
3883 g.DebugItemPickerActive =
false;
3907 g.SettingsHandlers.push_back(ini_handler);
3910 #ifdef IMGUI_HAS_TABLE
3916 ini_handler.
ReadOpenFn = TableSettingsHandler_ReadOpen;
3917 ini_handler.
ReadLineFn = TableSettingsHandler_ReadLine;
3918 ini_handler.
WriteAllFn = TableSettingsHandler_WriteAll;
3919 g.SettingsHandlers.push_back(ini_handler);
3921 #endif // #ifdef IMGUI_HAS_TABLE
3923 #ifdef IMGUI_HAS_DOCK
3924 #endif // #ifdef IMGUI_HAS_DOCK
3926 g.Initialized =
true;
3934 if (
g.IO.Fonts &&
g.FontAtlasOwnedByContext)
3946 if (
g.SettingsLoaded &&
g.IO.IniFilename !=
NULL)
3955 for (
int i = 0;
i <
g.Windows.Size;
i++)
3958 g.WindowsFocusOrder.clear();
3959 g.WindowsTempSortBuffer.clear();
3960 g.CurrentWindow =
NULL;
3961 g.CurrentWindowStack.clear();
3962 g.WindowsById.Clear();
3964 g.HoveredWindow =
g.HoveredRootWindow =
NULL;
3965 g.ActiveIdWindow =
g.ActiveIdPreviousFrameWindow =
NULL;
3966 g.MovingWindow =
NULL;
3967 g.ColorModifiers.clear();
3968 g.StyleModifiers.clear();
3969 g.FontStack.clear();
3970 g.OpenPopupStack.clear();
3971 g.BeginPopupStack.clear();
3972 g.DrawDataBuilder.ClearFreeMemory();
3973 g.BackgroundDrawList.ClearFreeMemory();
3974 g.ForegroundDrawList.ClearFreeMemory();
3977 g.CurrentTabBarStack.clear();
3978 g.ShrinkWidthBuffer.clear();
3980 g.PrivateClipboard.clear();
3981 g.MenusIdSubmittedThisFrame.clear();
3982 g.InputTextState.ClearFreeMemory();
3984 g.SettingsWindows.clear();
3985 g.SettingsHandlers.clear();
3989 #ifndef IMGUI_DISABLE_TTY_FUNCTIONS
3995 g.LogBuffer.clear();
3997 g.Initialized =
false;
4009 return (
a->BeginOrderWithinParent -
b->BeginOrderWithinParent);
4066 IM_ASSERT(draw_list->
_VtxCurrentIdx < (1 << 16) &&
"Too many vertices in ImDrawList using 16-bit indices. Read comment above");
4113 draw_data->
Valid =
true;
4120 for (
int n = 0;
n < draw_lists->
Size;
n++)
4131 window->
DrawList->
PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect);
4149 if (
g.FrameCountEnded ==
g.FrameCount)
4151 IM_ASSERT(
g.WithinFrameScope &&
"Forgot to call ImGui::NewFrame()?");
4156 if (
g.IO.ImeSetInputScreenPosFn && (
g.PlatformImeLastPos.x == FLT_MAX ||
ImLengthSqr(
g.PlatformImeLastPos -
g.PlatformImePos) > 0.0001f))
4158 g.IO.ImeSetInputScreenPosFn((
int)
g.PlatformImePos.x, (
int)
g.PlatformImePos.y);
4159 g.PlatformImeLastPos =
g.PlatformImePos;
4163 g.WithinFrameScopeWithImplicitWindow =
false;
4164 if (
g.CurrentWindow && !
g.CurrentWindow->WriteAccessed)
4165 g.CurrentWindow->Active =
false;
4169 if (
g.NavWindowingTarget !=
NULL)
4173 if (
g.DragDropActive)
4175 bool is_delivered =
g.DragDropPayload.Delivery;
4177 if (is_delivered || is_elapsed)
4182 if (
g.DragDropActive &&
g.DragDropSourceFrameCount <
g.FrameCount)
4184 g.DragDropWithinSource =
true;
4186 g.DragDropWithinSource =
false;
4190 g.WithinFrameScope =
false;
4191 g.FrameCountEnded =
g.FrameCount;
4198 g.WindowsTempSortBuffer.resize(0);
4199 g.WindowsTempSortBuffer.reserve(
g.Windows.Size);
4200 for (
int i = 0;
i !=
g.Windows.Size;
i++)
4209 IM_ASSERT(
g.Windows.Size ==
g.WindowsTempSortBuffer.Size);
4210 g.Windows.swap(
g.WindowsTempSortBuffer);
4211 g.IO.MetricsActiveWindows =
g.WindowsActiveCount;
4214 g.IO.Fonts->Locked =
false;
4217 g.IO.MouseWheel =
g.IO.MouseWheelH = 0.0f;
4218 g.IO.InputQueueCharacters.resize(0);
4219 memset(
g.IO.NavInputs, 0,
sizeof(
g.IO.NavInputs));
4227 if (
g.FrameCountEnded !=
g.FrameCount)
4229 g.FrameCountRendered =
g.FrameCount;
4230 g.IO.MetricsRenderWindows = 0;
4231 g.DrawDataBuilder.Clear();
4234 if (!
g.BackgroundDrawList.VtxBuffer.empty())
4240 windows_to_render_top_most[1] = (
g.NavWindowingTarget ?
g.NavWindowingList :
NULL);
4241 for (
int n = 0;
n !=
g.Windows.Size;
n++)
4250 g.DrawDataBuilder.FlattenIntoSingleLayer();
4253 if (
g.IO.MouseDrawCursor)
4257 if (!
g.ForegroundDrawList.VtxBuffer.empty())
4262 g.IO.MetricsRenderVertices =
g.DrawData.TotalVtxCount;
4263 g.IO.MetricsRenderIndices =
g.DrawData.TotalIdxCount;
4266 #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
4267 if (
g.DrawData.CmdListsCount > 0 &&
g.IO.RenderDrawListsFn !=
NULL)
4268 g.IO.RenderDrawListsFn(&
g.DrawData);
4278 const char* text_display_end;
4279 if (hide_text_after_double_hash)
4282 text_display_end = text_end;
4286 if (text == text_display_end)
4287 return ImVec2(0.0
f, font_size);
4306 hovered_window =
g.MovingWindow;
4308 ImVec2 padding_regular =
g.Style.TouchExtraPadding;
4310 for (
int i =
g.Windows.Size - 1;
i >= 0;
i--)
4321 bb.
Expand(padding_regular);
4323 bb.
Expand(padding_for_resize_from_edges);
4328 if (hovered_window ==
NULL)
4329 hovered_window = window;
4334 g.HoveredWindow = hovered_window;
4347 ImRect rect_clipped(r_min, r_max);
4349 rect_clipped.
ClipWith(
g.CurrentWindow->ClipRect);
4352 const ImRect rect_for_touch(rect_clipped.
Min -
g.Style.TouchExtraPadding, rect_clipped.
Max +
g.Style.TouchExtraPadding);
4353 if (!rect_for_touch.
Contains(
g.IO.MousePos))
4369 if (user_key_index < 0)
4373 return g.IO.KeysDown[user_key_index];
4386 if (repeat_rate <= 0.0
f)
4387 return (t0 < repeat_delay) && (t1 >= repeat_delay);
4388 const int count_t0 = (t0 < repeat_delay) ? -1 : (
int)((t0 - repeat_delay) / repeat_rate);
4389 const int count_t1 = (t1 < repeat_delay) ? -1 : (
int)((t1 - repeat_delay) / repeat_rate);
4390 const int count = count_t1 - count_t0;
4400 const float t =
g.IO.KeysDownDuration[key_index];
4407 if (user_key_index < 0)
4410 const float t =
g.IO.KeysDownDuration[user_key_index];
4413 if (repeat && t >
g.IO.KeyRepeatDelay)
4421 if (user_key_index < 0)
return false;
4423 return g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !
g.IO.KeysDown[user_key_index];
4430 return g.IO.MouseDown[button];
4437 const float t =
g.IO.MouseDownDuration[button];
4441 if (repeat && t >
g.IO.KeyRepeatDelay)
4455 return g.IO.MouseReleased[button];
4462 return g.IO.MouseDoubleClicked[button];
4470 if (lock_threshold < 0.0
f)
4471 lock_threshold =
g.IO.MouseDragThreshold;
4472 return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold;
4479 if (!
g.IO.MouseDown[button])
4494 if (
g.BeginPopupStack.Size > 0)
4496 return g.IO.MousePos;
4505 const float MOUSE_INVALID = -256000.0f;
4507 return p.x >= MOUSE_INVALID &&
p.y >= MOUSE_INVALID;
4514 if (
g.IO.MouseDown[
n])
4526 if (lock_threshold < 0.0
f)
4527 lock_threshold =
g.IO.MouseDragThreshold;
4528 if (
g.IO.MouseDown[button] ||
g.IO.MouseReleased[button])
4529 if (
g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold)
4531 return g.IO.MousePos -
g.IO.MouseClickedPos[button];
4540 g.IO.MouseClickedPos[button] =
g.IO.MousePos;
4598 return IsItemDeactivated() && (
g.ActiveIdPreviousFrameHasBeenEditedBefore || (
g.ActiveId == 0 &&
g.ActiveIdHasBeenEditedBefore));
4606 if (
g.NavId == 0 ||
g.NavDisableHighlight ||
g.NavId != window->
DC.
LastItemId)
4631 return g.
HoveredId != 0 ||
g.HoveredIdPreviousFrame != 0;
4643 return g.
NavId != 0 && !
g.NavDisableHighlight;
4662 if (
g.HoveredId ==
g.CurrentWindow->DC.LastItemId)
4664 if (
g.ActiveId ==
g.CurrentWindow->DC.LastItemId)
4665 g.ActiveIdAllowOverlap =
true;
4689 return ImRect(0.0
f, 0.0
f,
g.IO.DisplaySize.x,
g.IO.DisplaySize.y);
4717 const float backup_border_size =
g.Style.ChildBorderSize;
4719 g.Style.ChildBorderSize = 0.0f;
4721 g.Style.ChildBorderSize = backup_border_size;
4763 g.WithinEndChild =
true;
4795 g.WithinEndChild =
false;
4845 g.WindowsById.SetVoidPtr(window->
ID, window);
4857 window->
Pos =
ImVec2(settings->Pos.x, settings->Pos.y);
4858 window->
Collapsed = settings->Collapsed;
4859 if (settings->Size.x > 0 && settings->Size.y > 0)
4860 size =
ImVec2(settings->Size.x, settings->Size.y);
4872 if (window->
Size.
x <= 0.0f)
4874 if (window->
Size.
y <= 0.0f)
4879 g.WindowsFocusOrder.push_back(window);
4881 g.Windows.push_front(window);
4883 g.Windows.push_back(window);
4893 ImRect cr =
g.NextWindowData.SizeConstraintRect;
4896 if (
g.NextWindowData.SizeCallback)
4899 data.UserData =
g.NextWindowData.SizeCallbackUserData;
4902 data.DesiredSize = new_size;
4903 g.NextWindowData.SizeCallback(&
data);
4904 new_size =
data.DesiredSize;
4914 new_size =
ImMax(new_size,
g.Style.WindowMinSize);
4940 ImVec2 size_desired = size_contents + size_pad + size_decorations;
4944 return size_desired;
4952 if (is_popup || is_menu)
4961 if (will_have_scrollbar_x)
4963 if (will_have_scrollbar_y)
4965 return size_auto_fit;
4990 ImVec2 size_expected = pos_max - pos_min;
4993 if (corner_norm.
x == 0.0f)
4994 out_pos->
x -= (size_constrained.
x - size_expected.
x);
4995 if (corner_norm.
y == 0.0f)
4996 out_pos->
y -= (size_constrained.
y - size_expected.
y);
4997 *out_size = size_constrained;
5018 if (thickness == 0.0
f) rect.
Max -=
ImVec2(1,1);
5019 if (border_n == 0)
return ImRect(rect.
Min.
x + perp_padding, rect.
Min.
y - thickness, rect.
Max.
x - perp_padding, rect.
Min.
y + thickness);
5020 if (border_n == 1)
return ImRect(rect.
Max.
x - thickness, rect.
Min.
y + perp_padding, rect.
Max.
x + thickness, rect.
Max.
y - perp_padding);
5021 if (border_n == 2)
return ImRect(rect.
Min.
x + perp_padding, rect.
Max.
y - thickness, rect.
Max.
x - perp_padding, rect.
Max.
y + thickness);
5022 if (border_n == 3)
return ImRect(rect.
Min.
x - thickness, rect.
Min.
y + perp_padding, rect.
Min.
x + thickness, rect.
Max.
y - perp_padding);
5050 bool ret_auto_fit =
false;
5051 const int resize_border_count =
g.IO.ConfigWindowsResizeFromEdges ? 4 : 0;
5053 const float grip_hover_inner_size =
IM_FLOOR(grip_draw_size * 0.75
f);
5056 ImVec2 pos_target(FLT_MAX, FLT_MAX);
5057 ImVec2 size_target(FLT_MAX, FLT_MAX);
5065 for (
int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++)
5071 ImRect resize_rect(corner - grip.
InnerDir * grip_hover_outer_size, corner + grip.
InnerDir * grip_hover_inner_size);
5077 if (hovered || held)
5080 if (held &&
g.IO.MouseDoubleClicked[0] && resize_grip_n == 0)
5084 ret_auto_fit =
true;
5094 if (resize_grip_n == 0 || held || hovered)
5097 for (
int border_n = 0; border_n < resize_border_count; border_n++)
5107 *border_held = border_n;
5127 if (
g.NavWindowingTarget &&
g.NavWindowingTarget->RootWindow == window)
5134 if (nav_resize_delta.
x != 0.0f || nav_resize_delta.
y != 0.0f)
5136 const float NAV_RESIZE_SPEED = 600.0f;
5137 nav_resize_delta *=
ImFloor(NAV_RESIZE_SPEED *
g.IO.DeltaTime *
ImMin(
g.IO.DisplayFramebufferScale.x,
g.IO.DisplayFramebufferScale.y));
5138 g.NavWindowingToggleLayer =
false;
5139 g.NavDisableMouseHover =
true;
5147 if (size_target.
x != FLT_MAX)
5152 if (pos_target.
x != FLT_MAX)
5159 return ret_auto_fit;
5166 window->
Pos =
ImMin(rect.
Max - padding,
ImMax(window->
Pos + size_for_clamping, rect.
Min + padding) - size_for_clamping);
5178 if (border_held != -1)
5180 struct ImGuiResizeBorderDef
5183 ImVec2 CornerPosN1, CornerPosN2;
5186 static const ImGuiResizeBorderDef resize_border_def[4] =
5193 const ImGuiResizeBorderDef& def = resize_border_def[border_held];
5227 RenderFrame(title_bar_rect.
Min, title_bar_rect.
Max, title_bar_col,
true, window_rounding);
5228 g.Style.FrameBorderSize = backup_border_size;
5236 bool override_alpha =
false;
5240 alpha =
g.NextWindowData.BgAlphaVal;
5241 override_alpha =
true;
5274 for (
int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++)
5297 const bool has_close_button = (p_open !=
NULL);
5310 float button_sz =
g.FontSize;
5312 ImVec2 collapse_button_pos;
5313 if (has_close_button)
5330 if (has_collapse_button)
5335 if (has_close_button)
5345 const char* UNSAVED_DOCUMENT_MARKER =
"*";
5352 pad_l +=
g.Style.ItemInnerSpacing.x;
5354 pad_r +=
g.Style.ItemInnerSpacing.x;
5358 float pad_extend =
ImMin(
ImMax(pad_l, pad_r), title_bar_rect.
GetWidth() - pad_l - pad_r - text_size.
x);
5359 pad_l =
ImMax(pad_l, pad_extend * centerness);
5360 pad_r =
ImMax(pad_r, pad_extend * centerness);
5363 ImRect layout_r(title_bar_rect.
Min.
x + pad_l, title_bar_rect.
Min.
y, title_bar_rect.
Max.
x - pad_r, title_bar_rect.
Max.
y);
5407 const bool window_just_created = (window ==
NULL);
5408 if (window_just_created)
5421 const int current_frame =
g.FrameCount;
5422 const bool first_begin_of_the_frame = (window->
LastFrameActive != current_frame);
5423 window->
IsFallbackWindow = (
g.CurrentWindowStack.Size == 0 &&
g.WithinFrameScopeWithImplicitWindow);
5426 bool window_just_activated_by_user = (window->
LastFrameActive < current_frame - 1);
5431 window_just_activated_by_user |= (window->
PopupId != popup_ref.
PopupId);
5432 window_just_activated_by_user |= (window != popup_ref.
Window);
5434 window->
Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize);
5439 if (first_begin_of_the_frame)
5453 ImGuiWindow* parent_window_in_stack =
g.CurrentWindowStack.empty() ?
NULL :
g.CurrentWindowStack.back();
5463 g.CurrentWindowStack.push_back(window);
5464 g.CurrentWindow =
NULL;
5469 popup_ref.
Window = window;
5470 g.BeginPopupStack.push_back(popup_ref);
5478 if (first_begin_of_the_frame)
5482 bool window_pos_set_by_api =
false;
5483 bool window_size_x_set_by_api =
false, window_size_y_set_by_api =
false;
5487 if (window_pos_set_by_api &&
ImLengthSqr(
g.NextWindowData.PosPivotVal) > 0.00001f)
5497 SetWindowPos(window,
g.NextWindowData.PosVal,
g.NextWindowData.PosCond);
5502 window_size_x_set_by_api = (window->
SetWindowSizeAllowFlags &
g.NextWindowData.SizeCond) != 0 && (
g.NextWindowData.SizeVal.x > 0.0f);
5503 window_size_y_set_by_api = (window->
SetWindowSizeAllowFlags &
g.NextWindowData.SizeCond) != 0 && (
g.NextWindowData.SizeVal.y > 0.0f);
5504 SetWindowSize(window,
g.NextWindowData.SizeVal,
g.NextWindowData.SizeCond);
5508 else if (first_begin_of_the_frame)
5518 if (first_begin_of_the_frame)
5533 bool window_title_visible_elsewhere =
false;
5535 window_title_visible_elsewhere =
true;
5536 if (window_title_visible_elsewhere && !window_just_created && strcmp(
name, window->
Name) != 0)
5553 if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api))
5563 if (!window_size_x_set_by_api)
5565 if (!window_size_y_set_by_api)
5591 if (
g.HoveredWindow == window &&
g.HoveredId == 0 &&
g.HoveredIdPreviousFrame == 0 &&
IsMouseHoveringRect(title_bar_rect.
Min, title_bar_rect.
Max) &&
g.IO.MouseDoubleClicked[0])
5610 bool use_current_size_for_scrollbar_x = window_just_created;
5611 bool use_current_size_for_scrollbar_y = window_just_created;
5615 if (!window_size_x_set_by_api)
5618 use_current_size_for_scrollbar_x =
true;
5620 if (!window_size_y_set_by_api)
5623 use_current_size_for_scrollbar_y =
true;
5633 use_current_size_for_scrollbar_x =
true;
5638 use_current_size_for_scrollbar_y =
true;
5654 if (window_just_activated_by_user)
5658 window->
Pos =
g.BeginPopupStack.back().OpenPopupPos;
5672 if (window_pos_with_pivot)
5698 bool want_focus =
false;
5708 int border_held = -1;
5709 ImU32 resize_grip_col[4] = {};
5710 const int resize_grip_count =
g.IO.ConfigWindowsResizeFromEdges ? 2 : 1;
5714 use_current_size_for_scrollbar_x = use_current_size_for_scrollbar_y =
true;
5727 float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame.
x : avail_size_from_last_frame.
x;
5728 float size_y_for_scrollbars = use_current_size_for_scrollbar_y ? avail_size_from_current_frame.
y : avail_size_from_last_frame.
y;
5804 const bool dim_bg_for_window_list =
g.NavWindowingTargetAnim && (window ==
g.NavWindowingTargetAnim->
RootWindow);
5805 if (dim_bg_for_modal || dim_bg_for_window_list)
5812 if (dim_bg_for_window_list && window ==
g.NavWindowingTargetAnim)
5826 bool render_decorations_in_parent =
false;
5829 render_decorations_in_parent =
true;
5830 if (render_decorations_in_parent)
5834 const ImGuiWindow* window_to_highlight =
g.NavWindowingTarget ?
g.NavWindowingTarget :
g.NavWindow;
5836 RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, resize_grip_count, resize_grip_col, resize_grip_draw_size);
5838 if (render_decorations_in_parent)
5843 if (
g.NavWindowingTargetAnim == window)
5850 bb.
Expand(-
g.FontSize - 1.0f);
5954 #ifdef IMGUI_ENABLE_TEST_ENGINE
5968 if (first_begin_of_the_frame)
5972 g.NextWindowData.ClearFlags();
5991 if (style.
Alpha <= 0.0f)
5998 bool skip_items =
false;
6013 if (
g.CurrentWindowStack.Size <= 1 &&
g.WithinFrameScopeWithImplicitWindow)
6034 g.CurrentWindowStack.pop_back();
6036 g.BeginPopupStack.pop_back();
6044 if (
g.WindowsFocusOrder.back() == window)
6046 for (
int i =
g.WindowsFocusOrder.Size - 2;
i >= 0;
i--)
6047 if (
g.WindowsFocusOrder[
i] == window)
6049 memmove(&
g.WindowsFocusOrder[
i], &
g.WindowsFocusOrder[
i + 1], (
size_t)(
g.WindowsFocusOrder.Size -
i - 1) *
sizeof(
ImGuiWindow*));
6050 g.WindowsFocusOrder[
g.WindowsFocusOrder.Size - 1] = window;
6059 if (current_front_window == window || current_front_window->
RootWindow == window)
6061 for (
int i =
g.Windows.Size - 2;
i >= 0;
i--)
6062 if (
g.Windows[
i] == window)
6064 memmove(&
g.Windows[
i], &
g.Windows[
i + 1], (
size_t)(
g.Windows.Size -
i - 1) *
sizeof(
ImGuiWindow*));
6065 g.Windows[
g.Windows.Size - 1] = window;
6073 if (
g.Windows[0] == window)
6075 for (
int i = 0;
i <
g.Windows.Size;
i++)
6076 if (
g.Windows[
i] == window)
6078 memmove(&
g.Windows[1], &
g.Windows[0], (
size_t)
i *
sizeof(
ImGuiWindow*));
6079 g.Windows[0] = window;
6089 if (
g.NavWindow != window)
6092 if (window &&
g.NavDisableMouseHover)
6093 g.NavMousePosDirty =
true;
6094 g.NavInitRequest =
false;
6096 g.NavFocusScopeId = 0;
6097 g.NavIdIsAlive =
false;
6116 if (
g.ActiveId != 0 &&
g.ActiveIdWindow &&
g.ActiveIdWindow->RootWindow != focus_front_window)
6130 if (under_this_window !=
NULL)
6133 if (under_this_window_idx != -1)
6134 start_idx = under_this_window_idx - 1;
6136 for (
int i = start_idx;
i >= 0;
i--)
6157 g.FontBaseSize =
ImMax(1.0
f,
g.IO.FontGlobalScale *
g.Font->FontSize *
g.Font->Scale);
6158 g.FontSize =
g.CurrentWindow ?
g.CurrentWindow->CalcFontSize() : 0.0f;
6162 g.DrawListSharedData.Font =
g.Font;
6163 g.DrawListSharedData.FontSize =
g.FontSize;
6172 g.FontStack.push_back(font);
6180 g.FontStack.pop_back();
6240 while (window !=
NULL)
6242 if (window == potential_parent)
6256 if (
g.HoveredWindow ==
NULL)
6264 if (
g.HoveredRootWindow !=
g.CurrentWindow->RootWindow)
6268 if (
g.HoveredWindow !=
g.CurrentWindow->RootWindow)
6276 if (
g.HoveredWindow !=
g.CurrentWindow)
6285 if (
g.ActiveId != 0 && !
g.ActiveIdAllowOverlap &&
g.ActiveId !=
g.HoveredWindow->MoveId)
6301 return g.NavWindow &&
g.NavWindow->RootWindow ==
g.CurrentWindow->RootWindow;
6303 return g.NavWindow ==
g.CurrentWindow->RootWindow;
6307 return g.NavWindow ==
g.CurrentWindow;
6322 return window->
Size.
x;
6328 return window->
Size.
y;
6372 return window->
Size;
6475 g.NextWindowData.PosVal = pos;
6476 g.NextWindowData.PosPivotVal = pivot;
6485 g.NextWindowData.SizeVal =
size;
6493 g.NextWindowData.SizeConstraintRect =
ImRect(size_min, size_max);
6494 g.NextWindowData.SizeCallback = custom_callback;
6495 g.NextWindowData.SizeCallbackUserData = custom_callback_user_data;
6504 g.NextWindowData.ContentSizeVal =
size;
6512 g.NextWindowData.CollapsedVal = collapsed;
6526 g.NextWindowData.BgAlphaVal =
alpha;
6555 g.FontSize =
g.DrawListSharedData.FontSize = window->
CalcFontSize();
6585 g.FocusRequestNextWindow = window;
6587 g.FocusRequestNextCounterTabStop = INT_MAX;
6598 g.NavInitRequest =
false;
6600 g.NavInitResultRectRel =
ImRect(
g.NavWindow->DC.LastItemRect.Min -
g.NavWindow->Pos,
g.NavWindow->DC.LastItemRect.Max -
g.NavWindow->Pos);
6659 return window->
GetID(str_id);
6665 return window->
GetID(str_id_begin, str_id_end);
6671 return window->
GetID(ptr_id);
6716 IM_ASSERT((
g.IO.DeltaTime > 0.0f ||
g.FrameCount == 0) &&
"Need a positive DeltaTime!");
6717 IM_ASSERT((
g.FrameCount == 0 ||
g.FrameCountEnded ==
g.FrameCount) &&
"Forgot to call Render() or EndFrame() at the end of the previous frame?");
6718 IM_ASSERT(
g.IO.DisplaySize.x >= 0.0f &&
g.IO.DisplaySize.y >= 0.0f &&
"Invalid DisplaySize value!");
6719 IM_ASSERT(
g.IO.Fonts->Fonts.Size > 0 &&
"Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
6720 IM_ASSERT(
g.IO.Fonts->Fonts[0]->IsLoaded() &&
"Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
6721 IM_ASSERT(
g.Style.CurveTessellationTol > 0.0f &&
"Invalid style setting!");
6722 IM_ASSERT(
g.Style.CircleSegmentMaxError > 0.0f &&
"Invalid style setting!");
6723 IM_ASSERT(
g.Style.Alpha >= 0.0f &&
g.Style.Alpha <= 1.0f &&
"Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
6724 IM_ASSERT(
g.Style.WindowMinSize.x >= 1.0f &&
g.Style.WindowMinSize.y >= 1.0f &&
"Invalid style setting.");
6727 IM_ASSERT(
g.IO.KeyMap[
n] >= -1 &&
g.IO.KeyMap[
n] <
IM_ARRAYSIZE(
g.IO.KeysDown) &&
"io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
6735 g.IO.ConfigWindowsResizeFromEdges =
false;
6744 IM_ASSERT(
g.IO.KeyMods == expected_key_mod_flags &&
"Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods");
6749 if (
g.CurrentWindowStack.Size != 1)
6751 if (
g.CurrentWindowStack.Size > 1)
6753 IM_ASSERT_USER_ERROR(
g.CurrentWindowStack.Size == 1,
"Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
6754 while (
g.CurrentWindowStack.Size > 1)
6759 IM_ASSERT_USER_ERROR(
g.CurrentWindowStack.Size == 1,
"Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?");
6774 {
int n = window->
IDStack.
Size;
if (write) *
p = (short)
n;
else IM_ASSERT(*
p ==
n &&
"PushID/PopID or TreeNode/TreePop Mismatch!");
p++; }
6779 {
int n =
g.BeginPopupStack.Size;
if (write) *
p = (short)
n;
else IM_ASSERT(*
p ==
n &&
"BeginMenu/EndMenu or BeginPopup/EndPopup Mismatch!");
p++; }
6780 {
int n =
g.ColorModifiers.Size;
if (write) *
p = (short)
n;
else IM_ASSERT(*
p >=
n &&
"PushStyleColor/PopStyleColor Mismatch!");
p++; }
6781 {
int n =
g.StyleModifiers.Size;
if (write) *
p = (short)
n;
else IM_ASSERT(*
p >=
n &&
"PushStyleVar/PopStyleVar Mismatch!");
p++; }
6782 {
int n =
g.FontStack.Size;
if (write) *
p = (short)
n;
else IM_ASSERT(*
p >=
n &&
"PushFont/PopFont Mismatch!");
p++; }
6881 if (
g.NavId ==
id ||
g.NavAnyRequest)
6887 #ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
6888 if (
id ==
g.DebugItemPickerBreakId)
6891 g.DebugItemPickerBreakId = 0;
6901 #ifdef IMGUI_ENABLE_TEST_ENGINE
6907 const bool is_clipped =
IsClippedEx(bb,
id,
false);
6930 if (offset_from_start_x != 0.0
f)
6932 if (spacing_w < 0.0
f) spacing_w = 0.0f;
6938 if (spacing_w < 0.0
f) spacing_w =
g.Style.ItemSpacing.x;
7010 window->
DC.
Indent.
x += (indent_w != 0.0f) ? indent_w :
g.Style.IndentSpacing;
7018 window->
DC.
Indent.
x -= (indent_w != 0.0f) ? indent_w :
g.Style.IndentSpacing;
7027 g.NextItemData.Width = item_width;
7047 for (
int i = 0;
i < components-1;
i++)
7068 w =
g.NextItemData.Width;
7089 if (
size.x < 0.0f ||
size.y < 0.0f)
7094 else if (
size.x < 0.0f)
7099 else if (
size.y < 0.0f)
7120 return g.
FontSize +
g.Style.FramePadding.y * 2.0f;
7126 return g.
FontSize +
g.Style.FramePadding.y * 2.0f +
g.Style.ItemSpacing.y;
7201 g.LogLinePosY = -FLT_MAX;
7221 g.LogLinePosY = -FLT_MAX;
7237 const bool group_contains_curr_active_id = (group_data.
BackupActiveIdIsAlive !=
g.ActiveId) && (
g.ActiveIdIsAlive ==
g.ActiveId) &&
g.ActiveId;
7239 if (group_contains_curr_active_id)
7241 else if (group_contains_prev_active_id)
7246 if (group_contains_curr_active_id &&
g.ActiveIdHasBeenEditedThisFrame)
7251 if (group_contains_prev_active_id &&
g.ActiveId !=
g.ActiveIdPreviousFrame)
7271 if (snap_on_edges && cr_x <= 0.0
f && target_x <= window->WindowPadding.x)
7283 if (snap_on_edges && cr_y <= 0.0
f && target_y <= window->WindowPadding.y)
7307 if (!window_rect.
Contains(item_rect))
7313 if (item_rect.
Min.
y < window_rect.
Min.
y)
7315 else if (item_rect.
Max.
y >= window_rect.
Max.
y)
7319 delta_scroll = next_scroll - window->
Scroll;
7326 return delta_scroll;
7383 IM_ASSERT(center_x_ratio >= 0.0
f && center_x_ratio <= 1.0
f);
7391 IM_ASSERT(center_y_ratio >= 0.0
f && center_y_ratio <= 1.0
f);
7393 local_y -= decoration_up_height;
7417 target_x += (last_item_width * center_x_ratio) + (
g.Style.ItemSpacing.x * (center_x_ratio - 0.5f) * 2.0f);
7427 target_y += (window->
DC.
PrevLineSize.
y * center_y_ratio) + (
g.Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f);
7444 if (
g.DragDropWithinSource ||
g.DragDropWithinTarget)
7450 ImVec2 tooltip_pos =
g.IO.MousePos +
ImVec2(16 *
g.Style.MouseCursorScale, 8 *
g.Style.MouseCursorScale);
7457 char window_name[16];
7464 window->Hidden =
true;
7465 window->HiddenFramesCanSkipItems = 1;
7506 return g.
OpenPopupStack.
Size >
g.BeginPopupStack.Size &&
g.OpenPopupStack[
g.BeginPopupStack.Size].PopupId ==
g.CurrentWindow->GetID(str_id);
7512 for (
int n =
g.OpenPopupStack.Size-1;
n >= 0;
n--)
7533 int current_stack_size =
g.BeginPopupStack.
Size;
7544 if (
g.OpenPopupStack.Size < current_stack_size + 1)
7546 g.OpenPopupStack.push_back(popup_ref);
7553 if (
g.OpenPopupStack[current_stack_size].PopupId ==
id &&
g.OpenPopupStack[current_stack_size].OpenFrameCount ==
g.FrameCount - 1)
7555 g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.
OpenFrameCount;
7560 g.OpenPopupStack.resize(current_stack_size + 1);
7561 g.OpenPopupStack[current_stack_size] = popup_ref;
7574 if (
g.OpenPopupStack.empty())
7579 int popup_count_to_keep = 0;
7583 for (; popup_count_to_keep <
g.OpenPopupStack.Size; popup_count_to_keep++)
7593 bool popup_or_descendent_is_ref_window =
false;
7594 for (
int m = popup_count_to_keep;
m <
g.OpenPopupStack.Size && !popup_or_descendent_is_ref_window;
m++)
7596 if (popup_window->RootWindow == ref_window->
RootWindow)
7597 popup_or_descendent_is_ref_window =
true;
7598 if (!popup_or_descendent_is_ref_window)
7602 if (popup_count_to_keep <
g.OpenPopupStack.Size)
7612 IM_ASSERT(remaining >= 0 && remaining <
g.OpenPopupStack.Size);
7613 ImGuiWindow* focus_window =
g.OpenPopupStack[remaining].SourceWindow;
7614 ImGuiWindow* popup_window =
g.OpenPopupStack[remaining].Window;
7615 g.OpenPopupStack.resize(remaining);
7617 if (restore_focus_to_window_under_popup)
7619 if (focus_window && !focus_window->
WasActive && popup_window)
7626 if (
g.NavLayer == 0 && focus_window)
7638 if (popup_idx < 0 || popup_idx >=
g.OpenPopupStack.Size ||
g.BeginPopupStack[popup_idx].PopupId !=
g.OpenPopupStack[popup_idx].PopupId)
7642 while (popup_idx > 0)
7644 ImGuiWindow* popup_window =
g.OpenPopupStack[popup_idx].Window;
7645 ImGuiWindow* parent_popup_window =
g.OpenPopupStack[popup_idx - 1].Window;
7646 bool close_parent =
false;
7649 close_parent =
true;
7661 window->DC.NavHideHighlightOneFrame =
true;
7690 if (
g.OpenPopupStack.Size <=
g.BeginPopupStack.Size)
7708 g.NextWindowData.ClearFlags();
7719 if (!is_open || (p_open && !*p_open))
7742 g.WithinEndChild =
true;
7744 g.WithinEndChild =
false;
7778 str_id =
"window_context";
7789 str_id =
"void_context";
7810 const ImGuiDir dir = (
n == -1) ? *last_dir : dir_prefered_order[
n];
7811 if (
n != -1 && dir == *last_dir)
7829 const ImGuiDir dir = (
n == -1) ? *last_dir : dir_prefered_order[
n];
7830 if (
n != -1 && dir == *last_dir)
7834 if (avail_w <
size.x || avail_h <
size.y)
7870 ImGuiWindow* parent_window =
g.CurrentWindowStack[
g.CurrentWindowStack.Size - 2];
7871 float horizontal_overlap =
g.Style.ItemInnerSpacing.x;
7876 r_avoid =
ImRect(parent_window->
Pos.
x + horizontal_overlap, -FLT_MAX, parent_window->
Pos.
x + parent_window->
Size.
x - horizontal_overlap - parent_window->
ScrollbarSizes.
x, FLT_MAX);
7887 float sc =
g.Style.MouseCursorScale;
7891 r_avoid =
ImRect(ref_pos.
x - 16, ref_pos.
y - 8, ref_pos.
x + 16, ref_pos.
y + 8);
7893 r_avoid =
ImRect(ref_pos.
x - 16, ref_pos.
y - 8, ref_pos.
x + 24 *
sc, ref_pos.
y + 24 *
sc);
7896 pos = ref_pos +
ImVec2(2, 2);
7913 IM_ASSERT(nav_layer == 0 || nav_layer == 1);
7915 g.NavFocusScopeId = focus_scope_id;
7916 g.NavWindow->NavLastIds[nav_layer] =
id;
7922 SetNavID(
id, nav_layer, focus_scope_id);
7923 g.NavWindow->NavRectRel[nav_layer] = rect_rel;
7924 g.NavMousePosDirty =
true;
7925 g.NavDisableHighlight =
false;
7926 g.NavDisableMouseHover =
true;
7937 if (
g.NavWindow != window)
7938 g.NavInitRequest =
false;
7939 g.NavWindow = window;
7941 g.NavLayer = nav_layer;
7948 g.NavDisableMouseHover =
true;
7950 g.NavDisableHighlight =
true;
7991 const ImRect& curr =
g.NavScoringRectScreen;
7992 g.NavScoringCount++;
8010 float dby =
NavScoreItemDistInterval(
ImLerp(cand.
Min.
y, cand.
Max.
y, 0.2f),
ImLerp(cand.
Min.
y, cand.
Max.
y, 0.8f),
ImLerp(curr.
Min.
y, curr.
Max.
y, 0.2f),
ImLerp(curr.
Min.
y, curr.
Max.
y, 0.8f));
8011 if (dby != 0.0
f && dbx != 0.0
f)
8012 dbx = (dbx/1000.0f) + ((dbx > 0.0
f) ? +1.0f : -1.0f);
8022 float dax = 0.0f, day = 0.0f, dist_axial = 0.0f;
8023 if (dbx != 0.0
f || dby != 0.0
f)
8028 dist_axial = dist_box;
8031 else if (dcx != 0.0
f || dcy != 0.0
f)
8036 dist_axial = dist_center;
8045 #if IMGUI_DEBUG_NAV_SCORING
8049 ImFormatString(
buf,
IM_ARRAYSIZE(
buf),
"dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial,
"WENS"[
g.NavMoveDir],
"WENS"[quadrant]);
8056 else if (
g.IO.KeyCtrl)
8059 if (quadrant ==
g.NavMoveDir)
8070 bool new_best =
false;
8071 if (quadrant ==
g.NavMoveDir)
8074 if (dist_box < result->DistBox)
8080 if (dist_box == result->
DistBox)
8083 if (dist_center < result->DistCenter)
8104 if (result->
DistBox == FLT_MAX && dist_axial < result->DistAxial)
8131 g.NavInitResultId =
id;
8132 g.NavInitResultRectRel = nav_bb_rel;
8136 g.NavInitRequest =
false;
8145 ImGuiNavMoveResult* result = (window ==
g.NavWindow) ? &
g.NavMoveResultLocal : &
g.NavMoveResultOther;
8148 if (!
g.NavMoveRequest)
8149 g.NavMoveDir =
g.NavMoveDirLast;
8150 bool new_best =
NavScoreItem(result, nav_bb) &&
g.NavMoveRequest;
8152 bool new_best =
g.NavMoveRequest &&
NavScoreItem(result, nav_bb);
8163 const float VISIBLE_RATIO = 0.70f;
8168 result = &
g.NavMoveResultLocalVisibleSet;
8179 g.NavWindow = window;
8182 g.NavIdIsAlive =
true;
8191 return g.
NavMoveRequest &&
g.NavMoveResultLocal.ID == 0 &&
g.NavMoveResultOther.ID == 0;
8206 g.NavMoveDir = move_dir;
8207 g.NavMoveClipDir = clip_dir;
8209 g.NavMoveRequestFlags = move_flags;
8210 g.NavWindow->NavRectRel[
g.NavLayer] = bb_rel;
8255 if (parent_window && parent_window != nav_window)
8283 if (
g.NavAnyRequest)
8292 bool init_for_nav =
false;
8295 init_for_nav =
true;
8300 g.NavInitRequest =
true;
8301 g.NavInitRequestFromMove =
false;
8302 g.NavInitResultId = 0;
8303 g.NavInitResultRectRel =
ImRect();
8309 g.NavFocusScopeId = 0;
8316 if (
g.NavDisableHighlight || !
g.NavDisableMouseHover || !
g.NavWindow)
8321 return g.LastValidMousePos;
8326 const ImRect& rect_rel =
g.NavWindow->NavRectRel[
g.NavLayer];
8339 const float t =
g.IO.NavInputsDownDuration[
n];
8341 return (
g.IO.NavInputsDownDurationPrev[
n] >= 0.0f ? 1.0f : 0.0f);
8345 return (t == 0.0
f) ? 1.0f : 0.0f;
8365 delta *= slow_factor;
8367 delta *= fast_factor;
8376 if (
g.NavScoringCount > 0)
IMGUI_DEBUG_LOG(
"NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n",
g.FrameCount,
g.NavScoringCount,
g.NavWindow ?
g.NavWindow->Name :
"NULL",
g.NavLayer,
g.NavInitRequest ||
g.NavInitResultId != 0,
g.NavMoveRequest);
8383 if (nav_gamepad_active)
8388 if (nav_keyboard_active)
8390 #define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(g.IO.KeyMap[_KEY])) { g.IO.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_NavKeyboard; } } while (0)
8402 if (
g.IO.KeyAlt && !
g.IO.KeyCtrl)
8406 memcpy(
g.IO.NavInputsDownDurationPrev,
g.IO.NavInputsDownDuration,
sizeof(
g.IO.NavInputsDownDuration));
8408 g.IO.NavInputsDownDuration[
i] = (
g.IO.NavInputs[
i] > 0.0f) ? (
g.IO.NavInputsDownDuration[
i] < 0.0f ? 0.0f :
g.IO.NavInputsDownDuration[
i] +
g.IO.DeltaTime) : -1.0
f;
8412 if (
g.NavInitResultId != 0 && (!
g.NavDisableHighlight ||
g.NavInitRequestFromMove) &&
g.NavWindow)
8416 if (
g.NavInitRequestFromMove)
8420 g.NavWindow->NavRectRel[
g.NavLayer] =
g.NavInitResultRectRel;
8422 g.NavInitRequest =
false;
8423 g.NavInitRequestFromMove =
false;
8424 g.NavInitResultId = 0;
8425 g.NavJustMovedToId = 0;
8428 if (
g.NavMoveRequest)
8435 if (
g.NavMoveResultLocal.ID == 0 &&
g.NavMoveResultOther.ID == 0)
8436 g.NavDisableHighlight =
false;
8441 if (
g.NavMousePosDirty &&
g.NavIdIsAlive)
8446 if (!
g.NavDisableHighlight &&
g.NavDisableMouseHover &&
g.NavWindow)
8449 g.IO.WantSetMousePos =
true;
8452 g.NavMousePosDirty =
false;
8454 g.NavIdIsAlive =
false;
8455 g.NavJustTabbedId = 0;
8461 if (
g.NavWindow &&
g.NavWindow->NavLastChildNavWindow !=
NULL &&
g.NavLayer == 0)
8462 g.NavWindow->NavLastChildNavWindow =
NULL;
8469 g.IO.NavVisible = (
g.IO.NavActive &&
g.NavId != 0 && !
g.NavDisableHighlight) || (
g.NavWindowingTarget !=
NULL);
8474 if (
g.ActiveId != 0)
8488 g.NavIdIsAlive =
false;
8489 if (
g.NavDisableMouseHover)
8490 g.NavMousePosDirty =
true;
8492 else if (
g.OpenPopupStack.Size > 0)
8498 else if (
g.NavLayer != 0)
8507 g.NavWindow->NavLastIds[0] = 0;
8508 g.NavId =
g.NavFocusScopeId = 0;
8513 g.NavActivateId =
g.NavActivateDownId =
g.NavActivatePressedId =
g.NavInputId = 0;
8518 if (
g.ActiveId == 0 && activate_pressed)
8519 g.NavActivateId =
g.NavId;
8520 if ((
g.ActiveId == 0 ||
g.ActiveId ==
g.NavId) && activate_down)
8521 g.NavActivateDownId =
g.NavId;
8522 if ((
g.ActiveId == 0 ||
g.ActiveId ==
g.NavId) && activate_pressed)
8523 g.NavActivatePressedId =
g.NavId;
8525 g.NavInputId =
g.NavId;
8528 g.NavDisableHighlight =
true;
8529 if (
g.NavActivateId != 0)
8530 IM_ASSERT(
g.NavActivateDownId ==
g.NavActivateId);
8531 g.NavMoveRequest =
false;
8534 if (
g.NavNextActivateId != 0)
8535 g.NavActivateId =
g.NavActivateDownId =
g.NavActivatePressedId =
g.NavInputId =
g.NavNextActivateId;
8536 g.NavNextActivateId = 0;
8551 g.NavMoveClipDir =
g.NavMoveDir;
8564 float nav_scoring_rect_offset_y = 0.0f;
8565 if (nav_keyboard_active)
8571 g.NavMoveRequest =
true;
8572 g.NavMoveDirLast =
g.NavMoveDir;
8574 if (
g.NavMoveRequest &&
g.NavId == 0)
8577 g.NavInitRequest =
g.NavInitRequestFromMove =
true;
8579 g.NavInitResultId = 0;
8580 g.NavDisableHighlight =
false;
8604 g.NavMoveFromClampedRefRect =
true;
8606 if (scroll_dir.
y != 0.0f)
8609 g.NavMoveFromClampedRefRect =
true;
8614 g.NavMoveResultLocal.Clear();
8615 g.NavMoveResultLocalVisibleSet.Clear();
8616 g.NavMoveResultOther.Clear();
8619 if (
g.NavMoveRequest &&
g.NavMoveFromClampedRefRect &&
g.NavLayer == 0)
8628 g.NavId =
g.NavFocusScopeId = 0;
8630 g.NavMoveFromClampedRefRect =
false;
8634 ImRect nav_rect_rel = (
g.NavWindow && !
g.NavWindow->NavRectRel[
g.NavLayer].IsInverted()) ?
g.NavWindow->NavRectRel[
g.NavLayer] :
ImRect(0,0,0,0);
8636 g.NavScoringRectScreen.TranslateY(nav_scoring_rect_offset_y);
8637 g.NavScoringRectScreen.Min.x =
ImMin(
g.NavScoringRectScreen.Min.x + 1.0f,
g.NavScoringRectScreen.Max.x);
8638 g.NavScoringRectScreen.Max.x =
g.NavScoringRectScreen.Min.x;
8639 IM_ASSERT(!
g.NavScoringRectScreen.IsInverted());
8641 g.NavScoringCount = 0;
8642 #if IMGUI_DEBUG_NAV_RECTS
8647 if (1) {
ImU32 col = (!
g.NavWindow->Hidden) ?
IM_COL32(255,0,255,255) :
IM_COL32(255,0,0,255);
ImVec2 p =
NavCalcPreferredRefPos();
char buf[32];
ImFormatString(
buf, 32,
"%d",
g.NavLayer); draw_list->
AddCircleFilled(
p, 3.0
f, col); draw_list->
AddText(
NULL, 13.0
f,
p +
ImVec2(8,-4), col,
buf); }
8656 if (
g.NavMoveResultLocal.ID == 0 &&
g.NavMoveResultOther.ID == 0)
8662 g.NavDisableMouseHover =
true;
8668 ImGuiNavMoveResult* result = (
g.NavMoveResultLocal.ID != 0) ? &
g.NavMoveResultLocal : &
g.NavMoveResultOther;
8672 if (
g.NavMoveResultLocalVisibleSet.ID != 0 &&
g.NavMoveResultLocalVisibleSet.ID !=
g.NavId)
8673 result = &
g.NavMoveResultLocalVisibleSet;
8676 if (result != &
g.NavMoveResultOther &&
g.NavMoveResultOther.
ID != 0 &&
g.NavMoveResultOther.Window->ParentWindow ==
g.NavWindow)
8677 if ((
g.NavMoveResultOther.DistBox < result->
DistBox) || (
g.NavMoveResultOther.DistBox == result->
DistBox &&
g.NavMoveResultOther.DistCenter < result->
DistCenter))
8678 result = &
g.NavMoveResultOther;
8682 if (
g.NavLayer == 0)
8704 if (
g.NavId != result->
ID)
8707 g.NavJustMovedToId = result->
ID;
8712 g.NavMoveFromClampedRefRect =
false;
8729 if (page_up_held != page_down_held || home_pressed != end_pressed)
8738 else if (home_pressed)
8740 else if (end_pressed)
8747 float nav_scoring_rect_offset_y = 0.0f;
8750 nav_scoring_rect_offset_y = -page_offset_y;
8757 nav_scoring_rect_offset_y = +page_offset_y;
8762 else if (home_pressed)
8769 nav_rect_rel.
Min.
x = nav_rect_rel.
Max.
x = 0.0f;
8773 else if (end_pressed)
8777 nav_rect_rel.
Min.
x = nav_rect_rel.
Max.
x = 0.0f;
8781 return nav_scoring_rect_offset_y;
8790 for (
int i =
g.WindowsFocusOrder.Size-1;
i >= 0;
i--)
8791 if (
g.WindowsFocusOrder[
i] == window)
8799 for (
int i = i_start;
i >= 0 &&
i <
g.WindowsFocusOrder.Size &&
i != i_stop;
i += dir)
8815 window_target =
FindWindowNavFocusable((focus_change_dir < 0) ? (
g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir);
8817 g.NavWindowingTarget =
g.NavWindowingTargetAnim = window_target;
8818 g.NavWindowingToggleLayer =
false;
8828 bool apply_toggle_layer =
false;
8831 if (modal_window !=
NULL)
8833 g.NavWindowingTarget =
NULL;
8838 if (
g.NavWindowingTargetAnim &&
g.NavWindowingTarget ==
NULL)
8840 g.NavWindowingHighlightAlpha =
ImMax(
g.NavWindowingHighlightAlpha -
g.IO.DeltaTime * 10.0f, 0.0f);
8841 if (
g.DimBgRatio <= 0.0f &&
g.NavWindowingHighlightAlpha <= 0.0f)
8842 g.NavWindowingTargetAnim =
NULL;
8848 if (start_windowing_with_gamepad || start_windowing_with_keyboard)
8851 g.NavWindowingTarget =
g.NavWindowingTargetAnim = window->RootWindow;
8852 g.NavWindowingTimer =
g.NavWindowingHighlightAlpha = 0.0f;
8853 g.NavWindowingToggleLayer = start_windowing_with_keyboard ?
false :
true;
8858 g.NavWindowingTimer +=
g.IO.DeltaTime;
8866 if (focus_change_dir != 0)
8869 g.NavWindowingHighlightAlpha = 1.0f;
8875 g.NavWindowingToggleLayer &= (
g.NavWindowingHighlightAlpha < 1.0f);
8876 if (
g.NavWindowingToggleLayer &&
g.NavWindow)
8877 apply_toggle_layer =
true;
8878 else if (!
g.NavWindowingToggleLayer)
8879 apply_focus_window =
g.NavWindowingTarget;
8880 g.NavWindowingTarget =
NULL;
8892 apply_focus_window =
g.NavWindowingTarget;
8898 g.NavWindowingToggleLayer =
true;
8901 apply_toggle_layer =
true;
8911 if (move_delta.
x != 0.0f || move_delta.
y != 0.0f)
8913 const float NAV_MOVE_SPEED = 800.0f;
8914 const float move_speed =
ImFloor(NAV_MOVE_SPEED *
g.IO.DeltaTime *
ImMin(
g.IO.DisplayFramebufferScale.x,
g.IO.DisplayFramebufferScale.y));
8916 g.NavDisableMouseHover =
true;
8922 if (apply_focus_window && (
g.NavWindow ==
NULL || apply_focus_window !=
g.NavWindow->
RootWindow))
8925 g.NavDisableHighlight =
false;
8926 g.NavDisableMouseHover =
true;
8937 if (apply_focus_window)
8938 g.NavWindowingTarget =
NULL;
8941 if (apply_toggle_layer &&
g.NavWindow)
8950 if (new_nav_window !=
g.NavWindow)
8956 g.NavDisableHighlight =
false;
8957 g.NavDisableMouseHover =
true;
8971 return "(Main menu bar)";
8972 return "(Untitled)";
8984 if (
g.NavWindowingList ==
NULL)
8990 for (
int n =
g.WindowsFocusOrder.Size - 1;
n >= 0;
n--)
9012 g.DragDropPayload.Clear();
9014 g.DragDropAcceptIdCurr =
g.DragDropAcceptIdPrev = 0;
9015 g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
9016 g.DragDropAcceptFrameCount = -1;
9018 g.DragDropPayloadBufHeap.clear();
9019 memset(&
g.DragDropPayloadBufLocal, 0,
sizeof(
g.DragDropPayloadBufLocal));
9029 bool source_drag_active =
false;
9036 if (source_id != 0 &&
g.ActiveId != source_id)
9038 if (
g.IO.MouseDown[mouse_button] ==
false)
9061 if (is_hovered &&
g.IO.MouseClicked[mouse_button])
9066 if (
g.ActiveId == source_id)
9067 g.ActiveIdAllowOverlap = is_hovered;
9071 g.ActiveIdAllowOverlap =
false;
9073 if (
g.ActiveId != source_id)
9079 g.ActiveIdUsingNavDirMask = ~(
ImU32)0;
9080 g.ActiveIdUsingNavInputMask = ~(
ImU32)0;
9081 g.ActiveIdUsingKeyInputMask = ~(
ImU64)0;
9087 source_drag_active =
true;
9090 if (source_drag_active)
9092 if (!
g.DragDropActive)
9099 g.DragDropActive =
true;
9100 g.DragDropSourceFlags =
flags;
9101 g.DragDropMouseButton = mouse_button;
9103 g.DragDropSourceFrameCount =
g.FrameCount;
9104 g.DragDropWithinSource =
true;
9131 IM_ASSERT(
g.DragDropWithinSource &&
"Not after a BeginDragDropSource()?");
9137 if (
g.DragDropPayload.DataFrameCount == -1)
9139 g.DragDropWithinSource =
false;
9160 g.DragDropPayloadBufHeap.resize(0);
9161 if (data_size >
sizeof(
g.DragDropPayloadBufLocal))
9164 g.DragDropPayloadBufHeap.resize((
int)data_size);
9165 payload.
Data =
g.DragDropPayloadBufHeap.Data;
9166 memcpy(payload.
Data,
data, data_size);
9168 else if (data_size > 0)
9171 memset(&
g.DragDropPayloadBufLocal, 0,
sizeof(
g.DragDropPayloadBufLocal));
9172 payload.
Data =
g.DragDropPayloadBufLocal;
9173 memcpy(payload.
Data,
data, data_size);
9183 return (
g.DragDropAcceptFrameCount ==
g.FrameCount) || (
g.DragDropAcceptFrameCount ==
g.FrameCount - 1);
9189 if (!
g.DragDropActive)
9202 g.DragDropTargetRect = bb;
9203 g.DragDropTargetId =
id;
9204 g.DragDropWithinTarget =
true;
9215 if (!
g.DragDropActive)
9228 if (
g.DragDropPayload.SourceId ==
id)
9232 g.DragDropTargetRect = display_rect;
9233 g.DragDropTargetId =
id;
9234 g.DragDropWithinTarget =
true;
9256 const bool was_accepted_previously = (
g.DragDropAcceptIdPrev ==
g.DragDropTargetId);
9258 float r_surface =
r.
GetWidth() *
r.GetHeight();
9259 if (r_surface <
g.DragDropAcceptIdCurrRectSurface)
9261 g.DragDropAcceptFlags =
flags;
9262 g.DragDropAcceptIdCurr =
g.DragDropTargetId;
9263 g.DragDropAcceptIdCurrRectSurface = r_surface;
9267 payload.
Preview = was_accepted_previously;
9279 g.DragDropAcceptFrameCount =
g.FrameCount;
9299 g.DragDropWithinTarget =
false;
9320 g.LogBuffer.Buf.resize(0);
9341 const bool log_new_line = ref_pos && (ref_pos->
y >
g.LogLinePosY + 1);
9343 g.LogLinePosY = ref_pos->
y;
9345 g.LogLineFirstItem =
true;
9347 const char* text_remaining = text;
9350 const int tree_depth = (window->
DC.
TreeDepth -
g.LogDepthRef);
9355 const char* line_start = text_remaining;
9357 const bool is_first_line = (line_start == text);
9358 const bool is_last_line = (line_end == text_end);
9359 if (!is_last_line || (line_start != line_end))
9361 const int char_count = (int)(line_end - line_start);
9362 if (log_new_line || !is_first_line)
9364 else if (
g.LogLineFirstItem)
9365 LogText(
"%*s%.*s", tree_depth * 4,
"", char_count, line_start);
9367 LogText(
" %.*s", char_count, line_start);
9368 g.LogLineFirstItem =
false;
9370 else if (log_new_line)
9379 text_remaining = line_end + 1;
9391 g.LogEnabled =
true;
9394 g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth :
g.LogDepthToExpandDefault);
9395 g.LogLinePosY = FLT_MAX;
9396 g.LogLineFirstItem =
true;
9405 #ifndef IMGUI_DISABLE_TTY_FUNCTIONS
9423 if (!filename || !filename[0])
9463 #ifndef IMGUI_DISABLE_TTY_FUNCTIONS
9473 if (!
g.LogBuffer.empty())
9481 g.LogEnabled =
false;
9484 g.LogBuffer.clear();
9494 #ifndef IMGUI_DISABLE_TTY_FUNCTIONS
9497 const bool log_to_tty =
false;
9500 const bool log_to_clipboard =
Button(
"Log To Clipboard");
SameLine();
9503 SliderInt(
"Default Depth", &
g.LogDepthToExpandDefault, 0, 9,
NULL);
9512 if (log_to_clipboard)
9525 if (!
g.SettingsLoaded)
9528 if (
g.IO.IniFilename)
9530 g.SettingsLoaded =
true;
9534 if (
g.SettingsDirtyTimer > 0.0f)
9536 g.SettingsDirtyTimer -=
g.IO.DeltaTime;
9537 if (
g.SettingsDirtyTimer <= 0.0f)
9539 if (
g.IO.IniFilename !=
NULL)
9542 g.IO.WantSaveIniSettings =
true;
9543 g.SettingsDirtyTimer = 0.0f;
9551 if (
g.SettingsDirtyTimer <= 0.0f)
9559 if (
g.SettingsDirtyTimer <= 0.0f)
9567 #if !IMGUI_DEBUG_INI_SETTINGS
9570 if (
const char*
p = strstr(
name,
"###"))
9588 for (
ImGuiWindowSettings* settings =
g.SettingsWindows.begin(); settings !=
NULL; settings =
g.SettingsWindows.next_chunk(settings))
9589 if (settings->ID ==
id)
9603 size_t file_data_size = 0;
9615 for (
int handler_n = 0; handler_n <
g.SettingsHandlers.Size; handler_n++)
9616 if (
g.SettingsHandlers[handler_n].TypeHash == type_hash)
9617 return &
g.SettingsHandlers[handler_n];
9626 IM_ASSERT(
g.SettingsLoaded ==
false &&
g.FrameCount == 0);
9631 ini_size = strlen(ini_data);
9633 char* buf_end =
buf + ini_size;
9634 memcpy(
buf, ini_data, ini_size);
9637 void* entry_data =
NULL;
9640 char* line_end =
NULL;
9641 for (
char* line =
buf; line < buf_end; line = line_end + 1)
9644 while (*line ==
'\n' || *line ==
'\r')
9647 while (line_end < buf_end && *line_end !=
'\n' && *line_end !=
'\r')
9652 if (line[0] ==
'[' && line_end > line && line_end[-1] ==
']')
9656 const char* name_end = line_end - 1;
9657 const char* type_start = line + 1;
9658 char* type_end = (
char*)(
void*)
ImStrchrRange(type_start, name_end,
']');
9659 const char* name_start = type_end ?
ImStrchrRange(type_end + 1, name_end,
'[') :
NULL;
9660 if (!type_end || !name_start)
9665 entry_data = entry_handler ? entry_handler->
ReadOpenFn(&
g, entry_handler, name_start) :
NULL;
9667 else if (entry_handler !=
NULL && entry_data !=
NULL)
9670 entry_handler->
ReadLineFn(&
g, entry_handler, entry_data, line);
9674 g.SettingsLoaded =
true;
9684 size_t ini_data_size = 0;
9698 g.SettingsIniData.Buf.resize(0);
9699 g.SettingsIniData.Buf.push_back(0);
9700 for (
int handler_n = 0; handler_n <
g.SettingsHandlers.Size; handler_n++)
9706 *out_size = (size_t)
g.SettingsIniData.size();
9707 return g.SettingsIniData.c_str();
9715 return (
void*)settings;
9723 if (sscanf(line,
"Pos=%i,%i", &
x, &
y) == 2) settings->
Pos =
ImVec2ih((
short)
x, (short)
y);
9724 else if (sscanf(line,
"Size=%i,%i", &
x, &
y) == 2) settings->
Size =
ImVec2ih((
short)
x, (short)
y);
9725 else if (sscanf(line,
"Collapsed=%d", &
i) == 1) settings->
Collapsed = (
i != 0);
9733 for (
int i = 0;
i !=
g.Windows.Size;
i++)
9752 buf->reserve(
buf->size() +
g.SettingsWindows.size() * 6);
9753 for (
ImGuiWindowSettings* settings =
g.SettingsWindows.begin(); settings !=
NULL; settings =
g.SettingsWindows.next_chunk(settings))
9755 const char* settings_name = settings->GetName();
9756 buf->appendf(
"[%s][%s]\n",
handler->TypeName, settings_name);
9757 buf->appendf(
"Pos=%d,%d\n", settings->Pos.x, settings->Pos.y);
9758 buf->appendf(
"Size=%d,%d\n", settings->Size.x, settings->Size.y);
9759 buf->appendf(
"Collapsed=%d\n", settings->Collapsed);
9783 #if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
9786 #pragma comment(lib, "user32")
9787 #pragma comment(lib, "kernel32")
9795 if (!::OpenClipboard(
NULL))
9797 HANDLE wbuf_handle = ::GetClipboardData(CF_UNICODETEXT);
9798 if (wbuf_handle ==
NULL)
9803 if (
const WCHAR* wbuf_global = (
const WCHAR*)::GlobalLock(wbuf_handle))
9805 int buf_len = ::WideCharToMultiByte(CP_UTF8, 0, wbuf_global, -1,
NULL, 0,
NULL,
NULL);
9806 buf_local.
resize(buf_len);
9807 ::WideCharToMultiByte(CP_UTF8, 0, wbuf_global, -1, buf_local.
Data, buf_len,
NULL,
NULL);
9809 ::GlobalUnlock(wbuf_handle);
9811 return buf_local.
Data;
9816 if (!::OpenClipboard(
NULL))
9818 const int wbuf_length = ::MultiByteToWideChar(CP_UTF8, 0, text, -1,
NULL, 0);
9819 HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length *
sizeof(WCHAR));
9820 if (wbuf_handle ==
NULL)
9825 WCHAR* wbuf_global = (WCHAR*)::GlobalLock(wbuf_handle);
9826 ::MultiByteToWideChar(CP_UTF8, 0, text, -1, wbuf_global, wbuf_length);
9827 ::GlobalUnlock(wbuf_handle);
9829 if (::SetClipboardData(CF_UNICODETEXT, wbuf_handle) ==
NULL)
9830 ::GlobalFree(wbuf_handle);
9834 #elif defined(__APPLE__) && TARGET_OS_OSX && defined(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS)
9836 #include <Carbon/Carbon.h>
9837 static PasteboardRef main_clipboard = 0;
9843 if (!main_clipboard)
9844 PasteboardCreate(kPasteboardClipboard, &main_clipboard);
9845 PasteboardClear(main_clipboard);
9846 CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (
const UInt8*)text, strlen(text));
9849 PasteboardPutItemFlavor(main_clipboard, (PasteboardItemID)1, CFSTR(
"public.utf8-plain-text"), cf_data, 0);
9856 if (!main_clipboard)
9857 PasteboardCreate(kPasteboardClipboard, &main_clipboard);
9858 PasteboardSynchronize(main_clipboard);
9860 ItemCount item_count = 0;
9861 PasteboardGetItemCount(main_clipboard, &item_count);
9862 for (ItemCount
i = 0;
i < item_count;
i++)
9864 PasteboardItemID item_id = 0;
9865 PasteboardGetItemIdentifier(main_clipboard,
i + 1, &item_id);
9866 CFArrayRef flavor_type_array = 0;
9867 PasteboardCopyItemFlavors(main_clipboard, item_id, &flavor_type_array);
9868 for (CFIndex j = 0, nj = CFArrayGetCount(flavor_type_array); j < nj; j++)
9871 if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR(
"public.utf8-plain-text"), &cf_data) == noErr)
9874 int length = (int)CFDataGetLength(cf_data);
9876 CFDataGetBytes(cf_data, CFRangeMake(0,
length), (UInt8*)clipboard_text.
Data);
9877 clipboard_text[
length] = 0;
9879 return clipboard_text.
Data;
9899 const char* text_end = text + strlen(text);
9900 g.PrivateClipboard.resize((
int)(text_end - text) + 1);
9901 memcpy(&
g.PrivateClipboard[0], text, (
size_t)(text_end - text));
9902 g.PrivateClipboard[(int)(text_end - text)] = 0;
9908 #if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
9912 #pragma comment(lib, "imm32")
9920 if (HIMC himc = ::ImmGetContext(hwnd))
9923 cf.ptCurrentPos.x =
x;
9924 cf.ptCurrentPos.y =
y;
9925 cf.dwStyle = CFS_FORCE_POSITION;
9926 ::ImmSetCompositionWindow(himc, &cf);
9927 ::ImmReleaseContext(hwnd, himc);
9941 #ifndef IMGUI_DISABLE_METRICS_WINDOW
9965 enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count };
9966 const char* wrt_rects_names[WRT_Count] = {
"OuterRect",
"OuterRectClipped",
"InnerRect",
"InnerClipRect",
"WorkRect",
"Content",
"ContentRegionRect" };
9967 enum { TRT_OuterRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersDesired, TRT_ColumnsContentRowsFrozen, TRT_ColumnsContentRowsUnfrozen, TRT_Count };
9968 const char* trt_rects_names[TRT_Count] = {
"OuterRect",
"WorkRect",
"HostClipRect",
"InnerClipRect",
"BackgroundClipRect",
"ColumnsRect",
"ColumnsClipRect",
"ColumnsContentHeadersUsed",
"ColumnsContentHeadersDesired",
"ColumnsContentRowsFrozen",
"ColumnsContentRowsUnfrozen" };
9971 static bool show_windows_rects =
false;
9972 static int show_windows_rect_type = WRT_WorkRect;
9973 static bool show_windows_begin_order =
false;
9974 static bool show_tables_rects =
false;
9975 static int show_tables_rect_type = TRT_WorkRect;
9976 static bool show_drawcmd_details =
true;
9999 if (rect_type == WRT_OuterRect) {
return window->
Rect(); }
10000 else if (rect_type == WRT_OuterRectClipped) {
return window->
OuterRectClipped; }
10001 else if (rect_type == WRT_InnerRect) {
return window->
InnerRect; }
10002 else if (rect_type == WRT_InnerClipRect) {
return window->
InnerClipRect; }
10003 else if (rect_type == WRT_WorkRect) {
return window->
WorkRect; }
10005 else if (rect_type == WRT_ContentRegionRect) {
return window->
ContentRegionRect; }
10028 ImGui::TextDisabled(
"Warning: owning Window is inactive. This DrawList is not being rendered!");
10030 unsigned int elem_offset = 0;
10033 if (pcmd->UserCallback ==
NULL && pcmd->ElemCount == 0)
10035 if (pcmd->UserCallback)
10037 ImGui::BulletText(
"Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
10044 pcmd->ElemCount/3, (
void*)(intptr_t)pcmd->TextureId,
10045 pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
10049 ImRect clip_rect = pcmd->ClipRect;
10050 ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
10051 for (
unsigned int i = elem_offset;
i < elem_offset + (int)pcmd->ElemCount;
i++)
10052 vtxs_rect.
Add(draw_list->
VtxBuffer[idx_buffer ? idx_buffer[
i] :
i].pos);
10056 if (!pcmd_node_open)
10061 float total_area = 0.0f;
10062 for (
unsigned int base_idx = elem_offset; base_idx < (elem_offset + pcmd->ElemCount); base_idx += 3)
10065 for (
int n = 0;
n < 3;
n++)
10066 triangle[
n] = draw_list->
VtxBuffer[idx_buffer ? idx_buffer[base_idx +
n] : (base_idx +
n)].pos;
10067 total_area +=
ImTriangleArea(triangle[0], triangle[1], triangle[2]);
10071 ImFormatString(
buf,
IM_ARRAYSIZE(
buf),
"Mesh: ElemCount: %d, VtxOffset: +%d, IdxOffset: +%d, Area: ~%0.f px", pcmd->ElemCount, pcmd->VtxOffset, pcmd->IdxOffset, total_area);
10078 ImRect clip_rect = pcmd->ClipRect;
10080 for (
unsigned int base_idx = elem_offset; base_idx < (elem_offset + pcmd->ElemCount); base_idx += 3)
10083 for (
int n = 0;
n < 3;
n++)
10084 triangle[
n] = draw_list->
VtxBuffer[idx_buffer ? idx_buffer[base_idx +
n] : (base_idx +
n)].pos;
10087 fg_draw_list->
Flags = backup_flags;
10092 while (clipper.
Step())
10097 for (
int n = 0;
n < 3;
n++, idx_i++)
10100 triangle[
n] =
v.pos;
10101 buf_p +=
ImFormatString(buf_p, buf_end - buf_p,
"%s %04d: pos (%8.2f,%8.2f), uv (%.6f,%.6f), col %08X\n",
10102 (
n == 0) ?
"Vert:" :
" ", idx_i,
v.pos.x,
v.pos.y,
v.uv.x,
v.uv.y,
v.col);
10111 fg_draw_list->
Flags = backup_flags;
10121 if (!
ImGui::TreeNode((
void*)(uintptr_t)columns->
ID,
"Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->
ID, columns->
Count, columns->
Flags))
10124 for (
int column_n = 0; column_n < columns->
Columns.
Size; column_n++)
10133 for (
int i = 0;
i < windows.
Size;
i++)
10136 Funcs::NodeWindow(windows[
i],
"Window");
10144 if (window ==
NULL)
10155 NodeDrawList(window, window->
DrawList,
"DrawList");
10156 ImGui::BulletText(
"Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f)", window->
Pos.
x, window->
Pos.
y, window->
Size.
x, window->
Size.
y, window->
ContentSize.
x, window->
ContentSize.
y);
10192 for (
int tab_n = 0; tab_n < tab_bar->
Tabs.
Size; tab_n++)
10209 for (
int n = 0;
n < storage->
Data.Size;
n++)
10218 Funcs::NodeWindows(
g.Windows,
"Windows");
10220 if (
ImGui::TreeNode(
"DrawLists",
"Active DrawLists (%d)",
g.DrawDataBuilder.Layers[0].Size))
10222 for (
int i = 0;
i <
g.DrawDataBuilder.Layers[0].Size;
i++)
10223 Funcs::NodeDrawList(
NULL,
g.DrawDataBuilder.Layers[0][
i],
"DrawList");
10230 for (
int i = 0;
i <
g.OpenPopupStack.Size;
i++)
10241 for (
int n = 0;
n <
g.TabBars.GetSize();
n++)
10242 Funcs::NodeTabBar(
g.TabBars.GetByIndex(
n));
10250 #ifdef IMGUI_HAS_TABLE
10253 for (
int n = 0;
n <
g.Tables.GetSize();
n++)
10254 Funcs::NodeTable(
g.Tables.GetByIndex(
n));
10257 #endif // #define IMGUI_HAS_TABLE
10260 #ifdef IMGUI_HAS_DOCK
10265 #endif // #define IMGUI_HAS_DOCK
10271 ImGui::Text(
"HoveredWindow: '%s'",
g.HoveredWindow ?
g.HoveredWindow->Name :
"NULL");
10272 ImGui::Text(
"HoveredRootWindow: '%s'",
g.HoveredRootWindow ?
g.HoveredRootWindow->Name :
"NULL");
10273 ImGui::Text(
"HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d",
g.HoveredId,
g.HoveredIdPreviousFrame,
g.HoveredIdTimer,
g.HoveredIdAllowOverlap);
10274 ImGui::Text(
"ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s",
g.ActiveId,
g.ActiveIdPreviousFrame,
g.ActiveIdTimer,
g.ActiveIdAllowOverlap, input_source_names[
g.ActiveIdSource]);
10275 ImGui::Text(
"ActiveIdWindow: '%s'",
g.ActiveIdWindow ?
g.ActiveIdWindow->Name :
"NULL");
10276 ImGui::Text(
"MovingWindow: '%s'",
g.MovingWindow ?
g.MovingWindow->Name :
"NULL");
10277 ImGui::Text(
"NavWindow: '%s'",
g.NavWindow ?
g.NavWindow->Name :
"NULL");
10278 ImGui::Text(
"NavId: 0x%08X, NavLayer: %d",
g.NavId,
g.NavLayer);
10279 ImGui::Text(
"NavInputSource: %s", input_source_names[
g.NavInputSource]);
10280 ImGui::Text(
"NavActive: %d, NavVisible: %d",
g.IO.NavActive,
g.IO.NavVisible);
10281 ImGui::Text(
"NavActivateId: 0x%08X, NavInputId: 0x%08X",
g.NavActivateId,
g.NavInputId);
10282 ImGui::Text(
"NavDisableHighlight: %d, NavDisableMouseHover: %d",
g.NavDisableHighlight,
g.NavDisableMouseHover);
10283 ImGui::Text(
"NavWindowingTarget: '%s'",
g.NavWindowingTarget ?
g.NavWindowingTarget->Name :
"NULL");
10284 ImGui::Text(
"DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)",
g.DragDropActive,
g.DragDropPayload.SourceId,
g.DragDropPayload.DataType,
g.DragDropPayload.DataSize);
10295 MetricsHelpMarker(
"Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash.");
10297 ImGui::Checkbox(
"Show windows begin order", &show_windows_begin_order);
10301 show_windows_rects |=
ImGui::Combo(
"##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count, WRT_Count);
10302 if (show_windows_rects &&
g.NavWindow)
10306 for (
int rect_n = 0; rect_n < WRT_Count; rect_n++)
10308 ImRect r = Funcs::GetWindowRect(
g.NavWindow, rect_n);
10309 ImGui::Text(
"(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s",
r.Min.x,
r.Min.y,
r.Max.x,
r.Max.y,
r.GetWidth(),
r.GetHeight(), wrt_rects_names[rect_n]);
10313 ImGui::Checkbox(
"Show details when hovering ImDrawCmd node", &show_drawcmd_details);
10318 if (show_windows_rects || show_windows_begin_order)
10320 for (
int n = 0;
n <
g.Windows.Size;
n++)
10326 if (show_windows_rects)
10328 ImRect r = Funcs::GetWindowRect(window, show_windows_rect_type);
10342 #ifdef IMGUI_HAS_TABLE
10344 if (show_tables_rects)
10346 for (
int table_n = 0; table_n <
g.Tables.GetSize(); table_n++)
10348 ImGuiTable*
table =
g.Tables.GetByIndex(table_n);
10351 #endif // #define IMGUI_HAS_TABLE
10353 #ifdef IMGUI_HAS_DOCK
10355 if (show_docking_nodes &&
g.IO.KeyCtrl)
10358 #endif // #define IMGUI_HAS_DOCK
10373 #ifdef IMGUI_INCLUDE_IMGUI_USER_INL
10374 #include "imgui_user.inl"
10379 #endif // #ifndef IMGUI_DISABLE