How does ImGui know what the current level of indentation is?

936 Views Asked by At

It just dawned on me that with ImGui

if(CollapsingHeader("MyHeader"))
{
    if(Button("B"))
    {
      // Do stuff
    }
}

Results in a different rendering than:

if(CollapsingHeader("MyHeader"))
{
}
if(Button("B"))
{
      // Do stuff
}

With the first the button is nested in the header, with the second it is outside the header. How on earth can ImGui tell that in the first version the button function is nested within the if but that in the second it isn't?

0

There are 0 best solutions below