From 503574441e1d9d40da0dc13a50ed9fea5790e218 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:15:20 +0300 Subject: [PATCH] [RTL] Allow setting image alignment as separate bbcode argument. --- scene/gui/rich_text_label.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 26141663c1..a406ea3d89 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -4853,6 +4853,38 @@ void RichTextLabel::append_text(const String &p_bbcode) { height = bbcode_value.substr(sep + 1).to_int(); } } else { + OptionMap::Iterator align_option = bbcode_options.find("align"); + if (align_option) { + Vector subtag = _split_unquoted(align_option->value, U','); + _normalize_subtags(subtag); + + if (subtag.size() > 1) { + if (subtag[0] == "top" || subtag[0] == "t") { + alignment = INLINE_ALIGNMENT_TOP_TO; + } else if (subtag[0] == "center" || subtag[0] == "c") { + alignment = INLINE_ALIGNMENT_CENTER_TO; + } else if (subtag[0] == "bottom" || subtag[0] == "b") { + alignment = INLINE_ALIGNMENT_BOTTOM_TO; + } + if (subtag[1] == "top" || subtag[1] == "t") { + alignment |= INLINE_ALIGNMENT_TO_TOP; + } else if (subtag[1] == "center" || subtag[1] == "c") { + alignment |= INLINE_ALIGNMENT_TO_CENTER; + } else if (subtag[1] == "baseline" || subtag[1] == "l") { + alignment |= INLINE_ALIGNMENT_TO_BASELINE; + } else if (subtag[1] == "bottom" || subtag[1] == "b") { + alignment |= INLINE_ALIGNMENT_TO_BOTTOM; + } + } else if (subtag.size() > 0) { + if (subtag[0] == "top" || subtag[0] == "t") { + alignment = INLINE_ALIGNMENT_TOP; + } else if (subtag[0] == "center" || subtag[0] == "c") { + alignment = INLINE_ALIGNMENT_CENTER; + } else if (subtag[0] == "bottom" || subtag[0] == "b") { + alignment = INLINE_ALIGNMENT_BOTTOM; + } + } + } OptionMap::Iterator width_option = bbcode_options.find("width"); if (width_option) { width = width_option->value.to_int();