Layout-Question / Get ChildSize()

Hi,

I have beginner question. I’m frequently stumbling over layout tasks. Is there a simple method to position a button of a fixed size precisely in the bottom right corner of the current window?

I know that I could use GetWindowSize() to get the Size (including some header and WindowPadding). But I can’t figure out how to position the cursor precisely N pixels from the bottom. Using GetContentRegionMax() seems to include margins for scrollbars (which I have disabled).

thanks a lot,
tom

GetContentRegionMax() has issue on the axis where there is scrolling (e.g. GetContentRegionMax().x when there’s horizontal scrolling won’t be what you think).

If you use the latest version from master, use the tools in Metrics>Tools to visualize the different rectangles. Essentailly I would like to transition to exposing WorkRect and ditching ContentRegionRect over tme.

Sorry this doesn’t constitute a full answer per se, hope the tools will help.

Wow! Thanks for this quick reply. Metrics is awesome! (I can know ditch my own version of a similar window:) )

I have some more questions:

  1. Is there an API to access the regions presented by “Show window rectangles ContentRegionRect”?
  2. Would it be possible to format the list of windows so better see the nesting?
  3. What does currently appending mean?
  4. Are there any plans to make it possible to “pick” an element (similar to Firefox or Chrome?)

Thanks again for your incredible job!
Tom

  1. Depend which…
  2. It would require some work, but you can already browse child windows from a given window.
  3. This window is the one being output into so we cannot display the ImDrawList contents meaningfully (other window are showing either the last frame or the current frame draw list contents depending on their submission order relative to the Metrics window).
  4. I don’t understasnd the question.

Please try to use the github repo for detailed questions.

  1. I was referring to the screen rects of a window’s children (rendered in dark red)

  2. With the Chrome developer-tools you can “pick” a pixel of the UI to quickly see the UI-elements on that coordinate. In a similar way pix for DirectX re-renders a frame and collects all shaders, resources and properties involved in the rendering of a selected pixel. I don’t know, if something like this is even remotely feasible for ImGUI. But picking an item, and visualizing the current context, state, attributes and styles when it is being rendered would be extremely useful.

Please try to use the github repo for detailed questions

I was afraid that github-issues are for issues only. So far all issues I had with imgui were caused by my incomplete understanding of the framework.

How embarrassing! I finally figured out that ContentRegionMin / Max is precisely what I was looking for, but I somehow forgot add WindowPos:

            ImGui.GetForegroundDrawList().AddRect(
                ImGui.GetWindowContentRegionMin() + ImGui.GetWindowPos(),
                ImGui.GetWindowContentRegionMax() + ImGui.GetWindowPos(),
                Color.White);
1 Like