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

Add a [kbd] tag for highlighting keyboard shortcuts in the editor help

This allows backporting documentation from the `master` branch more easily,
as it already features the `[kbd]` tag.

Co-authored-by: Yuri Sizov <11782833+YuriSizov@users.noreply.github.com>
This commit is contained in:
Hugo Locurcio
2022-08-25 19:51:43 +02:00
parent 03940b77a2
commit ed380cc0fa
13 changed files with 59 additions and 37 deletions

View File

@@ -1282,11 +1282,14 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts");
Ref<Font> doc_bold_font = p_rt->get_font("doc_bold", "EditorFonts");
Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts");
Ref<Font> doc_kbd_font = p_rt->get_font("doc_keyboard", "EditorFonts");
Color font_color_hl = p_rt->get_color("headline_color", "EditorHelp");
Color accent_color = p_rt->get_color("accent_color", "Editor");
Color property_color = p_rt->get_color("property_color", "Editor");
Color link_color = accent_color.linear_interpolate(font_color_hl, 0.8);
Color code_color = accent_color.linear_interpolate(font_color_hl, 0.6);
Color kbd_color = accent_color.linear_interpolate(property_color, 0.6);
String bbcode = p_bbcode.dedent().replace("\t", "").replace("\r", "").strip_edges();
@@ -1396,6 +1399,13 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
code_tag = true;
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "kbd") {
// Use keyboard font with custom color.
p_rt->push_font(doc_kbd_font);
p_rt->push_color(kbd_color);
code_tag = true; // Though not strictly a code tag, logic is similar.
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "center") {
// Align to center.
p_rt->push_align(RichTextLabel::ALIGN_CENTER);