-
Notifications
You must be signed in to change notification settings - Fork 334
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
Change modal position to a fixed vertical distance from the top of the window #4700
Conversation
This avoids the modal moving vertically when content size changes.
you should be able to circumvent that by giving the Window a new id than whats already persisted |
@@ -109,10 +130,16 @@ impl Modal { | |||
|
|||
let mut open = ui.input(|i| !i.key_pressed(egui::Key::Escape)); | |||
|
|||
let screen_height = ui.ctx().screen_rect().height(); | |||
let modal_vertical_margins = (75.0).at_most(screen_height * 0.1); | |||
|
|||
let mut window = egui::Window::new(&self.title) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut window = egui::Window::new(&self.title) | |
let mut window = egui::Window::new(&self.title) | |
.id(egui::Id::new("modal", &self.title)) // Workaround for https://github.com/emilk/egui/pull/3721 until we make a new egui release |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works (well—to the extent that it invalidates any existing cache).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the bug was only when changing pivot
, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct. So we should be good.
What
This avoids the modal moving vertically when content size changes.
NOTE: this PR would trigger the bug fixed in emilk/egui#3721, so it needs an egui release before being released. This is avoided by salting the modals' ID such as to in invalidate existing caches.
modal_position.mp4
Checklist
main
build: app.rerun.ionightly
build: app.rerun.io