Skip to content

Commit

Permalink
Fix popups (color picker) closing all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
Jupeyy committed Jan 16, 2025
1 parent fdc3980 commit 69ba26f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions game/editor/src/ui/group_and_layer/layer_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserDataWithTab>, ui_st
});
if intersected
.is_some_and(|(outside, clicked)| outside && clicked && resource_selector_was_outside)
&& !ui.memory(|i| i.any_popup_open())
{
map.unselect_all(true, true);
}
Expand Down
4 changes: 3 additions & 1 deletion game/editor/src/ui/group_and_layer/quad_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserDataWithTab>, ui_st
None
}
});
if intersected.is_some_and(|(outside, clicked)| outside && clicked) {
if intersected.is_some_and(|(outside, clicked)| outside && clicked)
&& !ui.memory(|i| i.any_popup_open())
{
match &pipe.user_data.tools.active_tool {
ActiveTool::Quads(ActiveToolQuads::Brush) => {
pipe.user_data.tools.quads.brush.last_selection = None;
Expand Down
2 changes: 2 additions & 0 deletions game/editor/src/ui/main_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserData>, ui_state: &m
super::group_and_layer::sound_props::render(ui, &mut pipe, ui_state);
}

*pipe.user_data.pointer_is_used |= ui.memory(|i| i.any_popup_open());

*pipe.user_data.unused_rect = Some(ui.available_rect_before_wrap());
if *pipe.user_data.pointer_is_used {
*pipe.user_data.unused_rect = None;
Expand Down
10 changes: 4 additions & 6 deletions game/editor/src/ui/top_menu/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,13 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserData>) {
ui.label("Name:");
ui.text_edit_singleline(mapper_name);
ui.label("Color:");
let color_open = ui.color_edit_button_srgb(color).enabled();
ui.color_edit_button_srgb(color);
if ui.button("Host").clicked() {
host = true;
}
if ui.button("Cancel").clicked() {
cancel = true;
}
color_open
});

if host {
Expand Down Expand Up @@ -245,7 +244,7 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserData>) {
}
});
if intersected.is_some_and(|(outside, clicked)| outside && clicked)
&& !window_res.inner.unwrap_or_default()
&& !ui.memory(|i| i.any_popup_open())
{
*menu_dialog_mode = EditorMenuDialogMode::None;
}
Expand Down Expand Up @@ -277,14 +276,13 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserData>) {
ui.label("Name:");
ui.text_edit_singleline(mapper_name);
ui.label("Color:");
let is_open = ui.color_edit_button_srgb(color).enabled();
ui.color_edit_button_srgb(color);
if ui.button("Join").clicked() {
join = true;
}
if ui.button("Cancel").clicked() {
cancel = true;
}
is_open
});

if join {
Expand Down Expand Up @@ -325,7 +323,7 @@ pub fn render(ui: &mut egui::Ui, pipe: &mut UiRenderPipe<UserData>) {
}
});
if intersected.is_some_and(|(outside, clicked)| outside && clicked)
&& !window_res.inner.unwrap_or_default()
&& !ui.memory(|i| i.any_popup_open())
{
*menu_dialog_mode = EditorMenuDialogMode::None;
}
Expand Down

0 comments on commit 69ba26f

Please sign in to comment.