summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2022-01-28 14:04:33 +0100
committerGitHub <noreply@github.com>2022-01-28 14:04:33 +0100
commit38c6611b91f5ee7ded0c2c1d279ab7dcdc4f2f1c (patch)
treec111d3553f8af807ce59c075ba81ee9c6a4c4a38
parentbb1f55c38741e9b820fc0d3ef9e005cbf8c4c184 (diff)
parenta2f5f7cccf5aa9fce3130c3ab536bb111448b5ee (diff)
Merge pull request #57344 from bruvzg/rtl_fix_tab_offset
-rw-r--r--scene/gui/rich_text_label.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 4d3c8aef33..151ae2f092 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -238,7 +238,8 @@ void RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font>
ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames.
ItemFrame *frame = static_cast<ItemFrame *>(E);
for (int i = 0; i < frame->lines.size(); i++) {
- _resize_line(frame, i, p_base_font, p_base_font_size, 1);
+ int w = _find_margin(frame->lines[i].from, p_base_font, p_base_font_size) + 1;
+ _resize_line(frame, i, p_base_font, p_base_font_size, w);
}
idx++;
}
@@ -254,12 +255,7 @@ void RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font>
for (int i = 0; i < col_count; i++) {
remaining_width -= table->columns[i].min_width;
if (table->columns[i].max_width > table->columns[i].min_width) {
- // If the column can grow, allow it to grow.
table->columns.write[i].expand = true;
- } else {
- // Otherwise make it shrink as much as possible, so that other columns can grow if needs be.
- // We keep the max width as is to spread the remaining space between the columns later.
- table->columns.write[i].min_width = 0;
}
if (table->columns[i].expand) {
total_ratio += table->columns[i].expand_ratio;
@@ -487,7 +483,8 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
int column = idx % col_count;
for (int i = 0; i < frame->lines.size(); i++) {
int char_offset = l.char_offset + l.char_count;
- _shape_line(frame, i, p_base_font, p_base_font_size, 1, &char_offset);
+ int w = _find_margin(frame->lines[i].from, p_base_font, p_base_font_size) + 1;
+ _shape_line(frame, i, p_base_font, p_base_font_size, w, &char_offset);
int cell_ch = (char_offset - (l.char_offset + l.char_count));
l.char_count += cell_ch;
t_char_count += cell_ch;
@@ -507,12 +504,7 @@ void RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
for (int i = 0; i < col_count; i++) {
remaining_width -= table->columns[i].min_width;
if (table->columns[i].max_width > table->columns[i].min_width) {
- // If the column can grow, allow it to grow.
table->columns.write[i].expand = true;
- } else {
- // Otherwise make it shrink as much as possible, so that other columns can grow if needs be.
- // We keep the max width as is to spread the remaining space between the columns later.
- table->columns.write[i].min_width = 0;
}
if (table->columns[i].expand) {
total_ratio += table->columns[i].expand_ratio;