-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I add a separator line for dragging and dropping selectables? #7803
Comments
(A) (B)
Also see #2823 |
My implementation for a scene outliner had to solve the same problem. Maybe my solution will help you, it has this basic structure:
The drop target for the child window that contains basically everything is the most interesting part. That is where I draw the insertion line manually like this: // dropBeforeItem = memorized item for reordering
// dropRectMin/Max = x spans dropBeforeItem (with same indentation),
// y spans space between previous item and dropBeforeItem
// handle dropping items in front of other items
if ( ( dropBeforeItem != nullptr ) && ImGui::BeginDragDropTarget() )
{
ImGuiDragDropFlags flags = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect;
if ( const ImGuiPayload* payload = ImGui::AcceptDragDropPayload( Outliner_Payload, flags ) )
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
dropRectMin.y = dropRectMax.y = 0.5f * ( dropRectMin.y + dropRectMax.y );
drawList->AddLine( dropRectMin, dropRectMax, ImGui::GetColorU32( ImGuiCol_DragDropTarget ), 3.5f );
if ( payload->IsDelivery() )
{
// handle actual editor specific stuff
// - filter circular dependencies
// - make selected items children of parent of dropBeforeItem
// - reorder selected items to be before dropBeforeItem
// - record all changes for the undo/redo system
}
}
ImGui::EndDragDropTarget();
} |
Version/Branch of Dear ImGui:
docking
Back-ends:
imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
Compiler, OS:
Windows 10 + MSVC
Full config/build information:
No response
Details:
I am trying to make a list of objects, and you can drag and drop them around to change their position in the std::vector of objects.
This is my code for doing this:
Currently, I have to drag object selectables into each other, but I want there to be a line between the objects that is invisible and acts as a drag target that I can drag the object selectables into. But how would I do that?
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered: