From fb02d16983fb1d2dac121ba53ab2aa00ab736483 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 16 Jul 2022 19:28:39 +0200 Subject: [PATCH] Now custom controls can be added to the top bar of the plugin settings page. --- editor/editor_plugin_settings.cpp | 19 ++++++++++++++----- editor/editor_plugin_settings.h | 27 ++++++++++++++++----------- editor/project_settings_editor.h | 1 + 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 41bd3484b..402751fe0 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -30,25 +30,32 @@ #include "editor_plugin_settings.h" -#include "core/io/config_file.h" -#include "core/os/file_access.h" -#include "core/os/main_loop.h" -#include "editor_node.h" -#include "editor_scale.h" #include "core/class_db.h" #include "core/error_list.h" #include "core/error_macros.h" +#include "core/io/config_file.h" #include "core/os/dir_access.h" +#include "core/os/file_access.h" +#include "core/os/main_loop.h" #include "core/os/memory.h" #include "core/reference.h" #include "core/variant.h" #include "editor/plugin_config_dialog.h" +#include "editor_node.h" +#include "editor_scale.h" #include "scene/gui/button.h" #include "scene/gui/control.h" #include "scene/gui/label.h" #include "scene/gui/tree.h" #include "scene/main/node.h" +void EditorPluginSettings::add_control_to_top_bar(Control *p_control) { + _custom_top_bar_control_container->add_child(p_control); +} +void EditorPluginSettings::remove_control_from_top_bar(Control *p_control) { + _custom_top_bar_control_container->remove_child(p_control); +} + void EditorPluginSettings::_notification(int p_what) { if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { update_plugins(); @@ -209,6 +216,8 @@ EditorPluginSettings::EditorPluginSettings() { HBoxContainer *title_hb = memnew(HBoxContainer); title_hb->add_child(memnew(Label(TTR("Installed Plugins:")))); title_hb->add_spacer(); + _custom_top_bar_control_container = memnew(HBoxContainer); + title_hb->add_child(_custom_top_bar_control_container); create_plugin = memnew(Button(TTR("Create"))); create_plugin->connect("pressed", this, "_create_clicked"); title_hb->add_child(create_plugin); diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h index b16dd089a..d190dddf9 100644 --- a/editor/editor_plugin_settings.h +++ b/editor/editor_plugin_settings.h @@ -36,14 +36,27 @@ #include "core/ustring.h" #include "core/vector.h" - class Button; class PluginConfigDialog; class Tree; +class HBoxContainer; class EditorPluginSettings : public VBoxContainer { GDCLASS(EditorPluginSettings, VBoxContainer); +public: + void add_control_to_top_bar(Control *p_control); + void remove_control_from_top_bar(Control *p_control); + + void update_plugins(); + + EditorPluginSettings(); + +protected: + void _notification(int p_what); + + static void _bind_methods(); + enum { BUTTON_PLUGIN_EDIT }; @@ -54,21 +67,13 @@ class EditorPluginSettings : public VBoxContainer { Tree *plugin_list; bool updating; + HBoxContainer *_custom_top_bar_control_container; + void _plugin_activity_changed(); void _create_clicked(); void _cell_button_pressed(Object *p_item, int p_column, int p_id); static Vector _get_plugins(const String &p_dir); - -protected: - void _notification(int p_what); - - static void _bind_methods(); - -public: - void update_plugins(); - - EditorPluginSettings(); }; #endif // EDITORPLUGINSETTINGS_H diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index fff9d427a..472323fe7 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -219,6 +219,7 @@ public: void update_plugins(); EditorAutoloadSettings *get_autoload_settings() { return autoload_settings; } + EditorPluginSettings *get_plugin_settings() { return plugin_settings; } TabContainer *get_tabs();