Make `close_popup` take an `Id` and add `close_all_popups` (#5820)
Ooops, fixes a regression introduced in #5799 * [x] I have followed the instructions in the PR template
This commit is contained in:
parent
1aced06e47
commit
a2afc8d092
|
|
@ -85,7 +85,7 @@ pub enum PopupCloseBehavior {
|
||||||
/// but in the popup's body
|
/// but in the popup's body
|
||||||
CloseOnClickOutside,
|
CloseOnClickOutside,
|
||||||
|
|
||||||
/// Clicks will be ignored. Popup might be closed manually by calling [`crate::Memory::close_popup`]
|
/// Clicks will be ignored. Popup might be closed manually by calling [`crate::Memory::close_all_popups`]
|
||||||
/// or by pressing the escape button
|
/// or by pressing the escape button
|
||||||
IgnoreClicks,
|
IgnoreClicks,
|
||||||
}
|
}
|
||||||
|
|
@ -524,7 +524,7 @@ impl<'a> Popup<'a> {
|
||||||
_ => mem.open_popup(id),
|
_ => mem.open_popup(id),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mem.close_popup();
|
mem.close_popup(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(SetOpenCommand::Toggle) => {
|
Some(SetOpenCommand::Toggle) => {
|
||||||
|
|
@ -606,7 +606,7 @@ impl<'a> Popup<'a> {
|
||||||
}
|
}
|
||||||
OpenKind::Memory { .. } => {
|
OpenKind::Memory { .. } => {
|
||||||
if should_close {
|
if should_close {
|
||||||
ctx.memory_mut(|mem| mem.close_popup());
|
ctx.memory_mut(|mem| mem.close_popup(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1098,17 +1098,26 @@ impl Memory {
|
||||||
.and_then(|(popup_id, pos)| if popup_id == id { pos } else { None })
|
.and_then(|(popup_id, pos)| if popup_id == id { pos } else { None })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Close the open popup, if any.
|
/// Close any currently open popup.
|
||||||
pub fn close_popup(&mut self) {
|
pub fn close_all_popups(&mut self) {
|
||||||
self.popup = None;
|
self.popup = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Close the given popup, if it is open.
|
||||||
|
///
|
||||||
|
/// See also [`Self::close_all_popups`] if you want to close any / all currently open popups.
|
||||||
|
pub fn close_popup(&mut self, popup_id: Id) {
|
||||||
|
if self.is_popup_open(popup_id) {
|
||||||
|
self.popup = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Toggle the given popup between closed and open.
|
/// Toggle the given popup between closed and open.
|
||||||
///
|
///
|
||||||
/// Note: At most, only one popup can be open at a time.
|
/// Note: At most, only one popup can be open at a time.
|
||||||
pub fn toggle_popup(&mut self, popup_id: Id) {
|
pub fn toggle_popup(&mut self, popup_id: Id) {
|
||||||
if self.is_popup_open(popup_id) {
|
if self.is_popup_open(popup_id) {
|
||||||
self.close_popup();
|
self.close_popup(popup_id);
|
||||||
} else {
|
} else {
|
||||||
self.open_popup(popup_id);
|
self.open_popup(popup_id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -521,7 +521,7 @@ pub fn color_edit_button_hsva(ui: &mut Ui, hsva: &mut Hsva, alpha: Alpha) -> Res
|
||||||
if !button_response.clicked()
|
if !button_response.clicked()
|
||||||
&& (ui.input(|i| i.key_pressed(Key::Escape)) || area_response.clicked_elsewhere())
|
&& (ui.input(|i| i.key_pressed(Key::Escape)) || area_response.clicked_elsewhere())
|
||||||
{
|
{
|
||||||
ui.memory_mut(|mem| mem.close_popup());
|
ui.memory_mut(|mem| mem.close_popup(popup_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue