structImFontConfig;// Configuration data when adding a font or merging fonts
structImColor;// Helper functions to create a color that can be converted to either u32 or float4
structImGuiIO;// Main configuration and I/O between your application and ImGui
structImGuiOnceUponAFrame;// Simple helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro
structImGuiStorage;// Simple custom key value storage
structImGuiStyle;// Runtime data for styling/colors
structImGuiTextFilter;// Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
structImGuiTextBuffer;// Text buffer for logging/accumulating text
structImGuiTextEditCallbackData;// Shared state of ImGui::InputText() when using custom ImGuiTextEditCallback (rare/advanced use)
structImGuiSizeConstraintCallbackData;// Structure used to constraint window size in custom ways when using custom ImGuiSizeConstraintCallback (rare/advanced use)
structImGuiListClipper;// Helper to manually clip large list of items
// class ImVector<> // Lightweight std::vector like class.
// 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)
structImVec2
{
floatx,y;
ImVec2(){x=y=0.0f;}
ImVec2(float_x,float_y){x=_x;y=_y;}
#ifdef IM_VEC2_CLASS_EXTRA // Define constructor and implicit cast operators in imconfig.h to convert back<>forth from your math types and ImVec2.
#ifdef IM_VEC4_CLASS_EXTRA // Define constructor and implicit cast operators in imconfig.h to convert back<>forth from your math types and ImVec4.
IM_VEC4_CLASS_EXTRA
#endif
};
// ImGui end-user API
// In a namespace so that user can add extra functions in a separate file (e.g. Value() helpers for your vector or common types)
namespaceImGui
{
// Main
IMGUI_APIImGuiIO&GetIO();
IMGUI_APIImGuiStyle&GetStyle();
IMGUI_APIImDrawData*GetDrawData();// same value as passed to your io.RenderDrawListsFn() function. valid after Render() and until the next call to NewFrame()
IMGUI_APIvoidNewFrame();// start a new ImGui frame, you can submit any command from this point until Render()/EndFrame().
IMGUI_APIvoidRender();// ends the ImGui frame, finalize the draw data, then call your io.RenderDrawListsFn() function if set.
IMGUI_APIvoidEndFrame();// ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead!
IMGUI_APIvoidShowDemoWindow(bool*p_open=NULL);// create demo/test window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
IMGUI_APIvoidShowStyleEditor(ImGuiStyle*ref=NULL);// add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
IMGUI_APIboolShowStyleSelector(constchar*label);
IMGUI_APIvoidShowFontSelector(constchar*label);
IMGUI_APIvoidShowUserGuide();// add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
IMGUI_APIboolBegin(constchar*name,bool*p_open=NULL,ImGuiWindowFlagsflags=0);// push window to the stack and start appending to it. see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_open' creates a widget on the upper-right to close the window (which sets your bool to false).
IMGUI_APIvoidEnd();// finish appending to current window, pop it off the window stack.
IMGUI_APIboolBeginChild(constchar*str_id,constImVec2&size=ImVec2(0,0),boolborder=false,ImGuiWindowFlagsextra_flags=0);// begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400).
IMGUI_APIImVec2GetContentRegionMax();// current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
IMGUI_APIImVec2GetWindowContentRegionMin();// content boundaries min (roughly (0,0)-Scroll), in window coordinates
IMGUI_APIImVec2GetWindowContentRegionMax();// content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
IMGUI_APIfloatGetWindowContentRegionWidth();//
IMGUI_APIImDrawList*GetWindowDrawList();// get rendering command-list if you want to append your own draw primitives
IMGUI_APIImVec2GetWindowPos();// get current window position in screen space (useful if you want to do your own drawing via the DrawList api)
IMGUI_APIImVec2GetWindowSize();// get current window size
IMGUI_APIvoidSetNextWindowPos(constImVec2&pos,ImGuiCondcond=0,constImVec2&pivot=ImVec2(0,0));// set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
IMGUI_APIvoidSetNextWindowSize(constImVec2&size,ImGuiCondcond=0);// set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
IMGUI_APIvoidSetNextWindowSizeConstraints(constImVec2&size_min,constImVec2&size_max,ImGuiSizeConstraintCallbackcustom_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. Use callback to apply non-trivial programmatic constraints.
IMGUI_APIvoidSetNextWindowContentSize(constImVec2&size);// set next window content size (~ enforce the range of scrollbars). not including window decorations (title bar, menu bar, etc.). set an axis to 0.0f to leave it automatic. call before Begin()
IMGUI_APIvoidSetNextWindowCollapsed(boolcollapsed,ImGuiCondcond=0);// set next window collapsed state. call before Begin()
IMGUI_APIvoidSetWindowPos(constImVec2&pos,ImGuiCondcond=0);// (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
IMGUI_APIvoidSetWindowSize(constImVec2&size,ImGuiCondcond=0);// (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0,0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
IMGUI_APIvoidSetWindowCollapsed(boolcollapsed,ImGuiCondcond=0);// (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
IMGUI_APIvoidSetWindowPos(constchar*name,constImVec2&pos,ImGuiCondcond=0);// set named window position.
IMGUI_APIvoidSetWindowSize(constchar*name,constImVec2&size,ImGuiCondcond=0);// set named window size. set axis to 0.0f to force an auto-fit on this axis.
IMGUI_APIvoidSetWindowCollapsed(constchar*name,boolcollapsed,ImGuiCondcond=0);// set named window collapsed state
IMGUI_APIvoidSetWindowFocus(constchar*name);// set named window to be focused / front-most. use NULL to remove focus.
IMGUI_APIvoidSetScrollHere(floatcenter_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.
IMGUI_APIvoidSetScrollFromPosY(floatpos_y,floatcenter_y_ratio=0.5f);// adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions.
IMGUI_APIvoidSetStateStorage(ImGuiStorage*tree);// replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it)
IMGUI_APIImGuiStorage*GetStateStorage();
// Parameters stacks (shared)
IMGUI_APIvoidPushFont(ImFont*font);// use NULL as a shortcut to push default font
IMGUI_APIconstImVec4&GetStyleColorVec4(ImGuiColidx);// retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwhise use GetColorU32() to get style color + style alpha.
IMGUI_APIvoidPushItemWidth(floatitem_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 -1.0f always align width to the right side)
IMGUI_APIvoidPopItemWidth();
IMGUI_APIfloatCalcItemWidth();// width of item given pushed settings and current cursor position
IMGUI_APIvoidPushTextWrapPos(floatwrap_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
IMGUI_APIvoidPushAllowKeyboardFocus(boolallow_keyboard_focus);// allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
IMGUI_APIvoidPushButtonRepeat(boolrepeat);// 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.
IMGUI_APIvoidBeginGroup();// lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
IMGUI_APIvoidEndGroup();
IMGUI_APIImVec2GetCursorPos();// cursor position is relative to window position
IMGUI_APIvoidAlignTextToFramePadding();// vertically align/lower upcoming text to FramePadding.y so that it will aligns to upcoming widgets (call if you have text on a line before regular widgets)
IMGUI_APIfloatGetTextLineHeight();// ~ FontSize
IMGUI_APIfloatGetTextLineHeightWithSpacing();// ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)
IMGUI_APIfloatGetColumnWidth(intcolumn_index=-1);// get column width (in pixels). pass -1 to use current column
IMGUI_APIvoidSetColumnWidth(intcolumn_index,floatwidth);// set column width (in pixels). pass -1 to use current column
IMGUI_APIfloatGetColumnOffset(intcolumn_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
IMGUI_APIvoidSetColumnOffset(intcolumn_index,floatoffset_x);// set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
// If you are creating widgets in a loop you most likely want to push a unique identifier (e.g. object pointer, loop index) so ImGui can differentiate them.
// You can also use the "##foobar" syntax within widget label to distinguish them from each others. Read "A primer on the use of labels/IDs" in the FAQ for more details.
IMGUI_APIImGuiIDGetID(constchar*str_id);// calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself
IMGUI_APIvoidTextUnformatted(constchar*text,constchar*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.
IMGUI_APIvoidText(constchar*fmt,...)IM_FMTARGS(1);// simple formatted text
IMGUI_APIvoidTextWrapped(constchar*fmt,...)IM_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().
IMGUI_APIvoidBullet();// draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
IMGUI_APIboolSmallButton(constchar*label);// button with FramePadding=(0,0) to easily embed within text
IMGUI_APIboolInvisibleButton(constchar*str_id,constImVec2&size);// button behavior without the visuals, useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
IMGUI_APIboolCombo(constchar*label,int*current_item,constchar*items_separated_by_zeros,intpopup_max_height_in_items=-1);// Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0"
// For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that 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. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
IMGUI_APIboolDragFloat(constchar*label,float*v,floatv_speed=1.0f,floatv_min=0.0f,floatv_max=0.0f,constchar*display_format="%.3f",floatpower=1.0f);// If v_min >= v_max we have no bound
IMGUI_APIboolDragInt(constchar*label,int*v,floatv_speed=1.0f,intv_min=0,intv_max=0,constchar*display_format="%.0f");// If v_min >= v_max we have no bound
IMGUI_APIboolSliderFloat(constchar*label,float*v,floatv_min,floatv_max,constchar*display_format="%.3f",floatpower=1.0f);// adjust display_format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for logarithmic sliders
// Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little colored preview square that can be left-clicked to open a picker, and right-clicked to open an option menu.)
// Note that 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. You can the pass the address of a first float element out of a contiguous structure, e.g. &myvector.x
IMGUI_APIboolColorButton(constchar*desc_id,constImVec4&col,ImGuiColorEditFlagsflags=0,ImVec2size=ImVec2(0,0));// display a colored square/button, hover for details, return true when pressed.
IMGUI_APIvoidSetColorEditOptions(ImGuiColorEditFlagsflags);// 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.
IMGUI_APIboolTreeNode(constchar*label);// if returning 'true' the node is open and the tree id is pushed into the id stack. user is responsible for calling TreePop().
IMGUI_APIboolTreeNode(constchar*str_id,constchar*fmt,...)IM_FMTARGS(2);// 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().
IMGUI_APIvoidTreePush(constchar*str_id);// ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call Push/Pop yourself for layout purpose
IMGUI_APIvoidTreeAdvanceToLabelPos();// advance cursor x position by GetTreeNodeToLabelSpacing()
IMGUI_APIfloatGetTreeNodeToLabelSpacing();// horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode
IMGUI_APIboolCollapsingHeader(constchar*label,ImGuiTreeNodeFlagsflags=0);// if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop().
IMGUI_APIboolCollapsingHeader(constchar*label,bool*p_open,ImGuiTreeNodeFlagsflags=0);// when 'p_open' isn't NULL, display an additional small close button on upper right of the header
// Widgets: Selectable / Lists
IMGUI_APIboolSelectable(constchar*label,boolselected=false,ImGuiSelectableFlagsflags=0,constImVec2&size=ImVec2(0,0));// 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
IMGUI_APIboolListBoxHeader(constchar*label,constImVec2&size=ImVec2(0,0));// use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards.
// Widgets: Value() Helpers. 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)
IMGUI_APIvoidSetTooltip(constchar*fmt,...)IM_FMTARGS(1);// set text tooltip under mouse-cursor, typically use with ImGui::IsItemHovered(). overidde any previous call to SetTooltip().
IMGUI_APIboolBeginMenuBar();// append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window). only call EndMenuBar() if this returns true!
IMGUI_APIboolBeginMenu(constchar*label,boolenabled=true);// create a sub-menu entry. only call EndMenu() if this returns true!
IMGUI_APIvoidEndMenu();
IMGUI_APIboolMenuItem(constchar*label,constchar*shortcut=NULL,boolselected=false,boolenabled=true);// return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
IMGUI_APIboolMenuItem(constchar*label,constchar*shortcut,bool*p_selected,boolenabled=true);// return true when activated + toggle (*p_selected) if p_selected != NULL
IMGUI_APIvoidOpenPopup(constchar*str_id);// call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
IMGUI_APIboolOpenPopupOnItemClick(constchar*str_id=NULL,intmouse_button=1);// helper to open popup when clicked on last item. return true when just opened.
IMGUI_APIboolBeginPopup(constchar*str_id);// return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returned true!
IMGUI_APIboolBeginPopupModal(constchar*name,bool*p_open=NULL,ImGuiWindowFlagsextra_flags=0);// modal dialog (block interactions behind the modal window, can't close the modal window by clicking outside)
IMGUI_APIboolBeginPopupContextItem(constchar*str_id=NULL,intmouse_button=1);// helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. 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!
IMGUI_APIboolBeginPopupContextWindow(constchar*str_id=NULL,intmouse_button=1,boolalso_over_items=true);// helper to open and begin popup when clicked on current window.
IMGUI_APIboolBeginPopupContextVoid(constchar*str_id=NULL,intmouse_button=1);// helper to open and begin popup when clicked in void (where there are no imgui windows).
IMGUI_APIvoidLogText(constchar*fmt,...)IM_FMTARGS(1);// pass text data straight to log (without being displayed)
// Drag and Drop
// [BETA API] Missing Demo code. API may evolve.
IMGUI_APIboolBeginDragDropSource(ImGuiDragDropFlagsflags=0,intmouse_button=0);// call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource()
IMGUI_APIboolSetDragDropPayload(constchar*type,constvoid*data,size_tsize,ImGuiCondcond=0);// type is a user defined string of maximum 8 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
IMGUI_APIvoidEndDragDropSource();
IMGUI_APIboolBeginDragDropTarget();// call after submitting an item that may receive an item. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget()
IMGUI_APIconstImGuiPayload*AcceptDragDropPayload(constchar*type,ImGuiDragDropFlagsflags=0);// accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released.
// (FIXME: Those functions will be reworked after we merge the navigation branch + have a pass at focusing/tabbing features.)
// (Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHere()" when applicable, to make your code more forward compatible when navigation branch is merged)
IMGUI_APIvoidSetItemDefaultFocus();// make last item the default focused item of a window (WIP navigation branch only). Pleaase use instead of SetScrollHere().
IMGUI_APIvoidSetKeyboardFocusHere(intoffset=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.
IMGUI_APIboolIsItemHovered(ImGuiHoveredFlagsflags=0);// is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options.
IMGUI_APIboolIsItemActive();// is the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false)
IMGUI_APIboolIsItemClicked(intmouse_button=0);// is the last item clicked? (e.g. button/node just clicked on)
IMGUI_APIboolIsItemVisible();// is the last item visible? (aka not out of sight due to clipping/scrolling.)
IMGUI_APIvoidSetItemAllowOverlap();// allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
IMGUI_APIboolIsWindowFocused(ImGuiFocusedFlagsflags=0);// is current window focused? or its root/child, depending on flags. see flags for options.
IMGUI_APIboolIsWindowHovered(ImGuiHoveredFlagsflags=0);// is current window hovered (and typically: not blocked by a popup/modal)? see flags for options.
IMGUI_APIboolIsAnyWindowFocused();
IMGUI_APIboolIsAnyWindowHovered();// is mouse hovering any visible window
IMGUI_APIboolIsRectVisible(constImVec2&size);// test if rectangle (of given size, starting from cursor position) is visible / not clipped.
IMGUI_APIboolIsRectVisible(constImVec2&rect_min,constImVec2&rect_max);// test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
IMGUI_APIImVec2CalcItemRectClosestPoint(constImVec2&pos,boolon_edge=false,floatoutward=+0.0f);// utility to find the closest point the last item bounding rectangle edge. useful to visually link items
IMGUI_APIvoidCalcListClipping(intitems_count,floatitems_height,int*out_items_display_start,int*out_items_display_end);// calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can.
IMGUI_APIboolBeginChildFrame(ImGuiIDid,constImVec2&size,ImGuiWindowFlagsextra_flags=0);// helper to create a child window / scrolling region that looks like a normal widget frame
IMGUI_APIintGetKeyIndex(ImGuiKeyimgui_key);// map ImGuiKey_* values into user's key index. == io.KeyMap[key]
IMGUI_APIboolIsKeyDown(intuser_key_index);// is key being held. == io.KeysDown[user_key_index]. note that imgui doesn't know the semantic of each entry of io.KeyDown[]. Use your own indices/enums according to how your backend/engine stored them into KeyDown[]!
IMGUI_APIboolIsKeyPressed(intuser_key_index,boolrepeat=true);// was key pressed (went from !Down to Down). if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
IMGUI_APIboolIsKeyReleased(intuser_key_index);// was key released (went from Down to !Down)..
IMGUI_APIintGetKeyPressedAmount(intkey_index,floatrepeat_delay,floatrate);// 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
IMGUI_APIboolIsMouseDown(intbutton);// is mouse button held
IMGUI_APIboolIsMouseClicked(intbutton,boolrepeat=false);// did mouse button clicked (went from !Down to Down)
IMGUI_APIboolIsMouseDoubleClicked(intbutton);// did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
IMGUI_APIboolIsMouseReleased(intbutton);// did mouse button released (went from Down to !Down)
IMGUI_APIboolIsMouseDragging(intbutton=0,floatlock_threshold=-1.0f);// is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
IMGUI_APIboolIsMouseHoveringRect(constImVec2&r_min,constImVec2&r_max,boolclip=true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
IMGUI_APIImGuiMouseCursorGetMouseCursor();// get desired cursor type, 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
IMGUI_APIvoidSetMouseCursor(ImGuiMouseCursortype);// set desired cursor type
IMGUI_APIvoidCaptureKeyboardFromApp(boolcapture=true);// manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application handle). e.g. force capture keyboard when your widget is being hovered.
IMGUI_APIvoidCaptureMouseFromApp(boolcapture=true);// manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application handle).
// Helpers functions to access functions pointers in ImGui::GetIO()
IMGUI_APIvoid*MemAlloc(size_tsz);
IMGUI_APIvoidMemFree(void*ptr);
IMGUI_APIconstchar*GetClipboardText();
IMGUI_APIvoidSetClipboardText(constchar*text);
// Internal context access - if you want to use multiple context, share context between modules (e.g. DLL). There is a default context created and active by default.
// All contexts share a same ImFontAtlas by default. If you want different font atlas, you can new() them and overwrite the GetIO().Fonts variable of an ImGui context.
ImGuiWindowFlags_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.
ImGuiWindowFlags_HorizontalScrollbar=1<<11,// Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
ImGuiWindowFlags_NoFocusOnAppearing=1<<12,// Disable taking focus when transitioning from hidden to visible state
ImGuiWindowFlags_NoBringToFrontOnFocus=1<<13,// Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus)
ImGuiWindowFlags_AlwaysVerticalScrollbar=1<<14,// Always show vertical scrollbar (even if ContentSize.y < Size.y)
ImGuiWindowFlags_AlwaysHorizontalScrollbar=1<<15,// Always show horizontal scrollbar (even if ContentSize.x < Size.x)
ImGuiWindowFlags_AlwaysUseWindowPadding=1<<16,// Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
ImGuiWindowFlags_ResizeFromAnySide=1<<17,// (WIP) Enable resize from any corners and borders. Your back-end needs to honor the different values of io.MouseCursor set by imgui.
ImGuiInputTextFlags_CharsUppercase=1<<2,// Turn a..z into A..Z
ImGuiInputTextFlags_CharsNoBlank=1<<3,// Filter out spaces, tabs
ImGuiInputTextFlags_AutoSelectAll=1<<4,// Select entire text when first taking mouse focus
ImGuiInputTextFlags_EnterReturnsTrue=1<<5,// Return 'true' when Enter is pressed (as opposed to when the value was modified)
ImGuiInputTextFlags_CallbackCompletion=1<<6,// Call user function on pressing TAB (for completion handling)
ImGuiInputTextFlags_CallbackHistory=1<<7,// Call user function on pressing Up/Down arrows (for history handling)
ImGuiInputTextFlags_CallbackAlways=1<<8,// Call user function every time. User code may query cursor position, modify text buffer.
ImGuiInputTextFlags_CallbackCharFilter=1<<9,// Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
ImGuiInputTextFlags_AllowTabInput=1<<10,// Pressing TAB input a '\t' character into the text field
ImGuiInputTextFlags_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).
ImGuiInputTextFlags_NoHorizontalScroll=1<<12,// Disable following the cursor horizontally
ImGuiInputTextFlags_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().
ImGuiTreeNodeFlags_NoTreePushOnOpen=1<<3,// Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack
ImGuiTreeNodeFlags_NoAutoOpenOnLog=1<<4,// Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes)
ImGuiTreeNodeFlags_DefaultOpen=1<<5,// Default node to be open
ImGuiTreeNodeFlags_OpenOnDoubleClick=1<<6,// Need double-click to open node
ImGuiTreeNodeFlags_OpenOnArrow=1<<7,// Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
ImGuiTreeNodeFlags_Leaf=1<<8,// No collapsing, no arrow (use as a convenience for leaf nodes).
ImGuiTreeNodeFlags_Bullet=1<<9,// Display a bullet instead of arrow
ImGuiTreeNodeFlags_FramePadding=1<<10,// Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding().
//ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 11, // FIXME: TODO: Extend hit box horizontally even if not framed
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 12, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
ImGuiComboFlags_PopupAlignLeft=1<<0,// Align the popup toward the left by default
ImGuiComboFlags_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()
ImGuiComboFlags_HeightRegular=1<<2,// Max ~8 items visible (default)
ImGuiComboFlags_HeightLarge=1<<3,// Max ~20 items visible
ImGuiComboFlags_HeightLargest=1<<4,// As many fitting items as possible
// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
enumImGuiHoveredFlags_
{
ImGuiHoveredFlags_Default=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.
ImGuiHoveredFlags_ChildWindows=1<<0,// IsWindowHovered() only: Return true if any children of the window is hovered
ImGuiHoveredFlags_RootWindow=1<<1,// IsWindowHovered() only: Test from root window (top most parent of the current hierarchy)
ImGuiHoveredFlags_AllowWhenBlockedByPopup=1<<2,// Return true even if a popup window is normally blocking access to this item/window
//ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 3, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem=1<<4,// Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
ImGuiHoveredFlags_AllowWhenOverlapped=1<<5,// Return true even if the position is overlapped by another window
// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()
enumImGuiDragDropFlags_
{
// BeginDragDropSource() flags
ImGuiDragDropFlags_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 disable this behavior.
ImGuiDragDropFlags_SourceNoDisableHover=1<<1,// By default, when dragging we clear data so that IsItemHovered() will return true, to avoid subsequent user code submitting tooltips. This flag disable this behavior so you can still call IsItemHovered() on the source item.
ImGuiDragDropFlags_SourceNoHoldToOpenOthers=1<<2,// Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item.
ImGuiDragDropFlags_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.
ImGuiDragDropFlags_SourceExtern=1<<4,// External source (from outside of imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously.
// AcceptDragDropPayload() flags
ImGuiDragDropFlags_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.
ImGuiDragDropFlags_AcceptNoDrawDefaultRect=1<<11,// Do not draw the default highlight rectangle when hovering over target.
ImGuiDragDropFlags_AcceptPeekOnly=ImGuiDragDropFlags_AcceptBeforeDelivery|ImGuiDragDropFlags_AcceptNoDrawDefaultRect// For peeking ahead and inspecting the payload before delivery.
};
// Standard Drag and Drop payload types. You can define you own payload types using 8-characters long strings. Types starting with '_' are defined by Dear ImGui.
#define IMGUI_PAYLOAD_TYPE_COLOR_3F "_COL3F" // float[3] // Standard type for colors, without alpha. User code may use this type.
#define IMGUI_PAYLOAD_TYPE_COLOR_4F "_COL4F" // float[4] // Standard type for colors. User code may use this type.
// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure.
// NB: the enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code. During initialization, feel free to just poke into ImGuiStyle directly.
// NB: if changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
ImGuiColorEditFlags_NoAlpha=1<<1,// // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (read 3 components from the input pointer).
ImGuiColorEditFlags_NoPicker=1<<2,// // ColorEdit: disable picker when clicking on colored square.
ImGuiColorEditFlags_NoOptions=1<<3,// // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview.
ImGuiColorEditFlags_NoSmallPreview=1<<4,// // ColorEdit, ColorPicker: disable colored square preview next to the inputs. (e.g. to show only the inputs)
ImGuiColorEditFlags_NoInputs=1<<5,// // ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the small preview colored square).
ImGuiColorEditFlags_NoTooltip=1<<6,// // ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview.
ImGuiColorEditFlags_NoLabel=1<<7,// // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker).
ImGuiColorEditFlags_NoSidePreview=1<<8,// // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead.
// User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions(). The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions() during startup.
ImGuiColorEditFlags_AlphaBar=1<<9,// // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
ImGuiColorEditFlags_AlphaPreview=1<<10,// // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque.
ImGuiColorEditFlags_HDR=1<<12,// // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well).
ImGuiColorEditFlags_RGB=1<<13,// [Inputs] // ColorEdit: choose one among RGB/HSV/HEX. ColorPicker: choose any combination using RGB/HSV/HEX.
ImGuiColorEditFlags_Float=1<<17,// [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.
ImGuiColorEditFlags_PickerHueBar=1<<18,// [PickerMode] // ColorPicker: bar for Hue, rectangle for Sat/Value.
ImGuiColorEditFlags_PickerHueWheel=1<<19,// [PickerMode] // ColorPicker: wheel for Hue, triangle for Sat/Value.
// Condition for ImGui::SetWindow***(), SetNextWindow***(), SetNextTreeNode***() functions
// All those functions treat 0 as a shortcut to ImGuiCond_Always. From the point of view of the user use this as an enum (don't combine multiple values into flags).
floatChildRounding;// Radius of child window corners rounding. Set to 0.0f to have rectangular windows.
floatChildBorderSize;// 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)
floatPopupRounding;// Radius of popup window corners rounding.
floatPopupBorderSize;// Thickness of border around popup windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly)
ImVec2ItemSpacing;// Horizontal and vertical spacing between widgets/lines
ImVec2ItemInnerSpacing;// Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
ImVec2TouchExtraPadding;// 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!
floatIndentSpacing;// Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2).
floatColumnsMinSpacing;// Minimum horizontal spacing between two columns
floatScrollbarSize;// Width of the vertical scrollbar, Height of the horizontal scrollbar
floatScrollbarRounding;// Radius of grab corners for scrollbar
floatGrabMinSize;// Minimum width/height of a grab box for slider/scrollbar.
floatGrabRounding;// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
ImVec2ButtonTextAlign;// Alignment of button text when button is larger than text. Defaults to (0.5f,0.5f) for horizontally+vertically centered.
ImVec2DisplayWindowPadding;// Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
ImVec2DisplaySafeAreaPadding;// If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
boolAntiAliasedLines;// Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
boolAntiAliasedFill;// Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
floatCurveTessellationTol;// Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
void*UserData;// = NULL // Store your own data for retrieval by callbacks.
ImFontAtlas*Fonts;// <auto> // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
floatFontGlobalScale;// = 1.0f // Global scale all fonts
boolFontAllowUserScaling;// = false // Allow user scaling text of individual window with CTRL+Wheel.
ImFont*FontDefault;// = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
ImVec2DisplayFramebufferScale;// = (1.0f,1.0f) // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
ImVec2DisplayVisibleMin;// <unset> (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
ImVec2DisplayVisibleMax;// <unset> (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
boolOptMacOSXBehaviors;// = 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
boolOptCursorBlink;// = true // Enable blinking cursor, for users who consider it annoying.
// Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer.
// (default to posix malloc/free)
void*(*MemAllocFn)(size_tsz);
void(*MemFreeFn)(void*ptr);
// 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)
// (default to use native imm32 api on Windows)
void(*ImeSetInputScreenPosFn)(intx,inty);
void*ImeWindowHandle;// (Windows) Set this to your HWND to get automatic IME cursor positioning.
boolMouseDown[5];// Mouse buttons: left, right, middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
floatMouseWheel;// Mouse wheel: 1 unit scrolls about 5 lines text.
boolMouseDrawCursor;// Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
boolWantCaptureMouse;// When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. This is set by ImGui when it wants to use your mouse (e.g. unclicked mouse is hovering a window, or a widget is active).
boolWantCaptureKeyboard;// When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. This is set by ImGui when it wants to use your keyboard inputs.
boolWantTextInput;// Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
boolWantMoveMouse;// [BETA-NAV] MousePos has been altered, back-end should reposition mouse on next frame. Set only when 'NavMovesMouse=true'.
floatFramerate;// Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
intMetricsAllocs;// Number of active memory allocations
intMetricsRenderVertices;// Vertices output during last call to Render()
intMetricsRenderIndices;// Indices output during last call to Render() = number of triangles * 3
intMetricsActiveWindows;// Number of visible root windows (exclude child windows)
ImVec2MouseDelta;// 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.
boolMouseDoubleClicked[5];// Has mouse button been double-clicked?
boolMouseReleased[5];// Mouse button went from Down to !Down
boolMouseDownOwned[5];// Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds.
floatMouseDownDuration[5];// Duration the mouse button has been down (0.0f == just clicked)
floatMouseDownDurationPrev[5];// Previous time the mouse button has been down
staticinlinevoidSetNextWindowContentWidth(floatwidth){SetNextWindowContentSize(ImVec2(width,0.0f));}// OBSOLETE 1.53+ (nb: original version preserved last Y value set by SetNextWindowContentSize())
staticinlineboolIsRootWindowOrAnyChildHovered(ImGuiHoveredFlagsflags=0){returnIsItemHovered(flags|ImGuiHoveredFlags_RootWindow|ImGuiHoveredFlags_ChildWindows);}// OBSOLETE 1.53+ use flags directly
boolBegin(constchar*name,bool*p_open,constImVec2&size_on_first_use,floatbg_alpha_override=-1.0f,ImGuiWindowFlagsflags=0);// OBSOLETE 1.52+. use SetNextWindowSize() instead if you want to set a window size.
staticinlineboolIsPosHoveringAnyWindow(constImVec2&){IM_ASSERT(0);returnfalse;}// OBSOLETE 1.51+. This was partly broken. You probably wanted to use ImGui::GetIO().WantCaptureMouse instead.
// Lightweight 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).
// Our implementation does NOT call C++ constructors/destructors. This is intentional and we do not require it. Do not use this class as a straight std::vector replacement in your code!
// Helper: execute a block of code at maximum once a frame. Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
// Helper macro for ImGuiOnceUponAFrame. Attention: The macro expands into 2 statement so make sure you don't use it within e.g. an if() statement without curly braces.
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS // Will obsolete
#define IMGUI_ONCE_UPON_A_FRAME static ImGuiOnceUponAFrame imgui_oaf; if (imgui_oaf)
IMGUI_APIvoid*GetVoidPtr(ImGuiIDkey)const;// default_val is NULL
IMGUI_APIvoidSetVoidPtr(ImGuiIDkey,void*val);
// - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set.
// - 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.
// - 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)
// **Avoid storing ImColor! Store either u32 of ImVec4. This is not a full-featured color class. MAY OBSOLETE.
// **None of the ImGui API are using ImColor directly but you can use it as a convenience to pass colors in either ImU32 or ImVec4 formats. Explicitly cast to ImU32 or ImVec4 if needed.
// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse clipping based on visibility to save yourself from processing those items at all.
// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped.
// ImGui already clip items based on their bounds but it needs to measure text size to do so. Coarse clipping before submission makes this cost and your own data fetching/submission cost null.
// Usage:
// ImGuiListClipper clipper(1000); // we have 1000 elements, evenly spaced.
// while (clipper.Step())
// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
// ImGui::Text("line number %d", i);
// - Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor).
// - Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element.
// - (Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.)
// - Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop.
structImGuiListClipper
{
floatStartPosY;
floatItemsHeight;
intItemsCount,StepNo,DisplayStart,DisplayEnd;
// items_count: Use -1 to ignore (you can call Begin later). 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).
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
// If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step().
ImGuiListClipper(intitems_count=-1,floatitems_height=-1.0f){Begin(items_count,items_height);}// NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want).
~ImGuiListClipper(){IM_ASSERT(ItemsCount==-1);}// Assert if user forgot to call End() or Step() until false.
IMGUI_APIboolStep();// Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items.
IMGUI_APIvoidBegin(intitems_count,floatitems_height=-1.0f);// Automatically called by constructor if you passed 'items_count' or by Step() in Step 1.
IMGUI_APIvoidEnd();// Automatically called on the last call of Step() that returns false.
// NB- You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering (you can poke into the draw list for that)
// Draw callback may be useful for example, A) Change your GPU render state, B) render a complex 3D scene inside a UI element (without an intermediate texture/render target), etc.
// The expected behavior from your rendering function is 'if (cmd.UserCallback != NULL) cmd.UserCallback(parent_list, cmd); else RenderTriangles()'
unsignedintElemCount;// Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
ImTextureIDTextureId;// 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.
ImDrawCallbackUserCallback;// If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
void*UserCallbackData;// The draw callback code can access this.
// Vertex index (override with '#define ImDrawIdx unsigned int' inside in imconfig.h)
#ifndef ImDrawIdx
typedefunsignedshortImDrawIdx;
#endif
// Vertex layout
#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
structImDrawVert
{
ImVec2pos;
ImVec2uv;
ImU32col;
};
#else
// You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h
// 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.
// The type has to be described within the macro (you can either declare the struct or use a typedef)
// 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.
// Draw channels are used by the Columns API to "split" the render list into different channels while building, so items of each column can be batched together.
// You can also use them to simulate drawing layers and submit primitives in a different order than how they will be rendered.
// 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.
// Each ImGui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to access the current window draw list and draw custom primitives.
// All positions are generally in pixel coordinates (top-left at (0,0), bottom-right at io.DisplaySize), however you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well)
// Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects.
IMGUI_APIvoidPushClipRect(ImVec2clip_rect_min,ImVec2clip_rect_max,boolintersect_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)
IMGUI_APIvoidAddRect(constImVec2&a,constImVec2&b,ImU32col,floatrounding=0.0f,introunding_corners_flags=ImDrawCornerFlags_All,floatthickness=1.0f);// a: upper-left, b: lower-right, rounding_corners_flags: 4-bits corresponding to which corner to round
// - Use to simulate layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
IMGUI_APIvoidAddCallback(ImDrawCallbackcallback,void*callback_data);// Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles.
IMGUI_APIvoidAddDrawCmd();// 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
// Internal helpers
// NB: all primitives needs to be reserved via PrimReserve() beforehand!
IMGUI_APIvoidDeIndexAllBuffers();// For backward compatibility or convenience: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
IMGUI_APIvoidScaleClipRects(constImVec2&sc);// Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
intOversampleH,OversampleV;// 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
boolPixelSnapH;// 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.
ImVec2GlyphExtraSpacing;// 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now.
ImVec2GlyphOffset;// 0, 0 // Offset all glyphs from this font input.
constImWchar*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.
boolMergeMode;// false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights.
unsignedintRasterizerFlags;// 0x00 // Settings for custom font rasterizer (e.g. ImGuiFreeType). Leave as zero if you aren't using one.
floatRasterizerMultiply;// 1.0f // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable.
// Sharing a texture for multiple fonts allows us to reduce the number of draw calls during rendering.
// We also add custom graphic data into the texture that serves for ImGui.
// 1. (Optional) Call AddFont*** functions. If you don't call any, the default font will be loaded for you.
// 2. Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data.
// 3. Upload the pixels data into a texture within your graphics system.
// 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.
// IMPORTANT: If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the ImFont is build (when calling GetTextData*** or Build()). We only copy the pointer, not the data.
IMGUI_APIImFont*AddFontFromMemoryTTF(void*font_data,intfont_size,floatsize_pixels,constImFontConfig*font_cfg=NULL,constImWchar*glyph_ranges=NULL);// Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after Build(). Set font_cfg->FontDataOwnedByAtlas to false to keep ownership.
IMGUI_APIImFont*AddFontFromMemoryCompressedTTF(constvoid*compressed_font_data,intcompressed_font_size,floatsize_pixels,constImFontConfig*font_cfg=NULL,constImWchar*glyph_ranges=NULL);// 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
IMGUI_APIImFont*AddFontFromMemoryCompressedBase85TTF(constchar*compressed_font_data_base85,floatsize_pixels,constImFontConfig*font_cfg=NULL,constImWchar*glyph_ranges=NULL);// 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter.
// 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().
// RGBA32 format is provided for convenience and compatibility, but note that unless you use CustomRect to draw color data, the RGB pixels emitted from Fonts will all be white (~75% of waste).
// 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.
voidSetBit(intn){UsedChars[n>>3]|=1<<(n&7);}// Set bit 'c' in the array
voidAddChar(ImWcharc){SetBit(c);}// Add character
IMGUI_APIvoidAddText(constchar*text,constchar*text_end=NULL);// Add string (each character of the UTF-8 string are added)
IMGUI_APIvoidAddRanges(constImWchar*ranges);// Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault) to force add all of ASCII/Latin+Ext
IMGUI_APIvoidBuildRanges(ImVector<ImWchar>*out_ranges);// Output new ranges
};
//-------------------------------------------
// Custom Rectangles/Glyphs API
//-------------------------------------------
// You can request arbitrary rectangles to be packed into the atlas, for your own purposes. After calling Build(), you can query the rectangle position and render your pixels.
// You can also request your rectangles to be mapped as font glyph (given a font + Unicode point), so you can render e.g. custom colorful icons and use them as regular glyphs.
structCustomRect
{
unsignedintID;// Input // User ID. Use <0x10000 to map into a font glyph, >=0x10000 for other/internal/custom texture data.
IMGUI_APIintAddCustomRectRegular(unsignedintid,intwidth,intheight);// Id needs to be >= 0x10000. Id >= 0x80000000 are reserved for ImGui and ImDrawList
IMGUI_APIintAddCustomRectFontGlyph(ImFont*font,ImWcharid,intwidth,intheight,floatadvance_x,constImVec2&offset=ImVec2(0,0));// Id needs to be < 0x10000 to register a rectangle to map into a specific font.
ImTextureIDTexID;// 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 ImDrawCmd structure.
intTexDesiredWidth;// 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.
intTexGlyphPadding;// Padding between glyphs within texture in pixels. Defaults to 1.
// [Internal]
// NB: Access texture data via GetTexData*() calls! Which will setup a default font for you.
unsignedchar*TexPixelsAlpha8;// 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
unsignedint*TexPixelsRGBA32;// 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
intTexWidth;// Texture width calculated during Build().
intTexHeight;// Texture height calculated during Build().
ImVec2TexUvWhitePixel;// Texture coordinates to a white pixel
ImVector<ImFont*>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.
ImVector<float>IndexAdvanceX;// // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
ImWcharFallbackChar;// = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
// Members: Cold ~18/26 bytes
shortConfigDataCount;// ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
ImFontConfig*ConfigData;// // Pointer within ContainerAtlas->ConfigData
ImFontAtlas*ContainerAtlas;// // What we has been loaded into
floatAscent,Descent;// // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
intMetricsTotalSurface;// // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
IMGUI_APIvoidAddRemapChar(ImWchardst,ImWcharsrc,booloverwrite_dst=true);// Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.