@@ -315,6 +315,13 @@ void TreeItem::set_text(int p_column, String p_text) {
315315 cells.write [p_column].max = MAX (cells[p_column].max , value);
316316 }
317317 cells.write [p_column].step = 0 ;
318+ } else {
319+ // Don't auto translate if it's in string mode and editable, as the text can be changed to anything by the user.
320+ if (tree && (!cells[p_column].editable || cells[p_column].mode != TreeItem::CELL_MODE_STRING)) {
321+ cells.write [p_column].xl_text = tree->atr (p_text);
322+ } else {
323+ cells.write [p_column].xl_text = p_text;
324+ }
318325 }
319326
320327 cells.write [p_column].cached_minimum_size_dirty = true ;
@@ -1933,7 +1940,8 @@ void Tree::update_column(int p_col) {
19331940 columns.write [p_col].text_buf ->set_direction ((TextServer::Direction)columns[p_col].text_direction );
19341941 }
19351942
1936- columns.write [p_col].text_buf ->add_string (columns[p_col].title , theme_cache.tb_font , theme_cache.tb_font_size , columns[p_col].language );
1943+ columns.write [p_col].xl_title = atr (columns[p_col].title );
1944+ columns.write [p_col].text_buf ->add_string (columns[p_col].xl_title , theme_cache.tb_font , theme_cache.tb_font_size , columns[p_col].language );
19371945 columns.write [p_col].cached_minimum_width_dirty = true ;
19381946}
19391947
@@ -1957,7 +1965,7 @@ void Tree::update_item_cell(TreeItem *p_item, int p_col) {
19571965 value = strings[j].get_slicec (' :' , 1 ).to_int ();
19581966 }
19591967 if (option == value) {
1960- valtext = strings[j].get_slicec (' :' , 0 );
1968+ valtext = atr ( strings[j].get_slicec (' :' , 0 ) );
19611969 break ;
19621970 }
19631971 }
@@ -1966,11 +1974,21 @@ void Tree::update_item_cell(TreeItem *p_item, int p_col) {
19661974 valtext = String::num (p_item->cells [p_col].val , Math::range_step_decimals (p_item->cells [p_col].step ));
19671975 }
19681976 } else {
1969- valtext = p_item->cells [p_col].text ;
1977+ // Don't auto translate if it's in string mode and editable, as the text can be changed to anything by the user.
1978+ if (!p_item->cells [p_col].editable || p_item->cells [p_col].mode != TreeItem::CELL_MODE_STRING) {
1979+ p_item->cells .write [p_col].xl_text = atr (p_item->cells [p_col].text );
1980+ } else {
1981+ p_item->cells .write [p_col].xl_text = p_item->cells [p_col].text ;
1982+ }
1983+
1984+ valtext = p_item->cells [p_col].xl_text ;
19701985 }
19711986
19721987 if (!p_item->cells [p_col].suffix .is_empty ()) {
1973- valtext += " " + p_item->cells [p_col].suffix ;
1988+ if (!valtext.is_empty ()) {
1989+ valtext += " " ;
1990+ }
1991+ valtext += p_item->cells [p_col].suffix ;
19741992 }
19751993
19761994 if (p_item->cells [p_col].text_direction == Control::TEXT_DIRECTION_INHERITED) {
@@ -2076,7 +2094,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
20762094
20772095 if (p_item->cells [i].expand_right ) {
20782096 int plus = 1 ;
2079- while (i + plus < columns.size () && !p_item->cells [i + plus].editable && p_item->cells [i + plus].mode == TreeItem::CELL_MODE_STRING && p_item->cells [i + plus].text .is_empty () && p_item->cells [i + plus].icon .is_null ()) {
2097+ while (i + plus < columns.size () && !p_item->cells [i + plus].editable && p_item->cells [i + plus].mode == TreeItem::CELL_MODE_STRING && p_item->cells [i + plus].xl_text .is_empty () && p_item->cells [i + plus].icon .is_null ()) {
20802098 item_width += get_column_width (i + plus);
20812099 plus++;
20822100 skip2++;
@@ -4666,7 +4684,7 @@ int Tree::get_column_minimum_width(int p_column) const {
46664684
46674685 // Check if the visible title of the column is wider.
46684686 if (show_column_titles) {
4669- min_width = MAX (theme_cache.font ->get_string_size (columns[p_column].title , HORIZONTAL_ALIGNMENT_LEFT, -1 , theme_cache.font_size ).width + theme_cache.panel_style ->get_margin (SIDE_LEFT) + theme_cache.panel_style ->get_margin (SIDE_RIGHT), min_width);
4687+ min_width = MAX (theme_cache.font ->get_string_size (columns[p_column].xl_title , HORIZONTAL_ALIGNMENT_LEFT, -1 , theme_cache.font_size ).width + theme_cache.panel_style ->get_margin (SIDE_LEFT) + theme_cache.panel_style ->get_margin (SIDE_RIGHT), min_width);
46704688 }
46714689
46724690 if (!columns[p_column].clip_content ) {
@@ -4921,6 +4939,7 @@ void Tree::set_column_title(int p_column, const String &p_title) {
49214939 }
49224940
49234941 columns.write [p_column].title = p_title;
4942+ columns.write [p_column].xl_title = atr (p_title);
49244943 update_column (p_column);
49254944 queue_redraw ();
49264945}
0 commit comments