diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-06-15 10:34:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-15 10:34:22 +0200 |
commit | 0a3c21d999559617cc9cdfe261d631e6d1267374 (patch) | |
tree | aca6cb0c6ef04e3f78fd9ad555cb5e1beeb4238b /scene/gui | |
parent | 63b8c00d555e532f3649639f808f3740eb185df1 (diff) | |
parent | c4e5ee1fd21750431bfa9c5587c9ebf11e4dac77 (diff) |
Merge pull request #29785 from eligt/fix-richtext-alignment
Fix RichTextLabel alignment tags not working properly
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/rich_text_label.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index c6b6d29384..8891f679ee 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -307,6 +307,13 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & switch (it->type) { + case ITEM_ALIGN: { + + ItemAlign *align_it = static_cast<ItemAlign *>(it); + + align = align_it->align; + + } break; case ITEM_TEXT: { ItemText *text = static_cast<ItemText *>(it); @@ -1411,9 +1418,13 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) if (p_enter) current = p_item; - if (p_ensure_newline && current_frame->lines[current_frame->lines.size() - 1].from) { - _invalidate_current_line(current_frame); - current_frame->lines.resize(current_frame->lines.size() + 1); + if (p_ensure_newline) { + Item *from = current_frame->lines[current_frame->lines.size() - 1].from; + // only create a new line for Item types that generate content/layout, ignore those that represent formatting/styling + if (from && from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH) { + _invalidate_current_line(current_frame); + current_frame->lines.resize(current_frame->lines.size() + 1); + } } if (current_frame->lines[current_frame->lines.size() - 1].from == NULL) { |