KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
KarmaGui.h
Go to the documentation of this file.
1
10
11// Dear ImGui (1.89.2) is Copyright (c) 2014-2023 Omar Cornut. This code is practically ImGui in Karma context, with minor modifications of course!!
12
13#pragma once
14
15#if(defined(__clang__) || defined(__GNUC__))
16#define KG_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
17#define KG_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
18#else
19#define KG_FMTARGS(FMT)
20#define KG_FMTLIST(FMT)
21#endif
22
23#define KG_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers!
24#define KG_UNUSED(_VAR) ((void)(_VAR))
25#define KG_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11
26
27
28//-----------------------------------------------------------------------------
29// [SECTION] Forward declarations and basic types
30//-----------------------------------------------------------------------------
31
32// Forward declarations (KG = KarmaGui)
33struct KGDrawChannel; // Temporary storage to output draw commands out of order, used by KGDrawListSplitter and KGDrawList::ChannelsSplit()
34struct KGDrawCmd; // A single draw command within a parent KGDrawList (generally maps to 1 GPU draw call, unless it is a callback)
35struct KGDrawData; // All draw command lists required to render the frame + pos/size coordinates to use for the projection matrix.
36struct KGDrawList; // A single draw command list (generally one per window, conceptually you may see this as a dynamic "mesh" builder)
37struct KGDrawListSharedData; // Data shared among multiple draw lists (typically owned by parent ImGui context, but you may create one yourself)
38struct KGDrawListSplitter; // Helper to split a draw list into different layers which can be drawn into out of order, then flattened back.
39struct KGDrawVert; // A single vertex (pos + uv + col = 20 bytes by default. Override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT)
40 // May need to feed in vertex shader provision
41struct KGFont; // Runtime data for a single font within a parent KGFontAtlas
42struct KGFontAtlas; // Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader
43struct KGFontBuilderIO; // Opaque interface to a font builder (stb_truetype or FreeType).
44struct KGFontConfig; // Configuration data when adding a font or merging fonts
45struct KGFontGlyph; // A single font glyph (code point + coordinates within in KGFontAtlas + offset)
46struct KGFontGlyphRangesBuilder; // Helper to build glyph ranges from text/string data
47struct KGColor; // Helper functions to create a color that can be converted to either u32 or float4 (*OBSOLETE* please avoid using)
48struct KarmaGuiContext; // KarmaGui context (opaque structure, unless including KarmaGuiInternal.h)
49struct KarmaGuiIO; // Main configuration and I/O between your application and ImGui
50struct KarmaGuiInputTextCallbackData; // Shared state of InputText() when using custom KarmaGuiInputTextCallback (rare/advanced use)
51struct KarmaGuiKeyData; // Storage for KarmaGuiIO and IsKeyDown(), IsKeyPressed() etc functions.
52struct KarmaGuiListClipper; // Helper to manually clip large list of items
53struct KarmaGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame
54struct KarmaGuiPayload; // User data payload for drag and drop operations
55struct KarmaGuiPlatformIO; // Multi-viewport support: interface for Platform/Renderer backends + viewports to render
56struct KarmaGuiPlatformMonitor; // Multi-viewport support: user-provided bounds for each connected monitor/display. Used when positioning popups and tooltips to avoid them straddling monitors
57struct KarmaGuiPlatformImeData; // Platform IME data for io.SetPlatformImeDataFn() function.
58struct KarmaGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use)
59struct KarmaGuiStorage; // Helper for key->value storage
60struct KarmaGuiStyle; // Runtime data for styling/colors
61struct KarmaGuiTableSortSpecs; // Sorting specifications for a table (often handling sort specs for a single column, occasionally more)
62struct KarmaGuiTableColumnSortSpecs; // Sorting specification for one column of a table
63struct KarmaGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder)
64struct KarmaGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]")
65struct KarmaGuiViewport; // A Platform Window (always 1 unless multi-viewport are enabled. One per platform window to output to). In the future may represent Platform Monitor
66struct KarmaGuiWindowClass; // Window class (rare/advanced uses: provide hints to the platform backend via altered viewport flags and parent/child info)
67
68// Enumerations
69// - We don't use strongly typed enums much because they add constraints (can't extend in private code, can't store typed in bit fields, extra casting on iteration)
70// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists!
71// In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
72// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
73// What about XCode und QTCreator Omar?
74enum KarmaGuiKey : int; // -> enum KarmaGuiKey // Enum: A key identifier (KGGuiKey_XXX or KGGuiMod_XXX value)
75
76typedef int KarmaGuiCol; // -> enum KGGuiCol_ // Enum: A color identifier for styling
77typedef int KarmaGuiCond; // -> enum KGGuiCond_ // Enum: A condition for many Set*() functions
78typedef int KarmaGuiDataType; // -> enum KGGuiDataType_ // Enum: A primary data type
79typedef int KarmaGuiDir; // -> enum KGGuiDir_ // Enum: A cardinal direction
80typedef int KarmaGuiMouseButton; // -> enum KGGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle)
81typedef int KarmaGuiMouseCursor; // -> enum KGGuiMouseCursor_ // Enum: A mouse cursor shape
82typedef int KarmaGuiSortDirection; // -> enum KGGuiSortDirection_ // Enum: A sorting direction (ascending or descending)
83typedef int KarmaGuiStyleVar; // -> enum KGGuiStyleVar_ // Enum: A variable identifier for styling
84typedef int KarmaGuiTableBgTarget; // -> enum KGGuiTableBgTarget_ // Enum: A color target for TableSetBgColor()
85
86// Flags (declared as int for compatibility with old C++, to allow using as flags without overhead, and to not pollute the top of this file)
87typedef int KGDrawFlags; // -> enum KGDrawFlags_ // Flags: for KGDrawList functions
88typedef int KGDrawListFlags; // -> enum KGDrawListFlags_ // Flags: for KGDrawList instance
89typedef int KGFontAtlasFlags; // -> enum KGFontAtlasFlags_ // Flags: for KGFontAtlas build
90typedef int KarmaGuiBackendFlags; // -> enum KGGuiBackendFlags_ // Flags: for io.BackendFlags
91typedef int KarmaGuiButtonFlags; // -> enum KGGuiButtonFlags_ // Flags: for InvisibleButton()
92typedef int KarmaGuiColorEditFlags; // -> enum KGGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc.
93typedef int KarmaGuiConfigFlags; // -> enum KGGuiConfigFlags_ // Flags: for io.ConfigFlags
94typedef int KarmaGuiComboFlags; // -> enum KGGuiComboFlags_ // Flags: for BeginCombo()
95typedef int KarmaGuiDockNodeFlags; // -> enum KGGuiDockNodeFlags_ // Flags: for DockSpace()
96typedef int KarmaGuiDragDropFlags; // -> enum KGGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload()
97typedef int KarmaGuiFocusedFlags; // -> enum KGGuiFocusedFlags_ // Flags: for IsWindowFocused()
98typedef int KarmaGuiHoveredFlags; // -> enum KGGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
99typedef int KarmaGuiInputFlags; // -> enum KGGuiInputFlags_ // Flags: for Shortcut() (+ upcoming advanced versions of IsKeyPressed()/IsMouseClicked()/SetKeyOwner()/SetItemKeyOwner() currently in imgui_internal.h)
100typedef int KarmaGuiInputTextFlags; // -> enum KGGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
101typedef int KarmaGuiKeyChord; // -> KarmaGuiKey | KGGuiMod_XXX // Flags: for storage only for now: an KarmaGuiKey optionally OR-ed with one or more KGGuiMod_XXX values.
102typedef int KarmaGuiPopupFlags; // -> enum KGGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
103typedef int KarmaGuiSelectableFlags; // -> enum KGGuiSelectableFlags_ // Flags: for Selectable()
104typedef int KarmaGuiSliderFlags; // -> enum KGGuiSliderFlags_ // Flags: for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc.
105typedef int KarmaGuiTabBarFlags; // -> enum KGGuiTabBarFlags_ // Flags: for BeginTabBar()
106typedef int KarmaGuiTabItemFlags; // -> enum KGGuiTabItemFlags_ // Flags: for BeginTabItem()
107typedef int KarmaGuiTableFlags; // -> enum KGGuiTableFlags_ // Flags: For BeginTable()
108typedef int KarmaGuiTableColumnFlags; // -> enum KGGuiTableColumnFlags_// Flags: For TableSetupColumn()
109typedef int KarmaGuiTableRowFlags; // -> enum KGGuiTableRowFlags_ // Flags: For TableNextRow()
110typedef int KarmaGuiTreeNodeFlags; // -> enum KGGuiTreeNodeFlags_ // Flags: for TreeNode(), TreeNodeEx(), CollapsingHeader()
111typedef int KarmaGuiViewportFlags; // -> enum KGGuiViewportFlags_ // Flags: for KarmaGuiViewport
112typedef int KarmaGuiWindowFlags; // -> enum KGGuiWindowFlags_ // Flags: for Begin(), BeginChild()
113typedef void* KGTextureID; // Default: store a pointer or an integer fitting in a pointer (most renderer backends are ok with that)
114
115
116// KGDrawIdx: vertex index. [Compile-time configurable type]
117// - To use 16-bit indices + allow large meshes: backend need to set 'io.BackendFlags |= KGGuiBackendFlags_RendererHasVtxOffset' and handle KGDrawCmd::VtxOffset (recommended).
118// - To use 32-bit indices: override with '#define KGDrawIdx unsigned int' in your imconfig.h file.
119#ifndef KGDrawIdx
120typedef unsigned short KGDrawIdx; // Default: 16-bit (for maximum compatibility with renderer backends)
121#endif
122
123// ////////////////////////////////////////////////////
124// // Needs hooked code with Karma's types if possible
125// ////////////////////////////////////////////////////
126
127// Scalar data types
128// Seems like be restricted to KarmaGui
129typedef unsigned int KGGuiID;// A unique ID used by widgets (typically the result of hashing a stack of string)
130typedef signed char KGS8; // 8-bit signed integer
131typedef unsigned char KGU8; // 8-bit unsigned integer
132typedef signed short KGS16; // 16-bit signed integer
133typedef unsigned short KGU16; // 16-bit unsigned integer
134typedef signed int KGS32; // 32-bit signed integer == int
135typedef unsigned int KGU32; // 32-bit unsigned integer (often used to store packed colors)
136typedef signed long long KGS64; // 64-bit signed integer
137typedef unsigned long long KGU64; // 64-bit unsigned integer
138
139// Character types
140// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
141typedef unsigned short KGWchar16; // A single decoded U16 character/code point. We encode them as multi bytes UTF-8 when used in strings.
142typedef KGWchar16 KGWchar;
143
144// Callback and functions types
145typedef int (*KarmaGuiInputTextCallback)(KarmaGuiInputTextCallbackData* data); // Callback function for ImGui::InputText()
146typedef void (*KarmaGuiSizeCallback)(KarmaGuiSizeCallbackData* data); // Callback function for ImGui::SetNextWindowSizeConstraints()
147typedef void* (*KarmaGuiMemAllocFunc)(size_t sz, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
148typedef void (*KarmaGuiMemFreeFunc)(void* ptr, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
149
150// KGVec2: 2D vector used to store positions, sizes etc. [Compile-time configurable type]
151// This is a frequently used type in the API. Consider using IM_VEC2_CLASS_EXTRA to create implicit cast from/to our preferred type.
152struct KGVec2
153{
154 float x, y;
155 constexpr KGVec2() : x(0.0f), y(0.0f) { }
156 constexpr KGVec2(float _x, float _y) : x(_x), y(_y) { }
157 float operator[] (size_t idx) const { KR_CORE_ASSERT(idx <= 1, ""); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
158 float& operator[] (size_t idx) { KR_CORE_ASSERT(idx <= 1, ""); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
159};
160
161// KGVec4: 4D vector used to store clipping rectangles, colors etc. [Compile-time configurable type]
162struct KGVec4
163{
164 float x, y, z, w;
165 constexpr KGVec4() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) { }
166 constexpr KGVec4(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) { }
167#ifdef KG_VEC4_CLASS_EXTRA
168 KG_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and KGVec4.
169#endif
170};
171
172namespace Karma
173{
188 {
189 public:
190 // Context creation and access
191 static KarmaGuiContext* CreateContext(KGFontAtlas* shared_font_atlas = NULL);
192 static void DestroyContext(KarmaGuiContext* ctx = NULL); // NULL = destroy current context
193 static KarmaGuiContext* GetCurrentContext();
194 static void SetCurrentContext(KarmaGuiContext* ctx);
195
196 // Main
197 static KarmaGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags)
198 static KarmaGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame!
199 static void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().
200 static void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all!
207 static void Render();
208 static KGDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render.
209
210 // Demo, Debug, Information
211 static void ShowDemoWindow(bool* p_open = NULL); // create Demo window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
212 static void ShowMetricsWindow(bool* p_open = NULL); // create Metrics/Debugger window. display Dear ImGui internals: windows, draw commands, various internal state, etc.
213 static void ShowDebugLogWindow(bool* p_open = NULL); // create Debug Log window. display a simplified log of important dear imgui events.
214 static void ShowStackToolWindow(bool* p_open = NULL); // create Stack Tool window. hover items with mouse to query information about the source of their unique ID.
215 static void ShowAboutWindow(bool* p_open = NULL); // create About window. display Dear ImGui version, credits and build/system information.
216 static void ShowStyleEditor(KarmaGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference KarmaGuiStyle structure to compare to, revert to and save to (else it uses the default style)
217 static bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles.
218 static void ShowFontSelector(const char* label); // add font selector block (not a window), essentially a combo listing the loaded fonts.
219 static void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as an end-user (mouse/keyboard controls).
220
221 // Styles
222 static void StyleColorsDark(KarmaGuiStyle* dst = NULL); // new, recommended style (default)
223 static void StyleColorsLight(KarmaGuiStyle* dst = NULL); // best used with borders and a custom, thicker font
224 static void StyleColorsClassic(KarmaGuiStyle* dst = NULL); // classic karmagui style
225 static void StyleColorsKarma(KarmaGuiStyle* dst = NULL); // Karma's style
226
227 // Windows
228 // - Begin() = push window to the stack and start appending to it. End() = pop window from the stack.
229 // - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window,
230 // which clicking will set the boolean to false when clicked.
231 // - You may append multiple times to the same window during the same frame by calling Begin()/End() pairs multiple times.
232 // Some information such as 'flags' or 'p_open' will only be considered by the first call to Begin().
233 // - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
234 // anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
235 // [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
236 // BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
237 // returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
238 // - Note that the bottom of window stack always contains a window called "Debug".
239 static bool Begin(const char* name, bool* p_open = NULL, KarmaGuiWindowFlags flags = 0);
240 static void End();
241
242 // Child Windows
243 // - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child.
244 // - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. KGVec2(0,400).
245 // - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
246 // Always call a matching EndChild() for each BeginChild() call, regardless of its return value.
247 // [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
248 // BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
249 // returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
250 static bool BeginChild(const char* str_id, const KGVec2& size = KGVec2(0, 0), bool border = false, KarmaGuiWindowFlags flags = 0);
251 static bool BeginChild(KGGuiID id, const KGVec2& size = KGVec2(0, 0), bool border = false, KarmaGuiWindowFlags flags = 0);
252 static void EndChild();
253
254 // Windows Utilities
255 // - 'current window' = the window we are appending into while inside a Begin()/End() block. 'next window' = next window we will Begin() into.
256 static bool IsWindowAppearing();
257 static bool IsWindowCollapsed();
258 static bool IsWindowFocused(KarmaGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options.
259 static bool IsWindowHovered(KarmaGuiHoveredFlags flags=0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ!
260 static KGDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives
261 static float GetWindowDpiScale(); // get DPI scale currently associated to the current window's viewport.
262 static KGVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
263 static KGVec2 GetWindowSize(); // get current window size
264 static float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x)
265 static float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y)
266 static KarmaGuiViewport*GetWindowViewport(); // get viewport currently associated to the current window.
267
268 // Window manipulation
269 // - Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
270 static void SetNextWindowPos(const KGVec2& pos, KarmaGuiCond cond = 0, const KGVec2& pivot = KGVec2(0, 0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
271 static void SetNextWindowSize(const KGVec2& size, KarmaGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
272 static void SetNextWindowSizeConstraints(const KGVec2& size_min, const KGVec2& size_max, KarmaGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints.
273 static void SetNextWindowContentSize(const KGVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()
274 static void SetNextWindowCollapsed(bool collapsed, KarmaGuiCond cond = 0); // set next window collapsed state. call before Begin()
275 static void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
276 static void SetNextWindowScroll(const KGVec2& scroll); // set next window scrolling value (use < 0.0f to not affect a given axis).
277 static void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of KGGuiCol_WindowBg/ChildBg/PopupBg. you may also use KGGuiWindowFlags_NoBackground.
278 static void SetNextWindowViewport(KGGuiID viewport_id); // set next window viewport
279 static void SetWindowPos(const KGVec2& pos, KarmaGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
280 static void SetWindowSize(const KGVec2& size, KarmaGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to KGVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
281 static void SetWindowCollapsed(bool collapsed, KarmaGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
282 static void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus().
283 static void SetWindowFontScale(float scale); // [OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild KGFontAtlas + call style.ScaleAllSizes().
284 static void SetWindowPos(const char* name, const KGVec2& pos, KarmaGuiCond cond = 0); // set named window position.
285 static void SetWindowSize(const char* name, const KGVec2& size, KarmaGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
286 static void SetWindowCollapsed(const char* name, bool collapsed, KarmaGuiCond cond = 0); // set named window collapsed state
287 static void SetWindowFocus(const char* name); // set named window to be focused / top-most. use NULL to remove focus.
288
289 // Content region
290 // - Retrieve available space from a given point. GetContentRegionAvail() is frequently useful.
291 // - Those functions are bound to be redesigned (they are confusing, incomplete and the Min/Max return values are in local window coordinates which increases confusion)
292 static KGVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
293 static KGVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
294 static KGVec2 GetWindowContentRegionMin(); // content boundaries min for the full window (roughly (0,0)-Scroll), in window coordinates
295 static KGVec2 GetWindowContentRegionMax(); // content boundaries max for the full window (roughly (0,0)+Size-Scroll) where Size can be overridden with SetNextWindowContentSize(), in window coordinates
296
297 // Windows Scrolling
298 // - Any change of Scroll will be applied at the beginning of next frame in the first call to Begin().
299 // - You may instead use SetNextWindowScroll() prior to calling Begin() to avoid this delay, as an alternative to using SetScrollX()/SetScrollY().
300 static float GetScrollX(); // get scrolling amount [0 .. GetScrollMaxX()]
301 static float GetScrollY(); // get scrolling amount [0 .. GetScrollMaxY()]
302 static void SetScrollX(float scroll_x); // set scrolling amount [0 .. GetScrollMaxX()]
303 static void SetScrollY(float scroll_y); // set scrolling amount [0 .. GetScrollMaxY()]
304 static float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.x - WindowSize.x - DecorationsSize.x
305 static float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.y - WindowSize.y - DecorationsSize.y
306 static void SetScrollHereX(float center_x_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.
307 static void SetScrollHereY(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.
308 static void SetScrollFromPosX(float local_x, float center_x_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position.
309 static void SetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position.
310
311 // Parameters stacks (shared)
312 static void PushFont(KGFont* font); // use NULL as a shortcut to push default font
313 static void PopFont();
314 static void PushStyleColor(KarmaGuiCol idx, KGU32 col); // modify a style color. always use this if you modify the style after NewFrame().
315 static void PushStyleColor(KarmaGuiCol idx, const KGVec4& col);
316 static void PopStyleColor(int count = 1);
317 static void PushStyleVar(KarmaGuiStyleVar idx, float val); // modify a style float variable. always use this if you modify the style after NewFrame().
318 static void PushStyleVar(KarmaGuiStyleVar idx, const KGVec2& val); // modify a style KGVec2 variable. always use this if you modify the style after NewFrame().
319 static void PopStyleVar(int count = 1);
320 static void PushAllowKeyboardFocus(bool allow_keyboard_focus); // == tab stop enable. Allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
321 static void PopAllowKeyboardFocus();
322 static void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame.
323 static void PopButtonRepeat();
324
325 // Parameters stacks (current window)
326 static void PushItemWidth(float item_width); // push width of items for common large "item+label" widgets. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -FLT_MIN always align width to the right side).
327 static void PopItemWidth();
328 static void SetNextItemWidth(float item_width); // set width of the _next_ common large "item+label" widget. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -FLT_MIN always align width to the right side)
329 static float CalcItemWidth(); // width of item given pushed settings and current cursor position. NOT necessarily the width of last item unlike most 'Item' functions.
330 static void PushTextWrapPos(float wrap_local_pos_x = 0.0f); // push word-wrapping position for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space
331 static void PopTextWrapPos();
332
333 // Style read access
334 // - Use the style editor (ShowStyleEditor() function) to interactively see what the colors are)
335 static KGFont* GetFont(); // get current font
336 static float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
337 static KGVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the KGDrawList API
338 static KGU32 GetColorU32(KarmaGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier, packed as a 32-bit value suitable for KGDrawList
339 static KGU32 GetColorU32(const KGVec4& col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for KGDrawList
340 static KGU32 GetColorU32(KGU32 col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for KGDrawList
341 static const KGVec4& GetStyleColorVec4(KarmaGuiCol idx); // retrieve style color as stored in KarmaGuiStyle structure. use to feed back into PushStyleColor(), otherwise use GetColorU32() to get style color with style alpha baked in.
342
343 // Cursor / Layout
344 // - By "cursor" we mean the current output position.
345 // - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
346 // - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceding widget.
347 // - Attention! We currently have inconsistencies between window-local and absolute positions we will aim to fix with future API:
348 // Window-local coordinates: SameLine(), GetCursorPos(), SetCursorPos(), GetCursorStartPos(), GetContentRegionMax(), GetWindowContentRegion*(), PushTextWrapPos()
349 // Absolute coordinate: GetCursorScreenPos(), SetCursorScreenPos(), all KGDrawList:: functions.
350 static void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
351 static void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f); // call between widgets or groups to layout them horizontally. X position given in window coordinates.
352 static void NewLine(); // undo a SameLine() or force a new line when in a horizontal-layout context.
353 static void Spacing(); // add vertical spacing.
354 static void Dummy(const KGVec2& size); // add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into.
355 static void Indent(float indent_w = 0.0f); // move content position toward the right, by indent_w, or style.IndentSpacing if indent_w <= 0
356 static void Unindent(float indent_w = 0.0f); // move content position back to the left, by indent_w, or style.IndentSpacing if indent_w <= 0
357 static void BeginGroup(); // lock horizontal starting position
358 static void EndGroup(); // unlock horizontal starting position + capture the whole group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
359 static KGVec2 GetCursorPos(); // cursor position in window coordinates (relative to window position)
360 static float GetCursorPosX(); // (some functions are using window-relative coordinates, such as: GetCursorPos, GetCursorStartPos, GetContentRegionMax, GetWindowContentRegion* etc.
361 static float GetCursorPosY(); // other functions such as GetCursorScreenPos or everything in KGDrawList::
362 static void SetCursorPos(const KGVec2& local_pos); // are using the main, absolute coordinate system.
363 static void SetCursorPosX(float local_x); // GetWindowPos() + GetCursorPos() == GetCursorScreenPos() etc.)
364 static void SetCursorPosY(float local_y); //
365 static KGVec2 GetCursorStartPos(); // initial cursor position in window coordinates
366 static KGVec2 GetCursorScreenPos(); // cursor position in absolute coordinates (useful to work with KGDrawList API). generally top-left == GetMainViewport()->Pos == (0,0) in single viewport mode, and bottom-right == GetMainViewport()->Pos+Size == io.DisplaySize in single-viewport mode.
367 static void SetCursorScreenPos(const KGVec2& pos); // cursor position in absolute coordinates
368 static void AlignTextToFramePadding(); // vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item)
369 static float GetTextLineHeight(); // ~ FontSize
370 static float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)
371 static float GetFrameHeight(); // ~ FontSize + style.FramePadding.y * 2
372 static float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets)
373
374 // ID stack/scopes
375 // Read the FAQ (docs/FAQ.md or http://dearimgui.org/faq) for more details about how ID are handled in dear imgui.
376 // - Those questions are answered and impacted by understanding of the ID stack system:
377 // - "Q: Why is my widget not reacting when I click on it?"
378 // - "Q: How can I have widgets with an empty label?"
379 // - "Q: How can I have multiple widgets with the same label?"
380 // - Short version: ID are hashes of the entire ID stack. If you are creating widgets in a loop you most likely
381 // want to push a unique identifier (e.g. object pointer, loop index) to uniquely differentiate them.
382 // - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others.
383 // - In this header file we use the "label"/"name" terminology to denote a string that will be displayed + used as an ID,
384 // whereas "str_id" denote a string that is only used as an ID and not normally displayed.
385 static void PushID(const char* str_id); // push string into the ID stack (will hash string).
386 static void PushID(const char* str_id_begin, const char* str_id_end); // push string into the ID stack (will hash string).
387 static void PushID(const void* ptr_id); // push pointer into the ID stack (will hash pointer).
388 static void PushID(int int_id); // push integer into the ID stack (will hash integer).
389 static void PopID(); // pop from the ID stack.
390 static KGGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into KarmaGuiStorage yourself
391 static KGGuiID GetID(const char* str_id_begin, const char* str_id_end);
392 static KGGuiID GetID(const void* ptr_id);
393
394 // Widgets: Text
395 static void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
396 static void Text(const char* fmt, ...) KG_FMTARGS(1); // formatted text
397 static void TextV(const char* fmt, va_list args) KG_FMTLIST(1);
398 static void TextColored(const KGVec4& col, const char* fmt, ...) KG_FMTARGS(2); // shortcut for PushStyleColor(KGGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
399 static void AddTextVertical(KGDrawList* DrawList, const char *text, KGVec2 pos, KGU32 text_color);
400 static void TextColoredV(const KGVec4& col, const char* fmt, va_list args) KG_FMTLIST(2);
401 static void TextDisabled(const char* fmt, ...) KG_FMTARGS(1); // shortcut for PushStyleColor(KGGuiCol_Text, style.Colors[KGGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor();
402 static void TextDisabledV(const char* fmt, va_list args) KG_FMTLIST(1);
403 static void TextWrapped(const char* fmt, ...) KG_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize().
404 static void TextWrappedV(const char* fmt, va_list args) KG_FMTLIST(1);
405 static void LabelText(const char* label, const char* fmt, ...) KG_FMTARGS(2); // display text+label aligned the same way as value+label widgets
406 static void LabelTextV(const char* label, const char* fmt, va_list args) KG_FMTLIST(2);
407 static void BulletText(const char* fmt, ...) KG_FMTARGS(1); // shortcut for Bullet()+Text()
408 static void BulletTextV(const char* fmt, va_list args) KG_FMTLIST(1);
409
410 // Widgets: Main
411 // - Most widgets return true when the value has been changed or when pressed/selected
412 // - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state.
413 static bool Button(const char* label, const KGVec2& size = KGVec2(0, 0)); // button
414 static bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
415 static bool InvisibleButton(const char* str_id, const KGVec2& size, KarmaGuiButtonFlags flags = 0); // flexible button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
416 static bool ArrowButton(const char* str_id, KarmaGuiDir dir); // square button with an arrow shape
417 static bool Checkbox(const char* label, bool* v);
418 static bool CheckboxFlags(const char* label, int* flags, int flags_value);
419 static bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
420 static bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; }
421 static bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer
422 static void ProgressBar(float fraction, const KGVec2& size_arg = KGVec2(-FLT_MIN, 0), const char* overlay = NULL);
423 static void Bullet(); // draw a small circle + keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
424
425 // Widgets: Images
426 // - Read about KGTextureID here: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
427 static void Image(KGTextureID user_texture_id, const KGVec2& size, const KGVec2& uv0 = KGVec2(0, 0), const KGVec2& uv1 = KGVec2(1, 1), const KGVec4& tint_col = KGVec4(1, 1, 1, 1), const KGVec4& border_col = KGVec4(0, 0, 0, 0));
433 static bool ImageButton(const char* str_id, KGTextureID user_texture_id, const KGVec2& size, const KGVec2& uv0 = KGVec2(0, 0), const KGVec2& uv1 = KGVec2(1, 1), const KGVec4& bg_col = KGVec4(0, 0, 0, 0), const KGVec4& tint_col = KGVec4(1, 1, 1, 1));
434
435 // Widgets: Combo Box (Dropdown)
436 // - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
437 // - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. This is analogous to how ListBox are created.
438 static bool BeginCombo(const char* label, const char* preview_value, KarmaGuiComboFlags flags = 0);
439 static void EndCombo(); // only call EndCombo() if BeginCombo() returns true!
440 static bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1);
441 static bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0"
442 static bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1);
443
444 // Widgets: Drag Sliders
445 // - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use KGGuiSliderFlags_AlwaysClamp to always clamp.
446 // - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every function, note that a 'float v[X]' function argument is the same as 'float* v',
447 // the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
448 // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
449 // - Format string may also be set to NULL or use the default format ("%f" or "%d").
450 // - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision).
451 // - Use v_min < v_max to clamp edits to given limits. Note that CTRL+Click manual input can override those limits if KGGuiSliderFlags_AlwaysClamp is not used.
452 // - Use v_max = FLT_MAX / INT_MAX etc to avoid clamping to a maximum, same with v_min = -FLT_MAX / INT_MIN to avoid clamping to a minimum.
453 // - We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them.
454 // - Legacy: Pre-1.78 there are DragXXX() function signatures that take a final `float power=1.0f' argument instead of the `KarmaGuiSliderFlags flags=0' argument.
455 // If you get a warning converting a float to KarmaGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361
456 static bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", KarmaGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound
457 static bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", KarmaGuiSliderFlags flags = 0);
458 static bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", KarmaGuiSliderFlags flags = 0);
459 static bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", KarmaGuiSliderFlags flags = 0);
460 static bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, KarmaGuiSliderFlags flags = 0);
461 static bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", KarmaGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound
462 static bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", KarmaGuiSliderFlags flags = 0);
463 static bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", KarmaGuiSliderFlags flags = 0);
464 static bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", KarmaGuiSliderFlags flags = 0);
465 static bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL, KarmaGuiSliderFlags flags = 0);
466 static bool DragScalar(const char* label, KarmaGuiDataType data_type, void* p_data, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, KarmaGuiSliderFlags flags = 0);
467 static bool DragScalarN(const char* label, KarmaGuiDataType data_type, void* p_data, int components, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, KarmaGuiSliderFlags flags = 0);
468
469 // Widgets: Regular Sliders
470 // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use KGGuiSliderFlags_AlwaysClamp to always clamp.
471 // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
472 // - Format string may also be set to NULL or use the default format ("%f" or "%d").
473 // - Legacy: Pre-1.78 there are SliderXXX() function signatures that take a final `float power=1.0f' argument instead of the `KarmaGuiSliderFlags flags=0' argument.
474 // If you get a warning converting a float to KarmaGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361
475 static bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", KarmaGuiSliderFlags flags = 0); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display.
476 static bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", KarmaGuiSliderFlags flags = 0);
477 static bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", KarmaGuiSliderFlags flags = 0);
478 static bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", KarmaGuiSliderFlags flags = 0);
479 static bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg", KarmaGuiSliderFlags flags = 0);
480 static bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d", KarmaGuiSliderFlags flags = 0);
481 static bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d", KarmaGuiSliderFlags flags = 0);
482 static bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d", KarmaGuiSliderFlags flags = 0);
483 static bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d", KarmaGuiSliderFlags flags = 0);
484 static bool SliderScalar(const char* label, KarmaGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, KarmaGuiSliderFlags flags = 0);
485 static bool SliderScalarN(const char* label, KarmaGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format = NULL, KarmaGuiSliderFlags flags = 0);
486 static bool VSliderFloat(const char* label, const KGVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", KarmaGuiSliderFlags flags = 0);
487 static bool VSliderInt(const char* label, const KGVec2& size, int* v, int v_min, int v_max, const char* format = "%d", KarmaGuiSliderFlags flags = 0);
488 static bool VSliderScalar(const char* label, const KGVec2& size, KarmaGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, KarmaGuiSliderFlags flags = 0);
489
490 // Widgets: Input with Keyboard
491 // - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp.
492 // - Most of the KarmaGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc.
493 static bool InputText(const char* label, char* buf, size_t buf_size, KarmaGuiInputTextFlags flags = 0, KarmaGuiInputTextCallback callback = NULL, void* user_data = NULL);
494 static bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const KGVec2& size = KGVec2(0, 0), KarmaGuiInputTextFlags flags = 0, KarmaGuiInputTextCallback callback = NULL, void* user_data = NULL);
495 static bool InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, KarmaGuiInputTextFlags flags = 0, KarmaGuiInputTextCallback callback = NULL, void* user_data = NULL);
496 static bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", KarmaGuiInputTextFlags flags = 0);
497 static bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", KarmaGuiInputTextFlags flags = 0);
498 static bool InputFloat3(const char* label, float v[3], const char* format = "%.3f", KarmaGuiInputTextFlags flags = 0);
499 static bool InputFloat4(const char* label, float v[4], const char* format = "%.3f", KarmaGuiInputTextFlags flags = 0);
500 static bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, KarmaGuiInputTextFlags flags = 0);
501 static bool InputInt2(const char* label, int v[2], KarmaGuiInputTextFlags flags = 0);
502 static bool InputInt3(const char* label, int v[3], KarmaGuiInputTextFlags flags = 0);
503 static bool InputInt4(const char* label, int v[4], KarmaGuiInputTextFlags flags = 0);
504 static bool InputDouble(const char* label, double* v, double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", KarmaGuiInputTextFlags flags = 0);
505 static bool InputScalar(const char* label, KarmaGuiDataType data_type, void* p_data, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, KarmaGuiInputTextFlags flags = 0);
506 static bool InputScalarN(const char* label, KarmaGuiDataType data_type, void* p_data, int components, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, KarmaGuiInputTextFlags flags = 0);
507
508 // Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little color square that can be left-clicked to open a picker, and right-clicked to open an option menu.)
509 // - Note that in C++ a 'float v[X]' function argument is the _same_ as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible.
510 // - You can pass the address of a first float element out of a contiguous structure, e.g. &myvector.x
511 static bool ColorEdit3(const char* label, float col[3], KarmaGuiColorEditFlags flags = 0);
512 static bool ColorEdit4(const char* label, float col[4], KarmaGuiColorEditFlags flags = 0);
513 static bool ColorPicker3(const char* label, float col[3], KarmaGuiColorEditFlags flags = 0);
514 static bool ColorPicker4(const char* label, float col[4], KarmaGuiColorEditFlags flags = 0, const float* ref_col = NULL);
515 static bool ColorButton(const char* desc_id, const KGVec4& col, KarmaGuiColorEditFlags flags = 0, const KGVec2& size = KGVec2(0, 0)); // display a color square/button, hover for details, return true when pressed.
516 static void SetColorEditOptions(KarmaGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls.
517
518 // Widgets: Trees
519 // - TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents.
520 static bool TreeNode(const char* label);
521 static bool TreeNode(const char* str_id, const char* fmt, ...) KG_FMTARGS(2); // helper variation to easily decorelate the id from the displayed string. Read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet().
522 static bool TreeNode(const void* ptr_id, const char* fmt, ...) KG_FMTARGS(2); // "
523 static bool TreeNodeV(const char* str_id, const char* fmt, va_list args) KG_FMTLIST(2);
524 static bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) KG_FMTLIST(2);
525 static bool TreeNodeEx(const char* label, KarmaGuiTreeNodeFlags flags = 0);
526 static bool TreeNodeEx(const char* str_id, KarmaGuiTreeNodeFlags flags, const char* fmt, ...) KG_FMTARGS(3);
527 static bool TreeNodeEx(const void* ptr_id, KarmaGuiTreeNodeFlags flags, const char* fmt, ...) KG_FMTARGS(3);
528 static bool TreeNodeExV(const char* str_id, KarmaGuiTreeNodeFlags flags, const char* fmt, va_list args) KG_FMTLIST(3);
529 static bool TreeNodeExV(const void* ptr_id, KarmaGuiTreeNodeFlags flags, const char* fmt, va_list args) KG_FMTLIST(3);
530 static void TreePush(const char* str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired.
531 static void TreePush(const void* ptr_id); // "
532 static void TreePop(); // ~ Unindent()+PopId()
533 static float GetTreeNodeToLabelSpacing(); // horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode
534 static bool CollapsingHeader(const char* label, KarmaGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop().
535 static bool CollapsingHeader(const char* label, bool* p_visible, KarmaGuiTreeNodeFlags flags = 0); // when 'p_visible != NULL': if '*p_visible==true' display an additional small close button on upper right of the header which will set the bool to false when clicked, if '*p_visible==false' don't display the header.
536 static void SetNextItemOpen(bool is_open, KarmaGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state.
537
538 // Widgets: Selectables
539 // - A selectable highlights when hovered, and can display another color when selected.
540 // - Neighbors selectable extend their highlight bounds in order to leave no gap between them. This is so a series of selected Selectable appear contiguous.
541 static bool Selectable(const char* label, bool selected = false, KarmaGuiSelectableFlags flags = 0, const KGVec2& size = KGVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
542 static bool Selectable(const char* label, bool* p_selected, KarmaGuiSelectableFlags flags = 0, const KGVec2& size = KGVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
543
544 // Widgets: List Boxes
545 // - This is essentially a thin wrapper to using BeginChild/EndChild with some stylistic changes.
546 // - The BeginListBox()/EndListBox() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() or any items.
547 // - The simplified/old ListBox() api are helpers over BeginListBox()/EndListBox() which are kept available for convenience purpose. This is analoguous to how Combos are created.
548 // - Choose frame width: size.x > 0.0f: custom / size.x < 0.0f or -FLT_MIN: right-align / size.x = 0.0f (default): use current ItemWidth
549 // - Choose frame height: size.y > 0.0f: custom / size.y < 0.0f or -FLT_MIN: bottom-align / size.y = 0.0f (default): arbitrary default height which can fit ~7 items
550 static bool BeginListBox(const char* label, const KGVec2& size = KGVec2(0, 0)); // open a framed scrolling region
551 static void EndListBox(); // only call EndListBox() if BeginListBox() returned true!
552 static bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1);
553 static bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
554
555 // Widgets: Data Plotting
556 // - Consider using ImPlot (https://github.com/epezent/implot) which is much better!
557 static void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, KGVec2 graph_size = KGVec2(0, 0), int stride = sizeof(float));
558 static void PlotLines(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, KGVec2 graph_size = KGVec2(0, 0));
559 static void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, KGVec2 graph_size = KGVec2(0, 0), int stride = sizeof(float));
560 static void PlotHistogram(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, KGVec2 graph_size = KGVec2(0, 0));
561
562 // Widgets: Value() Helpers.
563 // - Those are merely shortcut to calling Text() with a format string. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace)
564 static void Value(const char* prefix, bool b);
565 static void Value(const char* prefix, int v);
566 static void Value(const char* prefix, unsigned int v);
567 static void Value(const char* prefix, float v, const char* float_format = NULL);
568
569 // Widgets: Menus
570 // - Use BeginMenuBar() on a window KGGuiWindowFlags_MenuBar to append to its menu bar.
571 // - Use BeginMainMenuBar() to create a menu bar at the top of the screen and append to it.
572 // - Use BeginMenu() to create a menu. You can call BeginMenu() multiple time with the same identifier to append more items to it.
573 // - Not that MenuItem() keyboardshortcuts are displayed as a convenience but _not processed_ by Dear ImGui at the moment.
574 static bool BeginMenuBar(); // append to menu-bar of current window (requires KGGuiWindowFlags_MenuBar flag set on parent window).
575 static void EndMenuBar(); // only call EndMenuBar() if BeginMenuBar() returns true!
576 static bool BeginMainMenuBar(); // create and append to a full screen menu-bar.
577 static void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true!
578 static bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true!
579 static void EndMenu(); // only call EndMenu() if BeginMenu() returns true!
580 static bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated.
581 static bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
582
583 // Tooltips
584 // - Tooltip are windows following the mouse. They do not take focus away.
585 static void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items).
586 static void EndTooltip();
587 static void SetTooltip(const char* fmt, ...) KG_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip().
588 static void SetTooltipV(const char* fmt, va_list args) KG_FMTLIST(1);
589
590 // Popups, Modals
591 // - They block normal mouse hovering detection (and therefore most mouse interactions) behind them.
592 // - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
593 // - Their visibility state (~bool) is held internally instead of being held by the programmer as we are used to with regular Begin*() calls.
594 // - The 3 properties above are related: we need to retain popup visibility state in the library because popups may be closed as any time.
595 // - You can bypass the hovering restriction by using KGGuiHoveredFlags_AllowWhenBlockedByPopup when calling IsItemHovered() or IsWindowHovered().
596 // - IMPORTANT: Popup identifiers are relative to the current ID stack, so OpenPopup and BeginPopup generally needs to be at the same level of the stack.
597 // This is sometimes leading to confusing mistakes. May rework this in the future.
598
599 // Popups: begin/end functions
600 // - BeginPopup(): query popup state, if open start appending into the window. Call EndPopup() afterwards. KarmaGuiWindowFlags are forwarded to the window.
601 // - BeginPopupModal(): block every interaction behind the window, cannot be closed by user, add a dimming background, has a title bar.
602 static bool BeginPopup(const char* str_id, KarmaGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it.
603 static bool BeginPopupModal(const char* name, bool* p_open = NULL, KarmaGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it.
604 static void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
605
606 // Popups: open/close functions
607 // - OpenPopup(): set popup state to open. KarmaGuiPopupFlags are available for opening options.
608 // - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
609 // - CloseCurrentPopup(): use inside the BeginPopup()/EndPopup() scope to close manually.
610 // - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
611 // - Use KGGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
612 // - Use IsWindowAppearing() after BeginPopup() to tell if a window just opened.
613 // - IMPORTANT: Notice that for OpenPopupOnItemClick() we exceptionally default flags to 1 (== KGGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter
614 static void OpenPopup(const char* str_id, KarmaGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
615 static void OpenPopup(KGGuiID id, KarmaGuiPopupFlags popup_flags = 0); // id overload to facilitate calling from nested stacks
616 static void OpenPopupOnItemClick(const char* str_id = NULL, KarmaGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to KGGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
617 static void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
618
619 // Popups: open+begin combined functions helpers
620 // - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
621 // - They are convenient to easily create context menus, hence the name.
622 // - IMPORTANT: Notice that BeginPopupContextXXX takes KarmaGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add KarmaGuiWindowFlags to the BeginPopupContextXXX functions in the future.
623 // - IMPORTANT: Notice that we exceptionally default their flags to 1 (== KGGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the KGGuiPopupFlags_MouseButtonRight.
624 static bool BeginPopupContextItem(const char* str_id = NULL, KarmaGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
625 static bool BeginPopupContextWindow(const char* str_id = NULL, KarmaGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
626 static bool BeginPopupContextVoid(const char* str_id = NULL, KarmaGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
627
628 // Popups: query functions
629 // - IsPopupOpen(): return true if the popup is open at the current BeginPopup() level of the popup stack.
630 // - IsPopupOpen() with KGGuiPopupFlags_AnyPopupId: return true if any popup is open at the current BeginPopup() level of the popup stack.
631 // - IsPopupOpen() with KGGuiPopupFlags_AnyPopupId + KGGuiPopupFlags_AnyPopupLevel: return true if any popup is open.
632 static bool IsPopupOpen(const char* str_id, KarmaGuiPopupFlags flags = 0); // return true if the popup is open.
633
634 // Tables
635 // - Full-featured replacement for old Columns API.
636 // - See Demo->Tables for demo code. See top of imgui_tables.cpp for general commentary.
637 // - See KGGuiTableFlags_ and KGGuiTableColumnFlags_ enums for a description of available flags.
638 // The typical call flow is:
639 // - 1. Call BeginTable(), early out if returning false.
640 // - 2. Optionally call TableSetupColumn() to submit column name/flags/defaults.
641 // - 3. Optionally call TableSetupScrollFreeze() to request scroll freezing of columns/rows.
642 // - 4. Optionally call TableHeadersRow() to submit a header row. Names are pulled from TableSetupColumn() data.
643 // - 5. Populate contents:
644 // - In most situations you can use TableNextRow() + TableSetColumnIndex(N) to start appending into a column.
645 // - If you are using tables as a sort of grid, where every column is holding the same type of contents,
646 // you may prefer using TableNextColumn() instead of TableNextRow() + TableSetColumnIndex().
647 // TableNextColumn() will automatically wrap-around into the next row if needed.
648 // - IMPORTANT: Comparatively to the old Columns() API, we need to call TableNextColumn() for the first column!
649 // - Summary of possible call flow:
650 // --------------------------------------------------------------------------------------------------------
651 // TableNextRow() -> TableSetColumnIndex(0) -> Text("Hello 0") -> TableSetColumnIndex(1) -> Text("Hello 1") // OK
652 // TableNextRow() -> TableNextColumn() -> Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK
653 // TableNextColumn() -> Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK: TableNextColumn() automatically gets to next row!
654 // TableNextRow() -> Text("Hello 0") // Not OK! Missing TableSetColumnIndex() or TableNextColumn()! Text will not appear!
655 // --------------------------------------------------------------------------------------------------------
656 // - 5. Call EndTable()
657 static bool BeginTable(const char* str_id, int column, KarmaGuiTableFlags flags = 0, const KGVec2& outer_size = KGVec2(0.0f, 0.0f), float inner_width = 0.0f);
658 static void EndTable(); // only call EndTable() if BeginTable() returns true!
659 static void TableNextRow(KarmaGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row.
660 static bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible.
661 static bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible.
662
663 // Tables: Headers & Columns declaration
664 // - Use TableSetupColumn() to specify label, resizing policy, default width/weight, id, various other flags etc.
665 // - Use TableHeadersRow() to create a header row and automatically submit a TableHeader() for each column.
666 // Headers are required to perform: reordering, sorting, and opening the context menu.
667 // The context menu can also be made available in columns body using KGGuiTableFlags_ContextMenuInBody.
668 // - You may manually submit headers using TableNextRow() + TableHeader() calls, but this is only useful in
669 // some advanced use cases (e.g. adding custom widgets in header row).
670 // - Use TableSetupScrollFreeze() to lock columns/rows so they stay visible when scrolled.
671 static void TableSetupColumn(const char* label, KarmaGuiTableColumnFlags flags = 0, float init_width_or_weight = 0.0f, KGGuiID user_id = 0);
672 static void TableSetupScrollFreeze(int cols, int rows); // lock columns/rows so they stay visible when scrolled.
673 static void TableHeadersRow(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu
674 static void TableHeader(const char* label); // submit one header cell manually (rarely used)
675
676 // Tables: Sorting & Miscellaneous functions
677 // - Sorting: call TableGetSortSpecs() to retrieve latest sort specs for the table. NULL when not sorting.
678 // When 'sort_specs->SpecsDirty == true' you should sort your data. It will be true when sorting specs have
679 // changed since last call, or the first time. Make sure to set 'SpecsDirty = false' after sorting,
680 // else you may wastefully sort your data every frame!
681 // - Functions args 'int column_n' treat the default value of -1 as the same as passing the current column index.
682 static KarmaGuiTableSortSpecs* TableGetSortSpecs(); // get latest sort specs for the table (NULL if not sorting). Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable().
683 static int TableGetColumnCount(); // return number of columns (value passed to BeginTable)
684 static int TableGetColumnIndex(); // return current column index.
685 static int TableGetRowIndex(); // return current row index.
686 static const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
687 static KarmaGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column.
688 static void TableSetColumnEnabled(int column_n, bool v);// change user accessible enabled/disabled state of a column. Set to false to hide the column. User can use the context menu to change this themselves (right-click in headers, or right-click in columns body with KGGuiTableFlags_ContextMenuInBody)
689 static void TableSetBgColor(KarmaGuiTableBgTarget target, KGU32 color, int column_n = -1); // change the color of a cell, row, or column. See KGGuiTableBgTarget_ flags for details.
690
691 // Legacy Columns API (prefer using Tables!)
692 // - You can also use SameLine(pos_x) to mimic simplified columns.
693 static void Columns(int count = 1, const char* id = NULL, bool border = true);
694 static void NextColumn(); // next column, defaults to current row or next row if the current row is finished
695 static int GetColumnIndex(); // get current column index
696 static float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column
697 static void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column
698 static float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f
699 static void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
700 static int GetColumnsCount();
701
702 // Tab Bars, Tabs
703 // - Note: Tabs are automatically created by the docking system (when in 'docking' branch). Use this to create tab bars/tabs yourself.
704 static bool BeginTabBar(const char* str_id, KarmaGuiTabBarFlags flags = 0); // create and append into a TabBar
705 static void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true!
706 static bool BeginTabItem(const char* label, bool* p_open = NULL, KarmaGuiTabItemFlags flags = 0); // create a Tab. Returns true if the Tab is selected.
707 static void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true!
708 static bool TabItemButton(const char* label, KarmaGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar.
709 static void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
710
711 // Docking
712 // [BETA API] Enable with io.ConfigFlags |= KGGuiConfigFlags_DockingEnable.
713 // Note: You can use most Docking facilities without calling any API. You DO NOT need to call DockSpace() to use Docking!
714 // - Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking/undocking.
715 // - Drag from window menu button (upper-left button) to undock an entire node (all windows).
716 // - When io.ConfigDockingWithShift == true, you instead need to hold SHIFT to _enable_ docking/undocking.
717 // About dockspaces:
718 // - Use DockSpace() to create an explicit dock node _within_ an existing window. See Docking demo for details.
719 // - Use DockSpaceOverViewport() to create an explicit dock node covering the screen or a specific viewport.
720 // This is often used with KGGuiDockNodeFlags_PassthruCentralNode.
721 // - Important: Dockspaces need to be submitted _before_ any window they can host. Submit it early in your frame!
722 // - Important: Dockspaces need to be kept alive if hidden, otherwise windows docked into it will be undocked.
723 // e.g. if you have multiple tabs with a dockspace inside each tab: submit the non-visible dockspaces with KGGuiDockNodeFlags_KeepAliveOnly.
724 static KGGuiID DockSpace(KGGuiID id, const KGVec2& size = KGVec2(0, 0), KarmaGuiDockNodeFlags flags = 0, const KarmaGuiWindowClass* window_class = NULL);
725 static KGGuiID DockSpaceOverViewport(const KarmaGuiViewport* viewport = NULL, KarmaGuiDockNodeFlags flags = 0, const KarmaGuiWindowClass* window_class = NULL);
726 static void SetNextWindowDockID(KGGuiID dock_id, KarmaGuiCond cond = 0); // set next window dock id
727 static void SetNextWindowClass(const KarmaGuiWindowClass* window_class); // set next window class (control docking compatibility + provide hints to platform backend via custom viewport flags and platform parent/child relationship)
728 static KGGuiID GetWindowDockID();
729 static bool IsWindowDocked(); // is current window docked into another window?
730
731 // Logging/Capture
732 // - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging.
733 static void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout)
734 static void LogToFile(int auto_open_depth = -1, const char* filename = NULL); // start logging to file
735 static void LogToClipboard(int auto_open_depth = -1); // start logging to OS clipboard
736 static void LogFinish(); // stop logging (close file, etc.)
737 static void LogButtons(); // helper to display buttons for logging to tty/file/clipboard
738 static void LogText(const char* fmt, ...) KG_FMTARGS(1); // pass text data straight to log (without being displayed)
739 static void LogTextV(const char* fmt, va_list args) KG_FMTLIST(1);
740 static void LogTextV(KarmaGuiContext& g, const char* fmt, va_list args);
741
742 // Drag and Drop
743 // - On source items, call BeginDragDropSource(), if it returns true also call SetDragDropPayload() + EndDragDropSource().
744 // - On target candidates, call BeginDragDropTarget(), if it returns true also call AcceptDragDropPayload() + EndDragDropTarget().
745 // - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip, see #1725)
746 // - An item can be both drag source and drop target.
747 static bool BeginDragDropSource(KarmaGuiDragDropFlags flags = 0); // call after submitting an item which may be dragged. when this return true, you can call SetDragDropPayload() + EndDragDropSource()
748 static bool SetDragDropPayload(const char* type, const void* data, size_t sz, KarmaGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. Return true when payload has been accepted.
749 static void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
750 static bool BeginDragDropTarget(); // call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget()
751 static const KarmaGuiPayload* AcceptDragDropPayload(const char* type, KarmaGuiDragDropFlags flags = 0); // accept contents of a given type. If KGGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released.
752 static void EndDragDropTarget(); // only call EndDragDropTarget() if BeginDragDropTarget() returns true!
753 static const KarmaGuiPayload* GetDragDropPayload(); // peek directly into the current payload from anywhere. may return NULL. use KarmaGuiPayload::IsDataType() to test for the payload type.
754
755 // Disabling [BETA API]
756 // - Disable all user interactions and dim items visuals (applying style.DisabledAlpha over current colors)
757 // - Those can be nested but it cannot be used to enable an already disabled section (a single BeginDisabled(true) in the stack is enough to keep everything disabled)
758 // - BeginDisabled(false) essentially does nothing useful but is provided to facilitate use of boolean expressions. If you can avoid calling BeginDisabled(False)/EndDisabled() best to avoid it.
759 static void BeginDisabled(bool disabled = true);
760 static void EndDisabled();
761
762 // Clipping
763 // - Mouse hovering is affected by ImGui::PushClipRect() calls, unlike direct calls to KGDrawList::PushClipRect() which are render only.
764 static void PushClipRect(const KGVec2& clip_rect_min, const KGVec2& clip_rect_max, bool intersect_with_current_clip_rect);
765 static void PopClipRect();
766
767 // Focus, Activation
768 // - Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHereY()" when applicable to signify "this is the default item"
769 static void SetItemDefaultFocus(); // make last item the default focused item of a window.
770 static void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget.
771
772 // Item/Widgets Utilities and Query Functions
773 // - Most of the functions are referring to the previous Item that has been submitted.
774 // - See Demo Window under "Widgets->Querying Status" for an interactive visualization of most of those functions.
775 static bool IsItemHovered(KarmaGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See KarmaGuiHoveredFlags for more options.
776 static bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited. This will continuously return true while holding mouse button on an item. Items that don't interact will always return false)
777 static bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation?
778 static bool IsItemClicked(KarmaGuiMouseButton mouse_button = 0); // is the last item hovered and mouse clicked on? (**) == IsMouseClicked(mouse_button) && IsItemHovered()Important. (**) this is NOT equivalent to the behavior of e.g. Button(). Read comments in function definition.
779 static bool IsItemVisible(); // is the last item visible? (items may be out of sight because of clipping/scrolling)
780 static bool IsItemEdited(); // did the last item modify its underlying value this frame? or was pressed? This is generally the same as the "bool" return value of many widgets.
781 static bool IsItemActivated(); // was the last item just made active (item was previously inactive).
782 static bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that require continuous editing.
783 static bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that require continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item).
784 static bool IsItemToggledOpen(); // was the last item open state toggled? set by TreeNode().
785 static bool IsAnyItemHovered(); // is any item hovered?
786 static bool IsAnyItemActive(); // is any item active?
787 static bool IsAnyItemFocused(); // is any item focused?
788 static KGGuiID GetItemID(); // get ID of last item (~~ often same ImGui::GetID(label) beforehand)
789 static KGVec2 GetItemRectMin(); // get upper-left bounding rectangle of the last item (screen space)
790 static KGVec2 GetItemRectMax(); // get lower-right bounding rectangle of the last item (screen space)
791 static KGVec2 GetItemRectSize(); // get size of last item
792 static void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
793
794 // Viewports
795 // - Currently represents the Platform Window created by the application which is hosting our Dear ImGui windows.
796 // - In 'docking' branch with multi-viewport enabled, we extend this concept to have multiple active viewports.
797 // - In the future we will extend this concept further to also represent Platform Monitor and support a "no main platform window" operation mode.
798 static KarmaGuiViewport* GetMainViewport(); // return primary/default viewport. This can never be NULL.
799
800 // Background/Foreground Draw Lists
801 static KGDrawList* GetBackgroundDrawList(); // get background draw list for the viewport associated to the current window. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
802 static KGDrawList* GetForegroundDrawList(); // get foreground draw list for the viewport associated to the current window. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
803 static KGDrawList* GetBackgroundDrawList(KarmaGuiViewport* viewport); // get background draw list for the given viewport. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
804 static KGDrawList* GetForegroundDrawList(KarmaGuiViewport* viewport); // get foreground draw list for the given viewport. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
805
806 // Miscellaneous Utilities
807 static bool IsRectVisible(const KGVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
808 static bool IsRectVisible(const KGVec2& rect_min, const KGVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
809 static double GetTime(); // get global imgui time. incremented by io.DeltaTime every frame.
810 static int GetFrameCount(); // get global imgui frame count. incremented by 1 every frame.
811 static KGDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own KGDrawList instances.
812 static const char* GetStyleColorName(KarmaGuiCol idx); // get a string corresponding to the enum value (for display, saving, etc.).
813 static void SetStateStorage(KarmaGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
814 static KarmaGuiStorage* GetStateStorage();
815 static bool BeginChildFrame(KGGuiID id, const KGVec2& size, KarmaGuiWindowFlags flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame
816 static void EndChildFrame(); // always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window)
817
818 // Text Utilities
819 static KGVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
820
821 // Color Utilities
822 static KGVec4 ColorConvertU32ToFloat4(KGU32 in);
823 static KGU32 ColorConvertFloat4ToU32(const KGVec4& in);
824 static void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
825 static void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
826
827 // Inputs Utilities: Keyboard/Mouse/Gamepad
828 // - the KarmaGuiKey enum contains all possible keyboard, mouse and gamepad inputs (e.g. KGGuiKey_A, KGGuiKey_MouseLeft, KGGuiKey_GamepadDpadUp...).
829 // - before v1.87, we used KarmaGuiKey to carry native/user indices as defined by each backends. About use of those legacy KarmaGuiKey values:
830 // - without IMGUI_DISABLE_OBSOLETE_KEYIO (legacy support): you can still use your legacy native/user indices (< 512) according to how your backend/engine stored them in io.KeysDown[], but need to cast them to KarmaGuiKey.
831 // - with IMGUI_DISABLE_OBSOLETE_KEYIO (this is the way forward): any use of KarmaGuiKey will assert with key < 512. GetKeyIndex() is pass-through and therefore deprecated (gone if IMGUI_DISABLE_OBSOLETE_KEYIO is defined).
832 static bool IsKeyDown(KarmaGuiKey key); // is key being held.
833 static bool IsKeyPressed(KarmaGuiKey key, bool repeat = true); // was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
834 static bool IsKeyReleased(KarmaGuiKey key); // was key released (went from Down to !Down)?
835 static int GetKeyPressedAmount(KarmaGuiKey key, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate
836 static const char* GetKeyName(KarmaGuiKey key); // [DEBUG] returns English name of the key. Those names a provided for debugging purpose and are not meant to be saved persistently not compared.
837 static void SetNextFrameWantCaptureKeyboard(bool want_capture_keyboard); // Override io.WantCaptureKeyboard flag next frame (said flag is left for your application to handle, typically when true it instructs your app to ignore inputs). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard"; after the next NewFrame() call.
838
839 // Inputs Utilities: Shortcut testing (with Routing Resolution)
840 // - KarmaGuiKeyChord = a KarmaGuiKey optionally OR-red with KGGuiMod_Alt/KGGuiMod_Ctrl/KGGuiMod_Shift/KGGuiMod_Super/KGGuiMod_Shortcut.
841 // KGGuiKey_C (accepted by functions taking KarmaGuiKey or KarmaGuiKeyChord)
842 // KGGuiKey_C | KGGuiMod_Ctrl (accepted by functions taking KarmaGuiKeyChord)
843 // ONLY KGGuiMod_XXX values are legal to 'OR' with an KarmaGuiKey. You CANNOT 'OR' two KarmaGuiKey values.
844 // - The general idea of routing is that multiple locations may register interest in a shortcut,
845 // and only one location will be granted access to the shortcut.
846 // - The default routing policy (KGGuiInputFlags_RouteFocused) checks for current window being in
847 // the focus stack, and route the shortcut to the deepest requesting window in the focus stack.
848 // - Consider Shortcut() to be a widget: the calling location matters + it has side-effects as shortcut routes are
849 // registered into the system (for it to be able to pick the best one). This is why this is not called 'IsShortcutPressed()'.
850 // - If this is called for a specific widget, pass its ID as 'owner_id' in order for key ownership and routing priorities
851 // to be honored (e.g. with default KGGuiInputFlags_RouteFocused, the highest priority is given to active item).
852 static bool Shortcut(KarmaGuiKeyChord key_chord, KGGuiID owner_id = 0, KarmaGuiInputFlags flags = 0);
853
854 // Inputs Utilities: Mouse specific
855 // - To refer to a mouse button, you may use named enums in your code e.g. KGGuiMouseButton_Left, KGGuiMouseButton_Right.
856 // - You can also use regular integer: it is forever guaranteed that 0=Left, 1=Right, 2=Middle.
857 // - Dragging operations are only reported after mouse has moved a certain distance away from the initial clicking position (see 'lock_threshold' and 'io.MouseDraggingThreshold')
858 static bool IsMouseDown(KarmaGuiMouseButton button); // is mouse button held?
859 static bool IsMouseClicked(KarmaGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down). Same as GetMouseClickedCount() == 1.
860 static bool IsMouseReleased(KarmaGuiMouseButton button); // did mouse button released? (went from Down to !Down)
861 static bool IsMouseDoubleClicked(KarmaGuiMouseButton button); // did mouse button double-clicked? Same as GetMouseClickedCount() == 2. (note that a double-click will also report IsMouseClicked() == true)
862 static int GetMouseClickedCount(KarmaGuiMouseButton button); // return the number of successive mouse-clicks at the time where a click happen (otherwise 0).
863 static bool IsMouseHoveringRect(const KGVec2& r_min, const KGVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block.
864 static bool IsMousePosValid(const KGVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available
865 static bool IsAnyMouseDown(); // [WILL OBSOLETE] is any mouse button held? This was designed for backends, but prefer having backend maintain a mask of held mouse buttons, because upcoming input queue system will make this invalid.
866 static KGVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
867 static KGVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves)
868 static bool IsMouseDragging(KarmaGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
869 static KGVec2 GetMouseDragDelta(KarmaGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
870 static void ResetMouseDragDelta(KarmaGuiMouseButton button = 0); //
871 static KarmaGuiMouseCursor GetMouseCursor(); // get desired mouse cursor shape. Important: reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
872 static void SetMouseCursor(KarmaGuiMouseCursor cursor_type); // set desired mouse cursor shape
873 static void SetNextFrameWantCaptureMouse(bool want_capture_mouse); // Override io.WantCaptureMouse flag next frame (said flag is left for your application to handle, typical when true it instucts your app to ignore inputs). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse;" after the next NewFrame() call.
874
875 // Clipboard Utilities
876 // - Also see the LogToClipboard() function to capture GUI into clipboard, or easily output text data to the clipboard.
877 static const char* GetClipboardText();
878 static void SetClipboardText(const char* text);
879
880 // Settings/.Ini Utilities
881 // - The disk functions are automatically called if io.IniFilename != NULL (default is "kggui.ini").
882 // - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually.
883 // - Important: default value "kggui.ini" is relative to current working dir! Most apps will want to lock this to an absolute path (e.g. same path as executables).
884 static void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename).
885 static void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source.
886 static void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext).
887 static const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings.
888
889 // Debug Utilities
890 static void DebugTextEncoding(const char* text);
891 static bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro.
892
893 // Memory Allocators
894 // - Those functions are not reliant on the current context.
895 // - DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
896 // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
897 static void SetAllocatorFunctions(KarmaGuiMemAllocFunc alloc_func, KarmaGuiMemFreeFunc free_func, void* user_data = NULL);
898 static void GetAllocatorFunctions(KarmaGuiMemAllocFunc* p_alloc_func, KarmaGuiMemFreeFunc* p_free_func, void** p_user_data);
907 static void* MemAlloc(size_t size);
916 static void MemFree(void* ptr);
917
918 // (Optional) Platform/OS interface for multi-viewport support
919 // Read comments around the KarmaGuiPlatformIO structure for more details.
920 // Note: You may use GetWindowViewport() to get the current viewport of the current window.
921 static KarmaGuiPlatformIO& GetPlatformIO(); // platform/renderer functions, for backend to setup + viewports list.
922 static void UpdatePlatformWindows(); // call in main loop. will call CreateWindow/ResizeWindow/etc. platform functions for each secondary viewport, and DestroyWindow for each inactive viewport.
931 static void RenderPlatformWindowsDefault(void* platform_render_arg = NULL, void* renderer_render_arg = NULL);
932 static void DestroyPlatformWindows(); // call DestroyWindow platform functions for all viewports. call from backend Shutdown() if you need to close platform windows before imgui shutdown. otherwise will be called by DestroyContext().
933 static KarmaGuiViewport* FindViewportByID(KGGuiID id); // this is a helper for backends.
934 static KarmaGuiViewport* FindViewportByPlatformHandle(void* platform_handle); // this is a helper for backends. the type platform_handle is decided by the backend (e.g. HWND, MyWindow*, GLFWwindow* etc.)
935 static KarmaGuiKey GetKeyIndex(KarmaGuiKey key); // map KGGuiKey_* values into legacy native key index. == io.KeyMap[key]
936 private:
937 // Those names a provided for debugging purpose and are not meant to be saved persistently not compared.
938 static const char* const GKeyNames[];
939 };
940
941}// Namespace Karma
942
943//-----------------------------------------------------------------------------
944// [SECTION] Flags & Enumerations
945//-----------------------------------------------------------------------------
946
947// Flags for ImGui::Begin()
948// (Those are per-window flags. There are shared flags in KarmaGuiIO: io.ConfigWindowsResizeFromEdges and io.ConfigWindowsMoveFromTitleBarOnly)
949enum KGGuiWindowFlags_
950{
951 KGGuiWindowFlags_None = 0,
952 KGGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar
953 KGGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip
954 KGGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window
955 KGGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbars (window can still scroll with mouse or programmatically)
956 KGGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set.
957 KGGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it. Also referred to as Window Menu Button (e.g. within a docking node).
958 KGGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
959 KGGuiWindowFlags_NoBackground = 1 << 7, // Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f).
960 KGGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
961 KGGuiWindowFlags_NoMouseInputs = 1 << 9, // Disable catching mouse, hovering test with pass through.
962 KGGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar
963 KGGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(KGVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
964 KGGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state
965 KGGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it focus)
966 KGGuiWindowFlags_AlwaysVerticalScrollbar= 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y)
967 KGGuiWindowFlags_AlwaysHorizontalScrollbar=1<< 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x)
968 KGGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
969 KGGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window
970 KGGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
971 KGGuiWindowFlags_UnsavedDocument = 1 << 20, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
972 KGGuiWindowFlags_NoDocking = 1 << 21, // Disable docking of this window
973
974 KGGuiWindowFlags_NoNav = KGGuiWindowFlags_NoNavInputs | KGGuiWindowFlags_NoNavFocus,
975 KGGuiWindowFlags_NoDecoration = KGGuiWindowFlags_NoTitleBar | KGGuiWindowFlags_NoResize | KGGuiWindowFlags_NoScrollbar | KGGuiWindowFlags_NoCollapse,
976 KGGuiWindowFlags_NoInputs = KGGuiWindowFlags_NoMouseInputs | KGGuiWindowFlags_NoNavInputs | KGGuiWindowFlags_NoNavFocus,
977
978 // [Internal]
979 KGGuiWindowFlags_NavFlattened = 1 << 23, // [BETA] On child window: allow gamepad/keyboard navigation to cross over parent border to this child or between sibling child windows.
980 KGGuiWindowFlags_ChildWindow = 1 << 24, // Don't use! For internal use by BeginChild()
981 KGGuiWindowFlags_Tooltip = 1 << 25, // Don't use! For internal use by BeginTooltip()
982 KGGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
983 KGGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal()
984 KGGuiWindowFlags_ChildMenu = 1 << 28, // Don't use! For internal use by BeginMenu()
985 KGGuiWindowFlags_DockNodeHost = 1 << 29, // Don't use! For internal use by Begin()/NewFrame()
986};
987
988// Flags for ImGui::InputText()
989// (Those are per-item flags. There are shared flags in KarmaGuiIO: io.ConfigInputTextCursorBlink and io.ConfigInputTextEnterKeepActive)
990enum KGGuiInputTextFlags_
991{
992 KGGuiInputTextFlags_None = 0,
993 KGGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
994 KGGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
995 KGGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z
996 KGGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs
997 KGGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus
998 KGGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to every time the value was modified). Consider looking at the IsItemDeactivatedAfterEdit() function.
999 KGGuiInputTextFlags_CallbackCompletion = 1 << 6, // Callback on pressing TAB (for completion handling)
1000 KGGuiInputTextFlags_CallbackHistory = 1 << 7, // Callback on pressing Up/Down arrows (for history handling)
1001 KGGuiInputTextFlags_CallbackAlways = 1 << 8, // Callback on each iteration. User code may query cursor position, modify text buffer.
1002 KGGuiInputTextFlags_CallbackCharFilter = 1 << 9, // Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
1003 KGGuiInputTextFlags_AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field
1004 KGGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, // In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is opposite: unfocus with Ctrl+Enter, add line with Enter).
1005 KGGuiInputTextFlags_NoHorizontalScroll = 1 << 12, // Disable following the cursor horizontally
1006 KGGuiInputTextFlags_AlwaysOverwrite = 1 << 13, // Overwrite mode
1007 KGGuiInputTextFlags_ReadOnly = 1 << 14, // Read-only mode
1008 KGGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*'
1009 KGGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
1010 KGGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input)
1011 KGGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
1012 KGGuiInputTextFlags_CallbackEdit = 1 << 19, // Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
1013 KGGuiInputTextFlags_EscapeClearsAll = 1 << 20, // Escape key clears content if not empty, and deactivate otherwise (contrast to default behavior of Escape to revert)
1014
1015 // Obsolete names (will be removed soon)
1016#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1017 KGGuiInputTextFlags_AlwaysInsertMode = KGGuiInputTextFlags_AlwaysOverwrite // [renamed in 1.82] name was not matching behavior
1018#endif
1019};
1020
1021// Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*()
1022enum KGGuiTreeNodeFlags_
1023{
1024 KGGuiTreeNodeFlags_None = 0,
1025 KGGuiTreeNodeFlags_Selected = 1 << 0, // Draw as selected
1026 KGGuiTreeNodeFlags_Framed = 1 << 1, // Draw frame with background (e.g. for CollapsingHeader)
1027 KGGuiTreeNodeFlags_AllowItemOverlap = 1 << 2, // Hit testing to allow subsequent widgets to overlap this one
1028 KGGuiTreeNodeFlags_NoTreePushOnOpen = 1 << 3, // Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack
1029 KGGuiTreeNodeFlags_NoAutoOpenOnLog = 1 << 4, // Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes)
1030 KGGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be open
1031 KGGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Need double-click to open node
1032 KGGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If KGGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
1033 KGGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
1034 KGGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow
1035 KGGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding().
1036 KGGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, // Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line. In the future we may refactor the hit system to be front-to-back, allowing natural overlaps and then this can become the default.
1037 KGGuiTreeNodeFlags_SpanFullWidth = 1 << 12, // Extend hit box to the left-most and right-most edges (bypass the indented area).
1038 KGGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 13, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
1039 //KGGuiTreeNodeFlags_NoScrollOnOpen = 1 << 14, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
1040 KGGuiTreeNodeFlags_CollapsingHeader = KGGuiTreeNodeFlags_Framed | KGGuiTreeNodeFlags_NoTreePushOnOpen | KGGuiTreeNodeFlags_NoAutoOpenOnLog,
1041};
1042
1043// Flags for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() functions.
1044// - To be backward compatible with older API which took an 'int mouse_button = 1' argument, we need to treat
1045// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags.
1046// It is therefore guaranteed to be legal to pass a mouse button index in KarmaGuiPopupFlags.
1047// - For the same reason, we exceptionally default the KarmaGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0.
1048// IMPORTANT: because the default parameter is 1 (==KGGuiPopupFlags_MouseButtonRight), if you rely on the default parameter
1049// and want to use another flag, you need to pass in the KGGuiPopupFlags_MouseButtonRight flag explicitly.
1050// - Multiple buttons currently cannot be combined/or-ed in those functions (we could allow it later).
1051enum KGGuiPopupFlags_
1052{
1053 KGGuiPopupFlags_None = 0,
1054 KGGuiPopupFlags_MouseButtonLeft = 0, // For BeginPopupContext*(): open on Left Mouse release. Guaranteed to always be == 0 (same as KGGuiMouseButton_Left)
1055 KGGuiPopupFlags_MouseButtonRight = 1, // For BeginPopupContext*(): open on Right Mouse release. Guaranteed to always be == 1 (same as KGGuiMouseButton_Right)
1056 KGGuiPopupFlags_MouseButtonMiddle = 2, // For BeginPopupContext*(): open on Middle Mouse release. Guaranteed to always be == 2 (same as KGGuiMouseButton_Middle)
1057 KGGuiPopupFlags_MouseButtonMask_ = 0x1F,
1058 KGGuiPopupFlags_MouseButtonDefault_ = 1,
1059 KGGuiPopupFlags_NoOpenOverExistingPopup = 1 << 5, // For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack
1060 KGGuiPopupFlags_NoOpenOverItems = 1 << 6, // For BeginPopupContextWindow(): don't return true when hovering items, only when hovering empty space
1061 KGGuiPopupFlags_AnyPopupId = 1 << 7, // For IsPopupOpen(): ignore the KGGuiID parameter and test for any popup.
1062 KGGuiPopupFlags_AnyPopupLevel = 1 << 8, // For IsPopupOpen(): search/test at any level of the popup stack (default test in the current level)
1063 KGGuiPopupFlags_AnyPopup = KGGuiPopupFlags_AnyPopupId | KGGuiPopupFlags_AnyPopupLevel,
1064};
1065
1066// Flags for KarmaGui::Selectable()
1067enum KGGuiSelectableFlags_
1068{
1069 KGGuiSelectableFlags_None = 0,
1070 KGGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this doesn't close parent popup window
1071 KGGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column)
1072 KGGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too
1073 KGGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text
1074 KGGuiSelectableFlags_AllowItemOverlap = 1 << 4, // (WIP) Hit testing to allow subsequent widgets to overlap this one
1075};
1076
1077// Flags for KarmaGui::BeginCombo()
1078enum KGGuiComboFlags_
1079{
1080 KGGuiComboFlags_None = 0,
1081 KGGuiComboFlags_PopupAlignLeft = 1 << 0, // Align the popup toward the left by default
1082 KGGuiComboFlags_HeightSmall = 1 << 1, // Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo()
1083 KGGuiComboFlags_HeightRegular = 1 << 2, // Max ~8 items visible (default)
1084 KGGuiComboFlags_HeightLarge = 1 << 3, // Max ~20 items visible
1085 KGGuiComboFlags_HeightLargest = 1 << 4, // As many fitting items as possible
1086 KGGuiComboFlags_NoArrowButton = 1 << 5, // Display on the preview box without the square arrow button
1087 KGGuiComboFlags_NoPreview = 1 << 6, // Display only a square arrow button
1088 KGGuiComboFlags_HeightMask_ = KGGuiComboFlags_HeightSmall | KGGuiComboFlags_HeightRegular | KGGuiComboFlags_HeightLarge | KGGuiComboFlags_HeightLargest,
1089};
1090
1091// Flags for KarmaGui::BeginTabBar()
1092enum KGGuiTabBarFlags_
1093{
1094 KGGuiTabBarFlags_None = 0,
1095 KGGuiTabBarFlags_Reorderable = 1 << 0, // Allow manually dragging tabs to re-order them + New tabs are appended at the end of list
1096 KGGuiTabBarFlags_AutoSelectNewTabs = 1 << 1, // Automatically select new tabs when they appear
1097 KGGuiTabBarFlags_TabListPopupButton = 1 << 2, // Disable buttons to open the tab list popup
1098 KGGuiTabBarFlags_NoCloseWithMiddleMouseButton = 1 << 3, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
1099 KGGuiTabBarFlags_NoTabListScrollingButtons = 1 << 4, // Disable scrolling buttons (apply when fitting policy is KGGuiTabBarFlags_FittingPolicyScroll)
1100 KGGuiTabBarFlags_NoTooltip = 1 << 5, // Disable tooltips when hovering a tab
1101 KGGuiTabBarFlags_FittingPolicyResizeDown = 1 << 6, // Resize tabs when they don't fit
1102 KGGuiTabBarFlags_FittingPolicyScroll = 1 << 7, // Add scroll buttons when tabs don't fit
1103 KGGuiTabBarFlags_FittingPolicyMask_ = KGGuiTabBarFlags_FittingPolicyResizeDown | KGGuiTabBarFlags_FittingPolicyScroll,
1104 KGGuiTabBarFlags_FittingPolicyDefault_ = KGGuiTabBarFlags_FittingPolicyResizeDown,
1105};
1106
1107// Flags for KarmaGui::BeginTabItem()
1108enum KGGuiTabItemFlags_
1109{
1110 KGGuiTabItemFlags_None = 0,
1111 KGGuiTabItemFlags_UnsavedDocument = 1 << 0, // Display a dot next to the title + tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
1112 KGGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem()
1113 KGGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
1114 KGGuiTabItemFlags_NoPushId = 1 << 3, // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
1115 KGGuiTabItemFlags_NoTooltip = 1 << 4, // Disable tooltip for the given tab
1116 KGGuiTabItemFlags_NoReorder = 1 << 5, // Disable reordering this tab or having another tab cross over this tab
1117 KGGuiTabItemFlags_Leading = 1 << 6, // Enforce the tab position to the left of the tab bar (after the tab list popup button)
1118 KGGuiTabItemFlags_Trailing = 1 << 7, // Enforce the tab position to the right of the tab bar (before the scrolling buttons)
1119};
1120
1121// Flags for ImGui::BeginTable()
1122// - Important! Sizing policies have complex and subtle side effects, much more so than you would expect.
1123// Read comments/demos carefully + experiment with live demos to get acquainted with them.
1124// - The DEFAULT sizing policies are:
1125// - Default to KGGuiTableFlags_SizingFixedFit if ScrollX is on, or if host window has KGGuiWindowFlags_AlwaysAutoResize.
1126// - Default to KGGuiTableFlags_SizingStretchSame if ScrollX is off.
1127// - When ScrollX is off:
1128// - Table defaults to KGGuiTableFlags_SizingStretchSame -> all Columns defaults to KGGuiTableColumnFlags_WidthStretch with same weight.
1129// - Columns sizing policy allowed: Stretch (default), Fixed/Auto.
1130// - Fixed Columns (if any) will generally obtain their requested width (unless the table cannot fit them all).
1131// - Stretch Columns will share the remaining width according to their respective weight.
1132// - Mixed Fixed/Stretch columns is possible but has various side-effects on resizing behaviors.
1133// The typical use of mixing sizing policies is: any number of LEADING Fixed columns, followed by one or two TRAILING Stretch columns.
1134// (this is because the visible order of columns have subtle but necessary effects on how they react to manual resizing).
1135// - When ScrollX is on:
1136// - Table defaults to KGGuiTableFlags_SizingFixedFit -> all Columns defaults to KGGuiTableColumnFlags_WidthFixed
1137// - Columns sizing policy allowed: Fixed/Auto mostly.
1138// - Fixed Columns can be enlarged as needed. Table will show a horizontal scrollbar if needed.
1139// - When using auto-resizing (non-resizable) fixed columns, querying the content width to use item right-alignment e.g. SetNextItemWidth(-FLT_MIN) doesn't make sense, would create a feedback loop.
1140// - Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable().
1141// If you specify a value for 'inner_width' then effectively the scrolling space is known and Stretch or mixed Fixed/Stretch columns become meaningful again.
1142// - Read on documentation at the top of imgui_tables.cpp for details.
1143enum KGGuiTableFlags_
1144{
1145 // Features
1146 KGGuiTableFlags_None = 0,
1147 KGGuiTableFlags_Resizable = 1 << 0, // Enable resizing columns.
1148 KGGuiTableFlags_Reorderable = 1 << 1, // Enable reordering columns in header row (need calling TableSetupColumn() + TableHeadersRow() to display headers)
1149 KGGuiTableFlags_Hideable = 1 << 2, // Enable hiding/disabling columns in context menu.
1150 KGGuiTableFlags_Sortable = 1 << 3, // Enable sorting. Call TableGetSortSpecs() to obtain sort specs. Also see KGGuiTableFlags_SortMulti and KGGuiTableFlags_SortTristate.
1151 KGGuiTableFlags_NoSavedSettings = 1 << 4, // Disable persisting columns order, width and sort settings in the .ini file.
1152 KGGuiTableFlags_ContextMenuInBody = 1 << 5, // Right-click on columns body/contents will display table context menu. By default it is available in TableHeadersRow().
1153 // Decorations
1154 KGGuiTableFlags_RowBg = 1 << 6, // Set each RowBg color with KGGuiCol_TableRowBg or KGGuiCol_TableRowBgAlt (equivalent of calling TableSetBgColor with ImGuiTableBgFlags_RowBg0 on each row manually)
1155 KGGuiTableFlags_BordersInnerH = 1 << 7, // Draw horizontal borders between rows.
1156 KGGuiTableFlags_BordersOuterH = 1 << 8, // Draw horizontal borders at the top and bottom.
1157 KGGuiTableFlags_BordersInnerV = 1 << 9, // Draw vertical borders between columns.
1158 KGGuiTableFlags_BordersOuterV = 1 << 10, // Draw vertical borders on the left and right sides.
1159 KGGuiTableFlags_BordersH = KGGuiTableFlags_BordersInnerH | KGGuiTableFlags_BordersOuterH, // Draw horizontal borders.
1160 KGGuiTableFlags_BordersV = KGGuiTableFlags_BordersInnerV | KGGuiTableFlags_BordersOuterV, // Draw vertical borders.
1161 KGGuiTableFlags_BordersInner = KGGuiTableFlags_BordersInnerV | KGGuiTableFlags_BordersInnerH, // Draw inner borders.
1162 KGGuiTableFlags_BordersOuter = KGGuiTableFlags_BordersOuterV | KGGuiTableFlags_BordersOuterH, // Draw outer borders.
1163 KGGuiTableFlags_Borders = KGGuiTableFlags_BordersInner | KGGuiTableFlags_BordersOuter, // Draw all borders.
1164 KGGuiTableFlags_NoBordersInBody = 1 << 11, // [ALPHA] Disable vertical borders in columns Body (borders will always appear in Headers). -> May move to style
1165 KGGuiTableFlags_NoBordersInBodyUntilResize = 1 << 12, // [ALPHA] Disable vertical borders in columns Body until hovered for resize (borders will always appear in Headers). -> May move to style
1166 // Sizing Policy (read above for defaults)
1167 KGGuiTableFlags_SizingFixedFit = 1 << 13, // Columns default to _WidthFixed or _WidthAuto (if resizable or not resizable), matching contents width.
1168 KGGuiTableFlags_SizingFixedSame = 2 << 13, // Columns default to _WidthFixed or _WidthAuto (if resizable or not resizable), matching the maximum contents width of all columns. Implicitly enable KGGuiTableFlags_NoKeepColumnsVisible.
1169 KGGuiTableFlags_SizingStretchProp = 3 << 13, // Columns default to _WidthStretch with default weights proportional to each columns contents widths.
1170 KGGuiTableFlags_SizingStretchSame = 4 << 13, // Columns default to _WidthStretch with default weights all equal, unless overridden by TableSetupColumn().
1171 // Sizing Extra Options
1172 KGGuiTableFlags_NoHostExtendX = 1 << 16, // Make outer width auto-fit to columns, overriding outer_size.x value. Only available when ScrollX/ScrollY are disabled and Stretch columns are not used.
1173 KGGuiTableFlags_NoHostExtendY = 1 << 17, // Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit). Only available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.
1174 KGGuiTableFlags_NoKeepColumnsVisible = 1 << 18, // Disable keeping column always minimally visible when ScrollX is off and table gets too small. Not recommended if columns are resizable.
1175 KGGuiTableFlags_PreciseWidths = 1 << 19, // Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.
1176 // Clipping
1177 KGGuiTableFlags_NoClip = 1 << 20, // Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with TableSetupScrollFreeze().
1178 // Padding
1179 KGGuiTableFlags_PadOuterX = 1 << 21, // Default if BordersOuterV is on. Enable outermost padding. Generally desirable if you have headers.
1180 KGGuiTableFlags_NoPadOuterX = 1 << 22, // Default if BordersOuterV is off. Disable outermost padding.
1181 KGGuiTableFlags_NoPadInnerX = 1 << 23, // Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off).
1182 // Scrolling
1183 KGGuiTableFlags_ScrollX = 1 << 24, // Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Changes default sizing policy. Because this creates a child window, ScrollY is currently generally recommended when using ScrollX.
1184 KGGuiTableFlags_ScrollY = 1 << 25, // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size.
1185 // Sorting
1186 KGGuiTableFlags_SortMulti = 1 << 26, // Hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).
1187 KGGuiTableFlags_SortTristate = 1 << 27, // Allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).
1188
1189 // [Internal] Combinations and masks
1190 KGGuiTableFlags_SizingMask_ = KGGuiTableFlags_SizingFixedFit | KGGuiTableFlags_SizingFixedSame | KGGuiTableFlags_SizingStretchProp | KGGuiTableFlags_SizingStretchSame,
1191};
1192
1193// Flags for KarmaGui::TableSetupColumn()
1194enum KGGuiTableColumnFlags_
1195{
1196 // Input configuration flags
1197 KGGuiTableColumnFlags_None = 0,
1198 KGGuiTableColumnFlags_Disabled = 1 << 0, // Overriding/master disable flag: hide column, won't show in context menu (unlike calling TableSetColumnEnabled() which manipulates the user accessible state)
1199 KGGuiTableColumnFlags_DefaultHide = 1 << 1, // Default as a hidden/disabled column.
1200 KGGuiTableColumnFlags_DefaultSort = 1 << 2, // Default as a sorting column.
1201 KGGuiTableColumnFlags_WidthStretch = 1 << 3, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is _SizingStretchSame or _SizingStretchProp).
1202 KGGuiTableColumnFlags_WidthFixed = 1 << 4, // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is _SizingFixedFit and table is resizable).
1203 KGGuiTableColumnFlags_NoResize = 1 << 5, // Disable manual resizing.
1204 KGGuiTableColumnFlags_NoReorder = 1 << 6, // Disable manual reordering this column, this will also prevent other columns from crossing over this column.
1205 KGGuiTableColumnFlags_NoHide = 1 << 7, // Disable ability to hide/disable this column.
1206 KGGuiTableColumnFlags_NoClip = 1 << 8, // Disable clipping for this column (all NoClip columns will render in a same draw command).
1207 KGGuiTableColumnFlags_NoSort = 1 << 9, // Disable ability to sort on this field (even if KGGuiTableFlags_Sortable is set on the table).
1208 KGGuiTableColumnFlags_NoSortAscending = 1 << 10, // Disable ability to sort in the ascending direction.
1209 KGGuiTableColumnFlags_NoSortDescending = 1 << 11, // Disable ability to sort in the descending direction.
1210 KGGuiTableColumnFlags_NoHeaderLabel = 1 << 12, // TableHeadersRow() will not submit label for this column. Convenient for some small columns. Name will still appear in context menu.
1211 KGGuiTableColumnFlags_NoHeaderWidth = 1 << 13, // Disable header text width contribution to automatic column width.
1212 KGGuiTableColumnFlags_PreferSortAscending = 1 << 14, // Make the initial sort direction Ascending when first sorting on this column (default).
1213 KGGuiTableColumnFlags_PreferSortDescending = 1 << 15, // Make the initial sort direction Descending when first sorting on this column.
1214 KGGuiTableColumnFlags_IndentEnable = 1 << 16, // Use current Indent value when entering cell (default for column 0).
1215 KGGuiTableColumnFlags_IndentDisable = 1 << 17, // Ignore current Indent value when entering cell (default for columns > 0). Indentation changes _within_ the cell will still be honored.
1216
1217 // Output status flags, read-only via TableGetColumnFlags()
1218 KGGuiTableColumnFlags_IsEnabled = 1 << 24, // Status: is enabled == not hidden by user/api (referred to as "Hide" in _DefaultHide and _NoHide) flags.
1219 KGGuiTableColumnFlags_IsVisible = 1 << 25, // Status: is visible == is enabled AND not clipped by scrolling.
1220 KGGuiTableColumnFlags_IsSorted = 1 << 26, // Status: is currently part of the sort specs
1221 KGGuiTableColumnFlags_IsHovered = 1 << 27, // Status: is hovered by mouse
1222
1223 // [Internal] Combinations and masks
1224 KGGuiTableColumnFlags_WidthMask_ = KGGuiTableColumnFlags_WidthStretch | KGGuiTableColumnFlags_WidthFixed,
1225 KGGuiTableColumnFlags_IndentMask_ = KGGuiTableColumnFlags_IndentEnable | KGGuiTableColumnFlags_IndentDisable,
1226 KGGuiTableColumnFlags_StatusMask_ = KGGuiTableColumnFlags_IsEnabled | KGGuiTableColumnFlags_IsVisible | KGGuiTableColumnFlags_IsSorted | KGGuiTableColumnFlags_IsHovered,
1227 KGGuiTableColumnFlags_NoDirectResize_ = 1 << 30, // [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge)
1228};
1229
1230// Flags for KarmaGui::TableNextRow()
1231enum KGGuiTableRowFlags_
1232{
1233 KGGuiTableRowFlags_None = 0,
1234 KGGuiTableRowFlags_Headers = 1 << 0, // Identify header row (set default background color + width of its contents accounted differently for auto column width)
1235};
1236
1237// Enum for ImGui::TableSetBgColor()
1238// Background colors are rendering in 3 layers:
1239// - Layer 0: draw with RowBg0 color if set, otherwise draw with ColumnBg0 if set.
1240// - Layer 1: draw with RowBg1 color if set, otherwise draw with ColumnBg1 if set.
1241// - Layer 2: draw with CellBg color if set.
1242// The purpose of the two row/columns layers is to let you decide if a background color change should override or blend with the existing color.
1243// When using KGGuiTableFlags_RowBg on the table, each row has the RowBg0 color automatically set for odd/even rows.
1244// If you set the color of RowBg0 target, your color will override the existing RowBg0 color.
1245// If you set the color of RowBg1 or ColumnBg1 target, your color will blend over the RowBg0 color.
1246enum KGGuiTableBgTarget_
1247{
1248 KGGuiTableBgTarget_None = 0,
1249 KGGuiTableBgTarget_RowBg0 = 1, // Set row background color 0 (generally used for background, automatically set when KGGuiTableFlags_RowBg is used)
1250 KGGuiTableBgTarget_RowBg1 = 2, // Set row background color 1 (generally used for selection marking)
1251 KGGuiTableBgTarget_CellBg = 3, // Set cell background color (top-most color)
1252};
1253
1254// Flags for KarmaGui::IsWindowFocused()
1255enum KGGuiFocusedFlags_
1256{
1257 KGGuiFocusedFlags_None = 0,
1258 KGGuiFocusedFlags_ChildWindows = 1 << 0, // Return true if any children of the window is focused
1259 KGGuiFocusedFlags_RootWindow = 1 << 1, // Test from root window (top most parent of the current hierarchy)
1260 KGGuiFocusedFlags_AnyWindow = 1 << 2, // Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ!
1261 KGGuiFocusedFlags_NoPopupHierarchy = 1 << 3, // Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow)
1262 KGGuiFocusedFlags_DockHierarchy = 1 << 4, // Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow)
1263 KGGuiFocusedFlags_RootAndChildWindows = KGGuiFocusedFlags_RootWindow | KGGuiFocusedFlags_ChildWindows,
1264};
1265
1266// Flags for KarmaGui::IsItemHovered(), KarmaGui::IsWindowHovered()
1267// Note: if you are trying to check whether your mouse should be dispatched to Dear ImGui or to your app, you should use 'io.WantCaptureMouse' instead! Please read the FAQ!
1268// Note: windows with the KGGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls.
1269enum KGGuiHoveredFlags_
1270{
1271 KGGuiHoveredFlags_None = 0, // Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them.
1272 KGGuiHoveredFlags_ChildWindows = 1 << 0, // IsWindowHovered() only: Return true if any children of the window is hovered
1273 KGGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy)
1274 KGGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered
1275 KGGuiHoveredFlags_NoPopupHierarchy = 1 << 3, // IsWindowHovered() only: Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow)
1276 KGGuiHoveredFlags_DockHierarchy = 1 << 4, // IsWindowHovered() only: Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow)
1277 KGGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 5, // Return true even if a popup window is normally blocking access to this item/window
1278 //KGGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 6, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
1279 KGGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 7, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
1280 KGGuiHoveredFlags_AllowWhenOverlapped = 1 << 8, // IsItemHovered() only: Return true even if the position is obstructed or overlapped by another window
1281 KGGuiHoveredFlags_AllowWhenDisabled = 1 << 9, // IsItemHovered() only: Return true even if the item is disabled
1282 KGGuiHoveredFlags_NoNavOverride = 1 << 10, // Disable using gamepad/keyboard navigation state when active, always query mouse.
1283 KGGuiHoveredFlags_RectOnly = KGGuiHoveredFlags_AllowWhenBlockedByPopup | KGGuiHoveredFlags_AllowWhenBlockedByActiveItem | KGGuiHoveredFlags_AllowWhenOverlapped,
1284 KGGuiHoveredFlags_RootAndChildWindows = KGGuiHoveredFlags_RootWindow | KGGuiHoveredFlags_ChildWindows,
1285
1286 // Hovering delays (for tooltips)
1287 KGGuiHoveredFlags_DelayNormal = 1 << 11, // Return true after io.HoverDelayNormal elapsed (~0.30 sec)
1288 KGGuiHoveredFlags_DelayShort = 1 << 12, // Return true after io.HoverDelayShort elapsed (~0.10 sec)
1289 KGGuiHoveredFlags_NoSharedDelay = 1 << 13, // Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
1290};
1291
1292// Flags for KarmaGui::DockSpace(), shared/inherited by child nodes.
1293// (Some flags can be applied to individual nodes directly)
1294// FIXME-DOCK: Also see KGGuiDockNodeFlagsPrivate_ which may involve using the WIP and internal DockBuilder api.
1295enum KGGuiDockNodeFlags_
1296{
1297 KGGuiDockNodeFlags_None = 0,
1298 KGGuiDockNodeFlags_KeepAliveOnly = 1 << 0, // Shared // Don't display the dockspace node but keep it alive. Windows docked into this dockspace node won't be undocked.
1299 //KGGuiDockNodeFlags_NoCentralNode = 1 << 1, // Shared // Disable Central Node (the node which can stay empty)
1300 KGGuiDockNodeFlags_NoDockingInCentralNode = 1 << 2, // Shared // Disable docking inside the Central Node, which will be always kept empty.
1301 KGGuiDockNodeFlags_PassthruCentralNode = 1 << 3, // Shared // Enable passthru dockspace: 1) DockSpace() will render a KGGuiCol_WindowBg background covering everything excepted the Central Node when empty. Meaning the host window should probably use SetNextWindowBgAlpha(0.0f) prior to Begin() when using this. 2) When Central Node is empty: let inputs pass-through + won't display a DockingEmptyBg background. See demo for details.
1302 KGGuiDockNodeFlags_NoSplit = 1 << 4, // Shared/Local // Disable splitting the node into smaller nodes. Useful e.g. when embedding dockspaces into a main root one (the root one may have splitting disabled to reduce confusion). Note: when turned off, existing splits will be preserved.
1303 KGGuiDockNodeFlags_NoResize = 1 << 5, // Shared/Local // Disable resizing node using the splitter/separators. Useful with programmatically setup dockspaces.
1304 KGGuiDockNodeFlags_AutoHideTabBar = 1 << 6, // Shared/Local // Tab bar will automatically hide when there is a single window in the dock node.
1305};
1306
1307// Flags for KarmaGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
1308enum KGGuiDragDropFlags_
1309{
1310 KGGuiDragDropFlags_None = 0,
1311 // BeginDragDropSource() flags
1312 KGGuiDragDropFlags_SourceNoPreviewTooltip = 1 << 0, // By default, a successful call to BeginDragDropSource opens a tooltip so you can display a preview or description of the source contents. This flag disables this behavior.
1313 KGGuiDragDropFlags_SourceNoDisableHover = 1 << 1, // By default, when dragging we clear data so that IsItemHovered() will return false, to avoid subsequent user code submitting tooltips. This flag disables this behavior so you can still call IsItemHovered() on the source item.
1314 KGGuiDragDropFlags_SourceNoHoldToOpenOthers = 1 << 2, // Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item.
1315 KGGuiDragDropFlags_SourceAllowNullID = 1 << 3, // Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit.
1316 KGGuiDragDropFlags_SourceExtern = 1 << 4, // External source (from outside of dear imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously.
1317 KGGuiDragDropFlags_SourceAutoExpirePayload = 1 << 5, // Automatically expire the payload if the source cease to be submitted (otherwise payloads are persisting while being dragged)
1318 // AcceptDragDropPayload() flags
1319 KGGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered.
1320 KGGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target.
1321 KGGuiDragDropFlags_AcceptNoPreviewTooltip = 1 << 12, // Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site.
1322 KGGuiDragDropFlags_AcceptPeekOnly = KGGuiDragDropFlags_AcceptBeforeDelivery | KGGuiDragDropFlags_AcceptNoDrawDefaultRect, // For peeking ahead and inspecting the payload before delivery.
1323};
1324
1325// Standard Drag and Drop payload types. You can define you own payload types using short strings. Types starting with '_' are defined by Dear ImGui.
1326#define KARMAGUI_PAYLOAD_TYPE_COLOR_3F "_COL3F" // float[3]: Standard type for colors, without alpha. User code may use this type.
1327#define KARMAGUI_PAYLOAD_TYPE_COLOR_4F "_COL4F" // float[4]: Standard type for colors. User code may use this type.
1328
1329// A primary data type
1330enum KGGuiDataType_
1331{
1332 KGGuiDataType_S8, // signed char / char (with sensible compilers)
1333 KGGuiDataType_U8, // unsigned char
1334 KGGuiDataType_S16, // short
1335 KGGuiDataType_U16, // unsigned short
1336 KGGuiDataType_S32, // int
1337 KGGuiDataType_U32, // unsigned int
1338 KGGuiDataType_S64, // long long / __int64
1339 KGGuiDataType_U64, // unsigned long long / unsigned __int64
1340 KGGuiDataType_Float, // float
1341 KGGuiDataType_Double, // double
1342 KGGuiDataType_COUNT
1343};
1344
1345// A cardinal direction
1346enum KGGuiDir_
1347{
1348 KGGuiDir_None = -1,
1349 KGGuiDir_Left = 0,
1350 KGGuiDir_Right = 1,
1351 KGGuiDir_Up = 2,
1352 KGGuiDir_Down = 3,
1353 KGGuiDir_COUNT
1354};
1355
1356// A sorting direction
1357enum KGGuiSortDirection_
1358{
1359 KGGuiSortDirection_None = 0,
1360 KGGuiSortDirection_Ascending = 1, // Ascending = 0->9, A->Z etc.
1361 KGGuiSortDirection_Descending = 2 // Descending = 9->0, Z->A etc.
1362};
1363
1364// A key identifier (KGGuiKey_XXX or KGGuiMod_XXX value): can represent Keyboard, Mouse and Gamepad values.
1365// All our named keys are >= 512. Keys value 0 to 511 are left unused as legacy native/opaque key values (< 1.87).
1366// Since >= 1.89 we increased typing (went from int to enum), some legacy code may need a cast to KarmaGuiKey.
1367// Read details about the 1.87 and 1.89 transition : https://github.com/ocornut/imgui/issues/4921
1368enum KarmaGuiKey : int
1369{
1370 // Keyboard
1371 KGGuiKey_None = 0,
1372 KGGuiKey_Tab = 512, // == KGGuiKey_NamedKey_BEGIN
1373 KGGuiKey_LeftArrow,
1374 KGGuiKey_RightArrow,
1375 KGGuiKey_UpArrow,
1376 KGGuiKey_DownArrow,
1377 KGGuiKey_PageUp,
1378 KGGuiKey_PageDown,
1379 KGGuiKey_Home,
1380 KGGuiKey_End,
1381 KGGuiKey_Insert,
1382 KGGuiKey_Delete,
1383 KGGuiKey_Backspace,
1384 KGGuiKey_Space,
1385 KGGuiKey_Enter,
1386 KGGuiKey_Escape,
1387 KGGuiKey_LeftCtrl, KGGuiKey_LeftShift, KGGuiKey_LeftAlt, KGGuiKey_LeftSuper,
1388 KGGuiKey_RightCtrl, KGGuiKey_RightShift, KGGuiKey_RightAlt, KGGuiKey_RightSuper,
1389 KGGuiKey_Menu,
1390 KGGuiKey_0, KGGuiKey_1, KGGuiKey_2, KGGuiKey_3, KGGuiKey_4, KGGuiKey_5, KGGuiKey_6, KGGuiKey_7, KGGuiKey_8, KGGuiKey_9,
1391 KGGuiKey_A, KGGuiKey_B, KGGuiKey_C, KGGuiKey_D, KGGuiKey_E, KGGuiKey_F, KGGuiKey_G, KGGuiKey_H, KGGuiKey_I, KGGuiKey_J,
1392 KGGuiKey_K, KGGuiKey_L, KGGuiKey_M, KGGuiKey_N, KGGuiKey_O, KGGuiKey_P, KGGuiKey_Q, KGGuiKey_R, KGGuiKey_S, KGGuiKey_T,
1393 KGGuiKey_U, KGGuiKey_V, KGGuiKey_W, KGGuiKey_X, KGGuiKey_Y, KGGuiKey_Z,
1394 KGGuiKey_F1, KGGuiKey_F2, KGGuiKey_F3, KGGuiKey_F4, KGGuiKey_F5, KGGuiKey_F6,
1395 KGGuiKey_F7, KGGuiKey_F8, KGGuiKey_F9, KGGuiKey_F10, KGGuiKey_F11, KGGuiKey_F12,
1396 KGGuiKey_Apostrophe, // '
1397 KGGuiKey_Comma, // ,
1398 KGGuiKey_Minus, // -
1399 KGGuiKey_Period, // .
1400 KGGuiKey_Slash, // /
1401 KGGuiKey_Semicolon, // ;
1402 KGGuiKey_Equal, // =
1403 KGGuiKey_LeftBracket, // [
1404 KGGuiKey_Backslash, // \ (this text inhibit multiline comment caused by backslash)
1405 KGGuiKey_RightBracket, // ]
1406 KGGuiKey_GraveAccent, // `
1407 KGGuiKey_CapsLock,
1408 KGGuiKey_ScrollLock,
1409 KGGuiKey_NumLock,
1410 KGGuiKey_PrintScreen,
1411 KGGuiKey_Pause,
1412 KGGuiKey_Keypad0, KGGuiKey_Keypad1, KGGuiKey_Keypad2, KGGuiKey_Keypad3, KGGuiKey_Keypad4,
1413 KGGuiKey_Keypad5, KGGuiKey_Keypad6, KGGuiKey_Keypad7, KGGuiKey_Keypad8, KGGuiKey_Keypad9,
1414 KGGuiKey_KeypadDecimal,
1415 KGGuiKey_KeypadDivide,
1416 KGGuiKey_KeypadMultiply,
1417 KGGuiKey_KeypadSubtract,
1418 KGGuiKey_KeypadAdd,
1419 KGGuiKey_KeypadEnter,
1420 KGGuiKey_KeypadEqual,
1421
1422 // Gamepad (some of those are analog values, 0.0f to 1.0f) // NAVIGATION ACTION
1423 // (download controller mapping PNG/PSD at http://dearimgui.org/controls_sheets)
1424 KGGuiKey_GamepadStart, // Menu (Xbox) + (Switch) Start/Options (PS)
1425 KGGuiKey_GamepadBack, // View (Xbox) - (Switch) Share (PS)
1426 KGGuiKey_GamepadFaceLeft, // X (Xbox) Y (Switch) Square (PS) // Tap: Toggle Menu. Hold: Windowing mode (Focus/Move/Resize windows)
1427 KGGuiKey_GamepadFaceRight, // B (Xbox) A (Switch) Circle (PS) // Cancel / Close / Exit
1428 KGGuiKey_GamepadFaceUp, // Y (Xbox) X (Switch) Triangle (PS) // Text Input / On-screen Keyboard
1429 KGGuiKey_GamepadFaceDown, // A (Xbox) B (Switch) Cross (PS) // Activate / Open / Toggle / Tweak
1430 KGGuiKey_GamepadDpadLeft, // D-pad Left // Move / Tweak / Resize Window (in Windowing mode)
1431 KGGuiKey_GamepadDpadRight, // D-pad Right // Move / Tweak / Resize Window (in Windowing mode)
1432 KGGuiKey_GamepadDpadUp, // D-pad Up // Move / Tweak / Resize Window (in Windowing mode)
1433 KGGuiKey_GamepadDpadDown, // D-pad Down // Move / Tweak / Resize Window (in Windowing mode)
1434 KGGuiKey_GamepadL1, // L Bumper (Xbox) L (Switch) L1 (PS) // Tweak Slower / Focus Previous (in Windowing mode)
1435 KGGuiKey_GamepadR1, // R Bumper (Xbox) R (Switch) R1 (PS) // Tweak Faster / Focus Next (in Windowing mode)
1436 KGGuiKey_GamepadL2, // L Trig. (Xbox) ZL (Switch) L2 (PS) [Analog]
1437 KGGuiKey_GamepadR2, // R Trig. (Xbox) ZR (Switch) R2 (PS) [Analog]
1438 KGGuiKey_GamepadL3, // L Stick (Xbox) L3 (Switch) L3 (PS)
1439 KGGuiKey_GamepadR3, // R Stick (Xbox) R3 (Switch) R3 (PS)
1440 KGGuiKey_GamepadLStickLeft, // [Analog] // Move Window (in Windowing mode)
1441 KGGuiKey_GamepadLStickRight, // [Analog] // Move Window (in Windowing mode)
1442 KGGuiKey_GamepadLStickUp, // [Analog] // Move Window (in Windowing mode)
1443 KGGuiKey_GamepadLStickDown, // [Analog] // Move Window (in Windowing mode)
1444 KGGuiKey_GamepadRStickLeft, // [Analog]
1445 KGGuiKey_GamepadRStickRight, // [Analog]
1446 KGGuiKey_GamepadRStickUp, // [Analog]
1447 KGGuiKey_GamepadRStickDown, // [Analog]
1448
1449 // Aliases: Mouse Buttons (auto-submitted from AddMouseButtonEvent() calls)
1450 // - This is mirroring the data also written to io.MouseDown[], io.MouseWheel, in a format allowing them to be accessed via standard key API.
1451 KGGuiKey_MouseLeft, KGGuiKey_MouseRight, KGGuiKey_MouseMiddle, KGGuiKey_MouseX1, KGGuiKey_MouseX2, KGGuiKey_MouseWheelX, KGGuiKey_MouseWheelY,
1452
1453 // [Internal] Reserved for mod storage
1454 KGGuiKey_ReservedForModCtrl, KGGuiKey_ReservedForModShift, KGGuiKey_ReservedForModAlt, KGGuiKey_ReservedForModSuper,
1455 KGGuiKey_COUNT,
1456
1457 // Keyboard Modifiers (explicitly submitted by backend via AddKeyEvent() calls)
1458 // - This is mirroring the data also written to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper, in a format allowing
1459 // them to be accessed via standard key API, allowing calls such as IsKeyPressed(), IsKeyReleased(), querying duration etc.
1460 // - Code polling every key (e.g. an interface to detect a key press for input mapping) might want to ignore those
1461 // and prefer using the real keys (e.g. KGGuiKey_LeftCtrl, KGGuiKey_RightCtrl instead of KGGuiMod_Ctrl).
1462 // - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys.
1463 // In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and
1464 // backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user...
1465 KGGuiMod_None = 0,
1466 KGGuiMod_Ctrl = 1 << 12, // Ctrl
1467 KGGuiMod_Shift = 1 << 13, // Shift
1468 KGGuiMod_Alt = 1 << 14, // Option/Menu
1469 KGGuiMod_Super = 1 << 15, // Cmd/Super/Windows
1470 KGGuiMod_Shortcut = 1 << 11, // Alias for Ctrl (non-macOS) _or_ Super (macOS).
1471 KGGuiMod_Mask_ = 0xF800, // 5-bits
1472
1473 // [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index + the io.KeyMap[] array.
1474 // We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
1475 KGGuiKey_NamedKey_BEGIN = 512,
1476 KGGuiKey_NamedKey_END = KGGuiKey_COUNT,
1477 KGGuiKey_NamedKey_COUNT = KGGuiKey_NamedKey_END - KGGuiKey_NamedKey_BEGIN,
1478#ifdef KARMAGUI_DISABLE_OBSOLETE_KEYIO
1479 KGGuiKey_KeysData_SIZE = KGGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys
1480 KGGuiKey_KeysData_OFFSET = KGGuiKey_NamedKey_BEGIN, // First key stored in io.KeysData[0]. Accesses to io.KeysData[] must use (key - KGGuiKey_KeysData_OFFSET).
1481#else
1482 KGGuiKey_KeysData_SIZE = KGGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys
1483 KGGuiKey_KeysData_OFFSET = 0, // First key stored in io.KeysData[0]. Accesses to io.KeysData[] must use (key - KGGuiKey_KeysData_OFFSET).
1484#endif
1485
1486#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1487 KGGuiKey_ModCtrl = KGGuiMod_Ctrl, KGGuiKey_ModShift = KGGuiMod_Shift, KGGuiKey_ModAlt = KGGuiMod_Alt, KGGuiKey_ModSuper = KGGuiMod_Super, // Renamed in 1.89
1488 KGGuiKey_KeyPadEnter = KGGuiKey_KeypadEnter, // Renamed in 1.87
1489#endif
1490};
1491
1492// Flags for Shortcut()
1493// (+ for upcoming advanced versions of IsKeyPressed()/IsMouseClicked()/SetKeyOwner()/SetItemKeyOwner() that are currently in imgui_internal.h)
1494enum KGGuiInputFlags_
1495{
1496 KGGuiInputFlags_None = 0,
1497 KGGuiInputFlags_Repeat = 1 << 0, // Return true on successive repeats. Default for legacy IsKeyPressed(). NOT Default for legacy IsMouseClicked(). MUST BE == 1.
1498
1499 // Routing policies for Shortcut() + low-level SetShortcutRouting()
1500 // - The general idea is that several callers register interest in a shortcut, and only one owner gets it.
1501 // - When a policy (other than _RouteAlways) is set, Shortcut() will register itself with SetShortcutRouting(),
1502 // allowing the system to decide where to route the input among other route-aware calls.
1503 // - Shortcut() uses KGGuiInputFlags_RouteFocused by default: meaning that a simple Shortcut() poll
1504 // will register a route and only succeed when parent window is in the focus stack and if no-one
1505 // with a higher priority is claiming the shortcut.
1506 // - Using KGGuiInputFlags_RouteAlways is roughly equivalent to doing e.g. IsKeyPressed(key) + testing mods.
1507 // - Priorities: GlobalHigh > Focused (when owner is active item) > Global > Focused (when focused window) > GlobalLow.
1508
1509 // Policies (can select only 1 policy among all available)
1510 KGGuiInputFlags_RouteFocused = 1 << 8, // (Default) Register focused route: Accept inputs if window is in focus stack. Deep-most focused window takes inputs. ActiveId takes inputs over deep-most focused window.
1511 KGGuiInputFlags_RouteGlobalLow = 1 << 9, // Register route globally (lowest priority: unless a focused window or active item registered the route) -> recommended Global priority.
1512 KGGuiInputFlags_RouteGlobal = 1 << 10, // Register route globally (medium priority: unless an active item registered the route, e.g. CTRL+A registered by InputText).
1513 KGGuiInputFlags_RouteGlobalHigh = 1 << 11, // Register route globally (highest priority: unlikely you need to use that: will interfere with every active items)
1514 KGGuiInputFlags_RouteAlways = 1 << 12, // Do not register route, poll keys directly.
1515
1516 // Policies Options
1517 KGGuiInputFlags_RouteUnlessBgFocused= 1 << 13, // Global routes will not be applied if underlying background/void is focused (== no Dear ImGui windows are focused). Useful for overlay applications.
1518};
1519
1520#ifndef KARMAGUI_DISABLE_OBSOLETE_KEYIO
1521// OBSOLETED in 1.88 (from July 2022): KGGuiNavInput and io.NavInputs[].
1522// Official backends between 1.60 and 1.86: will keep working and feed gamepad inputs as long as IMGUI_DISABLE_OBSOLETE_KEYIO is not set.
1523// Custom backends: feed gamepad inputs via io.AddKeyEvent() and KGGuiKey_GamepadXXX enums.
1524enum KGGuiNavInput
1525{
1526 KGGuiNavInput_Activate, KGGuiNavInput_Cancel, KGGuiNavInput_Input, KGGuiNavInput_Menu, KGGuiNavInput_DpadLeft, KGGuiNavInput_DpadRight, KGGuiNavInput_DpadUp, KGGuiNavInput_DpadDown,
1527 KGGuiNavInput_LStickLeft, KGGuiNavInput_LStickRight, KGGuiNavInput_LStickUp, KGGuiNavInput_LStickDown, KGGuiNavInput_FocusPrev, KGGuiNavInput_FocusNext, KGGuiNavInput_TweakSlow, KGGuiNavInput_TweakFast,
1528 KGGuiNavInput_COUNT,
1529};
1530#endif
1531
1532// Configuration flags stored in io.ConfigFlags. Set by user/application.
1533enum KGGuiConfigFlags_
1534{
1535 KGGuiConfigFlags_None = 0,
1536 KGGuiConfigFlags_NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag.
1537 KGGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. Backend also needs to set KGGuiBackendFlags_HasGamepad.
1538 KGGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your backend, otherwise ImGui will react as if the mouse is jumping around back and forth.
1539 KGGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set.
1540 KGGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the backend.
1541 KGGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead.
1542
1543 // [BETA] Docking
1544 KGGuiConfigFlags_DockingEnable = 1 << 6, // Docking enable flags.
1545
1546 // [BETA] Viewports
1547 // When using viewports it is recommended that your default value for KGGuiCol_WindowBg is opaque (Alpha=1.0) so transition to a viewport won't be noticeable.
1548 KGGuiConfigFlags_ViewportsEnable = 1 << 10, // Viewport enable flags (require both KGGuiBackendFlags_PlatformHasViewports + KGGuiBackendFlags_RendererHasViewports set by the respective backends)
1549 KGGuiConfigFlags_DpiEnableScaleViewports= 1 << 14, // [BETA: Don't use] FIXME-DPI: Reposition and resize imgui windows when the DpiScale of a viewport changed (mostly useful for the main viewport hosting other window). Note that resizing the main window itself is up to your application.
1550 KGGuiConfigFlags_DpiEnableScaleFonts = 1 << 15, // [BETA: Don't use] FIXME-DPI: Request bitmap-scaled fonts to match DpiScale. This is a very low-quality workaround. The correct way to handle DPI is _currently_ to replace the atlas and/or fonts in the Platform_OnChangedViewport callback, but this is all early work in progress.
1551
1552 // User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are NOT used by core Dear ImGui)
1553 KGGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
1554 KGGuiConfigFlags_IsTouchScreen = 1 << 21, // Application is using a touch screen instead of a mouse.
1555};
1556
1557// Backend capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom backend.
1558enum KGGuiBackendFlags_
1559{
1560 KGGuiBackendFlags_None = 0,
1561 KGGuiBackendFlags_HasGamepad = 1 << 0, // Backend Platform supports gamepad and currently has one connected.
1562 KGGuiBackendFlags_HasMouseCursors = 1 << 1, // Backend Platform supports honoring GetMouseCursor() value to change the OS cursor shape.
1563 KGGuiBackendFlags_HasSetMousePos = 1 << 2, // Backend Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if KGGuiConfigFlags_NavEnableSetMousePos is set).
1564 KGGuiBackendFlags_RendererHasVtxOffset = 1 << 3, // Backend Renderer supports KGDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices.
1565
1566 // [BETA] Viewports
1567 KGGuiBackendFlags_PlatformHasViewports = 1 << 10, // Backend Platform supports multiple viewports.
1568 KGGuiBackendFlags_HasMouseHoveredViewport=1 << 11, // Backend Platform supports calling io.AddMouseViewportEvent() with the viewport under the mouse. IF POSSIBLE, ignore viewports with the KGGuiViewportFlags_NoInputs flag (Win32 backend, GLFW 3.30+ backend can do this, SDL backend cannot). If this cannot be done, Dear ImGui needs to use a flawed heuristic to find the viewport under.
1569 KGGuiBackendFlags_RendererHasViewports = 1 << 12, // Backend Renderer supports multiple viewports.
1570};
1571
1572// Enumeration for PushStyleColor() / PopStyleColor()
1573enum KGGuiCol_
1574{
1575 KGGuiCol_Text,
1576 KGGuiCol_TextDisabled,
1577 KGGuiCol_WindowBg, // Background of normal windows
1578 KGGuiCol_ChildBg, // Background of child windows
1579 KGGuiCol_PopupBg, // Background of popups, menus, tooltips windows
1580 KGGuiCol_Border,
1581 KGGuiCol_BorderShadow,
1582 KGGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input
1583 KGGuiCol_FrameBgHovered,
1584 KGGuiCol_FrameBgActive,
1585 KGGuiCol_TitleBg,
1586 KGGuiCol_TitleBgActive,
1587 KGGuiCol_TitleBgCollapsed,
1588 KGGuiCol_MenuBarBg,
1589 KGGuiCol_ScrollbarBg,
1590 KGGuiCol_ScrollbarGrab,
1591 KGGuiCol_ScrollbarGrabHovered,
1592 KGGuiCol_ScrollbarGrabActive,
1593 KGGuiCol_CheckMark,
1594 KGGuiCol_SliderGrab,
1595 KGGuiCol_SliderGrabActive,
1596 KGGuiCol_Button,
1597 KGGuiCol_ButtonHovered,
1598 KGGuiCol_ButtonActive,
1599 KGGuiCol_Header, // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem
1600 KGGuiCol_HeaderHovered,
1601 KGGuiCol_HeaderActive,
1602 KGGuiCol_Separator,
1603 KGGuiCol_SeparatorHovered,
1604 KGGuiCol_SeparatorActive,
1605 KGGuiCol_ResizeGrip, // Resize grip in lower-right and lower-left corners of windows.
1606 KGGuiCol_ResizeGripHovered,
1607 KGGuiCol_ResizeGripActive,
1608 KGGuiCol_Tab, // TabItem in a TabBar
1609 KGGuiCol_TabHovered,
1610 KGGuiCol_TabActive,
1611 KGGuiCol_TabUnfocused,
1612 KGGuiCol_TabUnfocusedActive,
1613 KGGuiCol_DockingPreview, // Preview overlay color when about to docking something
1614 KGGuiCol_DockingEmptyBg, // Background color for empty node (e.g. CentralNode with no window docked into it)
1615 KGGuiCol_PlotLines,
1616 KGGuiCol_PlotLinesHovered,
1617 KGGuiCol_PlotHistogram,
1618 KGGuiCol_PlotHistogramHovered,
1619 KGGuiCol_TableHeaderBg, // Table header background
1620 KGGuiCol_TableBorderStrong, // Table outer and header borders (prefer using Alpha=1.0 here)
1621 KGGuiCol_TableBorderLight, // Table inner borders (prefer using Alpha=1.0 here)
1622 KGGuiCol_TableRowBg, // Table row background (even rows)
1623 KGGuiCol_TableRowBgAlt, // Table row background (odd rows)
1624 KGGuiCol_TextSelectedBg,
1625 KGGuiCol_DragDropTarget, // Rectangle highlighting a drop target
1626 KGGuiCol_NavHighlight, // Gamepad/keyboard: current highlighted item
1627 KGGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB
1628 KGGuiCol_NavWindowingDimBg, // Darken/colorize entire screen behind the CTRL+TAB window list, when active
1629 KGGuiCol_ModalWindowDimBg, // Darken/colorize entire screen behind a modal window, when one is active
1630 KGGuiCol_COUNT
1631};
1632
1633// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the KarmaGuiStyle structure.
1634// - The enum only refers to fields of KarmaGuiStyle which makes sense to be pushed/popped inside UI code.
1635// During initialization or between frames, feel free to just poke into KarmaGuiStyle directly.
1636// - Tip: Use your programming IDE navigation facilities on the names in the _second column_ below to find the actual members and their description.
1637// In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
1638// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
1639// - When changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
1640enum KGGuiStyleVar_
1641{
1642 // Enum name --------------------- // Member in KarmaGuiStyle structure (see KarmaGuiStyle for descriptions)
1643 KGGuiStyleVar_Alpha, // float Alpha
1644 KGGuiStyleVar_DisabledAlpha, // float DisabledAlpha
1645 KGGuiStyleVar_WindowPadding, // KGVec2 WindowPadding
1646 KGGuiStyleVar_WindowRounding, // float WindowRounding
1647 KGGuiStyleVar_WindowBorderSize, // float WindowBorderSize
1648 KGGuiStyleVar_WindowMinSize, // KGVec2 WindowMinSize
1649 KGGuiStyleVar_WindowTitleAlign, // KGVec2 WindowTitleAlign
1650 KGGuiStyleVar_ChildRounding, // float ChildRounding
1651 KGGuiStyleVar_ChildBorderSize, // float ChildBorderSize
1652 KGGuiStyleVar_PopupRounding, // float PopupRounding
1653 KGGuiStyleVar_PopupBorderSize, // float PopupBorderSize
1654 KGGuiStyleVar_FramePadding, // KGVec2 FramePadding
1655 KGGuiStyleVar_FrameRounding, // float FrameRounding
1656 KGGuiStyleVar_FrameBorderSize, // float FrameBorderSize
1657 KGGuiStyleVar_ItemSpacing, // KGVec2 ItemSpacing
1658 KGGuiStyleVar_ItemInnerSpacing, // KGVec2 ItemInnerSpacing
1659 KGGuiStyleVar_IndentSpacing, // float IndentSpacing
1660 KGGuiStyleVar_CellPadding, // KGVec2 CellPadding
1661 KGGuiStyleVar_ScrollbarSize, // float ScrollbarSize
1662 KGGuiStyleVar_ScrollbarRounding, // float ScrollbarRounding
1663 KGGuiStyleVar_GrabMinSize, // float GrabMinSize
1664 KGGuiStyleVar_GrabRounding, // float GrabRounding
1665 KGGuiStyleVar_TabRounding, // float TabRounding
1666 KGGuiStyleVar_ButtonTextAlign, // KGVec2 ButtonTextAlign
1667 KGGuiStyleVar_SelectableTextAlign, // KGVec2 SelectableTextAlign
1668 KGGuiStyleVar_COUNT
1669};
1670
1671// Flags for InvisibleButton() [extended in imgui_internal.h]
1672enum KGGuiButtonFlags_
1673{
1674 KGGuiButtonFlags_None = 0,
1675 KGGuiButtonFlags_MouseButtonLeft = 1 << 0, // React on left mouse button (default)
1676 KGGuiButtonFlags_MouseButtonRight = 1 << 1, // React on right mouse button
1677 KGGuiButtonFlags_MouseButtonMiddle = 1 << 2, // React on center mouse button
1678
1679 // [Internal]
1680 KGGuiButtonFlags_MouseButtonMask_ = KGGuiButtonFlags_MouseButtonLeft | KGGuiButtonFlags_MouseButtonRight | KGGuiButtonFlags_MouseButtonMiddle,
1681 KGGuiButtonFlags_MouseButtonDefault_ = KGGuiButtonFlags_MouseButtonLeft,
1682};
1683
1684// Flags for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton()
1685enum KGGuiColorEditFlags_
1686{
1687 KGGuiColorEditFlags_None = 0,
1688 KGGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (will only read 3 components from the input pointer).
1689 KGGuiColorEditFlags_NoPicker = 1 << 2, // // ColorEdit: disable picker when clicking on color square.
1690 KGGuiColorEditFlags_NoOptions = 1 << 3, // // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview.
1691 KGGuiColorEditFlags_NoSmallPreview = 1 << 4, // // ColorEdit, ColorPicker: disable color square preview next to the inputs. (e.g. to show only the inputs)
1692 KGGuiColorEditFlags_NoInputs = 1 << 5, // // ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the small preview color square).
1693 KGGuiColorEditFlags_NoTooltip = 1 << 6, // // ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview.
1694 KGGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker).
1695 KGGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small color square preview instead.
1696 KGGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
1697 KGGuiColorEditFlags_NoBorder = 1 << 10, // // ColorButton: disable border (which is enforced by default)
1698
1699 // User Options (right-click on widget to change some of them).
1700 KGGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
1701 KGGuiColorEditFlags_AlphaPreview = 1 << 17, // // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque.
1702 KGGuiColorEditFlags_AlphaPreviewHalf= 1 << 18, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque.
1703 KGGuiColorEditFlags_HDR = 1 << 19, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use KGGuiColorEditFlags_Float flag as well).
1704 KGGuiColorEditFlags_DisplayRGB = 1 << 20, // [Display] // ColorEdit: override _display_ type among RGB/HSV/Hex. ColorPicker: select any combination using one or more of RGB/HSV/Hex.
1705 KGGuiColorEditFlags_DisplayHSV = 1 << 21, // [Display] // "
1706 KGGuiColorEditFlags_DisplayHex = 1 << 22, // [Display] // "
1707 KGGuiColorEditFlags_Uint8 = 1 << 23, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255.
1708 KGGuiColorEditFlags_Float = 1 << 24, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers.
1709 KGGuiColorEditFlags_PickerHueBar = 1 << 25, // [Picker] // ColorPicker: bar for Hue, rectangle for Sat/Value.
1710 KGGuiColorEditFlags_PickerHueWheel = 1 << 26, // [Picker] // ColorPicker: wheel for Hue, triangle for Sat/Value.
1711 KGGuiColorEditFlags_InputRGB = 1 << 27, // [Input] // ColorEdit, ColorPicker: input and output data in RGB format.
1712 KGGuiColorEditFlags_InputHSV = 1 << 28, // [Input] // ColorEdit, ColorPicker: input and output data in HSV format.
1713
1714 // Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to
1715 // override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup.
1716 KGGuiColorEditFlags_DefaultOptions_ = KGGuiColorEditFlags_Uint8 | KGGuiColorEditFlags_DisplayRGB | KGGuiColorEditFlags_InputRGB | KGGuiColorEditFlags_PickerHueBar,
1717
1718 // [Internal] Masks
1719 KGGuiColorEditFlags_DisplayMask_ = KGGuiColorEditFlags_DisplayRGB | KGGuiColorEditFlags_DisplayHSV | KGGuiColorEditFlags_DisplayHex,
1720 KGGuiColorEditFlags_DataTypeMask_ = KGGuiColorEditFlags_Uint8 | KGGuiColorEditFlags_Float,
1721 KGGuiColorEditFlags_PickerMask_ = KGGuiColorEditFlags_PickerHueWheel | KGGuiColorEditFlags_PickerHueBar,
1722 KGGuiColorEditFlags_InputMask_ = KGGuiColorEditFlags_InputRGB | KGGuiColorEditFlags_InputHSV,
1723
1724 // Obsolete names (will be removed)
1725 // KGGuiColorEditFlags_RGB = KGGuiColorEditFlags_DisplayRGB, KGGuiColorEditFlags_HSV = KGGuiColorEditFlags_DisplayHSV, KGGuiColorEditFlags_HEX = KGGuiColorEditFlags_DisplayHex // [renamed in 1.69]
1726};
1727
1728// Flags for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc.
1729// We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them.
1730// (Those are per-item flags. There are shared flags in KarmaGuiIO: io.ConfigDragClickToInputText)
1731enum KGGuiSliderFlags_
1732{
1733 KGGuiSliderFlags_None = 0,
1734 KGGuiSliderFlags_AlwaysClamp = 1 << 4, // Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds.
1735 KGGuiSliderFlags_Logarithmic = 1 << 5, // Make the widget logarithmic (linear otherwise). Consider using KGGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits.
1736 KGGuiSliderFlags_NoRoundToFormat = 1 << 6, // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits)
1737 KGGuiSliderFlags_NoInput = 1 << 7, // Disable CTRL+Click or Enter key allowing to input text directly into the widget
1738 KGGuiSliderFlags_InvalidMask_ = 0x7000000F, // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed.
1739
1740 // Obsolete names (will be removed)
1741#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1742 KGGuiSliderFlags_ClampOnInput = KGGuiSliderFlags_AlwaysClamp, // [renamed in 1.79]
1743#endif
1744};
1745
1746// Identify a mouse button.
1747// Those values are guaranteed to be stable and we frequently use 0/1 directly. Named enums provided for convenience.
1748enum KGGuiMouseButton_
1749{
1750 KGGuiMouseButton_Left = 0,
1751 KGGuiMouseButton_Right = 1,
1752 KGGuiMouseButton_Middle = 2,
1753 KGGuiMouseButton_COUNT = 5
1754};
1755
1756// Enumeration for GetMouseCursor()
1757// User code may request backend to display given cursor by calling SetMouseCursor(), which is why we have some cursors that are marked unused here
1758enum KGGuiMouseCursor_
1759{
1760 KGGuiMouseCursor_None = -1,
1761 KGGuiMouseCursor_Arrow = 0,
1762 KGGuiMouseCursor_TextInput, // When hovering over InputText, etc.
1763 KGGuiMouseCursor_ResizeAll, // (Unused by Dear ImGui functions)
1764 KGGuiMouseCursor_ResizeNS, // When hovering over a horizontal border
1765 KGGuiMouseCursor_ResizeEW, // When hovering over a vertical border or a column
1766 KGGuiMouseCursor_ResizeNESW, // When hovering over the bottom-left corner of a window
1767 KGGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window
1768 KGGuiMouseCursor_Hand, // (Unused by Dear ImGui functions. Use for e.g. hyperlinks)
1769 KGGuiMouseCursor_NotAllowed, // When hovering something with disallowed interaction. Usually a crossed circle.
1770 KGGuiMouseCursor_COUNT
1771};
1772
1773// Enumeration for ImGui::SetWindow***(), SetNextWindow***(), SetNextItem***() functions
1774// Represent a condition.
1775// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to KGGuiCond_Always.
1776enum KGGuiCond_
1777{
1778 KGGuiCond_None = 0, // No condition (always set the variable), same as _Always
1779 KGGuiCond_Always = 1 << 0, // No condition (always set the variable), same as _None
1780 KGGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call will succeed)
1781 KGGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file)
1782 KGGuiCond_Appearing = 1 << 3, // Set the variable if the object/window is appearing after being hidden/inactive (or the first time)
1783};
1784
1785//-----------------------------------------------------------------------------
1786// [SECTION] Helpers: Memory allocations macros, KGVector<>
1787//-----------------------------------------------------------------------------
1788
1789//-----------------------------------------------------------------------------
1790// IM_MALLOC(), KG_FREE(), KG_NEW(), KG_PLACEMENT_NEW(), KG_DELETE()
1791// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
1792// Defining a custom placement new() with a custom parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
1793//-----------------------------------------------------------------------------
1794
1796inline void* operator new(size_t, KGNewWrapper, void* ptr) { return ptr; }
1797inline void operator delete(void*, KGNewWrapper, void*) {} // This is only required so we can use the symmetrical new()
1798#define KG_ALLOC(_SIZE) Karma::KarmaGui::MemAlloc(_SIZE)
1799#define KG_FREE(_PTR) Karma::KarmaGui::MemFree(_PTR)
1800#define KG_PLACEMENT_NEW(_PTR) new(KGNewWrapper(), _PTR)
1801#define KG_NEW(_TYPE) new(KGNewWrapper(), Karma::KarmaGui::MemAlloc(sizeof(_TYPE))) _TYPE
1802template<typename T> void KG_DELETE(T* p) { if (p) { p->~T(); Karma::KarmaGui::MemFree(p); } }
1803
1804//-----------------------------------------------------------------------------
1805// KGVector<>
1806// Lightweight std::vector<>-like class to avoid dragging dependencies (also, some implementations of STL with debug enabled are absurdly slow, we bypass it so our code runs fast in debug).
1807//-----------------------------------------------------------------------------
1808// - You generally do NOT need to care or use this ever. But we need to make it available in imgui.h because some of our public structures are relying on it.
1809// - We use std-like naming convention here, which is a little unusual for this codebase.
1810// - Important: clear() frees memory, resize(0) keep the allocated buffer. We use resize(0) a lot to intentionally recycle allocated buffers across frames and amortize our costs.
1811// - Important: our implementation does NOT call C++ constructors/destructors, we treat everything as raw data! This is intentional but be extra mindful of that,
1812// Do NOT use this class as a std::vector replacement in your own code! Many of the structures used by dear imgui can be safely initialized by a zero-memset.
1813//-----------------------------------------------------------------------------
1814
1815template<typename T>
1816struct KGVector
1817{
1818 int Size;
1819 int Capacity;
1820 T* Data;
1821
1822 // Provide standard typedefs but we don't use them ourselves.
1823 typedef T value_type;
1824 typedef value_type* iterator;
1825 typedef const value_type* const_iterator;
1826
1827 // Constructors, destructor
1828 inline KGVector() { Size = Capacity = 0; Data = NULL; }
1829 inline KGVector(const KGVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
1830 inline KGVector<T>& operator=(const KGVector<T>& src) { clear(); resize(src.Size); if (src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
1831 inline ~KGVector() { if (Data) KG_FREE(Data); } // Important: does not destruct anything
1832
1833 inline void clear() { if (Data) { Size = Capacity = 0; KG_FREE(Data); Data = NULL; } } // Important: does not destruct anything
1834 inline void clear_delete() { for (int n = 0; n < Size; n++) KG_DELETE(Data[n]); clear(); } // Important: never called automatically! always explicit.
1835 inline void clear_destruct() { for (int n = 0; n < Size; n++) Data[n].~T(); clear(); } // Important: never called automatically! always explicit.
1836
1837 inline bool empty() const { return Size == 0; }
1838 inline int size() const { return Size; }
1839 inline int size_in_bytes() const { return Size * (int)sizeof(T); }
1840 inline int max_size() const { return 0x7FFFFFFF / (int)sizeof(T); }
1841 inline int capacity() const { return Capacity; }
1842 inline T& operator[](int i) { KR_CORE_ASSERT(i >= 0 && i < Size, ""); return Data[i]; }
1843 inline const T& operator[](int i) const { KR_CORE_ASSERT(i >= 0 && i < Size, ""); return Data[i]; }
1844
1845 inline T* begin() { return Data; }
1846 inline const T* begin() const { return Data; }
1847 inline T* end() { return Data + Size; }
1848 inline const T* end() const { return Data + Size; }
1849 inline T& front() { KR_CORE_ASSERT(Size > 0, ""); return Data[0]; }
1850 inline const T& front() const { KR_CORE_ASSERT(Size > 0, ""); return Data[0]; }
1851 inline T& back() { KR_CORE_ASSERT(Size > 0, ""); return Data[Size - 1]; }
1852 inline const T& back() const { KR_CORE_ASSERT(Size > 0, ""); return Data[Size - 1]; }
1853 inline void swap(KGVector<T>& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
1854
1855 inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity / 2) : 8; return new_capacity > sz ? new_capacity : sz; }
1856 inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
1857 inline void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; }
1858 inline void shrink(int new_size) { KR_CORE_ASSERT(new_size <= Size, ""); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation
1859 inline void reserve(int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)KG_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); KG_FREE(Data); } Data = new_data; Capacity = new_capacity; }
1860 inline void reserve_discard(int new_capacity) { if (new_capacity <= Capacity) return; if (Data) KG_FREE(Data); Data = (T*)KG_ALLOC((size_t)new_capacity * sizeof(T)); Capacity = new_capacity; }
1861
1862 // NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the KGVector data itself! e.g. v.push_back(v[10]) is forbidden.
1863 inline void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; }
1864 inline void pop_back() { KR_CORE_ASSERT(Size > 0, ""); Size--; }
1865 inline void push_front(const T& v) { if (Size == 0) push_back(v); else insert(Data, v); }
1866 inline T* erase(const T* it) { KR_CORE_ASSERT(it >= Data && it < Data + Size, ""); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(T)); Size--; return Data + off; }
1867 inline T* erase(const T* it, const T* it_last){ KR_CORE_ASSERT(it >= Data && it < Data + Size && it_last >= it && it_last <= Data + Size, ""); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - (size_t)count) * sizeof(T)); Size -= (int)count; return Data + off; }
1868 inline T* erase_unsorted(const T* it) { KR_CORE_ASSERT(it >= Data && it < Data + Size, ""); const ptrdiff_t off = it - Data; if (it < Data + Size - 1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; }
1869 inline T* insert(const T* it, const T& v) { KR_CORE_ASSERT(it >= Data && it <= Data + Size, ""); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; }
1870 inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; }
1871 inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
1872 inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; }
1873 inline bool find_erase(const T& v) { const T* it = find(v); if (it < Data + Size) { erase(it); return true; } return false; }
1874 inline bool find_erase_unsorted(const T& v) { const T* it = find(v); if (it < Data + Size) { erase_unsorted(it); return true; } return false; }
1875 inline int index_from_ptr(const T* it) const { KR_CORE_ASSERT(it >= Data && it < Data + Size, ""); const ptrdiff_t off = it - Data; return (int)off; }
1876};
1877
1878//-----------------------------------------------------------------------------
1879// [SECTION] KarmaGuiStyle
1880//-----------------------------------------------------------------------------
1881// You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame().
1882// During the frame, use ImGui::PushStyleVar(KGGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values,
1883// and ImGui::PushStyleColor(KGGuiCol_XXX)/PopStyleColor() for colors.
1884//-----------------------------------------------------------------------------
1885
1886struct KarmaGuiStyle
1887{
1888 float Alpha; // Global alpha applies to everything in Dear ImGui.
1889 float DisabledAlpha; // Additional alpha multiplier applied by BeginDisabled(). Multiply over current value of Alpha.
1890 KGVec2 WindowPadding; // Padding within a window.
1891 float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended.
1892 float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
1893 KGVec2 WindowMinSize; // Minimum window size. This is a global setting. If you want to constrain individual windows, use SetNextWindowSizeConstraints().
1894 KGVec2 WindowTitleAlign; // Alignment for title bar text. Defaults to (0.0f,0.5f) for left-aligned,vertically centered.
1895 KarmaGuiDir WindowMenuButtonPosition; // Side of the collapsing/docking button in the title bar (None/Left/Right). Defaults to KGGuiDir_Left.
1896 float ChildRounding; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows.
1897 float ChildBorderSize; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
1898 float PopupRounding; // Radius of popup window corners rounding. (Note that tooltip windows use WindowRounding)
1899 float PopupBorderSize; // Thickness of border around popup/tooltip windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
1900 KGVec2 FramePadding; // Padding within a framed rectangle (used by most widgets).
1901 float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
1902 float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
1903 KGVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines.
1904 KGVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
1905 KGVec2 CellPadding; // Padding within a table cell
1906 KGVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
1907 float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2).
1908 float ColumnsMinSpacing; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1).
1909 float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar.
1910 float ScrollbarRounding; // Radius of grab corners for scrollbar.
1911 float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar.
1912 float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
1913 float LogSliderDeadzone; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero.
1914 float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
1915 float TabBorderSize; // Thickness of border around tabs.
1916 float TabMinWidthForCloseButton; // Minimum width for close button to appear on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
1917 KarmaGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to KGGuiDir_Right.
1918 KGVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
1919 KGVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
1920 KGVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
1921 KGVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
1922 float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
1923 bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to KGDrawList).
1924 bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to KGDrawList).
1925 bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to KGDrawList).
1926 float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
1927 float CircleTessellationMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
1928 KGVec4 Colors[KGGuiCol_COUNT];
1929
1930 KarmaGuiStyle();
1931 void ScaleAllSizes(float scale_factor);
1932};
1933
1934//-----------------------------------------------------------------------------
1935// [SECTION] KarmaGuiIO
1936//-----------------------------------------------------------------------------
1937// Communicate most settings and inputs/outputs to Dear ImGui using this structure.
1938// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage.
1939//-----------------------------------------------------------------------------
1940
1941// [Internal] Storage used by IsKeyDown(), IsKeyPressed() etc functions.
1942// If prior to 1.87 you used io.KeysDownDuration[] (which was marked as internal), you should use GetKeyData(key)->DownDuration and *NOT* io.KeysData[key]->DownDuration.
1944{
1945 bool Down; // True for if key is down
1946 float DownDuration; // Duration the key has been down (<0.0f: not pressed, 0.0f: just pressed, >0.0f: time held)
1947 float DownDurationPrev; // Last frame duration the key has been down
1948 float AnalogValue; // 0.0f..1.0f for gamepad values
1949};
1950
1951struct KARMA_API KarmaGuiIO
1952{
1953 //------------------------------------------------------------------
1954 // Configuration // Default value
1955 //------------------------------------------------------------------
1956
1957 KarmaGuiConfigFlags ConfigFlags; // = 0 // See KGGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc.
1958 KarmaGuiBackendFlags BackendFlags; // = 0 // See KGGuiBackendFlags_ enum. Set by backend (imgui_impl_xxx files or custom backend) to communicate features supported by the backend.
1959 KGVec2 DisplaySize; // <unset> // Main display size, in pixels (generally == GetMainViewport()->Size). May change every frame.
1960 float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds. May change every frame.
1961 float IniSavingRate; // = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds.
1962 const char* IniFilename; // = "kggui.ini" // Path to .ini file (important: default "kggui.ini" is relative to current working dir!). Set NULL to disable automatic .ini loading/saving or if you want to manually call LoadIniSettingsXXX() / SaveIniSettingsXXX() functions.
1963 const char* LogFilename; // = "imgui_log.txt"// Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
1964 float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
1965 float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
1966 float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging.
1967 float KeyRepeatDelay; // = 0.275f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
1968 float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
1969 float HoverDelayNormal; // = 0.30 sec // Delay on hovering before IsItemHovered(KGGuiHoveredFlags_DelayNormal) returns true.
1970 float HoverDelayShort; // = 0.10 sec // Delay on hovering before IsItemHovered(KGGuiHoveredFlags_DelayShort) returns true.
1971 void* UserData; // = NULL // Store your own data.
1972
1973 KGFontAtlas*Fonts; // <auto> // Font atlas: load, rasterize and pack one or more fonts into a single texture.
1974 float FontGlobalScale; // = 1.0f // Global scale all fonts
1975 bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
1976 KGFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
1977 KGVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in KGDrawData::FramebufferScale.
1978
1979 // Docking options (when KGGuiConfigFlags_DockingEnable is set)
1980 bool ConfigDockingNoSplit; // = false // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
1981 bool ConfigDockingWithShift; // = false // Enable docking with holding Shift key (reduce visual noise, allows dropping in wider space)
1982 bool ConfigDockingAlwaysTabBar; // = false // [BETA] [FIXME: This currently creates regression with auto-sizing and general overhead] Make every single floating window display within a docking node.
1983 bool ConfigDockingTransparentPayload;// = false // [BETA] Make window or viewport transparent when docking and only display docking boxes on the target viewport. Useful if rendering of multiple viewport cannot be synced. Best used with ConfigViewportsNoAutoMerge.
1984
1985 // Viewport options (when KGGuiConfigFlags_ViewportsEnable is set)
1986 bool ConfigViewportsNoAutoMerge; // = false; // Set to make all floating imgui windows always create their own viewport. Otherwise, they are merged into the main host viewports when overlapping it. May also set KGGuiViewportFlags_NoAutoMerge on individual viewport.
1987 bool ConfigViewportsNoTaskBarIcon; // = false // Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, KGGuiViewportFlags_NoTaskBarIcon will be set on it.
1988 bool ConfigViewportsNoDecoration; // = true // Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations, KGGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size).
1989 bool ConfigViewportsNoDefaultParent; // = false // Disable default OS parenting to main viewport for secondary viewports. By default, viewports are marked with ParentViewportId = <main_viewport>, expecting the platform backend to setup a parent/child relationship between the OS windows (some backend may ignore this). Set to true if you want the default to be 0, then all viewports will be top-level OS windows.
1990
1991 // Miscellaneous options
1992 bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
1993 bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
1994 bool ConfigInputTrickleEventQueue; // = true // Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.
1995 bool ConfigInputTextCursorBlink; // = true // Enable blinking cursor (optional as some users consider it to be distracting).
1996 bool ConfigInputTextEnterKeepActive; // = false // [BETA] Pressing Enter will keep item active and select contents (single-line only).
1997 bool ConfigDragClickToInputText; // = false // [BETA] Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving). Not desirable on devices without a keyboard.
1998 bool ConfigWindowsResizeFromEdges; // = true // Enable resizing of windows from their edges and from the lower-left corner. This requires (io.BackendFlags & KGGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. (This used to be a per-window KGGuiWindowFlags_ResizeFromAnySide flag)
1999 bool ConfigWindowsMoveFromTitleBarOnly; // = false // Enable allowing to move windows only when clicking on their title bar. Does not apply to windows without a title bar.
2000 float ConfigMemoryCompactTimer; // = 60.0f // Timer (in seconds) to free transient windows/tables memory buffers when unused. Set to -1.0f to disable.
2001
2002 //------------------------------------------------------------------
2003 // Platform Functions
2004 // (the imgui_impl_xxxx backend files are setting those up for you)
2005 //------------------------------------------------------------------
2006
2007 // Optional: Platform/Renderer backend name (informational only! will be displayed in About Window) + User data for backend/wrappers to store their own stuff.
2008 const char* BackendPlatformName; // = NULL
2009 const char* BackendRendererName; // = NULL
2010 void* BackendPlatformUserData; // = NULL // User data for platform backend
2011 void* BackendRendererUserData; // = NULL // User data for renderer backend
2012 void* BackendLanguageUserData; // = NULL // User data for non C++ programming language backend
2013
2014 // Optional: Access OS clipboard
2015 // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
2016 const char* (*GetClipboardTextFn)(void* user_data);
2017 void (*SetClipboardTextFn)(void* user_data, const char* text);
2018 void* ClipboardUserData;
2019
2020 // Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows)
2021 // (default to use native imm32 api on Windows)
2022 void (*SetPlatformImeDataFn)(KarmaGuiViewport* viewport, KarmaGuiPlatformImeData* data);
2023#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
2024 void* ImeWindowHandle; // = NULL // [Obsolete] Set KarmaGuiViewport::PlatformHandleRaw instead. Set this to your HWND to get automatic IME cursor positioning.
2025#else
2026 void* _UnusedPadding; // Unused field to keep data structure the same size.
2027#endif
2028
2029 //------------------------------------------------------------------
2030 // Input - Call before calling NewFrame()
2031 //------------------------------------------------------------------
2032
2033 // Input Functions
2034 void AddKeyEvent(KarmaGuiKey key, bool down); // Queue a new key down/up event. Key should be "translated" (as in, generally KGGuiKey_A matches the key end-user would use to emit an 'A' character)
2035 void AddKeyAnalogEvent(KarmaGuiKey key, bool down, float v); // Queue a new key down/up event for analog values (e.g. KGGuiKey_Gamepad_ values). Dead-zones should be handled by the backend.
2036 void AddMousePosEvent(float x, float y); // Queue a mouse position update. Use -FLT_MAX,-FLT_MAX to signify no mouse (e.g. app not focused and not hovered)
2037 void AddMouseButtonEvent(int button, bool down); // Queue a mouse button change
2038 void AddMouseWheelEvent(float wh_x, float wh_y); // Queue a mouse wheel update
2039 void AddMouseViewportEvent(KGGuiID id); // Queue a mouse hovered viewport. Requires backend to set KGGuiBackendFlags_HasMouseHoveredViewport to call this (for multi-viewport support).
2040 void AddFocusEvent(bool focused); // Queue a gain/loss of focus for the application (generally based on OS/platform focus of your window)
2041 void AddInputCharacter(unsigned int c); // Queue a new character input
2042 void AddInputCharacterUTF16(KGWchar16 c); // Queue a new character input from a UTF-16 character, it can be a surrogate
2043 void AddInputCharactersUTF8(const char* str); // Queue a new characters input from a UTF-8 string
2044
2045 void SetKeyEventNativeData(KarmaGuiKey key, int native_keycode, int native_scancode, int native_legacy_index = -1); // [Optional] Specify index for legacy <1.87 IsKeyXXX() functions with native indices + specify native keycode, scancode.
2046 void SetAppAcceptingEvents(bool accepting_events); // Set master flag for accepting key/mouse/text events (default to true). Useful if you have native dialog boxes that are interrupting your application loop/refresh, and you want to disable events being queued while your app is frozen.
2047 void ClearInputCharacters(); // [Internal] Clear the text input buffer manually
2048 void ClearInputKeys(); // [Internal] Release all keys
2049
2050 //------------------------------------------------------------------
2051 // Output - Updated by NewFrame() or EndFrame()/Render()
2052 // (when reading from the io.WantCaptureMouse, io.WantCaptureKeyboard flags to dispatch your inputs, it is
2053 // generally easier and more correct to use their state BEFORE calling NewFrame(). See FAQ for details!)
2054 //------------------------------------------------------------------
2055
2056 bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
2057 bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
2058 bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
2059 bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when KGGuiConfigFlags_NavEnableSetMousePos flag is enabled.
2060 bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving!
2061 bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle KGGuiKey_NavXXX events) = a window is focused and it doesn't use the KGGuiWindowFlags_NoNavInputs flag.
2062 bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle KGGuiKey_NavXXX events).
2063 float Framerate; // Estimate of application framerate (rolling average over 60 frames, based on io.DeltaTime), in frame per second. Solely for convenience. Slow applications may not want to use a moving average or may want to reset underlying buffers occasionally.
2064 int MetricsRenderVertices; // Vertices output during last call to Render()
2065 int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
2066 int MetricsRenderWindows; // Number of visible windows
2067 int MetricsActiveWindows; // Number of active windows
2068 int MetricsActiveAllocations; // Number of active allocations, updated by MemAlloc/MemFree based on current context. May be off if you have multiple imgui contexts.
2069 KGVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta.
2070
2071 // Legacy: before 1.87, we required backend to fill io.KeyMap[] (imgui->native map) during initialization and io.KeysDown[] (native indices) every frame.
2072 // This is still temporarily supported as a legacy feature. However the new preferred scheme is for backend to call io.AddKeyEvent().
2073 // Old (<1.87): ImGui::IsKeyPressed(ImGui::GetIO().KeyMap[KGGuiKey_Space]) --> New (1.87+) ImGui::IsKeyPressed(KGGuiKey_Space)
2074#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
2075 int KeyMap[KGGuiKey_COUNT]; // [LEGACY] Input: map of indices into the KeysDown[512] entries array which represent your "native" keyboard state. The first 512 are now unused and should be kept zero. Legacy backend will write into KeyMap[] using KGGuiKey_ indices which are always >512.
2076 bool KeysDown[KGGuiKey_COUNT]; // [LEGACY] Input: Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys). This used to be [512] sized. It is now KGGuiKey_COUNT to allow legacy io.KeysDown[GetKeyIndex(...)] to work without an overflow.
2077 float NavInputs[KGGuiNavInput_COUNT]; // [LEGACY] Since 1.88, NavInputs[] was removed. Backends from 1.60 to 1.86 won't build. Feed gamepad inputs via io.AddKeyEvent() and KGGuiKey_GamepadXXX enums.
2078#endif
2079
2080 //------------------------------------------------------------------
2081 // [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed!
2082 //------------------------------------------------------------------
2083
2084 // Main Input State
2085 // (this block used to be written by backend, since 1.87 it is best to NOT write to those directly, call the AddXXX functions above instead)
2086 // (reading from those variables is fair game, as they are extremely unlikely to be moving anywhere)
2087 KGVec2 MousePos; // Mouse position, in pixels. Set to KGVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.)
2088 bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras (KGGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons. Other buttons allow us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
2089 float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text.
2090 float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with a horizontal wheel, may not be filled by all backends.
2091 KGGuiID MouseHoveredViewport; // (Optional) Modify using io.AddMouseViewportEvent(). With multi-viewports: viewport the OS mouse is hovering. If possible _IGNORING_ viewports with the KGGuiViewportFlags_NoInputs flag is much better (few backends can handle that). Set io.BackendFlags |= KGGuiBackendFlags_HasMouseHoveredViewport if you can provide this info. If you don't imgui will infer the value using the rectangles and last focused time of the viewports it knows about (ignoring other OS windows).
2092 bool KeyCtrl; // Keyboard modifier down: Control
2093 bool KeyShift; // Keyboard modifier down: Shift
2094 bool KeyAlt; // Keyboard modifier down: Alt
2095 bool KeySuper; // Keyboard modifier down: Cmd/Super/Windows
2096
2097 // Other state maintained from data above + IO function calls
2098 KarmaGuiKeyChord KeyMods; // Key mods flags (any of KGGuiMod_Ctrl/KGGuiMod_Shift/KGGuiMod_Alt/KGGuiMod_Super flags, same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags. DOES NOT CONTAINS KGGuiMod_Shortcut which is pretranslated). Read-only, updated by NewFrame()
2099 KarmaGuiKeyData KeysData[KGGuiKey_KeysData_SIZE]; // Key state for all known keys. Use IsKeyXXX() functions to access this.
2100 bool WantCaptureMouseUnlessPopupClose; // Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
2101 KGVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
2102 KGVec2 MouseClickedPos[5]; // Position at time of clicking
2103 double MouseClickedTime[5]; // Time of last click (used to figure out double-click)
2104 bool MouseClicked[5]; // Mouse button went from !Down to Down (same as MouseClickedCount[x] != 0)
2105 bool MouseDoubleClicked[5]; // Has mouse button been double-clicked? (same as MouseClickedCount[x] == 2)
2106 KGU16 MouseClickedCount[5]; // == 0 (not clicked), == 1 (same as MouseClicked[]), == 2 (double-clicked), == 3 (triple-clicked) etc. when going from !Down to Down
2107 KGU16 MouseClickedLastCount[5]; // Count successive number of clicks. Stays valid after mouse release. Reset after another click is done.
2108 bool MouseReleased[5]; // Mouse button went from Down to !Down
2109 bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window or over void blocked by a popup. We don't request mouse capture from the application if click started outside ImGui bounds.
2110 bool MouseDownOwnedUnlessPopupClose[5]; // Track if button was clicked inside a dear imgui window.
2111 float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
2112 float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
2113 KGVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point
2114 float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds)
2115 float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui.
2116 bool AppFocusLost; // Only modify via AddFocusEvent()
2117 bool AppAcceptingEvents; // Only modify via SetAppAcceptingEvents()
2118 KGS8 BackendUsingLegacyKeyArrays; // -1: unknown, 0: using AddKeyEvent(), 1: using legacy io.KeysDown[]
2119 bool BackendUsingLegacyNavInputArray; // 0: using AddKeyAnalogEvent(), 1: writing to legacy io.NavInputs[] directly
2120 KGWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16()
2121 KGVector<KGWchar> InputQueueCharacters; // Queue of _characters_ input (obtained by platform backend). Fill using AddInputCharacter() helper.
2122
2123 KarmaGuiIO();
2124};
2125
2126//-----------------------------------------------------------------------------
2127// [SECTION] Misc data structures
2128//-----------------------------------------------------------------------------
2129
2130// Shared state of InputText(), passed as an argument to your callback when a KGGuiInputTextFlags_Callback* flag is used.
2131// The callback function should return 0 by default.
2132// Callbacks (follow a flag name and see comments in KGGuiInputTextFlags_ declarations for more details)
2133// - KGGuiInputTextFlags_CallbackEdit: Callback on buffer edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
2134// - KGGuiInputTextFlags_CallbackAlways: Callback on each iteration
2135// - KGGuiInputTextFlags_CallbackCompletion: Callback on pressing TAB
2136// - KGGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows
2137// - KGGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
2138// - KGGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow.
2139struct KARMA_API KarmaGuiInputTextCallbackData
2140{
2141 KarmaGuiInputTextFlags EventFlag; // One KGGuiInputTextFlags_Callback* // Read-only
2142 KarmaGuiInputTextFlags Flags; // What user passed to InputText() // Read-only
2143 void* UserData; // What user passed to InputText() // Read-only
2144
2145 // Arguments for the different callback events
2146 // - To modify the text buffer in a callback, prefer using the InsertChars() / DeleteChars() function. InsertChars() will take care of calling the resize callback if necessary.
2147 // - If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so InputText can update its internal state.
2148 KGWchar EventChar; // Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0;
2149 KarmaGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only // [Completion,History]
2150 char* Buf; // Text buffer // Read-write // [Resize] Can replace pointer / [Completion,History,Always] Only write to pointed data, don't replace the actual pointer!
2151 int BufTextLen; // Text length (in bytes) // Read-write // [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length()
2152 int BufSize; // Buffer size (in bytes) = capacity+1 // Read-only // [Resize,Completion,History,Always] Include zero-terminator storage. In C land == ARRAYSIZE(my_char_array), in C++ land: string.capacity()+1
2153 bool BufDirty; // Set if you modify Buf/BufTextLen! // Write // [Completion,History,Always]
2154 int CursorPos; // // Read-write // [Completion,History,Always]
2155 int SelectionStart; // // Read-write // [Completion,History,Always] == to SelectionEnd when no selection)
2156 int SelectionEnd; // // Read-write // [Completion,History,Always]
2157
2158 // Helper functions for text manipulation.
2159 // Use those function to benefit from the CallbackResize behaviors. Calling those function reset the selection.
2160 KarmaGuiInputTextCallbackData();
2161 void DeleteChars(int pos, int bytes_count);
2162 void InsertChars(int pos, const char* text, const char* text_end = NULL);
2163 void SelectAll() { SelectionStart = 0; SelectionEnd = BufTextLen; }
2164 void ClearSelection() { SelectionStart = SelectionEnd = BufTextLen; }
2165 bool HasSelection() const { return SelectionStart != SelectionEnd; }
2166};
2167
2168// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin().
2169// NB: For basic min/max size constraint on each axis you don't need to use the callback! The SetNextWindowSizeConstraints() parameters are enough.
2171{
2172 void* UserData; // Read-only. What user passed to SetNextWindowSizeConstraints(). Generally store an integer or float in here (need reinterpret_cast<>).
2173 KGVec2 Pos; // Read-only. Window position, for reference.
2174 KGVec2 CurrentSize; // Read-only. Current window size.
2175 KGVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing.
2176};
2177
2178// [ALPHA] Rarely used / very advanced uses only. Use with SetNextWindowClass() and DockSpace() functions.
2179// Important: the content of this class is still highly WIP and likely to change and be refactored
2180// before we stabilize Docking features. Please be mindful if using this.
2181// Provide hints:
2182// - To the platform backend via altered viewport flags (enable/disable OS decoration, OS task bar icons, etc.)
2183// - To the platform backend for OS level parent/child relationships of viewport.
2184// - To the docking system for various options and filtering.
2185struct KARMA_API KarmaGuiWindowClass
2186{
2187 KGGuiID ClassId; // User data. 0 = Default class (unclassed). Windows of different classes cannot be docked with each others.
2188 KGGuiID ParentViewportId; // Hint for the platform backend. -1: use default. 0: request platform backend to not parent the platform. != 0: request platform backend to create a parent<>child relationship between the platform windows. Not conforming backends are free to e.g. parent every viewport to the main viewport or not.
2189 KarmaGuiViewportFlags ViewportFlagsOverrideSet; // Viewport flags to set when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
2190 KarmaGuiViewportFlags ViewportFlagsOverrideClear; // Viewport flags to clear when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
2191 KarmaGuiTabItemFlags TabItemFlagsOverrideSet; // [EXPERIMENTAL] TabItem flags to set when a window of this class gets submitted into a dock node tab bar. May use with KGGuiTabItemFlags_Leading or KGGuiTabItemFlags_Trailing.
2192 KarmaGuiDockNodeFlags DockNodeFlagsOverrideSet; // [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
2193 bool DockingAlwaysTabBar; // Set to true to enforce single floating windows of this class always having their own docking node (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
2194 bool DockingAllowUnclassed; // Set to true to allow windows of this class to be docked/merged with an unclassed window. // FIXME-DOCK: Move to DockNodeFlags override?
2195
2196 KarmaGuiWindowClass() { memset(this, 0, sizeof(*this)); ParentViewportId = (KGGuiID)-1; DockingAllowUnclassed = true; }
2197};
2198
2199// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload()
2200struct KARMA_API KarmaGuiPayload
2201{
2202 // Members
2203 void* Data; // Data (copied and owned by dear imgui)
2204 int DataSize; // Data size
2205
2206 // [Internal]
2207 KGGuiID SourceId; // Source item id
2208 KGGuiID SourceParentId; // Source parent id (if available)
2209 int DataFrameCount; // Data timestamp
2210 char DataType[32 + 1]; // Data type tag (short user-supplied string, 32 characters max)
2211 bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets)
2212 bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item.
2213
2214 KarmaGuiPayload() { Clear(); }
2215 void Clear() { SourceId = SourceParentId = 0; Data = NULL; DataSize = 0; memset(DataType, 0, sizeof(DataType)); DataFrameCount = -1; Preview = Delivery = false; }
2216 bool IsDataType(const char* type) const { return DataFrameCount != -1 && strcmp(type, DataType) == 0; }
2217 bool IsPreview() const { return Preview; }
2218 bool IsDelivery() const { return Delivery; }
2219};
2220
2221// Sorting specification for one column of a table (sizeof == 12 bytes)
2222struct KARMA_API KarmaGuiTableColumnSortSpecs
2223{
2224 KGGuiID ColumnUserID; // User id of the column (if specified by a TableSetupColumn() call)
2225 KGS16 ColumnIndex; // Index of the column
2226 KGS16 SortOrder; // Index within parent KarmaGuiTableSortSpecs (always stored in order starting from 0, tables sorted on a single criteria will always have a 0 here)
2227 KarmaGuiSortDirection SortDirection : 8; // KGGuiSortDirection_Ascending or KGGuiSortDirection_Descending (you can use this or SortSign, whichever is more convenient for your sort function)
2228
2229 KarmaGuiTableColumnSortSpecs() { memset(this, 0, sizeof(*this)); }
2230};
2231
2232// Sorting specifications for a table (often handling sort specs for a single column, occasionally more)
2233// Obtained by calling TableGetSortSpecs().
2234// When 'SpecsDirty == true' you can sort your data. It will be true with sorting specs have changed since last call, or the first time.
2235// Make sure to set 'SpecsDirty = false' after sorting, else you may wastefully sort your data every frame!
2236struct KARMA_API KarmaGuiTableSortSpecs
2237{
2238 const KarmaGuiTableColumnSortSpecs* Specs; // Pointer to sort spec array.
2239 int SpecsCount; // Sort spec count. Most often 1. May be > 1 when KGGuiTableFlags_SortMulti is enabled. May be == 0 when KGGuiTableFlags_SortTristate is enabled.
2240 bool SpecsDirty; // Set to true when specs have changed since last time! Use this to sort again, then clear the flag.
2241
2242 KarmaGuiTableSortSpecs() { memset(this, 0, sizeof(*this)); }
2243};
2244
2245//-----------------------------------------------------------------------------
2246// [SECTION] Helpers (KarmaGuiOnceUponAFrame, KarmaGuiTextFilter, KarmaGuiTextBuffer, KarmaGuiStorage, KarmaGuiListClipper, KGColor)
2247//-----------------------------------------------------------------------------
2248
2249// Helper: Unicode defines
2250#define KG_UNICODE_CODEPOINT_INVALID 0xFFFD // Invalid Unicode code point (standard value).
2251#define KG_UNICODE_CODEPOINT_MAX 0xFFFF // Maximum Unicode code point supported by this build.
2252
2253
2254// Helper: Execute a block of code at maximum once a frame. Convenient if you want to quickly create a UI within deep-nested code that runs multiple times every frame.
2255// Usage: static KarmaGuiOnceUponAFrame oaf; if (oaf) ImGui::Text("This will be called only once per frame");
2256struct KARMA_API KarmaGuiOnceUponAFrame
2257{
2258 KarmaGuiOnceUponAFrame() { RefFrame = -1; }
2259 mutable int RefFrame;
2260 operator bool() const { int current_frame = Karma::KarmaGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; }
2261};
2262
2263// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
2264struct KARMA_API KarmaGuiTextFilter
2265{
2266 KarmaGuiTextFilter(const char* default_filter = "");
2267 bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
2268 bool PassFilter(const char* text, const char* text_end = NULL) const;
2269 void Build();
2270 void Clear() { InputBuf[0] = 0; Build(); }
2271 bool IsActive() const { return !Filters.empty(); }
2272
2273 // [Internal]
2274 struct KARMA_API ImGuiTextRange
2275 {
2276 const char* b;
2277 const char* e;
2278
2279 ImGuiTextRange() { b = e = NULL; }
2280 ImGuiTextRange(const char* _b, const char* _e) { b = _b; e = _e; }
2281 bool empty() const { return b == e; }
2282 void split(char separator, KGVector<ImGuiTextRange>* out) const;
2283 };
2284 char InputBuf[256];
2286 int CountGrep;
2287};
2288
2289// Helper: Growable text buffer for logging/accumulating text
2290// (this could be called 'ImGuiTextBuilder' / 'ImGuiStringBuilder')
2291struct KARMA_API KarmaGuiTextBuffer
2292{
2293 KGVector<char> Buf;
2294 static char EmptyString[1];
2295
2296 KarmaGuiTextBuffer() { }
2297 inline char operator[](int i) const { KR_CORE_ASSERT(Buf.Data != NULL, ""); return Buf.Data[i]; }
2298 const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; }
2299 const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator
2300 int size() const { return Buf.Size ? Buf.Size - 1 : 0; }
2301 bool empty() const { return Buf.Size <= 1; }
2302 void clear() { Buf.clear(); }
2303 void reserve(int capacity) { Buf.reserve(capacity); }
2304 const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; }
2305 void append(const char* str, const char* str_end = NULL);
2306 void appendf(const char* fmt, ...) KG_FMTARGS(2);
2307 void appendfv(const char* fmt, va_list args) KG_FMTLIST(2);
2308};
2309
2310// Helper: Key->Value storage
2311// Typically you don't have to worry about this since a storage is held within each Window.
2312// We use it to e.g. store collapse state for a tree (Int 0/1)
2313// This is optimized for efficient lookup (dichotomy into a contiguous buffer) and rare insertion (typically tied to user interactions aka max once a frame)
2314// You can use it as custom user storage for temporary values. Declare your own storage if, for example:
2315// - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state).
2316// - You want to store custom debug data easily without adding or editing structures in your code (probably not efficient, but convenient)
2317// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types.
2319{
2320 // [Internal]
2321 struct ImGuiStoragePair
2322 {
2323 KGGuiID key;
2324 union { int val_i; float val_f; void* val_p; };
2325 ImGuiStoragePair(KGGuiID _key, int _val_i) { key = _key; val_i = _val_i; }
2326 ImGuiStoragePair(KGGuiID _key, float _val_f) { key = _key; val_f = _val_f; }
2327 ImGuiStoragePair(KGGuiID _key, void* _val_p) { key = _key; val_p = _val_p; }
2328 };
2329
2331
2332 // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
2333 // - Set***() functions find pair, insertion on demand if missing.
2334 // - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair.
2335 void Clear() { Data.clear(); }
2336 int GetInt(KGGuiID key, int default_val = 0) const;
2337 void SetInt(KGGuiID key, int val);
2338 bool GetBool(KGGuiID key, bool default_val = false) const;
2339 void SetBool(KGGuiID key, bool val);
2340 float GetFloat(KGGuiID key, float default_val = 0.0f) const;
2341 void SetFloat(KGGuiID key, float val);
2342 void* GetVoidPtr(KGGuiID key) const; // default_val is NULL
2343 void SetVoidPtr(KGGuiID key, void* val);
2344
2345 // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set.
2346 // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
2347 // - A typical use case where this is convenient for quick hacking (e.g. add storage during a live Edit&Continue session if you can't modify existing struct)
2348 // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
2349 int* GetIntRef(KGGuiID key, int default_val = 0);
2350 bool* GetBoolRef(KGGuiID key, bool default_val = false);
2351 float* GetFloatRef(KGGuiID key, float default_val = 0.0f);
2352 void** GetVoidPtrRef(KGGuiID key, void* default_val = NULL);
2353
2354 // Use on your own storage if you know only integer are being stored (open/close all tree nodes)
2355 void SetAllInt(int val);
2356
2357 // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
2358 void BuildSortByKey();
2359};
2360
2361// Helper: Manually clip large list of items.
2362// If you have lots evenly spaced items and you have random access to the list, you can perform coarse
2363// clipping based on visibility to only submit items that are in view.
2364// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped.
2365// (Dear ImGui already clip items based on their bounds but: it needs to first layout the item to do so, and generally
2366// fetching/submitting your own data incurs additional cost. Coarse clipping using KarmaGuiListClipper allows you to easily
2367// scale using lists with tens of thousands of items without a problem)
2368// Usage:
2369// KarmaGuiListClipper clipper;
2370// clipper.Begin(1000); // We have 1000 elements, evenly spaced.
2371// while (clipper.Step())
2372// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
2373// ImGui::Text("line number %d", i);
2374// Generally what happens is:
2375// - Clipper lets you process the first element (DisplayStart = 0, DisplayEnd = 1) regardless of it being visible or not.
2376// - User code submit that one element.
2377// - Clipper can measure the height of the first element
2378// - Clipper calculate the actual range of elements to display based on the current clipping rectangle, position the cursor before the first visible element.
2379// - User code submit visible elements.
2380// - The clipper also handles various subtleties related to keyboard/gamepad navigation, wrapping etc.
2381struct KARMA_API KarmaGuiListClipper
2382{
2383 int DisplayStart; // First item to display, updated by each call to Step()
2384 int DisplayEnd; // End of items to display (exclusive)
2385 int ItemsCount; // [Internal] Number of items
2386 float ItemsHeight; // [Internal] Height of item after a first step and item submission can calculate it
2387 float StartPosY; // [Internal] Cursor position at the time of Begin() or after table frozen rows are all processed
2388 void* TempData; // [Internal] Internal data
2389
2390 // items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step)
2391 // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
2392 KarmaGuiListClipper();
2393 ~KarmaGuiListClipper();
2394 void Begin(int items_count, float items_height = -1.0f);
2395 void End(); // Automatically called on the last call of Step() that returns false.
2396 bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
2397
2398 // Call ForceDisplayRangeByIndices() before first call to Step() if you need a range of items to be displayed regardless of visibility.
2399 void ForceDisplayRangeByIndices(int item_min, int item_max); // item_max is exclusive e.g. use (42, 42+1) to make item 42 always visible BUT due to alignment/padding of certain items it is likely that an extra item may be included on either end of the display range.
2400 inline KarmaGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79]
2401};
2402
2403// Helpers macros to generate 32-bit encoded colors
2404// User can declare their own format by #defining the 5 _SHIFT/_MASK macros in their imconfig file.
2405#ifndef KG_COL32_R_SHIFT
2406#define KG_COL32_R_SHIFT 0
2407#define KG_COL32_G_SHIFT 8
2408#define KG_COL32_B_SHIFT 16
2409#define KG_COL32_A_SHIFT 24
2410#define KG_COL32_A_MASK 0xFF000000
2411#endif
2412#define KG_COL32(R,G,B,A) (((KGU32)(A)<<KG_COL32_A_SHIFT) | ((KGU32)(B)<<KG_COL32_B_SHIFT) | ((KGU32)(G)<<KG_COL32_G_SHIFT) | ((KGU32)(R)<<KG_COL32_R_SHIFT))
2413#define KG_COL32_WHITE KG_COL32(255,255,255,255) // Opaque white = 0xFFFFFFFF
2414#define KG_COL32_BLACK KG_COL32(0,0,0,255) // Opaque black
2415#define KG_COL32_BLACK_TRANS KG_COL32(0,0,0,0) // Transparent black = 0x00000000
2416
2417// Helper: KGColor() implicitly converts colors to either KGU32 (packed 4x1 byte) or KGVec4 (4x1 float)
2418// Prefer using KG_COL32() macros if you want a guaranteed compile-time KGU32 for usage with KGDrawList API.
2419// **Avoid storing KGColor! Store either u32 of KGVec4. This is not a full-featured color class. MAY OBSOLETE.
2420// **None of the ImGui API are using KGColor directly but you can use it as a convenience to pass colors in either KGU32 or KGVec4 formats. Explicitly cast to KGU32 or KGVec4 if needed.
2421struct KARMA_API KGColor
2422{
2423 KGVec4 Value;
2424
2425 constexpr KGColor() { }
2426 constexpr KGColor(float r, float g, float b, float a = 1.0f) : Value(r, g, b, a) { }
2427 constexpr KGColor(const KGVec4& col) : Value(col) {}
2428 KGColor(int r, int g, int b, int a = 255) { float sc = 1.0f / 255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
2429 KGColor(KGU32 rgba) { float sc = 1.0f / 255.0f; Value.x = (float)((rgba >> KG_COL32_R_SHIFT) & 0xFF) * sc; Value.y = (float)((rgba >> KG_COL32_G_SHIFT) & 0xFF) * sc; Value.z = (float)((rgba >> KG_COL32_B_SHIFT) & 0xFF) * sc; Value.w = (float)((rgba >> KG_COL32_A_SHIFT) & 0xFF) * sc; }
2430 inline operator KGU32() const { return Karma::KarmaGui::ColorConvertFloat4ToU32(Value); }
2431 inline operator KGVec4() const { return Value; }
2432
2433 // FIXME-OBSOLETE: May need to obsolete/cleanup those helpers.
2434 inline void SetHSV(float h, float s, float v, float a = 1.0f){ Karma::KarmaGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; }
2435 KGColor HSV(float h, float s, float v, float a = 1.0f) { float r, g, b; Karma::KarmaGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return KGColor(r, g, b, a); }
2436};
2437
2438//-----------------------------------------------------------------------------
2439// [SECTION] Drawing API (KGDrawCmd, KGDrawIdx, KGDrawVert, KGDrawChannel, KGDrawListSplitter, KGDrawListFlags, KGDrawList, KGDrawData)
2440// Hold a series of drawing commands. The user provides a renderer for KGDrawData which essentially contains an array of KGDrawList.
2441//-----------------------------------------------------------------------------
2442
2443// The maximum line width to bake anti-aliased textures for. Build atlas with KGFontAtlasFlags_NoBakedLines to disable baking.
2444#ifndef KG_DRAWLIST_TEX_LINES_WIDTH_MAX
2445#define KG_DRAWLIST_TEX_LINES_WIDTH_MAX (63)
2446#endif
2447
2448// KGDrawCallback: Draw callbacks for advanced uses [configurable type: override in imconfig.h]
2449// NB: You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering,
2450// you can poke into the draw list for that! Draw callback may be useful for example to:
2451// A) Change your GPU render state,
2452// B) render a complex 3D scene inside a UI element without an intermediate texture/render target, etc. Yes
2453// The expected behavior from your rendering function is 'if (cmd.UserCallback != NULL) { cmd.UserCallback(parent_list, cmd); } else { RenderTriangles() }'
2454// If you want to override the signature of KGDrawCallback, you can simply use e.g. '#define KGDrawCallback MyDrawCallback' (in imconfig.h) + update rendering backend accordingly.
2455#ifndef KGDrawCallback
2456typedef void (*KGDrawCallback)(const KGDrawList* parent_list, const KGDrawCmd* cmd);
2457#endif
2458
2459// Special Draw callback value to request renderer backend to reset the graphics/render state.
2460// The renderer backend needs to handle this special value, otherwise it will crash trying to call a function at this address.
2461// This is useful for example if you submitted callbacks which you know have altered the render state and you want it to be restored.
2462// It is not done by default because they are many perfectly useful way of altering render state for imgui contents (e.g. changing shader/blending settings before an Image call).
2463#define KGDrawCallback_ResetRenderState (KGDrawCallback)(-1)
2464
2465// Typically, 1 command = 1 GPU draw call (unless command is a callback)
2466// - VtxOffset: When 'io.BackendFlags & KGGuiBackendFlags_RendererHasVtxOffset' is enabled,
2467// this fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices.
2468// Backends made for <1.71. will typically ignore the VtxOffset fields.
2469// - The ClipRect/TextureId/VtxOffset fields must be contiguous as we memcmp() them together (this is asserted for).
2470struct KARMA_API KGDrawCmd
2471{
2472 KGVec4 ClipRect; // 4*4 // Clipping rectangle (x1, y1, x2, y2). Subtract KGDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates
2473 KGTextureID TextureId; // 4-8 // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
2474 unsigned int VtxOffset; // 4 // Start offset in vertex buffer. KGGuiBackendFlags_RendererHasVtxOffset: always 0, otherwise may be > 0 to support meshes larger than 64K vertices with 16-bit indices.
2475 unsigned int IdxOffset; // 4 // Start offset in index buffer.
2476 unsigned int ElemCount; // 4 // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee KGDrawList's vtx_buffer[] array, indices in idx_buffer[].
2477 KGDrawCallback UserCallback; // 4-8 // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
2478 void* UserCallbackData; // 4-8 // The draw callback code can access this.
2479
2480 KGDrawCmd() { memset(this, 0, sizeof(*this)); } // Also ensure our padding fields are zeroed
2481
2482 // Since 1.83: returns KGTextureID associated with this draw call. Warning: DO NOT assume this is always same as 'TextureId' (we will change this function for an upcoming feature)
2483 inline KGTextureID GetTexID() const { return TextureId; }
2484};
2485
2486// Vertex layout
2487// try think about shaders rather for better integration with Karma
2488#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
2490{
2491 KGVec2 pos;
2492 KGVec2 uv;
2493 KGU32 col;
2494};
2495#else
2496// You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h
2497// The code expect KGVec2 pos (8 bytes), KGVec2 uv (8 bytes), KGU32 col (4 bytes), but you can re-order them or add other fields as needed to simplify integration in your engine.
2498// The type has to be described within the macro (you can either declare the struct or use a typedef). This is because KGVec2/KGU32 are likely not declared at the time you'd want to set your type up.
2499// NOTE: IMGUI DOESN'T CLEAR THE STRUCTURE AND DOESN'T CALL A CONSTRUCTOR SO ANY CUSTOM FIELD WILL BE UNINITIALIZED. IF YOU ADD EXTRA FIELDS (SUCH AS A 'Z' COORDINATES) YOU WILL NEED TO CLEAR THEM DURING RENDER OR TO IGNORE THEM.
2500IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT;
2501#endif
2502
2503// [Internal] For use by KGDrawList
2505{
2506 KGVec4 ClipRect;
2507 KGTextureID TextureId;
2508 unsigned int VtxOffset;
2509};
2510
2511// [Internal] For use by KGDrawListSplitter
2513{
2514 KGVector<KGDrawCmd> _CmdBuffer;
2515 KGVector<KGDrawIdx> _IdxBuffer;
2516};
2517
2518
2519// Split/Merge functions are used to split the draw list into different layers which can be drawn into out of order.
2520// This is used by the Columns/Tables API, so items of each column can be batched together in a same draw call.
2521struct KARMA_API KGDrawListSplitter
2522{
2523 int _Current; // Current channel number (0)
2524 int _Count; // Number of active channels (1+)
2525 KGVector<KGDrawChannel> _Channels; // Draw channels (not resized down so _Count might be < Channels.Size)
2526
2527 inline KGDrawListSplitter() { memset(this, 0, sizeof(*this)); }
2528 inline ~KGDrawListSplitter() { ClearFreeMemory(); }
2529 inline void Clear() { _Current = 0; _Count = 1; } // Do not clear Channels[] so our allocations are reused next frame
2530 void ClearFreeMemory();
2531 void Split(KGDrawList* draw_list, int count);
2532 void Merge(KGDrawList* draw_list);
2533 void SetCurrentChannel(KGDrawList* draw_list, int channel_idx);
2534};
2535
2536// Flags for KGDrawList functions
2537// (Legacy: bit 0 must always correspond to KGDrawFlags_Closed to be backward compatible with old API using a bool. Bits 1..3 must be unused)
2538enum KGDrawFlags_
2539{
2540 KGDrawFlags_None = 0,
2541 KGDrawFlags_Closed = 1 << 0, // PathStroke(), AddPolyline(): specify that shape should be closed (Important: this is always == 1 for legacy reason)
2542 KGDrawFlags_RoundCornersTopLeft = 1 << 4, // AddRect(), AddRectFilled(), PathRect(): enable rounding top-left corner only (when rounding > 0.0f, we default to all corners). Was 0x01.
2543 KGDrawFlags_RoundCornersTopRight = 1 << 5, // AddRect(), AddRectFilled(), PathRect(): enable rounding top-right corner only (when rounding > 0.0f, we default to all corners). Was 0x02.
2544 KGDrawFlags_RoundCornersBottomLeft = 1 << 6, // AddRect(), AddRectFilled(), PathRect(): enable rounding bottom-left corner only (when rounding > 0.0f, we default to all corners). Was 0x04.
2545 KGDrawFlags_RoundCornersBottomRight = 1 << 7, // AddRect(), AddRectFilled(), PathRect(): enable rounding bottom-right corner only (when rounding > 0.0f, we default to all corners). Wax 0x08.
2546 KGDrawFlags_RoundCornersNone = 1 << 8, // AddRect(), AddRectFilled(), PathRect(): disable rounding on all corners (when rounding > 0.0f). This is NOT zero, NOT an implicit flag!
2547 KGDrawFlags_RoundCornersTop = KGDrawFlags_RoundCornersTopLeft | KGDrawFlags_RoundCornersTopRight,
2548 KGDrawFlags_RoundCornersBottom = KGDrawFlags_RoundCornersBottomLeft | KGDrawFlags_RoundCornersBottomRight,
2549 KGDrawFlags_RoundCornersLeft = KGDrawFlags_RoundCornersBottomLeft | KGDrawFlags_RoundCornersTopLeft,
2550 KGDrawFlags_RoundCornersRight = KGDrawFlags_RoundCornersBottomRight | KGDrawFlags_RoundCornersTopRight,
2551 KGDrawFlags_RoundCornersAll = KGDrawFlags_RoundCornersTopLeft | KGDrawFlags_RoundCornersTopRight | KGDrawFlags_RoundCornersBottomLeft | KGDrawFlags_RoundCornersBottomRight,
2552 KGDrawFlags_RoundCornersDefault_ = KGDrawFlags_RoundCornersAll, // Default to ALL corners if none of the _RoundCornersXX flags are specified.
2553 KGDrawFlags_RoundCornersMask_ = KGDrawFlags_RoundCornersAll | KGDrawFlags_RoundCornersNone,
2554};
2555
2556// Flags for KGDrawList instance. Those are set automatically by KarmaGui:: functions from KarmaGuiIO settings, and generally not manipulated directly.
2557// It is however possible to temporarily alter flags between calls to KGDrawList:: functions.
2558enum KGDrawListFlags_
2559{
2560 KGDrawListFlags_None = 0,
2561 KGDrawListFlags_AntiAliasedLines = 1 << 0, // Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines thin enough to be drawn using textures, otherwise *3 the number of triangles)
2562 KGDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures when possible. Require backend to render with bilinear filtering (NOT point/nearest filtering).
2563 KGDrawListFlags_AntiAliasedFill = 1 << 2, // Enable anti-aliased edge around filled shapes (rounded rectangles, circles).
2564 KGDrawListFlags_AllowVtxOffset = 1 << 3, // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'KGGuiBackendFlags_RendererHasVtxOffset' is enabled.
2565};
2580struct KARMA_API KGDrawList
2581{
2582 // This is what you have to render
2583 KGVector<KGDrawCmd> CmdBuffer; // Draw commands. Typically 1 command = 1 GPU draw call, unless the command is a callback.
2584 KGVector<KGDrawIdx> IdxBuffer; // Index buffer. Each command consume KGDrawCmd::ElemCount of those
2585 KGVector<KGDrawVert> VtxBuffer; // Vertex buffer.
2586 KGDrawListFlags Flags; // Flags, you may poke into these to adjust anti-aliasing settings per-primitive.
2587
2588 // [Internal, used while building lists]
2589 unsigned int _VtxCurrentIdx; // [Internal] generally == VtxBuffer.Size unless we are past 64K vertices, in which case this gets reset to 0.
2590 KGDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context)
2591 const char* _OwnerName; // Pointer to owner window's name for debugging
2592 KGDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the KGVector<> operators too much)
2593 KGDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the KGVector<> operators too much)
2594 KGVector<KGVec4> _ClipRectStack; // [Internal]
2595 KGVector<KGTextureID> _TextureIdStack; // [Internal]
2596 KGVector<KGVec2> _Path; // [Internal] current path building
2597 KGDrawCmdHeader _CmdHeader; // [Internal] template of active commands. Fields should match those of CmdBuffer.back().
2598 KGDrawListSplitter _Splitter; // [Internal] for channels api (note: prefer using your own persistent instance of KGDrawListSplitter!)
2599 float _FringeScale; // [Internal] anti-alias fringe is scaled by this value, this helps to keep things sharp while zooming at vertex buffer content
2600
2601 // If you want to create KGDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own KGDrawListSharedData (so you can use KGDrawList without ImGui)
2602 KGDrawList(KGDrawListSharedData* shared_data) { memset(this, 0, sizeof(*this)); _Data = shared_data; }
2603
2604 ~KGDrawList() { _ClearFreeMemory(); }
2605 void PushClipRect(const KGVec2& clip_rect_min, const KGVec2& clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
2606 void PushClipRectFullScreen();
2607 void PopClipRect();
2608 void PushTextureID(KGTextureID texture_id);
2609 void PopTextureID();
2610 inline KGVec2 GetClipRectMin() const { const KGVec4& cr = _ClipRectStack.back(); return KGVec2(cr.x, cr.y); }
2611 inline KGVec2 GetClipRectMax() const { const KGVec4& cr = _ClipRectStack.back(); return KGVec2(cr.z, cr.w); }
2612
2613 // Primitives
2614 // - Filled shapes must always use clockwise winding order. The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing.
2615 // - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners.
2616 // - For circle primitives, use "num_segments == 0" to automatically calculate tessellation (preferred).
2617 // In older versions (until Dear ImGui 1.77) the AddCircle functions defaulted to num_segments == 12.
2618 // In future versions we will use textures to provide cheaper and higher-quality circles.
2619 // Use AddNgon() and AddNgonFilled() functions if you need to guarantee a specific number of sides.
2620 void AddLine(const KGVec2& p1, const KGVec2& p2, KGU32 col, float thickness = 1.0f);
2621 void AddRect(const KGVec2& p_min, const KGVec2& p_max, KGU32 col, float rounding = 0.0f, KGDrawFlags flags = 0, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size)
2622 void AddRectFilled(const KGVec2& p_min, const KGVec2& p_max, KGU32 col, float rounding = 0.0f, KGDrawFlags flags = 0); // a: upper-left, b: lower-right (== upper-left + size)
2623 void AddRectFilledMultiColor(const KGVec2& p_min, const KGVec2& p_max, KGU32 col_upr_left, KGU32 col_upr_right, KGU32 col_bot_right, KGU32 col_bot_left);
2624 void AddQuad(const KGVec2& p1, const KGVec2& p2, const KGVec2& p3, const KGVec2& p4, KGU32 col, float thickness = 1.0f);
2625 void AddQuadFilled(const KGVec2& p1, const KGVec2& p2, const KGVec2& p3, const KGVec2& p4, KGU32 col);
2626 void AddTriangle(const KGVec2& p1, const KGVec2& p2, const KGVec2& p3, KGU32 col, float thickness = 1.0f);
2627 void AddTriangleFilled(const KGVec2& p1, const KGVec2& p2, const KGVec2& p3, KGU32 col);
2628 void AddCircle(const KGVec2& center, float radius, KGU32 col, int num_segments = 0, float thickness = 1.0f);
2629 void AddCircleFilled(const KGVec2& center, float radius, KGU32 col, int num_segments = 0);
2630 void AddNgon(const KGVec2& center, float radius, KGU32 col, int num_segments, float thickness = 1.0f);
2631 void AddNgonFilled(const KGVec2& center, float radius, KGU32 col, int num_segments);
2632 void AddText(const KGVec2& pos, KGU32 col, const char* text_begin, const char* text_end = NULL);
2633 void AddText(const KGFont* font, float font_size, const KGVec2& pos, KGU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const KGVec4* cpu_fine_clip_rect = NULL);
2634 void AddPolyline(const KGVec2* points, int num_points, KGU32 col, KGDrawFlags flags, float thickness);
2635 void AddConvexPolyFilled(const KGVec2* points, int num_points, KGU32 col);
2636 void AddBezierCubic(const KGVec2& p1, const KGVec2& p2, const KGVec2& p3, const KGVec2& p4, KGU32 col, float thickness, int num_segments = 0); // Cubic Bezier (4 control points)
2637 void AddBezierQuadratic(const KGVec2& p1, const KGVec2& p2, const KGVec2& p3, KGU32 col, float thickness, int num_segments = 0); // Quadratic Bezier (3 control points)
2638
2639 // Image primitives
2640 // - Read FAQ to understand what KGTextureID is.
2641 // - "p_min" and "p_max" represent the upper-left and lower-right corners of the rectangle.
2642 // - "uv_min" and "uv_max" represent the normalized texture coordinates to use for those corners. Using (0,0)->(1,1) texture coordinates will generally display the entire texture.
2643 void AddImage(KGTextureID user_texture_id, const KGVec2& p_min, const KGVec2& p_max, const KGVec2& uv_min = KGVec2(0, 0), const KGVec2& uv_max = KGVec2(1, 1), KGU32 col = KG_COL32_WHITE);
2644 void AddImageQuad(KGTextureID user_texture_id, const KGVec2& p1, const KGVec2& p2, const KGVec2& p3, const KGVec2& p4, const KGVec2& uv1 = KGVec2(0, 0), const KGVec2& uv2 = KGVec2(1, 0), const KGVec2& uv3 = KGVec2(1, 1), const KGVec2& uv4 = KGVec2(0, 1), KGU32 col = KG_COL32_WHITE);
2645 void AddImageRounded(KGTextureID user_texture_id, const KGVec2& p_min, const KGVec2& p_max, const KGVec2& uv_min, const KGVec2& uv_max, KGU32 col, float rounding, KGDrawFlags flags = 0);
2646
2647 // Add custom background color to a window
2648 void SetWindowBackgroundColor(KGVec4 bgColor);
2649
2650 // Stateful path API, add points then finish with PathFillConvex() or PathStroke()
2651 // - Filled shapes must always use clockwise winding order. The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing.
2652 inline void PathClear() { _Path.Size = 0; }
2653 inline void PathLineTo(const KGVec2& pos) { _Path.push_back(pos); }
2654 inline void PathLineToMergeDuplicate(const KGVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size - 1], &pos, 8) != 0) _Path.push_back(pos); }
2655 inline void PathFillConvex(KGU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; }
2656 inline void PathStroke(KGU32 col, KGDrawFlags flags = 0, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, flags, thickness); _Path.Size = 0; }
2657 void PathArcTo(const KGVec2& center, float radius, float a_min, float a_max, int num_segments = 0);
2658 void PathArcToFast(const KGVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
2659 void PathBezierCubicCurveTo(const KGVec2& p2, const KGVec2& p3, const KGVec2& p4, int num_segments = 0); // Cubic Bezier (4 control points)
2660 void PathBezierQuadraticCurveTo(const KGVec2& p2, const KGVec2& p3, int num_segments = 0); // Quadratic Bezier (3 control points)
2661 void PathRect(const KGVec2& rect_min, const KGVec2& rect_max, float rounding = 0.0f, KGDrawFlags flags = 0);
2662
2663 // Advanced
2664 void AddCallback(KGDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in KGDrawCmd and call the function instead of rendering triangles.
2665 void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
2666 KGDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer.
2667
2668 // Advanced: Channels
2669 // - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives)
2670 // - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end)
2671 // - FIXME-OBSOLETE: This API shouldn't have been in KGDrawList in the first place!
2672 // Prefer using your own persistent instance of KGDrawListSplitter as you can stack them.
2673 // Using the KGDrawList::ChannelsXXXX you cannot stack a split over another.
2674 inline void ChannelsSplit(int count) { _Splitter.Split(this, count); }
2675 inline void ChannelsMerge() { _Splitter.Merge(this); }
2676 inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); }
2677
2678 // Advanced: Primitives allocations
2679 // - We render triangles (three vertices)
2680 // - All primitives needs to be reserved via PrimReserve() beforehand.
2681 void PrimReserve(int idx_count, int vtx_count);
2682 void PrimUnreserve(int idx_count, int vtx_count);
2683 void PrimRect(const KGVec2& a, const KGVec2& b, KGU32 col); // Axis aligned rectangle (composed of two triangles)
2684 void PrimRectUV(const KGVec2& a, const KGVec2& b, const KGVec2& uv_a, const KGVec2& uv_b, KGU32 col);
2685 void PrimQuadUV(const KGVec2& a, const KGVec2& b, const KGVec2& c, const KGVec2& d, const KGVec2& uv_a, const KGVec2& uv_b, const KGVec2& uv_c, const KGVec2& uv_d, KGU32 col);
2686 inline void PrimWriteVtx(const KGVec2& pos, const KGVec2& uv, KGU32 col) { _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
2687 inline void PrimWriteIdx(KGDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
2688 inline void PrimVtx(const KGVec2& pos, const KGVec2& uv, KGU32 col) { PrimWriteIdx((KGDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index
2689
2690 // [Internal helpers]
2691 void _ResetForNewFrame();
2692 void _ClearFreeMemory();
2693 void _PopUnusedDrawCmd();
2694 void _TryMergeDrawCmds();
2695 void _OnChangedClipRect();
2696 void _OnChangedTextureID();
2697 void _OnChangedVtxOffset();
2698 int _CalcCircleAutoSegmentCount(float radius) const;
2699 void _PathArcToFastEx(const KGVec2& center, float radius, int a_min_sample, int a_max_sample, int a_step);
2700 void _PathArcToN(const KGVec2& center, float radius, float a_min, float a_max, int num_segments);
2701};
2702
2703// All draw data to render a KarmaGui frame
2704// (NB: the style and the naming convention here is a little inconsistent, we currently preserve them for backward compatibility purpose,
2705// as this is one of the oldest structure exposed by the library! Basically, KGDrawList == CmdList)
2706struct KARMA_API KGDrawData
2707{
2708 bool Valid; // Only valid after Render() is called and before the next NewFrame() is called.
2709 int CmdListsCount; // Number of KGDrawList* to render
2710 int TotalIdxCount; // For convenience, sum of all KGDrawList's IdxBuffer.Size
2711 int TotalVtxCount; // For convenience, sum of all KGDrawList's VtxBuffer.Size
2712 KGDrawList** CmdLists; // Array of KGDrawList* to render. The KGDrawList are owned by KarmaGuiContext and only pointed to from here.
2713 KGVec2 DisplayPos; // Top-left position of the viewport to render (== top-left of the orthogonal projection matrix to use) (== GetMainViewport()->Pos for the main viewport, == (0.0) in most single-viewport applications)
2714 KGVec2 DisplaySize; // Size of the viewport to render (== GetMainViewport()->Size for the main viewport, == io.DisplaySize in most single-viewport applications)
2715 KGVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
2716 KarmaGuiViewport* OwnerViewport; // Viewport carrying the KGDrawData instance, might be of use to the renderer (generally not).
2717
2718 // Functions
2719 KGDrawData() { Clear(); }
2720 void Clear() { memset(this, 0, sizeof(*this)); } // The KGDrawList are owned by KarmaGuiContext!
2721 void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
2722 void ScaleClipRects(const KGVec2& fb_scale); // Helper to scale the ClipRect field of each KGDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
2723};
2724
2725//----------------------------------------------------------------------------------------------------------------
2726// [SECTION] Font API (KGFontConfig, KGFontGlyph, KGFontAtlasFlags, KGFontAtlas, KGFontGlyphRangesBuilder, KGFont)
2727//----------------------------------------------------------------------------------------------------------------
2728
2729struct KARMA_API KGFontConfig
2730{
2731 void* FontData; // // TTF/OTF data
2732 int FontDataSize; // // TTF/OTF data size
2733 bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container KGFontAtlas (will delete memory itself).
2734 int FontNo; // 0 // Index of font within TTF/OTF file
2735 float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height).
2736 int OversampleH; // 3 // Rasterize at higher quality for sub-pixel positioning. Note the difference between 2 and 3 is minimal so you can reduce this to 2 to save memory. Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details.
2737 int OversampleV; // 1 // Rasterize at higher quality for sub-pixel positioning. This is not really useful as we don't use sub-pixel positions on the Y axis.
2738 bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1.
2739 KGVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
2740 KGVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input.
2741 const KGWchar* GlyphRanges; // NULL // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
2742 float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font
2743 float GlyphMaxAdvanceX; // FLT_MAX // Maximum AdvanceX for glyphs
2744 bool MergeMode; // false // Merge into previous KGFont, so you can combine multiple inputs font into one KGFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights.
2745 unsigned int FontBuilderFlags; // 0 // Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure.
2746 float RasterizerMultiply; // 1.0f // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable.
2747 KGWchar EllipsisChar; // -1 // Explicitly specify unicode codepoint of ellipsis character. When fonts are being merged first specified ellipsis will be used.
2748
2749 // [Internal]
2750 char Name[40]; // Name (strictly to ease debugging)
2751 KGFont* DstFont;
2752
2753 KGFontConfig();
2754};
2755
2756// Hold rendering data for one glyph.
2757// (Note: some language parsers may fail to convert the 31+1 bitfield members, in this case maybe drop store a single u32 or we can rework this)
2759{
2760 unsigned int Colored : 1; // Flag to indicate glyph is colored and should generally ignore tinting (make it usable with no shift on little-endian as this is used in loops)
2761 unsigned int Visible : 1; // Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering.
2762 unsigned int Codepoint : 30; // 0x0000..0x10FFFF
2763 float AdvanceX; // Distance to next character (= data from font + KGFontConfig::GlyphExtraSpacing.x baked in)
2764 float X0, Y0, X1, Y1; // Glyph corners
2765 float U0, V0, U1, V1; // Texture coordinates
2766};
2767
2768// Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges().
2769// This is essentially a tightly packed of vector of 64k booleans = 8KB storage.
2770struct KARMA_API KGFontGlyphRangesBuilder
2771{
2772 KGVector<KGU32> UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used)
2773
2774 KGFontGlyphRangesBuilder() { Clear(); }
2775 inline void Clear() { int size_in_bytes = (KG_UNICODE_CODEPOINT_MAX + 1) / 8; UsedChars.resize(size_in_bytes / (int)sizeof(KGU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); }
2776 inline bool GetBit(size_t n) const { int off = (int)(n >> 5); KGU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array
2777 inline void SetBit(size_t n) { int off = (int)(n >> 5); KGU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array
2778 inline void AddChar(KGWchar c) { SetBit(c); } // Add character
2779 void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added)
2780 void AddRanges(const KGWchar* ranges); // Add ranges, e.g. builder.AddRanges(KGFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext
2781 void BuildRanges(KGVector<KGWchar>* out_ranges); // Output new ranges
2782};
2783
2784// See KGFontAtlas::AddCustomRectXXX functions.
2785struct KARMA_API KGFontAtlasCustomRect
2786{
2787 unsigned short Width, Height; // Input // Desired rectangle dimension
2788 unsigned short X, Y; // Output // Packed position in Atlas
2789 unsigned int GlyphID; // Input // For custom font glyphs only (ID < 0x110000)
2790 float GlyphAdvanceX; // Input // For custom font glyphs only: glyph xadvance
2791 KGVec2 GlyphOffset; // Input // For custom font glyphs only: glyph display offset
2792 KGFont* Font; // Input // For custom font glyphs only: target font
2793 KGFontAtlasCustomRect() { Width = Height = 0; X = Y = 0xFFFF; GlyphID = 0; GlyphAdvanceX = 0.0f; GlyphOffset = KGVec2(0, 0); Font = NULL; }
2794 bool IsPacked() const { return X != 0xFFFF; }
2795};
2796
2797// Flags for KGFontAtlas build
2798enum KGFontAtlasFlags_
2799{
2800 KGFontAtlasFlags_None = 0,
2801 KGFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, // Don't round the height to next power of two
2802 KGFontAtlasFlags_NoMouseCursors = 1 << 1, // Don't build software mouse cursors into the atlas (save a little texture memory)
2803 KGFontAtlasFlags_NoBakedLines = 1 << 2, // Don't build thick line textures into the atlas (save a little texture memory, allow support for point/nearest filtering). The AntiAliasedLinesUseTex features uses them, otherwise they will be rendered using polygons (more expensive for CPU/GPU).
2804};
2805
2806// Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding:
2807// - One or more fonts.
2808// - Custom graphics data needed to render the shapes needed by Dear ImGui.
2809// - Mouse cursor shapes for software cursor rendering (unless setting 'Flags |= KGFontAtlasFlags_NoMouseCursors' in the font atlas).
2810// It is the user-code responsibility to setup/build the atlas, then upload the pixel data into a texture accessible by your graphics api.
2811// - Optionally, call any of the AddFont*** functions. If you don't call any, the default font embedded in the code will be loaded for you.
2812// - Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
2813// - Upload the pixels data into a texture within your graphics system (see imgui_impl_xxxx.cpp examples)
2814// - Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture in a format natural to your graphics API.
2815// This value will be passed back to you during rendering to identify the texture. Read FAQ entry about KGTextureID for more details.
2816// Common pitfalls:
2817// - If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the
2818// atlas is build (when calling GetTexData*** or Build()). We only copy the pointer, not the data.
2819// - Important: By default, AddFontFromMemoryTTF() takes ownership of the data. Even though we are not writing to it, we will free the pointer on destruction.
2820// You can set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed,
2821// - Even though many functions are suffixed with "TTF", OTF data is supported just as well.
2822// - This is an old API and it is currently awkward for those and various other reasons! We will address them in the future!
2823struct KARMA_API KGFontAtlas
2824{
2825 KGFontAtlas();
2826 ~KGFontAtlas();
2827 KGFont* AddFont(const KGFontConfig* font_cfg);
2828 KGFont* AddFontDefault(const KGFontConfig* font_cfg = NULL);
2829 KGFont* AddFontFromFileTTF(const char* filename, float size_pixels, const KGFontConfig* font_cfg = NULL, const KGWchar* glyph_ranges = NULL);
2830 KGFont* AddFontFromMemoryTTF(void* font_data, int font_size, float size_pixels, const KGFontConfig* font_cfg = NULL, const KGWchar* glyph_ranges = NULL); // Note: Transfer ownership of 'ttf_data' to KGFontAtlas! Will be deleted after destruction of the atlas. Set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
2831 KGFont* AddFontFromMemoryCompressedTTF(const void* compressed_font_data, int compressed_font_size, float size_pixels, const KGFontConfig* font_cfg = NULL, const KGWchar* glyph_ranges = NULL); // 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
2832 KGFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels, const KGFontConfig* font_cfg = NULL, const KGWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter.
2833 void ClearInputData(); // Clear input data (all KGFontConfig structures including sizes, TTF data, glyph ranges, etc.) = all the data used to build the texture and fonts.
2834 void ClearTexData(); // Clear output texture data (CPU side). Saves RAM once the texture has been copied to graphics memory.
2835 void ClearFonts(); // Clear output font data (glyphs storage, UV coordinates).
2836 void Clear(); // Clear all input and output.
2837
2838 // Build atlas, retrieve pixel data.
2839 // User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID().
2840 // The pitch is always = Width * BytesPerPixels (1 or 4)
2841 // Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
2842 // the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste.
2843 bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions.
2844 void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
2845 void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
2846 bool IsBuilt() const { return Fonts.Size > 0 && TexReady; } // Bit ambiguous: used to detect when user didn't build texture but effectively we should check TexID != 0 except that would be backend dependent...
2847 void SetTexID(KGTextureID id) { TexID = id; }
2848
2849 //-------------------------------------------
2850 // Glyph Ranges
2851 //-------------------------------------------
2852
2853 // Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
2854 // NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details.
2855 // NB: Consider using KGFontGlyphRangesBuilder to build glyph ranges from textual data.
2856 static const KGWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
2857 static const KGWchar* GetGlyphRangesGreek(); // Default + Greek and Coptic
2858 static const KGWchar* GetGlyphRangesKorean(); // Default + Korean characters
2859 static const KGWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 2999 Ideographs
2860 static const KGWchar* GetGlyphRangesChineseFull(); // Default + Half-Width + Japanese Hiragana/Katakana + full set of about 21000 CJK Unified Ideographs
2861 static const KGWchar* GetGlyphRangesChineseSimplifiedCommon();// Default + Half-Width + Japanese Hiragana/Katakana + set of 2500 CJK Unified Ideographs for common simplified Chinese
2862 static const KGWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters
2863 static const KGWchar* GetGlyphRangesThai(); // Default + Thai characters
2864 static const KGWchar* GetGlyphRangesVietnamese(); // Default + Vietnamese characters
2865
2866 //-------------------------------------------
2867 // [BETA] Custom Rectangles/Glyphs API
2868 //-------------------------------------------
2869
2870 // You can request arbitrary rectangles to be packed into the atlas, for your own purposes.
2871 // - After calling Build(), you can query the rectangle position and render your pixels.
2872 // - If you render colored output, set 'atlas->TexPixelsUseColors = true' as this may help some backends decide of prefered texture format.
2873 // - You can also request your rectangles to be mapped as font glyph (given a font + Unicode point),
2874 // so you can render e.g. custom colorful icons and use them as regular glyphs.
2875 // - Read docs/FONTS.md for more details about using colorful icons.
2876 // - Note: this API may be redesigned later in order to support multi-monitor varying DPI settings.
2877 int AddCustomRectRegular(int width, int height);
2878 int AddCustomRectFontGlyph(KGFont* font, KGWchar id, int width, int height, float advance_x, const KGVec2& offset = KGVec2(0, 0));
2879 KGFontAtlasCustomRect* GetCustomRectByIndex(int index) { KR_CORE_ASSERT(index >= 0, ""); return &CustomRects[index]; }
2880
2881 // [Internal]
2882 void CalcCustomRectUV(const KGFontAtlasCustomRect* rect, KGVec2* out_uv_min, KGVec2* out_uv_max) const;
2883 bool GetMouseCursorTexData(KarmaGuiMouseCursor cursor, KGVec2* out_offset, KGVec2* out_size, KGVec2 out_uv_border[2], KGVec2 out_uv_fill[2]);
2884
2885 //-------------------------------------------
2886 // Members
2887 //-------------------------------------------
2888
2889 KGFontAtlasFlags Flags; // Build flags (see KGFontAtlasFlags_)
2890 KGTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the KGDrawCmd structure.
2891 int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
2892 int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1. If your rendering method doesn't rely on bilinear filtering you may set this to 0 (will also need to set AntiAliasedLinesUseTex = false).
2893 bool Locked; // Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert.
2894 void* UserData; // Store your own atlas related user-data (if e.g. you have multiple font atlas).
2895
2896 // [Internal]
2897 // NB: Access texture data via GetTexData*() calls! Which will setup a default font for you.
2898 bool TexReady; // Set when texture was built matching current font input
2899 bool TexPixelsUseColors; // Tell whether our texture data is known to use colors (rather than just alpha channel), in order to help backend select a format.
2900 unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
2901 unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
2902 int TexWidth; // Texture width calculated during Build().
2903 int TexHeight; // Texture height calculated during Build().
2904 KGVec2 TexUvScale; // = (1.0f/TexWidth, 1.0f/TexHeight)
2905 KGVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
2906 KGVector<KGFont*> Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
2907 KGVector<KGFontAtlasCustomRect> CustomRects; // Rectangles for packing custom texture data into the atlas.
2908 KGVector<KGFontConfig> ConfigData; // Configuration data
2909 KGVec4 TexUvLines[KG_DRAWLIST_TEX_LINES_WIDTH_MAX + 1]; // UVs for baked anti-aliased lines
2910
2911 // [Internal] Font builder
2912 const KGFontBuilderIO* FontBuilderIO; // Opaque interface to a font builder (default to stb_truetype, can be changed to use FreeType by defining KGGUI_ENABLE_FREETYPE).
2913 unsigned int FontBuilderFlags; // Shared flags (for all fonts) for custom font builder. THIS IS BUILD IMPLEMENTATION DEPENDENT. Per-font override is also available in KGFontConfig.
2914
2915 // [Internal] Packing data
2916 int PackIdMouseCursors; // Custom texture rectangle ID for white pixel and mouse cursors
2917 int PackIdLines; // Custom texture rectangle ID for baked anti-aliased lines
2918
2919 // [Obsolete]
2920 //typedef KGFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
2921 //typedef KGFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
2922};
2923
2924// Font runtime data and rendering
2925// KGFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
2926struct KARMA_API KGFont
2927{
2928 // Members: Hot ~20/24 bytes (for CalcTextSize)
2929 KGVector<float> IndexAdvanceX; // 12-16 // out // // Sparse. Glyphs->AdvanceX in a directly indexable way (cache-friendly for CalcTextSize functions which only this this info, and are often bottleneck in large UI).
2930 float FallbackAdvanceX; // 4 // out // = FallbackGlyph->AdvanceX
2931 float FontSize; // 4 // in // // Height of characters/line, set during loading (don't change after loading)
2932
2933 // Members: Hot ~28/40 bytes (for CalcTextSize + render loop)
2934 KGVector<KGWchar> IndexLookup; // 12-16 // out // // Sparse. Index glyphs by Unicode code-point.
2935 KGVector<KGFontGlyph> Glyphs; // 12-16 // out // // All glyphs.
2936 const KGFontGlyph* FallbackGlyph; // 4-8 // out // = FindGlyph(FontFallbackChar)
2937
2938 // Members: Cold ~32/40 bytes
2939 KGFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into
2940 const KGFontConfig* ConfigData; // 4-8 // in // // Pointer within ContainerAtlas->ConfigData
2941 short ConfigDataCount; // 2 // in // ~ 1 // Number of KGFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one KGFont.
2942 KGWchar FallbackChar; // 2 // out // = FFFD/'?' // Character used if a glyph isn't found.
2943 KGWchar EllipsisChar; // 2 // out // = '...' // Character used for ellipsis rendering.
2944 KGWchar DotChar; // 2 // out // = '.' // Character used for ellipsis rendering (if a single '...' character isn't found)
2945 bool DirtyLookupTables; // 1 // out //
2946 float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
2947 float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
2948 int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
2949 KGU8 Used4kPagesMap[(KG_UNICODE_CODEPOINT_MAX+1)/4096/8]; // 2 bytes if KGWchar=KGWchar16, 34 bytes if KGWchar==KGWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations across all used codepoints.
2950
2951 // Methods
2952 KGFont();
2953 ~KGFont();
2954 const KGFontGlyph*FindGlyph(KGWchar c) const;
2955 const KGFontGlyph*FindGlyphNoFallback(KGWchar c) const;
2956 float GetCharAdvance(KGWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
2957 bool IsLoaded() const { return ContainerAtlas != NULL; }
2958 const char* GetDebugName() const { return ConfigData ? ConfigData->Name : "<unknown>"; }
2959
2960 // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
2961 // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
2962 KGVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
2963 const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
2964 void RenderChar(KGDrawList* draw_list, float size, const KGVec2& pos, KGU32 col, KGWchar c) const;
2965 void RenderText(KGDrawList* draw_list, float size, const KGVec2& pos, KGU32 col, const KGVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
2966
2967 // [Internal] Don't use!
2968 void BuildLookupTable();
2969 void ClearOutputData();
2970 void GrowIndex(int new_size);
2971 void AddGlyph(const KGFontConfig* src_cfg, KGWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
2972 void AddRemapChar(KGWchar dst, KGWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
2973 void SetGlyphVisible(KGWchar c, bool visible);
2974 bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
2975};
2976
2977//-----------------------------------------------------------------------------
2978// [SECTION] Viewports
2979//-----------------------------------------------------------------------------
2980
2981// Flags stored in KarmaGuiViewport::Flags, giving indications to the platform backends.
2982enum KGGuiViewportFlags_
2983{
2984 KGGuiViewportFlags_None = 0,
2985 KGGuiViewportFlags_IsPlatformWindow = 1 << 0, // Represent a Platform Window
2986 KGGuiViewportFlags_IsPlatformMonitor = 1 << 1, // Represent a Platform Monitor (unused yet)
2987 KGGuiViewportFlags_OwnedByApp = 1 << 2, // Platform Window: is created/managed by the application (rather than a dear imgui backend)
2988 KGGuiViewportFlags_NoDecoration = 1 << 3, // Platform Window: Disable platform decorations: title bar, borders, etc. (generally set all windows, but if KGGuiConfigFlags_ViewportsDecoration is set we only set this on popups/tooltips)
2989 KGGuiViewportFlags_NoTaskBarIcon = 1 << 4, // Platform Window: Disable platform task bar icon (generally set on popups/tooltips, or all windows if KGGuiConfigFlags_ViewportsNoTaskBarIcon is set)
2990 KGGuiViewportFlags_NoFocusOnAppearing = 1 << 5, // Platform Window: Don't take focus when created.
2991 KGGuiViewportFlags_NoFocusOnClick = 1 << 6, // Platform Window: Don't take focus when clicked on.
2992 KGGuiViewportFlags_NoInputs = 1 << 7, // Platform Window: Make mouse pass through so we can drag this window while peaking behind it.
2993 KGGuiViewportFlags_NoRendererClear = 1 << 8, // Platform Window: Renderer doesn't need to clear the framebuffer ahead (because we will fill it entirely).
2994 KGGuiViewportFlags_TopMost = 1 << 9, // Platform Window: Display on top (for tooltips only).
2995 KGGuiViewportFlags_Minimized = 1 << 10, // Platform Window: Window is minimized, can skip render. When minimized we tend to avoid using the viewport pos/size for clipping window or testing if they are contained in the viewport.
2996 KGGuiViewportFlags_NoAutoMerge = 1 << 11, // Platform Window: Avoid merging this window into another host window. This can only be set via KarmaGuiWindowClass viewport flags override (because we need to now ahead if we are going to create a viewport in the first place!).
2997 KGGuiViewportFlags_CanHostOtherWindows = 1 << 12, // Main viewport: can host multiple imgui windows (secondary viewports are associated to a single window).
2998};
2999
3014struct KARMA_API KarmaGuiViewport
3015{
3016 KGGuiID ID; // Unique identifier for the viewport
3017 KarmaGuiViewportFlags Flags; // See KGGuiViewportFlags_
3018 KGVec2 Pos; // Main Area: Position of the viewport (Dear ImGui coordinates are the same as OS desktop/native coordinates)
3019 KGVec2 Size; // Main Area: Size of the viewport.
3020 KGVec2 WorkPos; // Work Area: Position of the viewport minus task bars, menus bars, status bars (>= Pos)
3021 KGVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size)
3022 float DpiScale; // 1.0f = 96 DPI = No extra scale.
3023 KGGuiID ParentViewportId; // (Advanced) 0: no parent. Instruct the platform backend to setup a parent/child relationship between platform windows.
3024 KGDrawData* DrawData; // The KGDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame().
3025
3026 // Platform/Backend Dependent Data
3027 // Our design separate the Renderer and Platform backends to facilitate combining default backends with each others.
3028 // When our create your own backend for a custom engine, it is possible that both Renderer and Platform will be handled
3029 // by the same system and you may not need to use all the UserData/Handle fields.
3030 // The library never uses those fields, they are merely storage to facilitate backend implementation.
3031 void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, framebuffers etc.). generally set by your Renderer_CreateWindow function.
3032 void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). generally set by your Platform_CreateWindow function.
3033 void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GLFWWindow*, SDL_Window*)
3034 void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms), when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
3035 bool PlatformWindowCreated; // Platform window has been created (Platform_CreateWindow() has been called). This is false during the first frame where a viewport is being created.
3036 bool PlatformRequestMove; // Platform window requested move (e.g. window was moved by the OS / host window manager, authoritative position will be OS window position)
3037 bool PlatformRequestResize; // Platform window requested resize (e.g. window was resized by the OS / host window manager, authoritative size will be OS window size)
3038 bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)
3039
3040 KarmaGuiViewport() { memset(this, 0, sizeof(*this)); }
3041 ~KarmaGuiViewport() { KR_CORE_ASSERT(PlatformUserData == NULL && RendererUserData == NULL, ""); }
3042
3043 // Helpers
3044 KGVec2 GetCenter() const { return KGVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); }
3045 KGVec2 GetWorkCenter() const { return KGVec2(WorkPos.x + WorkSize.x * 0.5f, WorkPos.y + WorkSize.y * 0.5f); }
3046};
3047
3048//-----------------------------------------------------------------------------
3049// [SECTION] Platform Dependent Interfaces (for e.g. multi-viewport support)
3050//-----------------------------------------------------------------------------
3051// [BETA] (Optional) This is completely optional, for advanced users!
3052// If you are new to Dear ImGui and trying to integrate it into your engine, you can probably ignore this for now.
3053//
3054// This feature allows you to seamlessly drag Dear ImGui windows outside of your application viewport.
3055// This is achieved by creating new Platform/OS windows on the fly, and rendering into them.
3056// Dear ImGui manages the viewport structures, and the backend create and maintain one Platform/OS window for each of those viewports.
3057//
3058// See Glossary https://github.com/ocornut/imgui/wiki/Glossary for details about some of the terminology.
3059// See Thread https://github.com/ocornut/imgui/issues/1542 for gifs, news and questions about this evolving feature.
3060//
3061// About the coordinates system:
3062// - When multi-viewports are enabled, all KarmaGui coordinates become absolute coordinates (same as OS coordinates!)
3063// - So e.g. ImGui::SetNextWindowPos(KGVec2(0,0)) will position a window relative to your primary monitor!
3064// - If you want to position windows relative to your main application viewport, use ImGui::GetMainViewport()->Pos as a base position.
3065//
3066// Steps to use multi-viewports in your application, when using a default backend from the examples/ folder:
3067// - Application: Enable feature with 'io.ConfigFlags |= KGGuiConfigFlags_ViewportsEnable'.
3068// - Backend: The backend initialization will setup all necessary KarmaGuiPlatformIO's functions and update monitors info every frame.
3069// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
3070// - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
3071//
3072// Steps to use multi-viewports in your application, when using a custom backend:
3073// - Important: THIS IS NOT EASY TO DO and comes with many subtleties not described here!
3074// It's also an experimental feature, so some of the requirements may evolve.
3075// Consider using default backends if you can. Either way, carefully follow and refer to examples/ backends for details.
3076// - Application: Enable feature with 'io.ConfigFlags |= KGGuiConfigFlags_ViewportsEnable'.
3077// - Backend: Hook KarmaGuiPlatformIO's Platform_* and Renderer_* callbacks (see below).
3078// Set 'io.BackendFlags |= KGGuiBackendFlags_PlatformHasViewports' and 'io.BackendFlags |= KGGuiBackendFlags_PlatformHasViewports'.
3079// Update KarmaGuiPlatformIO's Monitors list every frame.
3080// Update MousePos every frame, in absolute coordinates.
3081// - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render().
3082// You may skip calling RenderPlatformWindowsDefault() if its API is not convenient for your needs. Read comments below.
3083// - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls.
3084//
3085// About KarmaGui::RenderPlatformWindowsDefault():
3086// - This function is a mostly a _helper_ for the common-most cases, and to facilitate using default backends.
3087// - You can check its simple source code to understand what it does.
3088// It basically iterates secondary viewports and call 4 functions that are setup in KarmaGuiPlatformIO, if available:
3089// Platform_RenderWindow(), Renderer_RenderWindow(), Platform_SwapBuffers(), Renderer_SwapBuffers()
3090// Those functions pointers exists only for the benefit of RenderPlatformWindowsDefault().
3091// - If you have very specific rendering needs (e.g. flipping multiple swap-chain simultaneously, unusual sync/threading issues, etc.),
3092// you may be tempted to ignore RenderPlatformWindowsDefault() and write customized code to perform your renderingg.
3093// You may decide to setup the platform_io's *RenderWindow and *SwapBuffers pointers and call your functions through those pointers,
3094// or you may decide to never setup those pointers and call your code directly. They are a convenience, not an obligatory interface.
3095//-----------------------------------------------------------------------------
3096
3097// (Optional) Access via KarmaGui::GetPlatformIO()
3098struct KARMA_API KarmaGuiPlatformIO
3099{
3100 //------------------------------------------------------------------
3101 // Input - Backend interface/functions + Monitor List
3102 //------------------------------------------------------------------
3103
3104 // (Optional) Platform functions (e.g. Win32, GLFW, SDL2)
3105 // For reference, the second column shows which function are generally calling the Platform Functions:
3106 // N = ImGui::NewFrame() ~ beginning of the dear imgui frame: read info from platform/OS windows (latest size/position)
3107 // F = ImGui::Begin(), ImGui::EndFrame() ~ during the dear imgui frame
3108 // U = ImGui::UpdatePlatformWindows() ~ after the dear imgui frame: create and update all platform/OS windows
3109 // R = ImGui::RenderPlatformWindowsDefault() ~ render
3110 // D = ImGui::DestroyPlatformWindows() ~ shutdown
3111 // The general idea is that NewFrame() we will read the current Platform/OS state, and UpdatePlatformWindows() will write to it.
3112 //
3113 // The functions are designed so we can mix and match 2 imgui_impl_xxxx files, one for the Platform (~window/input handling), one for Renderer.
3114 // Custom engine backends will often provide both Platform and Renderer interfaces and so may not need to use all functions.
3115 // Platform functions are typically called before their Renderer counterpart, apart from Destroy which are called the other way.
3116
3117 // Platform function --------------------------------------------------- Called by -----
3118 void (*Platform_CreateWindow)(KarmaGuiViewport* vp); // . . U . . // Create a new platform window for the given viewport
3119 void (*Platform_DestroyWindow)(KarmaGuiViewport* vp); // N . U . D //
3120 void (*Platform_ShowWindow)(KarmaGuiViewport* vp); // . . U . . // Newly created windows are initially hidden so SetWindowPos/Size/Title can be called on them before showing the window
3121 void (*Platform_SetWindowPos)(KarmaGuiViewport* vp, KGVec2 pos); // . . U . . // Set platform window position (given the upper-left corner of client area)
3122 KGVec2 (*Platform_GetWindowPos)(KarmaGuiViewport* vp); // N . . . . //
3123 void (*Platform_SetWindowSize)(KarmaGuiViewport* vp, KGVec2 size); // . . U . . // Set platform window client area size (ignoring OS decorations such as OS title bar etc.)
3124 KGVec2 (*Platform_GetWindowSize)(KarmaGuiViewport* vp); // N . . . . // Get platform window client area size
3125 void (*Platform_SetWindowFocus)(KarmaGuiViewport* vp); // N . . . . // Move window to front and set input focus
3126 bool (*Platform_GetWindowFocus)(KarmaGuiViewport* vp); // . . U . . //
3127 bool (*Platform_GetWindowMinimized)(KarmaGuiViewport* vp); // N . . . . // Get platform window minimized state. When minimized, we generally won't attempt to get/set size and contents will be culled more easily
3128 void (*Platform_SetWindowTitle)(KarmaGuiViewport* vp, const char* str); // . . U . . // Set platform window title (given an UTF-8 string)
3129 void (*Platform_SetWindowAlpha)(KarmaGuiViewport* vp, float alpha); // . . U . . // (Optional) Setup global transparency (not per-pixel transparency)
3130 void (*Platform_UpdateWindow)(KarmaGuiViewport* vp); // . . U . . // (Optional) Called by UpdatePlatformWindows(). Optional hook to allow the platform backend from doing general book-keeping every frame.
3131 void (*Platform_RenderWindow)(KarmaGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Main rendering (platform side! This is often unused, or just setting a "current" context for OpenGL bindings). 'render_arg' is the value passed to RenderPlatformWindowsDefault().
3132 void (*Platform_SwapBuffers)(KarmaGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers (platform side! This is often unused!). 'render_arg' is the value passed to RenderPlatformWindowsDefault().
3133 float (*Platform_GetWindowDpiScale)(KarmaGuiViewport* vp); // N . . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Return DPI scale for this viewport. 1.0f = 96 DPI.
3134 void (*Platform_OnChangedViewport)(KarmaGuiViewport* vp); // . F . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Called during Begin() every time the viewport we are outputting into changes, so backend has a chance to swap fonts to adjust style.
3135 int (*Platform_CreateVkSurface)(KarmaGuiViewport* vp, KGU64 vk_inst, const void* vk_allocators, KGU64* out_vk_surface); // (Optional) For a Vulkan Renderer to call into Platform code (since the surface creation needs to tie them both).
3136
3137 // (Optional) Renderer functions (e.g. DirectX, OpenGL, Vulkan)
3138 void (*Renderer_CreateWindow)(KarmaGuiViewport* vp); // . . U . . // Create swap chain, frame buffers etc. (called after Platform_CreateWindow)
3142 void (*Renderer_DestroyWindow)(KarmaGuiViewport* vp); // N . U . D // Destroy swap chain, frame buffers etc. (called before Platform_DestroyWindow)
3149 void (*Renderer_SetWindowSize)(KarmaGuiViewport* vp, KGVec2 size); // . . U . . // Resize swap chain, frame buffers etc. (called after Platform_SetWindowSize)
3158 void (*Renderer_RenderWindow)(KarmaGuiViewport* vp, void* render_arg); // . . . R . //
3159
3168 void (*Renderer_SwapBuffers)(KarmaGuiViewport* vp, void* render_arg); // . . . R . // (Optional) Call Present/SwapBuffers. 'render_arg' is the value passed to RenderPlatformWindowsDefault().
3169
3170 // (Optional) Monitor list
3171 // - Updated by: application/backend. Update every frame to dynamically support changing monitor or DPI configuration.
3172 // - Used by: KarmaGui to query DPI info, clamp popups/tooltips within same monitor and not have them straddle monitors.
3174
3175 //------------------------------------------------------------------
3176 // Output - List of viewports to render into platform windows
3177 //------------------------------------------------------------------
3178
3179 // Viewports list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
3180 // (in the future we will attempt to organize this feature to remove the need for a "main viewport")
3181 KGVector<KarmaGuiViewport*> Viewports; // Main viewports, followed by all secondary viewports.
3182 KarmaGuiPlatformIO() { memset(this, 0, sizeof(*this)); } // Zero clear
3183};
3184
3185// (Optional) This is required when enabling multi-viewport. Represent the bounds of each connected monitor/display and their DPI.
3186// We use this information for multiple DPI support + clamping the position of popups and tooltips so they don't straddle multiple monitors.
3187struct KARMA_API KarmaGuiPlatformMonitor
3188{
3189 KGVec2 MainPos, MainSize; // Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
3190 KGVec2 WorkPos, WorkSize; // Coordinates without task bars / side bars / menu bars. Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
3191 float DpiScale; // 1.0f = 96 DPI
3192 KarmaGuiPlatformMonitor() { MainPos = MainSize = WorkPos = WorkSize = KGVec2(0, 0); DpiScale = 1.0f; }
3193};
3194
3195// (Optional) Support for IME (Input Method Editor) via the io.SetPlatformImeDataFn() function.
3196struct KARMA_API KarmaGuiPlatformImeData
3197{
3198 bool WantVisible; // A widget wants the IME to be visible
3199 KGVec2 InputPos; // Position of the input cursor
3200 float InputLineHeight; // Line height
3201
3202 KarmaGuiPlatformImeData() { memset(this, 0, sizeof(*this)); }
3203};
#define KARMA_API
Defining Karma's API macro for storage class information.
Definition Core.h:41
The chief class for our UI needs. The responsibility includes.
Definition KarmaGui.h:188
static bool ImageButton(const char *str_id, KGTextureID user_texture_id, const KGVec2 &size, const KGVec2 &uv0=KGVec2(0, 0), const KGVec2 &uv1=KGVec2(1, 1), const KGVec4 &bg_col=KGVec4(0, 0, 0, 0), const KGVec4 &tint_col=KGVec4(1, 1, 1, 1))
Function for drawing button with specified image.
Definition KarmaGuiWidgets.cpp:1110
static void MemFree(void *ptr)
A legacy function brought from ImGui for UI relevant memory deallocation.
Definition KarmaGui.cpp:3102
static void Render()
Function to fill the KGDrawData instance of KarmaGui.
Definition KarmaGui.cpp:4120
static void RenderPlatformWindowsDefault(void *platform_render_arg=NULL, void *renderer_render_arg=NULL)
Call in main loop. Will call RenderWindow/SwapBuffers platform functions for each secondary viewport ...
Definition KarmaGui.cpp:13339
static void AddTextVertical(KGDrawList *DrawList, const char *text, KGVec2 pos, KGU32 text_color)
Definition KarmaGuiWidgets.cpp:297
static void * MemAlloc(size_t size)
A legacy function brought from ImGui for UI relevant memory allocation.
Definition KarmaGui.cpp:3094
Definition KarmaGui.h:2422
Definition KarmaGui.h:2513
Definition KarmaGui.h:2505
Definition KarmaGui.h:2471
Definition KarmaGui.h:2707
Draw command list.
Definition KarmaGui.h:2581
Definition KarmaGuiInternal.h:632
Definition KarmaGui.h:2522
Definition KarmaGui.h:2490
Definition KarmaGui.h:2786
Definition KarmaGui.h:2824
Definition KarmaGuiInternal.h:3369
Definition KarmaGui.h:2730
Definition KarmaGui.h:2759
Definition KarmaGui.h:2771
Definition KarmaGui.h:2927
Definition KarmaGui.h:1795
Definition KarmaGui.h:153
Definition KarmaGui.h:163
Definition KarmaGui.h:1817
Definition KarmaGuiInternal.h:1734
Definition KarmaGui.h:1952
Definition KarmaGui.h:2140
Definition KarmaGui.h:1944
Definition KarmaGui.h:2382
Definition KarmaGui.h:2257
Definition KarmaGui.h:2201
Definition KarmaGui.h:3099
void(* Renderer_SwapBuffers)(KarmaGuiViewport *vp, void *render_arg)
(Optional) Call Present/SwapBuffers. 'render_arg' is the value passed to Karma::KarmaGui::RenderPlatf...
Definition KarmaGui.h:3168
void(* Renderer_RenderWindow)(KarmaGuiViewport *vp, void *render_arg)
(Optional) Clear framebuffer, setup render target, then render the viewport->DrawData....
Definition KarmaGui.h:3158
void(* Renderer_SetWindowSize)(KarmaGuiViewport *vp, KGVec2 size)
Resize swap chain, frame buffers etc. (called after Platform_SetWindowSize).
Definition KarmaGui.h:3149
Definition KarmaGui.h:3197
Definition KarmaGui.h:3188
Definition KarmaGui.h:2171
Definition KarmaGui.h:2319
Definition KarmaGui.h:1887
Definition KarmaGui.h:2223
Definition KarmaGui.h:2237
Definition KarmaGui.h:2292
Definition KarmaGui.h:2265
A Platform Window (always 1 unless multi-viewport are enabled. One per platform window to output to)....
Definition KarmaGui.h:3015
Definition KarmaGui.h:2186