Merge pull request #93140 from bruvzg/rtl_table_bg_sep
[RTL] Fix table h/v separation alignment.
This commit is contained in:
commit
39ab252ba1
|
@ -724,7 +724,7 @@ void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {
|
|||
p_table->rows.clear();
|
||||
p_table->rows_baseline.clear();
|
||||
|
||||
Vector2 offset;
|
||||
Vector2 offset = Vector2(theme_cache.table_h_separation * 0.5, theme_cache.table_v_separation * 0.5).floor();
|
||||
float row_height = 0.0;
|
||||
|
||||
for (const List<Item *>::Element *E = p_table->subitems.front(); E; E = E->next()) {
|
||||
|
@ -767,12 +767,12 @@ void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {
|
|||
row_height = MAX(yofs, row_height);
|
||||
// Add row height after last column of the row or last cell of the table.
|
||||
if (column == col_count - 1 || E->next() == nullptr) {
|
||||
offset.x = 0;
|
||||
offset.x = Math::floor(theme_cache.table_h_separation * 0.5);
|
||||
row_height += theme_cache.table_v_separation;
|
||||
p_table->total_height += row_height;
|
||||
offset.y += row_height;
|
||||
p_table->rows.push_back(row_height);
|
||||
p_table->rows_baseline.push_back(p_table->total_height - row_height + row_baseline);
|
||||
p_table->rows_baseline.push_back(p_table->total_height - row_height + row_baseline + Math::floor(theme_cache.table_v_separation * 0.5));
|
||||
row_height = 0;
|
||||
}
|
||||
idx++;
|
||||
|
@ -942,7 +942,8 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
|
|||
Color odd_row_bg = theme_cache.table_odd_row_bg;
|
||||
Color even_row_bg = theme_cache.table_even_row_bg;
|
||||
Color border = theme_cache.table_border;
|
||||
int h_separation = theme_cache.table_h_separation;
|
||||
float h_separation = theme_cache.table_h_separation;
|
||||
float v_separation = theme_cache.table_v_separation;
|
||||
|
||||
int col_count = table->columns.size();
|
||||
int row_count = table->rows.size();
|
||||
|
@ -962,17 +963,17 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
|
|||
if (row % 2 == 0) {
|
||||
Color c = frame->odd_row_bg != Color(0, 0, 0, 0) ? frame->odd_row_bg : odd_row_bg;
|
||||
if (c.a > 0.0) {
|
||||
draw_rect(Rect2(p_ofs + rect.position + off + coff - frame->padding.position, Size2(table->columns[col].width + h_separation + frame->padding.position.x + frame->padding.size.x, table->rows[row])), c, true);
|
||||
draw_rect(Rect2(p_ofs + rect.position + off + coff - frame->padding.position - Vector2(h_separation * 0.5, v_separation * 0.5).floor(), Size2(table->columns[col].width + h_separation + frame->padding.position.x + frame->padding.size.x, table->rows[row])), c, true);
|
||||
}
|
||||
} else {
|
||||
Color c = frame->even_row_bg != Color(0, 0, 0, 0) ? frame->even_row_bg : even_row_bg;
|
||||
if (c.a > 0.0) {
|
||||
draw_rect(Rect2(p_ofs + rect.position + off + coff - frame->padding.position, Size2(table->columns[col].width + h_separation + frame->padding.position.x + frame->padding.size.x, table->rows[row])), c, true);
|
||||
draw_rect(Rect2(p_ofs + rect.position + off + coff - frame->padding.position - Vector2(h_separation * 0.5, v_separation * 0.5).floor(), Size2(table->columns[col].width + h_separation + frame->padding.position.x + frame->padding.size.x, table->rows[row])), c, true);
|
||||
}
|
||||
}
|
||||
Color bc = frame->border != Color(0, 0, 0, 0) ? frame->border : border;
|
||||
if (bc.a > 0.0) {
|
||||
draw_rect(Rect2(p_ofs + rect.position + off + coff - frame->padding.position, Size2(table->columns[col].width + h_separation + frame->padding.position.x + frame->padding.size.x, table->rows[row])), bc, false);
|
||||
draw_rect(Rect2(p_ofs + rect.position + off + coff - frame->padding.position - Vector2(h_separation * 0.5, v_separation * 0.5).floor(), Size2(table->columns[col].width + h_separation + frame->padding.position.x + frame->padding.size.x, table->rows[row])), bc, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1534,7 +1535,7 @@ float RichTextLabel::_find_click_in_line(ItemFrame *p_frame, int p_line, const V
|
|||
if (rtl) {
|
||||
coff.x = rect.size.width - table->columns[col].width - coff.x;
|
||||
}
|
||||
Rect2 crect = Rect2(rect.position + coff - frame->padding.position, Size2(table->columns[col].width + theme_cache.table_h_separation, table->rows[row] + theme_cache.table_v_separation) + frame->padding.position + frame->padding.size);
|
||||
Rect2 crect = Rect2(rect.position + coff - frame->padding.position - Vector2(theme_cache.table_h_separation * 0.5, theme_cache.table_h_separation * 0.5).floor(), Size2(table->columns[col].width + theme_cache.table_h_separation, table->rows[row] + theme_cache.table_v_separation) + frame->padding.position + frame->padding.size);
|
||||
if (col == col_count - 1) {
|
||||
if (rtl) {
|
||||
crect.size.x = crect.position.x + crect.size.x;
|
||||
|
|
Loading…
Reference in New Issue