#include "editor_toaster.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/themes/editor_scale.h"
#include "scene/gui/button.h"
#include "scene/gui/label.h"
#include "scene/gui/panel_container.h"
#include "scene/resources/style_box_flat.h"
EditorToaster *EditorToaster::singleton = …;
void EditorToaster::_notification(int p_what) { … }
void EditorToaster::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type) { … }
void EditorToaster::_error_handler_impl(const String &p_file, int p_line, const String &p_error, const String &p_errorexp, bool p_editor_notify, int p_type) { … }
void EditorToaster::_update_vbox_position() { … }
void EditorToaster::_update_disable_notifications_button() { … }
void EditorToaster::_auto_hide_or_free_toasts() { … }
void EditorToaster::_draw_button() { … }
void EditorToaster::_draw_progress(Control *panel) { … }
void EditorToaster::_set_notifications_enabled(bool p_enabled) { … }
void EditorToaster::_repop_old() { … }
Control *EditorToaster::popup(Control *p_control, Severity p_severity, double p_time, const String &p_tooltip) { … }
void EditorToaster::popup_str(const String &p_message, Severity p_severity, const String &p_tooltip) { … }
void EditorToaster::_popup_str(const String &p_message, Severity p_severity, const String &p_tooltip) { … }
void EditorToaster::close(Control *p_control) { … }
void EditorToaster::_close_button_theme_changed(Control *p_close_button) { … }
EditorToaster *EditorToaster::get_singleton() { … }
EditorToaster::EditorToaster() {
set_notify_transform(true);
set_process_internal(true);
vbox_container = memnew(VBoxContainer);
vbox_container->set_as_top_level(true);
vbox_container->connect(SceneStringName(resized), callable_mp(this, &EditorToaster::_update_vbox_position));
add_child(vbox_container);
info_panel_style_background.instantiate();
info_panel_style_background->set_corner_radius_all(stylebox_radius * EDSCALE);
warning_panel_style_background.instantiate();
warning_panel_style_background->set_border_width(SIDE_LEFT, stylebox_radius * EDSCALE);
warning_panel_style_background->set_corner_radius_all(stylebox_radius * EDSCALE);
error_panel_style_background.instantiate();
error_panel_style_background->set_border_width(SIDE_LEFT, stylebox_radius * EDSCALE);
error_panel_style_background->set_corner_radius_all(stylebox_radius * EDSCALE);
Ref<StyleBoxFlat> boxes[] = { info_panel_style_background, warning_panel_style_background, error_panel_style_background };
for (int i = 0; i < 3; i++) {
boxes[i]->set_content_margin_individual(int(stylebox_radius * 2.5), 3, int(stylebox_radius * 2.5), 3);
}
info_panel_style_progress.instantiate();
info_panel_style_progress->set_corner_radius_all(stylebox_radius * EDSCALE);
warning_panel_style_progress.instantiate();
warning_panel_style_progress->set_border_width(SIDE_LEFT, stylebox_radius * EDSCALE);
warning_panel_style_progress->set_corner_radius_all(stylebox_radius * EDSCALE);
error_panel_style_progress.instantiate();
error_panel_style_progress->set_border_width(SIDE_LEFT, stylebox_radius * EDSCALE);
error_panel_style_progress->set_corner_radius_all(stylebox_radius * EDSCALE);
main_button = memnew(Button);
main_button->set_tooltip_text(TTR("No notifications."));
main_button->set_modulate(Color(0.5, 0.5, 0.5));
main_button->set_disabled(true);
main_button->set_theme_type_variation("FlatMenuButton");
main_button->connect(SceneStringName(pressed), callable_mp(this, &EditorToaster::_set_notifications_enabled).bind(true));
main_button->connect(SceneStringName(pressed), callable_mp(this, &EditorToaster::_repop_old));
main_button->connect(SceneStringName(draw), callable_mp(this, &EditorToaster::_draw_button));
add_child(main_button);
disable_notifications_panel = memnew(PanelContainer);
disable_notifications_panel->set_as_top_level(true);
disable_notifications_panel->add_theme_style_override(SceneStringName(panel), info_panel_style_background);
add_child(disable_notifications_panel);
disable_notifications_button = memnew(Button);
disable_notifications_button->set_tooltip_text(TTR("Silence the notifications."));
disable_notifications_button->set_flat(true);
disable_notifications_button->connect(SceneStringName(pressed), callable_mp(this, &EditorToaster::_set_notifications_enabled).bind(false));
disable_notifications_panel->add_child(disable_notifications_button);
singleton = this;
eh.errfunc = _error_handler;
add_error_handler(&eh);
};
EditorToaster::~EditorToaster() { … }