41#ifndef KGGUI_ENABLE_FREETYPE
42#define KGGUI_ENABLE_STB_TRUETYPE
83struct KGGuiTableColumnsSettings;
92enum KGGuiLocKey : int;
93typedef int KGGuiDataAuthority;
94typedef int KGGuiLayoutType;
97typedef int KGGuiActivateFlags;
98typedef int KGGuiDebugLogFlags;
99typedef int KGGuiItemFlags;
100typedef int KGGuiItemStatusFlags;
101typedef int KGGuiOldColumnFlags;
102typedef int KGGuiNavHighlightFlags;
103typedef int KGGuiNavMoveFlags;
104typedef int KGGuiNextItemDataFlags;
105typedef int KGGuiNextWindowDataFlags;
106typedef int KGGuiScrollFlags;
107typedef int KGGuiSeparatorFlags;
108typedef int KGGuiTextFlags;
109typedef int KGGuiTooltipFlags;
111typedef void (*KGGuiErrorLogCallback)(
void* user_data,
const char* fmt, ...);
127#undef STB_TEXTEDIT_STRING
128#undef STB_TEXTEDIT_CHARTYPE
129#define STB_TEXTEDIT_STRING KGGuiInputTextState
130#define STB_TEXTEDIT_CHARTYPE KGWchar
131#define STB_TEXTEDIT_GETWIDTH_NEWLINE (-1.0f)
132#define STB_TEXTEDIT_UNDOSTATECOUNT 99
133#define STB_TEXTEDIT_UNDOCHARCOUNT 999
134#include "KarmaSTBTextEdit.h"
142#define KARMAGUI_PAYLOAD_TYPE_WINDOW "_IMWINDOW"
145#ifndef KARMAGUI_DISABLE_DEBUG_TOOLS
146#define KARMAGUI_DEBUG_LOG(...) KR_CORE_INFO(...)
148#define KARMAGUI_DEBUG_LOG(...)
150#define KARMAGUI_DEBUG_LOG_ACTIVEID(...) do { if (g.DebugLogFlags & KGGuiDebugLogFlags_EventActiveId) KARMAGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
151#define KARMAGUI_DEBUG_LOG_FOCUS(...) do { if (g.DebugLogFlags & KGGuiDebugLogFlags_EventFocus) KARMAGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
152#define KARMAGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & KGGuiDebugLogFlags_EventPopup) KARMAGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
153#define KARMAGUI_DEBUG_LOG_NAV(...) do { if (g.DebugLogFlags & KGGuiDebugLogFlags_EventNav) KARMAGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
154#define ye_right(...) do { if (g.DebugLogFlags & KGGuiDebugLogFlags_EventClipper) KARMAGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
155#define KARMAGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & KGGuiDebugLogFlags_EventIO) KARMAGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
156#define KARMAGUI_DEBUG_LOG_DOCKING(...) do { if (g.DebugLogFlags & KGGuiDebugLogFlags_EventDocking) KARMAGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
157#define KARMAGUI_DEBUG_LOG_VIEWPORT(...) do { if (g.DebugLogFlags & KGGuiDebugLogFlags_EventViewport) KARMAGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
160#define KG_STATIC_ASSERT(_COND) KR_CORE_ASSERT(_COND, "")
163#define KG_PI 3.14159265358979323846f
164#ifdef KR_CORE_WINDOWS
165#define KG_NEWLINE "\r\n"
167#define KG_NEWLINE "\n"
170#define KG_TABSIZE (4)
172#define KG_MEMALIGN(_OFF,_ALIGN) (((_OFF) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1))
173#define KG_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f)))
174#define KG_F32_TO_INT8_SAT(_VAL) ((int)(KGSaturate(_VAL) * 255.0f + 0.5f))
175#define KG_FLOOR(_VAL) ((float)(int)(_VAL))
176#define KG_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f))
179#if defined(_MSC_VER) && !defined(__clang__)
180#define KG_MSVC_WARNING_SUPPRESS(XXXX) __pragma(warning(suppress: XXXX))
182#define KG_MSVC_WARNING_SUPPRESS(XXXX)
211KGGuiID KGHashData(
const void* data,
size_t data_size, KGU32 seed = 0);
212KGGuiID KGHashStr(
const char* data,
size_t data_size = 0, KGU32 seed = 0);
216static inline void KGQsort(
void* base,
size_t count,
size_t size_of_element,
int(*compare_func)(
void const*,
void const*)) {
if (count > 1) qsort(base, count, size_of_element, compare_func); }
220KGU32 KGAlphaBlendColors(KGU32 col_a, KGU32 col_b);
223static inline bool KGIsPowerOfTwo(
int v) {
return v != 0 && (v & (v - 1)) == 0; }
224static inline bool KGIsPowerOfTwo(KGU64 v) {
return v != 0 && (v & (v - 1)) == 0; }
225static inline int KGUpperPowerOfTwo(
int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++;
return v; }
228int KGStricmp(
const char* str1,
const char* str2);
229int KGStrnicmp(
const char* str1,
const char* str2,
size_t count);
230void KGStrncpy(
char* dst,
const char* src,
size_t count);
231char* KGStrdup(
const char* str);
232char* KGStrdupcpy(
char* dst,
size_t* p_dst_size,
const char* str);
233const char* KGStrchrRange(
const char* str_begin,
const char* str_end,
char c);
234int KGStrlenW(
const KGWchar* str);
235const char* KGStreolRange(
const char* str,
const char* str_end);
236const KGWchar* KGStrbolW(
const KGWchar* buf_mid_line,
const KGWchar* buf_begin);
237const char* KGStristr(
const char* haystack,
const char* haystack_end,
const char* needle,
const char* needle_end);
238void KGStrTrimBlanks(
char* str);
239const char* KGStrSkipBlank(
const char* str);
241static inline char KGToUpper(
char c) {
return (c >=
'a' && c <=
'z') ? c &= ~32 : c; }
242static inline bool KGCharIsBlankA(
char c) {
return c ==
' ' || c ==
'\t'; }
243static inline bool KGCharIsBlankW(
unsigned int c) {
return c ==
' ' || c ==
'\t' || c == 0x3000; }
246int KGFormatString(
char* buf,
size_t buf_size,
const char* fmt, ...) KG_FMTARGS(3);
247int KGFormatStringV(
char* buf,
size_t buf_size, const
char* fmt, va_list args) KG_FMTLIST(3);
248void KGFormatStringToTempBuffer(const
char** out_buf, const
char** out_buf_end, const
char* fmt, ...) KG_FMTARGS(3);
249void KGFormatStringToTempBufferV(const
char** out_buf, const
char** out_buf_end, const
char* fmt, va_list args) KG_FMTLIST(3);
250const
char* KGParseFormatFindStart(const
char* format);
251const
char* KGParseFormatFindEnd(const
char* format);
252const
char* KGParseFormatTrimDecorations(const
char* format,
char* buf,
size_t buf_size);
253void KGParseFormatSanitizeForPrinting(const
char* fmt_in,
char* fmt_out,
size_t fmt_out_size);
254const
char* KGParseFormatSanitizeForScanning(const
char* fmt_in,
char* fmt_out,
size_t fmt_out_size);
255int KGParseFormatPrecision(const
char* format,
int default_value);
258const
char* KGTextCharToUtf8(
char out_buf[5],
unsigned int c);
259int KGTextStrToUtf8(
char* out_buf,
int out_buf_size, const KGWchar* in_text, const KGWchar* in_text_end);
260int KGTextCharFromUtf8(
unsigned int* out_char, const
char* in_text, const
char* in_text_end);
261int KGTextStrFromUtf8(KGWchar* out_buf,
int out_buf_size, const
char* in_text, const
char* in_text_end, const
char** in_remaining = NULL);
262int KGTextCountCharsFromUtf8(const
char* in_text, const
char* in_text_end);
263int KGTextCountUtf8BytesFromChar(const
char* in_text, const
char* in_text_end);
264int KGTextCountUtf8BytesFromStr(const KGWchar* in_text, const KGWchar* in_text_end);
266#ifndef KARMAGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
267typedef FILE* ImFileHandle;
268ImFileHandle KGFileOpen(
const char* filename,
const char* mode);
269bool KGFileClose(ImFileHandle file);
270KGU64 KGFileGetSize(ImFileHandle file);
271KGU64 KGFileRead(
void* data, KGU64 size, KGU64 count, ImFileHandle file);
272KGU64 KGFileWrite(
const void* data, KGU64 size, KGU64 count, ImFileHandle file);
274#define IMGUI_DISABLE_TTY_FUNCTIONS
276void* KGFileLoadToMemory(
const char* filename,
const char* mode,
size_t* out_file_size = NULL,
int padding_bytes = 0);
280#ifndef KARMAGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
281#define KGFabs(X) fabsf(X)
282#define KGSqrt(X) sqrtf(X)
283#define KGFmod(X, Y) fmodf((X), (Y))
284#define KGCos(X) cosf(X)
285#define KGSin(X) sinf(X)
286#define KGAcos(X) acosf(X)
287#define KGAtan2(Y, X) atan2f((Y), (X))
288#define KGAtof(STR) atof(STR)
290#define KGCeil(X) ceilf(X)
292static inline KGVec2 operator*(
const KGVec2& lhs,
const float rhs) {
return KGVec2(lhs.x * rhs, lhs.y * rhs); }
293static inline KGVec2 operator/(
const KGVec2& lhs,
const float rhs) {
return KGVec2(lhs.x / rhs, lhs.y / rhs); }
294static inline KGVec2 operator+(
const KGVec2& lhs,
const KGVec2& rhs) {
return KGVec2(lhs.x + rhs.x, lhs.y + rhs.y); }
295static inline KGVec2 operator-(
const KGVec2& lhs,
const KGVec2& rhs) {
return KGVec2(lhs.x - rhs.x, lhs.y - rhs.y); }
296static inline KGVec2 operator*(
const KGVec2& lhs,
const KGVec2& rhs) {
return KGVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
297static inline KGVec2 operator/(
const KGVec2& lhs,
const KGVec2& rhs) {
return KGVec2(lhs.x / rhs.x, lhs.y / rhs.y); }
298static inline KGVec2& operator*=(
KGVec2& lhs,
const float rhs) { lhs.x *= rhs; lhs.y *= rhs;
return lhs; }
299static inline KGVec2& operator/=(
KGVec2& lhs,
const float rhs) { lhs.x /= rhs; lhs.y /= rhs;
return lhs; }
300static inline KGVec2& operator+=(
KGVec2& lhs,
const KGVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y;
return lhs; }
301static inline KGVec2& operator-=(
KGVec2& lhs,
const KGVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y;
return lhs; }
302static inline KGVec2& operator*=(
KGVec2& lhs,
const KGVec2& rhs) { lhs.x *= rhs.x; lhs.y *= rhs.y;
return lhs; }
303static inline KGVec2& operator/=(
KGVec2& lhs,
const KGVec2& rhs) { lhs.x /= rhs.x; lhs.y /= rhs.y;
return lhs; }
304static inline KGVec4 operator+(
const KGVec4& lhs,
const KGVec4& rhs) {
return KGVec4(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z, lhs.w + rhs.w); }
305static inline KGVec4 operator-(
const KGVec4& lhs,
const KGVec4& rhs) {
return KGVec4(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w); }
306static inline KGVec4 operator*(
const KGVec4& lhs,
const KGVec4& rhs) {
return KGVec4(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w); }
308static inline float KGPow(
float x,
float y) {
return powf(x, y); }
309static inline double KGPow(
double x,
double y) {
return pow(x, y); }
310static inline float KGLog(
float x) {
return logf(x); }
311static inline double KGLog(
double x) {
return log(x); }
312static inline int KGAbs(
int x) {
return x < 0 ? -x : x; }
313static inline float KGAbs(
float x) {
return fabsf(x); }
314static inline double KGAbs(
double x) {
return fabs(x); }
315static inline float KGSign(
float x) {
return (x < 0.0f) ? -1.0f : (x > 0.0f) ? 1.0f : 0.0f; }
316static inline double KGSign(
double x) {
return (x < 0.0) ? -1.0 : (x > 0.0) ? 1.0 : 0.0; }
317static inline float KGRsqrt(
float x) {
return 1.0f / sqrtf(x); }
318static inline double KGRsqrt(
double x) {
return 1.0 / sqrt(x); }
323template<
typename T>
static inline T KGMin(T lhs, T rhs) {
return lhs < rhs ? lhs : rhs; }
324template<
typename T>
static inline T KGMax(T lhs, T rhs) {
return lhs >= rhs ? lhs : rhs; }
325template<
typename T>
static inline T KGClamp(T v, T mn, T mx) {
return (v < mn) ? mn : (v > mx) ? mx : v; }
326template<
typename T>
static inline T KGLerp(T a, T b,
float t) {
return (T)(a + (b - a) * t); }
327template<
typename T>
static inline void KGSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
328template<
typename T>
static inline T KGAddClampOverflow(T a, T b, T mn, T mx) {
if (b < 0 && (a < mn - b))
return mn;
if (b > 0 && (a > mx - b))
return mx;
return a + b; }
329template<
typename T>
static inline T KGSubClampOverflow(T a, T b, T mn, T mx) {
if (b > 0 && (a < mn + b))
return mn;
if (b < 0 && (a > mx + b))
return mx;
return a - b; }
331static inline KGVec2 KGMin(
const KGVec2& lhs,
const KGVec2& rhs) {
return KGVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
332static inline KGVec2 KGMax(
const KGVec2& lhs,
const KGVec2& rhs) {
return KGVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
333static inline KGVec2 KGClamp(
const KGVec2& v,
const KGVec2& mn,
KGVec2 mx) {
return KGVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
334static inline KGVec2 KGLerp(
const KGVec2& a,
const KGVec2& b,
float t) {
return KGVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
335static inline KGVec2 KGLerp(
const KGVec2& a,
const KGVec2& b,
const KGVec2& t) {
return KGVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
336static inline KGVec4 KGLerp(
const KGVec4& a,
const KGVec4& b,
float t) {
return KGVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
337static inline float KGSaturate(
float f) {
return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
338static inline float KGLengthSqr(
const KGVec2& lhs) {
return (lhs.x * lhs.x) + (lhs.y * lhs.y); }
339static inline float KGLengthSqr(
const KGVec4& lhs) {
return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); }
340static inline float KGInvLength(
const KGVec2& lhs,
float fail_value) {
float d = (lhs.x * lhs.x) + (lhs.y * lhs.y);
if (d > 0.0f)
return KGRsqrt(d);
return fail_value; }
341static inline float KGFloor(
float f) {
return (
float)(int)(f); }
342static inline float KGFloorSigned(
float f) {
return (
float)((f >= 0 || (float)(int)f == f) ? (int)f : (int)f - 1); }
343static inline KGVec2 KGFloor(
const KGVec2& v) {
return KGVec2((
float)(
int)(v.x), (
float)(
int)(v.y)); }
344static inline KGVec2 KGFloorSigned(
const KGVec2& v) {
return KGVec2(KGFloorSigned(v.x), KGFloorSigned(v.y)); }
345static inline int KGModPositive(
int a,
int b) {
return (a + b) % b; }
346static inline float KGDot(
const KGVec2& a,
const KGVec2& b) {
return a.x * b.x + a.y * b.y; }
347static inline KGVec2 KGRotate(
const KGVec2& v,
float cos_a,
float sin_a) {
return KGVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
348static inline float KGLinearSweep(
float current,
float target,
float speed) {
if (current < target)
return KGMin(current + speed, target);
if (current > target)
return KGMax(current - speed, target);
return current; }
350static inline bool KGIsFloatAboveGuaranteedIntegerPrecision(
float f) {
return f <= -16777216 || f >= 16777216; }
351static inline float KGExponentialMovingAverage(
float avg,
float sample,
int n) { avg -= avg / n; avg += sample / n;
return avg; }
361void KGTriangleBarycentricCoords(
const KGVec2& a,
const KGVec2& b,
const KGVec2& c,
const KGVec2& p,
float& out_u,
float& out_v,
float& out_w);
362inline float KGTriangleArea(
const KGVec2& a,
const KGVec2& b,
const KGVec2& c) {
return KGFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; }
363KarmaGuiDir KGGetDirQuadrantFromDelta(
float dx,
float dy);
371 constexpr KGVec1() : x(0.0f) { }
372 constexpr KGVec1(
float _x) : x(_x) { }
379 constexpr KGVec2ih() : x(0), y(0) {}
380 constexpr KGVec2ih(
short _x,
short _y) : x(_x), y(_y) {}
381 constexpr explicit KGVec2ih(
const KGVec2& rhs) : x((
short)rhs.x), y((
short)rhs.y) {}
391 constexpr KGRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {}
393 constexpr KGRect(
const KGVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
394 constexpr KGRect(
float x1,
float y1,
float x2,
float y2) : Min(x1, y1), Max(x2, y2) {}
396 KGVec2 GetCenter()
const {
return KGVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
397 KGVec2 GetSize()
const {
return KGVec2(Max.x - Min.x, Max.y - Min.y); }
398 float GetWidth()
const {
return Max.x - Min.x; }
399 float GetHeight()
const {
return Max.y - Min.y; }
400 float GetArea()
const {
return (Max.x - Min.x) * (Max.y - Min.y); }
401 KGVec2 GetTL()
const {
return Min; }
404 KGVec2 GetBR()
const {
return Max; }
405 bool Contains(
const KGVec2& p)
const {
return p.x >= Min.x && p.y >= Min.y && p.x < Max.x&& p.y < Max.y; }
406 bool Contains(
const KGRect& r)
const {
return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x <= Max.x && r.Max.y <= Max.y; }
407 bool Overlaps(
const KGRect& r)
const {
return r.Min.y < Max.y&& r.Max.y > Min.y && r.Min.x < Max.x&& r.Max.x > Min.x; }
408 void Add(
const KGVec2& p) {
if (Min.x > p.x) Min.x = p.x;
if (Min.y > p.y) Min.y = p.y;
if (Max.x < p.x) Max.x = p.x;
if (Max.y < p.y) Max.y = p.y; }
409 void Add(
const KGRect& r) {
if (Min.x > r.Min.x) Min.x = r.Min.x;
if (Min.y > r.Min.y) Min.y = r.Min.y;
if (Max.x < r.Max.x) Max.x = r.Max.x;
if (Max.y < r.Max.y) Max.y = r.Max.y; }
410 void Expand(
const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
411 void Expand(
const KGVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
412 void Translate(
const KGVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; }
413 void TranslateX(
float dx) { Min.x += dx; Max.x += dx; }
414 void TranslateY(
float dy) { Min.y += dy; Max.y += dy; }
415 void ClipWith(
const KGRect& r) { Min = KGMax(Min, r.Min); Max = KGMin(Max, r.Max); }
416 void ClipWithFull(
const KGRect& r) { Min = KGClamp(Min, r.Min, r.Max); Max = KGClamp(Max, r.Min, r.Max); }
417 void Floor() { Min.x = KG_FLOOR(Min.x); Min.y = KG_FLOOR(Min.y); Max.x = KG_FLOOR(Max.x); Max.y = KG_FLOOR(Max.y); }
418 bool IsInverted()
const {
return Min.x > Max.x || Min.y > Max.y; }
419 KGVec4 ToVec4()
const {
return KGVec4(Min.x, Min.y, Max.x, Max.y); }
423inline bool KGBitArrayTestBit(
const KGU32* arr,
int n) { KGU32 mask = (KGU32)1 << (n & 31);
return (arr[n >> 5] & mask) != 0; }
424inline void KGBitArrayClearBit(KGU32* arr,
int n) { KGU32 mask = (KGU32)1 << (n & 31); arr[n >> 5] &= ~mask; }
425inline void KGBitArraySetBit(KGU32* arr,
int n) { KGU32 mask = (KGU32)1 << (n & 31); arr[n >> 5] |= mask; }
426inline void KGBitArraySetBitRange(KGU32* arr,
int n,
int n2)
431 int a_mod = (n & 31);
432 int b_mod = (n2 > (n | 31) ? 31 : (n2 & 31)) + 1;
433 KGU32 mask = (KGU32)(((KGU64)1 << b_mod) - 1) & ~(KGU32)(((KGU64)1 << a_mod) - 1);
441template<
int BITCOUNT,
int OFFSET = 0>
444 KGU32 Storage[(BITCOUNT + 31) >> 5];
446 void ClearAllBits() { memset(Storage, 0,
sizeof(Storage)); }
447 void SetAllBits() { memset(Storage, 255,
sizeof(Storage)); }
448 bool TestBit(
int n)
const { n += OFFSET; KR_CORE_ASSERT(n >= 0 && n < BITCOUNT,
"");
return KGBitArrayTestBit(Storage, n); }
449 void SetBit(
int n) { n += OFFSET; KR_CORE_ASSERT(n >= 0 && n < BITCOUNT,
""); KGBitArraySetBit(Storage, n); }
450 void ClearBit(
int n) { n += OFFSET; KR_CORE_ASSERT(n >= 0 && n < BITCOUNT,
""); KGBitArrayClearBit(Storage, n); }
451 void SetBitRange(
int n,
int n2) { n += OFFSET; n2 += OFFSET; KR_CORE_ASSERT(n >= 0 && n < BITCOUNT&& n2 > n && n2 <= BITCOUNT,
""); KGBitArraySetBitRange(Storage, n, n2); }
452 bool operator[](
int n)
const { n += OFFSET; KR_CORE_ASSERT(n >= 0 && n < BITCOUNT,
"");
return KGBitArrayTestBit(Storage, n); }
460 void Create(
int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (
size_t)Storage.Size *
sizeof(Storage.Data[0])); }
461 void Clear() { Storage.clear(); }
462 bool TestBit(
int n)
const { KR_CORE_ASSERT(n < (Storage.Size << 5),
"");
return KGBitArrayTestBit(Storage.Data, n); }
463 void SetBit(
int n) { KR_CORE_ASSERT(n < (Storage.Size << 5),
""); KGBitArraySetBit(Storage.Data, n); }
464 void ClearBit(
int n) { KR_CORE_ASSERT(n < (Storage.Size << 5),
""); KGBitArrayClearBit(Storage.Data, n); }
476 inline KGSpan() { Data = DataEnd = NULL; }
477 inline KGSpan(T* data,
int size) { Data = data; DataEnd = data + size; }
478 inline KGSpan(T* data, T* data_end) { Data = data; DataEnd = data_end; }
480 inline void set(T* data,
int size) { Data = data; DataEnd = data + size; }
481 inline void set(T* data, T* data_end) { Data = data; DataEnd = data_end; }
482 inline int size()
const {
return (
int)(ptrdiff_t)(DataEnd - Data); }
483 inline int size_in_bytes()
const {
return (
int)(ptrdiff_t)(DataEnd - Data) * (int)
sizeof(T); }
484 inline T& operator[](
int i) { T* p = Data + i; KR_CORE_ASSERT(p >= Data && p < DataEnd,
"");
return *p; }
485 inline const T& operator[](
int i)
const {
const T* p = Data + i; KR_CORE_ASSERT(p >= Data && p < DataEnd,
"");
return *p; }
487 inline T* begin() {
return Data; }
488 inline const T* begin()
const {
return Data; }
489 inline T* end() {
return DataEnd; }
490 inline const T* end()
const {
return DataEnd; }
493 inline int index_from_ptr(
const T* it)
const { KR_CORE_ASSERT(it >= Data && it < DataEnd,
"");
const ptrdiff_t off = it - Data;
return (
int)off; }
509 inline void Reserve(
int n,
size_t sz,
int a = 4) { KR_CORE_ASSERT(n == CurrIdx && n < CHUNKS,
""); CurrOff = KG_MEMALIGN(CurrOff, a); Offsets[n] = CurrOff; Sizes[n] = (int)sz; CurrIdx++; CurrOff += (int)sz; }
510 inline int GetArenaSizeInBytes() {
return CurrOff; }
511 inline void SetArenaBasePtr(
void* base_ptr) { BasePtr = (
char*)base_ptr; }
512 inline void* GetSpanPtrBegin(
int n) { KR_CORE_ASSERT(n >= 0 && n < CHUNKS&& CurrIdx == CHUNKS,
"");
return (
void*)(BasePtr + Offsets[n]); }
513 inline void* GetSpanPtrEnd(
int n) { KR_CORE_ASSERT(n >= 0 && n < CHUNKS&& CurrIdx == CHUNKS,
"");
return (
void*)(BasePtr + Offsets[n] + Sizes[n]); }
515 inline void GetSpan(
int n,
KGSpan<T>* span) { span->set((T*)GetSpanPtrBegin(n), (T*)GetSpanPtrEnd(n)); }
521typedef int KGPoolIdx;
528 KGPoolIdx AliveCount;
530 KGPool() { FreeIdx = AliveCount = 0; }
532 T* GetByKey(KGGuiID key) {
int idx = Map.GetInt(key, -1);
return (idx != -1) ? &Buf[idx] : NULL; }
533 T* GetByIndex(KGPoolIdx n) {
return &Buf[n]; }
534 KGPoolIdx GetIndex(
const T* p)
const { KR_CORE_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size,
"");
return (KGPoolIdx)(p - Buf.Data); }
535 T* GetOrAddByKey(KGGuiID key) {
int* p_idx = Map.GetIntRef(key, -1);
if (*p_idx != -1)
return &Buf[*p_idx]; *p_idx = FreeIdx;
return Add(); }
536 bool Contains(
const T* p)
const {
return (p >= Buf.Data && p < Buf.Data + Buf.Size); }
537 void Clear() {
for (
int n = 0; n < Map.Data.Size; n++) {
int idx = Map.Data[n].val_i;
if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = AliveCount = 0; }
538 T* Add() {
int idx = FreeIdx;
if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; }
else { FreeIdx = *(
int*)&Buf[idx]; } KG_PLACEMENT_NEW(&Buf[idx]) T(); AliveCount++;
return &Buf[idx]; }
539 void Remove(KGGuiID key,
const T* p) { Remove(key, GetIndex(p)); }
540 void Remove(KGGuiID key, KGPoolIdx idx) { Buf[idx].~T(); *(
int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); AliveCount--; }
541 void Reserve(
int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); }
545 int GetAliveCount()
const {
return AliveCount; }
546 int GetBufSize()
const {
return Buf.Size; }
547 int GetMapSize()
const {
return Map.Data.Size; }
548 T* TryGetMapData(KGPoolIdx n) {
int idx = Map.Data[n].val_i;
if (idx == -1)
return NULL;
return GetByIndex(idx); }
549#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
550 int GetSize() {
return GetMapSize(); }
564 void clear() { Buf.clear(); }
565 bool empty()
const {
return Buf.Size == 0; }
566 int size()
const {
return Buf.Size; }
567 T* alloc_chunk(
size_t sz) {
size_t HDR_SZ = 4; sz = KG_MEMALIGN(HDR_SZ + sz, 4u);
int off = Buf.Size; Buf.resize(off + (
int)sz); ((
int*)(
void*)(Buf.Data + off))[0] = (int)sz;
return (T*)(
void*)(Buf.Data + off + (
int)HDR_SZ); }
568 T* begin() {
size_t HDR_SZ = 4;
if (!Buf.Data)
return NULL;
return (T*)(
void*)(Buf.Data + HDR_SZ); }
569 T* next_chunk(T* p) {
size_t HDR_SZ = 4; KR_CORE_ASSERT(p >= begin() && p < end(),
""); p = (T*)(
void*)((
char*)(
void*)p + chunk_size(p));
if (p == (T*)(
void*)((
char*)end() + HDR_SZ))
return (T*)0; KR_CORE_ASSERT(p < end(),
"");
return p; }
570 int chunk_size(
const T* p) {
return ((
const int*)p)[-1]; }
571 T* end() {
return (T*)(
void*)(Buf.Data + Buf.Size); }
572 int offset_from_ptr(
const T* p) { KR_CORE_ASSERT(p >= begin() && p < end(),
"");
const ptrdiff_t off = (
const char*)p - Buf.Data;
return (
int)off; }
573 T* ptr_from_offset(
int off) { KR_CORE_ASSERT(off >= 4 && off < Buf.Size,
"");
return (T*)(
void*)(Buf.Data + off); }
584 void clear() { LineOffsets.clear(); EndOffset = 0; }
585 int size() {
return LineOffsets.Size; }
586 const char* get_line_begin(
const char* base,
int n) {
return base + LineOffsets[n]; }
587 const char* get_line_end(
const char* base,
int n) {
return base + (n + 1 < LineOffsets.Size ? (LineOffsets[n + 1] - 1) : EndOffset); }
588 void append(
const char* base,
int old_size,
int new_size);
605#define KG_ROUNDUP_TO_EVEN(_V) ((((_V) + 1) / 2) * 2)
606#define KG_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN 4
607#define KG_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX 512
608#define KG_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR) KGClamp(KG_ROUNDUP_TO_EVEN((int)KGCeil(KG_PI / KGAcos(1 - KGMin((_MAXERROR), (_RAD)) / (_RAD)))), KG_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, KG_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX)
611#define KG_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(_N,_MAXERROR) ((_MAXERROR) / (1 - KGCos(KG_PI / KGMax((float)(_N), KG_PI))))
612#define KG_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_ERROR(_N,_RAD) ((1 - KGCos(KG_PI / KGMax((float)(_N), KG_PI))) / (_RAD))
615#ifndef KG_DRAWLIST_ARCFAST_TABLE_SIZE
616#define KG_DRAWLIST_ARCFAST_TABLE_SIZE 48
618#define IM_DRAWLIST_ARCFAST_SAMPLE_MAX KG_DRAWLIST_ARCFAST_TABLE_SIZE
627 float CurveTessellationTol;
628 float CircleSegmentMaxError;
629 KGVec4 ClipRectFullscreen;
630 KGDrawListFlags InitialFlags;
636 KGVec2 ArcFastVtx[KG_DRAWLIST_ARCFAST_TABLE_SIZE];
637 float ArcFastRadiusCutoff;
638 KGU8 CircleSegmentCounts[64];
642 void SetCircleTessellationMaxError(
float max_error);
649 void Clear() {
for (
int n = 0; n < KG_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
650 void ClearFreeMemory() {
for (
int n = 0; n < KG_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
651 int GetDrawListCount()
const {
int count = 0;
for (
int n = 0; n < KG_ARRAYSIZE(Layers); n++) count += Layers[n].Size;
return count; }
652 void FlattenIntoSingleLayer();
667 KGGuiItemFlags_None = 0,
668 KGGuiItemFlags_NoTabStop = 1 << 0,
669 KGGuiItemFlags_ButtonRepeat = 1 << 1,
670 KGGuiItemFlags_Disabled = 1 << 2,
671 KGGuiItemFlags_NoNav = 1 << 3,
672 KGGuiItemFlags_NoNavDefaultFocus = 1 << 4,
673 KGGuiItemFlags_SelectableDontClosePopup = 1 << 5,
674 KGGuiItemFlags_MixedValue = 1 << 6,
675 KGGuiItemFlags_ReadOnly = 1 << 7,
676 KGGuiItemFlags_NoWindowHoverableCheck = 1 << 8,
679 KGGuiItemFlags_Inputable = 1 << 10,
684enum KGGuiItemStatusFlags_
686 KGGuiItemStatusFlags_None = 0,
687 KGGuiItemStatusFlags_HoveredRect = 1 << 0,
688 KGGuiItemStatusFlags_HasDisplayRect = 1 << 1,
689 KGGuiItemStatusFlags_Edited = 1 << 2,
690 KGGuiItemStatusFlags_ToggledSelection = 1 << 3,
691 KGGuiItemStatusFlags_ToggledOpen = 1 << 4,
692 KGGuiItemStatusFlags_HasDeactivated = 1 << 5,
693 KGGuiItemStatusFlags_Deactivated = 1 << 6,
694 KGGuiItemStatusFlags_HoveredWindow = 1 << 7,
695 KGGuiItemStatusFlags_FocusedByTabbing = 1 << 8,
696 KGGuiItemStatusFlags_Visible = 1 << 9,
700enum KGGuiInputTextFlagsPrivate_
703 KGGuiInputTextFlags_Multiline = 1 << 26,
704 KGGuiInputTextFlags_NoMarkEdited = 1 << 27,
705 KGGuiInputTextFlags_MergedItem = 1 << 28,
709enum KGGuiButtonFlagsPrivate_
711 KGGuiButtonFlags_PressedOnClick = 1 << 4,
712 KGGuiButtonFlags_PressedOnClickRelease = 1 << 5,
713 KGGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 6,
714 KGGuiButtonFlags_PressedOnRelease = 1 << 7,
715 KGGuiButtonFlags_PressedOnDoubleClick = 1 << 8,
716 KGGuiButtonFlags_PressedOnDragDropHold = 1 << 9,
717 KGGuiButtonFlags_Repeat = 1 << 10,
718 KGGuiButtonFlags_FlattenChildren = 1 << 11,
719 KGGuiButtonFlags_AllowItemOverlap = 1 << 12,
720 KGGuiButtonFlags_DontClosePopups = 1 << 13,
722 KGGuiButtonFlags_AlignTextBaseLine = 1 << 15,
723 KGGuiButtonFlags_NoKeyModifiers = 1 << 16,
724 KGGuiButtonFlags_NoHoldingActiveId = 1 << 17,
725 KGGuiButtonFlags_NoNavFocus = 1 << 18,
726 KGGuiButtonFlags_NoHoveredOnFocus = 1 << 19,
727 KGGuiButtonFlags_NoSetKeyOwner = 1 << 20,
728 KGGuiButtonFlags_NoTestKeyOwner = 1 << 21,
729 KGGuiButtonFlags_PressedOnMask_ = KGGuiButtonFlags_PressedOnClick | KGGuiButtonFlags_PressedOnClickRelease | KGGuiButtonFlags_PressedOnClickReleaseAnywhere | KGGuiButtonFlags_PressedOnRelease | KGGuiButtonFlags_PressedOnDoubleClick | KGGuiButtonFlags_PressedOnDragDropHold,
730 KGGuiButtonFlags_PressedOnDefault_ = KGGuiButtonFlags_PressedOnClickRelease,
734enum KGGuiComboFlagsPrivate_
736 KGGuiComboFlags_CustomPreview = 1 << 20,
740enum KGGuiSliderFlagsPrivate_
742 KGGuiSliderFlags_Vertical = 1 << 20,
743 KGGuiSliderFlags_ReadOnly = 1 << 21,
747enum KGGuiSelectableFlagsPrivate_
750 KGGuiSelectableFlags_NoHoldingActiveID = 1 << 20,
751 KGGuiSelectableFlags_SelectOnNav = 1 << 21,
752 KGGuiSelectableFlags_SelectOnClick = 1 << 22,
753 KGGuiSelectableFlags_SelectOnRelease = 1 << 23,
754 KGGuiSelectableFlags_SpanAvailWidth = 1 << 24,
755 KGGuiSelectableFlags_DrawHoveredWhenHeld = 1 << 25,
756 KGGuiSelectableFlags_SetNavIdOnHover = 1 << 26,
757 KGGuiSelectableFlags_NoPadWithHalfSpacing = 1 << 27,
758 KGGuiSelectableFlags_NoSetKeyOwner = 1 << 28,
762enum KGGuiTreeNodeFlagsPrivate_
764 KGGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20,
767enum KGGuiSeparatorFlags_
769 KGGuiSeparatorFlags_None = 0,
770 KGGuiSeparatorFlags_Horizontal = 1 << 0,
771 KGGuiSeparatorFlags_Vertical = 1 << 1,
772 KGGuiSeparatorFlags_SpanAllColumns = 1 << 2,
777 KGGuiTextFlags_None = 0,
778 KGGuiTextFlags_NoWidthForLargeClippedText = 1 << 0,
781enum KGGuiTooltipFlags_
783 KGGuiTooltipFlags_None = 0,
784 KGGuiTooltipFlags_OverridePreviousTooltip = 1 << 0,
791 KGGuiLayoutType_Horizontal = 0,
792 KGGuiLayoutType_Vertical = 1
797 KGGuiLogType_None = 0,
801 KGGuiLogType_Clipboard,
815 KGGuiPlotType_Histogram,
818enum KGGuiPopupPositionPolicy
820 KGGuiPopupPositionPolicy_Default,
821 KGGuiPopupPositionPolicy_ComboBox,
822 KGGuiPopupPositionPolicy_Tooltip,
835 const char* PrintFmt;
840enum KGGuiDataTypePrivate_
842 KGGuiDataType_String = KGGuiDataType_COUNT + 1,
843 KGGuiDataType_Pointer,
857 KarmaGuiStyleVar VarIdx;
858 union {
int BackupInt[2];
float BackupFloat[2]; };
859 KGGuiStyleMod(KarmaGuiStyleVar idx,
int v) { VarIdx = idx; BackupInt[0] = v; }
860 KGGuiStyleMod(KarmaGuiStyleVar idx,
float v) { VarIdx = idx; BackupFloat[0] = v; }
861 KGGuiStyleMod(KarmaGuiStyleVar idx,
KGVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
869 KGVec2 BackupCursorMaxPos;
870 KGVec2 BackupCursorPosPrevLine;
871 float BackupPrevLineTextBaseOffset;
872 KGGuiLayoutType BackupLayout;
882 KGVec2 BackupCursorMaxPos;
885 KGVec2 BackupCurrLineSize;
886 float BackupCurrLineTextBaseOffset;
887 KGGuiID BackupActiveIdIsAlive;
888 bool BackupActiveIdPreviousFrameIsAlive;
889 bool BackupHoveredIdIsAlive;
897 KGU32 NextTotalWidth;
901 KGU16 OffsetShortcut;
906 void Update(
float spacing,
bool window_reappearing);
907 float DeclColumns(
float w_icon,
float w_label,
float w_shortcut,
float w_mark);
908 void CalcNextTotalWidth(
bool update_offsets);
917 int CurLenW, CurLenA;
927 bool SelectedAllMouseLock;
929 KarmaGuiInputTextFlags Flags;
932 void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); }
933 void ClearFreeMemory() { TextW.clear(); TextA.clear(); InitialTextA.clear(); }
934 int GetUndoAvailCount()
const {
return Stb.undostate.undo_point; }
935 int GetRedoAvailCount()
const {
return STB_TEXTEDIT_UNDOSTATECOUNT - Stb.undostate.redo_point; }
936 void OnKeyPressed(
int key);
939 void CursorAnimReset() { CursorAnim = -0.30f; }
940 void CursorClamp() { Stb.cursor = KGMin(Stb.cursor, CurLenW); Stb.select_start = KGMin(Stb.select_start, CurLenW); Stb.select_end = KGMin(Stb.select_end, CurLenW); }
941 bool HasSelection()
const {
return Stb.select_start != Stb.select_end; }
942 void ClearSelection() { Stb.select_start = Stb.select_end = Stb.cursor; }
943 int GetCursorPos()
const {
return Stb.cursor; }
944 int GetSelectionStart()
const {
return Stb.select_start; }
945 int GetSelectionEnd()
const {
return Stb.select_end; }
946 void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
957 KGGuiID OpenParentId;
961 KGGuiPopupData() { memset(
this, 0,
sizeof(*
this)); ParentNavLayer = OpenFrameCount = -1; }
964enum KGGuiNextWindowDataFlags_
966 KGGuiNextWindowDataFlags_None = 0,
967 KGGuiNextWindowDataFlags_HasPos = 1 << 0,
968 KGGuiNextWindowDataFlags_HasSize = 1 << 1,
969 KGGuiNextWindowDataFlags_HasContentSize = 1 << 2,
970 KGGuiNextWindowDataFlags_HasCollapsed = 1 << 3,
971 KGGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4,
972 KGGuiNextWindowDataFlags_HasFocus = 1 << 5,
973 KGGuiNextWindowDataFlags_HasBgAlpha = 1 << 6,
974 KGGuiNextWindowDataFlags_HasScroll = 1 << 7,
975 KGGuiNextWindowDataFlags_HasViewport = 1 << 8,
976 KGGuiNextWindowDataFlags_HasDock = 1 << 9,
977 KGGuiNextWindowDataFlags_HasWindowClass = 1 << 10,
983 KGGuiNextWindowDataFlags Flags;
984 KarmaGuiCond PosCond;
985 KarmaGuiCond SizeCond;
986 KarmaGuiCond CollapsedCond;
987 KarmaGuiCond DockCond;
995 KGRect SizeConstraintRect;
996 KarmaGuiSizeCallback SizeCallback;
997 void* SizeCallbackUserData;
1002 KGVec2 MenuBarOffsetMinVal;
1005 inline void ClearFlags() { Flags = KGGuiNextWindowDataFlags_None; }
1008enum KGGuiNextItemDataFlags_
1010 KGGuiNextItemDataFlags_None = 0,
1011 KGGuiNextItemDataFlags_HasWidth = 1 << 0,
1012 KGGuiNextItemDataFlags_HasOpen = 1 << 1,
1017 KGGuiNextItemDataFlags Flags;
1019 KGGuiID FocusScopeId;
1020 KarmaGuiCond OpenCond;
1024 inline void ClearFlags() { Flags = KGGuiNextItemDataFlags_None; }
1031 KGGuiItemFlags InFlags;
1032 KGGuiItemStatusFlags StatusFlags;
1042 short SizeOfIDStack;
1043 short SizeOfColorStack;
1044 short SizeOfStyleVarStack;
1045 short SizeOfFontStack;
1046 short SizeOfFocusScopeStack;
1047 short SizeOfGroupStack;
1048 short SizeOfItemFlagsStack;
1049 short SizeOfBeginPopupStack;
1050 short SizeOfDisabledStack;
1053 void SetToCurrentState();
1054 void CompareWithCurrentState();
1088#define KGGuiKey_LegacyNativeKey_BEGIN 0
1089#define KGGuiKey_LegacyNativeKey_END 512
1090#define KGGuiKey_Keyboard_BEGIN (KGGuiKey_NamedKey_BEGIN)
1091#define KGGuiKey_Keyboard_END (KGGuiKey_GamepadStart)
1092#define KGGuiKey_Gamepad_BEGIN (KGGuiKey_GamepadStart)
1093#define KGGuiKey_Gamepad_END (KGGuiKey_GamepadRStickDown + 1)
1094#define KGGuiKey_Mouse_BEGIN (KGGuiKey_MouseLeft)
1095#define KGGuiKey_Mouse_END (KGGuiKey_MouseWheelY + 1)
1096#define KGGuiKey_Aliases_BEGIN (KGGuiKey_Mouse_BEGIN)
1097#define KGGuiKey_Aliases_END (KGGuiKey_Mouse_END)
1100#define KGGuiKey_NavKeyboardTweakSlow KGGuiMod_Ctrl
1101#define KGGuiKey_NavKeyboardTweakFast KGGuiMod_Shift
1102#define KGGuiKey_NavGamepadTweakSlow KGGuiKey_GamepadL1
1103#define KGGuiKey_NavGamepadTweakFast KGGuiKey_GamepadR1
1104#define KGGuiKey_NavGamepadActivate KGGuiKey_GamepadFaceDown
1105#define KGGuiKey_NavGamepadCancel KGGuiKey_GamepadFaceRight
1106#define KGGuiKey_NavGamepadMenu KGGuiKey_GamepadFaceLeft
1107#define KGGuiKey_NavGamepadInput KGGuiKey_GamepadFaceUp
1109enum KGGuiInputEventType
1111 KGGuiInputEventType_None = 0,
1112 KGGuiInputEventType_MousePos,
1113 KGGuiInputEventType_MouseWheel,
1114 KGGuiInputEventType_MouseButton,
1115 KGGuiInputEventType_MouseViewport,
1116 KGGuiInputEventType_Key,
1117 KGGuiInputEventType_Text,
1118 KGGuiInputEventType_Focus,
1119 KGGuiInputEventType_COUNT
1122enum KGGuiInputSource
1124 KGGuiInputSource_None = 0,
1125 KGGuiInputSource_Mouse,
1126 KGGuiInputSource_Keyboard,
1127 KGGuiInputSource_Gamepad,
1128 KGGuiInputSource_Clipboard,
1129 KGGuiInputSource_Nav,
1130 KGGuiInputSource_COUNT
1145 KGGuiInputEventType Type;
1146 KGGuiInputSource Source;
1157 bool AddedByTestEngine;
1163#define KGGuiKeyOwner_Any ((KGGuiID)0)
1164#define KGGuiKeyOwner_None ((KGGuiID)-1)
1166typedef KGS16 KGGuiKeyRoutingIndex;
1171 KGGuiKeyRoutingIndex NextEntryIndex;
1173 KGU8 RoutingNextScore;
1174 KGGuiID RoutingCurr;
1175 KGGuiID RoutingNext;
1177 KGGuiKeyRoutingData() { NextEntryIndex = -1; Mods = 0; RoutingNextScore = 255; RoutingCurr = RoutingNext = KGGuiKeyOwner_None; }
1184 KGGuiKeyRoutingIndex Index[KGGuiKey_NamedKey_COUNT];
1189 void Clear() {
for (
int n = 0; n < KG_ARRAYSIZE(Index); n++) Index[n] = -1; Entries.clear(); EntriesNext.clear(); }
1199 bool LockUntilRelease;
1201 KGGuiKeyOwnerData() { OwnerCurr = OwnerNext = KGGuiKeyOwner_None; LockThisFrame = LockUntilRelease =
false; }
1207enum KGGuiInputFlagsPrivate_
1210 KGGuiInputFlags_RepeatRateDefault = 1 << 1,
1211 KGGuiInputFlags_RepeatRateNavMove = 1 << 2,
1212 KGGuiInputFlags_RepeatRateNavTweak = 1 << 3,
1213 KGGuiInputFlags_RepeatRateMask_ = KGGuiInputFlags_RepeatRateDefault | KGGuiInputFlags_RepeatRateNavMove | KGGuiInputFlags_RepeatRateNavTweak,
1216 KGGuiInputFlags_CondHovered = 1 << 4,
1217 KGGuiInputFlags_CondActive = 1 << 5,
1218 KGGuiInputFlags_CondDefault_ = KGGuiInputFlags_CondHovered | KGGuiInputFlags_CondActive,
1219 KGGuiInputFlags_CondMask_ = KGGuiInputFlags_CondHovered | KGGuiInputFlags_CondActive,
1222 KGGuiInputFlags_LockThisFrame = 1 << 6,
1223 KGGuiInputFlags_LockUntilRelease = 1 << 7,
1226 KGGuiInputFlags_RouteMask_ = KGGuiInputFlags_RouteFocused | KGGuiInputFlags_RouteGlobal | KGGuiInputFlags_RouteGlobalLow | KGGuiInputFlags_RouteGlobalHigh,
1227 KGGuiInputFlags_RouteExtraMask_ = KGGuiInputFlags_RouteAlways | KGGuiInputFlags_RouteUnlessBgFocused,
1228 KGGuiInputFlags_SupportedByIsKeyPressed = KGGuiInputFlags_Repeat | KGGuiInputFlags_RepeatRateMask_,
1229 KGGuiInputFlags_SupportedByShortcut = KGGuiInputFlags_Repeat | KGGuiInputFlags_RepeatRateMask_ | KGGuiInputFlags_RouteMask_ | KGGuiInputFlags_RouteExtraMask_,
1230 KGGuiInputFlags_SupportedBySetKeyOwner = KGGuiInputFlags_LockThisFrame | KGGuiInputFlags_LockUntilRelease,
1231 KGGuiInputFlags_SupportedBySetItemKeyOwner = KGGuiInputFlags_SupportedBySetKeyOwner | KGGuiInputFlags_CondMask_,
1242 bool PosToIndexConvert;
1243 KGS8 PosToIndexOffsetMin;
1244 KGS8 PosToIndexOffsetMax;
1254 float LossynessOffset;
1260 void Reset(
KarmaGuiListClipper* clipper) { ListClipper = clipper; StepNo = ItemsFrozen = 0; Ranges.resize(0); }
1267enum KGGuiActivateFlags_
1269 KGGuiActivateFlags_None = 0,
1270 KGGuiActivateFlags_PreferInput = 1 << 0,
1271 KGGuiActivateFlags_PreferTweak = 1 << 1,
1272 KGGuiActivateFlags_TryToPreserveState = 1 << 2,
1276enum KGGuiScrollFlags_
1278 KGGuiScrollFlags_None = 0,
1279 KGGuiScrollFlags_KeepVisibleEdgeX = 1 << 0,
1280 KGGuiScrollFlags_KeepVisibleEdgeY = 1 << 1,
1281 KGGuiScrollFlags_KeepVisibleCenterX = 1 << 2,
1282 KGGuiScrollFlags_KeepVisibleCenterY = 1 << 3,
1283 KGGuiScrollFlags_AlwaysCenterX = 1 << 4,
1284 KGGuiScrollFlags_AlwaysCenterY = 1 << 5,
1285 KGGuiScrollFlags_NoScrollParent = 1 << 6,
1286 KGGuiScrollFlags_MaskX_ = KGGuiScrollFlags_KeepVisibleEdgeX | KGGuiScrollFlags_KeepVisibleCenterX | KGGuiScrollFlags_AlwaysCenterX,
1287 KGGuiScrollFlags_MaskY_ = KGGuiScrollFlags_KeepVisibleEdgeY | KGGuiScrollFlags_KeepVisibleCenterY | KGGuiScrollFlags_AlwaysCenterY,
1290enum KGGuiNavHighlightFlags_
1292 KGGuiNavHighlightFlags_None = 0,
1293 KGGuiNavHighlightFlags_TypeDefault = 1 << 0,
1294 KGGuiNavHighlightFlags_TypeThin = 1 << 1,
1295 KGGuiNavHighlightFlags_AlwaysDraw = 1 << 2,
1296 KGGuiNavHighlightFlags_NoRounding = 1 << 3,
1299enum KGGuiNavMoveFlags_
1301 KGGuiNavMoveFlags_None = 0,
1302 KGGuiNavMoveFlags_LoopX = 1 << 0,
1303 KGGuiNavMoveFlags_LoopY = 1 << 1,
1304 KGGuiNavMoveFlags_WrapX = 1 << 2,
1305 KGGuiNavMoveFlags_WrapY = 1 << 3,
1306 KGGuiNavMoveFlags_AllowCurrentNavId = 1 << 4,
1307 KGGuiNavMoveFlags_AlsoScoreVisibleSet = 1 << 5,
1308 KGGuiNavMoveFlags_ScrollToEdgeY = 1 << 6,
1309 KGGuiNavMoveFlags_Forwarded = 1 << 7,
1310 KGGuiNavMoveFlags_DebugNoResult = 1 << 8,
1311 KGGuiNavMoveFlags_FocusApi = 1 << 9,
1312 KGGuiNavMoveFlags_Tabbing = 1 << 10,
1313 KGGuiNavMoveFlags_Activate = 1 << 11,
1314 KGGuiNavMoveFlags_DontSetNavHighlight = 1 << 12,
1319 KGGuiNavLayer_Main = 0,
1320 KGGuiNavLayer_Menu = 1,
1328 KGGuiID FocusScopeId;
1330 KGGuiItemFlags InFlags;
1336 void Clear() { Window = NULL; ID = FocusScopeId = 0; InFlags = 0; DistBox = DistCenter = DistAxial = FLT_MAX; }
1344enum KGGuiOldColumnFlags_
1346 KGGuiOldColumnFlags_None = 0,
1347 KGGuiOldColumnFlags_NoBorder = 1 << 0,
1348 KGGuiOldColumnFlags_NoResize = 1 << 1,
1349 KGGuiOldColumnFlags_NoPreserveWidths = 1 << 2,
1350 KGGuiOldColumnFlags_NoForceWithinWindow = 1 << 3,
1351 KGGuiOldColumnFlags_GrowParentContentsSize = 1 << 4,
1357 float OffsetNormBeforeResize;
1358 KGGuiOldColumnFlags Flags;
1367 KGGuiOldColumnFlags Flags;
1369 bool IsBeingResized;
1372 float OffMinX, OffMaxX;
1373 float LineMinY, LineMaxY;
1374 float HostCursorPosY;
1375 float HostCursorMaxPosX;
1376 KGRect HostInitialClipRect;
1377 KGRect HostBackupClipRect;
1378 KGRect HostBackupParentWorkRect;
1389#define DOCKING_HOST_DRAW_CHANNEL_BG 0
1390#define DOCKING_HOST_DRAW_CHANNEL_FG 1
1395enum KGGuiDockNodeFlagsPrivate_
1398 KGGuiDockNodeFlags_DockSpace = 1 << 10,
1399 KGGuiDockNodeFlags_CentralNode = 1 << 11,
1400 KGGuiDockNodeFlags_NoTabBar = 1 << 12,
1401 KGGuiDockNodeFlags_HiddenTabBar = 1 << 13,
1402 KGGuiDockNodeFlags_NoWindowMenuButton = 1 << 14,
1403 KGGuiDockNodeFlags_NoCloseButton = 1 << 15,
1404 KGGuiDockNodeFlags_NoDocking = 1 << 16,
1405 KGGuiDockNodeFlags_NoDockingSplitMe = 1 << 17,
1406 KGGuiDockNodeFlags_NoDockingSplitOther = 1 << 18,
1407 KGGuiDockNodeFlags_NoDockingOverMe = 1 << 19,
1408 KGGuiDockNodeFlags_NoDockingOverOther = 1 << 20,
1409 KGGuiDockNodeFlags_NoDockingOverEmpty = 1 << 21,
1410 KGGuiDockNodeFlags_NoResizeX = 1 << 22,
1411 KGGuiDockNodeFlags_NoResizeY = 1 << 23,
1412 KGGuiDockNodeFlags_SharedFlagsInheritMask_ = ~0,
1413 KGGuiDockNodeFlags_NoResizeFlagsMask_ = KGGuiDockNodeFlags_NoResize | KGGuiDockNodeFlags_NoResizeX | KGGuiDockNodeFlags_NoResizeY,
1414 KGGuiDockNodeFlags_LocalFlagsMask_ = KGGuiDockNodeFlags_NoSplit | KGGuiDockNodeFlags_NoResizeFlagsMask_ | KGGuiDockNodeFlags_AutoHideTabBar | KGGuiDockNodeFlags_DockSpace | KGGuiDockNodeFlags_CentralNode | KGGuiDockNodeFlags_NoTabBar | KGGuiDockNodeFlags_HiddenTabBar | KGGuiDockNodeFlags_NoWindowMenuButton | KGGuiDockNodeFlags_NoCloseButton | KGGuiDockNodeFlags_NoDocking,
1415 KGGuiDockNodeFlags_LocalFlagsTransferMask_ = KGGuiDockNodeFlags_LocalFlagsMask_ & ~KGGuiDockNodeFlags_DockSpace,
1416 KGGuiDockNodeFlags_SavedFlagsMask_ = KGGuiDockNodeFlags_NoResizeFlagsMask_ | KGGuiDockNodeFlags_DockSpace | KGGuiDockNodeFlags_CentralNode | KGGuiDockNodeFlags_NoTabBar | KGGuiDockNodeFlags_HiddenTabBar | KGGuiDockNodeFlags_NoWindowMenuButton | KGGuiDockNodeFlags_NoCloseButton | KGGuiDockNodeFlags_NoDocking
1420enum KGGuiDataAuthority_
1422 KGGuiDataAuthority_Auto,
1423 KGGuiDataAuthority_DockNode,
1424 KGGuiDataAuthority_Window,
1427enum KGGuiDockNodeState
1429 KGGuiDockNodeState_Unknown,
1430 KGGuiDockNodeState_HostWindowHiddenBecauseSingleWindow,
1431 KGGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing,
1432 KGGuiDockNodeState_HostWindowVisible,
1439 KarmaGuiDockNodeFlags SharedFlags;
1440 KarmaGuiDockNodeFlags LocalFlags;
1441 KarmaGuiDockNodeFlags LocalFlagsInWindows;
1442 KarmaGuiDockNodeFlags MergedFlags;
1443 KGGuiDockNodeState State;
1451 KGGuiAxis SplitAxis;
1459 int CountNodeWithWindows;
1461 int LastFrameActive;
1462 int LastFrameFocused;
1463 KGGuiID LastFocusedNodeId;
1464 KGGuiID SelectedTabId;
1465 KGGuiID WantCloseTabId;
1466 KGGuiDataAuthority AuthorityForPos : 3;
1467 KGGuiDataAuthority AuthorityForSize : 3;
1468 KGGuiDataAuthority AuthorityForViewport : 3;
1471 bool IsBgDrawnThisFrame : 1;
1472 bool HasCloseButton : 1;
1473 bool HasWindowMenuButton : 1;
1474 bool HasCentralNodeChild : 1;
1475 bool WantCloseAll : 1;
1476 bool WantLockSizeOnce : 1;
1477 bool WantMouseMove : 1;
1478 bool WantHiddenTabBarUpdate : 1;
1479 bool WantHiddenTabBarToggle : 1;
1483 bool IsRootNode()
const {
return ParentNode == NULL; }
1484 bool IsDockSpace()
const {
return (MergedFlags & KGGuiDockNodeFlags_DockSpace) != 0; }
1485 bool IsFloatingNode()
const {
return ParentNode == NULL && (MergedFlags & KGGuiDockNodeFlags_DockSpace) == 0; }
1486 bool IsCentralNode()
const {
return (MergedFlags & KGGuiDockNodeFlags_CentralNode) != 0; }
1487 bool IsHiddenTabBar()
const {
return (MergedFlags & KGGuiDockNodeFlags_HiddenTabBar) != 0; }
1488 bool IsNoTabBar()
const {
return (MergedFlags & KGGuiDockNodeFlags_NoTabBar) != 0; }
1489 bool IsSplitNode()
const {
return ChildNodes[0] != NULL; }
1490 bool IsLeafNode()
const {
return ChildNodes[0] == NULL; }
1491 bool IsEmpty()
const {
return ChildNodes[0] == NULL && Windows.Size == 0; }
1492 KGRect Rect()
const {
return KGRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
1494 void SetLocalFlags(KarmaGuiDockNodeFlags flags) { LocalFlags = flags; UpdateMergedFlags(); }
1495 void UpdateMergedFlags() { MergedFlags = SharedFlags | LocalFlags | LocalFlagsInWindows; }
1502enum KGGuiWindowDockStyleCol
1504 KGGuiWindowDockStyleCol_Text,
1505 KGGuiWindowDockStyleCol_Tab,
1506 KGGuiWindowDockStyleCol_TabHovered,
1507 KGGuiWindowDockStyleCol_TabActive,
1508 KGGuiWindowDockStyleCol_TabUnfocused,
1509 KGGuiWindowDockStyleCol_TabUnfocusedActive,
1510 KGGuiWindowDockStyleCol_COUNT
1515 KGU32 Colors[KGGuiWindowDockStyleCol_COUNT];
1523 bool WantFullRebuild;
1538 int LastFrameActive;
1539 int LastFrontMostStampCount;
1540 KGGuiID LastNameHash;
1544 short PlatformMonitor;
1546 int DrawListsLastFrame[2];
1555 KGVec2 BuildWorkOffsetMin;
1556 KGVec2 BuildWorkOffsetMax;
1558 KGGuiViewportP() { Idx = -1; LastFrameActive = DrawListsLastFrame[0] = DrawListsLastFrame[1] = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; Window = NULL; DrawLists[0] = DrawLists[1] = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize =
KGVec2(FLT_MAX, FLT_MAX); }
1559 ~KGGuiViewportP() {
if (DrawLists[0]) KG_DELETE(DrawLists[0]);
if (DrawLists[1]) KG_DELETE(DrawLists[1]); }
1560 void ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize =
false; }
1563 KGVec2 CalcWorkRectPos(
const KGVec2& off_min)
const {
return KGVec2(Pos.x + off_min.x, Pos.y + off_min.y); }
1564 KGVec2 CalcWorkRectSize(
const KGVec2& off_min,
const KGVec2& off_max)
const {
return KGVec2(KGMax(0.0f, Size.x - off_min.x + off_max.x), KGMax(0.0f, Size.y - off_min.y + off_max.y)); }
1565 void UpdateWorkRect() { WorkPos = CalcWorkRectPos(WorkOffsetMin); WorkSize = CalcWorkRectSize(WorkOffsetMin, WorkOffsetMax); }
1568 KGRect GetMainRect()
const {
return KGRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
1569 KGRect GetWorkRect()
const {
return KGRect(WorkPos.x, WorkPos.y, WorkPos.x + WorkSize.x, WorkPos.y + WorkSize.y); }
1570 KGRect GetBuildWorkRect()
const {
KGVec2 pos = CalcWorkRectPos(BuildWorkOffsetMin);
KGVec2 size = CalcWorkRectSize(BuildWorkOffsetMin, BuildWorkOffsetMax);
return KGRect(pos.x, pos.y, pos.x + size.x, pos.y + size.y); }
1594 char* GetName() {
return (
char*)(
this + 1); }
1599 const char* TypeName;
1617enum KGGuiLocKey :
int
1619 ImGuiLocKey_TableSizeOne,
1620 ImGuiLocKey_TableSizeAllFit,
1621 ImGuiLocKey_TableSizeAllDefault,
1622 ImGuiLocKey_TableResetOrder,
1623 ImGuiLocKey_WindowingMainMenuBar,
1624 ImGuiLocKey_WindowingPopup,
1625 ImGuiLocKey_WindowingUntitled,
1626 ImGuiLocKey_DockingHideTabBar,
1640enum KGGuiDebugLogFlags_
1643 KGGuiDebugLogFlags_None = 0,
1644 KGGuiDebugLogFlags_EventActiveId = 1 << 0,
1645 KGGuiDebugLogFlags_EventFocus = 1 << 1,
1646 KGGuiDebugLogFlags_EventPopup = 1 << 2,
1647 KGGuiDebugLogFlags_EventNav = 1 << 3,
1648 KGGuiDebugLogFlags_EventClipper = 1 << 4,
1649 KGGuiDebugLogFlags_EventIO = 1 << 5,
1650 KGGuiDebugLogFlags_EventDocking = 1 << 6,
1651 KGGuiDebugLogFlags_EventViewport = 1 << 7,
1652 KGGuiDebugLogFlags_EventMask_ = KGGuiDebugLogFlags_EventActiveId | KGGuiDebugLogFlags_EventFocus | KGGuiDebugLogFlags_EventPopup | KGGuiDebugLogFlags_EventNav | KGGuiDebugLogFlags_EventClipper | KGGuiDebugLogFlags_EventIO | KGGuiDebugLogFlags_EventDocking | KGGuiDebugLogFlags_EventViewport,
1653 KGGuiDebugLogFlags_OutputToTTY = 1 << 10,
1660 bool ShowWindowsRects;
1661 bool ShowWindowsBeginOrder;
1662 bool ShowTablesRects;
1663 bool ShowDrawCmdMesh;
1664 bool ShowDrawCmdBoundingBoxes;
1665 bool ShowDockingNodes;
1666 int ShowWindowsRectsType;
1667 int ShowTablesRectsType;
1671 ShowDebugLog = ShowStackTool = ShowWindowsRects = ShowWindowsBeginOrder = ShowTablesRects =
false;
1672 ShowDrawCmdMesh =
true;
1673 ShowDrawCmdBoundingBoxes =
true;
1674 ShowDockingNodes =
false;
1675 ShowWindowsRectsType = ShowTablesRectsType = -1;
1682 KGS8 QueryFrameCount;
1684 KarmaGuiDataType DataType : 8;
1693 int LastActiveFrame;
1697 bool CopyToClipboardOnCtrlC;
1698 float CopyToClipboardLastTime;
1700 KGGuiStackTool() { memset(
this, 0,
sizeof(*
this)); CopyToClipboardLastTime = -FLT_MAX; }
1708enum ImGuiContextHookType { ImGuiContextHookType_NewFramePre, ImGuiContextHookType_NewFramePost, ImGuiContextHookType_EndFramePre, ImGuiContextHookType_EndFramePost, ImGuiContextHookType_RenderPre, ImGuiContextHookType_RenderPost, ImGuiContextHookType_Shutdown, ImGuiContextHookType_PendingRemoval_ };
1713 ImGuiContextHookType Type;
1715 ImGuiContextHookCallback Callback;
1727 bool FontAtlasOwnedByContext;
1733 KarmaGuiConfigFlags ConfigFlagsCurrFrame;
1734 KarmaGuiConfigFlags ConfigFlagsLastFrame;
1741 int FrameCountEnded;
1742 int FrameCountPlatformEnded;
1743 int FrameCountRendered;
1744 bool WithinFrameScope;
1745 bool WithinFrameScopeWithImplicitWindow;
1746 bool WithinEndChild;
1748 bool TestEngineHookItems;
1757 int WindowsActiveCount;
1758 KGVec2 WindowsHoverPadding;
1764 KGVec2 WheelingWindowRefMousePos;
1765 int WheelingWindowStartFrame;
1766 float WheelingWindowReleaseTimer;
1767 KGVec2 WheelingWindowWheelRemainder;
1771 KGGuiID DebugHookIdInfo;
1773 KGGuiID HoveredIdPreviousFrame;
1774 bool HoveredIdAllowOverlap;
1775 bool HoveredIdDisabled;
1776 float HoveredIdTimer;
1777 float HoveredIdNotActiveTimer;
1779 KGGuiID ActiveIdIsAlive;
1780 float ActiveIdTimer;
1781 bool ActiveIdIsJustActivated;
1782 bool ActiveIdAllowOverlap;
1783 bool ActiveIdNoClearOnFocusLoss;
1784 bool ActiveIdHasBeenPressedBefore;
1785 bool ActiveIdHasBeenEditedBefore;
1786 bool ActiveIdHasBeenEditedThisFrame;
1787 KGVec2 ActiveIdClickOffset;
1789 KGGuiInputSource ActiveIdSource;
1790 int ActiveIdMouseButton;
1791 KGGuiID ActiveIdPreviousFrame;
1792 bool ActiveIdPreviousFrameIsAlive;
1793 bool ActiveIdPreviousFrameHasBeenEditedBefore;
1795 KGGuiID LastActiveId;
1796 float LastActiveIdTimer;
1804 KGU32 ActiveIdUsingNavDirMask;
1805 bool ActiveIdUsingAllKeyboardKeys;
1806#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
1807 KGU32 ActiveIdUsingNavInputMask;
1811 KGGuiID CurrentFocusScopeId;
1812 KGGuiItemFlags CurrentItemFlags;
1813 KGGuiID DebugLocateId;
1831 float CurrentDpiScale;
1835 KGGuiID PlatformLastFocusedViewportId;
1837 int ViewportFrontMostStampCount;
1842 KGGuiID NavFocusScopeId;
1843 KGGuiID NavActivateId;
1844 KGGuiID NavActivateDownId;
1845 KGGuiID NavActivatePressedId;
1846 KGGuiID NavActivateInputId;
1847 KGGuiActivateFlags NavActivateFlags;
1848 KGGuiID NavJustMovedToId;
1849 KGGuiID NavJustMovedToFocusScopeId;
1850 KarmaGuiKeyChord NavJustMovedToKeyMods;
1851 KGGuiID NavNextActivateId;
1852 KGGuiActivateFlags NavNextActivateFlags;
1853 KGGuiInputSource NavInputSource;
1854 KGGuiNavLayer NavLayer;
1856 bool NavMousePosDirty;
1857 bool NavDisableHighlight;
1858 bool NavDisableMouseHover;
1862 bool NavInitRequest;
1863 bool NavInitRequestFromMove;
1864 KGGuiID NavInitResultId;
1865 KGRect NavInitResultRectRel;
1866 bool NavMoveSubmitted;
1867 bool NavMoveScoringItems;
1868 bool NavMoveForwardToNextFrame;
1869 KGGuiNavMoveFlags NavMoveFlags;
1870 KGGuiScrollFlags NavMoveScrollFlags;
1871 KarmaGuiKeyChord NavMoveKeyMods;
1872 KarmaGuiDir NavMoveDir;
1873 KarmaGuiDir NavMoveDirForDebug;
1874 KarmaGuiDir NavMoveClipDir;
1876 KGRect NavScoringNoClipRect;
1877 int NavScoringDebugCount;
1879 int NavTabbingCounter;
1886 KarmaGuiKeyChord ConfigNavWindowingKeyNext;
1887 KarmaGuiKeyChord ConfigNavWindowingKeyPrev;
1891 float NavWindowingTimer;
1892 float NavWindowingHighlightAlpha;
1893 bool NavWindowingToggleLayer;
1894 KGVec2 NavWindowingAccumDeltaPos;
1895 KGVec2 NavWindowingAccumDeltaSize;
1899 KarmaGuiMouseCursor MouseCursor;
1902 bool DragDropActive;
1903 bool DragDropWithinSource;
1904 bool DragDropWithinTarget;
1905 KarmaGuiDragDropFlags DragDropSourceFlags;
1906 int DragDropSourceFrameCount;
1907 int DragDropMouseButton;
1909 KGRect DragDropTargetRect;
1910 KGGuiID DragDropTargetId;
1911 KarmaGuiDragDropFlags DragDropAcceptFlags;
1912 float DragDropAcceptIdCurrRectSurface;
1913 KGGuiID DragDropAcceptIdCurr;
1914 KGGuiID DragDropAcceptIdPrev;
1915 int DragDropAcceptFrameCount;
1916 KGGuiID DragDropHoldJustPressedId;
1918 unsigned char DragDropPayloadBufLocal[16];
1921 int ClipperTempDataStacked;
1926 int TablesTempDataStacked;
1939 KGGuiID HoverDelayId;
1940 KGGuiID HoverDelayIdPreviousFrame;
1941 float HoverDelayTimer;
1942 float HoverDelayClearTimer;
1945 KGVec2 MouseLastValidPos;
1947 KGFont InputTextPasswordFont;
1948 KGGuiID TempInputId;
1949 KarmaGuiColorEditFlags ColorEditOptions;
1950 float ColorEditLastHue;
1951 float ColorEditLastSat;
1952 KGU32 ColorEditLastColor;
1955 float SliderGrabClickOffset;
1956 float SliderCurrentAccum;
1957 bool SliderCurrentAccumDirty;
1958 bool DragCurrentAccumDirty;
1959 float DragCurrentAccum;
1960 float DragSpeedDefaultRatio;
1961 float ScrollbarClickDeltaToGrabCenter;
1962 float DisabledAlphaBackup;
1963 short DisabledStackSize;
1964 short TooltipOverrideCount;
1971 KGGuiID PlatformImeViewport;
1972 char PlatformLocaleDecimalPoint;
1979 bool SettingsLoaded;
1980 float SettingsDirtyTimer;
1989 const char* LocalizationTable[ImGuiLocKey_COUNT];
1993 KGGuiLogType LogType;
1994 ImFileHandle LogFile;
1996 const char* LogNextPrefix;
1997 const char* LogNextSuffix;
1999 bool LogLineFirstItem;
2001 int LogDepthToExpand;
2002 int LogDepthToExpandDefault;
2005 KGGuiDebugLogFlags DebugLogFlags;
2008 KGU8 DebugLocateFrames;
2009 bool DebugItemPickerActive;
2010 KGU8 DebugItemPickerMouseButton;
2011 KGGuiID DebugItemPickerBreakId;
2017 float FramerateSecPerFrame[60];
2018 int FramerateSecPerFrameIdx;
2019 int FramerateSecPerFrameCount;
2020 float FramerateSecPerFrameAccum;
2021 int WantCaptureMouseNextFrame;
2022 int WantCaptureKeyboardNextFrame;
2023 int WantTextInputNextFrame;
2027 : InputTextState(
this)
2029 Initialized =
false;
2030 ConfigFlagsCurrFrame = ConfigFlagsLastFrame = KGGuiConfigFlags_None;
2031 FontAtlasOwnedByContext = shared_font_atlas ? false :
true;
2033 FontSize = FontBaseSize = 0.0f;
2034 IO.Fonts = shared_font_atlas ? shared_font_atlas : KG_NEW(
KGFontAtlas)();
2037 FrameCountEnded = FrameCountPlatformEnded = FrameCountRendered = -1;
2038 WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild =
false;
2039 GcCompactAll =
false;
2040 TestEngineHookItems =
false;
2043 WindowsActiveCount = 0;
2044 CurrentWindow = NULL;
2045 HoveredWindow = NULL;
2046 HoveredWindowUnderMovingWindow = NULL;
2047 MovingWindow = NULL;
2048 WheelingWindow = NULL;
2049 WheelingWindowStartFrame = -1;
2050 WheelingWindowReleaseTimer = 0.0f;
2052 DebugHookIdInfo = 0;
2053 HoveredId = HoveredIdPreviousFrame = 0;
2054 HoveredIdAllowOverlap =
false;
2055 HoveredIdDisabled =
false;
2056 HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
2058 ActiveIdIsAlive = 0;
2059 ActiveIdTimer = 0.0f;
2060 ActiveIdIsJustActivated =
false;
2061 ActiveIdAllowOverlap =
false;
2062 ActiveIdNoClearOnFocusLoss =
false;
2063 ActiveIdHasBeenPressedBefore =
false;
2064 ActiveIdHasBeenEditedBefore =
false;
2065 ActiveIdHasBeenEditedThisFrame =
false;
2066 ActiveIdClickOffset =
KGVec2(-1, -1);
2067 ActiveIdWindow = NULL;
2068 ActiveIdSource = KGGuiInputSource_None;
2069 ActiveIdMouseButton = -1;
2070 ActiveIdPreviousFrame = 0;
2071 ActiveIdPreviousFrameIsAlive =
false;
2072 ActiveIdPreviousFrameHasBeenEditedBefore =
false;
2073 ActiveIdPreviousFrameWindow = NULL;
2075 LastActiveIdTimer = 0.0f;
2077 ActiveIdUsingNavDirMask = 0x00;
2078 ActiveIdUsingAllKeyboardKeys =
false;
2079#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
2080 ActiveIdUsingNavInputMask = 0x00;
2083 CurrentFocusScopeId = 0;
2084 CurrentItemFlags = KGGuiItemFlags_None;
2087 CurrentDpiScale = 0.0f;
2088 CurrentViewport = NULL;
2089 MouseViewport = MouseLastHoveredViewport = NULL;
2090 PlatformLastFocusedViewportId = 0;
2091 ViewportFrontMostStampCount = 0;
2094 NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavActivateInputId = 0;
2095 NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
2096 NavActivateFlags = NavNextActivateFlags = KGGuiActivateFlags_None;
2097 NavJustMovedToKeyMods = KGGuiMod_None;
2098 NavInputSource = KGGuiInputSource_None;
2099 NavLayer = KGGuiNavLayer_Main;
2100 NavIdIsAlive =
false;
2101 NavMousePosDirty =
false;
2102 NavDisableHighlight =
true;
2103 NavDisableMouseHover =
false;
2104 NavAnyRequest =
false;
2105 NavInitRequest =
false;
2106 NavInitRequestFromMove =
false;
2107 NavInitResultId = 0;
2108 NavMoveSubmitted =
false;
2109 NavMoveScoringItems =
false;
2110 NavMoveForwardToNextFrame =
false;
2111 NavMoveFlags = KGGuiNavMoveFlags_None;
2112 NavMoveScrollFlags = KGGuiScrollFlags_None;
2113 NavMoveKeyMods = KGGuiMod_None;
2114 NavMoveDir = NavMoveDirForDebug = NavMoveClipDir = KGGuiDir_None;
2115 NavScoringDebugCount = 0;
2117 NavTabbingCounter = 0;
2119 ConfigNavWindowingKeyNext = KGGuiMod_Ctrl | KGGuiKey_Tab;
2120 ConfigNavWindowingKeyPrev = KGGuiMod_Ctrl | KGGuiMod_Shift | KGGuiKey_Tab;
2121 NavWindowingTarget = NavWindowingTargetAnim = NavWindowingListWindow = NULL;
2122 NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
2123 NavWindowingToggleLayer =
false;
2126 MouseCursor = KGGuiMouseCursor_Arrow;
2128 DragDropActive = DragDropWithinSource = DragDropWithinTarget =
false;
2129 DragDropSourceFlags = KGGuiDragDropFlags_None;
2130 DragDropSourceFrameCount = -1;
2131 DragDropMouseButton = -1;
2132 DragDropTargetId = 0;
2133 DragDropAcceptFlags = KGGuiDragDropFlags_None;
2134 DragDropAcceptIdCurrRectSurface = 0.0f;
2135 DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
2136 DragDropAcceptFrameCount = -1;
2137 DragDropHoldJustPressedId = 0;
2138 memset(DragDropPayloadBufLocal, 0,
sizeof(DragDropPayloadBufLocal));
2140 ClipperTempDataStacked = 0;
2142 CurrentTable = NULL;
2143 TablesTempDataStacked = 0;
2144 CurrentTabBar = NULL;
2146 HoverDelayId = HoverDelayIdPreviousFrame = 0;
2147 HoverDelayTimer = HoverDelayClearTimer = 0.0f;
2150 ColorEditOptions = KGGuiColorEditFlags_DefaultOptions_;
2151 ColorEditLastHue = ColorEditLastSat = 0.0f;
2152 ColorEditLastColor = 0;
2153 SliderGrabClickOffset = 0.0f;
2154 SliderCurrentAccum = 0.0f;
2155 SliderCurrentAccumDirty =
false;
2156 DragCurrentAccumDirty =
false;
2157 DragCurrentAccum = 0.0f;
2158 DragSpeedDefaultRatio = 1.0f / 100.0f;
2159 ScrollbarClickDeltaToGrabCenter = 0.0f;
2160 DisabledAlphaBackup = 0.0f;
2161 DisabledStackSize = 0;
2162 TooltipOverrideCount = 0;
2164 PlatformImeData.InputPos =
KGVec2(0.0f, 0.0f);
2165 PlatformImeDataPrev.InputPos =
KGVec2(-1.0f, -1.0f);
2166 PlatformImeViewport = 0;
2167 PlatformLocaleDecimalPoint =
'.';
2169 SettingsLoaded =
false;
2170 SettingsDirtyTimer = 0.0f;
2173 memset(LocalizationTable, 0,
sizeof(LocalizationTable));
2176 LogType = KGGuiLogType_None;
2177 LogNextPrefix = LogNextSuffix = NULL;
2179 LogLinePosY = FLT_MAX;
2180 LogLineFirstItem =
false;
2182 LogDepthToExpand = LogDepthToExpandDefault = 2;
2184 DebugLogFlags = KGGuiDebugLogFlags_OutputToTTY;
2186 DebugLocateFrames = 0;
2187 DebugItemPickerActive =
false;
2188 DebugItemPickerMouseButton = KGGuiMouseButton_Left;
2189 DebugItemPickerBreakId = 0;
2190 DebugHoveredDockNode = NULL;
2192 memset(FramerateSecPerFrame, 0,
sizeof(FramerateSecPerFrame));
2193 FramerateSecPerFrameIdx = FramerateSecPerFrameCount = 0;
2194 FramerateSecPerFrameAccum = 0.0f;
2195 WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
2210 KGVec2 CursorPosPrevLine;
2216 float CurrLineTextBaseOffset;
2217 float PrevLineTextBaseOffset;
2223 KGVec2 CursorStartPosLossyness;
2226 KGGuiNavLayer NavLayerCurrent;
2227 short NavLayersActiveMask;
2228 short NavLayersActiveMaskNext;
2229 bool NavHideHighlightOneFrame;
2233 bool MenuBarAppending;
2237 KGU32 TreeJumpToParentOnPopMask;
2241 int CurrentTableIdx;
2242 KGGuiLayoutType LayoutType;
2243 KGGuiLayoutType ParentLayoutType;
2258 KarmaGuiWindowFlags Flags, FlagsPreviousFrame;
2263 int ViewportAllowPlatformMonitorExtend;
2269 KGVec2 ContentSizeExplicit;
2272 float WindowRounding;
2273 float WindowBorderSize;
2274 float DecoOuterSizeX1, DecoOuterSizeY1;
2275 float DecoOuterSizeX2, DecoOuterSizeY2;
2276 float DecoInnerSizeX1, DecoInnerSizeY1;
2284 KGVec2 ScrollTargetCenterRatio;
2285 KGVec2 ScrollTargetEdgeSnapDist;
2287 bool bUseCustomBgColor;
2288 bool ScrollbarX, ScrollbarY;
2294 bool WantCollapseToggle;
2298 bool IsFallbackWindow;
2299 bool IsExplicitChild;
2300 bool HasCloseButton;
2301 signed char ResizeBorderHeld;
2303 short BeginCountPreviousFrame;
2304 short BeginOrderWithinParent;
2305 short BeginOrderWithinContext;
2308 KGS8 AutoFitFramesX, AutoFitFramesY;
2309 KGS8 AutoFitChildAxises;
2310 bool AutoFitOnlyGrows;
2311 KarmaGuiDir AutoPosLastDirection;
2312 KGS8 HiddenFramesCanSkipItems;
2313 KGS8 HiddenFramesCannotSkipItems;
2314 KGS8 HiddenFramesForRenderOnly;
2315 KGS8 DisableInputsFrames;
2316 KarmaGuiCond SetWindowPosAllowFlags : 8;
2317 KarmaGuiCond SetWindowSizeAllowFlags : 8;
2318 KarmaGuiCond SetWindowCollapsedAllowFlags : 8;
2319 KarmaGuiCond SetWindowDockAllowFlags : 8;
2321 KGVec2 SetWindowPosPivot;
2334 KGRect ContentRegionRect;
2338 int LastFrameActive;
2339 int LastFrameJustFocused;
2340 float LastTimeActive;
2341 float ItemWidthDefault;
2344 float FontWindowScale;
2359 KGGuiID NavLastIds[KGGuiNavLayer_COUNT];
2360 KGRect NavRectRel[KGGuiNavLayer_COUNT];
2361 KGGuiID NavRootFocusScopeId;
2363 int MemoryDrawListIdxCapacity;
2364 int MemoryDrawListVtxCapacity;
2365 bool MemoryCompacted;
2368 bool DockIsActive : 1;
2369 bool DockNodeIsVisible : 1;
2370 bool DockTabIsVisible : 1;
2371 bool DockTabWantClose : 1;
2377 KGGuiItemStatusFlags DockTabItemStatusFlags;
2384 KGGuiID GetID(
const char* str,
const char* str_end = NULL);
2385 KGGuiID GetID(
const void* ptr);
2386 KGGuiID GetID(
int n);
2387 KGGuiID GetIDFromRectangle(
const KGRect& r_abs);
2390 KGRect Rect()
const {
return KGRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
2391 float CalcFontSize()
const;
2392 float TitleBarHeight()
const;
2393 KGRect TitleBarRect()
const {
return KGRect(Pos,
KGVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
2394 float MenuBarHeight()
const;
2395 KGRect MenuBarRect()
const {
float y1 = Pos.y + TitleBarHeight();
return KGRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
2403enum KGGuiTabBarFlagsPrivate_
2405 KGGuiTabBarFlags_DockNode = 1 << 20,
2406 KGGuiTabBarFlags_IsFocused = 1 << 21,
2407 KGGuiTabBarFlags_SaveSettings = 1 << 22,
2411enum KGGuiTabItemFlagsPrivate_
2413 KGGuiTabItemFlags_SectionMask_ = KGGuiTabItemFlags_Leading | KGGuiTabItemFlags_Trailing,
2414 KGGuiTabItemFlags_NoCloseButton = 1 << 20,
2415 KGGuiTabItemFlags_Button = 1 << 21,
2416 KGGuiTabItemFlags_Unsorted = 1 << 22,
2417 KGGuiTabItemFlags_Preview = 1 << 23,
2424 KarmaGuiTabItemFlags Flags;
2426 int LastFrameVisible;
2427 int LastFrameSelected;
2431 float RequestedWidth;
2434 KGS16 IndexDuringLayout;
2437 KGGuiTabItem() { memset(
this, 0,
sizeof(*
this)); LastFrameVisible = LastFrameSelected = -1; RequestedWidth = -1.0f; NameOffset = -1; BeginOrder = IndexDuringLayout = -1; }
2444 KarmaGuiTabBarFlags Flags;
2446 KGGuiID SelectedTabId;
2447 KGGuiID NextSelectedTabId;
2448 KGGuiID VisibleTabId;
2449 int CurrFrameVisible;
2450 int PrevFrameVisible;
2452 float CurrTabsContentsHeight;
2453 float PrevTabsContentsHeight;
2455 float WidthAllTabsIdeal;
2456 float ScrollingAnim;
2457 float ScrollingTarget;
2458 float ScrollingTargetDistToVisibility;
2459 float ScrollingSpeed;
2460 float ScrollingRectMinX;
2461 float ScrollingRectMaxX;
2462 KGGuiID ReorderRequestTabId;
2463 KGS16 ReorderRequestOffset;
2466 bool VisibleTabWasSubmitted;
2468 KGS16 TabsActiveCount;
2469 KGS16 LastTabItemIdx;
2476 int GetTabOrder(
const KGGuiTabItem* tab)
const {
return Tabs.index_from_ptr(tab); }
2480 return tab->Window->Name;
2481 KR_CORE_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size,
"");
2482 return TabsNames.Buf.Data + tab->NameOffset;
2490#define KG_COL32_DISABLE KG_COL32(0,0,0,1)
2491#define KARMAGUI_TABLE_MAX_COLUMNS 64
2492#define KARMAGUI_TABLE_MAX_DRAW_CHANNELS (4 + 64 * 2)
2495typedef KGS8 KGGuiTableColumnIdx;
2496typedef KGU8 KGGuiTableDrawChannelIdx;
2504 KarmaGuiTableColumnFlags Flags;
2510 float StretchWeight;
2511 float InitStretchWeightOrWidth;
2517 float ContentMaxXFrozen;
2518 float ContentMaxXUnfrozen;
2519 float ContentMaxXHeadersUsed;
2520 float ContentMaxXHeadersIdeal;
2522 KGGuiTableColumnIdx DisplayOrder;
2523 KGGuiTableColumnIdx IndexWithinEnabledSet;
2524 KGGuiTableColumnIdx PrevEnabledColumn;
2525 KGGuiTableColumnIdx NextEnabledColumn;
2526 KGGuiTableColumnIdx SortOrder;
2527 KGGuiTableDrawChannelIdx DrawChannelCurrent;
2528 KGGuiTableDrawChannelIdx DrawChannelFrozen;
2529 KGGuiTableDrawChannelIdx DrawChannelUnfrozen;
2532 bool IsUserEnabledNextFrame;
2535 bool IsRequestOutput;
2537 bool IsPreserveWidthAuto;
2538 KGS8 NavLayerCurrent;
2540 KGU8 CannotSkipItemsQueue;
2541 KGU8 SortDirection : 2;
2542 KGU8 SortDirectionsAvailCount : 2;
2543 KGU8 SortDirectionsAvailMask : 4;
2544 KGU8 SortDirectionsAvailList;
2548 memset(
this, 0,
sizeof(*
this));
2549 StretchWeight = WidthRequest = -1.0f;
2551 DisplayOrder = IndexWithinEnabledSet = -1;
2552 PrevEnabledColumn = NextEnabledColumn = -1;
2554 SortDirection = KGGuiSortDirection_None;
2555 DrawChannelCurrent = DrawChannelFrozen = DrawChannelUnfrozen = (KGU8)-1;
2564 KGGuiTableColumnIdx Column;
2570 float LastOuterHeight;
2571 float LastFirstRowHeight;
2572 float LastFrozenHeight;
2581 KarmaGuiTableFlags Flags;
2587 KGU64 EnabledMaskByDisplayOrder;
2588 KGU64 EnabledMaskByIndex;
2589 KGU64 VisibleMaskByIndex;
2590 KGU64 RequestOutputMaskByIndex;
2591 KarmaGuiTableFlags SettingsLoadedFlags;
2593 int LastFrameActive;
2597 KGS16 InstanceCurrent;
2598 KGS16 InstanceInteracted;
2602 float RowTextBaseline;
2603 float RowIndentOffsetX;
2604 KarmaGuiTableRowFlags RowFlags : 16;
2605 KarmaGuiTableRowFlags LastRowFlags : 16;
2606 int RowBgColorCounter;
2607 KGU32 RowBgColor[2];
2608 KGU32 BorderColorStrong;
2609 KGU32 BorderColorLight;
2613 float MinColumnWidth;
2614 float OuterPaddingX;
2617 float CellSpacingX1;
2618 float CellSpacingX2;
2620 float ColumnsGivenWidth;
2621 float ColumnsAutoFitWidth;
2622 float ColumnsStretchSumWeights;
2623 float ResizedColumnNextWidth;
2624 float ResizeLockMinContentsX2;
2631 KGRect Bg0ClipRectForDrawCmd;
2632 KGRect Bg2ClipRectForDrawCmd;
2634 KGRect HostBackupInnerClipRect;
2644 KGGuiTableColumnIdx SortSpecsCount;
2645 KGGuiTableColumnIdx ColumnsEnabledCount;
2646 KGGuiTableColumnIdx ColumnsEnabledFixedCount;
2647 KGGuiTableColumnIdx DeclColumnsCount;
2648 KGGuiTableColumnIdx HoveredColumnBody;
2649 KGGuiTableColumnIdx HoveredColumnBorder;
2650 KGGuiTableColumnIdx AutoFitSingleColumn;
2651 KGGuiTableColumnIdx ResizedColumn;
2652 KGGuiTableColumnIdx LastResizedColumn;
2653 KGGuiTableColumnIdx HeldHeaderColumn;
2654 KGGuiTableColumnIdx ReorderColumn;
2655 KGGuiTableColumnIdx ReorderColumnDir;
2656 KGGuiTableColumnIdx LeftMostEnabledColumn;
2657 KGGuiTableColumnIdx RightMostEnabledColumn;
2658 KGGuiTableColumnIdx LeftMostStretchedColumn;
2659 KGGuiTableColumnIdx RightMostStretchedColumn;
2660 KGGuiTableColumnIdx ContextPopupColumn;
2661 KGGuiTableColumnIdx FreezeRowsRequest;
2662 KGGuiTableColumnIdx FreezeRowsCount;
2663 KGGuiTableColumnIdx FreezeColumnsRequest;
2664 KGGuiTableColumnIdx FreezeColumnsCount;
2665 KGGuiTableColumnIdx RowCellDataCurrent;
2666 KGGuiTableDrawChannelIdx DummyDrawChannel;
2667 KGGuiTableDrawChannelIdx Bg2DrawChannelCurrent;
2668 KGGuiTableDrawChannelIdx Bg2DrawChannelUnfrozen;
2669 bool IsLayoutLocked;
2671 bool IsInitializing;
2672 bool IsSortSpecsDirty;
2673 bool IsUsingHeaders;
2674 bool IsContextPopupOpen;
2675 bool IsSettingsRequestLoad;
2676 bool IsSettingsDirty;
2677 bool IsDefaultDisplayOrder;
2678 bool IsResetAllRequest;
2679 bool IsResetDisplayOrderRequest;
2680 bool IsUnfrozenRows;
2681 bool IsDefaultSizingPolicy;
2682 bool HasScrollbarYCurr;
2683 bool HasScrollbarYPrev;
2684 bool MemoryCompacted;
2687 KGGuiTable() { memset(
this, 0,
sizeof(*
this)); LastFrameActive = -1; }
2697 float LastTimeActive;
2702 KGRect HostBackupWorkRect;
2703 KGRect HostBackupParentWorkRect;
2704 KGVec2 HostBackupPrevLineSize;
2705 KGVec2 HostBackupCurrLineSize;
2706 KGVec2 HostBackupCursorMaxPos;
2707 KGVec1 HostBackupColumnsOffset;
2708 float HostBackupItemWidth;
2709 int HostBackupItemWidthStackSize;
2717 float WidthOrWeight;
2719 KGGuiTableColumnIdx Index;
2720 KGGuiTableColumnIdx DisplayOrder;
2721 KGGuiTableColumnIdx SortOrder;
2722 KGU8 SortDirection : 2;
2728 WidthOrWeight = 0.0f;
2731 DisplayOrder = SortOrder = -1;
2732 SortDirection = KGGuiSortDirection_None;
2742 KarmaGuiTableFlags SaveFlags;
2744 KGGuiTableColumnIdx ColumnsCount;
2745 KGGuiTableColumnIdx ColumnsCountMax;
2758 static KarmaGuiMemAllocFunc GImAllocatorAllocFunc;
2759 static KarmaGuiMemFreeFunc GImAllocatorFreeFunc;
2760 static void* GImAllocatorUserData;
2763 static void SetCurrentWindow(
KGGuiWindow* window);
2764 static void FindHoveredWindow();
2765 static KGGuiWindow* CreateNewWindow(
const char* name, KarmaGuiWindowFlags flags);
2779 static const char* GetClipboardTextFn_DefaultImpl(
void* user_data);
2780 static void SetClipboardTextFn_DefaultImpl(
void* user_data,
const char* text);
2784 static void NavUpdate();
2785 static void NavUpdateWindowing();
2786 static void NavUpdateWindowingOverlay();
2787 static void NavUpdateCancelRequest();
2788 static void NavUpdateCreateMoveRequest();
2789 static void NavUpdateCreateTabbingRequest();
2790 static float NavUpdatePageUpPageDown();
2791 static inline void NavUpdateAnyRequestFlag();
2792 static void NavUpdateCreateWrappingRequest();
2793 static void NavEndFrame();
2796 static void NavProcessItem();
2797 static void NavProcessItemForTabbingRequest(KGGuiID
id);
2798 static KGVec2 NavCalcPreferredRefPos();
2799 static void NavSaveLastChildNavWindowIntoParent(
KGGuiWindow* nav_window);
2801 static void NavRestoreLayer(KGGuiNavLayer layer);
2802 static void NavRestoreHighlightAfterMove();
2803 static int FindWindowFocusIndex(
KGGuiWindow* window);
2806 static void ErrorCheckNewFrameSanityChecks();
2807 static void ErrorCheckEndFrameSanityChecks();
2808 static void UpdateDebugToolItemPicker();
2809 static void UpdateDebugToolStackQueries();
2812 static void UpdateKeyboardInputs();
2813 static void UpdateMouseInputs();
2814 static void UpdateMouseWheel();
2818 static void UpdateSettings();
2819 static bool UpdateWindowManualResize(
KGGuiWindow* window,
const KGVec2& size_auto_fit,
int* border_held,
int resize_grip_count, KGU32 resize_grip_col[4],
const KGRect& visibility_rect);
2820 static void RenderWindowOuterBorders(
KGGuiWindow* window);
2821 static void RenderWindowDecorations(
KGGuiWindow* window,
const KGRect& title_bar_rect,
bool title_bar_is_highlight,
bool handle_borders_and_resize_grips,
int resize_grip_count,
const KGU32 resize_grip_col[4],
float resize_grip_draw_size);
2822 static void RenderWindowTitleBarContents(
KGGuiWindow* window,
const KGRect& title_bar_rect,
const char* name,
bool* p_open);
2823 static void RenderDimmedBackgroundBehindWindow(
KGGuiWindow* window, KGU32 col);
2824 static void RenderDimmedBackgrounds();
2828 const static KGGuiID IMGUI_VIEWPORT_DEFAULT_ID = 0x11111111;
2831 static void UpdateViewportsNewFrame();
2832 static void UpdateViewportsEndFrame();
2833 static void WindowSelectViewport(
KGGuiWindow* window);
2836 static bool UpdateTryMergeWindowIntoHostViewports(
KGGuiWindow* window);
2837 static bool GetWindowAlwaysWantOwnViewport(
KGGuiWindow* window);
2838 static int FindPlatformMonitorForPos(
const KGVec2& pos);
2839 static int FindPlatformMonitorForRect(
const KGRect& r);
2840 static void UpdateViewportPlatformMonitor(
KGGuiViewportP* viewport);
2853 static KGGuiWindow* FindWindowByName(
const char* name);
2854 static void UpdateWindowParentAndRootLinks(
KGGuiWindow* window, KarmaGuiWindowFlags flags,
KGGuiWindow* parent_window);
2856 static bool IsWindowChildOf(
KGGuiWindow* window,
KGGuiWindow* potential_parent,
bool popup_hierarchy,
bool dock_hierarchy);
2859 static bool IsWindowNavFocusable(
KGGuiWindow* window);
2860 static void SetWindowPos(
KGGuiWindow* window,
const KGVec2& pos, KarmaGuiCond cond = 0);
2861 static void SetWindowSize(
KGGuiWindow* window,
const KGVec2& size, KarmaGuiCond cond = 0);
2862 static void SetWindowCollapsed(
KGGuiWindow* window,
bool collapsed, KarmaGuiCond cond = 0);
2864 static inline KGRect WindowRectAbsToRel(
KGGuiWindow* window,
const KGRect& r) {
KGVec2 off = window->DC.CursorStartPos;
return KGRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
2865 static inline KGRect WindowRectRelToAbs(
KGGuiWindow* window,
const KGRect& r) {
KGVec2 off = window->DC.CursorStartPos;
return KGRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
2870 static void BringWindowToFocusFront(
KGGuiWindow* window);
2871 static void BringWindowToDisplayFront(
KGGuiWindow* window);
2872 static void BringWindowToDisplayBack(
KGGuiWindow* window);
2874 static int FindWindowDisplayIndex(
KGGuiWindow* window);
2878 static void SetCurrentFont(
KGFont* font);
2879 static KGFont* GetDefaultFont();
2880 static inline KGDrawList* GetForegroundDrawList(
KGGuiWindow* window) {
return KarmaGui::GetForegroundDrawList(window->Viewport); }
2883 static void Initialize();
2884 static void Shutdown();
2887 static void UpdateInputEvents(
bool trickle_fast_inputs);
2888 static void UpdateHoveredWindowAndCaptureFlags();
2889 static void StartMouseMovingWindow(
KGGuiWindow* window);
2891 static void UpdateMouseMovingWindowNewFrame();
2892 static void UpdateMouseMovingWindowEndFrame();
2896 static void RemoveContextHook(
KarmaGuiContext* context, KGGuiID hook_to_remove);
2897 static void CallContextHooks(
KarmaGuiContext* context, ImGuiContextHookType type);
2901 static void ScaleWindowsInViewport(
KGGuiViewportP* viewport,
float scale);
2906 static KGGuiViewportP* FindHoveredViewportFromPlatformWindowStack(
const KGVec2& mouse_platform_pos);
2909 static void MarkIniSettingsDirty();
2910 static void MarkIniSettingsDirty(
KGGuiWindow* window);
2911 static void ClearIniSettings();
2916 static void RemoveSettingsHandler(
const char* type_name);
2920 static void LocalizeRegisterEntries(
const KGGuiLocEntry* entries,
int count);
2921 static const char* LocalizeGetMsg(KGGuiLocKey key);
2924 static void SetScrollX(
KGGuiWindow* window,
float scroll_x);
2925 static void SetScrollY(
KGGuiWindow* window,
float scroll_y);
2926 static void SetScrollFromPosX(
KGGuiWindow* window,
float local_x,
float center_x_ratio);
2927 static void SetScrollFromPosY(
KGGuiWindow* window,
float local_y,
float center_y_ratio);
2930 static void ScrollToItem(KGGuiScrollFlags flags = 0);
2931 static void ScrollToRect(
KGGuiWindow* window,
const KGRect& rect, KGGuiScrollFlags flags = 0);
2935 static inline KGGuiItemStatusFlags GetItemStatusFlags() {
KarmaGuiContext& g = *GKarmaGui;
return g.LastItemData.StatusFlags; }
2936 static inline KGGuiItemFlags GetItemFlags() {
KarmaGuiContext& g = *GKarmaGui;
return g.LastItemData.InFlags; }
2937 static inline KGGuiID GetActiveID() {
KarmaGuiContext& g = *GKarmaGui;
return g.ActiveId; }
2938 static inline KGGuiID GetFocusID() {
KarmaGuiContext& g = *GKarmaGui;
return g.NavId; }
2939 static void SetActiveID(KGGuiID
id,
KGGuiWindow* window);
2940 static void SetFocusID(KGGuiID
id,
KGGuiWindow* window);
2941 static void ClearActiveID();
2942 static KGGuiID GetHoveredID();
2943 static void SetHoveredID(KGGuiID
id);
2944 static void KeepAliveID(KGGuiID
id);
2945 static void MarkItemEdited(KGGuiID
id);
2946 static void PushOverrideID(KGGuiID
id);
2947 static KGGuiID GetIDWithSeed(
const char* str_id_begin,
const char* str_id_end, KGGuiID seed);
2950 static void ItemSize(
const KGVec2& size,
float text_baseline_y = -1.0f);
2951 static inline void ItemSize(
const KGRect& bb,
float text_baseline_y = -1.0f) { ItemSize(bb.GetSize(), text_baseline_y); }
2952 static bool ItemAdd(
const KGRect& bb, KGGuiID
id,
const KGRect* nav_bb = NULL, KGGuiItemFlags extra_flags = 0);
2953 static bool ItemHoverable(
const KGRect& bb, KGGuiID
id);
2954 static bool IsClippedEx(
const KGRect& bb, KGGuiID
id);
2955 static void SetLastItemData(KGGuiID item_id, KGGuiItemFlags in_flags, KGGuiItemStatusFlags status_flags,
const KGRect& item_rect);
2956 static KGVec2 CalcItemSize(
KGVec2 size,
float default_w,
float default_h);
2957 static float CalcWrapWidthForPos(
const KGVec2& pos,
float wrap_pos_x);
2958 static void PushMultiItemsWidths(
int components,
float width_full);
2959 static bool IsItemToggledSelection();
2960 static KGVec2 GetContentRegionMaxAbs();
2964 static void PushItemFlag(KGGuiItemFlags option,
bool enabled);
2965 static void PopItemFlag();
2968 static void LogBegin(KGGuiLogType type,
int auto_open_depth);
2969 static void LogToBuffer(
int auto_open_depth = -1);
2970 static void LogRenderedText(
const KGVec2* ref_pos,
const char* text,
const char* text_end = NULL);
2971 static void LogSetNextTextDecoration(
const char* prefix,
const char* suffix);
2974 static bool BeginChildEx(
const char* name, KGGuiID
id,
const KGVec2& size_arg,
bool border, KarmaGuiWindowFlags flags);
2975 static void OpenPopupEx(KGGuiID
id, KarmaGuiPopupFlags popup_flags = KGGuiPopupFlags_None);
2976 static void ClosePopupToLevel(
int remaining,
bool restore_focus_to_window_under_popup);
2977 static void ClosePopupsOverWindow(
KGGuiWindow* ref_window,
bool restore_focus_to_window_under_popup);
2978 static void ClosePopupsExceptModals();
2979 static bool IsPopupOpen(KGGuiID
id, KarmaGuiPopupFlags popup_flags);
2980 static bool BeginPopupEx(KGGuiID
id, KarmaGuiWindowFlags extra_flags);
2981 static void BeginTooltipEx(KGGuiTooltipFlags tooltip_flags, KarmaGuiWindowFlags extra_window_flags);
2984 static KGGuiWindow* GetTopMostAndVisiblePopupModal();
2986 static KGVec2 FindBestWindowPosForPopupEx(
const KGVec2& ref_pos,
const KGVec2& size, KarmaGuiDir* last_dir,
const KGRect& r_outer,
const KGRect& r_avoid, KGGuiPopupPositionPolicy policy);
2989 static bool BeginViewportSideBar(
const char* name,
KarmaGuiViewport* viewport, KarmaGuiDir dir,
float size, KarmaGuiWindowFlags window_flags);
2990 static bool BeginMenuEx(
const char* label,
const char* icon,
bool enabled =
true);
2991 static bool MenuItemEx(
const char* label,
const char* icon,
const char* shortcut = NULL,
bool selected =
false,
bool enabled =
true);
2994 static bool BeginComboPopup(KGGuiID popup_id,
const KGRect& bb, KarmaGuiComboFlags flags);
2995 static bool BeginComboPreview();
2996 static void EndComboPreview();
2999 static void NavInitWindow(
KGGuiWindow* window,
bool force_reinit);
3000 static void NavInitRequestApplyResult();
3001 static bool NavMoveRequestButNoResultYet();
3002 static void NavMoveRequestSubmit(KarmaGuiDir move_dir, KarmaGuiDir clip_dir, KGGuiNavMoveFlags move_flags, KGGuiScrollFlags scroll_flags);
3003 static void NavMoveRequestForward(KarmaGuiDir move_dir, KarmaGuiDir clip_dir, KGGuiNavMoveFlags move_flags, KGGuiScrollFlags scroll_flags);
3005 static void NavMoveRequestCancel();
3006 static void NavMoveRequestApplyResult();
3007 static void NavMoveRequestTryWrapping(
KGGuiWindow* window, KGGuiNavMoveFlags move_flags);
3008 static void ActivateItem(KGGuiID
id);
3010 static void SetNavID(KGGuiID
id, KGGuiNavLayer nav_layer, KGGuiID focus_scope_id,
const KGRect& rect_rel);
3014 static inline bool IsNamedKey(KarmaGuiKey key) {
return key >= KGGuiKey_NamedKey_BEGIN && key < KGGuiKey_NamedKey_END; }
3015 static inline bool IsNamedKeyOrModKey(KarmaGuiKey key) {
return (key >= KGGuiKey_NamedKey_BEGIN && key < KGGuiKey_NamedKey_END) || key == KGGuiMod_Ctrl || key == KGGuiMod_Shift || key == KGGuiMod_Alt || key == KGGuiMod_Super || key == KGGuiMod_Shortcut; }
3016 static inline bool IsLegacyKey(KarmaGuiKey key) {
return key >= KGGuiKey_LegacyNativeKey_BEGIN && key < KGGuiKey_LegacyNativeKey_END; }
3017 static inline bool IsKeyboardKey(KarmaGuiKey key) {
return key >= KGGuiKey_Keyboard_BEGIN && key < KGGuiKey_Keyboard_END; }
3018 static inline bool IsGamepadKey(KarmaGuiKey key) {
return key >= KGGuiKey_Gamepad_BEGIN && key < KGGuiKey_Gamepad_END; }
3019 static inline bool IsMouseKey(KarmaGuiKey key) {
return key >= KGGuiKey_Mouse_BEGIN && key < KGGuiKey_Mouse_END; }
3020 static inline bool IsAliasKey(KarmaGuiKey key) {
return key >= KGGuiKey_Aliases_BEGIN && key < KGGuiKey_Aliases_END; }
3021 static KarmaGuiKeyChord ConvertShortcutMod(KarmaGuiKeyChord key_chord);
3022 static KarmaGuiKey ConvertSingleModFlagToKey(KarmaGuiKey key);
3024 static void GetKeyChordName(KarmaGuiKeyChord key_chord,
char* out_buf,
int out_buf_size);
3025 static inline KarmaGuiKey MouseButtonToKey(KarmaGuiMouseButton button) { KR_CORE_ASSERT(button >= 0 && button < KGGuiMouseButton_COUNT,
"");
return (KarmaGuiKey)(KGGuiKey_MouseLeft + button); }
3026 static bool IsMouseDragPastThreshold(KarmaGuiMouseButton button,
float lock_threshold = -1.0f);
3027 static KGVec2 GetKeyMagnitude2d(KarmaGuiKey key_left, KarmaGuiKey key_right, KarmaGuiKey key_up, KarmaGuiKey key_down);
3028 static float GetNavTweakPressedAmount(KGGuiAxis axis);
3029 static int CalcTypematicRepeatAmount(
float t0,
float t1,
float repeat_delay,
float repeat_rate);
3030 static void GetTypematicRepeatRate(KarmaGuiInputFlags flags,
float* repeat_delay,
float* repeat_rate);
3031 static void SetActiveIdUsingAllKeyboardKeys();
3032 static inline bool IsActiveIdUsingNavDir(KarmaGuiDir dir);
3045 static KGGuiID GetKeyOwner(KarmaGuiKey key);
3046 static void SetKeyOwner(KarmaGuiKey key, KGGuiID owner_id, KarmaGuiInputFlags flags = 0);
3047 static void SetItemKeyOwner(KarmaGuiKey key, KarmaGuiInputFlags flags = 0);
3048 static bool TestKeyOwner(KarmaGuiKey key, KGGuiID owner_id);
3057 static bool IsKeyDown(KarmaGuiKey key, KGGuiID owner_id);
3058 static bool IsKeyPressed(KarmaGuiKey key, KGGuiID owner_id, KarmaGuiInputFlags flags = 0);
3059 static bool IsKeyReleased(KarmaGuiKey key, KGGuiID owner_id);
3060 static bool IsMouseDown(KarmaGuiMouseButton button, KGGuiID owner_id);
3061 static bool IsMouseClicked(KarmaGuiMouseButton button, KGGuiID owner_id, KarmaGuiInputFlags flags = 0);
3062 static bool IsMouseReleased(KarmaGuiMouseButton button, KGGuiID owner_id);
3069 static bool SetShortcutRouting(KarmaGuiKeyChord key_chord, KGGuiID owner_id = 0, KarmaGuiInputFlags flags = 0);
3070 static bool TestShortcutRouting(KarmaGuiKeyChord key_chord, KGGuiID owner_id);
3077 static void DockContextClearNodes(
KarmaGuiContext* ctx, KGGuiID root_id,
bool clear_settings_refs);
3091 static void DockNodeEndAmendTabBar();
3092 static inline KGGuiDockNode* DockNodeGetRootNode(
KGGuiDockNode* node) {
while (node->ParentNode) node = node->ParentNode;
return node; }
3093 static inline bool DockNodeIsInHierarchyOf(
KGGuiDockNode* node,
KGGuiDockNode* parent) {
while (node) {
if (node == parent)
return true; node = node->ParentNode; }
return false; }
3094 static inline int DockNodeGetDepth(
const KGGuiDockNode* node) {
int depth = 0;
while (node->ParentNode) { node = node->ParentNode; depth++; }
return depth; }
3095 static inline KGGuiID DockNodeGetWindowMenuButtonId(
const KGGuiDockNode* node) {
return KGHashStr(
"#COLLAPSE", 0, node->ID); }
3097 static bool GetWindowAlwaysWantOwnTabBar(
KGGuiWindow* window);
3098 static void BeginDocked(
KGGuiWindow* window,
bool* p_open);
3099 static void BeginDockableDragDropSource(
KGGuiWindow* window);
3100 static void BeginDockableDragDropTarget(
KGGuiWindow* window);
3101 static void SetWindowDock(
KGGuiWindow* window, KGGuiID dock_id, KarmaGuiCond cond);
3112 static void DockBuilderDockWindow(
const char* window_name, KGGuiID node_id);
3115 static KGGuiID DockBuilderAddNode(KGGuiID node_id = 0, KarmaGuiDockNodeFlags flags = 0);
3116 static void DockBuilderRemoveNode(KGGuiID node_id);
3117 static void DockBuilderRemoveNodeDockedWindows(KGGuiID node_id,
bool clear_settings_refs =
true);
3118 static void DockBuilderRemoveNodeChildNodes(KGGuiID node_id);
3119 static void DockBuilderSetNodePos(KGGuiID node_id,
KGVec2 pos);
3120 static void DockBuilderSetNodeSize(KGGuiID node_id,
KGVec2 size);
3121 static KGGuiID DockBuilderSplitNode(KGGuiID node_id, KarmaGuiDir split_dir,
float size_ratio_for_node_at_dir, KGGuiID* out_id_at_dir, KGGuiID* out_id_at_opposite_dir);
3122 static void DockBuilderCopyDockSpace(KGGuiID src_dockspace_id, KGGuiID dst_dockspace_id,
KGVector<const char*>* in_window_remap_pairs);
3123 static void DockBuilderCopyNode(KGGuiID src_node_id, KGGuiID dst_node_id,
KGVector<KGGuiID>* out_node_remap_pairs);
3124 static void DockBuilderCopyWindowSettings(
const char* src_name,
const char* dst_name);
3125 static void DockBuilderFinish(KGGuiID node_id);
3135 static void PushFocusScope(KGGuiID
id);
3136 static void PopFocusScope();
3137 static inline KGGuiID GetCurrentFocusScope() {
KarmaGuiContext& g = *GKarmaGui;
return g.CurrentFocusScopeId; }
3140 static bool IsDragDropActive();
3141 static bool BeginDragDropTargetCustom(
const KGRect& bb, KGGuiID
id);
3142 static void ClearDragDrop();
3143 static bool IsDragDropPayloadBeingAccepted();
3144 static void RenderDragDropTargetRect(
const KGRect& bb);
3147 static void SetWindowClipRectBeforeSetChannel(
KGGuiWindow* window,
const KGRect& clip_rect);
3148 static void BeginColumns(
const char* str_id,
int count, KGGuiOldColumnFlags flags = 0);
3149 static void EndColumns();
3150 static void PushColumnClipRect(
int column_index);
3151 static void PushColumnsBackground();
3152 static void PopColumnsBackground();
3153 static KGGuiID GetColumnsID(
const char* str_id,
int count);
3155 static float GetColumnOffsetFromNorm(
const KGGuiOldColumns* columns,
float offset_norm);
3156 static float GetColumnNormFromOffset(
const KGGuiOldColumns* columns,
float offset);
3159 static void TableOpenContextMenu(
int column_n = -1);
3160 static void TableSetColumnWidth(
int column_n,
float width);
3161 static void TableSetColumnSortDirection(
int column_n, KarmaGuiSortDirection sort_direction,
bool append_to_sort_specs);
3162 static int TableGetHoveredColumn();
3163 static float TableGetHeaderRowHeight();
3164 static void TablePushBackgroundChannel();
3165 static void TablePopBackgroundChannel();
3169 static KGGuiTable* TableFindByID(KGGuiID
id);
3170 static bool BeginTableEx(
const char* name, KGGuiID
id,
int columns_count, KarmaGuiTableFlags flags = 0,
const KGVec2& outer_size =
KGVec2(0, 0),
float inner_width = 0.0f);
3171 static void TableBeginInitMemory(
KGGuiTable* table,
int columns_count);
3172 static void TableBeginApplyRequests(
KGGuiTable* table);
3173 static void TableSetupDrawChannels(
KGGuiTable* table);
3174 static void TableUpdateLayout(
KGGuiTable* table);
3175 static void TableUpdateBorders(
KGGuiTable* table);
3176 static void TableUpdateColumnsWeightFromWidth(
KGGuiTable* table);
3177 static void TableDrawBorders(
KGGuiTable* table);
3178 static void TableDrawContextMenu(
KGGuiTable* table);
3179 static bool TableBeginContextMenuPopup(
KGGuiTable* table);
3180 static void TableMergeDrawChannels(
KGGuiTable* table);
3181 static inline KGGuiTableInstanceData* TableGetInstanceData(
KGGuiTable* table,
int instance_no) {
if (instance_no == 0)
return &table->InstanceDataFirst;
return &table->InstanceDataExtra[instance_no - 1]; }
3182 static void TableSortSpecsSanitize(
KGGuiTable* table);
3183 static void TableSortSpecsBuild(
KGGuiTable* table);
3184 static KarmaGuiSortDirection TableGetColumnNextSortDirection(
KGGuiTableColumn* column);
3187 static void TableBeginRow(
KGGuiTable* table);
3189 static void TableBeginCell(
KGGuiTable* table,
int column_n);
3192 static const char* TableGetColumnName(
const KGGuiTable* table,
int column_n);
3193 static KGGuiID TableGetColumnResizeID(
const KGGuiTable* table,
int column_n,
int instance_no = 0);
3194 static float TableGetMaxColumnWidth(
const KGGuiTable* table,
int column_n);
3195 static void TableSetColumnWidthAutoSingle(
KGGuiTable* table,
int column_n);
3196 static void TableSetColumnWidthAutoAll(
KGGuiTable* table);
3198 static void TableGcCompactTransientBuffers(
KGGuiTable* table);
3200 static void TableGcCompactSettings();
3203 static void TableLoadSettings(
KGGuiTable* table);
3204 static void TableSaveSettings(
KGGuiTable* table);
3205 static void TableResetSettings(
KGGuiTable* table);
3207 static void TableSettingsAddSettingsHandler();
3216 static void TabBarRemoveTab(
KGGuiTabBar* tab_bar, KGGuiID tab_id);
3220 static bool TabBarProcessReorder(
KGGuiTabBar* tab_bar);
3221 static bool TabItemEx(
KGGuiTabBar* tab_bar,
const char* label,
bool* p_open, KarmaGuiTabItemFlags flags,
KGGuiWindow* docked_window);
3222 static KGVec2 TabItemCalcSize(
const char* label,
bool has_close_button_or_unsaved_marker);
3224 static void TabItemBackground(
KGDrawList* draw_list,
const KGRect& bb, KarmaGuiTabItemFlags flags, KGU32 col);
3225 static void TabItemLabelAndCloseButton(
KGDrawList* draw_list,
const KGRect& bb, KarmaGuiTabItemFlags flags,
KGVec2 frame_padding,
const char* label, KGGuiID tab_id, KGGuiID close_button_id,
bool is_contents_visible,
bool* out_just_closed,
bool* out_text_clipped);
3230 static void RenderText(
KGVec2 pos,
const char* text,
const char* text_end = NULL,
bool hide_text_after_hash =
true);
3231 static void RenderTextWrapped(
KGVec2 pos,
const char* text,
const char* text_end,
float wrap_width);
3232 static void RenderTextClipped(
const KGVec2& pos_min,
const KGVec2& pos_max,
const char* text,
const char* text_end,
const KGVec2* text_size_if_known,
const KGVec2& align =
KGVec2(0, 0),
const KGRect* clip_rect = NULL);
3233 static void RenderTextClippedEx(
KGDrawList* draw_list,
const KGVec2& pos_min,
const KGVec2& pos_max,
const char* text,
const char* text_end,
const KGVec2* text_size_if_known,
const KGVec2& align =
KGVec2(0, 0),
const KGRect* clip_rect = NULL);
3234 static void RenderTextEllipsis(
KGDrawList* draw_list,
const KGVec2& pos_min,
const KGVec2& pos_max,
float clip_max_x,
float ellipsis_max_x,
const char* text,
const char* text_end,
const KGVec2* text_size_if_known);
3235 static void RenderFrame(
KGVec2 p_min,
KGVec2 p_max, KGU32 fill_col,
bool border =
true,
float rounding = 0.0f);
3236 static void RenderFrameBorder(
KGVec2 p_min,
KGVec2 p_max,
float rounding = 0.0f);
3237 static void RenderColorRectWithAlphaCheckerboard(
KGDrawList* draw_list,
KGVec2 p_min,
KGVec2 p_max, KGU32 fill_col,
float grid_step,
KGVec2 grid_off,
float rounding = 0.0f, KGDrawFlags flags = 0);
3238 static void RenderNavHighlight(
const KGRect& bb, KGGuiID
id, KGGuiNavHighlightFlags flags = KGGuiNavHighlightFlags_TypeDefault);
3239 static const char* FindRenderedTextEnd(
const char* text,
const char* text_end = NULL);
3240 static void RenderMouseCursor(
KGVec2 pos,
float scale, KarmaGuiMouseCursor mouse_cursor, KGU32 col_fill, KGU32 col_border, KGU32 col_shadow);
3243 static void RenderArrow(
KGDrawList* draw_list,
KGVec2 pos, KGU32 col, KarmaGuiDir dir,
float scale = 1.0f);
3245 static void RenderCheckMark(
KGDrawList* draw_list,
KGVec2 pos, KGU32 col,
float sz);
3246 static void RenderArrowPointingAt(
KGDrawList* draw_list,
KGVec2 pos,
KGVec2 half_sz, KarmaGuiDir direction, KGU32 col);
3247 static void RenderArrowDockMenu(
KGDrawList* draw_list,
KGVec2 p_min,
float sz, KGU32 col);
3248 static void RenderRectFilledRangeH(
KGDrawList* draw_list,
const KGRect& rect, KGU32 col,
float x_start_norm,
float x_end_norm,
float rounding);
3249 static void RenderRectFilledWithHole(
KGDrawList* draw_list,
const KGRect& outer,
const KGRect& inner, KGU32 col,
float rounding);
3250 static KGDrawFlags CalcRoundingFlagsForRectInRect(
const KGRect& r_in,
const KGRect& r_outer,
float threshold);
3253 static void TextEx(
const char* text,
const char* text_end = NULL, KGGuiTextFlags flags = 0);
3254 static bool ButtonEx(
const char* label,
const KGVec2& size_arg =
KGVec2(0, 0), KarmaGuiButtonFlags flags = 0);
3255 static bool ArrowButtonEx(
const char* str_id, KarmaGuiDir dir,
KGVec2 size_arg, KarmaGuiButtonFlags flags = 0);
3256 static bool ImageButtonEx(KGGuiID
id, KGTextureID texture_id,
const KGVec2& size,
const KGVec2& uv0,
const KGVec2& uv1,
const KGVec4& bg_col,
const KGVec4& tint_col);
3257 static void SeparatorEx(KGGuiSeparatorFlags flags);
3258 static bool CheckboxFlags(
const char* label, KGS64* flags, KGS64 flags_value);
3259 static bool CheckboxFlags(
const char* label, KGU64* flags, KGU64 flags_value);
3262 static bool CloseButton(KGGuiID
id,
const KGVec2& pos);
3264 static void Scrollbar(KGGuiAxis axis);
3265 static bool ScrollbarEx(
const KGRect& bb, KGGuiID
id, KGGuiAxis axis, KGS64* p_scroll_v, KGS64 avail_v, KGS64 contents_v, KGDrawFlags flags);
3267 static KGGuiID GetWindowScrollbarID(
KGGuiWindow* window, KGGuiAxis axis);
3268 static KGGuiID GetWindowResizeCornerID(
KGGuiWindow* window,
int n);
3269 static KGGuiID GetWindowResizeBorderID(
KGGuiWindow* window, KarmaGuiDir dir);
3272 static bool ButtonBehavior(
const KGRect& bb, KGGuiID
id,
bool* out_hovered,
bool* out_held, KarmaGuiButtonFlags flags = 0);
3273 static bool DragBehavior(KGGuiID
id, KarmaGuiDataType data_type,
void* p_v,
float v_speed,
const void* p_min,
const void* p_max,
const char* format, KarmaGuiSliderFlags flags);
3274 static bool SliderBehavior(
const KGRect& bb, KGGuiID
id, KarmaGuiDataType data_type,
void* p_v,
const void* p_min,
const void* p_max,
const char* format, KarmaGuiSliderFlags flags,
KGRect* out_grab_bb);
3275 static bool SplitterBehavior(
const KGRect& bb, KGGuiID
id, KGGuiAxis axis,
float* size1,
float* size2,
float min_size1,
float min_size2,
float hover_extend = 0.0f,
float hover_visibility_delay = 0.0f, KGU32 bg_col = 0);
3276 static bool TreeNodeBehavior(KGGuiID
id, KarmaGuiTreeNodeFlags flags,
const char* label,
const char* label_end = NULL);
3277 static void TreePushOverrideID(KGGuiID
id);
3278 static void TreeNodeSetOpen(KGGuiID
id,
bool open);
3279 static bool TreeNodeUpdateNextOpen(KGGuiID
id, KarmaGuiTreeNodeFlags flags);
3284 template<
typename T,
typename SIGNED_T,
typename FLOAT_T>
static float ScaleRatioFromValueT(KarmaGuiDataType data_type, T v, T v_min, T v_max,
bool is_logarithmic,
float logarithmic_zero_epsilon,
float zero_deadzone_size);
3285 template<
typename T,
typename SIGNED_T,
typename FLOAT_T> T
static ScaleValueFromRatioT(KarmaGuiDataType data_type,
float t, T v_min, T v_max,
bool is_logarithmic,
float logarithmic_zero_epsilon,
float zero_deadzone_size);
3286 template<
typename T,
typename SIGNED_T,
typename FLOAT_T>
static bool DragBehaviorT(KarmaGuiDataType data_type, T* v,
float v_speed, T v_min, T v_max,
const char* format, KarmaGuiSliderFlags flags);
3287 template<
typename T,
typename SIGNED_T,
typename FLOAT_T>
bool static SliderBehaviorT(
const KGRect& bb, KGGuiID
id, KarmaGuiDataType data_type, T* v, T v_min, T v_max,
const char* format, KarmaGuiSliderFlags flags,
KGRect* out_grab_bb);
3288 template<
typename T> T
static RoundScalarWithFormatT(
const char* format, KarmaGuiDataType data_type, T v);
3289 template<
typename T>
static bool CheckboxFlagsT(
const char* label, T* flags, T flags_value);
3293 static int DataTypeFormatString(
char* buf,
int buf_size, KarmaGuiDataType data_type,
const void* p_data,
const char* format);
3294 static void DataTypeApplyOp(KarmaGuiDataType data_type,
int op,
void* output,
const void* arg_1,
const void* arg_2);
3295 static bool DataTypeApplyFromText(
const char* buf, KarmaGuiDataType data_type,
void* p_data,
const char* format);
3296 static int DataTypeCompare(KarmaGuiDataType data_type,
const void* arg_1,
const void* arg_2);
3297 static bool DataTypeClamp(KarmaGuiDataType data_type,
void* p_data,
const void* p_min,
const void* p_max);
3300 static bool InputTextEx(
const char* label,
const char* hint,
char* buf,
int buf_size,
const KGVec2& size_arg, KarmaGuiInputTextFlags flags, KarmaGuiInputTextCallback callback = NULL,
void* user_data = NULL);
3301 static bool TempInputText(
const KGRect& bb, KGGuiID
id,
const char* label,
char* buf,
int buf_size, KarmaGuiInputTextFlags flags);
3302 static bool TempInputScalar(
const KGRect& bb, KGGuiID
id,
const char* label, KarmaGuiDataType data_type,
void* p_data,
const char* format,
const void* p_clamp_min = NULL,
const void* p_clamp_max = NULL);
3303 static bool TempInputIsActive(KGGuiID
id);
3306 static void ColorTooltip(
const char* text,
const float* col, KarmaGuiColorEditFlags flags);
3307 static void ColorEditOptionsPopup(
const float* col, KarmaGuiColorEditFlags flags);
3308 static void ColorPickerOptionsPopup(
const float* ref_col, KarmaGuiColorEditFlags flags);
3311 static int PlotEx(KGGuiPlotType plot_type,
const char* label,
float (*values_getter)(
void* data,
int idx),
void* data,
int values_count,
int values_offset,
const char* overlay_text,
float scale_min,
float scale_max,
KGVec2 frame_size);
3314 static void ShadeVertsLinearColorGradientKeepAlpha(
KGDrawList* draw_list,
int vert_start_idx,
int vert_end_idx,
KGVec2 gradient_p0,
KGVec2 gradient_p1, KGU32 col0, KGU32 col1);
3315 static void ShadeVertsLinearUV(
KGDrawList* draw_list,
int vert_start_idx,
int vert_end_idx,
const KGVec2& a,
const KGVec2& b,
const KGVec2& uv_a,
const KGVec2& uv_b,
bool clamp);
3318 static void GcCompactTransientMiscBuffers();
3319 static void GcCompactTransientWindowBuffers(
KGGuiWindow* window);
3320 static void GcAwakeTransientWindowBuffers(
KGGuiWindow* window);
3323 static void ErrorCheckEndFrameRecover(KGGuiErrorLogCallback log_callback,
void* user_data = NULL);
3324 static void ErrorCheckEndWindowRecover(KGGuiErrorLogCallback log_callback,
void* user_data = NULL);
3325 static void ErrorCheckUsingSetCursorPosToExtendParentBoundaries();
3326 static void DebugLocateItem(KGGuiID target_id);
3327 static void DebugLocateItemOnHover(KGGuiID target_id);
3328 static void DebugLocateItemResolveWithLastItem();
3329 static inline void DebugDrawItemRect(KGU32 col = KG_COL32(255, 0, 0, 255)) {
KarmaGuiContext& g = *GKarmaGui;
KGGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, col); }
3330 static void DebugStartItemPicker();
3332 static void DebugHookIdInfo(KGGuiID
id, KarmaGuiDataType data_type,
const void* data_id,
const void* data_id_end);
3334 static void DebugNodeDockNode(
KGGuiDockNode* node,
const char* label);
3336 static void DebugNodeDrawCmdShowMeshAndBoundingBox(
KGDrawList* out_draw_list,
const KGDrawList* draw_list,
const KGDrawCmd* draw_cmd,
bool show_mesh,
bool show_aabb);
3337 static void DebugNodeFont(
KGFont* font);
3339 static void DebugNodeStorage(
KarmaGuiStorage* storage,
const char* label);
3340 static void DebugNodeTabBar(
KGGuiTabBar* tab_bar,
const char* label);
3341 static void DebugNodeTable(
KGGuiTable* table);
3344 static void DebugNodeWindow(
KGGuiWindow* window,
const char* label);
3347 static void DebugNodeWindowsListByBeginStackParent(
KGGuiWindow** windows,
int windows_size,
KGGuiWindow* parent_in_begin_stack);
3349 static void DebugRenderKeyboardPreview(
KGDrawList* draw_list);
3365#ifdef KGGUI_ENABLE_STB_TRUETYPE
3370 static void KGFontAtlasBuildInit(
KGFontAtlas* atlas);
3372 static void KGFontAtlasBuildPackCustomRects(
KGFontAtlas* atlas,
void* stbrp_context_opaque);
3373 static void KGFontAtlasBuildFinish(
KGFontAtlas* atlas);
3374 static void KGFontAtlasBuildRender8bppRectFromString(
KGFontAtlas* atlas,
int x,
int y,
int w,
int h,
const char* in_str,
char in_marker_char,
unsigned char in_marker_pixel_value);
3375 static void KGFontAtlasBuildRender32bppRectFromString(
KGFontAtlas* atlas,
int x,
int y,
int w,
int h,
const char* in_str,
char in_marker_char,
unsigned int in_marker_pixel_value);
3376 static void KGFontAtlasBuildMultiplyCalcLookupTable(
unsigned char out_table[256],
float in_multiply_factor);
3377 static void KGFontAtlasBuildMultiplyRectAlpha8(
const unsigned char table[256],
unsigned char* pixels,
int x,
int y,
int w,
int h,
int stride);
3384#define KARMAGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) ((void)0)
3385#define KARMAGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) ((void)g)
Definition KarmaGuiInternal.h:2755
Definition KarmaGuiInternal.h:443
Definition KarmaGuiInternal.h:458
Definition KarmaGuiInternal.h:561
Definition KarmaGui.h:2415
Definition KarmaGuiInternal.h:646
Definition KarmaGui.h:2647
Definition KarmaGuiInternal.h:623
Definition KarmaGui.h:2466
Definition KarmaGui.h:2521
Definition KarmaGui.h:2764
Definition KarmaGuiInternal.h:3360
Definition KarmaGui.h:2670
Definition KarmaGui.h:2699
Definition KarmaGui.h:2867
Definition KarmaGuiInternal.h:849
Definition KarmaGuiInternal.h:866
Definition KarmaGuiInternal.h:1711
Definition KarmaGuiInternal.h:832
Definition KarmaGuiInternal.h:826
Definition KarmaGuiInternal.h:1519
Definition KarmaGui.cpp:13581
Definition KarmaGuiInternal.h:1437
Definition KarmaGui.cpp:13542
Definition KarmaGuiInternal.h:879
Definition KarmaGuiInternal.h:1140
Definition KarmaGuiInternal.h:914
Definition KarmaGuiInternal.h:1195
Definition KarmaGuiInternal.h:1170
Definition KarmaGuiInternal.h:1183
Definition KarmaGuiInternal.h:1029
Definition KarmaGuiInternal.h:1252
Definition KarmaGuiInternal.h:1239
Definition KarmaGuiInternal.h:1631
Definition KarmaGuiInternal.h:895
Definition KarmaGuiInternal.h:1657
Definition KarmaGuiInternal.h:1325
Definition KarmaGuiInternal.h:1016
Definition KarmaGuiInternal.h:982
Definition KarmaGuiInternal.h:1355
Definition KarmaGuiInternal.h:1365
Definition KarmaGuiInternal.h:1073
Definition KarmaGuiInternal.h:1598
Definition KarmaGuiInternal.h:1066
Definition KarmaGuiInternal.h:1680
Definition KarmaGuiInternal.h:1041
Definition KarmaGuiInternal.h:856
Definition KarmaGuiInternal.h:2442
Definition KarmaGuiInternal.h:2422
Definition KarmaGuiInternal.h:2562
Definition KarmaGuiInternal.h:2716
Definition KarmaGuiInternal.h:2503
Definition KarmaGuiInternal.h:2569
Definition KarmaGuiInternal.h:2740
Definition KarmaGuiInternal.h:2695
Definition KarmaGuiInternal.h:2579
Definition KarmaGuiInternal.h:580
Definition KarmaGuiInternal.h:1536
Definition KarmaGuiInternal.h:1514
Definition KarmaGuiInternal.h:1581
Definition KarmaGuiInternal.h:1059
Definition KarmaGuiInternal.h:2207
Definition KarmaGuiInternal.h:2255
Definition KarmaGuiInternal.h:524
Definition KarmaGuiInternal.h:387
Definition KarmaGuiInternal.h:501
Definition KarmaGuiInternal.h:471
Definition KarmaGuiWidgets.cpp:320
Definition KarmaGuiInternal.h:369
Definition KarmaGui.h:145
Definition KarmaGuiInternal.h:377
Definition KarmaGui.h:155
Definition KarmaGui.h:1761
Definition KarmaGuiInternal.h:1725
Definition KarmaGui.h:1896
Definition KarmaGui.h:1888
Definition KarmaGui.h:2326
Definition KarmaGui.h:2145
Definition KarmaGui.h:2266
Definition KarmaGui.h:2263
Definition KarmaGui.h:1831
Definition KarmaGui.h:2167
Definition KarmaGui.h:2181
Definition KarmaGui.h:2236
Definition KarmaGui.h:2948
Definition KarmaGui.h:2130