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.cpp77
1 files changed, 69 insertions, 8 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 531aa2f9dc..17f383c8ae 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -92,7 +92,7 @@ void EditorProperty::_notification(int p_what) {
Rect2 bottom_rect;
{
- int child_room = size.width / 2;
+ int child_room = size.width * (1.0 - split_ratio);
Ref<Font> font = get_font("font", "Tree");
int height = font->get_height();
@@ -691,6 +691,15 @@ bool EditorProperty::is_selectable() const {
return selectable;
}
+void EditorProperty::set_name_split_ratio(float p_ratio) {
+ split_ratio = p_ratio;
+}
+
+float EditorProperty::get_name_split_ratio() const {
+
+ return split_ratio;
+}
+
void EditorProperty::set_object_and_property(Object *p_object, const StringName &p_property) {
object = p_object;
property = p_property;
@@ -744,6 +753,7 @@ void EditorProperty::_bind_methods() {
EditorProperty::EditorProperty() {
+ split_ratio = 0.5;
selectable = true;
text_size = 0;
read_only = false;
@@ -1114,6 +1124,30 @@ EditorInspectorSection::EditorInspectorSection() {
Ref<EditorInspectorPlugin> EditorInspector::inspector_plugins[MAX_PLUGINS];
int EditorInspector::inspector_plugin_count = 0;
+EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
+
+ for (int i = inspector_plugin_count - 1; i >= 0; i--) {
+
+ inspector_plugins[i]->parse_property(p_object, p_type, p_path, p_hint, p_hint_text, p_usage);
+ if (inspector_plugins[i]->added_editors.size()) {
+ for (int j = 1; j < inspector_plugins[i]->added_editors.size(); j++) { //only keep first one
+ memdelete(inspector_plugins[i]->added_editors[j].property_editor);
+ }
+
+ EditorProperty *prop = Object::cast_to<EditorProperty>(inspector_plugins[i]->added_editors[0].property_editor);
+ if (prop) {
+
+ inspector_plugins[i]->added_editors.clear();
+ return prop;
+ } else {
+ memdelete(inspector_plugins[i]->added_editors[0].property_editor);
+ inspector_plugins[i]->added_editors.clear();
+ }
+ }
+ }
+ return NULL;
+}
+
void EditorInspector::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
ERR_FAIL_COND(inspector_plugin_count == MAX_PLUGINS);
@@ -1331,8 +1365,9 @@ void EditorInspector::update_tree() {
} else if (!(p.usage & PROPERTY_USAGE_EDITOR))
continue;
- if (hide_script && p.name == "script")
+ if (p.name == "script" && (hide_script || bool(object->call("_hide_script_from_inspector")))) {
continue;
+ }
String basename = p.name;
if (group != "") {
@@ -1463,7 +1498,8 @@ void EditorInspector::update_tree() {
#endif
for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) {
Ref<EditorInspectorPlugin> ped = E->get();
- ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage);
+ bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage);
+
List<EditorInspectorPlugin::AddedEditor> editors = ped->added_editors; //make a copy, since plugins may be used again in a sub-inspector
ped->added_editors.clear();
@@ -1476,6 +1512,9 @@ void EditorInspector::update_tree() {
ep->object = object;
ep->connect("property_changed", this, "_property_changed");
+ if (p.usage & PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED) {
+ ep->connect("property_changed", this, "_property_changed_update_all", varray(), CONNECT_DEFERRED);
+ }
ep->connect("property_keyed", this, "_property_keyed");
ep->connect("property_keyed_with_value", this, "_property_keyed_with_value");
ep->connect("property_checked", this, "_property_checked");
@@ -1528,6 +1567,10 @@ void EditorInspector::update_tree() {
}
}
}
+
+ if (exclusive) {
+ break;
+ }
}
}
@@ -1563,7 +1606,7 @@ void EditorInspector::_clear() {
void EditorInspector::refresh() {
- if (refresh_countdown > 0)
+ if (refresh_countdown > 0 || changing)
return;
refresh_countdown = EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval");
}
@@ -1638,6 +1681,7 @@ void EditorInspector::register_text_enter(Node *p_line_edit) {
void EditorInspector::_filter_changed(const String &p_text) {
+ _clear();
update_tree();
}
@@ -1652,6 +1696,10 @@ void EditorInspector::set_use_folding(bool p_enable) {
update_tree();
}
+bool EditorInspector::is_using_folding() {
+ return use_folding;
+}
+
void EditorInspector::collapse_all_folding() {
for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) {
@@ -1759,9 +1807,7 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
}
undo_redo->add_do_method(this, "emit_signal", _prop_edited, p_name);
undo_redo->add_undo_method(this, "emit_signal", _prop_edited, p_name);
- changing++;
undo_redo->commit_action();
- changing--;
}
if (editor_property_map.has(p_name)) {
@@ -1771,9 +1817,21 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
}
}
-void EditorInspector::_property_changed(const String &p_path, const Variant &p_value) {
+void EditorInspector::_property_changed(const String &p_path, const Variant &p_value, bool changing) {
+
+ // The "changing" variable must be true for properties that trigger events as typing occurs,
+ // like "text_changed" signal. eg: Text property of Label, Button, RichTextLabel, etc.
+ if (changing)
+ this->changing++;
_edit_set(p_path, p_value, false, "");
+
+ if (changing)
+ this->changing--;
+}
+
+void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value) {
+ update_tree();
}
void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array p_values) {
@@ -1943,8 +2001,10 @@ void EditorInspector::_changed_callback(Object *p_changed, const char *p_prop) {
void EditorInspector::_bind_methods() {
+ ClassDB::bind_method("_property_changed", &EditorInspector::_property_changed, DEFVAL(false));
ClassDB::bind_method("_multiple_properties_changed", &EditorInspector::_multiple_properties_changed);
- ClassDB::bind_method("_property_changed", &EditorInspector::_property_changed);
+ ClassDB::bind_method("_property_changed_update_all", &EditorInspector::_property_changed_update_all);
+
ClassDB::bind_method("_edit_request_change", &EditorInspector::_edit_request_change);
ClassDB::bind_method("_node_removed", &EditorInspector::_node_removed);
ClassDB::bind_method("_filter_changed", &EditorInspector::_filter_changed);
@@ -1954,6 +2014,7 @@ void EditorInspector::_bind_methods() {
ClassDB::bind_method("_property_selected", &EditorInspector::_property_selected);
ClassDB::bind_method("_resource_selected", &EditorInspector::_resource_selected);
ClassDB::bind_method("_object_id_selected", &EditorInspector::_object_id_selected);
+ ClassDB::bind_method("refresh", &EditorInspector::refresh);
ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop")));