Skip to content

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

@pthom

Description

@pthom

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions