mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
[RTL] Fix size/alignment of tables with padded cells.
This commit is contained in:
parent
594d64ec24
commit
42edbcd748
2 changed files with 11 additions and 0 deletions
|
|
@ -685,6 +685,7 @@ void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {
|
|||
} else {
|
||||
p_table->total_width += p_table->columns[i].width;
|
||||
}
|
||||
p_table->columns[i].width_with_padding = p_table->columns[i].width;
|
||||
}
|
||||
|
||||
// Resize to max_width if needed and distribute the remaining space.
|
||||
|
|
@ -702,6 +703,7 @@ void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {
|
|||
p_table->columns[i].width = p_table->columns[i].max_width;
|
||||
p_table->total_width -= dif;
|
||||
total_ratio -= p_table->columns[i].expand_ratio;
|
||||
p_table->columns[i].width_with_padding = p_table->columns[i].width;
|
||||
}
|
||||
}
|
||||
// Grow.
|
||||
|
|
@ -715,6 +717,7 @@ void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {
|
|||
int incr = MIN(dif, slice);
|
||||
p_table->columns[i].width += incr;
|
||||
p_table->total_width += incr;
|
||||
p_table->columns[i].width_with_padding = p_table->columns[i].width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -745,6 +748,7 @@ void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {
|
|||
|
||||
frame->lines[i].text_buf->set_width(p_table->columns[column].width);
|
||||
p_table->columns[column].width = MAX(p_table->columns[column].width, ceil(frame->lines[i].text_buf->get_size().x));
|
||||
p_table->columns[column].width_with_padding = MAX(p_table->columns[column].width_with_padding, ceil(frame->lines[i].text_buf->get_size().x + frame->padding.position.x + frame->padding.size.x));
|
||||
|
||||
frame->lines[i].offset.y = prev_h;
|
||||
|
||||
|
|
@ -780,6 +784,12 @@ void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {
|
|||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
// Recalculate total width.
|
||||
p_table->total_width = 0;
|
||||
for (int i = 0; i < col_count; i++) {
|
||||
p_table->total_width += p_table->columns[i].width_with_padding + theme_cache.table_h_separation;
|
||||
}
|
||||
}
|
||||
|
||||
int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, float p_vsep, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_shadow_color, int p_shadow_outline_size, const Point2 &p_shadow_ofs, int &r_processed_glyphs) {
|
||||
|
|
|
|||
|
|
@ -347,6 +347,7 @@ private:
|
|||
int min_width = 0;
|
||||
int max_width = 0;
|
||||
int width = 0;
|
||||
int width_with_padding = 0;
|
||||
};
|
||||
|
||||
LocalVector<Column> columns;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue