mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 09:30:56 +01:00
Overlap: moved ImGuiItemflags_AllowOverlap handling from ButtoBehavior() to ItemHoverable() now that it is possible. (#6512, #3909, #517)
This allows DragXXX, SliderXXX, PlotXXX etc to honor SetNextItemAllowOverlap().
This commit is contained in:
parent
4dee919bc0
commit
6137443d24
@ -50,6 +50,10 @@ Breaking changes:
|
|||||||
- Renamed 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'
|
- Renamed 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'
|
||||||
- IsItemHovered: Changed behavior to return false when querying an item using AllowOverlap mode
|
- IsItemHovered: Changed behavior to return false when querying an item using AllowOverlap mode
|
||||||
which is being overlapped. Added ImGuiHoveredFlags_AllowWhenOverlappedByItem. (#6512, #3909, #517)
|
which is being overlapped. Added ImGuiHoveredFlags_AllowWhenOverlappedByItem. (#6512, #3909, #517)
|
||||||
|
- Selectable, TreeNode: When using ImGuiSelectableFlags_AllowOverlap/ImGuiTreeNodeFlags_AllowOverlap
|
||||||
|
and holding item held, overlapping widgets won't appear as hovered. (#6512, #3909)
|
||||||
|
- Most item types should now work with SetNextItemAllowOverlap(). (#6512, #3909, #517)
|
||||||
|
- Fixed first frame of an overlap highlighting underlying item if previous frame didn't hover anything.
|
||||||
- Kept redirecting enums (will obsolete).
|
- Kept redirecting enums (will obsolete).
|
||||||
|
|
||||||
Other changes:
|
Other changes:
|
||||||
@ -77,10 +81,6 @@ Other changes:
|
|||||||
- IsItemHovered: Added _AllowWhenOverlappedByWindow to ignore window-overlap only.
|
- IsItemHovered: Added _AllowWhenOverlappedByWindow to ignore window-overlap only.
|
||||||
Option ImGuiHoveredFlags_AllowWhenOverlapped now expand into a combination of both
|
Option ImGuiHoveredFlags_AllowWhenOverlapped now expand into a combination of both
|
||||||
_AllowWhenOverlappedByWindow + _AllowWhenOverlappedByItem, matching old behavior.
|
_AllowWhenOverlappedByWindow + _AllowWhenOverlappedByItem, matching old behavior.
|
||||||
- Overlapping items: (#6512, #3909, #517)
|
|
||||||
- Selectable, TreeNode: When using ImGuiSelectableFlags_AllowOverlap/ImGuiTreeNodeFlags_AllowOverlap
|
|
||||||
and holding item held, overlapping widgets won't appear as hovered. (#6512, #3909)
|
|
||||||
- Fixed first frame of an overlap highlighting underlying item if previous frame didn't hover anything.
|
|
||||||
- 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.
|
||||||
- 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
|
||||||
|
@ -4069,6 +4069,15 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flag
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
SetHoveredID(id);
|
SetHoveredID(id);
|
||||||
|
|
||||||
|
// AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match.
|
||||||
|
// This allows using patterns where a later submitted widget overlaps a previous one. Generally perceived as a front-to-back hit-test.
|
||||||
|
if (item_flags & ImGuiItemflags_AllowOverlap)
|
||||||
|
{
|
||||||
|
g.HoveredIdAllowOverlap = true;
|
||||||
|
if (g.HoveredIdPreviousFrame != id)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// When disabled we'll return false but still set HoveredId
|
// When disabled we'll return false but still set HoveredId
|
||||||
|
@ -531,15 +531,6 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
if (flatten_hovered_children)
|
if (flatten_hovered_children)
|
||||||
g.HoveredWindow = backup_hovered_window;
|
g.HoveredWindow = backup_hovered_window;
|
||||||
|
|
||||||
// AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one.
|
|
||||||
if (item_flags & ImGuiItemflags_AllowOverlap)
|
|
||||||
{
|
|
||||||
if (hovered && g.HoveredIdPreviousFrame != id)
|
|
||||||
hovered = false;
|
|
||||||
if (g.HoveredId == id) // FIXME: Added this to match legacy SetItemAllowOverlap(). Investigate precise side-effects of using (hovered==true) instead?
|
|
||||||
g.HoveredIdAllowOverlap = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mouse handling
|
// Mouse handling
|
||||||
const ImGuiID test_owner_id = (flags & ImGuiButtonFlags_NoTestKeyOwner) ? ImGuiKeyOwner_Any : id;
|
const ImGuiID test_owner_id = (flags & ImGuiButtonFlags_NoTestKeyOwner) ? ImGuiKeyOwner_Any : id;
|
||||||
if (hovered)
|
if (hovered)
|
||||||
|
Loading…
Reference in New Issue
Block a user