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

ComboBox flag for dynamic X resize #6881

Closed
wants to merge 2 commits into from
Closed

ComboBox flag for dynamic X resize #6881

wants to merge 2 commits into from

Conversation

mpv-enjoyer
Copy link
Contributor

This flag might be helpful in situations when you want an empty visible label with fully visible ComboBox preview (in a limited space) or when you simply want to save unused space. Right now combobox takes up at least twice of it's label's visible width and does not check for preview width (which makes working with empty labels unbearable).

I used this solution while working with ComboBox in tables (with ImGuiTableFlags_SizingFixedFit flag), similar example below.
image
image

mpv-enjoyer and others added 2 commits September 30, 2023 18:51
to match original projects' code style
@ocornut
Copy link
Owner

ocornut commented Oct 9, 2023

Hello,

Thanks for your PR.

I have mixed feeling about this:

  • I'm not sure this is an idiom we want to encourage. While it looks senseful in e.g. static screenshot, when you end up having multiple rows in that tables everything would look weirdly unaligned.
  • It's also something you could technically do from the outside by calling ImGui::SetNextItemWidth(), but I admit it would be a bit awkward to copy the computation of button width and spacing.
  • It won't work with ImGuiComboFlags_CustomPreview.

However, since actual code change is so simple, and I can see it being useful for super-dense types of UI (which are going to not look very good, but practical), I think it's ok to merge.

@ocornut
Copy link
Owner

ocornut commented Oct 9, 2023

I have now merged 112d8fc (your changes) + feddcf3 (amends: added asserts, fix padding computation).
Thank you!

@ocornut ocornut closed this Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants