From 922cc37a72d3eec316f059ce1fa67764225b4e4a Mon Sep 17 00:00:00 2001 From: Micky Date: Wed, 20 Nov 2024 20:08:07 +0100 Subject: [PATCH] Improve appearance of external links in built-in docs --- editor/editor_help.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index f0c54b9edd04..38c565becac6 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -2407,6 +2407,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, const C const Ref doc_code_font = p_owner_node->get_theme_font(SNAME("doc_source"), EditorStringName(EditorFonts)); const Ref doc_kbd_font = p_owner_node->get_theme_font(SNAME("doc_keyboard"), EditorStringName(EditorFonts)); + const int doc_font_size = p_owner_node->get_theme_font_size(SNAME("doc_size"), EditorStringName(EditorFonts)); const int doc_code_font_size = p_owner_node->get_theme_font_size(SNAME("doc_source_size"), EditorStringName(EditorFonts)); const int doc_kbd_font_size = p_owner_node->get_theme_font_size(SNAME("doc_keyboard_size"), EditorStringName(EditorFonts)); @@ -2522,6 +2523,12 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, const C if (tag != "/img") { p_rt->pop(); } + if (tag == "/url") { + p_rt->pop(); // hint + p_rt->pop(); // color + p_rt->add_text(" "); + p_rt->add_image(p_owner_node->get_editor_theme_icon(SNAME("ExternalLink")), 0, doc_font_size, link_color); + } } else if (tag.begins_with("method ") || tag.begins_with("constructor ") || tag.begins_with("operator ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ") || tag.begins_with("annotation ") || tag.begins_with("theme_item ")) { const int tag_end = tag.find_char(' '); const String link_tag = tag.left(tag_end); @@ -2793,13 +2800,17 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, const C end = bbcode.length(); } String url = bbcode.substr(brk_end + 1, end - brk_end - 1); - p_rt->push_meta(url); + p_rt->push_color(link_color); + p_rt->push_hint(url + "\n\n" + TTR("Click to open in browser.")); + p_rt->push_meta(url, RichTextLabel::META_UNDERLINE_ON_HOVER); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag.begins_with("url=")) { String url = tag.substr(4); - p_rt->push_meta(url); + p_rt->push_color(link_color); + p_rt->push_hint(url + "\n\n" + TTR("Click to open in browser.")); + p_rt->push_meta(url, RichTextLabel::META_UNDERLINE_ON_HOVER); pos = brk_end + 1; tag_stack.push_front("url");