@@ -693,7 +693,7 @@ void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {
693693 table_need_fit = false ;
694694 // Fit slim.
695695 for (int i = 0 ; i < col_count; i++) {
696- if (!p_table->columns [i].expand ) {
696+ if (!p_table->columns [i].expand || !p_table-> columns [i]. shrink ) {
697697 continue ;
698698 }
699699 int dif = p_table->columns [i].width - p_table->columns [i].max_width ;
@@ -3900,6 +3900,7 @@ void RichTextLabel::push_table(int p_columns, InlineAlignment p_alignment, int p
39003900 item->align_to_row = p_align_to_row;
39013901 for (int i = 0 ; i < (int )item->columns .size (); i++) {
39023902 item->columns [i].expand = false ;
3903+ item->columns [i].shrink = true ;
39033904 item->columns [i].expand_ratio = 1 ;
39043905 }
39053906 _add_item (item, true , false );
@@ -4038,7 +4039,7 @@ void RichTextLabel::push_context() {
40384039 _add_item (item, true );
40394040}
40404041
4041- void RichTextLabel::set_table_column_expand (int p_column, bool p_expand, int p_ratio) {
4042+ void RichTextLabel::set_table_column_expand (int p_column, bool p_expand, int p_ratio, bool p_shrink ) {
40424043 _stop_thread ();
40434044 MutexLock data_lock (data_mutex);
40444045
@@ -4047,6 +4048,7 @@ void RichTextLabel::set_table_column_expand(int p_column, bool p_expand, int p_r
40474048 ItemTable *table = static_cast <ItemTable *>(current);
40484049 ERR_FAIL_INDEX (p_column, (int )table->columns .size ());
40494050 table->columns [p_column].expand = p_expand;
4051+ table->columns [p_column].shrink = p_shrink;
40504052 table->columns [p_column].expand_ratio = p_ratio;
40514053}
40524054
@@ -4582,13 +4584,19 @@ void RichTextLabel::append_text(const String &p_bbcode) {
45824584 pos = brk_end + 1 ;
45834585 tag_stack.push_front (" cell" );
45844586 } else if (tag.begins_with (" cell " )) {
4587+ bool shrink = true ;
4588+ OptionMap::Iterator shrink_option = bbcode_options.find (" shrink" );
4589+ if (shrink_option) {
4590+ shrink = (shrink_option->value == " true" );
4591+ }
4592+
45854593 OptionMap::Iterator expand_option = bbcode_options.find (" expand" );
45864594 if (expand_option) {
45874595 int ratio = expand_option->value .to_int ();
45884596 if (ratio < 1 ) {
45894597 ratio = 1 ;
45904598 }
4591- set_table_column_expand (get_current_table_column (), true , ratio);
4599+ set_table_column_expand (get_current_table_column (), true , ratio, shrink );
45924600 }
45934601
45944602 push_cell ();
@@ -6429,7 +6437,7 @@ void RichTextLabel::_bind_methods() {
64296437 ClassDB::bind_method (D_METHOD (" push_strikethrough" ), &RichTextLabel::push_strikethrough);
64306438 ClassDB::bind_method (D_METHOD (" push_table" , " columns" , " inline_align" , " align_to_row" ), &RichTextLabel::push_table, DEFVAL (INLINE_ALIGNMENT_TOP), DEFVAL (-1 ));
64316439 ClassDB::bind_method (D_METHOD (" push_dropcap" , " string" , " font" , " size" , " dropcap_margins" , " color" , " outline_size" , " outline_color" ), &RichTextLabel::push_dropcap, DEFVAL (Rect2 ()), DEFVAL (Color (1 , 1 , 1 )), DEFVAL (0 ), DEFVAL (Color (0 , 0 , 0 , 0 )));
6432- ClassDB::bind_method (D_METHOD (" set_table_column_expand" , " column" , " expand" , " ratio" ), &RichTextLabel::set_table_column_expand, DEFVAL (1 ));
6440+ ClassDB::bind_method (D_METHOD (" set_table_column_expand" , " column" , " expand" , " ratio" , " shrink " ), &RichTextLabel::set_table_column_expand, DEFVAL (1 ), DEFVAL ( true ));
64336441 ClassDB::bind_method (D_METHOD (" set_cell_row_background_color" , " odd_row_bg" , " even_row_bg" ), &RichTextLabel::set_cell_row_background_color);
64346442 ClassDB::bind_method (D_METHOD (" set_cell_border_color" , " color" ), &RichTextLabel::set_cell_border_color);
64356443 ClassDB::bind_method (D_METHOD (" set_cell_size_override" , " min_size" , " max_size" ), &RichTextLabel::set_cell_size_override);
@@ -6568,11 +6576,6 @@ void RichTextLabel::_bind_methods() {
65686576 ClassDB::bind_method (D_METHOD (" is_menu_visible" ), &RichTextLabel::is_menu_visible);
65696577 ClassDB::bind_method (D_METHOD (" menu_option" , " option" ), &RichTextLabel::menu_option);
65706578
6571- #ifndef DISABLE_DEPRECATED
6572- ClassDB::bind_compatibility_method (D_METHOD (" push_font" , " font" , " font_size" ), &RichTextLabel::push_font);
6573- ClassDB::bind_compatibility_method (D_METHOD (" set_table_column_expand" , " column" , " expand" , " ratio" ), &RichTextLabel::set_table_column_expand);
6574- #endif // DISABLE_DEPRECATED
6575-
65766579 // Note: set "bbcode_enabled" first, to avoid unnecessary "text" resets.
65776580 ADD_PROPERTY (PropertyInfo (Variant::BOOL, " bbcode_enabled" ), " set_use_bbcode" , " is_using_bbcode" );
65786581 ADD_PROPERTY (PropertyInfo (Variant::STRING, " text" , PROPERTY_HINT_MULTILINE_TEXT), " set_text" , " get_text" );
0 commit comments