Merge pull request #14478 from akien-mga/property-tooltips
PropertyEditor: Fix display of property doc in tooltip
This commit is contained in:
commit
fae98c0b6a
|
@ -1036,7 +1036,6 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia
|
||||||
r_value = *c;
|
r_value = *c;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//if (check->constant_map.fin)
|
|
||||||
|
|
||||||
check = check->inherits_ptr;
|
check = check->inherits_ptr;
|
||||||
}
|
}
|
||||||
|
@ -1163,24 +1162,6 @@ bool ClassDB::has_method(StringName p_class, StringName p_method, bool p_no_inhe
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClassDB::get_setter_and_type_for_property(const StringName &p_class, const StringName &p_prop, StringName &r_class, StringName &r_setter) {
|
|
||||||
|
|
||||||
ClassInfo *type = classes.getptr(p_class);
|
|
||||||
ClassInfo *check = type;
|
|
||||||
while (check) {
|
|
||||||
|
|
||||||
if (check->property_setget.has(p_prop)) {
|
|
||||||
r_class = check->name;
|
|
||||||
r_setter = check->property_setget[p_prop].setter;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
check = check->inherits_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_METHODS_ENABLED
|
#ifdef DEBUG_METHODS_ENABLED
|
||||||
MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount) {
|
MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount) {
|
||||||
StringName mdname = method_name.name;
|
StringName mdname = method_name.name;
|
||||||
|
|
|
@ -349,8 +349,6 @@ public:
|
||||||
|
|
||||||
static StringName get_category(const StringName &p_node);
|
static StringName get_category(const StringName &p_node);
|
||||||
|
|
||||||
static bool get_setter_and_type_for_property(const StringName &p_class, const StringName &p_prop, StringName &r_class, StringName &r_setter);
|
|
||||||
|
|
||||||
static void set_class_enabled(StringName p_class, bool p_enable);
|
static void set_class_enabled(StringName p_class, bool p_enable);
|
||||||
static bool is_class_enabled(StringName p_class);
|
static bool is_class_enabled(StringName p_class);
|
||||||
|
|
||||||
|
|
|
@ -647,7 +647,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type)
|
if (type != Variant::NIL)
|
||||||
property_select->select_property_from_basic_type(type, v);
|
property_select->select_property_from_basic_type(type, v);
|
||||||
|
|
||||||
updating = false;
|
updating = false;
|
||||||
|
@ -2802,13 +2802,12 @@ void PropertyEditor::update_tree() {
|
||||||
TreeItem *sep = tree->create_item(root);
|
TreeItem *sep = tree->create_item(root);
|
||||||
current_category = sep;
|
current_category = sep;
|
||||||
String type = p.name;
|
String type = p.name;
|
||||||
//*
|
|
||||||
if (has_icon(type, "EditorIcons"))
|
if (has_icon(type, "EditorIcons"))
|
||||||
sep->set_icon(0, get_icon(type, "EditorIcons"));
|
sep->set_icon(0, get_icon(type, "EditorIcons"));
|
||||||
else
|
else
|
||||||
sep->set_icon(0, get_icon("Object", "EditorIcons"));
|
sep->set_icon(0, get_icon("Object", "EditorIcons"));
|
||||||
|
|
||||||
//*/
|
|
||||||
sep->set_text(0, type);
|
sep->set_text(0, type);
|
||||||
sep->set_expand_right(0, true);
|
sep->set_expand_right(0, true);
|
||||||
sep->set_selectable(0, false);
|
sep->set_selectable(0, false);
|
||||||
|
@ -2934,39 +2933,37 @@ void PropertyEditor::update_tree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_doc_hints) {
|
if (use_doc_hints) {
|
||||||
StringName setter;
|
|
||||||
StringName type;
|
|
||||||
if (ClassDB::get_setter_and_type_for_property(obj->get_class_name(), p.name, type, setter)) {
|
|
||||||
|
|
||||||
|
StringName classname = obj->get_class_name();
|
||||||
|
StringName propname = p.name;
|
||||||
String descr;
|
String descr;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
Map<StringName, Map<StringName, String> >::Element *E = descr_cache.find(type);
|
|
||||||
if (E) {
|
|
||||||
|
|
||||||
Map<StringName, String>::Element *F = E->get().find(setter);
|
Map<StringName, Map<StringName, String> >::Element *E = descr_cache.find(classname);
|
||||||
|
if (E) {
|
||||||
|
Map<StringName, String>::Element *F = E->get().find(propname);
|
||||||
if (F) {
|
if (F) {
|
||||||
found = true;
|
found = true;
|
||||||
descr = F->get();
|
descr = F->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
|
||||||
DocData *dd = EditorHelp::get_doc_data();
|
DocData *dd = EditorHelp::get_doc_data();
|
||||||
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type);
|
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(classname);
|
||||||
if (E) {
|
if (E) {
|
||||||
for (int i = 0; i < E->get().methods.size(); i++) {
|
for (int i = 0; i < E->get().properties.size(); i++) {
|
||||||
if (E->get().methods[i].name == setter.operator String()) {
|
if (E->get().properties[i].name == propname.operator String()) {
|
||||||
descr = E->get().methods[i].description.strip_edges().word_wrap(80);
|
descr = E->get().properties[i].description.strip_edges().word_wrap(80);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
descr_cache[type][setter] = descr;
|
descr_cache[classname][propname] = descr;
|
||||||
}
|
}
|
||||||
|
|
||||||
item->set_tooltip(0, TTR("Property:") + " " + p.name + "\n\n" + descr);
|
item->set_tooltip(0, TTR("Property:") + " " + p.name + "\n\n" + descr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary d;
|
Dictionary d;
|
||||||
d["name"] = p.name;
|
d["name"] = p.name;
|
||||||
|
|
|
@ -363,23 +363,6 @@ void PropertySelector::_item_selected() {
|
||||||
|
|
||||||
at_class = ClassDB::get_parent_class(at_class);
|
at_class = ClassDB::get_parent_class(at_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text == String()) {
|
|
||||||
|
|
||||||
StringName setter;
|
|
||||||
StringName type;
|
|
||||||
if (ClassDB::get_setter_and_type_for_property(class_type, name, type, setter)) {
|
|
||||||
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type);
|
|
||||||
if (E) {
|
|
||||||
for (int i = 0; i < E->get().methods.size(); i++) {
|
|
||||||
if (E->get().methods[i].name == setter.operator String()) {
|
|
||||||
text = E->get().methods[i].description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String at_class = class_type;
|
String at_class = class_type;
|
||||||
|
@ -516,6 +499,7 @@ void PropertySelector::select_property_from_script(const Ref<Script> &p_script,
|
||||||
search_box->grab_focus();
|
search_box->grab_focus();
|
||||||
_update_search();
|
_update_search();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertySelector::select_property_from_basic_type(Variant::Type p_type, const String &p_current) {
|
void PropertySelector::select_property_from_basic_type(Variant::Type p_type, const String &p_current) {
|
||||||
|
|
||||||
ERR_FAIL_COND(p_type == Variant::NIL);
|
ERR_FAIL_COND(p_type == Variant::NIL);
|
||||||
|
|
Loading…
Reference in New Issue