summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-01-04 09:07:31 +0100
committerGitHub <noreply@github.com>2018-01-04 09:07:31 +0100
commit59ce1757670ffc6ad5a9091b8def798880a1b1b5 (patch)
tree34321dd83fd0511fc8ddb622351d22ae10b98d04 /scene/gui
parentdbefa06d79237e3a0241d169eaf05fc98c89101a (diff)
parentc6c016e95ad3fffde021b3143dc37cf83ef34f77 (diff)
Merge pull request #15312 from poke1024/fix-rtl-table-wrap
Fixes word wrapping in tables in RichTextLabel
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/rich_text_label.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 4f2cfccd4a..37c7c34432 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -451,6 +451,8 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
table->columns[i].width = 0;
}
//compute minimum width for each cell
+ const int available_width = p_width - hseparation * (table->columns.size() - 1) - wofs;
+
for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) {
ERR_CONTINUE(E->get()->type != ITEM_FRAME); //children should all be frames
ItemFrame *frame = static_cast<ItemFrame *>(E->get());
@@ -461,7 +463,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
for (int i = 0; i < frame->lines.size(); i++) {
- _process_line(frame, Point2(), ly, p_width, i, PROCESS_CACHE, cfont, Color());
+ _process_line(frame, Point2(), ly, available_width, i, PROCESS_CACHE, cfont, Color());
table->columns[column].min_width = MAX(table->columns[column].min_width, frame->lines[i].minimum_width);
}
idx++;
@@ -470,11 +472,11 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
//compute available width and total ratio (for expanders)
int total_ratio = 0;
- int available_width = p_width - hseparation * (table->columns.size() - 1);
+ int remaining_width = available_width;
table->total_width = hseparation;
for (int i = 0; i < table->columns.size(); i++) {
- available_width -= table->columns[i].min_width;
+ remaining_width -= table->columns[i].min_width;
if (table->columns[i].expand)
total_ratio += table->columns[i].expand_ratio;
}
@@ -484,7 +486,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
for (int i = 0; i < table->columns.size(); i++) {
table->columns[i].width = table->columns[i].min_width;
if (table->columns[i].expand)
- table->columns[i].width += table->columns[i].expand_ratio * available_width / total_ratio;
+ table->columns[i].width += table->columns[i].expand_ratio * remaining_width / total_ratio;
table->total_width += table->columns[i].width + hseparation;
}