source: opengl-game/IMGUI/imgui_internal.h@ 91c89f7

feature/imgui-sdl points-test
Last change on this file since 91c89f7 was c58ebc3, checked in by Dmitry Portnoy <dmp1488@…>, 7 years ago

Create an IMGUI folder for the imgui library files.

  • Property mode set to 100644
File size: 71.3 KB
Line 
1// dear imgui, v1.61 WIP
2// (internals)
3
4// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
5// Set:
6// #define IMGUI_DEFINE_MATH_OPERATORS
7// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators)
8
9#pragma once
10
11#ifndef IMGUI_VERSION
12#error Must include imgui.h before imgui_internal.h
13#endif
14
15#include <stdio.h> // FILE*
16#include <math.h> // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf
17#include <limits.h> // INT_MIN, INT_MAX
18
19#ifdef _MSC_VER
20#pragma warning (push)
21#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
22#endif
23
24#ifdef __clang__
25#pragma clang diagnostic push
26#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h
27#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h
28#pragma clang diagnostic ignored "-Wold-style-cast"
29#endif
30
31//-----------------------------------------------------------------------------
32// Forward Declarations
33//-----------------------------------------------------------------------------
34
35struct ImRect;
36struct ImGuiColMod;
37struct ImGuiStyleMod;
38struct ImGuiGroupData;
39struct ImGuiMenuColumns;
40struct ImGuiDrawContext;
41struct ImGuiTextEditState;
42struct ImGuiPopupRef;
43struct ImGuiWindow;
44struct ImGuiWindowSettings;
45
46typedef int ImGuiLayoutType; // enum: horizontal or vertical // enum ImGuiLayoutType_
47typedef int ImGuiButtonFlags; // flags: for ButtonEx(), ButtonBehavior() // enum ImGuiButtonFlags_
48typedef int ImGuiItemFlags; // flags: for PushItemFlag() // enum ImGuiItemFlags_
49typedef int ImGuiItemStatusFlags; // flags: storage for DC.LastItemXXX // enum ImGuiItemStatusFlags_
50typedef int ImGuiNavHighlightFlags; // flags: for RenderNavHighlight() // enum ImGuiNavHighlightFlags_
51typedef int ImGuiNavDirSourceFlags; // flags: for GetNavInputAmount2d() // enum ImGuiNavDirSourceFlags_
52typedef int ImGuiSeparatorFlags; // flags: for Separator() - internal // enum ImGuiSeparatorFlags_
53typedef int ImGuiSliderFlags; // flags: for SliderBehavior() // enum ImGuiSliderFlags_
54
55 //-------------------------------------------------------------------------
56 // STB libraries
57 //-------------------------------------------------------------------------
58
59namespace ImGuiStb
60{
61
62#undef STB_TEXTEDIT_STRING
63#undef STB_TEXTEDIT_CHARTYPE
64#define STB_TEXTEDIT_STRING ImGuiTextEditState
65#define STB_TEXTEDIT_CHARTYPE ImWchar
66#define STB_TEXTEDIT_GETWIDTH_NEWLINE -1.0f
67#include "stb_textedit.h"
68
69} // namespace ImGuiStb
70
71 //-----------------------------------------------------------------------------
72 // Context
73 //-----------------------------------------------------------------------------
74
75#ifndef GImGui
76extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointer
77#endif
78
79 //-----------------------------------------------------------------------------
80 // Helpers
81 //-----------------------------------------------------------------------------
82
83#define IM_PI 3.14159265358979323846f
84#ifdef _WIN32
85#define IM_NEWLINE "\r\n" // Play it nice with Windows users (2018: Notepad _still_ doesn't display files properly when they use Unix-style carriage returns)
86#else
87#define IM_NEWLINE "\n"
88#endif
89
90 // Helpers: UTF-8 <> wchar
91IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
92IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // return input UTF-8 bytes count
93IMGUI_API int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count
94IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count)
95IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string as UTF-8 code-points
96
97 // Helpers: Misc
98IMGUI_API ImU32 ImHash(const void* data, int data_size, ImU32 seed = 0); // Pass data_size==0 for zero-terminated strings
99IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int* out_file_size = NULL, int padding_bytes = 0);
100IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode);
101static inline bool ImCharIsSpace(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; }
102static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; }
103static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
104
105// Helpers: Geometry
106IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p);
107IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
108IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
109IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
110
111// Helpers: String
112IMGUI_API int ImStricmp(const char* str1, const char* str2);
113IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count);
114IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count);
115IMGUI_API char* ImStrdup(const char* str);
116IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c);
117IMGUI_API int ImStrlenW(const ImWchar* str);
118IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
119IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
120IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
121IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
122
123// Helpers: Math
124// We are keeping those not leaking to the user by default, in the case the user has implicit cast operators between ImVec2 and its own types (when IM_VEC2_CLASS_EXTRA is defined)
125#ifdef IMGUI_DEFINE_MATH_OPERATORS
126static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
127static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x / rhs, lhs.y / rhs); }
128static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x + rhs.x, lhs.y + rhs.y); }
129static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); }
130static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
131static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x / rhs.x, lhs.y / rhs.y); }
132static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
133static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
134static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
135static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
136static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z, lhs.w + rhs.w); }
137static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w); }
138static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
139#endif
140
141static inline int ImMin(int lhs, int rhs) { return lhs < rhs ? lhs : rhs; }
142static inline int ImMax(int lhs, int rhs) { return lhs >= rhs ? lhs : rhs; }
143static inline float ImMin(float lhs, float rhs) { return lhs < rhs ? lhs : rhs; }
144static inline float ImMax(float lhs, float rhs) { return lhs >= rhs ? lhs : rhs; }
145static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
146static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
147static inline int ImClamp(int v, int mn, int mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
148static inline float ImClamp(float v, float mn, float mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
149static inline ImVec2 ImClamp(const ImVec2& f, const ImVec2& mn, ImVec2 mx) { return ImVec2(ImClamp(f.x, mn.x, mx.x), ImClamp(f.y, mn.y, mx.y)); }
150static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
151static inline void ImSwap(int& a, int& b) { int tmp = a; a = b; b = tmp; }
152static inline void ImSwap(float& a, float& b) { float tmp = a; a = b; b = tmp; }
153static inline int ImLerp(int a, int b, float t) { return (int)(a + (b - a) * t); }
154static inline float ImLerp(float a, float b, float t) { return a + (b - a) * t; }
155static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
156static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
157static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
158static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
159static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
160static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; }
161static inline float ImFloor(float f) { return (float)(int)f; }
162static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
163static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; }
164static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); }
165static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; }
166static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); }
167
168//-----------------------------------------------------------------------------
169// Types
170//-----------------------------------------------------------------------------
171
172enum ImGuiButtonFlags_
173{
174 ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
175 ImGuiButtonFlags_PressedOnClickRelease = 1 << 1, // return true on click + release on same item [DEFAULT if no PressedOn* flag is set]
176 ImGuiButtonFlags_PressedOnClick = 1 << 2, // return true on click (default requires click+release)
177 ImGuiButtonFlags_PressedOnRelease = 1 << 3, // return true on release (default requires click+release)
178 ImGuiButtonFlags_PressedOnDoubleClick = 1 << 4, // return true on double-click (default requires click+release)
179 ImGuiButtonFlags_FlattenChildren = 1 << 5, // allow interactions even if a child window is overlapping
180 ImGuiButtonFlags_AllowItemOverlap = 1 << 6, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
181 ImGuiButtonFlags_DontClosePopups = 1 << 7, // disable automatically closing parent popup on press // [UNUSED]
182 ImGuiButtonFlags_Disabled = 1 << 8, // disable interactions
183 ImGuiButtonFlags_AlignTextBaseLine = 1 << 9, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
184 ImGuiButtonFlags_NoKeyModifiers = 1 << 10, // disable interaction if a key modifier is held
185 ImGuiButtonFlags_NoHoldingActiveID = 1 << 11, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
186 ImGuiButtonFlags_PressedOnDragDropHold = 1 << 12, // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
187 ImGuiButtonFlags_NoNavFocus = 1 << 13 // don't override navigation focus when activated
188};
189
190enum ImGuiSliderFlags_
191{
192 ImGuiSliderFlags_Vertical = 1 << 0
193};
194
195enum ImGuiColumnsFlags_
196{
197 // Default: 0
198 ImGuiColumnsFlags_NoBorder = 1 << 0, // Disable column dividers
199 ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers
200 ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns
201 ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window
202 ImGuiColumnsFlags_GrowParentContentsSize = 1 << 4 // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
203};
204
205enum ImGuiSelectableFlagsPrivate_
206{
207 // NB: need to be in sync with last value of ImGuiSelectableFlags_
208 ImGuiSelectableFlags_Menu = 1 << 3, // -> PressedOnClick
209 ImGuiSelectableFlags_MenuItem = 1 << 4, // -> PressedOnRelease
210 ImGuiSelectableFlags_Disabled = 1 << 5,
211 ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
212};
213
214enum ImGuiSeparatorFlags_
215{
216 ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
217 ImGuiSeparatorFlags_Vertical = 1 << 1
218};
219
220// Storage for LastItem data
221enum ImGuiItemStatusFlags_
222{
223 ImGuiItemStatusFlags_HoveredRect = 1 << 0,
224 ImGuiItemStatusFlags_HasDisplayRect = 1 << 1
225};
226
227// FIXME: this is in development, not exposed/functional as a generic feature yet.
228enum ImGuiLayoutType_
229{
230 ImGuiLayoutType_Vertical,
231 ImGuiLayoutType_Horizontal
232};
233
234enum ImGuiAxis
235{
236 ImGuiAxis_None = -1,
237 ImGuiAxis_X = 0,
238 ImGuiAxis_Y = 1
239};
240
241enum ImGuiPlotType
242{
243 ImGuiPlotType_Lines,
244 ImGuiPlotType_Histogram
245};
246
247enum ImGuiDataType
248{
249 ImGuiDataType_Int32,
250 ImGuiDataType_Uint32,
251 ImGuiDataType_Float,
252 ImGuiDataType_Double,
253 ImGuiDataType_COUNT
254};
255
256enum ImGuiInputSource
257{
258 ImGuiInputSource_None = 0,
259 ImGuiInputSource_Mouse,
260 ImGuiInputSource_Nav,
261 ImGuiInputSource_NavKeyboard, // Only used occasionally for storage, not tested/handled by most code
262 ImGuiInputSource_NavGamepad, // "
263 ImGuiInputSource_COUNT
264};
265
266// FIXME-NAV: Clarify/expose various repeat delay/rate
267enum ImGuiInputReadMode
268{
269 ImGuiInputReadMode_Down,
270 ImGuiInputReadMode_Pressed,
271 ImGuiInputReadMode_Released,
272 ImGuiInputReadMode_Repeat,
273 ImGuiInputReadMode_RepeatSlow,
274 ImGuiInputReadMode_RepeatFast
275};
276
277enum ImGuiNavHighlightFlags_
278{
279 ImGuiNavHighlightFlags_TypeDefault = 1 << 0,
280 ImGuiNavHighlightFlags_TypeThin = 1 << 1,
281 ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2,
282 ImGuiNavHighlightFlags_NoRounding = 1 << 3
283};
284
285enum ImGuiNavDirSourceFlags_
286{
287 ImGuiNavDirSourceFlags_Keyboard = 1 << 0,
288 ImGuiNavDirSourceFlags_PadDPad = 1 << 1,
289 ImGuiNavDirSourceFlags_PadLStick = 1 << 2
290};
291
292enum ImGuiNavForward
293{
294 ImGuiNavForward_None,
295 ImGuiNavForward_ForwardQueued,
296 ImGuiNavForward_ForwardActive
297};
298
299// 2D axis aligned bounding-box
300// NB: we can't rely on ImVec2 math operators being available here
301struct IMGUI_API ImRect
302{
303 ImVec2 Min; // Upper-left
304 ImVec2 Max; // Lower-right
305
306 ImRect() : Min(FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX) {}
307 ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {}
308 ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
309 ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {}
310
311 ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
312 ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
313 float GetWidth() const { return Max.x - Min.x; }
314 float GetHeight() const { return Max.y - Min.y; }
315 ImVec2 GetTL() const { return Min; } // Top-left
316 ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right
317 ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left
318 ImVec2 GetBR() const { return Max; } // Bottom-right
319 bool Contains(const ImVec2& p) const { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; }
320 bool Contains(const ImRect& r) const { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x <= Max.x && r.Max.y <= Max.y; }
321 bool Overlaps(const ImRect& r) const { return r.Min.y < Max.y && r.Max.y > Min.y && r.Min.x < Max.x && r.Max.x > Min.x; }
322 void Add(const ImVec2& p) { if (Min.x > p.x) Min.x = p.x; if (Min.y > p.y) Min.y = p.y; if (Max.x < p.x) Max.x = p.x; if (Max.y < p.y) Max.y = p.y; }
323 void Add(const ImRect& r) { if (Min.x > r.Min.x) Min.x = r.Min.x; if (Min.y > r.Min.y) Min.y = r.Min.y; if (Max.x < r.Max.x) Max.x = r.Max.x; if (Max.y < r.Max.y) Max.y = r.Max.y; }
324 void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
325 void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
326 void Translate(const ImVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; }
327 void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
328 void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped.
329 void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
330 bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; }
331};
332
333// Stacked color modifier, backup of modified data so we can restore it
334struct ImGuiColMod
335{
336 ImGuiCol Col;
337 ImVec4 BackupValue;
338};
339
340// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable.
341struct ImGuiStyleMod
342{
343 ImGuiStyleVar VarIdx;
344 union { int BackupInt[2]; float BackupFloat[2]; };
345 ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; }
346 ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; }
347 ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; }
348};
349
350// Stacked data for BeginGroup()/EndGroup()
351struct ImGuiGroupData
352{
353 ImVec2 BackupCursorPos;
354 ImVec2 BackupCursorMaxPos;
355 float BackupIndentX;
356 float BackupGroupOffsetX;
357 float BackupCurrentLineHeight;
358 float BackupCurrentLineTextBaseOffset;
359 float BackupLogLinePosY;
360 bool BackupActiveIdIsAlive;
361 bool AdvanceCursor;
362};
363
364// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper.
365struct IMGUI_API ImGuiMenuColumns
366{
367 int Count;
368 float Spacing;
369 float Width, NextWidth;
370 float Pos[4], NextWidths[4];
371
372 ImGuiMenuColumns();
373 void Update(int count, float spacing, bool clear);
374 float DeclColumns(float w0, float w1, float w2);
375 float CalcExtraSpace(float avail_w);
376};
377
378// Internal state of the currently focused/edited text input box
379struct IMGUI_API ImGuiTextEditState
380{
381 ImGuiID Id; // widget id owning the text state
382 ImVector<ImWchar> Text; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
383 ImVector<char> InitialText; // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
384 ImVector<char> TempTextBuffer;
385 int CurLenA, CurLenW; // we need to maintain our buffer length in both UTF-8 and wchar format.
386 int BufSizeA; // end-user buffer size
387 float ScrollX;
388 ImGuiStb::STB_TexteditState StbState;
389 float CursorAnim;
390 bool CursorFollow;
391 bool SelectedAllMouseLock;
392
393 ImGuiTextEditState() { memset(this, 0, sizeof(*this)); }
394 void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking
395 void CursorClamp() { StbState.cursor = ImMin(StbState.cursor, CurLenW); StbState.select_start = ImMin(StbState.select_start, CurLenW); StbState.select_end = ImMin(StbState.select_end, CurLenW); }
396 bool HasSelection() const { return StbState.select_start != StbState.select_end; }
397 void ClearSelection() { StbState.select_start = StbState.select_end = StbState.cursor; }
398 void SelectAll() { StbState.select_start = 0; StbState.cursor = StbState.select_end = CurLenW; StbState.has_preferred_x = false; }
399 void OnKeyPressed(int key);
400};
401
402// Data saved in imgui.ini file
403struct ImGuiWindowSettings
404{
405 char* Name;
406 ImGuiID Id;
407 ImVec2 Pos;
408 ImVec2 Size;
409 bool Collapsed;
410
411 ImGuiWindowSettings() { Name = NULL; Id = 0; Pos = Size = ImVec2(0, 0); Collapsed = false; }
412};
413
414struct ImGuiSettingsHandler
415{
416 const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
417 ImGuiID TypeHash; // == ImHash(TypeName, 0, 0)
418 void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
419 void(*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
420 void(*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf'
421 void* UserData;
422
423 ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); }
424};
425
426// Storage for current popup stack
427struct ImGuiPopupRef
428{
429 ImGuiID PopupId; // Set on OpenPopup()
430 ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
431 ImGuiWindow* ParentWindow; // Set on OpenPopup()
432 int OpenFrameCount; // Set on OpenPopup()
433 ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differenciate multiple menu sets from each others (e.g. inside menu bar vs loose menu items)
434 ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse)
435 ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup
436};
437
438struct ImGuiColumnData
439{
440 float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
441 float OffsetNormBeforeResize;
442 ImGuiColumnsFlags Flags; // Not exposed
443 ImRect ClipRect;
444
445 ImGuiColumnData() { OffsetNorm = OffsetNormBeforeResize = 0.0f; Flags = 0; }
446};
447
448struct ImGuiColumnsSet
449{
450 ImGuiID ID;
451 ImGuiColumnsFlags Flags;
452 bool IsFirstFrame;
453 bool IsBeingResized;
454 int Current;
455 int Count;
456 float MinX, MaxX;
457 float LineMinY, LineMaxY;
458 float StartPosY; // Copy of CursorPos
459 float StartMaxPosX; // Copy of CursorMaxPos
460 ImVector<ImGuiColumnData> Columns;
461
462 ImGuiColumnsSet() { Clear(); }
463 void Clear()
464 {
465 ID = 0;
466 Flags = 0;
467 IsFirstFrame = false;
468 IsBeingResized = false;
469 Current = 0;
470 Count = 1;
471 MinX = MaxX = 0.0f;
472 LineMinY = LineMaxY = 0.0f;
473 StartPosY = 0.0f;
474 StartMaxPosX = 0.0f;
475 Columns.clear();
476 }
477};
478
479struct IMGUI_API ImDrawListSharedData
480{
481 ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas
482 ImFont* Font; // Current/default font (optional, for simplified AddText overload)
483 float FontSize; // Current/default font size (optional, for simplified AddText overload)
484 float CurveTessellationTol;
485 ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen()
486
487 // Const data
488 // FIXME: Bake rounded corners fill/borders in atlas
489 ImVec2 CircleVtx12[12];
490
491 ImDrawListSharedData();
492};
493
494struct ImDrawDataBuilder
495{
496 ImVector<ImDrawList*> Layers[2]; // Global layers for: regular, tooltip
497
498 void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); }
499 void ClearFreeMemory() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); }
500 IMGUI_API void FlattenIntoSingleLayer();
501};
502
503struct ImGuiNavMoveResult
504{
505 ImGuiID ID; // Best candidate
506 ImGuiID ParentID; // Best candidate window->IDStack.back() - to compare context
507 ImGuiWindow* Window; // Best candidate window
508 float DistBox; // Best candidate box distance to current NavId
509 float DistCenter; // Best candidate center distance to current NavId
510 float DistAxial;
511 ImRect RectRel; // Best candidate bounding box in window relative space
512
513 ImGuiNavMoveResult() { Clear(); }
514 void Clear() { ID = ParentID = 0; Window = NULL; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); }
515};
516
517// Storage for SetNexWindow** functions
518struct ImGuiNextWindowData
519{
520 ImGuiCond PosCond;
521 ImGuiCond SizeCond;
522 ImGuiCond ContentSizeCond;
523 ImGuiCond CollapsedCond;
524 ImGuiCond SizeConstraintCond;
525 ImGuiCond FocusCond;
526 ImGuiCond BgAlphaCond;
527 ImVec2 PosVal;
528 ImVec2 PosPivotVal;
529 ImVec2 SizeVal;
530 ImVec2 ContentSizeVal;
531 bool CollapsedVal;
532 ImRect SizeConstraintRect;
533 ImGuiSizeCallback SizeCallback;
534 void* SizeCallbackUserData;
535 float BgAlphaVal;
536 ImVec2 MenuBarOffsetMinVal; // This is not exposed publicly, so we don't clear it.
537
538 ImGuiNextWindowData()
539 {
540 PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
541 PosVal = PosPivotVal = SizeVal = ImVec2(0.0f, 0.0f);
542 ContentSizeVal = ImVec2(0.0f, 0.0f);
543 CollapsedVal = false;
544 SizeConstraintRect = ImRect();
545 SizeCallback = NULL;
546 SizeCallbackUserData = NULL;
547 BgAlphaVal = FLT_MAX;
548 MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
549 }
550
551 void Clear()
552 {
553 PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
554 }
555};
556
557// Main state for ImGui
558struct ImGuiContext
559{
560 bool Initialized;
561 bool FontAtlasOwnedByContext; // Io.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
562 ImGuiIO IO;
563 ImGuiStyle Style;
564 ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
565 float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
566 float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
567 ImDrawListSharedData DrawListSharedData;
568
569 float Time;
570 int FrameCount;
571 int FrameCountEnded;
572 int FrameCountRendered;
573 ImVector<ImGuiWindow*> Windows;
574 ImVector<ImGuiWindow*> WindowsSortBuffer;
575 ImVector<ImGuiWindow*> CurrentWindowStack;
576 ImGuiStorage WindowsById;
577 int WindowsActiveCount;
578 ImGuiWindow* CurrentWindow; // Being drawn into
579 ImGuiWindow* HoveredWindow; // Will catch mouse inputs
580 ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
581 ImGuiID HoveredId; // Hovered widget
582 bool HoveredIdAllowOverlap;
583 ImGuiID HoveredIdPreviousFrame;
584 float HoveredIdTimer;
585 ImGuiID ActiveId; // Active widget
586 ImGuiID ActiveIdPreviousFrame;
587 float ActiveIdTimer;
588 bool ActiveIdIsAlive; // Active widget has been seen this frame
589 bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
590 bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
591 int ActiveIdAllowNavDirFlags; // Active widget allows using directional navigation (e.g. can activate a button and move away from it)
592 ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
593 ImGuiWindow* ActiveIdWindow;
594 ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
595 ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
596 ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
597 ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
598 ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
599 ImVector<ImGuiPopupRef> OpenPopupStack; // Which popups are open (persistent)
600 ImVector<ImGuiPopupRef> CurrentPopupStack; // Which level of BeginPopup() we are in (reset every frame)
601 ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions
602 bool NextTreeNodeOpenVal; // Storage for SetNextTreeNode** functions
603 ImGuiCond NextTreeNodeOpenCond;
604
605 // Navigation data (for gamepad/keyboard)
606 ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow'
607 ImGuiID NavId; // Focused item for navigation
608 ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0, also set when calling ActivateItem()
609 ImGuiID NavActivateDownId; // ~~ IsNavInputDown(ImGuiNavInput_Activate) ? NavId : 0
610 ImGuiID NavActivatePressedId; // ~~ IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0
611 ImGuiID NavInputId; // ~~ IsNavInputPressed(ImGuiNavInput_Input) ? NavId : 0
612 ImGuiID NavJustTabbedId; // Just tabbed to this id.
613 ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest)
614 ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame
615 ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode?
616 ImRect NavScoringRectScreen; // Rectangle used for scoring, in screen space. Based of window->DC.NavRefRectRel[], modified for directional navigation scoring.
617 int NavScoringCount; // Metrics for debugging
618 ImGuiWindow* NavWindowingTarget; // When selecting a window (holding Menu+FocusPrev/Next, or equivalent of CTRL-TAB) this window is temporarily displayed front-most.
619 float NavWindowingHighlightTimer;
620 float NavWindowingHighlightAlpha;
621 bool NavWindowingToggleLayer;
622 int NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
623 int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
624 bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRefRectRel is valid
625 bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
626 bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (NB: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover)
627 bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
628 bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest
629 bool NavInitRequest; // Init request for appearing window to select first item
630 bool NavInitRequestFromMove;
631 ImGuiID NavInitResultId;
632 ImRect NavInitResultRectRel;
633 bool NavMoveFromClampedRefRect; // Set by manual scrolling, if we scroll to a point where NavId isn't visible we reset navigation from visible items
634 bool NavMoveRequest; // Move request for this frame
635 ImGuiNavForward NavMoveRequestForward; // None / ForwardQueued / ForwardActive (this is used to navigate sibling parent menus from a child menu)
636 ImGuiDir NavMoveDir, NavMoveDirLast; // Direction of the move request (left/right/up/down), direction of the previous move request
637 ImGuiNavMoveResult NavMoveResultLocal; // Best move request candidate within NavWindow
638 ImGuiNavMoveResult NavMoveResultOther; // Best move request candidate within NavWindow's flattened hierarchy (when using the NavFlattened flag)
639
640 // Render
641 ImDrawData DrawData; // Main ImDrawData instance to pass render information to the user
642 ImDrawDataBuilder DrawDataBuilder;
643 float ModalWindowDarkeningRatio;
644 ImDrawList OverlayDrawList; // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays
645 ImGuiMouseCursor MouseCursor;
646
647 // Drag and Drop
648 bool DragDropActive;
649 ImGuiDragDropFlags DragDropSourceFlags;
650 int DragDropMouseButton;
651 ImGuiPayload DragDropPayload;
652 ImRect DragDropTargetRect;
653 ImGuiID DragDropTargetId;
654 float DragDropAcceptIdCurrRectSurface;
655 ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload)
656 ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
657 int DragDropAcceptFrameCount; // Last time a target expressed a desire to accept the source
658 ImVector<unsigned char> DragDropPayloadBufHeap; // We don't expose the ImVector<> directly
659 unsigned char DragDropPayloadBufLocal[8]; // Local buffer for small payloads
660
661 // Widget state
662 ImGuiTextEditState InputTextState;
663 ImFont InputTextPasswordFont;
664 ImGuiID ScalarAsInputTextId; // Temporary text input when CTRL+clicking on a slider, etc.
665 ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
666 ImVec4 ColorPickerRef;
667 float DragCurrentValue; // Currently dragged value, always float, not rounded by end-user precision settings
668 ImVec2 DragLastMouseDelta;
669 float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
670 float DragSpeedScaleSlow;
671 float DragSpeedScaleFast;
672 ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
673 int TooltipOverrideCount;
674 ImVector<char> PrivateClipboard; // If no custom clipboard handler is defined
675 ImVec2 PlatformImePos, PlatformImeLastPos; // Cursor position request & last passed to the OS Input Method Editor
676
677 // Settings
678 bool SettingsLoaded;
679 float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
680 ImVector<ImGuiWindowSettings> SettingsWindows; // .ini settings for ImGuiWindow
681 ImVector<ImGuiSettingsHandler> SettingsHandlers; // List of .ini settings handlers
682
683 // Logging
684 bool LogEnabled;
685 FILE* LogFile; // If != NULL log to stdout/ file
686 ImGuiTextBuffer* LogClipboard; // Else log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
687 int LogStartDepth;
688 int LogAutoExpandMaxDepth;
689
690 // Misc
691 float FramerateSecPerFrame[120]; // Calculate estimate of framerate for user over the last 2 seconds.
692 int FramerateSecPerFrameIdx;
693 float FramerateSecPerFrameAccum;
694 int WantCaptureMouseNextFrame; // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags
695 int WantCaptureKeyboardNextFrame;
696 int WantTextInputNextFrame;
697 char TempBuffer[1024 * 3 + 1]; // Temporary text buffer
698
699 ImGuiContext(ImFontAtlas* shared_font_atlas) : OverlayDrawList(NULL)
700 {
701 Initialized = false;
702 Font = NULL;
703 FontSize = FontBaseSize = 0.0f;
704 FontAtlasOwnedByContext = shared_font_atlas ? false : true;
705 IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
706
707 Time = 0.0f;
708 FrameCount = 0;
709 FrameCountEnded = FrameCountRendered = -1;
710 WindowsActiveCount = 0;
711 CurrentWindow = NULL;
712 HoveredWindow = NULL;
713 HoveredRootWindow = NULL;
714 HoveredId = 0;
715 HoveredIdAllowOverlap = false;
716 HoveredIdPreviousFrame = 0;
717 HoveredIdTimer = 0.0f;
718 ActiveId = 0;
719 ActiveIdPreviousFrame = 0;
720 ActiveIdTimer = 0.0f;
721 ActiveIdIsAlive = false;
722 ActiveIdIsJustActivated = false;
723 ActiveIdAllowOverlap = false;
724 ActiveIdAllowNavDirFlags = 0;
725 ActiveIdClickOffset = ImVec2(-1, -1);
726 ActiveIdWindow = NULL;
727 ActiveIdSource = ImGuiInputSource_None;
728 MovingWindow = NULL;
729 NextTreeNodeOpenVal = false;
730 NextTreeNodeOpenCond = 0;
731
732 NavWindow = NULL;
733 NavId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
734 NavJustTabbedId = NavJustMovedToId = NavNextActivateId = 0;
735 NavInputSource = ImGuiInputSource_None;
736 NavScoringRectScreen = ImRect();
737 NavScoringCount = 0;
738 NavWindowingTarget = NULL;
739 NavWindowingHighlightTimer = NavWindowingHighlightAlpha = 0.0f;
740 NavWindowingToggleLayer = false;
741 NavLayer = 0;
742 NavIdTabCounter = INT_MAX;
743 NavIdIsAlive = false;
744 NavMousePosDirty = false;
745 NavDisableHighlight = true;
746 NavDisableMouseHover = false;
747 NavAnyRequest = false;
748 NavInitRequest = false;
749 NavInitRequestFromMove = false;
750 NavInitResultId = 0;
751 NavMoveFromClampedRefRect = false;
752 NavMoveRequest = false;
753 NavMoveRequestForward = ImGuiNavForward_None;
754 NavMoveDir = NavMoveDirLast = ImGuiDir_None;
755
756 ModalWindowDarkeningRatio = 0.0f;
757 OverlayDrawList._Data = &DrawListSharedData;
758 OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
759 MouseCursor = ImGuiMouseCursor_Arrow;
760
761 DragDropActive = false;
762 DragDropSourceFlags = 0;
763 DragDropMouseButton = -1;
764 DragDropTargetId = 0;
765 DragDropAcceptIdCurrRectSurface = 0.0f;
766 DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
767 DragDropAcceptFrameCount = -1;
768 memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal));
769
770 ScalarAsInputTextId = 0;
771 ColorEditOptions = ImGuiColorEditFlags__OptionsDefault;
772 DragCurrentValue = 0.0f;
773 DragLastMouseDelta = ImVec2(0.0f, 0.0f);
774 DragSpeedDefaultRatio = 1.0f / 100.0f;
775 DragSpeedScaleSlow = 1.0f / 100.0f;
776 DragSpeedScaleFast = 10.0f;
777 ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
778 TooltipOverrideCount = 0;
779 PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX);
780
781 SettingsLoaded = false;
782 SettingsDirtyTimer = 0.0f;
783
784 LogEnabled = false;
785 LogFile = NULL;
786 LogClipboard = NULL;
787 LogStartDepth = 0;
788 LogAutoExpandMaxDepth = 2;
789
790 memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));
791 FramerateSecPerFrameIdx = 0;
792 FramerateSecPerFrameAccum = 0.0f;
793 WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
794 memset(TempBuffer, 0, sizeof(TempBuffer));
795 }
796};
797
798// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
799// This is going to be exposed in imgui.h when stabilized enough.
800enum ImGuiItemFlags_
801{
802 ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true
803 ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
804 ImGuiItemFlags_Disabled = 1 << 2, // false // FIXME-WIP: Disable interactions but doesn't affect visuals. Should be: grey out and disable interactions with widgets that affect data + view widgets (WIP)
805 ImGuiItemFlags_NoNav = 1 << 3, // false
806 ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
807 ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
808 ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus
809};
810
811// Transient per-window data, reset at the beginning of the frame
812// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiDrawContext is quite tenuous and could be reconsidered.
813struct IMGUI_API ImGuiDrawContext
814{
815 ImVec2 CursorPos;
816 ImVec2 CursorPosPrevLine;
817 ImVec2 CursorStartPos;
818 ImVec2 CursorMaxPos; // Used to implicitly calculate the size of our contents, always growing during the frame. Turned into window->SizeContents at the beginning of next frame
819 float CurrentLineHeight;
820 float CurrentLineTextBaseOffset;
821 float PrevLineHeight;
822 float PrevLineTextBaseOffset;
823 float LogLinePosY;
824 int TreeDepth;
825 ImU32 TreeDepthMayJumpToParentOnPop; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31
826 ImGuiID LastItemId;
827 ImGuiItemStatusFlags LastItemStatusFlags;
828 ImRect LastItemRect; // Interaction rect
829 ImRect LastItemDisplayRect; // End-user display rect (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect)
830 bool NavHideHighlightOneFrame;
831 bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f)
832 int NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
833 int NavLayerCurrentMask; // = (1 << NavLayerCurrent) used by ItemAdd prior to clipping.
834 int NavLayerActiveMask; // Which layer have been written to (result from previous frame)
835 int NavLayerActiveMaskNext; // Which layer have been written to (buffer for current frame)
836 bool MenuBarAppending; // FIXME: Remove this
837 ImVec2 MenuBarOffset; // MenuBarOffset.x is sort of equivalent of a per-layer CursorPos.x, saved/restored as we switch to the menu bar. The only situation when MenuBarOffset.y is > 0 if when (SafeAreaPadding.y > FramePadding.y), often used on TVs.
838 ImVector<ImGuiWindow*> ChildWindows;
839 ImGuiStorage* StateStorage;
840 ImGuiLayoutType LayoutType;
841 ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin()
842
843 // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
844 ImGuiItemFlags ItemFlags; // == ItemFlagsStack.back() [empty == ImGuiItemFlags_Default]
845 float ItemWidth; // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
846 float TextWrapPos; // == TextWrapPosStack.back() [empty == -1.0f]
847 ImVector<ImGuiItemFlags>ItemFlagsStack;
848 ImVector<float> ItemWidthStack;
849 ImVector<float> TextWrapPosStack;
850 ImVector<ImGuiGroupData>GroupStack;
851 int StackSizesBackup[6]; // Store size of various stacks for asserting
852
853 float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
854 float GroupOffsetX;
855 float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
856 ImGuiColumnsSet* ColumnsSet; // Current columns set
857
858 ImGuiDrawContext()
859 {
860 CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
861 CurrentLineHeight = PrevLineHeight = 0.0f;
862 CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
863 LogLinePosY = -1.0f;
864 TreeDepth = 0;
865 TreeDepthMayJumpToParentOnPop = 0x00;
866 LastItemId = 0;
867 LastItemStatusFlags = 0;
868 LastItemRect = LastItemDisplayRect = ImRect();
869 NavHideHighlightOneFrame = false;
870 NavHasScroll = false;
871 NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
872 NavLayerCurrent = 0;
873 NavLayerCurrentMask = 1 << 0;
874 MenuBarAppending = false;
875 MenuBarOffset = ImVec2(0.0f, 0.0f);
876 StateStorage = NULL;
877 LayoutType = ParentLayoutType = ImGuiLayoutType_Vertical;
878 ItemWidth = 0.0f;
879 ItemFlags = ImGuiItemFlags_Default_;
880 TextWrapPos = -1.0f;
881 memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
882
883 IndentX = 0.0f;
884 GroupOffsetX = 0.0f;
885 ColumnsOffsetX = 0.0f;
886 ColumnsSet = NULL;
887 }
888};
889
890// Windows data
891struct IMGUI_API ImGuiWindow
892{
893 char* Name;
894 ImGuiID ID; // == ImHash(Name)
895 ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
896 ImVec2 Pos; // Position (always rounded-up to nearest pixel)
897 ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
898 ImVec2 SizeFull; // Size when non collapsed
899 ImVec2 SizeFullAtLastBegin; // Copy of SizeFull at the end of Begin. This is the reference value we'll use on the next frame to decide if we need scrollbars.
900 ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame. Include decoration, window title, border, menu, etc.
901 ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
902 ImRect ContentsRegionRect; // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
903 ImVec2 WindowPadding; // Window padding at the time of begin.
904 float WindowRounding; // Window rounding at the time of begin.
905 float WindowBorderSize; // Window border size at the time of begin.
906 ImGuiID MoveId; // == window->GetID("#MOVE")
907 ImGuiID ChildId; // Id of corresponding item in parent window (for child windows)
908 ImVec2 Scroll;
909 ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
910 ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
911 ImVec2 ScrollbarSizes;
912 bool ScrollbarX, ScrollbarY;
913 bool Active; // Set to true on Begin(), unless Collapsed
914 bool WasActive;
915 bool WriteAccessed; // Set to true when any widget access the current window
916 bool Collapsed; // Set when collapsing window to become only title-bar
917 bool CollapseToggleWanted;
918 bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
919 bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
920 bool CloseButton; // Set when the window has a close button (p_open != NULL)
921 int BeginOrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
922 int BeginOrderWithinContext; // Order within entire imgui context. This is mostly used for debugging submission order related issues.
923 int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
924 ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
925 int AutoFitFramesX, AutoFitFramesY;
926 bool AutoFitOnlyGrows;
927 int AutoFitChildAxises;
928 ImGuiDir AutoPosLastDirection;
929 int HiddenFrames;
930 ImGuiCond SetWindowPosAllowFlags; // store acceptable condition flags for SetNextWindowPos() use.
931 ImGuiCond SetWindowSizeAllowFlags; // store acceptable condition flags for SetNextWindowSize() use.
932 ImGuiCond SetWindowCollapsedAllowFlags; // store acceptable condition flags for SetNextWindowCollapsed() use.
933 ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
934 ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0,0) when positioning from top-left corner; ImVec2(0.5f,0.5f) for centering; ImVec2(1,1) for bottom right.
935
936 ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
937 ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
938 ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
939 ImRect WindowRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.
940 ImRect InnerRect, InnerClipRect;
941 int LastFrameActive;
942 float ItemWidthDefault;
943 ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items
944 ImGuiStorage StateStorage;
945 ImVector<ImGuiColumnsSet> ColumnsStorage;
946 float FontWindowScale; // User scale multiplier per-window
947
948 ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
949 ImDrawList DrawListInst;
950 ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
951 ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window.
952 ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
953 ImGuiWindow* RootWindowForTabbing; // Point to ourself or first ancestor which can be CTRL-Tabbed into.
954 ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
955
956 ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.)
957 ImGuiID NavLastIds[2]; // Last known NavId for this window, per layer (0/1)
958 ImRect NavRectRel[2]; // Reference rectangle, in window relative space
959
960 // Navigation / Focus
961 // FIXME-NAV: Merge all this with the new Nav system, at least the request variables should be moved to ImGuiContext
962 int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
963 int FocusIdxTabCounter; // (same, but only count widgets which you can Tab through)
964 int FocusIdxAllRequestCurrent; // Item being requested for focus
965 int FocusIdxTabRequestCurrent; // Tab-able item being requested for focus
966 int FocusIdxAllRequestNext; // Item being requested for focus, for next update (relies on layout to be stable between the frame pressing TAB and the next frame)
967 int FocusIdxTabRequestNext; // "
968
969public:
970 ImGuiWindow(ImGuiContext* context, const char* name);
971 ~ImGuiWindow();
972
973 ImGuiID GetID(const char* str, const char* str_end = NULL);
974 ImGuiID GetID(const void* ptr);
975 ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
976 ImGuiID GetIDFromRectangle(const ImRect& r_abs);
977
978 // We don't use g.FontSize because the window may be != g.CurrentWidow.
979 ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
980 float CalcFontSize() const { return GImGui->FontBaseSize * FontWindowScale; }
981 float TitleBarHeight() const { return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f; }
982 ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
983 float MenuBarHeight() const { return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
984 ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
985};
986
987// Backup and restore just enough data to be able to use IsItemHovered() on item A after another B in the same window has overwritten the data.
988struct ImGuiItemHoveredDataBackup
989{
990 ImGuiID LastItemId;
991 ImGuiItemStatusFlags LastItemStatusFlags;
992 ImRect LastItemRect;
993 ImRect LastItemDisplayRect;
994
995 ImGuiItemHoveredDataBackup() { Backup(); }
996 void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; }
997 void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; }
998};
999
1000//-----------------------------------------------------------------------------
1001// Internal API
1002// No guarantee of forward compatibility here.
1003//-----------------------------------------------------------------------------
1004
1005namespace ImGui
1006{
1007 // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
1008 // If this ever crash because g.CurrentWindow is NULL it means that either
1009 // - ImGui::NewFrame() has never been called, which is illegal.
1010 // - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
1011 inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
1012 inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
1013 IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
1014 IMGUI_API void FocusWindow(ImGuiWindow* window);
1015 IMGUI_API void BringWindowToFront(ImGuiWindow* window);
1016 IMGUI_API void BringWindowToBack(ImGuiWindow* window);
1017 IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
1018 IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
1019
1020 IMGUI_API void Initialize(ImGuiContext* context);
1021 IMGUI_API void Shutdown(ImGuiContext* context); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
1022
1023 IMGUI_API void NewFrameUpdateHoveredWindowAndCaptureFlags();
1024
1025 IMGUI_API void MarkIniSettingsDirty();
1026 IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
1027 IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id);
1028
1029 IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
1030 IMGUI_API ImGuiID GetActiveID();
1031 IMGUI_API void SetFocusID(ImGuiID id, ImGuiWindow* window);
1032 IMGUI_API void ClearActiveID();
1033 IMGUI_API void SetHoveredID(ImGuiID id);
1034 IMGUI_API ImGuiID GetHoveredID();
1035 IMGUI_API void KeepAliveID(ImGuiID id);
1036
1037 IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
1038 IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
1039 IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
1040 IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
1041 IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
1042 IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop = true); // Return true if focus is requested
1043 IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
1044 IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
1045 IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
1046 IMGUI_API void PushMultiItemsWidths(int components, float width_full = 0.0f);
1047 IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
1048 IMGUI_API void PopItemFlag();
1049
1050 IMGUI_API void SetCurrentFont(ImFont* font);
1051
1052 IMGUI_API void OpenPopupEx(ImGuiID id);
1053 IMGUI_API void ClosePopup(ImGuiID id);
1054 IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window);
1055 IMGUI_API bool IsPopupOpen(ImGuiID id);
1056 IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
1057 IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
1058 IMGUI_API ImGuiWindow* GetFrontMostPopupModal();
1059
1060 IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
1061 IMGUI_API void NavMoveRequestCancel();
1062 IMGUI_API void ActivateItem(ImGuiID id); // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again.
1063
1064 IMGUI_API float GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode);
1065 IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f);
1066 IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
1067
1068 IMGUI_API void Scrollbar(ImGuiLayoutType direction);
1069 IMGUI_API void VerticalSeparator(); // Vertical separator, for menu bars (use current line height). not exposed because it is misleading what it doesn't have an effect on regular layout.
1070 IMGUI_API bool SplitterBehavior(ImGuiID id, const ImRect& bb, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f);
1071
1072 IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id);
1073 IMGUI_API void ClearDragDrop();
1074 IMGUI_API bool IsDragDropPayloadBeingAccepted();
1075
1076 // FIXME-WIP: New Columns API
1077 IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
1078 IMGUI_API void EndColumns(); // close columns
1079 IMGUI_API void PushColumnClipRect(int column_index = -1);
1080
1081 // NB: All position are in absolute pixels coordinates (never using window coordinates internally)
1082 // AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT.
1083 IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
1084 IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
1085 IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL);
1086 IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
1087 IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
1088 IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
1089 IMGUI_API void RenderArrow(ImVec2 pos, ImGuiDir dir, float scale = 1.0f);
1090 IMGUI_API void RenderBullet(ImVec2 pos);
1091 IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
1092 IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
1093 IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
1094 IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
1095
1096 IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
1097 IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
1098 IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos, float radius);
1099
1100 IMGUI_API bool SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, const char* format, float power, ImGuiSliderFlags flags = 0);
1101 IMGUI_API bool SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* format, float power);
1102 IMGUI_API bool SliderIntN(const char* label, int* v, int components, int v_min, int v_max, const char* format);
1103
1104 IMGUI_API bool DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_speed, float v_min, float v_max, const char* format, float power);
1105 IMGUI_API bool DragFloatN(const char* label, float* v, int components, float v_speed, float v_min, float v_max, const char* format, float power);
1106 IMGUI_API bool DragIntN(const char* label, int* v, int components, float v_speed, int v_min, int v_max, const char* format);
1107
1108 IMGUI_API bool InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
1109 IMGUI_API bool InputFloatN(const char* label, float* v, int components, const char* format, ImGuiInputTextFlags extra_flags);
1110 IMGUI_API bool InputIntN(const char* label, int* v, int components, ImGuiInputTextFlags extra_flags);
1111 IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* format, ImGuiInputTextFlags extra_flags = 0);
1112 IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* data_ptr, const char* format);
1113
1114 IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
1115 IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
1116
1117 IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
1118 IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
1119 IMGUI_API void TreePushRawID(ImGuiID id);
1120
1121 IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size);
1122
1123 IMGUI_API const char* ParseFormatTrimDecorationsLeading(const char* format);
1124 IMGUI_API const char* ParseFormatTrimDecorations(const char* format, char* buf, int buf_size);
1125 IMGUI_API int ParseFormatPrecision(const char* format, int default_value);
1126 IMGUI_API float RoundScalarWithFormat(const char* format, float value);
1127
1128 // Shade functions (write over already created vertices)
1129 IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
1130 IMGUI_API void ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_start, ImDrawVert* vert_end, float gradient_p0_x, float gradient_p1_x);
1131 IMGUI_API void ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
1132
1133} // namespace ImGui
1134
1135 // ImFontAtlas internals
1136IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
1137IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
1138IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
1139IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* spc);
1140IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
1141IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
1142IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
1143
1144#ifdef __clang__
1145#pragma clang diagnostic pop
1146#endif
1147
1148#ifdef _MSC_VER
1149#pragma warning (pop)
1150#endif
Note: See TracBrowser for help on using the repository browser.