Use META_UNDERLINE_ON_HOVER in built-in class reference

This commit is contained in:
Micky 2024-03-01 16:40:00 +01:00
parent f28964805e
commit 3a0d056180
1 changed files with 11 additions and 7 deletions

View File

@ -360,7 +360,7 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum, bool p_is
link_t = link_t.trim_suffix("[]"); link_t = link_t.trim_suffix("[]");
display_t = display_t.trim_suffix("[]"); display_t = display_t.trim_suffix("[]");
class_desc->push_meta("#Array"); // class class_desc->push_meta("#Array", RichTextLabel::META_UNDERLINE_ON_HOVER); // class
class_desc->add_text("Array"); class_desc->add_text("Array");
class_desc->pop(); // meta class_desc->pop(); // meta
class_desc->add_text("["); class_desc->add_text("[");
@ -374,9 +374,9 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum, bool p_is
} }
if (is_enum_type) { if (is_enum_type) {
class_desc->push_meta("$" + link_t); // enum class_desc->push_meta("$" + link_t, RichTextLabel::META_UNDERLINE_ON_HOVER); // enum
} else { } else {
class_desc->push_meta("#" + link_t); // class class_desc->push_meta("#" + link_t, RichTextLabel::META_UNDERLINE_ON_HOVER); // class
} }
} }
class_desc->add_text(display_t); class_desc->add_text(display_t);
@ -503,7 +503,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
const bool is_documented = p_method.is_deprecated || p_method.is_experimental || !p_method.description.strip_edges().is_empty(); const bool is_documented = p_method.is_deprecated || p_method.is_experimental || !p_method.description.strip_edges().is_empty();
if (p_overview && is_documented) { if (p_overview && is_documented) {
class_desc->push_meta("@method " + p_method.name); class_desc->push_meta("@method " + p_method.name, RichTextLabel::META_UNDERLINE_ON_HOVER);
} }
class_desc->push_color(theme_cache.headline_color); class_desc->push_color(theme_cache.headline_color);
@ -1210,7 +1210,7 @@ void EditorHelp::_update_doc() {
class_desc->push_color(theme_cache.headline_color); class_desc->push_color(theme_cache.headline_color);
if (describe) { if (describe) {
class_desc->push_meta("@member " + prop.name); class_desc->push_meta("@member " + prop.name, RichTextLabel::META_UNDERLINE_ON_HOVER);
} }
class_desc->add_text(prop.name); class_desc->add_text(prop.name);
@ -2452,12 +2452,16 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control
const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" "); const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" ");
Color target_color = link_color; Color target_color = link_color;
RichTextLabel::MetaUnderline underline_mode = RichTextLabel::META_UNDERLINE_ON_HOVER;
if (link_tag == "method" || link_tag == "constructor" || link_tag == "operator") { if (link_tag == "method" || link_tag == "constructor" || link_tag == "operator") {
target_color = link_method_color; target_color = link_method_color;
} else if (link_tag == "member" || link_tag == "signal" || link_tag == "theme_item") { } else if (link_tag == "member" || link_tag == "signal" || link_tag == "theme_item") {
target_color = link_property_color; target_color = link_property_color;
} else if (link_tag == "annotation") { } else if (link_tag == "annotation") {
target_color = link_annotation_color; target_color = link_annotation_color;
} else {
// Better visibility for constants, enums, etc.
underline_mode = RichTextLabel::META_UNDERLINE_ALWAYS;
} }
// Use monospace font to make clickable references // Use monospace font to make clickable references
@ -2465,7 +2469,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control
p_rt->push_font(doc_code_font); p_rt->push_font(doc_code_font);
p_rt->push_font_size(doc_code_font_size); p_rt->push_font_size(doc_code_font_size);
p_rt->push_color(target_color); p_rt->push_color(target_color);
p_rt->push_meta("@" + link_tag + " " + link_target); p_rt->push_meta("@" + link_tag + " " + link_target, underline_mode);
if (link_tag == "member" && if (link_tag == "member" &&
((!link_target.contains(".") && (p_class == "ProjectSettings" || p_class == "EditorSettings")) || ((!link_target.contains(".") && (p_class == "ProjectSettings" || p_class == "EditorSettings")) ||
@ -2526,7 +2530,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control
p_rt->push_font(doc_code_font); p_rt->push_font(doc_code_font);
p_rt->push_font_size(doc_code_font_size); p_rt->push_font_size(doc_code_font_size);
p_rt->push_color(type_color); p_rt->push_color(type_color);
p_rt->push_meta("#" + tag); p_rt->push_meta("#" + tag, RichTextLabel::META_UNDERLINE_ON_HOVER);
p_rt->add_text(tag); p_rt->add_text(tag);