Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

imgui.h 73KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  1. // ImGui library v1.37
  2. // See .cpp file for documentation.
  3. // See ImGui::ShowTestWindow() for sample code.
  4. // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
  5. // Get latest version at https://github.com/ocornut/imgui
  6. #pragma once
  7. #include "imconfig.h" // User-editable configuration file
  8. #include <float.h> // FLT_MAX
  9. #include <stdarg.h> // va_list
  10. #include <stddef.h> // ptrdiff_t, NULL
  11. #include <stdlib.h> // NULL, malloc, free, qsort, atoi
  12. #include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
  13. #define IMGUI_VERSION "1.37"
  14. // Define assertion handler.
  15. #ifndef IM_ASSERT
  16. #include <assert.h>
  17. #define IM_ASSERT(_EXPR) assert(_EXPR)
  18. #endif
  19. // Define attributes of all API symbols declarations, e.g. for DLL under Windows.
  20. #ifndef IMGUI_API
  21. #define IMGUI_API
  22. #endif
  23. // Forward declarations
  24. struct ImDrawCmd;
  25. struct ImDrawList;
  26. struct ImFont;
  27. struct ImFontAtlas;
  28. struct ImGuiIO;
  29. struct ImGuiStorage;
  30. struct ImGuiStyle;
  31. typedef unsigned int ImU32;
  32. typedef unsigned short ImWchar; // character for display
  33. typedef void* ImTextureID; // user data to refer to a texture (e.g. store your texture handle/id)
  34. typedef ImU32 ImGuiID; // unique ID used by widgets (typically hashed from a stack of string)
  35. typedef int ImGuiCol; // enum ImGuiCol_
  36. typedef int ImGuiStyleVar; // enum ImGuiStyleVar_
  37. typedef int ImGuiKey; // enum ImGuiKey_
  38. typedef int ImGuiColorEditMode; // enum ImGuiColorEditMode_
  39. typedef int ImGuiMouseCursor; // enum ImGuiMouseCursor_
  40. typedef int ImGuiWindowFlags; // enum ImGuiWindowFlags_
  41. typedef int ImGuiSetCond; // enum ImGuiSetCond_
  42. typedef int ImGuiInputTextFlags; // enum ImGuiInputTextFlags_
  43. struct ImGuiTextEditCallbackData; // for advanced uses of InputText()
  44. typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
  45. struct ImVec2
  46. {
  47. float x, y;
  48. ImVec2() {}
  49. ImVec2(float _x, float _y) { x = _x; y = _y; }
  50. #ifdef IM_VEC2_CLASS_EXTRA
  51. IM_VEC2_CLASS_EXTRA
  52. #endif
  53. };
  54. struct ImVec4
  55. {
  56. float x, y, z, w;
  57. ImVec4() {}
  58. ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
  59. #ifdef IM_VEC4_CLASS_EXTRA
  60. IM_VEC4_CLASS_EXTRA
  61. #endif
  62. };
  63. namespace ImGui
  64. {
  65. // Proxy functions to access the MemAllocFn/MemFreeFn pointers in ImGui::GetIO(). The only reason they exist here is to allow ImVector<> to compile inline.
  66. IMGUI_API void* MemAlloc(size_t sz);
  67. IMGUI_API void MemFree(void* ptr);
  68. }
  69. // std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
  70. // Use '#define ImVector std::vector' if you want to use the STL type or your own type.
  71. // Our implementation does NOT call c++ constructors! because the data types we use don't need them (but that could be added as well). Only provide the minimum functionalities we need.
  72. #ifndef ImVector
  73. template<typename T>
  74. class ImVector
  75. {
  76. protected:
  77. size_t Size;
  78. size_t Capacity;
  79. T* Data;
  80. public:
  81. typedef T value_type;
  82. typedef value_type* iterator;
  83. typedef const value_type* const_iterator;
  84. ImVector() { Size = Capacity = 0; Data = NULL; }
  85. ~ImVector() { if (Data) ImGui::MemFree(Data); }
  86. inline bool empty() const { return Size == 0; }
  87. inline size_t size() const { return Size; }
  88. inline size_t capacity() const { return Capacity; }
  89. inline value_type& at(size_t i) { IM_ASSERT(i < Size); return Data[i]; }
  90. inline const value_type& at(size_t i) const { IM_ASSERT(i < Size); return Data[i]; }
  91. inline value_type& operator[](size_t i) { IM_ASSERT(i < Size); return Data[i]; }
  92. inline const value_type& operator[](size_t i) const { IM_ASSERT(i < Size); return Data[i]; }
  93. inline void clear() { if (Data) { Size = Capacity = 0; ImGui::MemFree(Data); Data = NULL; } }
  94. inline iterator begin() { return Data; }
  95. inline const_iterator begin() const { return Data; }
  96. inline iterator end() { return Data + Size; }
  97. inline const_iterator end() const { return Data + Size; }
  98. inline value_type& front() { IM_ASSERT(Size > 0); return Data[0]; }
  99. inline const value_type& front() const { IM_ASSERT(Size > 0); return Data[0]; }
  100. inline value_type& back() { IM_ASSERT(Size > 0); return Data[Size-1]; }
  101. inline const value_type& back() const { IM_ASSERT(Size > 0); return Data[Size-1]; }
  102. inline void swap(ImVector<T>& rhs) { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
  103. inline void resize(size_t new_size) { if (new_size > Capacity) reserve(new_size); Size = new_size; }
  104. inline void reserve(size_t new_capacity)
  105. {
  106. if (new_capacity <= Capacity) return;
  107. T* new_data = (value_type*)ImGui::MemAlloc(new_capacity * sizeof(value_type));
  108. memcpy(new_data, Data, Size * sizeof(value_type));
  109. ImGui::MemFree(Data);
  110. Data = new_data;
  111. Capacity = new_capacity;
  112. }
  113. inline void push_back(const value_type& v) { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
  114. inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
  115. inline iterator erase(const_iterator it) { IM_ASSERT(it >= begin() && it < end()); const ptrdiff_t off = it - begin(); memmove(Data + off, Data + off + 1, (Size - (size_t)off - 1) * sizeof(value_type)); Size--; return Data + off; }
  116. inline iterator insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= begin() && it <= end()); const ptrdiff_t off = it - begin(); if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, (Size - (size_t)off) * sizeof(value_type)); Data[off] = v; Size++; return Data + off; }
  117. };
  118. #endif // #ifndef ImVector
  119. // Helpers at bottom of the file:
  120. // - IMGUI_ONCE_UPON_A_FRAME // Execute a block of code once per frame only (convenient for creating UI within deep-nested code that runs multiple times)
  121. // - struct ImGuiTextFilter // Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
  122. // - struct ImGuiTextBuffer // Text buffer for logging/accumulating text
  123. // - struct ImGuiStorage // Custom key value storage (if you need to alter open/close states manually)
  124. // - struct ImDrawList // Draw command list
  125. // - struct ImFont // TTF font loader, bake glyphs into bitmap
  126. // ImGui end-user API
  127. // In a namespace so that user can add extra functions (e.g. Value() helpers for your vector or common types)
  128. namespace ImGui
  129. {
  130. // Main
  131. IMGUI_API ImGuiIO& GetIO();
  132. IMGUI_API ImGuiStyle& GetStyle();
  133. IMGUI_API void NewFrame();
  134. IMGUI_API void Render();
  135. IMGUI_API void Shutdown();
  136. IMGUI_API void ShowUserGuide();
  137. IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL);
  138. IMGUI_API void ShowTestWindow(bool* open = NULL);
  139. // Window
  140. // See implementation in .cpp for details
  141. IMGUI_API bool Begin(const char* name = "Debug", bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
  142. IMGUI_API bool Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // this is the older/longer API. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! maybe obsolete this API eventually.
  143. IMGUI_API void End();
  144. IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). on each axis.
  145. IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
  146. IMGUI_API void EndChild();
  147. IMGUI_API ImVec2 GetContentRegionMax(); // window or current column boundaries, in windows coordinates
  148. IMGUI_API ImVec2 GetWindowContentRegionMin(); // window boundaries, in windows coordinates
  149. IMGUI_API ImVec2 GetWindowContentRegionMax();
  150. IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives
  151. IMGUI_API ImFont* GetWindowFont();
  152. IMGUI_API float GetWindowFontSize(); // size (also height in pixels) of current font with current scale applied
  153. IMGUI_API void SetWindowFontScale(float scale); // per-window font scale. Adjust IO.FontGlobalScale if you want to scale all windows
  154. IMGUI_API ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to do your own drawing
  155. IMGUI_API ImVec2 GetWindowSize(); // get current window position
  156. IMGUI_API float GetWindowWidth();
  157. IMGUI_API bool GetWindowCollapsed();
  158. IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set next window position - call before Begin()
  159. IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set next window size. set to ImVec2(0,0) to force an auto-fit
  160. IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set next window collapsed state
  161. IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most
  162. IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set current window position - call within Begin()/End(). may incur tearing
  163. IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing
  164. IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set current window collapsed state
  165. IMGUI_API void SetWindowFocus(); // set current window to be focused / front-most
  166. IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); // set named window position - call within Begin()/End(). may incur tearing
  167. IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); // set named window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing
  168. IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0); // set named window collapsed state
  169. IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most
  170. IMGUI_API float GetScrollPosY(); // get scrolling position [0..GetScrollMaxY()]
  171. IMGUI_API float GetScrollMaxY(); // get maximum scrolling position == ContentSize.Y - WindowSize.Y
  172. IMGUI_API void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position
  173. IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget
  174. IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
  175. IMGUI_API ImGuiStorage* GetStateStorage();
  176. // Parameters stacks (shared)
  177. IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font
  178. IMGUI_API void PopFont();
  179. IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col);
  180. IMGUI_API void PopStyleColor(int count = 1);
  181. IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val);
  182. IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val);
  183. IMGUI_API void PopStyleVar(int count = 1);
  184. // Parameters stacks (current window)
  185. IMGUI_API void PushItemWidth(float item_width); // width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -0.01f always align width to the right side)
  186. IMGUI_API void PopItemWidth();
  187. IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position
  188. IMGUI_API void PushAllowKeyboardFocus(bool v); // allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
  189. IMGUI_API void PopAllowKeyboardFocus();
  190. IMGUI_API void PushTextWrapPos(float wrap_pos_x = 0.0f); // word-wrapping 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
  191. IMGUI_API void PopTextWrapPos();
  192. // Tooltip
  193. IMGUI_API void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins
  194. IMGUI_API void SetTooltipV(const char* fmt, va_list args);
  195. IMGUI_API void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text
  196. IMGUI_API void EndTooltip();
  197. // Popup
  198. IMGUI_API void BeginPopup(bool* p_opened);
  199. IMGUI_API void EndPopup();
  200. // Layout
  201. IMGUI_API void BeginGroup();
  202. IMGUI_API void EndGroup();
  203. IMGUI_API void Separator(); // horizontal line
  204. IMGUI_API void SameLine(int column_x = 0, int spacing_w = -1); // call between widgets or groups to layout them horizontally
  205. IMGUI_API void Spacing(); // add vertical spacing
  206. IMGUI_API void Indent(); // move content position toward the right by style.IndentSpacing pixels
  207. IMGUI_API void Unindent(); // move content position back to the left (cancel Indent)
  208. IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border=true); // setup number of columns
  209. IMGUI_API void NextColumn(); // next column
  210. IMGUI_API int GetColumnIndex(); // get current column index
  211. IMGUI_API 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 usually 0.0f and not resizable unless you call this
  212. IMGUI_API 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
  213. IMGUI_API float GetColumnWidth(int column_index = -1); // column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset())
  214. IMGUI_API int GetColumnsCount(); // number of columns (what was passed to Columns())
  215. IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
  216. IMGUI_API float GetCursorPosX(); // "
  217. IMGUI_API float GetCursorPosY(); // "
  218. IMGUI_API void SetCursorPos(const ImVec2& pos); // "
  219. IMGUI_API void SetCursorPosX(float x); // "
  220. IMGUI_API void SetCursorPosY(float y); // "
  221. IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize]
  222. IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize]
  223. IMGUI_API void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets
  224. IMGUI_API float GetTextLineHeight(); // height of font == GetWindowFontSize()
  225. IMGUI_API float GetTextLineHeightWithSpacing(); // spacing (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
  226. // ID scopes
  227. // If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them
  228. // You can also use "##extra" within your widget name to distinguish them from each others (see 'Programmer Guide')
  229. IMGUI_API void PushID(const char* str_id); // push identifier into the ID stack. IDs are hash of the *entire* stack!
  230. IMGUI_API void PushID(const void* ptr_id);
  231. IMGUI_API void PushID(const int int_id);
  232. IMGUI_API void PopID();
  233. IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). useful if you want to query into ImGuiStorage yourself. otherwise rarely needed
  234. IMGUI_API ImGuiID GetID(const void* ptr_id);
  235. // Widgets
  236. IMGUI_API void Text(const char* fmt, ...);
  237. IMGUI_API void TextV(const char* fmt, va_list args);
  238. IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
  239. IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args);
  240. IMGUI_API void TextWrapped(const char* fmt, ...); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();
  241. IMGUI_API void TextWrappedV(const char* fmt, va_list args);
  242. IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text
  243. IMGUI_API void LabelText(const char* label, const char* fmt, ...); // display text+label aligned the same way as value+label widgets
  244. IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args);
  245. IMGUI_API void Bullet();
  246. IMGUI_API void BulletText(const char* fmt, ...);
  247. IMGUI_API void BulletTextV(const char* fmt, va_list args);
  248. IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0), bool repeat_when_held = false);
  249. IMGUI_API bool SmallButton(const char* label);
  250. IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size);
  251. IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
  252. IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,1), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
  253. IMGUI_API bool CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false);
  254. IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders
  255. IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
  256. IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
  257. IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
  258. IMGUI_API bool SliderAngle(const char* label, float* v, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); // *v in radians
  259. IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
  260. IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* display_format = "%.0f");
  261. IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* display_format = "%.0f");
  262. IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* display_format = "%.0f");
  263. IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
  264. IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = "%.0f");
  265. IMGUI_API 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, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
  266. IMGUI_API 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, ImVec2 graph_size = ImVec2(0,0));
  267. IMGUI_API 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, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
  268. IMGUI_API 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, ImVec2 graph_size = ImVec2(0,0));
  269. IMGUI_API bool Checkbox(const char* label, bool* v);
  270. IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
  271. IMGUI_API bool RadioButton(const char* label, bool active);
  272. IMGUI_API bool RadioButton(const char* label, int* v, int v_button);
  273. IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
  274. IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
  275. IMGUI_API bool InputFloat2(const char* label, float v[2], int decimal_precision = -1);
  276. IMGUI_API bool InputFloat3(const char* label, float v[3], int decimal_precision = -1);
  277. IMGUI_API bool InputFloat4(const char* label, float v[4], int decimal_precision = -1);
  278. IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0);
  279. IMGUI_API bool InputInt2(const char* label, int v[2]);
  280. IMGUI_API bool InputInt3(const char* label, int v[3]);
  281. IMGUI_API bool InputInt4(const char* label, int v[4]);
  282. IMGUI_API bool Combo(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
  283. IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1); // separate items with \0, end item-list with \0\0
  284. IMGUI_API 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 height_in_items = -1);
  285. IMGUI_API bool ColorButton(const ImVec4& col, bool small_height = false, bool outline_border = true);
  286. IMGUI_API bool ColorEdit3(const char* label, float col[3]);
  287. IMGUI_API bool ColorEdit4(const char* label, float col[4], bool show_alpha = true);
  288. IMGUI_API void ColorEditMode(ImGuiColorEditMode mode);
  289. // Trees
  290. IMGUI_API bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop
  291. IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...); // "
  292. IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...); // "
  293. IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // "
  294. IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // "
  295. IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
  296. IMGUI_API void TreePush(const void* ptr_id = NULL); // "
  297. IMGUI_API void TreePop();
  298. IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node to be opened.
  299. // Selectable / Lists
  300. IMGUI_API bool Selectable(const char* label, bool selected = false, const ImVec2& size = ImVec2(0,0));
  301. IMGUI_API bool Selectable(const char* label, bool* p_selected, const ImVec2& size = ImVec2(0,0));
  302. IMGUI_API bool ListBox(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
  303. IMGUI_API 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);
  304. IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards.
  305. IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // "
  306. IMGUI_API void ListBoxFooter(); // terminate the scrolling region
  307. // Value() Helpers: output single value in "name: value" format. Tip: freely declare your own within the ImGui namespace!
  308. IMGUI_API void Value(const char* prefix, bool b);
  309. IMGUI_API void Value(const char* prefix, int v);
  310. IMGUI_API void Value(const char* prefix, unsigned int v);
  311. IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL);
  312. IMGUI_API void Color(const char* prefix, const ImVec4& v);
  313. IMGUI_API void Color(const char* prefix, unsigned int v);
  314. // Logging: All text output from your interface are redirected to tty/file/clipboard. Tree nodes are automatically opened.
  315. IMGUI_API void LogToTTY(int max_depth = -1); // start logging to tty
  316. IMGUI_API void LogToFile(int max_depth = -1, const char* filename = NULL); // start logging to file
  317. IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard
  318. IMGUI_API void LogFinish(); // stop logging (close file, etc.)
  319. IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard
  320. IMGUI_API void LogText(const char* fmt, ...); // pass text data straight to log (without being displayed)
  321. // Utilities
  322. IMGUI_API bool IsItemHovered(); // was the last item hovered by mouse?
  323. IMGUI_API bool IsItemHoveredRect(); // was the last item hovered by mouse? even if another item is active while we are hovering this
  324. IMGUI_API bool IsItemActive(); // was the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false)
  325. IMGUI_API bool IsAnyItemActive(); //
  326. IMGUI_API ImVec2 GetItemRectMin(); // get bounding rect of last item
  327. IMGUI_API ImVec2 GetItemRectMax(); // "
  328. IMGUI_API ImVec2 GetItemRectSize(); // "
  329. IMGUI_API bool IsWindowFocused(); // is current window focused (differentiate child windows from each others)
  330. IMGUI_API bool IsRootWindowFocused(); // is current root window focused
  331. IMGUI_API bool IsRootWindowOrAnyChildFocused(); // is current root window or any of its child (including current window) focused
  332. IMGUI_API bool IsClipped(const ImVec2& item_size); // to perform coarse clipping on user's side (as an optimization)
  333. IMGUI_API bool IsKeyPressed(int key_index, bool repeat = true); // key_index into the keys_down[512] array, imgui doesn't know the semantic of each entry
  334. IMGUI_API bool IsMouseClicked(int button, bool repeat = false);
  335. IMGUI_API bool IsMouseDoubleClicked(int button);
  336. IMGUI_API bool IsMouseHoveringWindow(); // is mouse hovering current window ("window" in API names always refer to current window)
  337. IMGUI_API bool IsMouseHoveringAnyWindow(); // is mouse hovering any active imgui window
  338. IMGUI_API bool IsMouseHoveringRect(const ImVec2& rect_min, const ImVec2& rect_max);// is mouse hovering given bounding rect
  339. IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
  340. IMGUI_API bool IsPosHoveringAnyWindow(const ImVec2& pos); // is given position hovering any active imgui window
  341. IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
  342. IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // dragging amount since clicking, also see: GetItemActiveDragDelta(). if lock_threshold < -1.0f uses io.MouseDraggingThreshold
  343. IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
  344. IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type
  345. IMGUI_API float GetTime();
  346. IMGUI_API int GetFrameCount();
  347. IMGUI_API const char* GetStyleColName(ImGuiCol idx);
  348. IMGUI_API ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = +0.0f); // utility to find the closest point the last item bounding rectangle edge. useful to visually link items
  349. IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
  350. IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // helper to manually clip large list of items. see comments in implementation
  351. IMGUI_API void BeginChildFrame(ImGuiID id, const ImVec2& size); // helper to create a child window / scrolling region that looks like a normal widget frame
  352. IMGUI_API void EndChildFrame();
  353. IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in);
  354. IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
  355. IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
  356. // Internal state access - if you want to share ImGui state between modules (e.g. DLL) or allocate it yourself
  357. IMGUI_API const char* GetVersion();
  358. IMGUI_API void* GetInternalState();
  359. IMGUI_API size_t GetInternalStateSize();
  360. IMGUI_API void SetInternalState(void* state, bool construct = false);
  361. // Obsolete (will be removed)
  362. IMGUI_API void GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size); // OBSOLETE
  363. static inline void OpenNextNode(bool open) { ImGui::SetNextTreeNodeOpened(open, 0); } // OBSOLETE
  364. static inline bool GetWindowIsFocused() { return ImGui::IsWindowFocused(); } // OBSOLETE
  365. static inline ImVec2 GetItemBoxMin() { return GetItemRectMin(); } // OBSOLETE
  366. static inline ImVec2 GetItemBoxMax() { return GetItemRectMax(); } // OBSOLETE
  367. static inline bool IsMouseHoveringBox(const ImVec2& rect_min, const ImVec2& rect_max) { return IsMouseHoveringRect(rect_min, rect_max); } // OBSOLETE
  368. } // namespace ImGui
  369. // Flags for ImGui::Begin()
  370. enum ImGuiWindowFlags_
  371. {
  372. // Default: 0
  373. ImGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar
  374. ImGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip
  375. ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window
  376. ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbar (window can still scroll with mouse or programatically)
  377. ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user scrolling with mouse wheel
  378. ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it
  379. ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
  380. ImGuiWindowFlags_ShowBorders = 1 << 7, // Show borders around windows and items
  381. ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
  382. // [Internal]
  383. ImGuiWindowFlags_ChildWindow = 1 << 9, // For internal use by BeginChild()
  384. ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 10, // For internal use by BeginChild()
  385. ImGuiWindowFlags_ChildWindowAutoFitY = 1 << 11, // For internal use by BeginChild()
  386. ImGuiWindowFlags_ComboBox = 1 << 12, // For internal use by ComboBox()
  387. ImGuiWindowFlags_Tooltip = 1 << 13, // For internal use by BeginTooltip()
  388. ImGuiWindowFlags_Popup = 1 << 14 // For internal use by BeginPopup()
  389. };
  390. // Flags for ImGui::InputText()
  391. enum ImGuiInputTextFlags_
  392. {
  393. // Default: 0
  394. ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
  395. ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
  396. ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z
  397. ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs
  398. ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus
  399. ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
  400. ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Call user function on pressing TAB (for completion handling)
  401. ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Call user function on pressing Up/Down arrows (for history handling)
  402. ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Call user function every time
  403. ImGuiInputTextFlags_CallbackCharFilter = 1 << 9 // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
  404. };
  405. // User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
  406. enum ImGuiKey_
  407. {
  408. ImGuiKey_Tab,
  409. ImGuiKey_LeftArrow,
  410. ImGuiKey_RightArrow,
  411. ImGuiKey_UpArrow,
  412. ImGuiKey_DownArrow,
  413. ImGuiKey_Home,
  414. ImGuiKey_End,
  415. ImGuiKey_Delete,
  416. ImGuiKey_Backspace,
  417. ImGuiKey_Enter,
  418. ImGuiKey_Escape,
  419. ImGuiKey_A, // for CTRL+A: select all
  420. ImGuiKey_C, // for CTRL+C: copy
  421. ImGuiKey_V, // for CTRL+V: paste
  422. ImGuiKey_X, // for CTRL+X: cut
  423. ImGuiKey_Y, // for CTRL+Y: redo
  424. ImGuiKey_Z, // for CTRL+Z: undo
  425. ImGuiKey_COUNT
  426. };
  427. // Enumeration for PushStyleColor() / PopStyleColor()
  428. enum ImGuiCol_
  429. {
  430. ImGuiCol_Text,
  431. ImGuiCol_WindowBg,
  432. ImGuiCol_ChildWindowBg,
  433. ImGuiCol_Border,
  434. ImGuiCol_BorderShadow,
  435. ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input
  436. ImGuiCol_TitleBg,
  437. ImGuiCol_TitleBgCollapsed,
  438. ImGuiCol_ScrollbarBg,
  439. ImGuiCol_ScrollbarGrab,
  440. ImGuiCol_ScrollbarGrabHovered,
  441. ImGuiCol_ScrollbarGrabActive,
  442. ImGuiCol_ComboBg,
  443. ImGuiCol_CheckHovered,
  444. ImGuiCol_CheckActive,
  445. ImGuiCol_CheckMark,
  446. ImGuiCol_SliderGrab,
  447. ImGuiCol_SliderGrabActive,
  448. ImGuiCol_Button,
  449. ImGuiCol_ButtonHovered,
  450. ImGuiCol_ButtonActive,
  451. ImGuiCol_Header,
  452. ImGuiCol_HeaderHovered,
  453. ImGuiCol_HeaderActive,
  454. ImGuiCol_Column,
  455. ImGuiCol_ColumnHovered,
  456. ImGuiCol_ColumnActive,
  457. ImGuiCol_ResizeGrip,
  458. ImGuiCol_ResizeGripHovered,
  459. ImGuiCol_ResizeGripActive,
  460. ImGuiCol_CloseButton,
  461. ImGuiCol_CloseButtonHovered,
  462. ImGuiCol_CloseButtonActive,
  463. ImGuiCol_PlotLines,
  464. ImGuiCol_PlotLinesHovered,
  465. ImGuiCol_PlotHistogram,
  466. ImGuiCol_PlotHistogramHovered,
  467. ImGuiCol_TextSelectedBg,
  468. ImGuiCol_TooltipBg,
  469. ImGuiCol_COUNT
  470. };
  471. // Enumeration for PushStyleVar() / PopStyleVar()
  472. // NB: the enum only refers to fields of ImGuiStyle() which makes sense to be pushed/poped in UI code. Feel free to add others.
  473. enum ImGuiStyleVar_
  474. {
  475. ImGuiStyleVar_Alpha, // float
  476. ImGuiStyleVar_WindowPadding, // ImVec2
  477. ImGuiStyleVar_WindowRounding, // float
  478. ImGuiStyleVar_ChildWindowRounding, // float
  479. ImGuiStyleVar_FramePadding, // ImVec2
  480. ImGuiStyleVar_FrameRounding, // float
  481. ImGuiStyleVar_ItemSpacing, // ImVec2
  482. ImGuiStyleVar_ItemInnerSpacing, // ImVec2
  483. ImGuiStyleVar_IndentSpacing, // float
  484. ImGuiStyleVar_GrabMinSize // float
  485. };
  486. // Enumeration for ColorEditMode()
  487. enum ImGuiColorEditMode_
  488. {
  489. ImGuiColorEditMode_UserSelect = -2,
  490. ImGuiColorEditMode_UserSelectShowButton = -1,
  491. ImGuiColorEditMode_RGB = 0,
  492. ImGuiColorEditMode_HSV = 1,
  493. ImGuiColorEditMode_HEX = 2
  494. };
  495. // Enumeration for GetMouseCursor()
  496. enum ImGuiMouseCursor_
  497. {
  498. ImGuiMouseCursor_Arrow = 0,
  499. ImGuiMouseCursor_TextInput,
  500. ImGuiMouseCursor_Move, // Unused by ImGui
  501. ImGuiMouseCursor_ResizeNS, // Unused by ImGui
  502. ImGuiMouseCursor_ResizeEW, // Unused by ImGui
  503. ImGuiMouseCursor_ResizeNESW, // Unused by ImGui
  504. ImGuiMouseCursor_ResizeNWSE,
  505. ImGuiMouseCursor_Count_
  506. };
  507. // Condition flags for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
  508. // All those functions treat 0 as a shortcut to ImGuiSetCond_Always
  509. enum ImGuiSetCond_
  510. {
  511. ImGuiSetCond_Always = 1 << 0, // Set the variable
  512. ImGuiSetCond_Once = 1 << 1, // Only set the variable on the first call per runtime session
  513. ImGuiSetCond_FirstUseEver = 1 << 2 // Only set the variable if the window doesn't exist in the .ini file
  514. };
  515. struct ImGuiStyle
  516. {
  517. float Alpha; // Global alpha applies to everything in ImGui
  518. ImVec2 WindowPadding; // Padding within a window
  519. ImVec2 WindowMinSize; // Minimum window size
  520. float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows
  521. float ChildWindowRounding; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows
  522. ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets)
  523. float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
  524. ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines
  525. ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
  526. ImVec2 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!
  527. ImVec2 AutoFitPadding; // Extra space after auto-fit (double-clicking on resize grip)
  528. float WindowFillAlphaDefault; // Default alpha of window background, if not specified in ImGui::Begin()
  529. float IndentSpacing; // Horizontal indentation when e.g. entering a tree node
  530. float ColumnsMinSpacing; // Minimum horizontal spacing between two columns
  531. float ScrollbarWidth; // Width of the vertical scrollbar
  532. float GrabMinSize; // Minimum width/height of a slider or scrollbar grab
  533. ImVec2 DisplaySafeAreaPadding; // Window positions are clamped to be visible within the display area. If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding.
  534. ImVec4 Colors[ImGuiCol_COUNT];
  535. IMGUI_API ImGuiStyle();
  536. };
  537. // This is where your app communicate with ImGui. Call ImGui::GetIO() to access.
  538. // Read 'Programmer guide' section in .cpp file for general usage.
  539. struct ImGuiIO
  540. {
  541. //------------------------------------------------------------------
  542. // Settings (fill once) // Default value:
  543. //------------------------------------------------------------------
  544. ImVec2 DisplaySize; // <unset> // Display size, in pixels. For clamping windows positions.
  545. float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
  546. float IniSavingRate; // = 5.0f // Maximum time between saving positions/sizes to .ini file, in seconds.
  547. const char* IniFilename; // = "imgui.ini" // Path to .ini file. NULL to disable .ini saving.
  548. const char* LogFilename; // = "imgui_log.txt" // Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
  549. float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
  550. float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
  551. float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging
  552. int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
  553. void* UserData; // = NULL // Store your own data for retrieval by callbacks.
  554. ImFontAtlas* Fonts; // <auto> // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
  555. float FontGlobalScale; // = 1.0f // Global scale all fonts
  556. bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
  557. ImVec2 DisplayVisibleMin; // <unset> (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
  558. ImVec2 DisplayVisibleMax; // <unset> (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
  559. //------------------------------------------------------------------
  560. // User Functions
  561. //------------------------------------------------------------------
  562. // REQUIRED: rendering function.
  563. // See example code if you are unsure of how to implement this.
  564. void (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count);
  565. // Optional: access OS clipboard
  566. // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
  567. const char* (*GetClipboardTextFn)();
  568. void (*SetClipboardTextFn)(const char* text);
  569. // Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer.
  570. // (default to posix malloc/free)
  571. void* (*MemAllocFn)(size_t sz);
  572. void (*MemFreeFn)(void* ptr);
  573. // Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows)
  574. // (default to use native imm32 api on Windows)
  575. void (*ImeSetInputScreenPosFn)(int x, int y);
  576. void* ImeWindowHandle; // (Windows) Set this to your HWND to get automatic IME cursor positioning.
  577. //------------------------------------------------------------------
  578. // Input - Fill before calling NewFrame()
  579. //------------------------------------------------------------------
  580. ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
  581. bool MouseDown[5]; // Mouse buttons. ImGui itself only uses button 0 (left button). Others buttons allows to track if mouse is being used by your application + available to user as a convenience via IsMouse** API.
  582. float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text.
  583. bool MouseDrawCursor; // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
  584. bool KeyCtrl; // Keyboard modifier pressed: Control
  585. bool KeyShift; // Keyboard modifier pressed: Shift
  586. bool KeyAlt; // Keyboard modifier pressed: Alt
  587. bool KeysDown[512]; // Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data)
  588. ImWchar InputCharacters[16+1]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
  589. // Function
  590. IMGUI_API void AddInputCharacter(ImWchar c); // Helper to add a new character into InputCharacters[]
  591. //------------------------------------------------------------------
  592. // Output - Retrieve after calling NewFrame(), you can use them to discard inputs or hide them from the rest of your application
  593. //------------------------------------------------------------------
  594. bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
  595. bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input)
  596. float Framerate; // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames
  597. //------------------------------------------------------------------
  598. // [Internal] ImGui will maintain those fields for you
  599. //------------------------------------------------------------------
  600. ImVec2 MousePosPrev; // Previous mouse position
  601. ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are negative to allow mouse enabling/disabling.
  602. bool MouseClicked[5]; // Mouse button went from !Down to Down
  603. ImVec2 MouseClickedPos[5]; // Position at time of clicking
  604. float MouseClickedTime[5]; // Time of last click (used to figure out double-click)
  605. bool MouseDoubleClicked[5]; // Has mouse button been double-clicked?
  606. bool MouseDownOwned[5]; // Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds.
  607. float MouseDownTime[5]; // Time the mouse button has been down
  608. float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the click point
  609. float KeysDownTime[512]; // Time the keyboard key has been down
  610. IMGUI_API ImGuiIO();
  611. };
  612. //-----------------------------------------------------------------------------
  613. // Helpers
  614. //-----------------------------------------------------------------------------
  615. // Helper: execute a block of code once a frame only
  616. // Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
  617. // Usage:
  618. // IMGUI_ONCE_UPON_A_FRAME
  619. // {
  620. // // code block will be executed one per frame
  621. // }
  622. // Attention! the macro expands into 2 statement so make sure you don't use it within e.g. an if() statement without curly braces.
  623. #define IMGUI_ONCE_UPON_A_FRAME static ImGuiOnceUponAFrame imgui_oaf##__LINE__; if (imgui_oaf##__LINE__)
  624. struct ImGuiOnceUponAFrame
  625. {
  626. ImGuiOnceUponAFrame() { RefFrame = -1; }
  627. mutable int RefFrame;
  628. operator bool() const { const int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; }
  629. };
  630. // Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
  631. struct ImGuiTextFilter
  632. {
  633. struct TextRange
  634. {
  635. const char* b;
  636. const char* e;
  637. TextRange() { b = e = NULL; }
  638. TextRange(const char* _b, const char* _e) { b = _b; e = _e; }
  639. const char* begin() const { return b; }
  640. const char* end() const { return e; }
  641. bool empty() const { return b == e; }
  642. char front() const { return *b; }
  643. static bool isblank(char c) { return c == ' ' || c == '\t'; }
  644. void trim_blanks() { while (b < e && isblank(*b)) b++; while (e > b && isblank(*(e-1))) e--; }
  645. IMGUI_API void split(char separator, ImVector<TextRange>& out);
  646. };
  647. char InputBuf[256];
  648. ImVector<TextRange> Filters;
  649. int CountGrep;
  650. ImGuiTextFilter(const char* default_filter = "");
  651. void Clear() { InputBuf[0] = 0; Build(); }
  652. void Draw(const char* label = "Filter (inc,-exc)", float width = -1.0f); // Helper calling InputText+Build
  653. bool PassFilter(const char* val) const;
  654. bool IsActive() const { return !Filters.empty(); }
  655. IMGUI_API void Build();
  656. };
  657. // Helper: Text buffer for logging/accumulating text
  658. struct ImGuiTextBuffer
  659. {
  660. ImVector<char> Buf;
  661. ImGuiTextBuffer() { Buf.push_back(0); }
  662. const char* begin() const { return &Buf.front(); }
  663. const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator
  664. size_t size() const { return Buf.size()-1; }
  665. bool empty() { return size() >= 1; }
  666. void clear() { Buf.clear(); Buf.push_back(0); }
  667. IMGUI_API void append(const char* fmt, ...);
  668. IMGUI_API void appendv(const char* fmt, va_list args);
  669. };
  670. // Helper: Key->value storage
  671. // - Store collapse state for a tree (Int 0/1)
  672. // - Store color edit options (Int using values in ImGuiColorEditMode enum).
  673. // - Custom user storage for temporary values.
  674. // Typically you don't have to worry about this since a storage is held within each Window.
  675. // Declare your own storage if:
  676. // - 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).
  677. // - You want to store custom debug data easily without adding or editing structures in your code.
  678. struct ImGuiStorage
  679. {
  680. struct Pair
  681. {
  682. ImGuiID key;
  683. union { int val_i; float val_f; void* val_p; };
  684. Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; }
  685. Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; }
  686. Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; }
  687. };
  688. ImVector<Pair> Data;
  689. // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
  690. // - Set***() functions find pair, insertion on demand if missing.
  691. // - Sorted insertion is costly but should amortize. A typical frame shouldn't need to insert any new pair.
  692. IMGUI_API void Clear();
  693. IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const;
  694. IMGUI_API void SetInt(ImGuiID key, int val);
  695. IMGUI_API float GetFloat(ImGuiID key, float default_val = 0.0f) const;
  696. IMGUI_API void SetFloat(ImGuiID key, float val);
  697. IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL
  698. IMGUI_API void SetVoidPtr(ImGuiID key, void* val);
  699. // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set.
  700. // - 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.
  701. // - A typical use case where this is convenient:
  702. // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
  703. // - You can also use this to quickly create temporary editable values during a session of using Edit&Continue, without restarting your application.
  704. IMGUI_API int* GetIntRef(ImGuiID key, int default_val = 0);
  705. IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0);
  706. // Use on your own storage if you know only integer are being stored (open/close all tree nodes)
  707. IMGUI_API void SetAllInt(int val);
  708. };
  709. // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
  710. struct ImGuiTextEditCallbackData
  711. {
  712. ImGuiInputTextFlags EventFlag; // One of ImGuiInputTextFlags_Callback* // Read-only
  713. ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only
  714. void* UserData; // What user passed to InputText() // Read-only
  715. // CharFilter event:
  716. ImWchar EventChar; // Character input // Read-write (replace character or set to zero)
  717. // Completion,History,Always events:
  718. ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only
  719. char* Buf; // Current text // Read-write (pointed data only)
  720. size_t BufSize; // // Read-only
  721. bool BufDirty; // Set if you modify Buf directly // Write
  722. int CursorPos; // // Read-write
  723. int SelectionStart; // // Read-write (== to SelectionEnd when no selection)
  724. int SelectionEnd; // // Read-write
  725. // NB: calling those function loses selection.
  726. void DeleteChars(int pos, int bytes_count);
  727. void InsertChars(int pos, const char* text, const char* text_end = NULL);
  728. };
  729. // ImColor() is just a helper that implicity converts to either ImU32 (packed 4x1 byte) or ImVec4 (4x1 float)
  730. // None of the ImGui API are using ImColor directly but you can use it as a convenience to pass colors in either formats.
  731. struct ImColor
  732. {
  733. ImVec4 Value;
  734. ImColor(int r, int g, int b, int a = 255) { Value.x = (float)r / 255.0f; Value.y = (float)g / 255.0f; Value.z = (float)b / 255.0f; Value.w = (float)a / 255.0f; }
  735. ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
  736. ImColor(const ImVec4& col) { Value = col; }
  737. operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
  738. operator ImVec4() const { return Value; }
  739. static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); }
  740. };
  741. //-----------------------------------------------------------------------------
  742. // Draw List
  743. // Hold a series of drawing commands. The user provides a renderer for ImDrawList.
  744. //-----------------------------------------------------------------------------
  745. // Draw callbacks for advanced uses.
  746. // NB- You most likely DO NOT need to care about draw callbacks just to create your own widget or customized UI rendering (you can poke into the draw list for that)
  747. // Draw callback are useful for example if you want to render a complex 3D scene inside a UI element.
  748. // The expected behavior from your rendering loop is:
  749. // if (cmd.user_callback != NULL)
  750. // cmd.user_callback(parent_list, cmd);
  751. // else
  752. // RenderTriangles()
  753. // It is up to you to decide if your rendering loop or the callback should be responsible for backup/restoring rendering state.
  754. typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd);
  755. // Typically, 1 command = 1 gpu draw call (unless command is a callback)
  756. struct ImDrawCmd
  757. {
  758. unsigned int vtx_count; // Number of vertices (multiple of 3) to be drawn as triangles. The vertices are stored in the callee ImDrawList's vtx_buffer[] array.
  759. ImVec4 clip_rect; // Clipping rectangle (x1, y1, x2, y2)
  760. ImTextureID texture_id; // 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.
  761. ImDrawCallback user_callback; // If != NULL, call the function instead of rendering the vertices. vtx_count will be 0. clip_rect and texture_id will be set normally.
  762. void* user_callback_data; // The draw callback code can access this.
  763. };
  764. // Vertex layout
  765. #ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
  766. struct ImDrawVert
  767. {
  768. ImVec2 pos;
  769. ImVec2 uv;
  770. ImU32 col;
  771. };
  772. #else
  773. // You can change the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h
  774. // The code expect ImVec2 pos (8 bytes), ImVec2 uv (8 bytes), ImU32 col (4 bytes), but you can re-order them or add other fields as needed to simplify integration in your engine.
  775. // The type has to be described by the #define (you can either declare the struct or use a typedef)
  776. IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT;
  777. #endif
  778. // Draw command list
  779. // This is the low-level list of polygons that ImGui functions are filling. At the end of the frame, all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering.
  780. // At the moment, each ImGui window contains its own ImDrawList but they could potentially be merged in the future.
  781. // If you want to add custom rendering within a window, you can use ImGui::GetWindowDrawList() to access the current draw list and add your own primitives.
  782. // You can interleave normal ImGui:: calls and adding primitives to the current draw list.
  783. // Note that this only gives you access to rendering polygons. If your intent is to create custom widgets and the publicly exposed functions/data aren't sufficient, you can add code in imgui_user.inl
  784. struct ImDrawList
  785. {
  786. // This is what you have to render
  787. ImVector<ImDrawCmd> commands; // Commands. Typically 1 command = 1 gpu draw call.
  788. ImVector<ImDrawVert> vtx_buffer; // Vertex buffer. Each command consume ImDrawCmd::vtx_count of those
  789. // [Internal to ImGui]
  790. ImVector<ImVec4> clip_rect_stack; // [Internal]
  791. ImVector<ImTextureID> texture_id_stack; // [Internal]
  792. ImDrawVert* vtx_write; // [Internal] point within vtx_buffer after each add command (to avoid using the ImVector<> operators too much)
  793. ImDrawList() { Clear(); }
  794. IMGUI_API void Clear();
  795. IMGUI_API void ClearFreeMemory();
  796. IMGUI_API void PushClipRect(const ImVec4& clip_rect); // Scissoring. The values are x1, y1, x2, y2.
  797. IMGUI_API void PushClipRectFullScreen();
  798. IMGUI_API void PopClipRect();
  799. IMGUI_API void PushTextureID(const ImTextureID& texture_id);
  800. IMGUI_API void PopTextureID();
  801. // Primitives
  802. IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
  803. IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners=0x0F);
  804. IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners=0x0F);
  805. IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col);
  806. IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
  807. IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
  808. IMGUI_API void AddArc(const ImVec2& center, float rad, ImU32 col, int a_min, int a_max, bool tris = false, const ImVec2& third_point_offset = ImVec2(0,0));
  809. IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec2* cpu_clip_max = NULL);
  810. IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
  811. // Advanced
  812. IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'user_callback' in ImDrawCmd and call the function instead of rendering triangles.
  813. IMGUI_API 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
  814. // Internal helpers
  815. IMGUI_API void ReserveVertices(unsigned int vtx_count);
  816. IMGUI_API void AddVtx(const ImVec2& pos, ImU32 col);
  817. IMGUI_API void AddVtxUV(const ImVec2& pos, ImU32 col, const ImVec2& uv);
  818. IMGUI_API void AddVtxLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
  819. IMGUI_API void UpdateClipRect();
  820. IMGUI_API void UpdateTextureID();
  821. };
  822. // Load and rasterize multiple TTF fonts into a same texture.
  823. // Sharing a texture for multiple fonts allows us to reduce the number of draw calls during rendering.
  824. // We also add custom graphic data into the texture that serves for ImGui.
  825. // 1. (Optional) Call AddFont*** functions. If you don't call any, the default font will be loaded for you.
  826. // 2. Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
  827. // 3. Upload the pixels data into a texture within your graphics system.
  828. // 4. Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture. This value will be passed back to you during rendering to identify the texture.
  829. // 5. Call ClearPixelsData() to free textures memory on the heap.
  830. struct ImFontAtlas
  831. {
  832. IMGUI_API ImFontAtlas();
  833. IMGUI_API ~ImFontAtlas();
  834. IMGUI_API ImFont* AddFontDefault();
  835. IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0);
  836. IMGUI_API ImFont* AddFontFromMemoryTTF(void* in_ttf_data, size_t in_ttf_data_size, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); // Pass ownership of 'in_ttf_data' memory.
  837. IMGUI_API void ClearTexData(); // Saves RAM once the texture has been copied to graphics memory.
  838. IMGUI_API void Clear();
  839. // Retrieve texture data
  840. // User is in charge of copying the pixels into graphics memory, then call SetTextureUserID()
  841. // After loading the texture into your graphic system, store your texture handle in 'TexID' (ignore if you aren't using multiple fonts nor images)
  842. // RGBA32 format is provided for convenience and high compatibility, but note that all RGB pixels are white, so 75% of the memory is wasted.
  843. // Pitch = Width * BytesPerPixels
  844. IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
  845. IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
  846. IMGUI_API void SetTexID(void* id) { TexID = id; }
  847. // Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list)
  848. // (Those functions could be static but aren't so most users don't have to refer to the ImFontAtlas:: name ever if in their code; just using io.Fonts->)
  849. IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin
  850. IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs
  851. IMGUI_API const ImWchar* GetGlyphRangesChinese(); // Japanese + full set of about 21000 CJK Unified Ideographs
  852. // Members
  853. // (Access texture data via GetTexData*() calls which will setup a default font for you.)
  854. void* TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It ia passed back to you during rendering.
  855. unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
  856. unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
  857. int TexWidth;
  858. int TexHeight;
  859. ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel (part of the TexExtraData block)
  860. ImVector<ImFont*> Fonts;
  861. // Private
  862. struct ImFontAtlasData;
  863. ImVector<ImFontAtlasData*> InputData; // Internal data
  864. IMGUI_API bool Build(); // Build pixels data. This is automatically for you by the GetTexData*** functions.
  865. IMGUI_API void ClearInputData(); // Clear the input TTF data.
  866. IMGUI_API void RenderCustomTexData(int pass, void* rects);
  867. };
  868. // TTF font loading and rendering
  869. // ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
  870. // Kerning isn't supported. At the moment some ImGui code does per-character CalcTextSize calls, need something more state-ful.
  871. struct ImFont
  872. {
  873. // Members: Settings
  874. float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
  875. float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
  876. ImVec2 DisplayOffset; // = (0.0f,0.0f) // Offset font rendering by xx pixels
  877. ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
  878. // Members: Runtime data
  879. struct Glyph
  880. {
  881. ImWchar Codepoint;
  882. signed short XAdvance;
  883. signed short Width, Height;
  884. signed short XOffset, YOffset;
  885. float U0, V0, U1, V1; // Texture coordinates
  886. };
  887. ImFontAtlas* ContainerAtlas; // What we has been loaded into
  888. ImVector<Glyph> Glyphs;
  889. const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
  890. float FallbackXAdvance; //
  891. ImVector<float> IndexXAdvance; // Glyphs->XAdvance directly indexable (for CalcTextSize functions which are often bottleneck in large UI)
  892. ImVector<int> IndexLookup; // Index glyphs by Unicode code-point
  893. // Methods
  894. IMGUI_API ImFont();
  895. IMGUI_API ~ImFont() { Clear(); }
  896. IMGUI_API void Clear();
  897. IMGUI_API void BuildLookupTable();
  898. IMGUI_API const Glyph* FindGlyph(unsigned short c) const;
  899. IMGUI_API void SetFallbackChar(ImWchar c);
  900. IMGUI_API bool IsLoaded() const { return ContainerAtlas != NULL; }
  901. // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
  902. // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
  903. IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
  904. IMGUI_API ImVec2 CalcTextSizeW(float size, float max_width, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL) const; // wchar
  905. IMGUI_API void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices, float wrap_width = 0.0f, const ImVec2* cpu_clip_max = NULL) const;
  906. IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
  907. };
  908. //---- Include imgui_user.h at the end of imgui.h
  909. //---- So you can include code that extends ImGui using any of the types declared above.
  910. //---- (also convenient for user to only explicitly include vanilla imgui.h)
  911. #ifdef IMGUI_INCLUDE_IMGUI_USER_H
  912. #include "imgui_user.h"
  913. #endif