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

First column is actually way wider than others #1266

Closed
devsaider opened this issue Aug 5, 2017 · 2 comments
Closed

First column is actually way wider than others #1266

devsaider opened this issue Aug 5, 2017 · 2 comments

Comments

@devsaider
Copy link

ImGui::Text("%f", ImGui::GetColumnWidth());
ImGui::Text("%f", ImGui::GetContentRegionAvailWidth());
ImGui::Text("%f", ImGui::GetContentRegionMax().x);
ImGui::Text("%f", ImGui::GetColumnOffset());

I've inserted this code to imgui_demo.cpp (line 1357). Result:
nz8w6ek

First column always shows bigger ImGui::GetContentRegionAvailWidth(). Why and how to fix?

@ocornut
Copy link
Owner

ocornut commented Aug 7, 2017

I'm looking into it, the reason is that columns after the first one have a bit of space between the border, whereas the first column doesn't have it. It makes sense because we don't display the left border (which in some situations is nice, in some perhaps less so). In your case since you don't use borders it's even weirder to see it like that.

Adding this spacing for the first column would offset the text in your picture a little on the right which would be odd. There are different solutions (perhaps different depending on if a border is enabled or not) and I am not sure which one is right. Since columns are a bit of a mess it is possible that I may defer the fix until I have time to spend serious time on columns in general.

@ocornut
Copy link
Owner

ocornut commented Aug 7, 2017

OK that difference (which was worth style.ItemSpacing.x) is now fixed.

Note that:

  • Because we currently need to pixel-align all sizes, some column may have still differing width by +/- pixel. E.g. with your test case after the fix I got 159, 160, 160.

  • The column system currently always expect for the possibility of a Vertical Scrollbar (because it currently as issues transitioning when the scrollbar toggles), which make the last columns appears wider while that space is generally empty. If you never need a scrollbar you can use the ImGuiWindowFlags_NoScrollbar flag to claim that space back. If you use ImGuiWindowFlags_AlwaysVerticalScrollbar as well you won't notice that space because it will always be filled.

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

2 participants