diff options
Diffstat (limited to 'scene/gui/tree.cpp')
-rw-r--r-- | scene/gui/tree.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
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<Font> &p_font) { + ERR_FAIL_INDEX(p_column, cells.size()); + cells.write[p_column].custom_font = p_font; +} +Ref<Font> TreeItem::get_custom_font(int p_column) const { + ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Font>()); + 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> 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; } |