1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-13 18:50:58 +01:00

Tweak HoverDelayClearTimer. Not exposing since I am unsure logic is viable (and is rather complex with upcoming addition of stationary logic). (#1485)

+ Tweaked default value of io.HoverDelayNormal from 0.30 to 0.35.
This commit is contained in:
ocornut 2023-06-14 17:39:26 +02:00
parent 6cabad6e7a
commit eec344cc1e
4 changed files with 19 additions and 12 deletions

View File

@ -41,6 +41,8 @@ Other changes:
- Clipper: Rework inner logic to allow functioning with a zero-clear constructor. - Clipper: Rework inner logic to allow functioning with a zero-clear constructor.
This is order to facilitate usage for language bindings (e.g cimgui or dear_binding) This is order to facilitate usage for language bindings (e.g cimgui or dear_binding)
where user may not be callinga constructor manually. (#5856) where user may not be callinga constructor manually. (#5856)
- IsItemHovered: Tweaked default value of io.HoverDelayNormal from 0.30 to 0.35 (used when
using the ImGuiHoveredFlags_DelayNormal flag). (#1485)
- Tooltips: Tweak default offset for non-drag and drop tooltips so underlying items - 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) isn't covered as much. (Match offset for drag and drop tooltips)
- Debug Tools: Added 'io.ConfigDebugIniSettings' option to save .ini data with extra - Debug Tools: Added 'io.ConfigDebugIniSettings' option to save .ini data with extra
@ -50,7 +52,7 @@ Other changes:
This seems to happens on some Windows setup when peripherals disconnect, and is likely This seems to happens on some Windows setup when peripherals disconnect, and is likely
to also happen on browser+Emscripten. Matches similar 1.89.4 fix in SDL backend. (#6491) to also happen on browser+Emscripten. Matches similar 1.89.4 fix in SDL backend. (#6491)
- Examples: Win32+OpenGL3: Changed DefWindowProc() to DefWindowProcW() to match other examples - Examples: Win32+OpenGL3: Changed DefWindowProc() to DefWindowProcW() to match other examples
and support the example app being compiled without UNICODE. (#6516, #5725, #5961, #5975) and support the example app being compiled without UNICODE. (#6516, #5725, #5961, #5975) [@yenixing]
----------------------------------------------------------------------- -----------------------------------------------------------------------

View File

@ -1218,7 +1218,7 @@ ImGuiIO::ImGuiIO()
#endif #endif
KeyRepeatDelay = 0.275f; KeyRepeatDelay = 0.275f;
KeyRepeatRate = 0.050f; KeyRepeatRate = 0.050f;
HoverDelayNormal = 0.30f; HoverDelayNormal = 0.35f;
HoverDelayShort = 0.10f; HoverDelayShort = 0.10f;
UserData = NULL; UserData = NULL;
@ -4549,8 +4549,9 @@ void ImGui::NewFrame()
else if (g.HoverDelayTimer > 0.0f) else if (g.HoverDelayTimer > 0.0f)
{ {
// This gives a little bit of leeway before clearing the hover timer, allowing mouse to cross gaps // This gives a little bit of leeway before clearing the hover timer, allowing mouse to cross gaps
// We could expose 0.25f as io.HoverClearDelay but I am not sure of the logic yet, this is particularly subtle.
g.HoverDelayClearTimer += g.IO.DeltaTime; 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 if (g.HoverDelayClearTimer >= ImMax(0.25f, g.IO.DeltaTime * 2.0f)) // ~7 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. 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.
} }
@ -8529,7 +8530,8 @@ static void ImGui::UpdateMouseInputs()
io.MouseDelta = ImVec2(0.0f, 0.0f); io.MouseDelta = ImVec2(0.0f, 0.0f);
// 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. // 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.
if (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f) const bool is_stationary = (g.IO.MouseDelta.x == 0.0f && g.IO.MouseDelta.y == 0.0f);
if (!is_stationary)
g.NavDisableMouseHover = false; g.NavDisableMouseHover = false;
io.MousePosPrev = io.MousePos; io.MousePosPrev = io.MousePos;

View File

@ -1285,8 +1285,8 @@ enum ImGuiHoveredFlags_
ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped, ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped,
ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows, ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows,
// Hovering delays (for tooltips) // Mouse Hovering delays (for tooltips)
ImGuiHoveredFlags_DelayNormal = 1 << 11, // Return true after io.HoverDelayNormal elapsed (~0.30 sec) ImGuiHoveredFlags_DelayNormal = 1 << 11, // Return true after io.HoverDelayNormal elapsed (~0.35 sec)
ImGuiHoveredFlags_DelayShort = 1 << 12, // Return true after io.HoverDelayShort elapsed (~0.10 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) 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)
}; };
@ -1929,7 +1929,7 @@ struct ImGuiIO
float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging. 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 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 KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
float HoverDelayNormal; // = 0.30 sec // Delay on hovering before IsItemHovered(ImGuiHoveredFlags_DelayNormal) returns true. 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.10 sec // Delay on hovering before IsItemHovered(ImGuiHoveredFlags_DelayShort) returns true.
void* UserData; // = NULL // Store your own data. void* UserData; // = NULL // Store your own data.

View File

@ -1919,7 +1919,6 @@ struct ImGuiContext
// Render // Render
float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list) float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
ImGuiMouseCursor MouseCursor;
// Drag and Drop // Drag and Drop
bool DragDropActive; bool DragDropActive;
@ -1961,11 +1960,14 @@ struct ImGuiContext
// Hover Delay system // Hover Delay system
ImGuiID HoverDelayId; ImGuiID HoverDelayId;
ImGuiID HoverDelayIdPreviousFrame; ImGuiID HoverDelayIdPreviousFrame;
float HoverDelayTimer; // Currently used IsItemHovered(), generally inferred from g.HoveredIdTimer but kept uncleared until clear timer elapse. float HoverDelayTimer; // Currently used by IsItemHovered()
float HoverDelayClearTimer; // Currently used IsItemHovered(): grace time before g.TooltipHoverTimer gets cleared. float HoverDelayClearTimer; // Currently used by IsItemHovered(): grace time before g.TooltipHoverTimer gets cleared.
// Mouse state
ImGuiMouseCursor MouseCursor;
ImVec2 MouseLastValidPos;
// Widget state // Widget state
ImVec2 MouseLastValidPos;
ImGuiInputTextState InputTextState; ImGuiInputTextState InputTextState;
ImGuiInputTextDeactivatedState InputTextDeactivatedState; ImGuiInputTextDeactivatedState InputTextDeactivatedState;
ImFont InputTextPasswordFont; ImFont InputTextPasswordFont;
@ -2142,7 +2144,6 @@ struct ImGuiContext
NavWindowingToggleLayer = false; NavWindowingToggleLayer = false;
DimBgRatio = 0.0f; DimBgRatio = 0.0f;
MouseCursor = ImGuiMouseCursor_Arrow;
DragDropActive = DragDropWithinSource = DragDropWithinTarget = false; DragDropActive = DragDropWithinSource = DragDropWithinTarget = false;
DragDropSourceFlags = ImGuiDragDropFlags_None; DragDropSourceFlags = ImGuiDragDropFlags_None;
@ -2165,6 +2166,8 @@ struct ImGuiContext
HoverDelayId = HoverDelayIdPreviousFrame = 0; HoverDelayId = HoverDelayIdPreviousFrame = 0;
HoverDelayTimer = HoverDelayClearTimer = 0.0f; HoverDelayTimer = HoverDelayClearTimer = 0.0f;
MouseCursor = ImGuiMouseCursor_Arrow;
TempInputId = 0; TempInputId = 0;
ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_; ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_;
ColorEditCurrentID = ColorEditSavedID = 0; ColorEditCurrentID = ColorEditSavedID = 0;