Expose toast notification methods

This commit is contained in:
Jayden Sipe
2024-10-30 15:33:40 -04:00
parent ec6a1c0e79
commit 722d932466
7 changed files with 59 additions and 0 deletions
+6
View File
@@ -43,6 +43,7 @@
#include "editor/gui/editor_quick_open_dialog.h"
#include "editor/gui/editor_run_bar.h"
#include "editor/gui/editor_scene_tabs.h"
#include "editor/gui/editor_toaster.h"
#include "editor/gui/scene_tree_editor.h"
#include "editor/inspector_dock.h"
#include "editor/plugins/node_3d_editor_plugin.h"
@@ -89,6 +90,10 @@ Ref<EditorSettings> EditorInterface::get_editor_settings() const {
return EditorSettings::get_singleton();
}
EditorToaster *EditorInterface::get_editor_toaster() const {
return EditorToaster::get_singleton();
}
EditorUndoRedoManager *EditorInterface::get_editor_undo_redo() const {
return EditorUndoRedoManager::get_singleton();
}
@@ -581,6 +586,7 @@ void EditorInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer);
ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection);
ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings);
ClassDB::bind_method(D_METHOD("get_editor_toaster"), &EditorInterface::get_editor_toaster);
ClassDB::bind_method(D_METHOD("get_editor_undo_redo"), &EditorInterface::get_editor_undo_redo);
ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews);
+2
View File
@@ -45,6 +45,7 @@ class EditorPlugin;
class EditorResourcePreview;
class EditorSelection;
class EditorSettings;
class EditorToaster;
class EditorUndoRedoManager;
class FileSystemDock;
class Mesh;
@@ -104,6 +105,7 @@ public:
EditorResourcePreview *get_resource_previewer() const;
EditorSelection *get_selection() const;
Ref<EditorSettings> get_editor_settings() const;
EditorToaster *get_editor_toaster() const;
EditorUndoRedoManager *get_editor_undo_redo() const;
Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size);
+8
View File
@@ -506,6 +506,14 @@ void EditorToaster::instant_close(Control *p_control) {
p_control->set_modulate(Color(1, 1, 1, 0));
}
void EditorToaster::_bind_methods() {
ClassDB::bind_method(D_METHOD("push_toast", "message", "severity", "tooltip"), &EditorToaster::_popup_str, DEFVAL(EditorToaster::SEVERITY_INFO), DEFVAL(String()));
BIND_ENUM_CONSTANT(SEVERITY_INFO);
BIND_ENUM_CONSTANT(SEVERITY_WARNING);
BIND_ENUM_CONSTANT(SEVERITY_ERROR);
}
EditorToaster *EditorToaster::get_singleton() {
return singleton;
}
+1
View File
@@ -105,6 +105,7 @@ private:
void _toast_theme_changed(Control *p_control);
protected:
static void _bind_methods();
static EditorToaster *singleton;
void _notification(int p_what);
+2
View File
@@ -52,6 +52,7 @@
#include "editor/filesystem_dock.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/gui/editor_spin_slider.h"
#include "editor/gui/editor_toaster.h"
#include "editor/import/3d/resource_importer_obj.h"
#include "editor/import/3d/resource_importer_scene.h"
#include "editor/import/editor_import_plugin.h"
@@ -146,6 +147,7 @@ void register_editor_types() {
GDREGISTER_CLASS(EditorSelection);
GDREGISTER_CLASS(EditorFileDialog);
GDREGISTER_CLASS(EditorSettings);
GDREGISTER_ABSTRACT_CLASS(EditorToaster);
GDREGISTER_CLASS(EditorNode3DGizmo);
GDREGISTER_CLASS(EditorNode3DGizmoPlugin);
GDREGISTER_ABSTRACT_CLASS(EditorResourcePreview);