The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' (by Tristan Grimmer) that is used by default.
We embed the font in source code so you can use Dear ImGui without any file system access.
You may also load external .TTF/.OTF files.
The files in this folder are suggested fonts, provided as a convenience.
(Note: .OTF support in stb_truetype.h currently doesn't appear to load every font)
The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' (by Tristan Grimmer) that is used by default.
We embed the font in source code so you can use Dear ImGui without any file system access.
You may also load external .TTF/.OTF files.
The files in this folder are suggested fonts, provided as a convenience.
(Note: .OTF support in stb_truetype.h currently doesn't appear to load every font)
Fonts are rasterized in a single texture at the time of calling either of io.Fonts.GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build().
Fonts are rasterized in a single texture at the time of calling either of io.Fonts.GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build().
Also read dear imgui FAQ in imgui.cpp!
---------------------------------
In this document:
- Using Icons
- Fonts Loading Instructions
- FreeType rasterizer, Small font sizes
- Building Custom Glyph Ranges
- Remapping Codepoints
- Embedding Fonts in Source Code
- Credits/Licences for fonts included in this folder
- Links, Other fonts
---------------------------------------
USING ICONS
---------------------------------
---------------------------------------
Using an icon font (such as FontAwesome: http://fontawesome.io) is an easy and practical way to use icons in your ImGui application.
A common pattern is to merge the icon font within your main font, so you can refer to the icons directly from your strings without having to change fonts back and forth.
To refer to the icon from your C++ code, you can use headers files created by Juliette Foucaut, at https://github.com/juliettef/IconFontCppHeaders
See Links below for other icons fonts and related tools.
A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without
having to change fonts back and forth.
To refer to the icon UTF-8 codepoints from your C++ code, you may use those headers files created by Juliette Foucaut:
https://github.com/juliettef/IconFontCppHeaders
The C++11 version of those files uses the u8"" utf-8 encoding syntax + \u
#define ICON_FA_SEARCH u8"\uf002"
The pre-C++11 version has the values directly encoded as utf-8:
All your strings needs to use UTF-8 encoding. Specifying literal in your source code using a local code page (such as CP-923 for Japanese, or CP-1251 for Cyrillic) will NOT work!
In C++11 you can encode a string literal in UTF-8 by using the u8"hello" syntax. Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
@ -117,9 +156,9 @@
You may also try to remap your local codepage characters to their Unicode codepoint using font->AddRemapChar(), but international users may have problems reading/editing your source code.
---------------------------------
EMBEDDING FONT IN SOURCE CODE
---------------------------------
---------------------------------------
EMBEDDING FONTS IN SOURCE CODE
---------------------------------------
Compile and use 'binary_to_compressed_c.cpp' to create a compressed C style array that you can embed in source code.
See the documentation in binary_to_compressed_c.cpp for instruction on how to use the tool.
@ -135,9 +174,9 @@
ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_base85, size_pixels, ...);
---------------------------------
FONT FILES INCLUDED IN THIS FOLDER
---------------------------------
---------------------------------------
CREDITS/LICENSES FOR FONTS INCLUDED IN THIS FOLDER
-2017/10/20(1.52)-markedIsItemHoveredRect()/IsMouseHoveringWindow()asobsolete,infavorofusingthenewlyintroducedflagsforIsItemHovered()andIsWindowHovered().Seehttps://github.com/ocornut/imgui/issues/1382 for details.
// Test for bounding box overlap, as updated as ItemAdd()
if(!window->DC.LastItemRectHoveredRect)
returnfalse;
IM_ASSERT((flags&ImGuiHoveredFlags_FlattenChilds)==0);// Flags not supported by this function
IM_ASSERT((flags&(ImGuiHoveredFlags_RootWindow|ImGuiHoveredFlags_ChildWindows))==0);// Flags not supported by this function
// Test if we are hovering the right window (our window could be behind another window)
// [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself.
ImGuiPopupRefpopup_ref=ImGuiPopupRef(id, window, window->GetID("##Menus"),g.IO.MousePos);// Tagged as new ref because constructor sets Window to NULL (we are passing the ParentWindow info here)
ImGuiPopupRefpopup_ref=ImGuiPopupRef(id,parent_window,parent_window->GetID("##Menus"),g.IO.MousePos);// Tagged as new ref because constructor sets Window to NULL.
window->RootNonPopupWindow=!(flags&(ImGuiWindowFlags_ChildWindow|ImGuiWindowFlags_Popup))||(flags&ImGuiWindowFlags_Modal) ? window:parent_window->RootNonPopupWindow;// Used to display TitleBgActive color and for selecting which window to use for NavWindowing
window->RootNonPopupWindow=!(flags&(ImGuiWindowFlags_ChildWindow|ImGuiWindowFlags_Popup))||(flags&ImGuiWindowFlags_Modal)||(parent_window==NULL)? window:parent_window->RootNonPopupWindow;// Used to display TitleBgActive color and for selecting which window to use for NavWindowing
// This is how we end up with child menus appearing (most-commonly) on the right of the parent menu.
IM_ASSERT(window_pos_set_by_api);
floathorizontal_overlap=style.ItemSpacing.x;// We want some overlap to convey the relative depth of each popup (currently the amount of overlap it is hard-coded to style.ItemSpacing.x, may need to introduce another style value).
// AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one.
ImVec2picker_size(g.FontSize*8,ImMax(g.FontSize*8-(SmallSquareSize()+g.Style.ItemInnerSpacing.x),1.0f));// FIXME: Picker size copied from main picker function
ImVec2picker_size(g.FontSize*8,ImMax(g.FontSize*8-(ImGui::GetFrameHeight()+g.Style.ItemInnerSpacing.x),1.0f));// FIXME: Picker size copied from main picker function
@ -82,7 +82,8 @@ typedef int ImGuiColorEditFlags; // flags: for ColorEdit*(), ColorPicker*()
typedefintImGuiDragDropFlags;// flags: for *DragDrop*() // enum ImGuiDragDropFlags_
typedefintImGuiColumnsFlags;// flags: for *Columns*() // enum ImGuiColumnsFlags_
typedefintImGuiComboFlags;// flags: for BeginCombo() // enum ImGuiComboFlags_
typedefintImGuiHoveredFlags;// flags: for IsItemHovered() // enum ImGuiHoveredFlags_
typedefintImGuiFocusedFlags;// flags: for IsWindowFocused() // enum ImGuiFocusedFlags_
typedefintImGuiHoveredFlags;// flags: for IsItemHovered() etc. // enum ImGuiHoveredFlags_
typedefintImGuiInputTextFlags;// flags: for InputText*() // enum ImGuiInputTextFlags_
typedefintImGuiSelectableFlags;// flags: for Selectable() // enum ImGuiSelectableFlags_
typedefintImGuiTreeNodeFlags;// flags: for TreeNode*(),CollapsingHeader()// enum ImGuiTreeNodeFlags_
@ -233,9 +234,10 @@ namespace ImGui
IMGUI_APIImVec2GetCursorScreenPos();// cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
IMGUI_APIvoidSetCursorScreenPos(constImVec2&pos);// cursor position in absolute screen coordinates [0..io.DisplaySize]
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();// height of font == GetWindowFontSize()
IMGUI_APIfloatGetTextLineHeightWithSpacing();// distance (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
IMGUI_APIfloatGetItemsLineHeightWithSpacing();// distance (in pixels) between 2 consecutive lines of standard height widgets == GetWindowFontSize() + GetStyle().FramePadding.y*2 + GetStyle().ItemSpacing.y
IMGUI_APIfloatGetTextLineHeight();// ~ FontSize
IMGUI_APIfloatGetTextLineHeightWithSpacing();// ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)
IMGUI_APIfloatGetFrameHeightWithSpacing();// ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets)
// Columns
// You can also use SameLine(pos_x) for simplified columns. The columns API is still work-in-progress and rather lacking.
@ -452,10 +454,8 @@ namespace ImGui
IMGUI_APIImVec2GetItemRectMax();// "
IMGUI_APIImVec2GetItemRectSize();// "
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();// is current Begin()-ed window focused?
IMGUI_APIboolIsWindowHovered(ImGuiHoveredFlagsflags=0);// is current Begin()-ed window hovered (and typically: not blocked by a popup/modal)?
IMGUI_APIboolIsRootWindowFocused();// is current Begin()-ed root window focused (root = top-most parent of a child, otherwise self)?
IMGUI_APIboolIsRootWindowOrAnyChildFocused();// is current Begin()-ed root window or any of its child (including current window) focused?
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_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.
ImGuiInputTextFlags_CharsUppercase=1<<2,// Turn a..z into A..Z
@ -573,7 +571,7 @@ enum ImGuiTreeNodeFlags_
{
ImGuiTreeNodeFlags_Selected=1<<0,// Draw as selected
ImGuiTreeNodeFlags_Framed=1<<1,// Full colored frame (e.g. for CollapsingHeader)
ImGuiTreeNodeFlags_AllowOverlapMode=1<<2,// Hit testing to allow subsequent widgets to overlap this one
ImGuiTreeNodeFlags_AllowItemOverlap =1<<2,// Hit testing to allow subsequent widgets to overlap this one
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
@ -585,12 +583,16 @@ enum ImGuiTreeNodeFlags_
//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
ImGuiSelectableFlags_DontClosePopups=1<<0,// Clicking this don't close parent popup window
ImGuiSelectableFlags_SpanAllColumns=1<<1,// Selectable frame can span all columns (text will still fit in current column)
ImGuiSelectableFlags_AllowDoubleClick=1<<2// Generate press events on double clicks too
@ -599,23 +601,32 @@ enum ImGuiSelectableFlags_
// Flags for ImGui::BeginCombo()
enumImGuiComboFlags_
{
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
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_AllowWhenBlockedByPopup=1<<0,// Return true even if a popup window is normally blocking access to this item/window
//ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 1, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem=1<<2,// Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
ImGuiHoveredFlags_AllowWhenOverlapped=1<<3,// Return true even if the position is overlapped by another window
ImGuiHoveredFlags_FlattenChilds=1<<4,// Treat all child windows as the same window (for IsWindowHovered())
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
ImGuiHoveredFlags_AllowWhenOverlapped=1<<5,// Return true even if the position is overlapped by another window
ImGuiMouseCursor_TextInput,// When hovering over InputText, etc.
ImGuiMouseCursor_Move,// Unused
ImGuiMouseCursor_ResizeNS,// Unused
ImGuiMouseCursor_ResizeEW,// When hovering over a column
ImGuiMouseCursor_ResizeNS,// When hovering over an horizontal border
ImGuiMouseCursor_ResizeEW,// When hovering over a vertical border or a column
ImGuiMouseCursor_ResizeNESW,// When hovering over the bottom-left corner of a window
ImGuiMouseCursor_ResizeNWSE,// When hovering over the bottom-right corner of a window
ImGuiMouseCursor_Count_
@ -963,8 +974,10 @@ struct ImGuiIO
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
namespaceImGui
{
staticinlinevoidSetNextWindowContentWidth(floatwidth){ImGui::SetNextWindowContentSize(ImVec2(width,0.0f));}// OBSOLETE 1.53+ (nb: original version preserved last Y value set by SetNextWindowContentSize())
staticinlineboolIsRootWindowOrAnyChildHovered(ImGuiHoveredFlagsflags=0){returnIsItemHovered(flags|ImGuiHoveredFlags_FlattenChilds);}// OBSOLETE 1.53+ use flags directly
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.
// 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 GetItemsLineHeightWithSpacing().
// 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.
// Display random stuff (for the sake of this trivial demo we are using basic Button+SameLine. If you want to create your own time line for a real application you may be better off
ImGui::SameLine();ShowHelpMarker("Request ImGui to render a mouse cursor for you in software. Note that a mouse cursor rendered via regular GPU rendering will feel more laggy than hardware cursor, but will be more in sync with your other visuals.");
ImGui::SameLine();ShowHelpMarker("Request ImGui to render a mouse cursor for you in software. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).");
// Testing IsItemHovered() function (because BulletText is an item itself and that would affect the output of IsItemHovered, we pass all lines in a single items to shorten the code)
ImGuiButtonFlags_AlignTextBaseLine =1<<8,// vertically align button to match text baseline (ButtonEx() only)
ImGuiButtonFlags_NoKeyModifiers =1<<9,// disable interaction if a key modifier is held
ImGuiButtonFlags_AllowOverlapMode =1<<10,// require previous frame HoveredId to either match id or be null before being usable
ImGuiButtonFlags_FlattenChildren=1<<5,// allow interactions even if a child window is overlapping
ImGuiButtonFlags_AllowItemOverlap =1<<6,// require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
ImGuiButtonFlags_AlignTextBaseLine =1<<9,// vertically align button to match text baseline (ButtonEx() only)
ImGuiButtonFlags_NoKeyModifiers =1<<10,// disable interaction if a key modifier is held
ImGuiButtonFlags_NoHoldingActiveID=1<<11,// don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
ImGuiButtonFlags_PressedOnDragDropHold=1<<12// press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
ImGuiWindow*ParentWindow;// Immediate parent in the window stack *regardless* of whether this window is a child window or not)
ImGuiWindow*ParentWindow;// If we are a child window, this is pointing to our parent.
ImGuiWindow*RootWindow;// Generally point to ourself. If we are a child window, this is pointing to the first non-child parent window.
ImGuiWindow*RootNonPopupWindow;// Generally point to ourself. Used to display TitleBgActive color and for selecting which window to use for NavWindowing
@ -826,11 +826,11 @@ namespace ImGui
// - You are calling ImGui functions after ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.