mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 03:47:00 +00:00
Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceAllowNullID doesn't lose tooltip when scrolling. (#143)
Reduced amount of self critical commentary since it'll appear like a hack for users but it isn't more a hack than many other things.
This commit is contained in:
parent
f8a806ad9f
commit
2c29e391dd
@ -67,6 +67,8 @@ Other Changes:
|
||||
by the clipper to display. (#3841)
|
||||
- Clipper: fixed content height declaration slightly mismatching the value of when not using a clipper.
|
||||
(an additional ItemSpacing.y was declared, affecting scrollbar range).
|
||||
- Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceAllowNullID doesn't lose
|
||||
tooltip when scrolling. (#143)
|
||||
- Backends: Vulkan: Call vkCmdSetScissor() at the end of render with a full-viewport to reduce
|
||||
likehood of issues with people using VK_DYNAMIC_STATE_SCISSOR in their app without calling
|
||||
vkCmdSetScissor() explicitly every frame. (#4644)
|
||||
|
@ -3121,7 +3121,7 @@ ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n)
|
||||
ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
const int r_rel[4] = { (int)(r_abs.Min.x - Pos.x), (int)(r_abs.Min.y - Pos.y), (int)(r_abs.Max.x - Pos.x), (int)(r_abs.Max.y - Pos.y) };
|
||||
ImRect r_rel = ImGui::WindowRectAbsToRel(this, r_abs);
|
||||
ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed);
|
||||
ImGui::KeepAliveID(id);
|
||||
return id;
|
||||
@ -10276,16 +10276,16 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
||||
return false;
|
||||
|
||||
// If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to:
|
||||
// A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride.
|
||||
// A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag.
|
||||
if (!(flags & ImGuiDragDropFlags_SourceAllowNullID))
|
||||
{
|
||||
IM_ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image()
|
||||
// Magic fallback to handle items with no assigned ID, e.g. Text(), Image()
|
||||
// We build a throwaway ID based on current ID stack + relative AABB of items in window.
|
||||
// THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
|
||||
// THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING/RESIZINGG OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
|
||||
// We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive.
|
||||
// Rely on keeping other window->LastItemXXX fields intact.
|
||||
source_id = g.LastItemData.ID = window->GetIDFromRectangle(g.LastItemData.Rect);
|
||||
|
Loading…
Reference in New Issue
Block a user