Hi. I'm using ImGui to make node editor (using imgui-node-editor extension). I want to position node title at the top center of the node.
Using this piece of code:
var textWidth = ImGui.calcTextSizeX(nodeName);
var nodeWidth = NodeEditor.getNodeSizeX(node.getNodeId()) - 20F;
var textX = Math.max(0F, (nodeWidth - textWidth) * 0.5F);
ImGui.setCursorPosX(ImGui.getCursorPosX() + textX);
Makes the title text appear at the left side of the node at first frame (node width is not known initially, depends on port name widths). At the next frame, it's repositioned to the center of the node. But this repositioning is noticeable for user. Not ideal.
Also, this solution is kinda hacky (without - 20F title is offset to the right a bit. Maybe it's not the exact value, not sure where it's coming from, maybe node borders).
Blueprints example of imgui-node-editor uses Spring extension from https://github.com/thedmd/imgui/tree/feature/layout (as mentioned in the project's README). I think that functions from that fork would not only be useful for ImGui NodeEditor, but also other use-cases where you need to position element horizontally.
Would be cool if you can look at it and, maybe, implement in imgui-java?
Hi. I'm using ImGui to make node editor (using imgui-node-editor extension). I want to position node title at the top center of the node.
Using this piece of code:
Makes the title text appear at the left side of the node at first frame (node width is not known initially, depends on port name widths). At the next frame, it's repositioned to the center of the node. But this repositioning is noticeable for user. Not ideal.
Also, this solution is kinda hacky (without
- 20Ftitle is offset to the right a bit. Maybe it's not the exact value, not sure where it's coming from, maybe node borders).Blueprints example of
imgui-node-editorusesSpringextension from https://github.com/thedmd/imgui/tree/feature/layout (as mentioned in the project's README). I think that functions from that fork would not only be useful for ImGui NodeEditor, but also other use-cases where you need to position element horizontally.Would be cool if you can look at it and, maybe, implement in imgui-java?