diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-06-02 18:40:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-02 18:40:58 +0200 |
commit | 4e52b84011b4b3c9edb7646731c3ffe451d26316 (patch) | |
tree | 53a3e0d4923558d3fd70a70119a78db73460b676 /editor | |
parent | 8b06d4275d78debf2bb3d326899648f56abbb492 (diff) | |
parent | d95bc3fa6705af7976e58e21d548c790b8ac4ce7 (diff) |
Merge pull request #49148 from reduz/use-bold-fonts
Use bold fonts in editor
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_fonts.cpp | 7 | ||||
-rw-r--r-- | editor/editor_inspector.cpp | 42 | ||||
-rw-r--r-- | editor/editor_inspector.h | 2 | ||||
-rw-r--r-- | editor/editor_node.cpp | 8 | ||||
-rw-r--r-- | editor/editor_sectioned_inspector.cpp | 3 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 17 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 1 |
7 files changed, 57 insertions, 23 deletions
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 96869ae6fd..8a5142459c 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -313,9 +313,14 @@ void editor_register_fonts(Ref<Theme> p_theme) { p_theme->set_font("bold", "EditorFonts", df_bold); // Title font - p_theme->set_font_size("title_size", "EditorFonts", default_font_size + 2 * EDSCALE); + p_theme->set_font_size("title_size", "EditorFonts", default_font_size + 1 * EDSCALE); p_theme->set_font("title", "EditorFonts", df_bold); + p_theme->set_font_size("main_button_font_size", "EditorFonts", default_font_size + 1 * EDSCALE); + p_theme->set_font("main_button_font", "EditorFonts", df_bold); + + p_theme->set_font("font", "Label", df_bold); + // Documentation fonts MAKE_SOURCE_FONT(df_code); p_theme->set_font_size("doc_size", "EditorFonts", int(EDITOR_GET("text_editor/help/help_font_size")) * EDSCALE); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index f869031446..20abe72750 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1097,9 +1097,12 @@ void EditorInspectorPlugin::_bind_methods() { void EditorInspectorCategory::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - draw_rect(Rect2(Vector2(), get_size()), bg_color); - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<StyleBox> sb = get_theme_stylebox("prop_category_style", "Editor"); + + draw_style_box(sb, Rect2(Vector2(), get_size())); + + Ref<Font> font = get_theme_font("bold", "EditorFonts"); + int font_size = get_theme_font_size("bold_size", "EditorFonts"); int hs = get_theme_constant("hseparation", "Tree"); @@ -1181,8 +1184,9 @@ void EditorInspectorSection::_test_unfold() { void EditorInspectorSection::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font("bold", "EditorFonts"); + int font_size = get_theme_font_size("bold_size", "EditorFonts"); + Ref<Texture2D> arrow; if (foldable) { @@ -1233,15 +1237,19 @@ void EditorInspectorSection::_notification(int p_what) { bool rtl = is_layout_rtl(); if (foldable) { - if (rtl) { - arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree"); + if (object->editor_is_section_unfolded(section)) { + arrow = get_theme_icon("arrow", "Tree"); } else { - arrow = get_theme_icon("arrow_collapsed", "Tree"); + if (is_layout_rtl()) { + arrow = get_theme_icon("arrow_collapsed_mirrored", "Tree"); + } else { + arrow = get_theme_icon("arrow_collapsed", "Tree"); + } } } - Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + Ref<Font> font = get_theme_font("bold", "EditorFonts"); + int font_size = get_theme_font_size("bold_size", "EditorFonts"); int h = font->get_height(font_size); if (arrow.is_valid()) { @@ -1249,12 +1257,15 @@ void EditorInspectorSection::_notification(int p_what) { } h += get_theme_constant("vseparation", "Tree"); - draw_rect(Rect2(Vector2(), Vector2(get_size().width, h)), bg_color); + Color c = bg_color; + c.a *= 0.4; + draw_rect(Rect2(Vector2(), Vector2(get_size().width, h)), c); - const int arrow_margin = 3; - Color color = get_theme_color("font_color", "Tree"); - float text_width = get_size().width - Math::round((16 + arrow_margin) * EDSCALE); - draw_string(font, Point2(rtl ? 0 : Math::round((16 + arrow_margin) * EDSCALE), font->get_ascent(font_size) + (h - font->get_height(font_size)) / 2).floor(), label, rtl ? HALIGN_RIGHT : HALIGN_LEFT, text_width, font_size, color); + const int arrow_margin = 2; + const int arrow_width = arrow.is_valid() ? arrow->get_width() : 0; + Color color = get_theme_color("font_color"); + float text_width = get_size().width - Math::round(arrow_width + arrow_margin * EDSCALE); + draw_string(font, Point2(rtl ? 0 : Math::round(arrow_width + arrow_margin * EDSCALE), font->get_ascent(font_size) + (h - font->get_height(font_size)) / 2).floor(), label, rtl ? HALIGN_RIGHT : HALIGN_LEFT, text_width, font_size, color); if (arrow.is_valid()) { if (rtl) { @@ -1737,7 +1748,6 @@ void EditorInspector::update_tree() { } category->label = type; - category->bg_color = get_theme_color("prop_category", "Editor"); if (use_doc_hints) { StringName type2 = p.name; if (!class_descr_cache.has(type2)) { diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 18250780be..348dea7086 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -208,7 +208,7 @@ class EditorInspectorCategory : public Control { friend class EditorInspector; Ref<Texture2D> icon; String label; - Color bg_color; + mutable String tooltip_text; protected: diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index aa632b90ad..9c77f9d25c 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -707,6 +707,11 @@ void EditorNode::_notification(int p_what) { p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon("Godot", "EditorIcons")); p->set_item_icon(p->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), gui_base->get_theme_icon("Heart", "EditorIcons")); + for (int i = 0; i < main_editor_buttons.size(); i++) { + main_editor_buttons.write[i]->add_theme_font_override("font", gui_base->get_theme_font("main_button_font", "EditorFonts")); + main_editor_buttons.write[i]->add_theme_font_size_override("font_size", gui_base->get_theme_font_size("main_button_font_size", "EditorFonts")); + } + _update_update_spinner(); } break; @@ -3059,6 +3064,9 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), "EditorIcons")); } + tb->add_theme_font_override("font", singleton->gui_base->get_theme_font("main_button_font", "EditorFonts")); + tb->add_theme_font_size_override("font_size", singleton->gui_base->get_theme_font_size("main_button_font_size", "EditorFonts")); + tb->set_name(p_editor->get_name()); singleton->main_editor_buttons.push_back(tb); singleton->main_editor_button_vb->add_child(tb); diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 7532f1c796..6bfb17f9c2 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -250,7 +250,8 @@ void SectionedInspector::update_category_list() { for (int i = 0; i < sc; i++) { TreeItem *parent = section_map[metasection]; - parent->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); + //parent->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); + parent->set_custom_font(0, get_theme_font("bold", "EditorFonts")); if (i > 0) { metasection += "/" + sectionarr[i]; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 7971dfc313..5efb7cdbf2 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -464,7 +464,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Ensure borders are visible when using an editor scale below 100%. const int border_width = CLAMP(border_size, 0, 2) * MAX(1, EDSCALE); - const int corner_width = CLAMP(corner_radius, 0, 6) * EDSCALE; + const int corner_width = CLAMP(corner_radius, 0, 6); const int default_margin_size = 4; const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 2); @@ -785,14 +785,17 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_property_bg->set_bg_color(highlight_color); style_property_bg->set_border_width_all(0); - theme->set_constant("font_offset", "EditorProperty", 1 * EDSCALE); + theme->set_constant("font_offset", "EditorProperty", 8 * EDSCALE); theme->set_stylebox("bg_selected", "EditorProperty", style_property_bg); theme->set_stylebox("bg", "EditorProperty", Ref<StyleBoxEmpty>(memnew(StyleBoxEmpty))); theme->set_constant("vseparation", "EditorProperty", (extra_spacing + default_margin_size) * EDSCALE); theme->set_color("error_color", "EditorProperty", error_color); theme->set_color("property_color", "EditorProperty", property_color); - theme->set_constant("inspector_margin", "Editor", 8 * EDSCALE); + Color inspector_section_color = font_color.lerp(Color(0.5, 0.5, 0.5), 0.35); + theme->set_color("font_color", "EditorInspectorSection", inspector_section_color); + + theme->set_constant("inspector_margin", "Editor", 12 * EDSCALE); // Tree & ItemList background Ref<StyleBoxFlat> style_tree_bg = style_default->duplicate(); @@ -884,6 +887,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("prop_subsection", "Editor", prop_subsection_color); theme->set_color("drop_position_color", "Tree", accent_color); + Ref<StyleBoxFlat> category_bg = style_default->duplicate(); + // Make Trees easier to distinguish from other controls by using a darker background color. + category_bg->set_bg_color(prop_category_color); + category_bg->set_border_color(prop_category_color); + theme->set_stylebox("prop_category_style", "Editor", category_bg); + // ItemList Ref<StyleBoxFlat> style_itemlist_bg = style_default->duplicate(); style_itemlist_bg->set_bg_color(dark_color_1); @@ -941,7 +950,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_content_panel->set_border_color(dark_color_3); style_content_panel->set_border_width_all(border_width); // compensate the border - style_content_panel->set_default_margin(SIDE_TOP, margin_size_extra * EDSCALE); + style_content_panel->set_default_margin(SIDE_TOP, (2 + margin_size_extra) * EDSCALE); style_content_panel->set_default_margin(SIDE_RIGHT, margin_size_extra * EDSCALE); style_content_panel->set_default_margin(SIDE_BOTTOM, margin_size_extra * EDSCALE); style_content_panel->set_default_margin(SIDE_LEFT, margin_size_extra * EDSCALE); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index a21a33a44a..ce98f699ae 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2834,6 +2834,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { button_toggle_display_mode->connect("toggled", callable_mp(this, &FileSystemDock::_toggle_split_mode)); button_toggle_display_mode->set_focus_mode(FOCUS_NONE); button_toggle_display_mode->set_tooltip(TTR("Toggle Split Mode")); + button_toggle_display_mode->set_flat(true); toolbar_hbc->add_child(button_toggle_display_mode); toolbar2_hbc = memnew(HBoxContainer); |