Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I automatically flow non-text to the current width of a window? #404

Open
xaxxon opened this issue Nov 12, 2015 · 4 comments
Open

Comments

@xaxxon
Copy link

xaxxon commented Nov 12, 2015

I want to have a bunch of things (imagebuttons to be specific) and have them automatically turned into rows based on the actual size of the window (or some container).

If the window is wide enough, they would all be on the same column and if the window is narrow enough they would be all down a single row.

Basically spread as wide as possible given the current window, but then overflow to a new line as necessary.

If I needed to, I could do the math myself, but I don't know how to get the current window / container width.

Thank you.

@ocornut
Copy link
Owner

ocornut commented Nov 15, 2015

Hello Zac and sorry for my late answer,

You can get the current window width with GetWindowWidth().
You probably want to call GetContentRegionAvailWidth() which would return you how much is available on your right, also remove the padding and work in context of columns.

To handle that automatically is however a desirable feature that hasn't been added yet but I'd like to add it someday.

@ocornut
Copy link
Owner

ocornut commented Jun 7, 2016

This old issue also relates to the older #97
Perhaps time to tackle that.

@wizzard0
Copy link

any chances this will be bumped up in priority?

@ocornut
Copy link
Owner

ocornut commented Aug 26, 2016

I might be able to look into it in September.

One tricky thing is that it will probably change the usage of ItemSize ItemAdd in a breaking way. Those functions are private and only declared in imgui_internal.h but among the most commonly used internal functions for people creating custom widgets.

Currently code calls ItemSize(ImVec2) to feed the size used for sizing calculation and then call ItemAdd(ImRect) to feed actual bounding box. The bounding box may have a different size, as the one passed to ItemSize often is a minimum required size, whereas the size used by ItemAdd may extend to all available space. The problem is that ItemSize(ImVec2) assume that the size extends from the cursor position.

What I imagine we might head to is to replace both with a new more fully-featured function, e.g. ItemLayout() that will perform the function of both and also allow moving the cursor.

It also relate to #395 for which I once had a semi-working stash but I wasn't happy with the code then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants