1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-19 14:31:59 +00:00

Editor: Fix some issues with EditorHelpTooltip

This commit is contained in:
Danil Alexeev
2023-10-10 11:30:36 +03:00
parent b931a6e5ce
commit f56532c577
3 changed files with 25 additions and 7 deletions

View File

@@ -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);