// (minor and older changes stripped away, please see git history for details)
// 2023-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2023-06-12: Accept glfwGetTime() not returning a monotonically increasing value. This seems to happens on some Windows setup when peripherals disconnect, and is likely to also happen on browser + Emscripten. (#6491)
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen on Windows ONLY, using a custom WndProc hook. (#2702)
// 2023-03-16: Inputs: Fixed key modifiers handling on secondary viewports (docking branch). Broken on 2023/01/04. (#6248, #6034)
// 2023-03-14: Emscripten: Avoid using glfwGetError() and glfwGetGamepadState() which are not correctly implemented in Emscripten emulation. (#6240)
// (Accept glfwGetTime() not returning a monotonically increasing value. Seems to happens on disconnecting peripherals and probably on VMs and Emscripten, see #6491, #6189, #6114, #3644)
staticconstfloatWINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER=0.04f;// Reduce visual noise by only highlighting the border after a certain time.
staticconstfloatWINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER=0.70f;// Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved.
// Tooltip offset
staticconstImVec2TOOLTIP_DEFAULT_OFFSET=ImVec2(16,10);// Multiplied by g.Style.MouseCursorScale
// Docking
staticconstfloatDOCKING_TRANSPARENT_PAYLOAD_ALPHA=0.50f;// For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport.
staticconstfloatDOCKING_SPLITTER_SIZE=2.0f;
@ -1183,6 +1187,13 @@ ImGuiStyle::ImGuiStyle()
CurveTessellationTol=1.25f;// Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
CircleTessellationMaxError=0.30f;// Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
// Behaviors
HoverStationaryDelay=0.15f;// Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
HoverDelayShort=0.15f;// Delay for IsItemHovered(ImGuiHoveredFlags_DelayShort). Usually used along with HoverStationaryDelay.
HoverDelayNormal=0.40f;// Delay for IsItemHovered(ImGuiHoveredFlags_DelayNormal). "
HoverFlagsForTooltipMouse=ImGuiHoveredFlags_Stationary|ImGuiHoveredFlags_DelayShort;// Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using mouse.
HoverFlagsForTooltipNav=ImGuiHoveredFlags_NoSharedDelay|ImGuiHoveredFlags_DelayNormal;// Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using keyboard/gamepad.
// Default theme
ImGui::StyleColorsDark(this);
}
@ -1231,16 +1242,10 @@ ImGuiIO::ImGuiIO()
IniSavingRate=5.0f;
IniFilename="imgui.ini";// Important: "imgui.ini" is relative to current working dir, most apps will want to lock this to an absolute path (e.g. same path as executables).
LogFilename="imgui_log.txt";
MouseDoubleClickTime=0.30f;
MouseDoubleClickMaxDist=6.0f;
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
for(inti=0;i<ImGuiKey_COUNT;i++)
KeyMap[i]=-1;
#endif
KeyRepeatDelay=0.275f;
KeyRepeatRate=0.050f;
HoverDelayNormal=0.30f;
HoverDelayShort=0.10f;
UserData=NULL;
Fonts=NULL;
@ -1278,6 +1283,13 @@ ImGuiIO::ImGuiIO()
ConfigDebugBeginReturnValueOnce=false;
ConfigDebugBeginReturnValueLoop=false;
// Inputs Behaviors
MouseDoubleClickTime=0.30f;
MouseDoubleClickMaxDist=6.0f;
MouseDragThreshold=6.0f;
KeyRepeatDelay=0.275f;
KeyRepeatRate=0.050f;
// Platform Functions
// Note: Initialize() will setup default clipboard/ime handlers.
// In theory here we should assert that we are already at the right position, but it seems saner to just seek at the end and not assert/crash the user.
ImGuiContext&g=*Ctx;
IMGUI_DEBUG_LOG_CLIPPER("Clipper: End() in '%s'\n",g.CurrentWindow->Name);
// This is roughly matching the behavior of internal-facing ItemHoverable()
// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered()
// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId
IM_ASSERT((flags&(ImGuiHoveredFlags_AnyWindow|ImGuiHoveredFlags_RootWindow|ImGuiHoveredFlags_ChildWindows|ImGuiHoveredFlags_NoPopupHierarchy|ImGuiHoveredFlags_DockHierarchy))==0);// Flags not supported by this function
// Done with rectangle culling so we can perform heavier checks now
// This gives a little bit of leeway before clearing the hover timer, allowing mouse to cross gaps
g.HoverDelayClearTimer+=g.IO.DeltaTime;
if(g.HoverDelayClearTimer>=ImMax(0.20f,g.IO.DeltaTime*2.0f))// ~6 frames at 30 Hz + allow for low framerate
g.HoverDelayTimer=g.HoverDelayClearTimer=0.0f;// May want a decaying timer, in which case need to clamp at max first, based on max of caller last requested timer.
// We could expose 0.25f as style.HoverClearDelay but I am not sure of the logic yet, this is particularly subtle.
g.HoverItemDelayClearTimer+=g.IO.DeltaTime;
if(g.HoverItemDelayClearTimer>=ImMax(0.25f,g.IO.DeltaTime*2.0f))// ~7 frames at 30 Hz + allow for low framerate
g.HoverItemDelayTimer=g.HoverItemDelayClearTimer=0.0f;// May want a decaying timer, in which case need to clamp at max first, based on max of caller last requested timer.
// Update stationary timer. Only reset on 2 successive moving frames.
// FIXME: May need to expose threshold or treat touch inputs differently.
constfloatmouse_stationary_threshold=(io.MouseSource==ImGuiMouseSource_Mouse)?2.0f:3.0f;// Slightly higher threshold for ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen, may need rework.
// If mouse moved we re-enable mouse hovering in case it was disabled by gamepad/keyboard. In theory should use a >0.0f threshold but would need to reset in everywhere we set this to true.
// The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor)
// In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
// Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do.
// Drag and Drop tooltips are positioning differently than other tooltips:
// - offset visibility to increase visibility around mouse.
// - never clamp within outer viewport boundary.
// We call SetNextWindowPos() to enforce position and disable clamping.
// See FindBestWindowPosForPopup() for positionning logic of other tooltips (not drag and drop ones).
//PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :(
// Position tooltip (always follows mouse + clamp within outer boundaries)
// Note that drag and drop tooltips are NOT using this path: BeginTooltipEx() manually sets their position.
// In theory we could handle both cases in same location, but requires a bit of shuffling as drag and drop tooltips are calling SetWindowPos() leading to 'window_pos_set_by_api' being set in Begin()
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.
r_avoid=ImRect(ref_pos.x-16,ref_pos.y-8,ref_pos.x+24*scale,ref_pos.y+24*scale);// FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d",g.HoveredIdPreviousFrame,g.HoveredIdTimer,g.HoveredIdAllowOverlap);// Not displaying g.HoveredId as it is update mid-frame
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.89.7 WIP"
#define IMGUI_VERSION_NUM 18962
#define IMGUI_VERSION_NUM 18964
#define IMGUI_HAS_TABLE
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
#define IMGUI_HAS_DOCK // Docking WIP branch
@ -674,12 +674,19 @@ namespace ImGui
IMGUI_APIboolMenuItem(constchar*label,constchar*shortcut,bool*p_selected,boolenabled=true);// return true when activated + toggle (*p_selected) if p_selected != NULL
// Tooltips
// - Tooltip are windows following the mouse. They do not take focus away.
// - Tooltips are windows following the mouse. They do not take focus away.
IMGUI_APIboolBeginTooltip();// begin/append a tooltip window. to create full-featured tooltip (with any kind of items).
IMGUI_APIvoidEndTooltip();// only call EndTooltip() if BeginTooltip() returns true!
IMGUI_APIvoidEndTooltip();// only call EndTooltip() if BeginTooltip()/BeginItemTooltip() returns true!
IMGUI_APIvoidSetTooltip(constchar*fmt,...)IM_FMTARGS(1);// set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip().
// Tooltips: helper for showing a tooltip when hovering an item
// - BeginItemTooltip(), SetItemTooltip() are shortcuts for the 'if (IsItemHovered(ImGuiHoveredFlags_Tooltip)) { BeginTooltip() or SetTooltip() }' idiom.
// - Where 'ImGuiHoveredFlags_Tooltip' itself is a shortcut to use 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav'. For mouse it defaults to 'ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort'.
IMGUI_APIboolBeginItemTooltip();// begin/append a tooltip window if preceding item was hovered.
IMGUI_APIvoidSetItemTooltip(constchar*fmt,...)IM_FMTARGS(1);// set a text-only tooltip if preceeding item was hovered. override any previous call to SetTooltip().
// - They block normal mouse hovering detection (and therefore most mouse interactions) behind them.
// - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
@ -1325,14 +1332,26 @@ enum ImGuiHoveredFlags_
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem=1<<7,// Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
ImGuiHoveredFlags_AllowWhenOverlapped=1<<8,// IsItemHovered() only: Return true even if the position is obstructed or overlapped by another window
ImGuiHoveredFlags_AllowWhenDisabled=1<<9,// IsItemHovered() only: Return true even if the item is disabled
ImGuiHoveredFlags_NoNavOverride=1<<10,// Disable using gamepad/keyboard navigation state when active, always query mouse.
ImGuiHoveredFlags_NoNavOverride=1<<10,// IsItemHovered() only: Disable using gamepad/keyboard navigation state when active, always query mouse
ImGuiHoveredFlags_DelayNormal=1<<11,// Return true after io.HoverDelayNormal elapsed (~0.30 sec)
ImGuiHoveredFlags_DelayShort=1<<12,// Return true after io.HoverDelayShort elapsed (~0.10 sec)
ImGuiHoveredFlags_NoSharedDelay=1<<13,// Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
// Tooltips mode
// - typically used in IsItemHovered() + SetTooltip() sequence.
// - this is a shortcut to pull flags from 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav' where you can reconfigure desired behavior.
// e.g. 'TooltipHoveredFlagsForMouse' defaults to 'ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort'.
// - for frequently actioned or hovered items providing a tooltip, you want may to use ImGuiHoveredFlags_ForTooltip (stationary + delay) so the tooltip doesn't show too often.
// - for items which main purpose is to be hovered, or items with low affordance, or in less consistent apps, prefer no delay or shorter delay.
ImGuiHoveredFlags_ForTooltip=1<<11,// Shortcut for standard flags when using IsItemHovered() + SetTooltip() sequence.
// (Advanced) Mouse Hovering delays.
// - generally you can use ImGuiHoveredFlags_ForTooltip to use application-standardized flags.
// - use those if you need specific overrides.
ImGuiHoveredFlags_Stationary=1<<12,// Require mouse to be stationary for style.HoverStationaryDelay (~0.15 sec) _at least one time_. After this, can move on same item/window. Using the stationary test tends to reduces the need for a long delay.
ImGuiHoveredFlags_DelayNone=1<<13,// IsItemHovered() only: Return true immediately (default). As this is the default you generally ignore this.
ImGuiHoveredFlags_DelayShort=1<<14,// IsItemHovered() only: Return true after style.HoverDelayShort elapsed (~0.15 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
ImGuiHoveredFlags_DelayNormal=1<<15,// IsItemHovered() only: Return true after style.HoverDelayNormal elapsed (~0.40 sec) (shared between items) + requires mouse to be stationary for style.HoverStationaryDelay (once per item).
ImGuiHoveredFlags_NoSharedDelay=1<<16,// IsItemHovered() only: Disable shared delay system where moving from one item to the next keeps the previous timer for a short time (standard for tooltips with long delays)
};
// Flags for ImGui::DockSpace(), shared/inherited by child nodes.
@ -1965,6 +1984,13 @@ struct ImGuiStyle
floatCircleTessellationMaxError;// Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
ImVec4Colors[ImGuiCol_COUNT];
// Behaviors
floatHoverStationaryDelay;// Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
floatHoverDelayShort;// Delay for IsItemHovered(ImGuiHoveredFlags_DelayShort). Usually used along with HoverStationaryDelay.
floatHoverDelayNormal;// Delay for IsItemHovered(ImGuiHoveredFlags_DelayNormal). "
ImGuiHoveredFlagsHoverFlagsForTooltipMouse;// Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using mouse.
ImGuiHoveredFlagsHoverFlagsForTooltipNav;// Default flags when using IsItemHovered(ImGuiHoveredFlags_ForTooltip) or BeginItemTooltip()/SetItemTooltip() while using keyboard/gamepad.
IMGUI_APIImGuiStyle();
IMGUI_APIvoidScaleAllSizes(floatscale_factor);
};
@ -1999,13 +2025,6 @@ struct ImGuiIO
floatIniSavingRate;// = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds.
constchar*IniFilename;// = "imgui.ini" // Path to .ini file (important: default "imgui.ini" is relative to current working dir!). Set NULL to disable automatic .ini loading/saving or if you want to manually call LoadIniSettingsXXX() / SaveIniSettingsXXX() functions.
constchar*LogFilename;// = "imgui_log.txt"// Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
floatMouseDoubleClickTime;// = 0.30f // Time for a double-click, in seconds.
floatMouseDoubleClickMaxDist;// = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
floatMouseDragThreshold;// = 6.0f // Distance threshold before considering we are dragging.
floatKeyRepeatDelay;// = 0.275f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
floatKeyRepeatRate;// = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
floatHoverDelayNormal;// = 0.30 sec // Delay on hovering before IsItemHovered(ImGuiHoveredFlags_DelayNormal) returns true.
floatHoverDelayShort;// = 0.10 sec // Delay on hovering before IsItemHovered(ImGuiHoveredFlags_DelayShort) returns true.
void*UserData;// = NULL // Store your own data.
ImFontAtlas*Fonts;// <auto> // Font atlas: load, rasterize and pack one or more fonts into a single texture.
@ -2037,18 +2056,31 @@ struct ImGuiIO
boolConfigWindowsMoveFromTitleBarOnly;// = false // Enable allowing to move windows only when clicking on their title bar. Does not apply to windows without a title bar.
floatConfigMemoryCompactTimer;// = 60.0f // Timer (in seconds) to free transient windows/tables memory buffers when unused. Set to -1.0f to disable.
// Inputs Behaviors
// (other variables, ones which are expected to be tweaked within UI code, are exposed in ImGuiStyle)
floatMouseDoubleClickTime;// = 0.30f // Time for a double-click, in seconds.
floatMouseDoubleClickMaxDist;// = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
floatMouseDragThreshold;// = 6.0f // Distance threshold before considering we are dragging.
floatKeyRepeatDelay;// = 0.275f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
floatKeyRepeatRate;// = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
// Tools to test correct Begin/End and BeginChild/EndChild behaviors.
// Presently Begin()/End() and BeginChild()/EndChild() needs to ALWAYS be called in tandem, regardless of return value of BeginXXX()
// This is inconsistent with other BeginXXX functions and create confusion for many users.
// We expect to update the API eventually. In the meanwhile we provide tools to facilitate checking user-code behavior.
boolConfigDebugBeginReturnValueOnce;// = false // First-time calls to Begin()/BeginChild() will return false. NEEDS TO BE SET AT APPLICATION BOOT TIME if you don't want to miss windows.
boolConfigDebugBeginReturnValueLoop;// = false // Some calls to Begin()/BeginChild() will return false. Will cycle through window depths then repeat. Suggested use: add "io.ConfigDebugBeginReturnValue = io.KeyShift" in your main loop then occasionally press SHIFT. Windows should be flickering while running.
// - option to deactivate io.AddFocusEvent(false) handling. May facilitate interactions with a debugger when focus loss leads to clearing inputs data.
// - backends may have other side-effects on focus loss, so this will reduce side-effects but not necessary remove all of them.
// - consider using e.g. Win32's IsDebuggerPresent() as an additional filter (or see ImOsIsDebuggerPresent() in imgui_test_engine/imgui_te_utils.cpp for a Unix compatible version).
// Option to deactivate io.AddFocusEvent(false) handling. May facilitate interactions with a debugger when focus loss leads to clearing inputs data.
// Backends may have other side-effects on focus loss, so this will reduce side-effects but not necessary remove all of them.
// Consider using e.g. Win32's IsDebuggerPresent() as an additional filter (or see ImOsIsDebuggerPresent() in imgui_test_engine/imgui_te_utils.cpp for a Unix compatible version).
boolConfigDebugIgnoreFocusLoss;// = false // Ignore io.AddFocusEvent(false), consequently not calling io.ClearInputKeys() in input processing.
// - tools to audit ini data
// Option to audit .ini data
boolConfigDebugIniSettings;// = false // Save .ini data with extra comments (particularly helpful for Docking, but makes saving slower)
ImGui::SliderFloat2("DisplaySafeAreaPadding",(float*)&style.DisplaySafeAreaPadding,0.0f,30.0f,"%.0f");ImGui::SameLine();HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
#define IM_STRINGIFY(_X) IM_STRINGIFY_HELPER(_X) // Preprocessor idiom to stringify e.g. an integer.
// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall