Imgui: Vertical alignement

Created on 3 Dec 2015  路  2Comments  路  Source: ocornut/imgui

Hi,

Is there a way to align some widgets on the bottom of a dialog ?

By example, I have several Collapsable headers, so the content size is dynamic !

How can I force the "Ok/Cancel" buttons to stay on the bottom ?

Thanks

layout

Most helpful comment

Krys,

In the absence of better layout helpers, there's a few ways so you can that for now

  • Either explicitly manipulate the cursor position, as simple as a SetCursorPosY
  • More typically as your content above may be dynamic and grow larger, that content may be in a child window to allow for scrolling. So it is a case of growing your child window to leave just enough space, which can be done with BeginChild("child_id", ImVec2(0,-xxxx)); That should work and cater for most simple case. See the layout example in the demo code.

// Leave room for 1 line below us ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing()));

layout

Ideally ImGui would have layout helpers to make that more straightforward and flexible in more situation, there's a fair amount of work required to get proper layout in.

All 2 comments

Krys,

In the absence of better layout helpers, there's a few ways so you can that for now

  • Either explicitly manipulate the cursor position, as simple as a SetCursorPosY
  • More typically as your content above may be dynamic and grow larger, that content may be in a child window to allow for scrolling. So it is a case of growing your child window to leave just enough space, which can be done with BeginChild("child_id", ImVec2(0,-xxxx)); That should work and cater for most simple case. See the layout example in the demo code.

// Leave room for 1 line below us ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing()));

layout

Ideally ImGui would have layout helpers to make that more straightforward and flexible in more situation, there's a fair amount of work required to get proper layout in.

Sure, layout request a lot of work :-P

Thanks for your help

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SlNPacifist picture SlNPacifist  路  3Comments

the-lay picture the-lay  路  3Comments

ILoveImgui picture ILoveImgui  路  3Comments

bogdaNNNN1 picture bogdaNNNN1  路  3Comments

inflex picture inflex  路  3Comments