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