imgui-node-editor: Clipping is not related to the window with the latest imgui
I have updated imgui from 1.88dock to 1.89.3dock. The screen is cut, depending on the position. It seems the editor has the size of the window but its clipping is not related to the window but rather to the world space (?).
The recording should explain what’s going on, notice the huge black parts around the editor:
https://user-images.githubusercontent.com/31058/222499397-e62c3d76-0906-4719-9eea-b4b0b03a02d2.mp4
What’s interesting though, I’ve found this code in the imgui_canvas.cpp:
// #debug: Canvas content.
//m_DrawList->AddRectFilled(m_StartPos, m_StartPos + m_CurrentSize, IM_COL32(0, 0, 0, 64));
//m_DrawList->AddRect(m_WidgetRect.Min, m_WidgetRect.Max, IM_COL32(255, 0, 255, 64));
I have uncommented the last line and it seems to fix everything (it is, remove the black parts and not crop the content):

However, it doesn’t seem to be a proper fix since it is commented as debug code.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 24 (12 by maintainers)
Commits related to this issue
- workaround https://github.com/thedmd/imgui-node-editor/issues/205 — committed to Namek/imgui-node-editor by Namek a year ago
- Added temporary workaround for https://github.com/thedmd/imgui-node-editor/issues/205 — committed to ngscopeclient/imgui-node-editor by azonenberg a year ago
- Fix #205: workaround clipping issues when link with docked windows This is a workaround for https://github.com/thedmd/imgui-node-editor/issues/205 https://github.com/pthom/imgui_bun... — committed to pthom/imgui-node-editor by pthom a year ago
- Example code for reproducing https://github.com/thedmd/imgui-node-editor/issues/205 — committed to pthom/node_window_clipping_issue by pthom a year ago
- Example code for reproducing https://github.com/thedmd/imgui-node-editor/issues/205 — committed to pthom/node_window_clipping_issue by pthom a year ago
- Example code for reproducing https://github.com/thedmd/imgui-node-editor/issues/205 — committed to pthom/node_window_clipping_issue by pthom a year ago
- Example code for reproducing https://github.com/thedmd/imgui-node-editor/issues/205 — committed to pthom/node_window_clipping_issue by pthom a year ago
- Working version with ImGui v1.88 The issue thedmd/imgui-node-editor#205 was absent with ImGui 1.88. Not sure if that helps, though — committed to pthom/node_window_clipping_issue by pthom a year ago
- Canvas: Ensure canvas draw commands are separated from other ImGui draw commands (#205, #250) — committed to thedmd/imgui-node-editor by thedmd 10 months ago
- [Bundle]: Bandaid patch for imgui-node-editor ImDrawCallback_ImCanvas sentinel callback // Patch for imgui-node-editor, which sometimes leaves // its sentinel callback... — committed to pthom/imgui by pthom 3 months ago
Thank you @Namek, @pthom, @ocornut all for takin time to investigate the issue.
@pthom This is most awesome repro I saw so far. Thank you very much it was very helpful.
Fixes for all issues listed here were pushed to
develop.Thank you @ocornut for taking a time to investigate. I appreciate that.
You’re correct. Canvas did made some assumption about how ImGui deal with ImDrawCmd. If I can recall correctly there was always an empty one ready in the buffer.
I will investigate the issue.
Bonjour @ocornut 😃 , hi @thedmd and @Namek
I’m sorry it took you so long to build the example. I think it was an error on my side to use a third party such as HelloImGui.
I rewrote the minimal repro repository so that it uses only ImGui, imgui-node-editor and SDL (and nothing else).
This demo is able to trigger different subtle issues that arise when using docked windows, and/or windows whose size is unknown at the first frame (so that the canvas does not know its size)
They are detailed in the Readme.
Also, I made a short video in order to demonstrate them, as well as the use of the repo (in the hope to make it easier to setup). I think the video is a good way to get a more complete picture of the issue.
thanks
Note: I can confirm that the issue seems to be absent with ImGui docking v1.88 (commit 58eb40db76783f5da09e592ca3eb421f4f2197e3). I’m not sure if that helps, though. Anyhow, I created a branch imgui_1_88 in the repository. It uses the SDL2 branch of SDL (you will need to remove
external/and re-run fetch_external.sh).I’ll need to let @thedmd finish this investigation, but I looked at iteration into
CmdBuffer[]and noticed they started fromm_DrawListCommadBufferSizeand wanted to see how it was setup:Since the value is set multiple times every frame, to visualize I use this neat trick:
Creating and appending into a window declared locally inside that function.
When the bug appears a third line appears:
I suspect changing
m_DrawListCommadBufferSize = ImMax(m_DrawList->CmdBuffer.Size - 1, 0);tom_DrawListCommadBufferSize = ImMax(m_DrawList->CmdBuffer.Size, 0);Might be the correct fix for this, but I’ll need @thedmd to investigate and confirm. It certainly appears to fix the issue but I don’t know if that’s the correct fix.FIx should be applied from
IMGUI_VERSION_NUM > 18913.Just checked with latest imgui from git and the issue is still present.
@Namek I created a minimal reproducible example in this repository
This code is self-contained in a short file: node_clipping_issue.cpp
However it was not possible to use the ImGui version inside node editor, since it is outdated, and adds stack layout patches to ImGui which are not trivial to rebase. So it uses HelloImGui, which is based on a quite recent version of the ImGui docking branch.
I tried to rebase the stack-layout imgui/, checked out imgui-node-editor/develop, updated the copy with latest rebased imgui + stack-layout (with few fixes pushed to https://github.com/thedmd/imgui-node-editor/pull/208) and couldn’t see an issue.
Please actually provide details as to how to reproduce the issue in
imgui-node-editor. I don’t even know what example of node-editor looks like the one you posted screenshot of above.