How to know if a tab bar of a docked window is hidden and its height


I am trying to get the height of the tab bar for a docked window but I do not know how to get it. Moreover even if I get it I do not know if it will return the right value when it is hidden so I may need to know if it is hidden too.

I show you in a picture[1] what I am talking about just in case.

Thank you.


You could open this sort of issue in the github issue tracker.

Anyway, my first and main question is almost always “Why do you need to do that ?”. If you don’t justify the use for some data or features, we are at risk of misleading you further into a direction that is not the ideal one. Try to always provide the “why” and the context.

Yeah, you are right. The problem is to calculate the mouse click position relative to the viewport I need to take into account the height of the tab bar if it is not hidden.

So I calculate it with ImGui::GetWindowSize(); and ImGui::GetWindowPos(); but I don’t know how to get the offset til the part I am drawing.

I was not sure if it was an issue or something that I did not know, if you want I open it as an issue.

As expected this is maybe the wrong direction.
You shouldn’t need to have to calculate any of that.
How are you drawing that viewport in the first place?

Are you using e.g. an Image() call ?
You can call GetCursorScreenPos() before the Image() call to get the current layout position.

Or you can call GetItemRectMin()/GetItemRectMax after the Image() call to retrieve the bounding box of the widget you just submitted.

Thank you for your answers @ocornut. I have used GetItemRectMin()/GetItemRectMax and now I get the correct ABB for the Image I was using to draw the viewport even when the tab bar title is hidden.

1 Like