summaryrefslogtreecommitdiff
path: root/editor/editor_inspector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r--editor/editor_inspector.cpp313
1 files changed, 210 insertions, 103 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 371100652f..74b874b54e 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,7 @@
#include "array_property_edit.h"
#include "dictionary_property_edit.h"
+#include "editor/doc_tools.h"
#include "editor_feature_profile.h"
#include "editor_node.h"
#include "editor_scale.h"
@@ -41,7 +42,8 @@
Size2 EditorProperty::get_minimum_size() const {
Size2 ms;
Ref<Font> font = get_theme_font("font", "Tree");
- ms.height = font->get_height();
+ int font_size = get_theme_font_size("font_size", "Tree");
+ ms.height = font->get_height(font_size);
for (int i = 0; i < get_child_count(); i++) {
Control *c = Object::cast_to<Control>(get_child(i));
@@ -79,7 +81,7 @@ Size2 EditorProperty::get_minimum_size() const {
}
if (bottom_editor != nullptr && bottom_editor->is_visible()) {
- ms.height += get_theme_constant("vseparation", "Tree");
+ ms.height += get_theme_constant("vseparation");
Size2 bems = bottom_editor->get_combined_minimum_size();
//bems.width += get_constant("item_margin", "Tree");
ms.height += bems.height;
@@ -93,6 +95,7 @@ void EditorProperty::emit_changed(const StringName &p_property, const Variant &p
Variant args[4] = { p_property, p_value, p_field, p_changing };
const Variant *argptrs[4] = { &args[0], &args[1], &args[2], &args[3] };
+ cache[p_property] = p_value;
emit_signal("property_changed", (const Variant **)argptrs, 4);
}
@@ -108,7 +111,8 @@ void EditorProperty::_notification(int p_what) {
{
int child_room = size.width * (1.0 - split_ratio);
Ref<Font> font = get_theme_font("font", "Tree");
- int height = font->get_height();
+ int font_size = get_theme_font_size("font_size", "Tree");
+ int height = font->get_height(font_size);
bool no_children = true;
//compute room needed
@@ -135,13 +139,17 @@ void EditorProperty::_notification(int p_what) {
rect = Rect2(size.width - 1, 0, 1, height);
} else {
text_size = MAX(0, size.width - (child_room + 4 * EDSCALE));
- rect = Rect2(size.width - child_room, 0, child_room, height);
+ if (is_layout_rtl()) {
+ rect = Rect2(1, 0, child_room, height);
+ } else {
+ rect = Rect2(size.width - child_room, 0, child_room, height);
+ }
}
if (bottom_editor) {
int m = 0; //get_constant("item_margin", "Tree");
- bottom_rect = Rect2(m, rect.size.height + get_theme_constant("vseparation", "Tree"), size.width - m, bottom_editor->get_combined_minimum_size().height);
+ bottom_rect = Rect2(m, rect.size.height + get_theme_constant("vseparation"), size.width - m, bottom_editor->get_combined_minimum_size().height);
}
if (keying) {
@@ -154,6 +162,9 @@ void EditorProperty::_notification(int p_what) {
}
rect.size.x -= key->get_width() + get_theme_constant("hseparator", "Tree");
+ if (is_layout_rtl()) {
+ rect.position.x += key->get_width() + get_theme_constant("hseparator", "Tree");
+ }
if (no_children) {
text_size -= key->get_width() + 4 * EDSCALE;
@@ -167,6 +178,10 @@ void EditorProperty::_notification(int p_what) {
rect.size.x -= close->get_width() + get_theme_constant("hseparator", "Tree");
+ if (is_layout_rtl()) {
+ rect.position.x += close->get_width() + get_theme_constant("hseparator", "Tree");
+ }
+
if (no_children) {
text_size -= close->get_width() + 4 * EDSCALE;
}
@@ -200,20 +215,26 @@ void EditorProperty::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
Color dark_color = get_theme_color("dark_color_2", "Editor");
+ bool rtl = is_layout_rtl();
Size2 size = get_size();
if (bottom_editor) {
- size.height = bottom_editor->get_margin(MARGIN_TOP);
+ size.height = bottom_editor->get_offset(SIDE_TOP);
} else if (label_reference) {
size.height = label_reference->get_size().height;
}
+ Ref<StyleBox> sb;
if (selected) {
- Ref<StyleBox> sb = get_theme_stylebox("selected", "Tree");
- draw_style_box(sb, Rect2(Vector2(), size));
+ sb = get_theme_stylebox("bg_selected");
+ } else {
+ sb = get_theme_stylebox("bg");
}
+ draw_style_box(sb, Rect2(Vector2(), size));
+
if (draw_top_bg && right_child_rect != Rect2()) {
draw_rect(right_child_rect, dark_color);
}
@@ -223,15 +244,15 @@ void EditorProperty::_notification(int p_what) {
Color color;
if (draw_red) {
- color = get_theme_color("error_color", "Editor");
+ color = get_theme_color("error_color");
} else {
- color = get_theme_color("property_color", "Editor");
+ color = get_theme_color("property_color");
}
if (label.find(".") != -1) {
color.a = 0.5; //this should be un-hacked honestly, as it's used for editor overrides
}
- int ofs = 0;
+ int ofs = get_theme_constant("font_offset");
int text_limit = text_size;
if (checkable) {
@@ -249,7 +270,11 @@ void EditorProperty::_notification(int p_what) {
color2.b *= 1.2;
}
check_rect = Rect2(ofs, ((size.height - checkbox->get_height()) / 2), checkbox->get_width(), checkbox->get_height());
- draw_texture(checkbox, check_rect.position, color2);
+ if (rtl) {
+ draw_texture(checkbox, Vector2(size.width - check_rect.position.x - checkbox->get_width(), check_rect.position.y), color2);
+ } else {
+ draw_texture(checkbox, check_rect.position, color2);
+ }
ofs += get_theme_constant("hseparator", "Tree") + checkbox->get_width() + get_theme_constant("hseparation", "CheckBox");
text_limit -= ofs;
} else {
@@ -267,14 +292,21 @@ void EditorProperty::_notification(int p_what) {
color2.g *= 1.2;
color2.b *= 1.2;
}
-
- draw_texture(reload_icon, revert_rect.position, color2);
+ if (rtl) {
+ draw_texture(reload_icon, Vector2(size.width - revert_rect.position.x - reload_icon->get_width(), revert_rect.position.y), color2);
+ } else {
+ draw_texture(reload_icon, revert_rect.position, color2);
+ }
} else {
revert_rect = Rect2();
}
- int v_ofs = (size.height - font->get_height()) / 2;
- draw_string(font, Point2(ofs, v_ofs + font->get_ascent()), label, color, text_limit);
+ int v_ofs = (size.height - font->get_height(font_size)) / 2;
+ if (rtl) {
+ draw_string(font, Point2(size.width - ofs - text_limit, v_ofs + font->get_ascent(font_size)), label, HALIGN_RIGHT, text_limit, font_size, color);
+ } else {
+ draw_string(font, Point2(ofs, v_ofs + font->get_ascent(font_size)), label, HALIGN_LEFT, text_limit, font_size, color);
+ }
if (keying) {
Ref<Texture2D> key;
@@ -294,7 +326,12 @@ void EditorProperty::_notification(int p_what) {
color2.b *= 1.2;
}
keying_rect = Rect2(ofs, ((size.height - key->get_height()) / 2), key->get_width(), key->get_height());
- draw_texture(key, keying_rect.position, color2);
+ if (rtl) {
+ draw_texture(key, Vector2(size.width - keying_rect.position.x - key->get_width(), keying_rect.position.y), color2);
+ } else {
+ draw_texture(key, keying_rect.position, color2);
+ }
+
} else {
keying_rect = Rect2();
}
@@ -313,7 +350,11 @@ void EditorProperty::_notification(int p_what) {
color2.b *= 1.2;
}
delete_rect = Rect2(ofs, ((size.height - close->get_height()) / 2), close->get_width(), close->get_height());
- draw_texture(close, delete_rect.position, color2);
+ if (rtl) {
+ draw_texture(close, Vector2(size.width - delete_rect.position.x - close->get_width(), delete_rect.position.y), color2);
+ } else {
+ draw_texture(close, delete_rect.position, color2);
+ }
} else {
delete_rect = Rect2();
}
@@ -648,27 +689,31 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouse> me = p_event;
if (me.is_valid()) {
+ Vector2 mpos = me->get_position();
+ if (is_layout_rtl()) {
+ mpos.x = get_size().x - mpos.x;
+ }
bool button_left = me->get_button_mask() & BUTTON_MASK_LEFT;
- bool new_keying_hover = keying_rect.has_point(me->get_position()) && !button_left;
+ bool new_keying_hover = keying_rect.has_point(mpos) && !button_left;
if (new_keying_hover != keying_hover) {
keying_hover = new_keying_hover;
update();
}
- bool new_delete_hover = delete_rect.has_point(me->get_position()) && !button_left;
+ bool new_delete_hover = delete_rect.has_point(mpos) && !button_left;
if (new_delete_hover != delete_hover) {
delete_hover = new_delete_hover;
update();
}
- bool new_revert_hover = revert_rect.has_point(me->get_position()) && !button_left;
+ bool new_revert_hover = revert_rect.has_point(mpos) && !button_left;
if (new_revert_hover != revert_hover) {
revert_hover = new_revert_hover;
update();
}
- bool new_check_hover = check_rect.has_point(me->get_position()) && !button_left;
+ bool new_check_hover = check_rect.has_point(mpos) && !button_left;
if (new_check_hover != check_hover) {
check_hover = new_check_hover;
update();
@@ -678,13 +723,18 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+ Vector2 mpos = mb->get_position();
+ if (is_layout_rtl()) {
+ mpos.x = get_size().x - mpos.x;
+ }
+
if (!selected && selectable) {
selected = true;
emit_signal("selected", property, -1);
update();
}
- if (keying_rect.has_point(mb->get_position())) {
+ if (keying_rect.has_point(mpos)) {
emit_signal("property_keyed", property, use_keying_next());
if (use_keying_next()) {
@@ -704,11 +754,11 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
call_deferred("update_property");
}
}
- if (delete_rect.has_point(mb->get_position())) {
+ if (delete_rect.has_point(mpos)) {
emit_signal("property_deleted", property);
}
- if (revert_rect.has_point(mb->get_position())) {
+ if (revert_rect.has_point(mpos)) {
Variant vorig;
Node *node = Object::cast_to<Node>(object);
@@ -744,7 +794,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
return;
}
}
- if (check_rect.has_point(mb->get_position())) {
+ if (check_rect.has_point(mpos)) {
checked = !checked;
update();
emit_signal("property_checked", property, checked);
@@ -760,6 +810,28 @@ void EditorProperty::set_bottom_editor(Control *p_control) {
bottom_editor = p_control;
}
+bool EditorProperty::is_cache_valid() const {
+ if (object) {
+ for (Map<StringName, Variant>::Element *E = cache.front(); E; E = E->next()) {
+ bool valid;
+ Variant value = object->get(E->key(), &valid);
+ if (!valid || value != E->get()) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+void EditorProperty::update_cache() {
+ cache.clear();
+ if (object && property != StringName()) {
+ bool valid;
+ Variant value = object->get(property, &valid);
+ if (valid) {
+ cache[property] = value;
+ }
+ }
+}
Variant EditorProperty::get_drag_data(const Point2 &p_point) {
if (property == StringName()) {
return Variant();
@@ -820,7 +892,7 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const {
String text;
PackedStringArray slices = p_text.split("::", false);
- if (!slices.empty()) {
+ if (!slices.is_empty()) {
String property_name = slices[0].strip_edges();
text = TTR("Property:") + " [u][b]" + property_name + "[/b][/u]";
@@ -918,6 +990,7 @@ EditorProperty::EditorProperty() {
selected_focusable = -1;
label_reference = nullptr;
bottom_editor = nullptr;
+ delete_hover = false;
}
////////////////////////////////////////////////
@@ -1024,10 +1097,11 @@ void EditorInspectorCategory::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
draw_rect(Rect2(Vector2(), get_size()), bg_color);
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
int hs = get_theme_constant("hseparation", "Tree");
- int w = font->get_string_size(label).width;
+ int w = font->get_string_size(label, font_size).width;
if (icon.is_valid()) {
w += hs + icon->get_width();
}
@@ -1040,7 +1114,7 @@ void EditorInspectorCategory::_notification(int p_what) {
}
Color color = get_theme_color("font_color", "Tree");
- draw_string(font, Point2(ofs, font->get_ascent() + (get_size().height - font->get_height()) / 2).floor(), label, color, get_size().width);
+ draw_string(font, Point2(ofs, font->get_ascent(font_size) + (get_size().height - font->get_height(font_size)) / 2).floor(), label, HALIGN_LEFT, get_size().width, font_size, color);
}
}
@@ -1051,7 +1125,7 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE);
PackedStringArray slices = p_text.split("::", false);
- if (!slices.empty()) {
+ if (!slices.is_empty()) {
String property_name = slices[0].strip_edges();
String text = "[u][b]" + property_name + "[/b][/u]";
@@ -1069,10 +1143,11 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons
Size2 EditorInspectorCategory::get_minimum_size() const {
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
Size2 ms;
ms.width = 1;
- ms.height = font->get_height();
+ ms.height = font->get_height(font_size);
if (icon.is_valid()) {
ms.height = MAX(icon->get_height(), ms.height);
}
@@ -1105,19 +1180,24 @@ void EditorInspectorSection::_test_unfold() {
void EditorInspectorSection::_notification(int p_what) {
if (p_what == NOTIFICATION_SORT_CHILDREN) {
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
Ref<Texture2D> arrow;
if (foldable) {
if (object->editor_is_section_unfolded(section)) {
arrow = get_theme_icon("arrow", "Tree");
} else {
- arrow = get_theme_icon("arrow_collapsed", "Tree");
+ if (is_layout_rtl()) {
+ arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree");
+ } else {
+ arrow = get_theme_icon("arrow_collapsed", "Tree");
+ }
}
}
Size2 size = get_size();
Point2 offset;
- offset.y = font->get_height();
+ offset.y = font->get_height(font_size);
if (arrow.is_valid()) {
offset.y = MAX(offset.y, arrow->get_height());
}
@@ -1148,18 +1228,20 @@ void EditorInspectorSection::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
Ref<Texture2D> arrow;
+ bool rtl = is_layout_rtl();
if (foldable) {
- if (object->editor_is_section_unfolded(section)) {
- arrow = get_theme_icon("arrow", "Tree");
+ if (rtl) {
+ arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree");
} else {
arrow = get_theme_icon("arrow_collapsed", "Tree");
}
}
Ref<Font> font = get_theme_font("font", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
- int h = font->get_height();
+ int h = font->get_height(font_size);
if (arrow.is_valid()) {
h = MAX(h, arrow->get_height());
}
@@ -1169,10 +1251,15 @@ void EditorInspectorSection::_notification(int p_what) {
const int arrow_margin = 3;
Color color = get_theme_color("font_color", "Tree");
- draw_string(font, Point2(Math::round((16 + arrow_margin) * EDSCALE), font->get_ascent() + (h - font->get_height()) / 2).floor(), label, color, get_size().width);
+ float text_width = get_size().width - Math::round((16 + arrow_margin) * EDSCALE);
+ draw_string(font, Point2(rtl ? 0 : Math::round((16 + arrow_margin) * EDSCALE), font->get_ascent(font_size) + (h - font->get_height(font_size)) / 2).floor(), label, rtl ? HALIGN_RIGHT : HALIGN_LEFT, text_width, font_size, color);
if (arrow.is_valid()) {
- draw_texture(arrow, Point2(Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor());
+ if (rtl) {
+ draw_texture(arrow, Point2(get_size().width - arrow->get_width() - Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor());
+ } else {
+ draw_texture(arrow, Point2(Math::round(arrow_margin * EDSCALE), (h - arrow->get_height()) / 2).floor());
+ }
}
if (dropping && !vbox->is_visible_in_tree()) {
@@ -1237,7 +1324,8 @@ Size2 EditorInspectorSection::get_minimum_size() const {
}
Ref<Font> font = get_theme_font("font", "Tree");
- ms.height += font->get_height() + get_theme_constant("vseparation", "Tree");
+ int font_size = get_theme_font_size("font_size", "Tree");
+ ms.height += font->get_height(font_size) + get_theme_constant("vseparation", "Tree");
ms.width += get_theme_constant("inspector_margin", "Editor");
return ms;
@@ -1273,7 +1361,8 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
Ref<Font> font = get_theme_font("font", "Tree");
- if (mb->get_position().y > font->get_height()) { //clicked outside
+ int font_size = get_theme_font_size("font_size", "Tree");
+ if (mb->get_position().y > font->get_height(font_size)) { //clicked outside
return;
}
@@ -1462,6 +1551,7 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit
ep->update_property();
ep->update_reload_status();
ep->set_deletable(deletable_properties);
+ ep->update_cache();
}
}
ped->added_editors.clear();
@@ -1599,7 +1689,7 @@ void EditorInspector::update_tree() {
bool valid = true;
//if no properties in category, skip
while (N) {
- if (N->get().usage & PROPERTY_USAGE_EDITOR) {
+ if (N->get().usage & PROPERTY_USAGE_EDITOR && (!restrict_to_basic || (N->get().usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) {
break;
}
if (N->get().usage & PROPERTY_USAGE_CATEGORY) {
@@ -1648,7 +1738,7 @@ void EditorInspector::update_tree() {
StringName type2 = p.name;
if (!class_descr_cache.has(type2)) {
String descr;
- DocData *dd = EditorHelp::get_doc_data();
+ DocTools *dd = EditorHelp::get_doc_data();
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type2);
if (E) {
descr = DTR(E->get().brief_description);
@@ -1667,10 +1757,14 @@ void EditorInspector::update_tree() {
continue;
- } else if (!(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name)) {
+ } else if (!(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name) || (restrict_to_basic && !(p.usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) {
continue;
}
+ if (p.name == "script") {
+ category_vbox = nullptr; // script should go into its own category
+ }
+
if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && RS::get_singleton()->is_low_end()) {
continue; //do not show this property in low end gfx
}
@@ -1818,7 +1912,7 @@ void EditorInspector::update_tree() {
}
if (!found) {
- DocData *dd = EditorHelp::get_doc_data();
+ DocTools *dd = EditorHelp::get_doc_data();
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(classname);
while (F && descr == String()) {
for (int i = 0; i < F->get().properties.size(); i++) {
@@ -1839,7 +1933,7 @@ void EditorInspector::update_tree() {
}
}
- if (!F->get().inherits.empty()) {
+ if (!F->get().inherits.is_empty()) {
F = dd->class_list.find(F->get().inherits);
} else {
break;
@@ -1920,6 +2014,7 @@ void EditorInspector::update_tree() {
}
ep->update_property();
ep->update_reload_status();
+ ep->update_cache();
if (current_selected && ep->property == current_selected) {
ep->select(current_focusable);
@@ -1950,6 +2045,7 @@ void EditorInspector::update_property(const String &p_prop) {
for (List<EditorProperty *>::Element *E = editor_property_map[p_prop].front(); E; E = E->next()) {
E->get()->update_property();
E->get()->update_reload_status();
+ E->get()->update_cache();
}
}
@@ -1965,13 +2061,6 @@ void EditorInspector::_clear() {
restart_request_props.clear();
}
-void EditorInspector::refresh() {
- if (refresh_countdown > 0 || changing) {
- return;
- }
- refresh_countdown = EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval");
-}
-
Object *EditorInspector::get_edited_object() {
return object;
}
@@ -1982,7 +2071,7 @@ void EditorInspector::edit(Object *p_object) {
}
if (object) {
_clear();
- object->remove_change_receptor(this);
+ object->disconnect("property_list_changed", callable_mp(this, &EditorInspector::_changed_callback));
}
object = p_object;
@@ -1992,7 +2081,7 @@ void EditorInspector::edit(Object *p_object) {
if (scroll_cache.has(object->get_instance_id())) { //if exists, set something else
update_scroll_request = scroll_cache[object->get_instance_id()]; //done this way because wait until full size is accommodated
}
- object->add_change_receptor(this);
+ object->connect("property_list_changed", callable_mp(this, &EditorInspector::_changed_callback));
update_tree();
}
}
@@ -2099,17 +2188,30 @@ void EditorInspector::set_use_wide_editors(bool p_enable) {
wide_editors = p_enable;
}
+void EditorInspector::_update_inspector_bg() {
+ if (sub_inspector) {
+ int count_subinspectors = 0;
+ Node *n = get_parent();
+ while (n) {
+ EditorInspector *ei = Object::cast_to<EditorInspector>(n);
+ if (ei && ei->sub_inspector) {
+ count_subinspectors++;
+ }
+ n = n->get_parent();
+ }
+ count_subinspectors = MIN(15, count_subinspectors);
+ add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), "Editor"));
+ } else {
+ add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
+ }
+}
void EditorInspector::set_sub_inspector(bool p_enable) {
sub_inspector = p_enable;
if (!is_inside_tree()) {
return;
}
- if (sub_inspector) {
- add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor"));
- } else {
- add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
- }
+ _update_inspector_bg();
}
void EditorInspector::set_use_deletable_properties(bool p_enabled) {
@@ -2289,6 +2391,7 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
for (List<EditorProperty *>::Element *E = editor_property_map[p_path].front(); E; E = E->next()) {
E->get()->update_property();
E->get()->update_reload_status();
+ E->get()->update_cache();
}
}
@@ -2332,13 +2435,12 @@ void EditorInspector::_node_removed(Node *p_node) {
void EditorInspector::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed));
+ set_process(is_visible_in_tree());
}
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (sub_inspector) {
- add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor"));
- } else {
- add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
+ _update_inspector_bg();
+ if (!sub_inspector) {
get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
}
}
@@ -2352,6 +2454,10 @@ void EditorInspector::_notification(int p_what) {
edit(nullptr);
}
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+ set_process(is_visible_in_tree());
+ }
+
if (p_what == NOTIFICATION_PROCESS) {
if (update_scroll_request >= 0) {
get_v_scrollbar()->call_deferred("set_value", update_scroll_request);
@@ -2362,10 +2468,14 @@ void EditorInspector::_notification(int p_what) {
if (refresh_countdown <= 0) {
for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) {
for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) {
- E->get()->update_property();
- E->get()->update_reload_status();
+ if (!E->get()->is_cache_valid()) {
+ E->get()->update_property();
+ E->get()->update_reload_status();
+ E->get()->update_cache();
+ }
}
}
+ refresh_countdown = float(EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval"));
}
}
@@ -2383,6 +2493,7 @@ void EditorInspector::_notification(int p_what) {
for (List<EditorProperty *>::Element *E = editor_property_map[prop].front(); E; E = E->next()) {
E->get()->update_property();
E->get()->update_reload_status();
+ E->get()->update_cache();
}
}
pending.erase(pending.front());
@@ -2393,19 +2504,17 @@ void EditorInspector::_notification(int p_what) {
}
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
- if (sub_inspector) {
- add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor"));
- } else if (is_inside_tree()) {
- add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
- }
+ _update_inspector_bg();
update_tree();
}
}
-void EditorInspector::_changed_callback(Object *p_changed, const char *p_prop) {
- //this is called when property change is notified via _change_notify()
- _edit_request_change(p_changed, p_prop);
+void EditorInspector::_changed_callback() {
+ //this is called when property change is notified via notify_property_list_changed()
+ if (object != nullptr) {
+ _edit_request_change(object, String());
+ }
}
void EditorInspector::_vscroll_changed(double p_offset) {
@@ -2444,26 +2553,15 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
return;
}
- List<StringName> classes;
- Map<StringName, String> paths;
+ List<Ref<Script>> classes;
// NodeC -> NodeB -> NodeA
while (script.is_valid()) {
- String n = EditorNode::get_editor_data().script_class_get_name(script->get_path());
- if (n.length()) {
- classes.push_front(n);
- } else if (script->get_path() != String() && script->get_path().find("::") == -1) {
- n = script->get_path().get_file();
- classes.push_front(n);
- } else {
- n = TTR("Built-in script");
- classes.push_front(n);
- }
- paths[n] = script->get_path();
+ classes.push_front(script);
script = script->get_base_script();
}
- if (classes.empty()) {
+ if (classes.is_empty()) {
return;
}
@@ -2483,17 +2581,18 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
}
Set<StringName> added;
- for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
- StringName name = E->get();
- String path = paths[name];
- Ref<Script> s;
- if (path == String()) {
- // Built-in script. It can't be inherited, so must be the script attached to the object.
- s = p_object.get_script();
- } else {
- s = ResourceLoader::load(path, "Script");
+ for (List<Ref<Script>>::Element *E = classes.front(); E; E = E->next()) {
+ Ref<Script> s = E->get();
+ String path = s->get_path();
+ String name = EditorNode::get_editor_data().script_class_get_name(path);
+ if (name.is_empty()) {
+ if (!path.is_empty() && path.find("::") == -1) {
+ name = path.get_file();
+ } else {
+ name = TTR("Built-in script");
+ }
}
- ERR_FAIL_COND(!s->is_valid());
+
List<PropertyInfo> props;
s->get_script_property_list(&props);
@@ -2525,11 +2624,14 @@ void EditorInspector::_update_script_class_properties(const Object &p_object, Li
r_list.erase(bottom);
}
+void EditorInspector::set_restrict_to_basic_settings(bool p_restrict) {
+ restrict_to_basic = p_restrict;
+ update_tree();
+}
+
void EditorInspector::_bind_methods() {
ClassDB::bind_method("_edit_request_change", &EditorInspector::_edit_request_change);
- ClassDB::bind_method("refresh", &EditorInspector::refresh);
-
ADD_SIGNAL(MethodInfo("property_selected", PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("property_deleted", PropertyInfo(Variant::STRING, "property")));
@@ -2561,16 +2663,21 @@ EditorInspector::EditorInspector() {
use_folding = false;
update_all_pending = false;
update_tree_pending = false;
- refresh_countdown = 0;
read_only = false;
search_box = nullptr;
keying = false;
_prop_edited = "property_edited";
- set_process(true);
+ set_process(false);
property_focusable = -1;
sub_inspector = false;
deletable_properties = false;
get_v_scrollbar()->connect("value_changed", callable_mp(this, &EditorInspector::_vscroll_changed));
update_scroll_request = -1;
+ if (EditorSettings::get_singleton()) {
+ refresh_countdown = float(EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval"));
+ } else {
+ //used when class is created by the docgen to dump default values of everything bindable, editorsettings may not be created
+ refresh_countdown = 0.33;
+ }
}