From 07868760770336900ee2c275851945219205b866 Mon Sep 17 00:00:00 2001 From: MewPurPur Date: Sat, 24 Jun 2023 18:09:31 +0200 Subject: [PATCH] Tweak documentation to use bold font when a class is referencing itself --- editor/editor_help.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 991807ccbb8..480e41b72b0 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1906,7 +1906,7 @@ void EditorHelp::_help_callback(const String &p_topic) { } } -static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control *p_owner_node) { +static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control *p_owner_node, const String &p_class = "") { DocTools *doc = EditorHelp::get_doc_data(); String base_path; @@ -2107,21 +2107,28 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control p_rt->pop(); // font pos = brk_end + 1; + } else if (tag == p_class) { + // Use a bold font when class reference tags are in their own page. + p_rt->push_font(doc_bold_font); + p_rt->add_text(tag); + p_rt->pop(); + + pos = brk_end + 1; + } else if (doc->class_list.has(tag)) { - // Class reference tag such as [Node2D] or [SceneTree]. - // Use monospace font to make clickable references - // easier to distinguish from inline code and other text. + // Use a monospace font for class reference tags such as [Node2D] or [SceneTree]. + p_rt->push_font(doc_code_font); p_rt->push_font_size(doc_code_font_size); - p_rt->push_color(type_color); p_rt->push_meta("#" + tag); p_rt->add_text(tag); - p_rt->pop(); - p_rt->pop(); - p_rt->pop(); // font size - p_rt->pop(); // font + p_rt->pop(); + p_rt->pop(); + p_rt->pop(); // Font size + p_rt->pop(); // Font + pos = brk_end + 1; } else if (tag == "b") { @@ -2252,7 +2259,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control } void EditorHelp::_add_text(const String &p_bbcode) { - _add_text_to_rt(p_bbcode, class_desc, this); + _add_text_to_rt(p_bbcode, class_desc, this, edited_class); } Thread EditorHelp::thread;