diff options
Diffstat (limited to 'editor/editor_inspector.cpp')
| -rw-r--r-- | editor/editor_inspector.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 395f4faa39..e1a7d8f111 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -906,12 +906,24 @@ void EditorProperty::_update_pin_flags() { } Control *EditorProperty::make_custom_tooltip(const String &p_text) const { - EditorHelpTooltip *tooltip = memnew(EditorHelpTooltip(p_text)); + EditorHelpBit *tooltip = nullptr; + + if (has_doc_tooltip) { + tooltip = memnew(EditorHelpTooltip(p_text)); + } if (object->has_method("_get_property_warning")) { String warn = object->call("_get_property_warning", property); if (!warn.is_empty()) { - tooltip->set_text(tooltip->get_rich_text()->get_text() + "\n[b][color=" + get_theme_color(SNAME("warning_color")).to_html(false) + "]" + warn + "[/color][/b]"); + String prev_text; + if (tooltip == nullptr) { + tooltip = memnew(EditorHelpBit()); + tooltip->set_text(p_text); + tooltip->get_rich_text()->set_custom_minimum_size(Size2(360 * EDSCALE, 0)); + } else { + prev_text = tooltip->get_rich_text()->get_text() + "\n"; + } + tooltip->set_text(prev_text + "[b][color=" + get_theme_color(SNAME("warning_color")).to_html(false) + "]" + warn + "[/color][/b]"); } } @@ -1148,8 +1160,7 @@ void EditorInspectorCategory::_notification(int p_what) { } Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const { - // Far from perfect solution, as there's nothing that prevents a category from having a name that starts with that. - return p_text.begins_with("class|") ? memnew(EditorHelpTooltip(p_text)) : nullptr; + return doc_class_name.is_empty() ? nullptr : memnew(EditorHelpTooltip(p_text)); } Size2 EditorInspectorCategory::get_minimum_size() const { @@ -3316,6 +3327,7 @@ void EditorInspector::update_tree() { } else { ep->set_tooltip_text("theme_item|" + classname + "|" + theme_item_name + "|"); } + ep->has_doc_tooltip = true; } ep->set_doc_path(doc_path); @@ -3391,11 +3403,16 @@ Object *EditorInspector::get_edited_object() { return object; } +Object *EditorInspector::get_next_edited_object() { + return next_object; +} + void EditorInspector::edit(Object *p_object) { if (object == p_object) { return; } + next_object = p_object; // Some plugins need to know the next edited object when clearing the inspector. if (object) { _clear(); object->disconnect("property_list_changed", callable_mp(this, &EditorInspector::_changed_callback)); @@ -3412,6 +3429,10 @@ void EditorInspector::edit(Object *p_object) { object->connect("property_list_changed", callable_mp(this, &EditorInspector::_changed_callback)); update_tree(); } + + // Keep it available until the end so it works with both main and sub inspectors. + next_object = nullptr; + emit_signal(SNAME("edited_object_changed")); } |
