|
@@ -693,7 +693,7 @@ void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {
|
|
|
table_need_fit = false;
|
|
|
// Fit slim.
|
|
|
for (int i = 0; i < col_count; i++) {
|
|
|
- if (!p_table->columns[i].expand) {
|
|
|
+ if (!p_table->columns[i].expand || !p_table->columns[i].shrink) {
|
|
|
continue;
|
|
|
}
|
|
|
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
|
|
|
item->align_to_row = p_align_to_row;
|
|
|
for (int i = 0; i < (int)item->columns.size(); i++) {
|
|
|
item->columns[i].expand = false;
|
|
|
+ item->columns[i].shrink = true;
|
|
|
item->columns[i].expand_ratio = 1;
|
|
|
}
|
|
|
_add_item(item, true, false);
|
|
@@ -4038,7 +4039,7 @@ void RichTextLabel::push_context() {
|
|
|
_add_item(item, true);
|
|
|
}
|
|
|
|
|
|
-void RichTextLabel::set_table_column_expand(int p_column, bool p_expand, int p_ratio) {
|
|
|
+void RichTextLabel::set_table_column_expand(int p_column, bool p_expand, int p_ratio, bool p_shrink) {
|
|
|
_stop_thread();
|
|
|
MutexLock data_lock(data_mutex);
|
|
|
|
|
@@ -4047,6 +4048,7 @@ void RichTextLabel::set_table_column_expand(int p_column, bool p_expand, int p_r
|
|
|
ItemTable *table = static_cast<ItemTable *>(current);
|
|
|
ERR_FAIL_INDEX(p_column, (int)table->columns.size());
|
|
|
table->columns[p_column].expand = p_expand;
|
|
|
+ table->columns[p_column].shrink = p_shrink;
|
|
|
table->columns[p_column].expand_ratio = p_ratio;
|
|
|
}
|
|
|
|
|
@@ -4582,13 +4584,19 @@ void RichTextLabel::append_text(const String &p_bbcode) {
|
|
|
pos = brk_end + 1;
|
|
|
tag_stack.push_front("cell");
|
|
|
} else if (tag.begins_with("cell ")) {
|
|
|
+ bool shrink = true;
|
|
|
+ OptionMap::Iterator shrink_option = bbcode_options.find("shrink");
|
|
|
+ if (shrink_option) {
|
|
|
+ shrink = (shrink_option->value == "true");
|
|
|
+ }
|
|
|
+
|
|
|
OptionMap::Iterator expand_option = bbcode_options.find("expand");
|
|
|
if (expand_option) {
|
|
|
int ratio = expand_option->value.to_int();
|
|
|
if (ratio < 1) {
|
|
|
ratio = 1;
|
|
|
}
|
|
|
- set_table_column_expand(get_current_table_column(), true, ratio);
|
|
|
+ set_table_column_expand(get_current_table_column(), true, ratio, shrink);
|
|
|
}
|
|
|
|
|
|
push_cell();
|
|
@@ -6429,7 +6437,7 @@ void RichTextLabel::_bind_methods() {
|
|
|
ClassDB::bind_method(D_METHOD("push_strikethrough"), &RichTextLabel::push_strikethrough);
|
|
|
ClassDB::bind_method(D_METHOD("push_table", "columns", "inline_align", "align_to_row"), &RichTextLabel::push_table, DEFVAL(INLINE_ALIGNMENT_TOP), DEFVAL(-1));
|
|
|
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)));
|
|
|
- ClassDB::bind_method(D_METHOD("set_table_column_expand", "column", "expand", "ratio"), &RichTextLabel::set_table_column_expand, DEFVAL(1));
|
|
|
+ ClassDB::bind_method(D_METHOD("set_table_column_expand", "column", "expand", "ratio", "shrink"), &RichTextLabel::set_table_column_expand, DEFVAL(1), DEFVAL(true));
|
|
|
ClassDB::bind_method(D_METHOD("set_cell_row_background_color", "odd_row_bg", "even_row_bg"), &RichTextLabel::set_cell_row_background_color);
|
|
|
ClassDB::bind_method(D_METHOD("set_cell_border_color", "color"), &RichTextLabel::set_cell_border_color);
|
|
|
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() {
|
|
|
ClassDB::bind_method(D_METHOD("is_menu_visible"), &RichTextLabel::is_menu_visible);
|
|
|
ClassDB::bind_method(D_METHOD("menu_option", "option"), &RichTextLabel::menu_option);
|
|
|
|
|
|
-#ifndef DISABLE_DEPRECATED
|
|
|
- ClassDB::bind_compatibility_method(D_METHOD("push_font", "font", "font_size"), &RichTextLabel::push_font);
|
|
|
- ClassDB::bind_compatibility_method(D_METHOD("set_table_column_expand", "column", "expand", "ratio"), &RichTextLabel::set_table_column_expand);
|
|
|
-#endif // DISABLE_DEPRECATED
|
|
|
-
|
|
|
// Note: set "bbcode_enabled" first, to avoid unnecessary "text" resets.
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bbcode_enabled"), "set_use_bbcode", "is_using_bbcode");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT), "set_text", "get_text");
|