mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Drag and Drop: added ImGuiDragDropFlags_AcceptDrawAsHovered. (#8632)
Not calling SetHoveredId() in that path, does not seem necessary.
This commit is contained in:
parent
b0d3c3a674
commit
bd0e2036e0
3 changed files with 13 additions and 5 deletions
|
|
@ -94,9 +94,12 @@ Other Changes:
|
||||||
triggered by some widgets e.g. Checkbox(), Selectable() and many others, which
|
triggered by some widgets e.g. Checkbox(), Selectable() and many others, which
|
||||||
cleared ActiveId at the same time as editing. (#9028)
|
cleared ActiveId at the same time as editing. (#9028)
|
||||||
Note that IsItemDeactivatedAfterEdit() was not affected, only IsItemEdited).
|
Note that IsItemDeactivatedAfterEdit() was not affected, only IsItemEdited).
|
||||||
- Style, Drag and Drop: added ImGuiCol_DragDropTargetBg, style.DragDropTargetRounding,
|
- Drag and Drop:
|
||||||
style.DragDropTargetBorderSize and style.DragDropTargetPadding to configure
|
- Added ImGuiDragDropFlags_AcceptDrawAsHovered to make accepting item render
|
||||||
the drop target highlight. (#9056) [@aaronkirkham]
|
as hovered, which can allow using e.g. Button() as drop target. (#8632)
|
||||||
|
- Style: added ImGuiCol_DragDropTargetBg, style.DragDropTargetRounding,
|
||||||
|
style.DragDropTargetBorderSize and style.DragDropTargetPadding to configure
|
||||||
|
the drop target highlight. (#9056) [@aaronkirkham]
|
||||||
- Demo: About Box: emit infos to convey when IM_ASSERT() macro is disabled,
|
- Demo: About Box: emit infos to convey when IM_ASSERT() macro is disabled,
|
||||||
- so users don't miss out on programming errors being reported.
|
- so users don't miss out on programming errors being reported.
|
||||||
- so it is included in config/build info submitted in new GitHub Issues.
|
- so it is included in config/build info submitted in new GitHub Issues.
|
||||||
|
|
|
||||||
1
imgui.h
1
imgui.h
|
|
@ -1484,6 +1484,7 @@ enum ImGuiDragDropFlags_
|
||||||
ImGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered.
|
ImGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered.
|
||||||
ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target.
|
ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target.
|
||||||
ImGuiDragDropFlags_AcceptNoPreviewTooltip = 1 << 12, // Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site.
|
ImGuiDragDropFlags_AcceptNoPreviewTooltip = 1 << 12, // Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site.
|
||||||
|
ImGuiDragDropFlags_AcceptDrawAsHovered = 1 << 13, // Accepting item will render as if hovered. Useful for e.g. a Button() used as a drop target.
|
||||||
ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect, // For peeking ahead and inspecting the payload before delivery.
|
ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect, // For peeking ahead and inspecting the payload before delivery.
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
|
|
||||||
|
|
@ -574,8 +574,9 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||||
|
|
||||||
// Special mode for Drag and Drop used by openables (tree nodes, tabs etc.)
|
// Special mode for Drag and Drop used by openables (tree nodes, tabs etc.)
|
||||||
// where holding the button pressed for a long time while drag a payload item triggers the button.
|
// where holding the button pressed for a long time while drag a payload item triggers the button.
|
||||||
if (g.DragDropActive && (flags & ImGuiButtonFlags_PressedOnDragDropHold) && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoHoldToOpenOthers))
|
if (g.DragDropActive)
|
||||||
if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
|
{
|
||||||
|
if ((flags & ImGuiButtonFlags_PressedOnDragDropHold) && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoHoldToOpenOthers) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
|
||||||
{
|
{
|
||||||
hovered = true;
|
hovered = true;
|
||||||
SetHoveredID(id);
|
SetHoveredID(id);
|
||||||
|
|
@ -586,6 +587,9 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||||
FocusWindow(window);
|
FocusWindow(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (g.DragDropAcceptIdPrev == id && (g.DragDropAcceptFlagsPrev & ImGuiDragDropFlags_AcceptDrawAsHovered))
|
||||||
|
hovered = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (flatten_hovered_children)
|
if (flatten_hovered_children)
|
||||||
g.HoveredWindow = backup_hovered_window;
|
g.HoveredWindow = backup_hovered_window;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue