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