Skip to content
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

Drag and drop preview on tree nodes and itemsize on tree nodes #1597

Closed
volcoma opened this issue Feb 6, 2018 · 7 comments
Closed

Drag and drop preview on tree nodes and itemsize on tree nodes #1597

volcoma opened this issue Feb 6, 2018 · 7 comments
Labels
drag drop drag and drop tree tree nodes

Comments

@volcoma
Copy link

volcoma commented Feb 6, 2018

I am using the new drag and drop stuff - they work great but I get an issue when trying to drop over a tree node target. The preview is kinda weird. It fights with the default hover effect on the treenode. Also getting the item size of the treenode seems to return the same smaller rect and not the one displayed by the default hover effect (the red one). Any ideas or is it a bug?
untitled

@ocornut
Copy link
Owner

ocornut commented Feb 6, 2018 via email

@volcoma
Copy link
Author

volcoma commented Feb 6, 2018

ya I updated and its not flickering. The problem is the outline rect and the itemsize of the treenode :). thx for the fast response.

@ocornut ocornut added bug and removed bug labels Feb 6, 2018
@ocornut
Copy link
Owner

ocornut commented Feb 6, 2018

That rectangle correspond to the interaction hit-box for the tree node, which is this way by default to allow items to be added on the right side of the tree node.

It's a little tricky to solve at the moment, will look at it later. Also linking to #143, one of the remaining feature for drag and drop is to be able to implement full dragging of/within tree nodes, with helpers to be able to distinguish "drag between those 2 nodes" vs "drag inside this node".

In the meanwhile you can pass the ImGuiDragDropFlags_AcceptNoDrawDefaultRect flag to AcceptDragDropPayload() and it won't draw that rectangle.

Repro code to paste anywhere there is a Color widget in sight:
(please provide repro code when you submit a request of that sort)

bool open = ImGui::TreeNode("Test");
if (ImGui::BeginDragDropTarget())
{
    if (ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F))
    {
    }
    ImGui::EndDragDropTarget();
}
if (open)
{
    ImGui::Text("Hello");
    ImGui::TreePop();
}

@ocornut
Copy link
Owner

ocornut commented Feb 6, 2018

It's a little tricky to solve at the moment, will look at it later.

Actually this is overlapping with some changes I wanted to make for the Navigation branch and I can store this without making internal's ItemAdd() more complex, so I'm going to fix it now.

@volcoma
Copy link
Author

volcoma commented Feb 6, 2018

Thats great man :) thx

ocornut added a commit that referenced this issue Feb 6, 2018
…rame. Added optional internal storage for item display rect. Will expose later. (#1597, #143)
@ocornut
Copy link
Owner

ocornut commented Feb 6, 2018

Fixed now.

image

@ocornut ocornut closed this as completed Feb 6, 2018
@volcoma
Copy link
Author

volcoma commented Feb 6, 2018

Thanks great!

@ocornut ocornut added the drag drop drag and drop label Apr 11, 2018
@ocornut ocornut added the tree tree nodes label Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drag drop drag and drop tree tree nodes
Projects
None yet
Development

No branches or pull requests

2 participants