diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2020-12-18 09:36:04 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2020-12-18 12:21:41 +0300 |
commit | 89ed0323b9d09ba5251f4bdecb4d1b7830340ac2 (patch) | |
tree | c16c211aed48e082349475879cfb378d82394aa2 | |
parent | 5332d212f9bc0932544156d1fa1f568bf4ae24a8 (diff) |
Show constructor arguments in Search Help panel (for basic types)
-rw-r--r-- | editor/editor_help_search.cpp | 32 | ||||
-rw-r--r-- | editor/editor_help_search.h | 4 |
2 files changed, 24 insertions, 12 deletions
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index c5d89b713c..5e784ba051 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -412,8 +412,20 @@ bool EditorHelpSearch::Runner::_phase_member_items() { ClassMatch &match = iterator_match->value(); TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item; + bool constructor_created = false; for (int i = 0; i < match.methods.size(); i++) { - _create_method_item(parent, match.doc, match.methods[i]); + String text = match.methods[i]->name; + if (!constructor_created) { + if (match.doc->name == match.methods[i]->name) { + text += " " + TTR("(constructors)"); + constructor_created = true; + } + } else { + if (match.doc->name == match.methods[i]->name) { + continue; + } + } + _create_method_item(parent, match.doc, text, match.methods[i]); } for (int i = 0; i < match.signals.size(); i++) { _create_signal_item(parent, match.doc, match.signals[i]); @@ -508,7 +520,7 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const return item; } -TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) { +TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) { String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "("; for (int i = 0; i < p_doc->arguments.size(); i++) { const DocData::ArgumentDoc &arg = p_doc->arguments[i]; @@ -521,7 +533,7 @@ TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, cons } } tooltip += ")"; - return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, TTRC("Method"), "method", tooltip); + return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, p_text, TTRC("Method"), "method", tooltip); } TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) { @@ -537,32 +549,32 @@ TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, cons } } tooltip += ")"; - return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, TTRC("Signal"), "signal", tooltip); + return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, p_doc->name, TTRC("Signal"), "signal", tooltip); } TreeItem *EditorHelpSearch::Runner::_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc) { String tooltip = p_class_doc->name + "." + p_doc->name; - return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, TTRC("Constant"), "constant", tooltip); + return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, p_doc->name, TTRC("Constant"), "constant", tooltip); } TreeItem *EditorHelpSearch::Runner::_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) { String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name; tooltip += "\n " + p_class_doc->name + "." + p_doc->setter + "(value) setter"; tooltip += "\n " + p_class_doc->name + "." + p_doc->getter + "() getter"; - return _create_member_item(p_parent, p_class_doc->name, "MemberProperty", p_doc->name, TTRC("Property"), "property", tooltip); + return _create_member_item(p_parent, p_class_doc->name, "MemberProperty", p_doc->name, p_doc->name, TTRC("Property"), "property", tooltip); } TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) { String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name; - return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, TTRC("Theme Property"), "theme_item", tooltip); + return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, p_doc->name, TTRC("Theme Property"), "theme_item", tooltip); } -TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_type, const String &p_metatype, const String &p_tooltip) { +TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip) { Ref<Texture2D> icon; String text; if (search_flags & SEARCH_SHOW_HIERARCHY) { icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); - text = p_name; + text = p_text; } else { icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); /*// In flat mode, show the class icon. @@ -570,7 +582,7 @@ if (ui_service->has_icon(p_class_name, "EditorIcons")) icon = ui_service->get_icon(p_class_name, "EditorIcons"); else if (ClassDB::is_parent_class(p_class_name, "Object")) icon = ui_service->get_icon("Object", "EditorIcons");*/ - text = p_class_name + "." + p_name; + text = p_class_name + "." + p_text; } TreeItem *item = results_tree->create_item(p_parent); diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index cb52c515de..d94066308a 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -140,12 +140,12 @@ class EditorHelpSearch::Runner : public Reference { void _match_item(TreeItem *p_item, const String &p_text); TreeItem *_create_class_hierarchy(const ClassMatch &p_match); TreeItem *_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray); - TreeItem *_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc); + TreeItem *_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc); TreeItem *_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc); TreeItem *_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc); TreeItem *_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc); TreeItem *_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc); - TreeItem *_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_type, const String &p_metatype, const String &p_tooltip); + TreeItem *_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip); public: bool work(uint64_t slot = 100000); |