-
Notifications
You must be signed in to change notification settings - Fork 566
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
Clipping error when using ImGui::SeparatorText in a node #214
Comments
Separators use windows I think there is a workaround: Does that solve your problem? |
I have this same problem, and will probably try to work around this as suggested by @thedmd, but in my case nodes do not have a fixed size unfortunately. So this means I will probably have to somehow pre-calculate the node with based on the contents I'm going to put there. I'm wondering whether it would be possible for imgui-node-editor to somehow calculate and set the clip rectangle automatically? I haven't studied the source code very well and I'm not an ImGui expert either, but I guess after calling ax::NodeEditor::EndNode, the size of the node is known, and could be used by subsequent draws to set the clip rectangle accordingly? For the first draw the clip rect could be set to (0, 0) so the first frame the node will be drawn empty, which may not be ideal but at least that way things like separators and collapsing headers can be used inside of nodes? |
I was able to implement the workaround suggested by @thedmd, by pre-calculating the width of the node header using that to set the clip rect for the rest of the node contents, that way separators etc are clipped correctly. I did find another problem related to this though, which is sort of the opposite: if nodes move too far to the right, separators and collapsing headers are cut off too early. For example look at the following screenshot where I disabled the PushClipRect workaround, so you would expect the separators to run all the way to far right end of the editor: The orange node itself is drawn ok, but the separators are prematurely cut off. Some observations:
I think what is going on, is that somewhere graph world-coordinates and window view-coordinates are being mixed up, affecting the WorkArea.Min/Max coordinates? The node-editor itself probably never looks at the window WorkArea so all its own drawing looks ok, but ImGui controls that use it are broken. I don't know enough about ImGui internals though so maybe what I'm saying makes no sense. Is there no way for the node editor to make sure the window WorkArea coordinates are properly matched with the node editor zoom/pan transform? |
WorkArea is troublesome. To make things look right Node Editor would have to track much, much more state that now, basically immitate what child windows do. Editor will then became more susceptable to internal changes in ImGui which will bump maintainance time significantly. I think the simplest way to address the issue is to roll out custom version of Another option would be to patch local copy of ImGui with extension: -void SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_w);
+void SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_w, float width = 0.0f); Where |
Revisiting this for a new project that also uses imgui-node-editor. @thedmd could you maybe have a look at Omar's comments on ocornut/imgui#7255 and comment on what he's suggesting (make imgui-node-editor WorkArea-aware and/or have a way to force node width so that controls like SeparatorText understand them)? I would be willing to spend some effort trying to modify imgui-node-editor so it behaves better with controls that depend on WorkRect, but only if there is some chance this will actually work and would be considered for merging at some point. It would be really nice to be able to use not just separaters but for example also collapsing headers inside nodes. |
Also see #298 for a possible solution |
Steps to reproduce: Call ImGui::SeparatorText() inside a graph node
Expected result: horizontal line stops at end of node
Actual result: line runs off to infinity at right side
I tried using a child window to do the clipping but this resulted in the node size growing to infinity.
Maybe related to #205?
The text was updated successfully, but these errors were encountered: