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

GetContentRegionMaxAbs / GetContentRegionAvail incorrect when within end column #2666

Closed
deltars opened this issue Jul 14, 2019 · 7 comments
Closed

Comments

@deltars
Copy link

deltars commented Jul 14, 2019

It's me again,

Really minor issue, GetContentRegionAvail returns a region that is a touch too narrow when inside the end column, as padding is removed from the back edge.

I would suggest simply checking we are not in the end column.

I hope this helps!

thanks

ImVec2 ImGui::GetContentRegionMaxAbs()
{
    ImGuiWindow* window = GImGui->CurrentWindow;
    ImVec2 mx = window->ContentsRegionRect.Max;
    if (window->DC.CurrentColumns)
        mx.x = window->Pos.x + GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x;
    return mx;
}

Please consider changing to:

ImVec2 ImGui::GetContentRegionMaxAbs()
{
    ImGuiWindow* window = GImGui->CurrentWindow;
    ImVec2 mx = window->ContentsRegionRect.Max;
    if (window->DC.CurrentColumns && window->DC.CurrentColumns->Current + 1 < window->DC.CurrentColumns->Count)
        mx.x = window->Pos.x + GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x;
    return mx;
}
@ocornut
Copy link
Owner

ocornut commented Jul 14, 2019

Hello,

As with your previous issue, please clarify what you expect is "correct" and why.

The current behavior is designed so that all columns are of equal width and have equal amount of available space.
If we add a ImGui::Text("Avail %.2f", ImGui::GetContentRegionAvail().x); in the Column demo you can see it:

image

Based on this criteria, your proposed fix would be incorrect.

It may be misleading because Columns currently don't have an easy way to display outer borders (on the left and the right), something with the upcoming Tables/ColumnV2 system will allow more easily.

@deltars
Copy link
Author

deltars commented Jul 15, 2019

Hello,

Yes I understand, I could be much clearer.

Just to clarify, I think this is a minor issue / perhaps just a taste thing and doesn't necessarily need changing, depending on your view. Also, maybe I am using the wrong layout mechanism for what I am trying to do.

What i would expect:

imgui_gif

My actual use case (with the suggested code change as above):

Screenshot (22)

Perhaps the problem is more that I am using column layout and thats not really the best way to achieve what I am trying to do?

@ocornut
Copy link
Owner

ocornut commented Jul 17, 2019

Let me investigate, I looked at this and there's definitively a larger bug than that with how WindowPadding is presently affecting columns (I think this is a bug added in 1.71 while refactoring the contents/work rectangle system).

ocornut added a commit that referenced this issue Jul 18, 2019
…tents rectangle within each column would wrongly use a WindowPadding.x instead of ItemSpacing.x like it always did. (#125, #2666)
ocornut added a commit that referenced this issue Jul 18, 2019
…rious values of ItemSpacing.x and WindowPadding.x. In particular, the right-most edge now reaches up to the clipping rectangle while ensuring that the right-most column clipping width matches others. (#125, #2666)
@ocornut
Copy link
Owner

ocornut commented Jul 18, 2019

One of the problem this was trying to solve was to ensure that the clipping rectangle width would match. So if you have large (too wide) items in every column, they would appear clipped the same way.
The problem is that without this padding, the right side of right-most column would start overlapping beyond the current window clipping rectangle (which is generally WindowPadding*0.5f within the InnerRect).

I made two fixes now, and one pushes the right-most up to the clipping region so we're saving WindowPadding.x*0.5 (4 pixels with the default style).

There's still another gap of WindowPadding.x*0.5 (4 pixels) + the fact that if you have a scrollbar and your ScrollbarBg is transparent it looks like there's a little more space on the right side (2-3 pixels) + the fact that with a scrollbar the outer window border will cover the left side of the contents area but not the right side (an extra +1 pixel).

I would like to get rid fo the half-window-padding-clipping thing eventually but that'll require other changes.

(I like your screenshot but I have absolutely no idea what to look for in it. I cannot even see a column delimiter in that screenshot.)

@deltars
Copy link
Author

deltars commented Jul 18, 2019

thank you for the fixes.

(My screenshot is our skeletal animation / pose editor. The styling has some lines hidden and most margins set quite small. We have custom icon buttons, and render target widget which uses a persistent render target object for containing the actual render target and input callbacks but otherwise runs as immediate.)

Screenshot (24)

@deltars deltars closed this as completed Jul 18, 2019
@ocornut
Copy link
Owner

ocornut commented Jul 19, 2019

One of the project i'm working with seems to have detected a regression caused by the changes I made yesterday, so I'm opening this again until they are fixed.
EDIT There is indeed a regression dealing with indentation levels accross columns.

@ocornut ocornut reopened this Jul 19, 2019
@ocornut ocornut added the bug label Jul 19, 2019
ocornut added a commit that referenced this issue Jul 19, 2019
… with various values of ItemSpacing.x and WindowPadding.x. In particular, the right-most edge now reaches up to the clipping rectangle while ensuring that the right-most column clipping width matches others. (#125, #2666)"

This reverts commit 6c16ba6.
ocornut added a commit that referenced this issue Jul 19, 2019
…e (removing WindowPadding.x*0.5 worth of asymmetrical/extraneous padding). (#125, #2666)

+ Moved a few things in BeginColumns().
ocornut added a commit that referenced this issue Jul 19, 2019
@ocornut
Copy link
Owner

ocornut commented Jul 19, 2019

Should be fixed now!

@ocornut ocornut closed this as completed Jul 19, 2019
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