From d95bc3fa6705af7976e58e21d548c790b8ac4ce7 Mon Sep 17 00:00:00 2001 From: reduz Date: Thu, 27 May 2021 12:32:30 -0300 Subject: Use bold fonts in editor * Labels are now bold * Categories in trees are bold * Main editor buttons are bold * Fixed section folding arrows in inspector --- scene/gui/tree.cpp | 24 ++++++++++++++++++++++-- scene/gui/tree.h | 5 +++++ 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 50e7ba97bc..f66cc13af5 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -870,6 +870,15 @@ void TreeItem::clear_custom_color(int p_column) { _changed_notify(p_column); } +void TreeItem::set_custom_font(int p_column, const Ref &p_font) { + ERR_FAIL_INDEX(p_column, cells.size()); + cells.write[p_column].custom_font = p_font; +} +Ref TreeItem::get_custom_font(int p_column) const { + ERR_FAIL_INDEX_V(p_column, cells.size(), Ref()); + return cells[p_column].custom_font; +} + void TreeItem::set_tooltip(int p_column, const String &p_tooltip) { ERR_FAIL_INDEX(p_column, cells.size()); cells.write[p_column].tooltip = p_tooltip; @@ -1050,8 +1059,11 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("is_editable", "column"), &TreeItem::is_editable); ClassDB::bind_method(D_METHOD("set_custom_color", "column", "color"), &TreeItem::set_custom_color); - ClassDB::bind_method(D_METHOD("clear_custom_color", "column"), &TreeItem::clear_custom_color); ClassDB::bind_method(D_METHOD("get_custom_color", "column"), &TreeItem::get_custom_color); + ClassDB::bind_method(D_METHOD("clear_custom_color", "column"), &TreeItem::clear_custom_color); + + ClassDB::bind_method(D_METHOD("set_custom_font", "column", "font"), &TreeItem::set_custom_font); + ClassDB::bind_method(D_METHOD("get_custom_font", "column"), &TreeItem::get_custom_font); ClassDB::bind_method(D_METHOD("set_custom_bg_color", "column", "color", "just_outline"), &TreeItem::set_custom_bg_color, DEFVAL(false)); ClassDB::bind_method(D_METHOD("clear_custom_bg_color", "column"), &TreeItem::clear_custom_bg_color); @@ -1372,6 +1384,7 @@ void Tree::update_column(int p_col) { } else { columns.write[p_col].text_buf->set_direction((TextServer::Direction)columns[p_col].text_direction); } + columns.write[p_col].text_buf->add_string(columns[p_col].title, cache.font, cache.font_size, columns[p_col].opentype_features, (columns[p_col].language != "") ? columns[p_col].language : TranslationServer::get_singleton()->get_tool_locale()); } @@ -1416,7 +1429,14 @@ void Tree::update_item_cell(TreeItem *p_item, int p_col) { } else { p_item->cells.write[p_col].text_buf->set_direction((TextServer::Direction)p_item->cells[p_col].text_direction); } - p_item->cells.write[p_col].text_buf->add_string(valtext, cache.font, cache.font_size, p_item->cells[p_col].opentype_features, (p_item->cells[p_col].language != "") ? p_item->cells[p_col].language : TranslationServer::get_singleton()->get_tool_locale()); + + Ref font; + if (p_item->cells[p_col].custom_font.is_valid()) { + font = p_item->cells[p_col].custom_font; + } else { + font = cache.font; + } + p_item->cells.write[p_col].text_buf->add_string(valtext, font, cache.font_size, p_item->cells[p_col].opentype_features, (p_item->cells[p_col].language != "") ? p_item->cells[p_col].language : TranslationServer::get_singleton()->get_tool_locale()); TS->shaped_text_set_bidi_override(p_item->cells[p_col].text_buf->get_rid(), structured_text_parser(p_item->cells[p_col].st_parser, p_item->cells[p_col].st_args, valtext)); p_item->cells.write[p_col].dirty = false; } diff --git a/scene/gui/tree.h b/scene/gui/tree.h index c0948f1b80..5176d01497 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -112,6 +112,8 @@ private: Vector