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

Some patches for a smoother integration of imgui-node-editor and imgui #310

Open
pthom opened this issue Oct 15, 2024 · 0 comments
Open

Comments

@pthom
Copy link

pthom commented Oct 15, 2024

Hello @thedmd,

Many thanks for your wonderful library!

During the development of Dear ImGui Bundle, I applied a series of patches to imgui-node-editor and imgui, to make their integration smoother. Since they require modifications on both imgui and imgui-node-editor, proposing a PR is not straightforward.

However, since they might be useful, I took the time to group them here in this issue, in the hope of being helpful.

Demo

Video demo:

Untitled13.mov

You can also test it live on this webasm demo

Handle node width in separators:

Thanks to this patch, ImGui::SeparatorText(), ImGui::Separator(), and ImGui::CollapsingHeader() can use the actual node width. It was proposed here

Handle Popups:

@lukaasm proposed a patch here, which solves many issues with popups in the node editor (by automatically suspending the canvas, and placing popups correctly).

Example implementation for this patch:

With this patch, ImGui::ColorEdit, ImGui::Begin/EndCombo will work correctly inside a node.

Warn users if using BeginChild / EndChild:

imgui-node-editor remains incompatible with ImGui::BeginChild() and ImGui::EndChild().

Below is the list of ImGui widgets which are concerned (because they use BeginChild/EndChild):

  • ImGui::InputTextMultiline()
  • ImGui::BeginListbox() and ImGui::EndListbox()
  • ImGui::BeginChild() and ImGui::EndChild()

We can warn the developer whenever they use these functions inside a node:

Handle InputTextMultiline

By default InputTextMultiline uses a child window, which is not compatible with the node editor.
An additional patch adapts its behavior, by showing a preview within a single line text input,
followed by a "..." button which triggers a popup with the full text edition.

To apply this, two patches are required:

  • inside imgui-node-editor: A patch on top of @lukaasm's patch:
    we need to handle the "depth" of call to ImGui::Begin/End (only the first call should trigger):
    it is available here
  • inside imgui: A patch for InputTextMultiline is available here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant