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

Improve width computation in multi-components widget (#7120) #7121

Closed
wants to merge 1 commit into from

Conversation

Nahor
Copy link
Contributor

@Nahor Nahor commented Dec 11, 2023

In the previous algorithm, all components were of the same width except for the last. That last one was using the remainder.
This meant that any error in that common width (caused by the truncation to the nearest pixel/integer), was getting accumulated and propagated into that last component.

The new algorithm avoid this issue by computing where each component should start, with the width being the difference between those locations. In essence, this spreads the errors over multiple components instead of just the last one.

In the previous algorithm, all components were of the same width except for
the last. That last one was using the remainder.
This meant that any error in that common width (caused by the truncation
to the nearest pixel/integer), was getting accumulated and propagated into
that last component.

The new algorithm avoid this issue by computing where each component should
start, with the width being the difference between those locations.
In essence, this spreads the errors over multiple components instead of
just the last one.
@ocornut
Copy link
Owner

ocornut commented Dec 11, 2023

Thanks for the PR, will try to look tomorrow.

FYI for future things it is absolutely fine to post the issues/details in single PR # (vs opening both issues # and PR #)

ocornut pushed a commit that referenced this pull request Dec 11, 2023
…ve multi-components width computation to better distribute the error. (#7120, #7121)
@ocornut
Copy link
Owner

ocornut commented Dec 11, 2023

Ended up merging as 86512ea. Thank you!
If you have time, ColorEdit4() use similar same-same-but-different code that ought to be reworked similarly as well.

@ocornut
Copy link
Owner

ocornut commented Dec 19, 2023

This broke layout when there's too little space for widgets. Working on a fix.

@Nahor
Copy link
Contributor Author

Nahor commented Dec 19, 2023

I'm guessing the ImMax(1.0f, ... of the previous code? I completely missed that, sorry.

ocornut added a commit that referenced this pull request Dec 19, 2023
… multi-components width in tight space (#7120, #7121)

+ extra tweak color ColorEdit4() label. Amend 86512ea, 3464662
@ocornut
Copy link
Owner

ocornut commented Dec 19, 2023

Pushed fix now + an extra tweak for ColorEdit4()!.
(it's really easy to break stuff, no worries! hadn't caught it either myself)

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