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

Automatically request repaint when Area size changed? #854

Closed
m-ou-se opened this issue Oct 29, 2021 · 1 comment · Fixed by #866
Closed

Automatically request repaint when Area size changed? #854

m-ou-se opened this issue Oct 29, 2021 · 1 comment · Fixed by #866

Comments

@m-ou-se
Copy link

m-ou-se commented Oct 29, 2021

I'm using an Area to center some ui, with .anchor(CENTER_CENTER, ZERO), which mostly works very well, except the first frame it shows up in the wrong place. This is expected, as only afterwards can it remember the size of the contents and calculate the right position for the ui to appear centered.

However, this first frame with the wrongly positioned center area stays visible until some kind of input event is generated.

For now I worked around this by using:

            let r = Area::new("...").anchor(Align2::CENTER_CENTER, Vec2::ZERO).show(...);

            if (r.response.rect.center() - ctx.available_rect().center()).length_sq() > 1.0 {
                ctx.request_repaint();
            }

Would it make sense for egui::Area to automatically request a repaint when after adding the contents the size turned out to be different than what it assumed while chosing the position? (Or maybe some functionality on Response to easliy opt-in to that behaviour?)

@emilk
Copy link
Owner

emilk commented Nov 1, 2021

Related: #843

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 a pull request may close this issue.

2 participants