Skip to content

Commit

Permalink
Selectable, TreeNode: When using ImGuiSelectableFlags_AllowOverlap/Im…
Browse files Browse the repository at this point in the history
…GuiTreeNodeFlags_AllowOverlap and holding item held, overlapping widgets won't appear as hovered. (#6512, #3909)

Essentially we are going to remove calls to SetItemAllowOverlap() and standardize the fact that only 'HoveredId == id' test from it is performed.

# Conflicts:
#	imgui_widgets.cpp
  • Loading branch information
ocornut committed Jun 26, 2023
1 parent cada789 commit 3ec128c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Other changes:
Tweaked default value of style.HoverDelayShort from 0.10 to 0.15. (#1485)
- IsWindowHovered: Added support for ImGuiHoveredFlags_Stationary.
- IsWindowHovered, IsItemHovered: Assert when passed any unsupported flags.
- Selectable, TreeNode: When using ImGuiSelectableFlags_AllowOverlap/ImGuiTreeNodeFlags_AllowOverlap
and holding item held, overlapping widgets won't appear as hovered. (#6512, #3909)
- Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either
ScrollX or ScrollY flags from being impossible to resize. (#6503)
- CollapsingHeader/TreeNode: Fixed text padding when using _Framed+_Leaf flags. (#6549) [@BobbyAnguelov]
Expand Down
10 changes: 5 additions & 5 deletions imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float
ButtonBehavior(bb_interact, id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap);
if (hovered)
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredRect; // for IsItemHovered(), because bb_interact is larger than bb
if (g.ActiveId != id)
if (g.ActiveId != id) // Because: we don't want to hover other while Active
SetItemAllowOverlap();

if (held || (hovered && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay))
Expand Down Expand Up @@ -6241,7 +6241,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledOpen;
}
}
if (flags & ImGuiTreeNodeFlags_AllowItemOverlap)
if ((flags & ImGuiTreeNodeFlags_AllowItemOverlap) && g.ActiveId != id) // Because: we don't want to hover other while Active
SetItemAllowOverlap();

// In this branch, TreeNodeBehavior() cannot toggle the selection so this will never trigger.
Expand Down Expand Up @@ -6528,7 +6528,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if (pressed)
MarkItemEdited(id);

if (flags & ImGuiSelectableFlags_AllowItemOverlap)
if ((flags & ImGuiTreeNodeFlags_AllowItemOverlap) && g.ActiveId != id) // Because: we don't want to hover other while Active

This comment has been minimized.

Copy link
@elect86

elect86 Aug 3, 2023

Contributor

Are you sure you didn't mean ImGuiSelectableFlags_AllowItemOverlap instead of ImGuiTreeNodeFlags_AllowItemOverlap?

This comment has been minimized.

Copy link
@elect86

elect86 Aug 3, 2023

Contributor

Forget, you fixed it the very next commit

SetItemAllowOverlap();

// In this branch, Selectable() cannot toggle the selection so this will never trigger.
Expand Down Expand Up @@ -8407,8 +8407,8 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
if (pressed && !is_tab_button)
TabBarQueueFocus(tab_bar, tab);

// Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered)
if (g.ActiveId != id)
// Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs or collapse/close button to be hovered)
if (g.ActiveId != id) // Because: we don't want to hover other items while dragging active)
SetItemAllowOverlap();

// Drag and drop: re-order tabs
Expand Down

0 comments on commit 3ec128c

Please sign in to comment.