mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 23:31:08 +01:00
Made BeginItemTooltip() and IsItemHovered() with delay flag infer an implicit ID using Pos only. (#7945, #1485, #143)
Perhaps a better approach would be to: store last non-zero ID + count successive zero ID and combine then.
This commit is contained in:
parent
a93f7db875
commit
f99febfd6f
@ -76,6 +76,8 @@ Other changes:
|
||||
- Windows: adjust default ClipRect to better match rendering of thick borders (which are in
|
||||
theory not supported). Compensate for the fact that borders are centered around the windows
|
||||
edge rather than inner. (#7887, #7888 + #3312, #7540, #3756, #6170, #6365)
|
||||
- Made BeginItemTooltip() and IsItemHovered() with delay flag infer an implicit ID (for
|
||||
ID-less items such as Text element) in a way that works when item resizes. (#7945, #1485)
|
||||
- MultiSelect+TreeNode+Drag and Drop: fixed an issue where carrying a drag and drop
|
||||
payload over an already open tree node would incorrectly select it. (#7850)
|
||||
- MultiSelect+TreeNode: default open behavior is OpenOnDoubleClick + OpenOnArrow
|
||||
|
12
imgui.cpp
12
imgui.cpp
@ -4261,7 +4261,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
||||
const float delay = CalcDelayFromHoveredFlags(flags);
|
||||
if (delay > 0.0f || (flags & ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
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->GetIDFromPos(g.LastItemData.Rect.Min);
|
||||
if ((flags & ImGuiHoveredFlags_NoSharedDelay) && (g.HoverItemDelayIdPreviousFrame != hover_delay_id))
|
||||
g.HoverItemDelayTimer = 0.0f;
|
||||
g.HoverItemDelayId = hover_delay_id;
|
||||
@ -8367,6 +8367,16 @@ ImGuiID ImGuiWindow::GetID(int n)
|
||||
}
|
||||
|
||||
// This is only used in rare/specific situations to manufacture an ID out of nowhere.
|
||||
// FIXME: Consider instead storing last non-zero ID + count of successive zero-ID, and combine those?
|
||||
ImGuiID ImGuiWindow::GetIDFromPos(const ImVec2& p_abs)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
ImVec2 p_rel = ImGui::WindowPosAbsToRel(this, p_abs);
|
||||
ImGuiID id = ImHashData(&p_rel, sizeof(p_rel), seed);
|
||||
return id;
|
||||
}
|
||||
|
||||
// "
|
||||
ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
|
2
imgui.h
2
imgui.h
@ -29,7 +29,7 @@
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.91.1 WIP"
|
||||
#define IMGUI_VERSION_NUM 19104
|
||||
#define IMGUI_VERSION_NUM 19105
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
/*
|
||||
|
@ -2715,6 +2715,7 @@ public:
|
||||
ImGuiID GetID(const char* str, const char* str_end = NULL);
|
||||
ImGuiID GetID(const void* ptr);
|
||||
ImGuiID GetID(int n);
|
||||
ImGuiID GetIDFromPos(const ImVec2& p_abs);
|
||||
ImGuiID GetIDFromRectangle(const ImRect& r_abs);
|
||||
|
||||
// We don't use g.FontSize because the window may be != g.CurrentWindow.
|
||||
@ -3124,8 +3125,8 @@ namespace ImGui
|
||||
inline void SetWindowParentWindowForFocusRoute(ImGuiWindow* window, ImGuiWindow* parent_window) { window->ParentWindowForFocusRoute = parent_window; }
|
||||
inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
|
||||
inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
|
||||
inline ImVec2 WindowPosRelToAbs(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x + off.x, p.y + off.y); }
|
||||
inline ImVec2 WindowPosAbsToRel(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x - off.x, p.y - off.y); }
|
||||
inline ImVec2 WindowPosRelToAbs(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x + off.x, p.y + off.y); }
|
||||
|
||||
// Windows: Display Order and Focus Order
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags = 0);
|
||||
|
Loading…
Reference in New Issue
Block a user