|
@@ -48,7 +48,6 @@
|
|
#include "editor/multi_node_edit.h"
|
|
#include "editor/multi_node_edit.h"
|
|
#include "editor/plugins/script_editor_plugin.h"
|
|
#include "editor/plugins/script_editor_plugin.h"
|
|
#include "editor/themes/editor_scale.h"
|
|
#include "editor/themes/editor_scale.h"
|
|
-#include "editor/themes/editor_theme_manager.h"
|
|
|
|
#include "scene/gui/margin_container.h"
|
|
#include "scene/gui/margin_container.h"
|
|
#include "scene/gui/separator.h"
|
|
#include "scene/gui/separator.h"
|
|
#include "scene/gui/spin_box.h"
|
|
#include "scene/gui/spin_box.h"
|
|
@@ -1554,6 +1553,17 @@ void EditorInspectorPlugin::_bind_methods() {
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
|
|
|
|
|
|
+static Ref<Script> _get_category_script(const PropertyInfo &p_info) {
|
|
|
|
+ if (!p_info.hint_string.is_empty() && !EditorNode::get_editor_data().is_type_recognized(p_info.name) && ResourceLoader::exists(p_info.hint_string, "Script")) {
|
|
|
|
+ return ResourceLoader::load(p_info.hint_string, "Script");
|
|
|
|
+ }
|
|
|
|
+ return Ref<Script>();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorInspectorCategory::_bind_methods() {
|
|
|
|
+ ADD_SIGNAL(MethodInfo("unfavorite_all"));
|
|
|
|
+}
|
|
|
|
+
|
|
void EditorInspectorCategory::_notification(int p_what) {
|
|
void EditorInspectorCategory::_notification(int p_what) {
|
|
switch (p_what) {
|
|
switch (p_what) {
|
|
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
|
|
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
|
|
@@ -1570,14 +1580,17 @@ void EditorInspectorCategory::_notification(int p_what) {
|
|
} break;
|
|
} break;
|
|
|
|
|
|
case NOTIFICATION_THEME_CHANGED: {
|
|
case NOTIFICATION_THEME_CHANGED: {
|
|
- if (menu) {
|
|
|
|
- if (is_favorite) {
|
|
|
|
- menu->set_item_icon(menu->get_item_index(EditorInspector::MENU_UNFAVORITE_ALL), get_editor_theme_icon(SNAME("Unfavorite")));
|
|
|
|
- } else {
|
|
|
|
- menu->set_item_icon(menu->get_item_index(MENU_OPEN_DOCS), get_editor_theme_icon(SNAME("Help")));
|
|
|
|
- }
|
|
|
|
|
|
+ menu_icon_dirty = true;
|
|
|
|
+ _update_icon();
|
|
|
|
+ } break;
|
|
|
|
+
|
|
|
|
+ case NOTIFICATION_TRANSLATION_CHANGED: {
|
|
|
|
+ if (is_favorite) {
|
|
|
|
+ label = TTR("Favorites");
|
|
}
|
|
}
|
|
|
|
+ queue_accessibility_update();
|
|
} break;
|
|
} break;
|
|
|
|
+
|
|
case NOTIFICATION_DRAW: {
|
|
case NOTIFICATION_DRAW: {
|
|
Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg"));
|
|
Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg"));
|
|
|
|
|
|
@@ -1623,19 +1636,7 @@ void EditorInspectorCategory::_notification(int p_what) {
|
|
}
|
|
}
|
|
|
|
|
|
void EditorInspectorCategory::_accessibility_action_menu(const Variant &p_data) {
|
|
void EditorInspectorCategory::_accessibility_action_menu(const Variant &p_data) {
|
|
- if (!is_favorite) {
|
|
|
|
- if (!menu) {
|
|
|
|
- menu = memnew(PopupMenu);
|
|
|
|
- menu->add_icon_item(get_editor_theme_icon(SNAME("Help")), TTR("Open Documentation"), MENU_OPEN_DOCS);
|
|
|
|
- add_child(menu);
|
|
|
|
- menu->connect(SceneStringName(id_pressed), callable_mp(this, &EditorInspectorCategory::_handle_menu_option));
|
|
|
|
- }
|
|
|
|
- menu->set_item_disabled(menu->get_item_index(MENU_OPEN_DOCS), !EditorHelp::get_doc_data()->class_list.has(doc_class_name));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- menu->set_position(get_screen_position());
|
|
|
|
- menu->reset_size();
|
|
|
|
- menu->popup();
|
|
|
|
|
|
+ _popup_context_menu(get_screen_position());
|
|
}
|
|
}
|
|
|
|
|
|
Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const {
|
|
Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const {
|
|
@@ -1647,13 +1648,29 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
|
|
return EditorHelpBitTooltip::show_tooltip(const_cast<EditorInspectorCategory *>(this), p_text);
|
|
return EditorHelpBitTooltip::show_tooltip(const_cast<EditorInspectorCategory *>(this), p_text);
|
|
}
|
|
}
|
|
|
|
|
|
-void EditorInspectorCategory::set_as_favorite(EditorInspector *p_for_inspector) {
|
|
|
|
|
|
+void EditorInspectorCategory::set_as_favorite() {
|
|
is_favorite = true;
|
|
is_favorite = true;
|
|
|
|
+ _update_icon();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorInspectorCategory::set_property_info(const PropertyInfo &p_info) {
|
|
|
|
+ info = p_info;
|
|
|
|
+
|
|
|
|
+ Ref<Script> scr = _get_category_script(info);
|
|
|
|
+ if (scr.is_valid()) {
|
|
|
|
+ StringName script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
|
|
|
|
+ if (script_name != StringName()) {
|
|
|
|
+ label = script_name;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (label.is_empty()) {
|
|
|
|
+ label = info.name;
|
|
|
|
+ }
|
|
|
|
+ _update_icon();
|
|
|
|
+}
|
|
|
|
|
|
- menu = memnew(PopupMenu);
|
|
|
|
- menu->add_item(TTR("Unfavorite All"), EditorInspector::MENU_UNFAVORITE_ALL);
|
|
|
|
- add_child(menu);
|
|
|
|
- menu->connect(SceneStringName(id_pressed), callable_mp(p_for_inspector, &EditorInspector::_handle_menu_option));
|
|
|
|
|
|
+void EditorInspectorCategory::set_doc_class_name(const String &p_name) {
|
|
|
|
+ doc_class_name = p_name;
|
|
}
|
|
}
|
|
|
|
|
|
Size2 EditorInspectorCategory::get_minimum_size() const {
|
|
Size2 EditorInspectorCategory::get_minimum_size() const {
|
|
@@ -1676,38 +1693,79 @@ Size2 EditorInspectorCategory::get_minimum_size() const {
|
|
|
|
|
|
void EditorInspectorCategory::_handle_menu_option(int p_option) {
|
|
void EditorInspectorCategory::_handle_menu_option(int p_option) {
|
|
switch (p_option) {
|
|
switch (p_option) {
|
|
- case MENU_OPEN_DOCS:
|
|
|
|
|
|
+ case MENU_OPEN_DOCS: {
|
|
ScriptEditor::get_singleton()->goto_help("class:" + doc_class_name);
|
|
ScriptEditor::get_singleton()->goto_help("class:" + doc_class_name);
|
|
EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
|
|
EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
|
|
- break;
|
|
|
|
|
|
+ } break;
|
|
|
|
+
|
|
|
|
+ case MENU_UNFAVORITE_ALL: {
|
|
|
|
+ emit_signal(SNAME("unfavorite_all"));
|
|
|
|
+ } break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void EditorInspectorCategory::gui_input(const Ref<InputEvent> &p_event) {
|
|
|
|
|
|
+void EditorInspectorCategory::_popup_context_menu(const Point2i &p_position) {
|
|
if (!is_favorite && doc_class_name.is_empty()) {
|
|
if (!is_favorite && doc_class_name.is_empty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- const Ref<InputEventMouseButton> &mb_event = p_event;
|
|
|
|
- if (mb_event.is_null() || !mb_event->is_pressed() || mb_event->get_button_index() != MouseButton::RIGHT) {
|
|
|
|
- return;
|
|
|
|
|
|
+ if (menu == nullptr) {
|
|
|
|
+ menu = memnew(PopupMenu);
|
|
|
|
+
|
|
|
|
+ if (is_favorite) {
|
|
|
|
+ menu->add_item(TTRC("Unfavorite All"), MENU_UNFAVORITE_ALL);
|
|
|
|
+ } else {
|
|
|
|
+ menu->add_item(TTRC("Open Documentation"), MENU_OPEN_DOCS);
|
|
|
|
+ menu->set_item_disabled(-1, !EditorHelp::get_doc_data()->class_list.has(doc_class_name));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ menu->connect(SceneStringName(id_pressed), callable_mp(this, &EditorInspectorCategory::_handle_menu_option));
|
|
|
|
+ add_child(menu);
|
|
}
|
|
}
|
|
|
|
|
|
- if (!is_favorite) {
|
|
|
|
- if (!menu) {
|
|
|
|
- menu = memnew(PopupMenu);
|
|
|
|
- menu->add_icon_item(get_editor_theme_icon(SNAME("Help")), TTR("Open Documentation"), MENU_OPEN_DOCS);
|
|
|
|
- add_child(menu);
|
|
|
|
- menu->connect(SceneStringName(id_pressed), callable_mp(this, &EditorInspectorCategory::_handle_menu_option));
|
|
|
|
|
|
+ if (menu_icon_dirty) {
|
|
|
|
+ if (is_favorite) {
|
|
|
|
+ menu->set_item_icon(menu->get_item_index(MENU_UNFAVORITE_ALL), get_editor_theme_icon(SNAME("Unfavorite")));
|
|
|
|
+ } else {
|
|
|
|
+ menu->set_item_icon(menu->get_item_index(MENU_OPEN_DOCS), get_editor_theme_icon(SNAME("Help")));
|
|
}
|
|
}
|
|
- menu->set_item_disabled(menu->get_item_index(MENU_OPEN_DOCS), !EditorHelp::get_doc_data()->class_list.has(doc_class_name));
|
|
|
|
|
|
+ menu_icon_dirty = false;
|
|
}
|
|
}
|
|
|
|
|
|
- menu->set_position(get_screen_position() + mb_event->get_position());
|
|
|
|
|
|
+ menu->set_position(p_position);
|
|
menu->reset_size();
|
|
menu->reset_size();
|
|
menu->popup();
|
|
menu->popup();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void EditorInspectorCategory::_update_icon() {
|
|
|
|
+ if (is_favorite) {
|
|
|
|
+ icon = get_editor_theme_icon(SNAME("Favorites"));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ icon = Ref<Texture2D>();
|
|
|
|
+
|
|
|
|
+ Ref<Script> scr = _get_category_script(info);
|
|
|
|
+ if (scr.is_valid()) {
|
|
|
|
+ StringName script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
|
|
|
|
+ if (script_name == StringName()) {
|
|
|
|
+ icon = EditorNode::get_singleton()->get_object_icon(scr.ptr(), "Object");
|
|
|
|
+ } else {
|
|
|
|
+ icon = EditorNode::get_singleton()->get_class_icon(script_name);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (icon.is_null() && !info.name.is_empty()) {
|
|
|
|
+ icon = EditorNode::get_singleton()->get_class_icon(info.name);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorInspectorCategory::gui_input(const Ref<InputEvent> &p_event) {
|
|
|
|
+ const Ref<InputEventMouseButton> &mb = p_event;
|
|
|
|
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) {
|
|
|
|
+ _popup_context_menu(get_screen_position() + mb->get_position());
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
EditorInspectorCategory::EditorInspectorCategory() {
|
|
EditorInspectorCategory::EditorInspectorCategory() {
|
|
set_focus_mode(FOCUS_ACCESSIBILITY);
|
|
set_focus_mode(FOCUS_ACCESSIBILITY);
|
|
}
|
|
}
|
|
@@ -3614,17 +3672,13 @@ void EditorInspector::update_tree() {
|
|
continue; // Empty, ignore it.
|
|
continue; // Empty, ignore it.
|
|
}
|
|
}
|
|
|
|
|
|
- String category_label;
|
|
|
|
String category_tooltip;
|
|
String category_tooltip;
|
|
- Ref<Texture> category_icon;
|
|
|
|
|
|
|
|
// Do not add an icon, do not change the current class (`doc_name`) for custom categories.
|
|
// Do not add an icon, do not change the current class (`doc_name`) for custom categories.
|
|
if (is_custom_category) {
|
|
if (is_custom_category) {
|
|
- category_label = p.name;
|
|
|
|
category_tooltip = p.name;
|
|
category_tooltip = p.name;
|
|
} else {
|
|
} else {
|
|
doc_name = p.name;
|
|
doc_name = p.name;
|
|
- category_label = p.name;
|
|
|
|
|
|
|
|
// Use category's owner script to update some of its information.
|
|
// Use category's owner script to update some of its information.
|
|
if (!EditorNode::get_editor_data().is_type_recognized(p.name) && ResourceLoader::exists(p.hint_string, "Script")) {
|
|
if (!EditorNode::get_editor_data().is_type_recognized(p.name) && ResourceLoader::exists(p.hint_string, "Script")) {
|
|
@@ -3632,14 +3686,6 @@ void EditorInspector::update_tree() {
|
|
if (scr.is_valid()) {
|
|
if (scr.is_valid()) {
|
|
doc_name = scr->get_doc_class_name();
|
|
doc_name = scr->get_doc_class_name();
|
|
|
|
|
|
- StringName script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
|
|
|
|
- if (script_name != StringName()) {
|
|
|
|
- category_label = script_name;
|
|
|
|
- category_icon = EditorNode::get_singleton()->get_class_icon(script_name);
|
|
|
|
- } else {
|
|
|
|
- category_icon = EditorNode::get_singleton()->get_object_icon(scr.ptr(), "Object");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Property favorites aren't compatible with built-in scripts.
|
|
// Property favorites aren't compatible with built-in scripts.
|
|
if (scr->is_built_in()) {
|
|
if (scr->is_built_in()) {
|
|
disable_favorite = true;
|
|
disable_favorite = true;
|
|
@@ -3647,10 +3693,6 @@ void EditorInspector::update_tree() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (category_icon.is_null() && !p.name.is_empty()) {
|
|
|
|
- category_icon = EditorNode::get_singleton()->get_class_icon(p.name);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (use_doc_hints) {
|
|
if (use_doc_hints) {
|
|
// `|` separators used in `EditorHelpBit`.
|
|
// `|` separators used in `EditorHelpBit`.
|
|
category_tooltip = "class|" + doc_name + "|";
|
|
category_tooltip = "class|" + doc_name + "|";
|
|
@@ -3668,15 +3710,14 @@ void EditorInspector::update_tree() {
|
|
|
|
|
|
// Create an EditorInspectorCategory and add it to the inspector.
|
|
// Create an EditorInspectorCategory and add it to the inspector.
|
|
EditorInspectorCategory *category = memnew(EditorInspectorCategory);
|
|
EditorInspectorCategory *category = memnew(EditorInspectorCategory);
|
|
|
|
+ category->set_property_info(p);
|
|
main_vbox->add_child(category);
|
|
main_vbox->add_child(category);
|
|
category_vbox = nullptr; // Reset.
|
|
category_vbox = nullptr; // Reset.
|
|
|
|
|
|
// Set the category info.
|
|
// Set the category info.
|
|
- category->label = category_label;
|
|
|
|
category->set_tooltip_text(category_tooltip);
|
|
category->set_tooltip_text(category_tooltip);
|
|
- category->icon = category_icon;
|
|
|
|
if (!is_custom_category) {
|
|
if (!is_custom_category) {
|
|
- category->doc_class_name = doc_name;
|
|
|
|
|
|
+ category->set_doc_class_name(doc_name);
|
|
}
|
|
}
|
|
|
|
|
|
// Add editors at the start of a category.
|
|
// Add editors at the start of a category.
|
|
@@ -5239,8 +5280,6 @@ void EditorInspector::_notification(int p_what) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- favorites_category->icon = get_editor_theme_icon(SNAME("Favorites"));
|
|
|
|
-
|
|
|
|
int separation = get_theme_constant(SNAME("v_separation"), SNAME("EditorInspector"));
|
|
int separation = get_theme_constant(SNAME("v_separation"), SNAME("EditorInspector"));
|
|
base_vbox->add_theme_constant_override("separation", separation);
|
|
base_vbox->add_theme_constant_override("separation", separation);
|
|
begin_vbox->add_theme_constant_override("separation", separation);
|
|
begin_vbox->add_theme_constant_override("separation", separation);
|
|
@@ -5425,14 +5464,6 @@ void EditorInspector::_add_meta_confirm() {
|
|
undo_redo->commit_action();
|
|
undo_redo->commit_action();
|
|
}
|
|
}
|
|
|
|
|
|
-void EditorInspector::_handle_menu_option(int p_option) {
|
|
|
|
- switch (p_option) {
|
|
|
|
- case MENU_UNFAVORITE_ALL:
|
|
|
|
- _clear_current_favorites();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void EditorInspector::_bind_methods() {
|
|
void EditorInspector::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("edit", "object"), &EditorInspector::edit);
|
|
ClassDB::bind_method(D_METHOD("edit", "object"), &EditorInspector::edit);
|
|
ClassDB::bind_method("_edit_request_change", &EditorInspector::_edit_request_change);
|
|
ClassDB::bind_method("_edit_request_change", &EditorInspector::_edit_request_change);
|
|
@@ -5467,10 +5498,10 @@ EditorInspector::EditorInspector() {
|
|
base_vbox->add_child(favorites_section);
|
|
base_vbox->add_child(favorites_section);
|
|
favorites_section->hide();
|
|
favorites_section->hide();
|
|
|
|
|
|
- favorites_category = memnew(EditorInspectorCategory);
|
|
|
|
- favorites_category->set_as_favorite(this);
|
|
|
|
|
|
+ EditorInspectorCategory *favorites_category = memnew(EditorInspectorCategory);
|
|
|
|
+ favorites_category->set_as_favorite();
|
|
|
|
+ favorites_category->connect("unfavorite_all", callable_mp(this, &EditorInspector::_clear_current_favorites));
|
|
favorites_section->add_child(favorites_category);
|
|
favorites_section->add_child(favorites_category);
|
|
- favorites_category->label = TTR("Favorites");
|
|
|
|
|
|
|
|
favorites_vbox = memnew(VBoxContainer);
|
|
favorites_vbox = memnew(VBoxContainer);
|
|
favorites_section->add_child(favorites_vbox);
|
|
favorites_section->add_child(favorites_vbox);
|