From f05049fce7a1538bf7936c6402f3c44f509e0c74 Mon Sep 17 00:00:00 2001 From: Malcolm Anderson Date: Wed, 29 Oct 2025 21:48:05 -0700 Subject: [PATCH] Use monospaced font for code names (methods, signals, properties) Add monospace font styling to more items in signal workflow Use monospace font in method and property selection dialogs Use monospaced font in Animation editor Add editor setting Additional fixes and things Add documentation to editor setting # Conflicts: # editor/inspector/property_selector.cpp Update doc/classes/EditorSettings.xml Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> --- doc/classes/EditorSettings.xml | 3 +++ editor/animation/animation_track_editor.cpp | 27 ++++++++++++++++++--- editor/inspector/property_selector.cpp | 17 +++++++++++++ editor/scene/connections_dialog.cpp | 27 +++++++++++++++++++++ editor/script/script_editor_plugin.cpp | 8 ++++++ editor/settings/editor_settings.cpp | 1 + 6 files changed, 79 insertions(+), 4 deletions(-) diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 74fa99210d..8cf014b909 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -1241,6 +1241,9 @@ The editor theme style to use. + + If [code]true[/code], use the monospace font for some labels in the editor that display code symbols, such as signals, properties, and methods. + If [code]true[/code], set accent color based on system settings. [b]Note:[/b] This setting is only effective on Windows, MacOS, and Android. diff --git a/editor/animation/animation_track_editor.cpp b/editor/animation/animation_track_editor.cpp index f984c0e456..7ca1eba875 100644 --- a/editor/animation/animation_track_editor.cpp +++ b/editor/animation/animation_track_editor.cpp @@ -2181,7 +2181,9 @@ void AnimationTrackEdit::_notification(int p_what) { } const Ref font = get_theme_font(SceneStringName(font), SNAME("Label")); + const Ref source_font = get_theme_font(SNAME("source"), EditorStringName(EditorFonts)); const int font_size = get_theme_font_size(SceneStringName(font_size), SNAME("Label")); + const int source_font_size = get_theme_font_size(SNAME("source_size"), EditorStringName(EditorFonts)); const Color color = get_theme_color(SceneStringName(font_color), SNAME("Label")); const Color dc = get_theme_color(SNAME("font_disabled_color"), EditorStringName(Editor)); @@ -2189,6 +2191,9 @@ void AnimationTrackEdit::_notification(int p_what) { // Names and icons. { + Ref font_to_use = font; + int font_size_to_use = font_size; + Ref check = animation->track_is_enabled(track) ? get_theme_icon(SNAME("checked"), SNAME("CheckBox")) : get_theme_icon(SNAME("unchecked"), SNAME("CheckBox")); int ofs = in_group ? outer_margin : 0; @@ -2223,6 +2228,13 @@ void AnimationTrackEdit::_notification(int p_what) { } else { text += anim_path.get_concatenated_subnames(); } + + bool use_monospace_font = EDITOR_GET("interface/theme/use_monospace_font_for_editor_symbols"); + if (animation->track_get_type(track) == Animation::TYPE_VALUE && use_monospace_font) { + font_to_use = source_font; + font_size_to_use = source_font_size; + } + text_color.a *= 0.7; } else if (node) { Ref icon = EditorNode::get_singleton()->get_object_icon(node); @@ -2246,9 +2258,9 @@ void AnimationTrackEdit::_notification(int p_what) { path_rect = Rect2(ofs, 0, limit - ofs - h_separation, get_size().height); - Vector2 string_pos = Point2(ofs, (get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size)); + Vector2 string_pos = Point2(ofs, (get_size().height - font_to_use->get_height(font_size_to_use)) / 2 + font_to_use->get_ascent(font_size_to_use)); string_pos = string_pos.floor(); - draw_string(font, string_pos, text, HORIZONTAL_ALIGNMENT_LEFT, limit - ofs - h_separation, font_size, text_color); + draw_string(font_to_use, string_pos, text, HORIZONTAL_ALIGNMENT_LEFT, limit - ofs - h_separation, font_size_to_use, text_color); draw_line(Point2(limit, 0), Point2(limit, get_size().height), h_line_color, Math::round(EDSCALE)); } @@ -2625,8 +2637,15 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool Vector2 ofs(p_x - icon_to_draw->get_width() / 2, (get_size().height - icon_to_draw->get_height()) / 2); if (animation->track_get_type(track) == Animation::TYPE_METHOD) { - const Ref font = get_theme_font(SceneStringName(font), SNAME("Label")); - const int font_size = get_theme_font_size(SceneStringName(font_size), SNAME("Label")); + bool use_monospace_font = EDITOR_GET("interface/theme/use_monospace_font_for_editor_symbols"); + + Ref font = get_theme_font(SceneStringName(font), SNAME("Label")); + int font_size = get_theme_font_size(SceneStringName(font_size), SNAME("Label")); + if (use_monospace_font) { + font = get_theme_font(SNAME("source"), EditorStringName(EditorFonts)); + font_size = get_theme_font_size(SNAME("source_size"), EditorStringName(EditorFonts)); + } + Color color = get_theme_color(SceneStringName(font_color), SNAME("Label")); color.a = 0.5; diff --git a/editor/inspector/property_selector.cpp b/editor/inspector/property_selector.cpp index 88a49aca91..334dfd04bb 100644 --- a/editor/inspector/property_selector.cpp +++ b/editor/inspector/property_selector.cpp @@ -32,7 +32,9 @@ #include "editor/doc/editor_help.h" #include "editor/editor_node.h" +#include "editor/editor_string_names.h" #include "editor/gui/filter_line_edit.h" +#include "editor/settings/editor_settings.h" #include "editor/themes/editor_scale.h" #include "scene/gui/margin_container.h" #include "scene/gui/tree.h" @@ -58,6 +60,10 @@ void PropertySelector::_update_search() { // Allow using spaces in place of underscores in the search string (makes the search more fault-tolerant). const String search_text = search_box->get_text().replace_char(' ', '_'); + // Set up font. + bool use_monospace_font = EDITOR_GET("interface/theme/use_monospace_font_for_editor_symbols"); + Ref monospace_font = get_theme_font(SNAME("source"), EditorStringName(EditorFonts)); + if (properties) { List props; @@ -120,6 +126,9 @@ void PropertySelector::_update_search() { TreeItem *item = search_options->create_item(category ? category : root); item->set_text(0, E.name); + if (use_monospace_font) { + item->set_custom_font(0, monospace_font); + } item->set_metadata(0, E.name); item->set_icon(0, search_options->get_editor_theme_icon(Variant::get_type_name(E.type))); @@ -281,6 +290,9 @@ void PropertySelector::_update_search() { } item->set_text(0, desc); + if (use_monospace_font) { + item->set_custom_font(0, monospace_font); + } item->set_metadata(0, name); item->set_selectable(0, true); @@ -479,6 +491,11 @@ void PropertySelector::_create_subproperty(TreeItem *p_parent_item, const String TreeItem *item = search_options->create_item(p_parent_item); item->set_text(0, p_name); + + bool use_monospace_font = EDITOR_GET("interface/theme/use_monospace_font_for_editor_symbols"); + if (use_monospace_font) { + item->set_custom_font(0, get_theme_font(SNAME("source"), EditorStringName(EditorFonts))); + } item->set_metadata(0, String(p_parent_item->get_metadata(0)) + ":" + p_name); item->set_icon(0, search_options->get_editor_theme_icon(Variant::get_type_name(p_type))); diff --git a/editor/scene/connections_dialog.cpp b/editor/scene/connections_dialog.cpp index d0083bbe11..63747304ec 100644 --- a/editor/scene/connections_dialog.cpp +++ b/editor/scene/connections_dialog.cpp @@ -296,9 +296,14 @@ StringName ConnectDialog::generate_method_callback_name(Object *p_source, const } void ConnectDialog::_create_method_tree_items(const List &p_methods, TreeItem *p_parent_item) { + bool use_monospace_font = EDITOR_GET("interface/theme/use_monospace_font_for_editor_symbols"); + Ref monospace_font = get_theme_font(SNAME("source"), EditorStringName(EditorFonts)); for (const MethodInfo &mi : p_methods) { TreeItem *method_item = method_tree->create_item(p_parent_item); method_item->set_text(0, get_signature(mi)); + if (use_monospace_font) { + method_item->set_custom_font(0, monospace_font); + } method_item->set_metadata(0, mi.name); } } @@ -518,6 +523,18 @@ void ConnectDialog::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { method_search->set_right_icon(get_editor_theme_icon("Search")); open_method_tree->set_button_icon(get_editor_theme_icon("Edit")); + + bool use_monospace_font = EDITOR_GET("interface/theme/use_monospace_font_for_editor_symbols"); + Ref monospace_font = get_theme_font(SNAME("source"), EditorStringName(EditorFonts)); + + if (use_monospace_font) { + from_signal->add_theme_font_override(SceneStringName(font), monospace_font); + dst_method->add_theme_font_override(SceneStringName(font), monospace_font); + } else { + from_signal->remove_theme_font_override(SceneStringName(font)); + dst_method->remove_theme_font_override(SceneStringName(font)); + } + } break; } } @@ -1534,6 +1551,9 @@ void ConnectionsDock::update_tree() { StringName native_base = selected_object->get_class(); Ref