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

Change modal position to a fixed vertical distance from the top of the window #4700

Merged
merged 3 commits into from
Jan 5, 2024

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Jan 5, 2024

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

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

This avoids the modal moving vertically when content size changes.
@abey79 abey79 added ui concerns graphical user interface include in changelog labels Jan 5, 2024
@abey79 abey79 changed the title Position modals at a fixed vertical distance from the top of the window Change modal position to a fixed vertical distance from the top of the window Jan 5, 2024
@abey79 abey79 marked this pull request as ready for review January 5, 2024 12:30
@emilk emilk added blocked can't make progress right now and removed blocked can't make progress right now labels Jan 5, 2024
@emilk
Copy link
Member

emilk commented Jan 5, 2024

this PR is very likely to trigger the bug fixed in

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Member Author

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).

Copy link
Member

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 ?

Copy link
Member Author

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.

@abey79 abey79 merged commit a0d5946 into main Jan 5, 2024
40 of 41 checks passed
@abey79 abey79 deleted the antoine/better-modal-position branch January 5, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog ui concerns graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants