@@ -878,6 +878,17 @@ int TreeItem::get_custom_minimum_height() const {
878878 return custom_min_height;
879879}
880880
881+ void TreeItem::set_custom_stylebox (int p_column, const Ref<StyleBox> &p_stylebox) {
882+ ERR_FAIL_INDEX (p_column, cells.size ());
883+ cells.write [p_column].custom_stylebox = p_stylebox;
884+ _changed_notify (p_column);
885+ }
886+
887+ Ref<StyleBox> TreeItem::get_custom_stylebox (int p_column) const {
888+ ERR_FAIL_INDEX_V (p_column, cells.size (), Ref<StyleBox>());
889+ return cells[p_column].custom_stylebox ;
890+ }
891+
881892TreeItem *TreeItem::create_child (int p_index) {
882893 TreeItem *ti = memnew (TreeItem (tree));
883894 if (tree) {
@@ -1843,6 +1854,9 @@ void TreeItem::_bind_methods() {
18431854 ClassDB::bind_method (D_METHOD (" set_custom_draw_callback" , " column" , " callback" ), &TreeItem::set_custom_draw_callback);
18441855 ClassDB::bind_method (D_METHOD (" get_custom_draw_callback" , " column" ), &TreeItem::get_custom_draw_callback);
18451856
1857+ ClassDB::bind_method (D_METHOD (" set_custom_stylebox" , " column" , " stylebox" ), &TreeItem::set_custom_stylebox);
1858+ ClassDB::bind_method (D_METHOD (" get_custom_stylebox" , " column" ), &TreeItem::get_custom_stylebox);
1859+
18461860 ClassDB::bind_method (D_METHOD (" set_collapsed" , " enable" ), &TreeItem::set_collapsed);
18471861 ClassDB::bind_method (D_METHOD (" is_collapsed" ), &TreeItem::is_collapsed);
18481862
@@ -2436,6 +2450,16 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
24362450 }
24372451 }
24382452
2453+ if (p_item->cells [i].custom_stylebox .is_valid ()) {
2454+ Rect2 r = cell_rect;
2455+ if (i == 0 ) {
2456+ r.position .x = p_draw_ofs.x ;
2457+ r.size .x = item_width + ofs;
2458+ }
2459+ r = convert_rtl_rect (r);
2460+ draw_style_box (p_item->cells [i].custom_stylebox , r);
2461+ }
2462+
24392463 if (drop_mode_flags && drop_mode_over) {
24402464 Rect2 r = convert_rtl_rect (cell_rect);
24412465 if (drop_mode_over == p_item) {
0 commit comments