Skip to content

Commit

Permalink
Improve appearance of external links in built-in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mickeon committed Nov 20, 2024
1 parent 9e60984 commit 922cc37
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, const C
const Ref<Font> doc_code_font = p_owner_node->get_theme_font(SNAME("doc_source"), EditorStringName(EditorFonts));
const Ref<Font> 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));

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 922cc37

Please sign in to comment.