mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Merge pull request #96735 from bruvzg/rtl_frame_indent
[RTL] Fix indent in tables and tables in indent.
This commit is contained in:
@@ -364,7 +364,8 @@ float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font
|
|||||||
Line &l = p_frame->lines[p_line];
|
Line &l = p_frame->lines[p_line];
|
||||||
MutexLock lock(l.text_buf->get_mutex());
|
MutexLock lock(l.text_buf->get_mutex());
|
||||||
|
|
||||||
l.offset.x = _find_margin(l.from, p_base_font, p_base_font_size) + l.prefix_width;
|
l.indent = _find_margin(l.from, p_base_font, p_base_font_size) + l.prefix_width;
|
||||||
|
l.offset.x = l.indent;
|
||||||
l.text_buf->set_width(p_width - l.offset.x);
|
l.text_buf->set_width(p_width - l.offset.x);
|
||||||
|
|
||||||
PackedFloat32Array tab_stops = _find_tab_stops(l.from);
|
PackedFloat32Array tab_stops = _find_tab_stops(l.from);
|
||||||
@@ -501,7 +502,8 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add indent.
|
// Add indent.
|
||||||
l.offset.x = _find_margin(l.from, p_base_font, p_base_font_size) + l.prefix_width;
|
l.indent = _find_margin(l.from, p_base_font, p_base_font_size) + l.prefix_width;
|
||||||
|
l.offset.x = l.indent;
|
||||||
l.text_buf->set_width(p_width - l.offset.x);
|
l.text_buf->set_width(p_width - l.offset.x);
|
||||||
l.text_buf->set_alignment(_find_alignment(l.from));
|
l.text_buf->set_alignment(_find_alignment(l.from));
|
||||||
l.text_buf->set_direction(_find_direction(l.from));
|
l.text_buf->set_direction(_find_direction(l.from));
|
||||||
@@ -625,8 +627,8 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font>
|
|||||||
t_char_count += cell_ch;
|
t_char_count += cell_ch;
|
||||||
remaining_characters -= cell_ch;
|
remaining_characters -= cell_ch;
|
||||||
|
|
||||||
table->columns[column].min_width = MAX(table->columns[column].min_width, ceil(frame->lines[i].text_buf->get_size().x));
|
table->columns[column].min_width = MAX(table->columns[column].min_width, frame->lines[i].indent + ceil(frame->lines[i].text_buf->get_size().x));
|
||||||
table->columns[column].max_width = MAX(table->columns[column].max_width, ceil(frame->lines[i].text_buf->get_non_wrapped_size().x));
|
table->columns[column].max_width = MAX(table->columns[column].max_width, frame->lines[i].indent + ceil(frame->lines[i].text_buf->get_non_wrapped_size().x));
|
||||||
}
|
}
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
@@ -977,6 +979,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
|
|||||||
|
|
||||||
if (frame->lines.size() != 0 && row < row_count) {
|
if (frame->lines.size() != 0 && row < row_count) {
|
||||||
Vector2 coff = frame->lines[0].offset;
|
Vector2 coff = frame->lines[0].offset;
|
||||||
|
coff.x -= frame->lines[0].indent;
|
||||||
if (rtl) {
|
if (rtl) {
|
||||||
coff.x = rect.size.width - table->columns[col].width - coff.x;
|
coff.x = rect.size.width - table->columns[col].width - coff.x;
|
||||||
}
|
}
|
||||||
@@ -2548,6 +2551,10 @@ int RichTextLabel::_find_margin(Item *p_item, const Ref<Font> &p_base_font, int
|
|||||||
float margin = 0.0;
|
float margin = 0.0;
|
||||||
|
|
||||||
while (item) {
|
while (item) {
|
||||||
|
if (item->type == ITEM_FRAME) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (item->type == ITEM_INDENT) {
|
if (item->type == ITEM_INDENT) {
|
||||||
Ref<Font> font = p_base_font;
|
Ref<Font> font = p_base_font;
|
||||||
int font_size = p_base_font_size;
|
int font_size = p_base_font_size;
|
||||||
@@ -4295,7 +4302,6 @@ void RichTextLabel::append_text(const String &p_bbcode) {
|
|||||||
parsing_bbcode.store(true);
|
parsing_bbcode.store(true);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int indent_level = 0;
|
|
||||||
|
|
||||||
bool in_bold = false;
|
bool in_bold = false;
|
||||||
bool in_italics = false;
|
bool in_italics = false;
|
||||||
@@ -4377,7 +4383,7 @@ void RichTextLabel::append_text(const String &p_bbcode) {
|
|||||||
in_italics = false;
|
in_italics = false;
|
||||||
}
|
}
|
||||||
if ((tag_stack.front()->get() == "indent") || (tag_stack.front()->get() == "ol") || (tag_stack.front()->get() == "ul")) {
|
if ((tag_stack.front()->get() == "indent") || (tag_stack.front()->get() == "ol") || (tag_stack.front()->get() == "ul")) {
|
||||||
indent_level--;
|
current_frame->indent_level--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tag_ok) {
|
if (!tag_ok) {
|
||||||
@@ -4650,44 +4656,44 @@ void RichTextLabel::append_text(const String &p_bbcode) {
|
|||||||
pos = brk_end + 1;
|
pos = brk_end + 1;
|
||||||
tag_stack.push_front(tag);
|
tag_stack.push_front(tag);
|
||||||
} else if (tag == "ul") {
|
} else if (tag == "ul") {
|
||||||
indent_level++;
|
current_frame->indent_level++;
|
||||||
push_list(indent_level, LIST_DOTS, false);
|
push_list(current_frame->indent_level, LIST_DOTS, false);
|
||||||
pos = brk_end + 1;
|
pos = brk_end + 1;
|
||||||
tag_stack.push_front(tag);
|
tag_stack.push_front(tag);
|
||||||
} else if (tag.begins_with("ul bullet=")) {
|
} else if (tag.begins_with("ul bullet=")) {
|
||||||
String bullet = _get_tag_value(tag);
|
String bullet = _get_tag_value(tag);
|
||||||
indent_level++;
|
current_frame->indent_level++;
|
||||||
push_list(indent_level, LIST_DOTS, false, bullet);
|
push_list(current_frame->indent_level, LIST_DOTS, false, bullet);
|
||||||
pos = brk_end + 1;
|
pos = brk_end + 1;
|
||||||
tag_stack.push_front("ul");
|
tag_stack.push_front("ul");
|
||||||
} else if ((tag == "ol") || (tag == "ol type=1")) {
|
} else if ((tag == "ol") || (tag == "ol type=1")) {
|
||||||
indent_level++;
|
current_frame->indent_level++;
|
||||||
push_list(indent_level, LIST_NUMBERS, false);
|
push_list(current_frame->indent_level, LIST_NUMBERS, false);
|
||||||
pos = brk_end + 1;
|
pos = brk_end + 1;
|
||||||
tag_stack.push_front("ol");
|
tag_stack.push_front("ol");
|
||||||
} else if (tag == "ol type=a") {
|
} else if (tag == "ol type=a") {
|
||||||
indent_level++;
|
current_frame->indent_level++;
|
||||||
push_list(indent_level, LIST_LETTERS, false);
|
push_list(current_frame->indent_level, LIST_LETTERS, false);
|
||||||
pos = brk_end + 1;
|
pos = brk_end + 1;
|
||||||
tag_stack.push_front("ol");
|
tag_stack.push_front("ol");
|
||||||
} else if (tag == "ol type=A") {
|
} else if (tag == "ol type=A") {
|
||||||
indent_level++;
|
current_frame->indent_level++;
|
||||||
push_list(indent_level, LIST_LETTERS, true);
|
push_list(current_frame->indent_level, LIST_LETTERS, true);
|
||||||
pos = brk_end + 1;
|
pos = brk_end + 1;
|
||||||
tag_stack.push_front("ol");
|
tag_stack.push_front("ol");
|
||||||
} else if (tag == "ol type=i") {
|
} else if (tag == "ol type=i") {
|
||||||
indent_level++;
|
current_frame->indent_level++;
|
||||||
push_list(indent_level, LIST_ROMAN, false);
|
push_list(current_frame->indent_level, LIST_ROMAN, false);
|
||||||
pos = brk_end + 1;
|
pos = brk_end + 1;
|
||||||
tag_stack.push_front("ol");
|
tag_stack.push_front("ol");
|
||||||
} else if (tag == "ol type=I") {
|
} else if (tag == "ol type=I") {
|
||||||
indent_level++;
|
current_frame->indent_level++;
|
||||||
push_list(indent_level, LIST_ROMAN, true);
|
push_list(current_frame->indent_level, LIST_ROMAN, true);
|
||||||
pos = brk_end + 1;
|
pos = brk_end + 1;
|
||||||
tag_stack.push_front("ol");
|
tag_stack.push_front("ol");
|
||||||
} else if (tag == "indent") {
|
} else if (tag == "indent") {
|
||||||
indent_level++;
|
current_frame->indent_level++;
|
||||||
push_indent(indent_level);
|
push_indent(current_frame->indent_level);
|
||||||
pos = brk_end + 1;
|
pos = brk_end + 1;
|
||||||
tag_stack.push_front(tag);
|
tag_stack.push_front(tag);
|
||||||
} else if (tag.begins_with("lang=")) {
|
} else if (tag.begins_with("lang=")) {
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ private:
|
|||||||
Color dc_ol_color;
|
Color dc_ol_color;
|
||||||
|
|
||||||
Vector2 offset;
|
Vector2 offset;
|
||||||
|
float indent = 0.0;
|
||||||
int char_offset = 0;
|
int char_offset = 0;
|
||||||
int char_count = 0;
|
int char_count = 0;
|
||||||
|
|
||||||
@@ -205,6 +206,7 @@ private:
|
|||||||
Size2 min_size_over = Size2(-1, -1);
|
Size2 min_size_over = Size2(-1, -1);
|
||||||
Size2 max_size_over = Size2(-1, -1);
|
Size2 max_size_over = Size2(-1, -1);
|
||||||
Rect2 padding;
|
Rect2 padding;
|
||||||
|
int indent_level = 0;
|
||||||
|
|
||||||
ItemFrame() {
|
ItemFrame() {
|
||||||
type = ITEM_FRAME;
|
type = ITEM_FRAME;
|
||||||
|
|||||||
Reference in New Issue
Block a user