Skip to content

Commit

Permalink
Merge pull request godotengine#98797 from KoBeWi/toastkill_f
Browse files Browse the repository at this point in the history
Close toasts instantly when Close button is pressed
  • Loading branch information
Repiteo committed Nov 11, 2024
2 parents 87cf530 + cb73046 commit cea186a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion editor/gui/editor_toaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_
if (p_time > 0.0) {
Button *close_button = memnew(Button);
close_button->set_flat(true);
close_button->connect(SceneStringName(pressed), callable_mp(this, &EditorToaster::close).bind(panel));
close_button->connect(SceneStringName(pressed), callable_mp(this, &EditorToaster::instant_close).bind(panel));
hbox_container->add_child(close_button);

toast.close_button = close_button;
Expand Down Expand Up @@ -501,6 +501,11 @@ void EditorToaster::close(Control *p_control) {
toasts[p_control].popped = false;
}

void EditorToaster::instant_close(Control *p_control) {
close(p_control);
p_control->set_modulate(Color(1, 1, 1, 0));
}

EditorToaster *EditorToaster::get_singleton() {
return singleton;
}
Expand Down
1 change: 1 addition & 0 deletions editor/gui/editor_toaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class EditorToaster : public HBoxContainer {
Control *popup(Control *p_control, Severity p_severity = SEVERITY_INFO, double p_time = 0.0, const String &p_tooltip = String());
void popup_str(const String &p_message, Severity p_severity = SEVERITY_INFO, const String &p_tooltip = String());
void close(Control *p_control);
void instant_close(Control *p_control);

EditorToaster();
~EditorToaster();
Expand Down

0 comments on commit cea186a

Please sign in to comment.