Merge pull request #15312 from poke1024/fix-rtl-table-wrap
Fixes word wrapping in tables in RichTextLabel
This commit is contained in:
commit
59ce175767
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue