mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-12 00:14:20 +00:00
(Breaking) Internals: added ImGuiItemFlags param to ItemHoverable(), so it can be called from ButtonBehavior() not following an ItemAdd().
This also allow moving AllowOverlap logic from ButtonBehavior() to ItemHoverable(), allowing other widgets to honor it. (#6512, #3909, #517)
This commit is contained in:
parent
10c7709f30
commit
4dee919bc0
4 changed files with 22 additions and 21 deletions
|
|
@ -4038,7 +4038,8 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||
}
|
||||
|
||||
// Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered().
|
||||
bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
|
||||
// (this does not rely on LastItemData it can be called from a ButtonBehavior() call not following an ItemAdd() call)
|
||||
bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
|
@ -4053,7 +4054,6 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
|
|||
return false;
|
||||
|
||||
// Done with rectangle culling so we can perform heavier checks now.
|
||||
ImGuiItemFlags item_flags = (g.LastItemData.ID == id ? g.LastItemData.InFlags : g.CurrentItemFlags);
|
||||
if (!(item_flags & ImGuiItemFlags_NoWindowHoverableCheck) && !IsWindowContentHoverable(window, ImGuiHoveredFlags_None))
|
||||
{
|
||||
g.HoveredIdDisabled = true;
|
||||
|
|
@ -12360,7 +12360,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|||
// Rely on keeping other window->LastItemXXX fields intact.
|
||||
source_id = g.LastItemData.ID = window->GetIDFromRectangle(g.LastItemData.Rect);
|
||||
KeepAliveID(source_id);
|
||||
bool is_hovered = ItemHoverable(g.LastItemData.Rect, source_id);
|
||||
bool is_hovered = ItemHoverable(g.LastItemData.Rect, source_id, g.LastItemData.InFlags);
|
||||
if (is_hovered && g.IO.MouseClicked[mouse_button])
|
||||
{
|
||||
SetActiveID(source_id, window);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue