-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Make Memory::keep_popup_open
less of a footgun
#7297
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
base: main
Are you sure you want to change the base?
Conversation
Preview available at https://egui-pr-preview.github.io/pr/7297-lucaspopup-footgun |
self.popups | ||
.get(&self.viewport_id) | ||
.is_some_and(|state| state.id == popup_id) | ||
|| self.everything_is_visible() | ||
} | ||
|
||
/// Check if the popup is open and keep it open. 8000 | ||
pub fn show_popup(&mut self, popup_id: Id) -> bool { |
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.
The docstring for open_popup
should link to this function, and vice-versa, to explain their difference..
Also: wouldn't it make sense if this called self.open_popup
?
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.
No, if this called open_popup, you couldn't use it to check if we should show the popup.
The docs should also mention it needs to be called every frame.
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.
I think this is just another shape of footgun.
Based only on the names of the functions, I would expect this to always hold:
mem.show_popup(popup_id);
assert!(mem.is_showing_popup(popup_id));
Which would then lead to the question "what is open_popup for?"
@@ -531,7 +531,7 @@ impl<'a> Popup<'a> { | |||
mem.toggle_popup(id); | |||
} | |||
None => { | |||
mem.keep_popup_open(id); | |||
mem.show_popup(id); |
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.
Shouldn't we always call this unless we return None
below? 🤔
Memory::keep_popup_open
less of a footgun #7037The breaking change is intentional, to force people to think about this, since otherwise the keep_popup_open thing would silently break popups.