Closed pthom closed 8 months ago
Closing this, the solution is that once you use ImGui::BeginHorizontal
in a given window, you should also use ImGui::BeginVertical
(so that the vertical layout width is transferred to its child horizontal layout).
And the code could for example be:
ed::BeginNode(node_id);
// A vertical layout that will contain the horizontal layout as a child
ImGui::BeginVertical("Vertical");
{
// A dummy item to set the node min width
ImGui::Dummy(ImVec2(minWidth, 0));
// Edit the min width
ImGui::Text("Min Width");
ImGui::SetNextItemWidth(70.f);
ImGui::SliderFloat("##minWidth", &minWidth, 0.f, 600.f);
// The horizontal child layout
ImGui::BeginHorizontal("Hor");
{
ImGui::Text("LEFT LABEL");
ImGui::Spring();
ImGui::Text("RIGHT LABEL");
}
ImGui::EndHorizontal();
}
ImGui::EndVertical();
ed::EndNode();
I think it could be worse it to add a succinct doc to imgui_stacklayout.h
in the future. If you are interested, I could try to propose something.
Thanks!
Hello,
I would like more information about the usage of your horizontal layout utilities inside a node.
I made some test with the following simple code:
With horizontalLayoutWidth = 0.f, I have the following result:
(i.e. the right label is not aligned to the right)
I tested different other possibilities, but did not find the correct one, I guess:
Here is a quick video of what I observed (1 minute long)
https://github.com/thedmd/imgui-node-editor/assets/7694091/18f61b4c-6b70-46a8-9c1b-0ef598f912b6
Am I missing something?
Many thanks for your hard work!