Nelarius / imnodes

A small, dependency-free node editor for dear imgui
MIT License
1.94k stars 236 forks source link

Panning on example_apple_opengl2 backend not working #114

Open jparismorgan opened 2 years ago

jparismorgan commented 2 years ago

Info

ImGui backend: https://github.com/ocornut/imgui/blob/docking/examples/example_apple_opengl2/main.mm ImGui branch: docking ImNodes example: https://github.com/Nelarius/imnodes/blob/master/example/hello.cpp

Issue

I am not able to pan around the graph. Have tried left / right click and pressing different keys down. Video:

https://user-images.githubusercontent.com/1396242/127697558-afbe466e-c6e1-483d-b706-9f7fee15833f.mov

Ristovski commented 2 years ago

Can confirm the same issue on Linux with a modified (to add minimap) colornode demo.

Green-Sky commented 2 years ago

dumb question: Have you tried middle mouse button?

edit: this might be related/a workaround: ImNodes::GetIO().EmulateThreeButtonMouse.Modifier = &ImGui::GetIO().KeyAlt;

Ristovski commented 2 years ago

Damn, indeed. From the OP I assumed the minimap responds to left clicking and dragging. Ping @jparismorgan :P

jparismorgan commented 2 years ago

Ah, this is it! I am able to pan with my middle mouse button.

Setting ImNodes::GetIO().EmulateThreeButtonMouse.Modifier = &ImGui::GetIO().KeyAlt; did not change behavior though (with or without alt key pressed, only the middle mouse button pans the canvas).

Nelarius commented 2 years ago

@jparismorgan Are you able to confirm whether left clicking and dragging while pressing alt pans the editor canvas?

hello.cpp


static HelloWorldNodeEditor editor;
} // namespace

void NodeEditorInitialize()
{
    ImNodes::SetNodeGridSpacePos(1, ImVec2(200.0f, 200.0f));
+   ImNodes::GetIO().EmulateThreeButtonMouse.Modifier = &ImGui::GetIO().KeyAlt;
}

void NodeEditorShow() { editor.show(); }
jparismorgan commented 2 years ago

Hey @Nelarius, that did not work for me. I also tried with KeyShift and KeySuper, and they did not work. It seems to be a conflict with the node selection handling, as I just get a selection box with I click and drag with any of them.

https://user-images.githubusercontent.com/1396242/133198183-309535f0-d05d-4aaf-9e3b-b291da75b51f.mov

Nelarius commented 2 years ago

Thanks, something isn't working. Thanks for providing the ImGui backends and branch, I'll see if I can repro using those. Additionally, I can see that you added the Minimap port to the hello.cpp example. Ane chance you could share the diff you are using?