Merge pull request #73098 from YuriSizov/editor-dont-hide-plugins
Avoid cleaning up editor plugins when property list changes
This commit is contained in:
commit
44b41ded82
3 changed files with 14 additions and 79 deletions
|
@ -2566,12 +2566,13 @@ bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorInspector::update_tree() {
|
void EditorInspector::update_tree() {
|
||||||
//to update properly if all is refreshed
|
// Store currently selected and focused elements to restore after the update.
|
||||||
|
// TODO: Can be useful to store more context for the focusable, such as the caret position in LineEdit.
|
||||||
StringName current_selected = property_selected;
|
StringName current_selected = property_selected;
|
||||||
int current_focusable = -1;
|
int current_focusable = -1;
|
||||||
|
|
||||||
if (property_focusable != -1) {
|
if (property_focusable != -1) {
|
||||||
//check focusable is really focusable
|
// Check that focusable is actually focusable.
|
||||||
bool restore_focus = false;
|
bool restore_focus = false;
|
||||||
Control *focused = get_viewport() ? get_viewport()->gui_get_focus_owner() : nullptr;
|
Control *focused = get_viewport() ? get_viewport()->gui_get_focus_owner() : nullptr;
|
||||||
if (focused) {
|
if (focused) {
|
||||||
|
@ -2579,8 +2580,8 @@ void EditorInspector::update_tree() {
|
||||||
while (parent) {
|
while (parent) {
|
||||||
EditorInspector *inspector = Object::cast_to<EditorInspector>(parent);
|
EditorInspector *inspector = Object::cast_to<EditorInspector>(parent);
|
||||||
if (inspector) {
|
if (inspector) {
|
||||||
restore_focus = inspector == this; //may be owned by another inspector
|
restore_focus = inspector == this; // May be owned by another inspector.
|
||||||
break; //exit after the first inspector is found, since there may be nested ones
|
break; // Exit after the first inspector is found, since there may be nested ones.
|
||||||
}
|
}
|
||||||
parent = parent->get_parent();
|
parent = parent->get_parent();
|
||||||
}
|
}
|
||||||
|
@ -2591,7 +2592,9 @@ void EditorInspector::update_tree() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_clear();
|
// Only hide plugins if we are not editing any object.
|
||||||
|
// This should be handled outside of the update_tree call anyway (see EditorInspector::edit), but might as well keep it safe.
|
||||||
|
_clear(!object);
|
||||||
|
|
||||||
if (!object) {
|
if (!object) {
|
||||||
return;
|
return;
|
||||||
|
@ -3301,17 +3304,19 @@ void EditorInspector::update_property(const String &p_prop) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorInspector::_clear() {
|
void EditorInspector::_clear(bool p_hide_plugins) {
|
||||||
while (main_vbox->get_child_count()) {
|
while (main_vbox->get_child_count()) {
|
||||||
memdelete(main_vbox->get_child(0));
|
memdelete(main_vbox->get_child(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
property_selected = StringName();
|
property_selected = StringName();
|
||||||
property_focusable = -1;
|
property_focusable = -1;
|
||||||
editor_property_map.clear();
|
editor_property_map.clear();
|
||||||
sections.clear();
|
sections.clear();
|
||||||
pending.clear();
|
pending.clear();
|
||||||
restart_request_props.clear();
|
restart_request_props.clear();
|
||||||
if (_is_main_editor_inspector()) {
|
|
||||||
|
if (p_hide_plugins && _is_main_editor_inspector()) {
|
||||||
EditorNode::get_singleton()->hide_unused_editors(this);
|
EditorNode::get_singleton()->hide_unused_editors(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3405,7 +3410,6 @@ void EditorInspector::register_text_enter(Node *p_line_edit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorInspector::_filter_changed(const String &p_text) {
|
void EditorInspector::_filter_changed(const String &p_text) {
|
||||||
_clear();
|
|
||||||
update_tree();
|
update_tree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -451,7 +451,7 @@ class EditorInspector : public ScrollContainer {
|
||||||
List<EditorInspectorSection *> sections;
|
List<EditorInspectorSection *> sections;
|
||||||
HashSet<StringName> pending;
|
HashSet<StringName> pending;
|
||||||
|
|
||||||
void _clear();
|
void _clear(bool p_hide_plugins = true);
|
||||||
Object *object = nullptr;
|
Object *object = nullptr;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -3705,82 +3705,13 @@ ThemeEditor::ThemeEditor() {
|
||||||
void ThemeEditorPlugin::edit(Object *p_node) {
|
void ThemeEditorPlugin::edit(Object *p_node) {
|
||||||
if (Object::cast_to<Theme>(p_node)) {
|
if (Object::cast_to<Theme>(p_node)) {
|
||||||
theme_editor->edit(Object::cast_to<Theme>(p_node));
|
theme_editor->edit(Object::cast_to<Theme>(p_node));
|
||||||
} else if (Object::cast_to<Font>(p_node) || Object::cast_to<StyleBox>(p_node) || Object::cast_to<Texture2D>(p_node)) {
|
|
||||||
// Do nothing, keep editing the existing theme.
|
|
||||||
} else {
|
} else {
|
||||||
theme_editor->edit(Ref<Theme>());
|
theme_editor->edit(Ref<Theme>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThemeEditorPlugin::handles(Object *p_node) const {
|
bool ThemeEditorPlugin::handles(Object *p_node) const {
|
||||||
if (Object::cast_to<Theme>(p_node)) {
|
return Object::cast_to<Theme>(p_node) != nullptr;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<Theme> edited_theme = theme_editor->get_edited_theme();
|
|
||||||
if (edited_theme.is_null()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we are editing a theme already and this particular resource happens to belong to it,
|
|
||||||
// then we just keep editing it, despite not being able to directly handle it.
|
|
||||||
// This only goes one layer deep, but if required this can be extended to support, say, Font inside of Font.
|
|
||||||
bool belongs_to_theme = false;
|
|
||||||
|
|
||||||
if (Object::cast_to<Font>(p_node)) {
|
|
||||||
Ref<Font> font_item = Object::cast_to<Font>(p_node);
|
|
||||||
List<StringName> types;
|
|
||||||
List<StringName> names;
|
|
||||||
|
|
||||||
edited_theme->get_font_type_list(&types);
|
|
||||||
for (const StringName &E : types) {
|
|
||||||
names.clear();
|
|
||||||
edited_theme->get_font_list(E, &names);
|
|
||||||
|
|
||||||
for (const StringName &F : names) {
|
|
||||||
if (font_item == edited_theme->get_font(F, E)) {
|
|
||||||
belongs_to_theme = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (Object::cast_to<StyleBox>(p_node)) {
|
|
||||||
Ref<StyleBox> stylebox_item = Object::cast_to<StyleBox>(p_node);
|
|
||||||
List<StringName> types;
|
|
||||||
List<StringName> names;
|
|
||||||
|
|
||||||
edited_theme->get_stylebox_type_list(&types);
|
|
||||||
for (const StringName &E : types) {
|
|
||||||
names.clear();
|
|
||||||
edited_theme->get_stylebox_list(E, &names);
|
|
||||||
|
|
||||||
for (const StringName &F : names) {
|
|
||||||
if (stylebox_item == edited_theme->get_stylebox(F, E)) {
|
|
||||||
belongs_to_theme = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (Object::cast_to<Texture2D>(p_node)) {
|
|
||||||
Ref<Texture2D> icon_item = Object::cast_to<Texture2D>(p_node);
|
|
||||||
List<StringName> types;
|
|
||||||
List<StringName> names;
|
|
||||||
|
|
||||||
edited_theme->get_icon_type_list(&types);
|
|
||||||
for (const StringName &E : types) {
|
|
||||||
names.clear();
|
|
||||||
edited_theme->get_icon_list(E, &names);
|
|
||||||
|
|
||||||
for (const StringName &F : names) {
|
|
||||||
if (icon_item == edited_theme->get_icon(F, E)) {
|
|
||||||
belongs_to_theme = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return belongs_to_theme;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeEditorPlugin::make_visible(bool p_visible) {
|
void ThemeEditorPlugin::make_visible(bool p_visible) {
|
||||||
|
|
Loading…
Reference in a new issue