IsItemHovered, Tooltips: Tweak default delay again. (#1485)

Amend eec344c
This commit is contained in:
ocornut 2023-06-15 15:23:05 +02:00
parent d96bbf0aae
commit f09ef23ae6
3 changed files with 22 additions and 21 deletions

View File

@ -43,8 +43,8 @@ Other changes:
where user may not be callinga constructor manually. (#5856)
- Modals: In the case of nested modal, made sure that focused or appearing windows are
moved below the lowest blocking modal (rather than the highest one). (#4317)
- IsItemHovered: Tweaked default value of io.HoverDelayNormal from 0.30 to 0.35 (used when
using the ImGuiHoveredFlags_DelayNormal flag). (#1485)
- IsItemHovered: Tweaked default value of io.HoverDelayNormal from 0.30 to 0.40,
Tweaked default value of io.HoverDelayShort from 0.10 to 0.15. (#1485)
- Tooltips: Tweak default offset for non-drag and drop tooltips so underlying items
isn't covered as much. (Match offset for drag and drop tooltips)
- Debug Tools: Added 'io.ConfigDebugIniSettings' option to save .ini data with extra

View File

@ -1218,8 +1218,8 @@ ImGuiIO::ImGuiIO()
#endif
KeyRepeatDelay = 0.275f;
KeyRepeatRate = 0.050f;
HoverDelayNormal = 0.35f;
HoverDelayShort = 0.10f;
HoverDelayShort = 0.15f;
HoverDelayNormal = 0.40f;
UserData = NULL;
Fonts = NULL;
@ -3981,10 +3981,10 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
// Handle hover delay
// (some ideas: https://www.nngroup.com/articles/timing-exposing-content)
float delay;
if (flags & ImGuiHoveredFlags_DelayNormal)
delay = g.IO.HoverDelayNormal;
else if (flags & ImGuiHoveredFlags_DelayShort)
if (flags & ImGuiHoveredFlags_DelayShort)
delay = g.IO.HoverDelayShort;
else if (flags & ImGuiHoveredFlags_DelayNormal)
delay = g.IO.HoverDelayNormal;
else
delay = 0.0f;
if (delay > 0.0f)
@ -10094,6 +10094,14 @@ void ImGui::EndTooltip()
End();
}
void ImGui::SetTooltip(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
SetTooltipV(fmt, args);
va_end(args);
}
void ImGui::SetTooltipV(const char* fmt, va_list args)
{
if (!BeginTooltipEx(ImGuiTooltipFlags_OverridePrevious, ImGuiWindowFlags_None))
@ -10102,13 +10110,6 @@ void ImGui::SetTooltipV(const char* fmt, va_list args)
EndTooltip();
}
void ImGui::SetTooltip(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
SetTooltipV(fmt, args);
va_end(args);
}
//-----------------------------------------------------------------------------
// [SECTION] POPUPS
@ -13588,7 +13589,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
else if (rect_type == WRT_InnerRect) { return window->InnerRect; }
else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; }
else if (rect_type == WRT_WorkRect) { return window->WorkRect; }
else if (rect_type == WRT_Content) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
else if (rect_type == WRT_Content) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
else if (rect_type == WRT_ContentIdeal) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSizeIdeal); }
else if (rect_type == WRT_ContentRegionRect) { return window->ContentRegionRect; }
IM_ASSERT(0);

12
imgui.h
View File

@ -665,7 +665,7 @@ namespace ImGui
IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = 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_API bool BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items).
IMGUI_API void EndTooltip(); // only call EndTooltip() if BeginTooltip() returns true!
IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip().
@ -1281,13 +1281,13 @@ 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_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped,
ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows,
// Mouse Hovering delays (for tooltips)
ImGuiHoveredFlags_DelayNormal = 1 << 11, // IsItemHovered() only: Return true after io.HoverDelayNormal elapsed (~0.35 sec)
ImGuiHoveredFlags_DelayShort = 1 << 12, // IsItemHovered() only: Return true after io.HoverDelayShort elapsed (~0.10 sec)
ImGuiHoveredFlags_DelayShort = 1 << 11, // IsItemHovered() only: Return true after io.HoverDelayShort elapsed (~0.15 sec)
ImGuiHoveredFlags_DelayNormal = 1 << 12, // IsItemHovered() only: Return true after io.HoverDelayNormal elapsed (~0.40 sec)
ImGuiHoveredFlags_NoSharedDelay = 1 << 13, // 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)
};
@ -1929,8 +1929,8 @@ struct ImGuiIO
float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging.
float KeyRepeatDelay; // = 0.275f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
float HoverDelayNormal; // = 0.35 sec // Delay on hovering before IsItemHovered(ImGuiHoveredFlags_DelayNormal) returns true.
float HoverDelayShort; // = 0.10 sec // Delay on hovering before IsItemHovered(ImGuiHoveredFlags_DelayShort) returns true.
float HoverDelayShort; // = 0.15 sec // Delay before IsItemHovered(ImGuiHoveredFlags_DelayShort) returns true.
float HoverDelayNormal; // = 0.40 sec // Delay before IsItemHovered(ImGuiHoveredFlags_DelayNormal) 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.