diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index bc6f3c2bbfe..00bf4b00b5f 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -146,6 +146,7 @@ void EditorHelp::_update_theme_item_cache() { theme_cache.value_color = get_theme_color(SNAME("value_color"), SNAME("EditorHelp")); theme_cache.qualifier_color = get_theme_color(SNAME("qualifier_color"), SNAME("EditorHelp")); theme_cache.type_color = get_theme_color(SNAME("type_color"), SNAME("EditorHelp")); + theme_cache.override_color = get_theme_color(SNAME("override_color"), SNAME("EditorHelp")); theme_cache.doc_font = get_theme_font(SNAME("doc"), EditorStringName(EditorFonts)); theme_cache.doc_bold_font = get_theme_font(SNAME("doc_bold"), EditorStringName(EditorFonts)); @@ -995,11 +996,30 @@ void EditorHelp::_update_doc() { class_desc->push_table(4); class_desc->set_table_column_expand(1, true); + cd.properties.sort_custom(); + + bool is_generating_overridden_properties = true; // Set to false as soon as we encounter a non-overridden property. + bool overridden_property_exists = false; + for (int i = 0; i < cd.properties.size(); i++) { // Ignore undocumented private. if (cd.properties[i].name.begins_with("_") && cd.properties[i].description.strip_edges().is_empty()) { continue; } + if (is_generating_overridden_properties && !cd.properties[i].overridden) { + is_generating_overridden_properties = false; + // No need for the extra spacing when there's no overridden property. + if (overridden_property_exists) { + class_desc->push_cell(); + class_desc->pop(); + class_desc->push_cell(); + class_desc->pop(); + class_desc->push_cell(); + class_desc->pop(); + class_desc->push_cell(); + class_desc->pop(); + } + } property_line[cd.properties[i].name] = class_desc->get_paragraph_count() - 2; //gets overridden if description // Property type. @@ -1054,25 +1074,27 @@ void EditorHelp::_update_doc() { _push_code_font(); if (!cd.properties[i].default_value.is_empty()) { - class_desc->push_color(theme_cache.symbol_color); if (cd.properties[i].overridden) { + class_desc->push_color(theme_cache.override_color); class_desc->add_text(" ["); class_desc->push_meta("@member " + cd.properties[i].overrides + "." + cd.properties[i].name); _add_text(vformat(TTR("overrides %s:"), cd.properties[i].overrides)); class_desc->pop(); - class_desc->add_text(" "); + class_desc->add_text(" " + _fix_constant(cd.properties[i].default_value) + "]"); + overridden_property_exists = true; } else { + class_desc->push_color(theme_cache.symbol_color); class_desc->add_text(" [" + TTR("default:") + " "); + + class_desc->push_color(theme_cache.value_color); + class_desc->add_text(_fix_constant(cd.properties[i].default_value)); + class_desc->pop(); + + class_desc->push_color(theme_cache.symbol_color); + class_desc->add_text("]"); + class_desc->pop(); } - class_desc->pop(); - - class_desc->push_color(theme_cache.value_color); - class_desc->add_text(_fix_constant(cd.properties[i].default_value)); - class_desc->pop(); - - class_desc->push_color(theme_cache.symbol_color); - class_desc->add_text("]"); - class_desc->pop(); + class_desc->pop(); // color } if (cd.properties[i].is_deprecated) { diff --git a/editor/editor_help.h b/editor/editor_help.h index 896f0adf434..e788350e76b 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -134,6 +134,7 @@ class EditorHelp : public VBoxContainer { Color value_color; Color qualifier_color; Color type_color; + Color override_color; Ref doc_font; Ref doc_bold_font; @@ -198,6 +199,16 @@ class EditorHelp : public VBoxContainer { static void _gen_extensions_docs(); static void _compute_doc_version_hash(); + struct PropertyCompare { + _FORCE_INLINE_ bool operator()(const DocData::PropertyDoc &p_l, const DocData::PropertyDoc &p_r) const { + // Sort overridden properties above all else. + if (p_l.overridden == p_r.overridden) { + return p_l.name.naturalcasecmp_to(p_r.name) < 0; + } + return p_l.overridden; + } + }; + protected: virtual void _update_theme_item_cache() override; diff --git a/editor/themes/editor_theme_manager.cpp b/editor/themes/editor_theme_manager.cpp index d89bbb72232..479a3ebc87c 100644 --- a/editor/themes/editor_theme_manager.cpp +++ b/editor/themes/editor_theme_manager.cpp @@ -2006,6 +2006,7 @@ void EditorThemeManager::_populate_editor_styles(const Ref &p_theme p_theme->set_color("value_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6)); p_theme->set_color("qualifier_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.8)); p_theme->set_color("type_color", "EditorHelp", p_config.accent_color.lerp(p_config.font_color, 0.5)); + p_theme->set_color("override_color", "EditorHelp", p_config.warning_color); p_theme->set_color("selection_color", "EditorHelp", p_config.selection_color); p_theme->set_color("link_color", "EditorHelp", p_config.accent_color.lerp(p_config.mono_color, 0.8)); p_theme->set_color("code_color", "EditorHelp", p_config.accent_color.lerp(p_config.mono_color, 0.6));