Merge pull request #52984 from pycbouh/disable-freaky-subinspectors-3.x

This commit is contained in:
Rémi Verschelde 2021-09-25 00:08:42 +02:00 committed by GitHub
commit 94f658a8d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 19 deletions

View file

@ -2237,7 +2237,7 @@ EditorPropertyRID::EditorPropertyRID() {
////////////// RESOURCE //////////////////////
void EditorPropertyResource::_resource_selected(const RES &p_resource) {
if (use_sub_inspector) {
if (_can_use_sub_inspector(p_resource)) {
bool unfold = !get_edited_object()->editor_is_section_unfolded(get_edited_property());
get_edited_object()->editor_set_section_unfold(get_edited_property(), unfold);
update_property();
@ -2399,6 +2399,20 @@ void EditorPropertyResource::_viewport_selected(const NodePath &p_path) {
update_property();
}
bool EditorPropertyResource::_can_use_sub_inspector(const RES &p_resource) {
bool use_editor = false;
if (p_resource.is_valid()) {
for (int i = 0; i < EditorNode::get_editor_data().get_editor_plugin_count(); i++) {
EditorPlugin *ep = EditorNode::get_editor_data().get_editor_plugin(i);
if (ep->handles((Resource *)p_resource.ptr())) {
use_editor = true;
}
}
}
return !use_editor && use_sub_inspector;
}
void EditorPropertyResource::setup(Object *p_object, const String &p_path, const String &p_base_type) {
if (resource_picker) {
resource_picker->disconnect("resource_selected", this, "_resource_selected");
@ -2433,7 +2447,7 @@ void EditorPropertyResource::setup(Object *p_object, const String &p_path, const
void EditorPropertyResource::update_property() {
RES res = get_edited_object()->get(get_edited_property());
if (use_sub_inspector) {
if (_can_use_sub_inspector(res)) {
if (res.is_valid() != resource_picker->is_toggle_mode()) {
resource_picker->set_toggle_mode(res.is_valid());
}
@ -2462,23 +2476,6 @@ void EditorPropertyResource::update_property() {
sub_inspector_vbox->add_child(sub_inspector);
resource_picker->set_toggle_pressed(true);
bool use_editor = false;
for (int i = 0; i < EditorNode::get_editor_data().get_editor_plugin_count(); i++) {
EditorPlugin *ep = EditorNode::get_editor_data().get_editor_plugin(i);
if (ep->handles(res.ptr())) {
use_editor = true;
}
}
if (use_editor) {
// Open editor directly and hide other such editors which are currently open.
_open_editor_pressed();
if (is_inside_tree()) {
get_tree()->call_deferred("call_group", "_editor_resource_properties", "_fold_other_editors", this);
}
opened_editor = true;
}
_update_property_bg();
}

View file

@ -562,6 +562,7 @@ class EditorPropertyResource : public EditorProperty {
void _sub_inspector_resource_selected(const RES &p_resource, const String &p_property);
void _sub_inspector_object_id_selected(int p_id);
bool _can_use_sub_inspector(const RES &p_resource);
void _open_editor_pressed();
void _fold_other_editors(Object *p_self);
void _update_property_bg();