<br>_(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_
**Offset font vertically by altering the `io.Font->DisplayOffset` value:**
```cpp
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels);
font->DisplayOffset.y = 1; // Render 1 pixel down
```
**Font Atlas too large?**
- If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API. The typical result of failing to upload a texture is if every glyphs appears as white rectangles.
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let us know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here:
- [imgui-demo-binaries-20200412.zip](http://www.dearimgui.org/binaries/imgui-demo-binaries-20200412.zip) (Windows, 1.76, built 2020/04/12, master branch) or [older demo binaries](http://www.dearimgui.org/binaries).
- [imgui-demo-binaries-20200918.zip](https://www.dearimgui.org/binaries/imgui-demo-binaries-20200918.zip) (Windows, 1.78 WIP, built 2020/09/18, master branch) or [older demo binaries](https://www.dearimgui.org/binaries).
The demo applications are not DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at different scale, and scale your style with `style.ScaleAllSizes()` (see [FAQ](https://www.dearimgui.org/faq)).
@ -114,7 +114,7 @@ Officially maintained bindings (in repository):
- Frameworks: Emscripten, Allegro5, Marmalade.
Third-party bindings (see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings/) page):
- Note that C bindings ([cimgui](https://github.com/cimgui/cimgui)) are auto-generated, you can use its json/lua output to generate bindings for other languages.
@ -247,7 +247,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
- popups/modals: although it is sometimes convenient that popups/modals lifetime is owned by imgui, we could also a bool-owned-by-user api as long as Begin() return value testing is enforced.
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
- tooltip: tooltip that doesn't fit in entire screen seems to lose their "last preferred direction" and may teleport when moving mouse.
- tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
- tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485)
- tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers.
ImGuiIDid=str_id?window->GetID(str_id):window->DC.LastItemId;// If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT(id!=0);// You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
OpenPopupEx(id,popup_flags);
returntrue;
}
returnfalse;
}
// This is a helper to handle the simplest case of associating one named popup to one given widget.
// - You can pass a NULL str_id to use the identifier of the last item.
// - You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
// - This is essentially the same as calling OpenPopupContextItem() + BeginPopup() but written to avoid
// computing the ID twice because BeginPopupContextXXX functions are called very frequently.
// - This is essentially the same as calling OpenPopupOnItemClick() + BeginPopup() but written to avoid
// computing the ID twice because BeginPopupContextXXX functions may be called very frequently.
// If there not enough room on one axis, there's no point in positioning on a side on this axis (e.g. when not enough width, use a top/bottom position to maximize available width)
r_avoid=ImRect(-FLT_MAX,parent_window->ClipRect.Min.y,FLT_MAX,parent_window->ClipRect.Max.y);// Avoid parent menu-bar. If we wanted multi-line menu-bar, we may instead want to have the calling window setup e.g. a NextWindowData.PosConstraintAvoidRect field
r_avoid=ImRect(ref_pos.x-16,ref_pos.y-8,ref_pos.x+24*sc,ref_pos.y+24*sc);// FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
pos=ref_pos+ImVec2(2,2);// If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible.
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
IMGUI_APIvoidOpenPopup(constchar*str_id,ImGuiPopupFlagspopup_flags=0);// call to mark popup as open (don't call every frame!).
IMGUI_APIbool OpenPopupContextItem(constchar*str_id=NULL,ImGuiPopupFlagspopup_flags=1);// helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
IMGUI_APIvoid OpenPopupOnItemClick(constchar*str_id=NULL,ImGuiPopupFlagspopup_flags=1);// helper to open popup when clicked on last item. return true when just opened. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
IMGUI_APIvoidCloseCurrentPopup();// manually close the popup we have begin-ed into.
// Popups: open+begin combined functions helpers
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
// - They are convenient to easily create context menus, hence the name.
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
// - We exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter. Passing a mouse button to ImGuiPopupFlags is guaranteed to be legal.
// - IMPORTANT: we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight.
IMGUI_APIboolBeginPopupContextItem(constchar*str_id=NULL,ImGuiPopupFlagspopup_flags=1);// open+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,ImGuiPopupFlagspopup_flags=1);// open+begin popup when clicked on current window.
IMGUI_APIboolBeginPopupContextVoid(constchar*str_id=NULL,ImGuiPopupFlagspopup_flags=1);// open+begin popup when clicked in void (where there are no windows).
@ -666,8 +666,9 @@ namespace ImGui
// Note: Tabs are automatically created by the docking system. Use this to create tab bars/tabs yourself without docking being involved.
IMGUI_APIboolBeginTabBar(constchar*str_id,ImGuiTabBarFlagsflags=0);// create and append into a TabBar
IMGUI_APIvoidEndTabBar();// only call EndTabBar() if BeginTabBar() returns true!
IMGUI_APIboolBeginTabItem(constchar*label,bool*p_open=NULL,ImGuiTabItemFlagsflags=0);// create a Tab. Returns true if the Tab is selected.
IMGUI_APIboolBeginTabItem(constchar*label,bool*p_open=NULL,ImGuiTabItemFlagsflags=0);// create a Tab. Returns true if the Tab is selected.
IMGUI_APIvoidEndTabItem();// only call EndTabItem() if BeginTabItem() returns true!
IMGUI_APIboolTabItemButton(constchar*label,ImGuiTabItemFlagsflags=0);// create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar.
IMGUI_APIvoidSetTabItemClosed(constchar*tab_or_docked_window_label);// notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
// Docking
@ -931,13 +932,15 @@ enum ImGuiTreeNodeFlags_
// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags.
// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags.
// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0.
// IMPORTANT: because the default parameter is 1 (==ImGuiPopupFlags_MouseButtonRight), if you rely on the default parameter
// and want to another another flag, you need to pass in the ImGuiPopupFlags_MouseButtonRight flag.
// - Multiple buttons currently cannot be combined/or-ed in those functions (we could allow it later).
enumImGuiPopupFlags_
{
ImGuiPopupFlags_None=0,
ImGuiPopupFlags_MouseButtonLeft=0,// For BeginPopupContext*(): open on Left Mouse release. Guaranted to always be == 0 (same as ImGuiMouseButton_Left)
ImGuiPopupFlags_MouseButtonRight=1,// For BeginPopupContext*(): open on Right Mouse release. Guaranted to always be == 1 (same as ImGuiMouseButton_Right)
ImGuiPopupFlags_MouseButtonMiddle=2,// For BeginPopupContext*(): open on Middle Mouse release. Guaranted to always be == 2 (same as ImGuiMouseButton_Middle)
ImGuiPopupFlags_MouseButtonLeft=0,// For BeginPopupContext*(): open on Left Mouse release. Guaranteed to always be == 0 (same as ImGuiMouseButton_Left)
ImGuiPopupFlags_MouseButtonRight=1,// For BeginPopupContext*(): open on Right Mouse release. Guaranteed to always be == 1 (same as ImGuiMouseButton_Right)
ImGuiPopupFlags_MouseButtonMiddle=2,// For BeginPopupContext*(): open on Middle Mouse release. Guaranteed to always be == 2 (same as ImGuiMouseButton_Middle)
ImGuiPopupFlags_MouseButtonMask_=0x1F,
ImGuiPopupFlags_MouseButtonDefault_=1,
ImGuiPopupFlags_NoOpenOverExistingPopup=1<<5,// For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack
@ -996,7 +999,10 @@ enum ImGuiTabItemFlags_
ImGuiTabItemFlags_SetSelected=1<<1,// Trigger flag to programmatically make the tab selected when calling BeginTabItem()
ImGuiTabItemFlags_NoCloseWithMiddleMouseButton=1<<2,// Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
ImGuiTabItemFlags_NoPushId=1<<3,// Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
ImGuiTabItemFlags_NoTooltip=1<<4// Disable tooltip for the given tab
ImGuiTabItemFlags_NoTooltip=1<<4,// Disable tooltip for the given tab
ImGuiTabItemFlags_NoReorder=1<<5,// Disable reordering this tab or having another tab cross over this tab
ImGuiTabItemFlags_Leading=1<<6,// Enforce the tab position to the left of the tab bar (after the tab list popup button)
ImGuiTabItemFlags_Trailing=1<<7// Enforce the tab position to the right of the tab bar (before the scrolling buttons)
};
// Flags for ImGui::IsWindowFocused()
@ -1815,7 +1821,9 @@ struct ImGuiPayload
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
namespaceImGui
{
// OBSOLETED in 1.78 (from August 2020)
// OBSOLETED in 1.79 (from August 2020)
staticinlinevoidOpenPopupContextItem(constchar*str_id=NULL,ImGuiMouseButtonmb=1){OpenPopupOnItemClick(str_id,mb);}// Bool return value removed. Use IsWindowAppearing() in BeginPopup() instead. Renamed in 1.77, renamed back in 1.79. Sorry!
// OBSOLETED in 1.78 (from June 2020)
// Old drag/sliders functions that took a 'float power = 1.0' argument instead of flags.
// For shared code, you can version check at compile-time with `#if IMGUI_VERSION_NUM >= 17704`.
staticinlineboolOpenPopupOnItemClick(constchar*str_id=NULL,ImGuiMouseButtonmb=1){returnOpenPopupContextItem(str_id,mb);}// Passing a mouse button to ImGuiPopupFlags is legal
ImGui::Text("The lazy dog is a good dog. This paragraph should fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.",wrap_width);
if (n==1)
else
ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh");
// Draw actual text bounding box, following by marker of our expected limit (should not overlap!)
ImGuiTabItemFlags_NoCloseButton=1<<20,// Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout)
ImGuiTabItemFlags_Unsorted=1<<21,// [Docking] Trailing tabs with the _Unsorted flag will be sorted based on the DockOrder of their Window.
ImGuiTabItemFlags_Preview=1<<22// [Docking] Display tab shape for docking preview (height is adjusted slightly to compensate for the yet missing tab bar)
ImGuiTabItemFlags_Button=1<<21,// Used by TabItemButton, change the tab item behavior to mimic a button
ImGuiTabItemFlags_Unsorted=1<<22,// [Docking] Trailing tabs with the _Unsorted flag will be sorted based on the DockOrder of their Window.
ImGuiTabItemFlags_Preview=1<<23// [Docking] Display tab shape for docking preview (height is adjusted slightly to compensate for the yet missing tab bar)
};
// Storage for one active tab item (sizeof() 32~40 bytes)
@ -1920,12 +1922,13 @@ struct ImGuiTabItem
intLastFrameSelected;// This allows us to infer an ordered list of the last activated tabs with little maintenance
floatOffset;// Position relative to beginning of tab
floatWidth;// Width currently displayed
floatContentWidth;// Width of actual contents, stored during BeginTabItem() call
floatContentWidth;// Width of label, stored during BeginTabItem() call
ImS16NameOffset;// When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
ImS8BeginOrder;// BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable
ImS8IndexDuringLayout;// Index only used during TabBarLayout()
boolWantClose;// Marked as closed by SetTabItemClosed()
g.ActiveIdUsingKeyInputMask|=((ImU64)1<<ImGuiKey_PageUp)|((ImU64)1<<ImGuiKey_PageDown);// FIXME-NAV: Page up/down actually not supported yet by widget, but claim them ahead.
IM_ASSERT(io.KeyMods==GetMergedKeyModFlags()&&"Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods");// We rarely do this check, but if anything let's do it here.
floatmargin=g.FontSize*1.0f;// When to scroll to make Tab N+1 visible always make a bit of N visible to suggest more scrolling area (since we don't have a scrollbar)
tab_to_select=&tab_bar->Tabs[(target_order>=0&&target_order<tab_bar->Tabs.Size)?target_order:selected_order];// If we are at the end of the list, still scroll to make our tab visible
// Skip tab item buttons until another tab item is found or end is reached
while(tab_to_scroll_to==NULL)
{
// If we are at the end of the list, still scroll to make our tab visible
IM_ASSERT((flags&(ImGuiTabItemFlags_Leading|ImGuiTabItemFlags_Trailing))!=(ImGuiTabItemFlags_Leading|ImGuiTabItemFlags_Trailing));// Can't use both Leading and Trailing
// Store into ImGuiTabItemFlags_NoCloseButton, also honor ImGuiTabItemFlags_NoCloseButton passed by user (although not documented)
// We don't have CPU clipping primitives to clip the CloseButton (until it becomes a texture), so need to add an extra draw call (temporary in the case of vertical animation)