1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 01:20:55 +01:00

Selectable, TreeNode: When using ImGuiSelectableFlags_AllowOverlap/ImGuiTreeNodeFlags_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
This commit is contained in:
ocornut 2023-06-26 14:47:05 +02:00
parent cada78917c
commit 3ec128c5fd
2 changed files with 7 additions and 5 deletions

View File

@ -65,6 +65,8 @@ Other changes:
Tweaked default value of style.HoverDelayShort from 0.10 to 0.15. (#1485) Tweaked default value of style.HoverDelayShort from 0.10 to 0.15. (#1485)
- IsWindowHovered: Added support for ImGuiHoveredFlags_Stationary. - IsWindowHovered: Added support for ImGuiHoveredFlags_Stationary.
- IsWindowHovered, IsItemHovered: Assert when passed any unsupported flags. - 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 - 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) ScrollX or ScrollY flags from being impossible to resize. (#6503)
- CollapsingHeader/TreeNode: Fixed text padding when using _Framed+_Leaf flags. (#6549) [@BobbyAnguelov] - CollapsingHeader/TreeNode: Fixed text padding when using _Framed+_Leaf flags. (#6549) [@BobbyAnguelov]

View File

@ -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); ButtonBehavior(bb_interact, id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap);
if (hovered) if (hovered)
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredRect; // for IsItemHovered(), because bb_interact is larger than bb 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(); SetItemAllowOverlap();
if (held || (hovered && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay)) if (held || (hovered && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay))
@ -6241,7 +6241,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledOpen; 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(); SetItemAllowOverlap();
// In this branch, TreeNodeBehavior() cannot toggle the selection so this will never trigger. // In this branch, TreeNodeBehavior() cannot toggle the selection so this will never trigger.
@ -6528,7 +6528,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if (pressed) if (pressed)
MarkItemEdited(id); MarkItemEdited(id);
if (flags & ImGuiSelectableFlags_AllowItemOverlap) if ((flags & ImGuiTreeNodeFlags_AllowItemOverlap) && g.ActiveId != id) // Because: we don't want to hover other while Active
SetItemAllowOverlap(); SetItemAllowOverlap();
// In this branch, Selectable() cannot toggle the selection so this will never trigger. // In this branch, Selectable() cannot toggle the selection so this will never trigger.
@ -8407,8 +8407,8 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
if (pressed && !is_tab_button) if (pressed && !is_tab_button)
TabBarQueueFocus(tab_bar, tab); 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) // 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) if (g.ActiveId != id) // Because: we don't want to hover other items while dragging active)
SetItemAllowOverlap(); SetItemAllowOverlap();
// Drag and drop: re-order tabs // Drag and drop: re-order tabs