mirror of
https://github.com/godotengine/godot.git
synced 2024-12-21 10:25:24 +08:00
Improve appearance of external links in built-in docs
This commit is contained in:
parent
d741a646a5
commit
b22bb4d75f
@ -2403,6 +2403,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));
|
||||
|
||||
@ -2515,7 +2516,14 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, const C
|
||||
|
||||
tag_stack.pop_front();
|
||||
pos = brk_end + 1;
|
||||
if (tag != "/img") {
|
||||
if (tag == "/img") {
|
||||
// Nothing to do.
|
||||
} else if (tag == "/url") {
|
||||
p_rt->pop(); // meta
|
||||
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 {
|
||||
p_rt->pop();
|
||||
}
|
||||
} 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 ")) {
|
||||
@ -2783,19 +2791,20 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, const C
|
||||
} else if (tag == "rb") {
|
||||
p_rt->add_text("]");
|
||||
pos = brk_end + 1;
|
||||
} else if (tag == "url") {
|
||||
int end = bbcode.find_char('[', brk_end);
|
||||
if (end == -1) {
|
||||
end = bbcode.length();
|
||||
} else if (tag == "url" || tag.begins_with("url=")) {
|
||||
String url;
|
||||
if (tag.begins_with("url=")) {
|
||||
url = tag.substr(4);
|
||||
} else {
|
||||
int end = bbcode.find_char('[', brk_end);
|
||||
if (end == -1) {
|
||||
end = bbcode.length();
|
||||
}
|
||||
url = bbcode.substr(brk_end + 1, end - brk_end - 1);
|
||||
}
|
||||
String url = bbcode.substr(brk_end + 1, end - brk_end - 1);
|
||||
p_rt->push_meta(url);
|
||||
|
||||
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_meta(url, RichTextLabel::META_UNDERLINE_ON_HOVER, url + "\n\n" + TTR("Click to open in browser."));
|
||||
|
||||
pos = brk_end + 1;
|
||||
tag_stack.push_front("url");
|
||||
|
Loading…
Reference in New Issue
Block a user