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

Internals: renamed HoverDelay fields.

This commit is contained in:
ocornut 2023-06-16 16:56:33 +02:00
parent 15d74bad1d
commit 194916135a
3 changed files with 23 additions and 23 deletions

View File

@ -3990,10 +3990,10 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
if (delay > 0.0f) if (delay > 0.0f)
{ {
ImGuiID hover_delay_id = (g.LastItemData.ID != 0) ? g.LastItemData.ID : window->GetIDFromRectangle(g.LastItemData.Rect); ImGuiID hover_delay_id = (g.LastItemData.ID != 0) ? g.LastItemData.ID : window->GetIDFromRectangle(g.LastItemData.Rect);
if ((flags & ImGuiHoveredFlags_NoSharedDelay) && (g.HoverDelayIdPreviousFrame != hover_delay_id)) if ((flags & ImGuiHoveredFlags_NoSharedDelay) && (g.HoverItemDelayIdPreviousFrame != hover_delay_id))
g.HoverDelayTimer = 0.0f; g.HoverItemDelayTimer = 0.0f;
g.HoverDelayId = hover_delay_id; g.HoverItemDelayId = hover_delay_id;
return g.HoverDelayTimer >= delay; return g.HoverItemDelayTimer >= delay;
} }
return true; return true;
@ -4538,21 +4538,21 @@ void ImGui::NewFrame()
#endif #endif
// Update hover delay for IsItemHovered() with delays and tooltips // Update hover delay for IsItemHovered() with delays and tooltips
g.HoverDelayIdPreviousFrame = g.HoverDelayId; g.HoverItemDelayIdPreviousFrame = g.HoverItemDelayId;
if (g.HoverDelayId != 0) if (g.HoverItemDelayId != 0)
{ {
//if (g.IO.MouseDelta.x == 0.0f && g.IO.MouseDelta.y == 0.0f) // Need design/flags //if (g.IO.MouseDelta.x == 0.0f && g.IO.MouseDelta.y == 0.0f) // Need design/flags
g.HoverDelayTimer += g.IO.DeltaTime; g.HoverItemDelayTimer += g.IO.DeltaTime;
g.HoverDelayClearTimer = 0.0f; g.HoverItemDelayClearTimer = 0.0f;
g.HoverDelayId = 0; g.HoverItemDelayId = 0;
} }
else if (g.HoverDelayTimer > 0.0f) else if (g.HoverItemDelayTimer > 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. // 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.HoverItemDelayClearTimer += g.IO.DeltaTime;
if (g.HoverDelayClearTimer >= ImMax(0.25f, g.IO.DeltaTime * 2.0f)) // ~7 frames at 30 Hz + allow for low framerate if (g.HoverItemDelayClearTimer >= 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.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.
} }
// Drag and drop // Drag and drop
@ -13968,7 +13968,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL"); Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
Text("ActiveIdUsing: AllKeyboardKeys: %d, NavDirMask: %X", g.ActiveIdUsingAllKeyboardKeys, g.ActiveIdUsingNavDirMask); Text("ActiveIdUsing: AllKeyboardKeys: %d, NavDirMask: %X", g.ActiveIdUsingAllKeyboardKeys, g.ActiveIdUsingNavDirMask);
Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Not displaying g.HoveredId as it is update mid-frame Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Not displaying g.HoveredId as it is update mid-frame
Text("HoverDelayId: 0x%08X, Timer: %.2f, ClearTimer: %.2f", g.HoverDelayId, g.HoverDelayTimer, g.HoverDelayClearTimer); Text("HoverItemDelayId: 0x%08X, Timer: %.2f, ClearTimer: %.2f", g.HoverItemDelayId, g.HoverItemDelayTimer, g.HoverItemDelayClearTimer);
Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize); Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
DebugLocateItemOnHover(g.DragDropPayload.SourceId); DebugLocateItemOnHover(g.DragDropPayload.SourceId);
Unindent(); Unindent();

View File

@ -1286,9 +1286,9 @@ enum ImGuiHoveredFlags_
ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows, ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows,
// Mouse Hovering delays (for tooltips) // Mouse Hovering delays (for tooltips)
ImGuiHoveredFlags_DelayNormal = 1 << 11, // Return true after io.HoverDelayNormal elapsed (~0.35 sec) ImGuiHoveredFlags_DelayNormal = 1 << 11, // IsItemHovered() only: 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, // IsItemHovered() only: 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, // 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::BeginDragDropSource(), ImGui::AcceptDragDropPayload() // Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload()

View File

@ -1958,10 +1958,10 @@ struct ImGuiContext
ImVector<ImGuiShrinkWidthItem> ShrinkWidthBuffer; ImVector<ImGuiShrinkWidthItem> ShrinkWidthBuffer;
// Hover Delay system // Hover Delay system
ImGuiID HoverDelayId; ImGuiID HoverItemDelayId;
ImGuiID HoverDelayIdPreviousFrame; ImGuiID HoverItemDelayIdPreviousFrame;
float HoverDelayTimer; // Currently used by IsItemHovered() float HoverItemDelayTimer; // Currently used by IsItemHovered()
float HoverDelayClearTimer; // Currently used by IsItemHovered(): grace time before g.TooltipHoverTimer gets cleared. float HoverItemDelayClearTimer; // Currently used by IsItemHovered(): grace time before g.TooltipHoverTimer gets cleared.
// Mouse state // Mouse state
ImGuiMouseCursor MouseCursor; ImGuiMouseCursor MouseCursor;
@ -2163,8 +2163,8 @@ struct ImGuiContext
TablesTempDataStacked = 0; TablesTempDataStacked = 0;
CurrentTabBar = NULL; CurrentTabBar = NULL;
HoverDelayId = HoverDelayIdPreviousFrame = 0; HoverItemDelayId = HoverItemDelayIdPreviousFrame = 0;
HoverDelayTimer = HoverDelayClearTimer = 0.0f; HoverItemDelayTimer = HoverItemDelayClearTimer = 0.0f;
MouseCursor = ImGuiMouseCursor_Arrow; MouseCursor = ImGuiMouseCursor_Arrow;