summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/rich_text_label.cpp74
-rw-r--r--scene/gui/rich_text_label.h8
-rw-r--r--scene/resources/text_line.cpp8
-rw-r--r--scene/resources/text_line.h4
-rw-r--r--scene/resources/text_paragraph.cpp8
-rw-r--r--scene/resources/text_paragraph.h4
6 files changed, 71 insertions, 35 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 3925e0c38e..3cb1f7d2bc 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -2289,7 +2289,7 @@ void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_sub
}
}
-void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color, VAlign p_align) {
+void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color, InlineAlign p_align) {
if (current->type == ITEM_TABLE) {
return;
}
@@ -2534,7 +2534,7 @@ void RichTextLabel::push_meta(const Variant &p_meta) {
_add_item(item, true);
}
-void RichTextLabel::push_table(int p_columns, VAlign p_align) {
+void RichTextLabel::push_table(int p_columns, InlineAlign p_align) {
ERR_FAIL_COND(p_columns < 1);
ItemTable *item = memnew(ItemTable);
@@ -2897,18 +2897,35 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
columns = 1;
}
- VAlign align = VALIGN_TOP;
- if (subtag.size() > 1) {
+ int align = INLINE_ALIGN_TOP;
+ if (subtag.size() > 2) {
if (subtag[1] == "top" || subtag[1] == "t") {
- align = VALIGN_TOP;
+ align = INLINE_ALIGN_TOP_TO;
} else if (subtag[1] == "center" || subtag[1] == "c") {
- align = VALIGN_CENTER;
+ align = INLINE_ALIGN_CENTER_TO;
} else if (subtag[1] == "bottom" || subtag[1] == "b") {
- align = VALIGN_BOTTOM;
+ align = INLINE_ALIGN_BOTTOM_TO;
+ }
+ if (subtag[2] == "top" || subtag[2] == "t") {
+ align |= INLINE_ALIGN_TO_TOP;
+ } else if (subtag[2] == "center" || subtag[2] == "c") {
+ align |= INLINE_ALIGN_TO_CENTER;
+ } else if (subtag[2] == "baseline" || subtag[2] == "l") {
+ align |= INLINE_ALIGN_TO_BASELINE;
+ } else if (subtag[2] == "bottom" || subtag[2] == "b") {
+ align |= INLINE_ALIGN_TO_BOTTOM;
+ }
+ } else if (subtag.size() > 1) {
+ if (subtag[1] == "top" || subtag[1] == "t") {
+ align = INLINE_ALIGN_TOP;
+ } else if (subtag[1] == "center" || subtag[1] == "c") {
+ align = INLINE_ALIGN_CENTER;
+ } else if (subtag[1] == "bottom" || subtag[1] == "b") {
+ align = INLINE_ALIGN_BOTTOM;
}
}
- push_table(columns, align);
+ push_table(columns, (InlineAlign)align);
pos = brk_end + 1;
tag_stack.push_front("table");
} else if (tag == "cell") {
@@ -3187,15 +3204,34 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
pos = end;
tag_stack.push_front(bbcode_name);
} else if (tag.begins_with("img")) {
- VAlign align = VALIGN_TOP;
+ int align = INLINE_ALIGN_CENTER;
if (tag.begins_with("img=")) {
- String al = tag.substr(4, tag.length());
- if (al == "top" || al == "t") {
- align = VALIGN_TOP;
- } else if (al == "center" || al == "c") {
- align = VALIGN_CENTER;
- } else if (al == "bottom" || al == "b") {
- align = VALIGN_BOTTOM;
+ Vector<String> subtag = tag.substr(4, tag.length()).split(",");
+ if (subtag.size() > 1) {
+ if (subtag[0] == "top" || subtag[0] == "t") {
+ align = INLINE_ALIGN_TOP_TO;
+ } else if (subtag[0] == "center" || subtag[0] == "c") {
+ align = INLINE_ALIGN_CENTER_TO;
+ } else if (subtag[0] == "bottom" || subtag[0] == "b") {
+ align = INLINE_ALIGN_BOTTOM_TO;
+ }
+ if (subtag[1] == "top" || subtag[1] == "t") {
+ align |= INLINE_ALIGN_TO_TOP;
+ } else if (subtag[1] == "center" || subtag[1] == "c") {
+ align |= INLINE_ALIGN_TO_CENTER;
+ } else if (subtag[1] == "baseline" || subtag[1] == "l") {
+ align |= INLINE_ALIGN_TO_BASELINE;
+ } else if (subtag[1] == "bottom" || subtag[1] == "b") {
+ align |= INLINE_ALIGN_TO_BOTTOM;
+ }
+ } else if (subtag.size() > 0) {
+ if (subtag[0] == "top" || subtag[0] == "t") {
+ align = INLINE_ALIGN_TOP;
+ } else if (subtag[0] == "center" || subtag[0] == "c") {
+ align = INLINE_ALIGN_CENTER;
+ } else if (subtag[0] == "bottom" || subtag[0] == "b") {
+ align = INLINE_ALIGN_BOTTOM;
+ }
}
}
@@ -3236,7 +3272,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) {
}
}
- add_image(texture, width, height, color, align);
+ add_image(texture, width, height, color, (InlineAlign)align);
}
pos = end;
@@ -3961,7 +3997,7 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text);
ClassDB::bind_method(D_METHOD("add_text", "text"), &RichTextLabel::add_text);
ClassDB::bind_method(D_METHOD("set_text", "text"), &RichTextLabel::set_text);
- ClassDB::bind_method(D_METHOD("add_image", "image", "width", "height", "color", "inline_align"), &RichTextLabel::add_image, DEFVAL(0), DEFVAL(0), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(VALIGN_TOP));
+ ClassDB::bind_method(D_METHOD("add_image", "image", "width", "height", "color", "inline_align"), &RichTextLabel::add_image, DEFVAL(0), DEFVAL(0), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(INLINE_ALIGN_CENTER));
ClassDB::bind_method(D_METHOD("newline"), &RichTextLabel::add_newline);
ClassDB::bind_method(D_METHOD("remove_line", "line"), &RichTextLabel::remove_line);
ClassDB::bind_method(D_METHOD("push_font", "font"), &RichTextLabel::push_font);
@@ -3981,7 +4017,7 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("push_meta", "data"), &RichTextLabel::push_meta);
ClassDB::bind_method(D_METHOD("push_underline"), &RichTextLabel::push_underline);
ClassDB::bind_method(D_METHOD("push_strikethrough"), &RichTextLabel::push_strikethrough);
- ClassDB::bind_method(D_METHOD("push_table", "columns", "inline_align"), &RichTextLabel::push_table, DEFVAL(VALIGN_TOP));
+ ClassDB::bind_method(D_METHOD("push_table", "columns", "inline_align"), &RichTextLabel::push_table, DEFVAL(INLINE_ALIGN_TOP));
ClassDB::bind_method(D_METHOD("push_dropcap", "string", "font", "size", "dropcap_margins", "color", "outline_size", "outline_color"), &RichTextLabel::push_dropcap, DEFVAL(Rect2()), DEFVAL(Color(1, 1, 1)), DEFVAL(0), DEFVAL(Color(0, 0, 0, 0)));
ClassDB::bind_method(D_METHOD("set_table_column_expand", "column", "expand", "ratio"), &RichTextLabel::set_table_column_expand);
ClassDB::bind_method(D_METHOD("set_cell_row_background_color", "odd_row_bg", "even_row_bg"), &RichTextLabel::set_cell_row_background_color);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 999d8b05fd..a73176ba7e 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -161,7 +161,7 @@ private:
struct ItemImage : public Item {
Ref<Texture2D> image;
- VAlign inline_align = VALIGN_TOP;
+ InlineAlign inline_align = INLINE_ALIGN_CENTER;
Size2 size;
Color color;
ItemImage() { type = ITEM_IMAGE; }
@@ -248,7 +248,7 @@ private:
int total_width = 0;
int total_height = 0;
- VAlign inline_align = VALIGN_TOP;
+ InlineAlign inline_align = INLINE_ALIGN_TOP;
ItemTable() { type = ITEM_TABLE; }
};
@@ -463,7 +463,7 @@ private:
public:
String get_text();
void add_text(const String &p_text);
- void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0), VAlign p_align = VALIGN_TOP);
+ void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0, const Color &p_color = Color(1.0, 1.0, 1.0), InlineAlign p_align = INLINE_ALIGN_CENTER);
void add_newline();
bool remove_line(const int p_line);
void push_dropcap(const String &p_string, const Ref<Font> &p_font, int p_size, const Rect2 &p_dropcap_margins = Rect2(), const Color &p_color = Color(1, 1, 1), int p_ol_size = 0, const Color &p_ol_color = Color(0, 0, 0, 0));
@@ -484,7 +484,7 @@ public:
void push_indent(int p_level);
void push_list(int p_level, ListType p_list, bool p_capitalize);
void push_meta(const Variant &p_meta);
- void push_table(int p_columns, VAlign p_align = VALIGN_TOP);
+ void push_table(int p_columns, InlineAlign p_align = INLINE_ALIGN_TOP);
void push_fade(int p_start_index, int p_length);
void push_shake(int p_strength, float p_rate);
void push_wave(float p_frequency, float p_amplitude);
diff --git a/scene/resources/text_line.cpp b/scene/resources/text_line.cpp
index f1eff6e84f..5e60c7c4ed 100644
--- a/scene/resources/text_line.cpp
+++ b/scene/resources/text_line.cpp
@@ -56,8 +56,8 @@ void TextLine::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bidi_override", "override"), &TextLine::_set_bidi_override);
ClassDB::bind_method(D_METHOD("add_string", "text", "fonts", "size", "opentype_features", "language"), &TextLine::add_string, DEFVAL(Dictionary()), DEFVAL(""));
- ClassDB::bind_method(D_METHOD("add_object", "key", "size", "inline_align", "length"), &TextLine::add_object, DEFVAL(VALIGN_CENTER), DEFVAL(1));
- ClassDB::bind_method(D_METHOD("resize_object", "key", "size", "inline_align"), &TextLine::resize_object, DEFVAL(VALIGN_CENTER));
+ ClassDB::bind_method(D_METHOD("add_object", "key", "size", "inline_align", "length"), &TextLine::add_object, DEFVAL(INLINE_ALIGN_CENTER), DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("resize_object", "key", "size", "inline_align"), &TextLine::resize_object, DEFVAL(INLINE_ALIGN_CENTER));
ClassDB::bind_method(D_METHOD("set_width", "width"), &TextLine::set_width);
ClassDB::bind_method(D_METHOD("get_width"), &TextLine::get_width);
@@ -175,13 +175,13 @@ bool TextLine::add_string(const String &p_text, const Ref<Font> &p_fonts, int p_
return res;
}
-bool TextLine::add_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align, int p_length) {
+bool TextLine::add_object(Variant p_key, const Size2 &p_size, InlineAlign p_inline_align, int p_length) {
bool res = TS->shaped_text_add_object(rid, p_key, p_size, p_inline_align, p_length);
dirty = true;
return res;
}
-bool TextLine::resize_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align) {
+bool TextLine::resize_object(Variant p_key, const Size2 &p_size, InlineAlign p_inline_align) {
const_cast<TextLine *>(this)->_shape();
return TS->shaped_text_resize_object(rid, p_key, p_size, p_inline_align);
}
diff --git a/scene/resources/text_line.h b/scene/resources/text_line.h
index 1b5c1a3123..b773bd05be 100644
--- a/scene/resources/text_line.h
+++ b/scene/resources/text_line.h
@@ -76,8 +76,8 @@ public:
bool get_preserve_control() const;
bool add_string(const String &p_text, const Ref<Font> &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "");
- bool add_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align = VALIGN_CENTER, int p_length = 1);
- bool resize_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align = VALIGN_CENTER);
+ bool add_object(Variant p_key, const Size2 &p_size, InlineAlign p_inline_align = INLINE_ALIGN_CENTER, int p_length = 1);
+ bool resize_object(Variant p_key, const Size2 &p_size, InlineAlign p_inline_align = INLINE_ALIGN_CENTER);
void set_align(HAlign p_align);
HAlign get_align() const;
diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp
index 958c94fe31..ffae551570 100644
--- a/scene/resources/text_paragraph.cpp
+++ b/scene/resources/text_paragraph.cpp
@@ -59,8 +59,8 @@ void TextParagraph::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear_dropcap"), &TextParagraph::clear_dropcap);
ClassDB::bind_method(D_METHOD("add_string", "text", "fonts", "size", "opentype_features", "language"), &TextParagraph::add_string, DEFVAL(Dictionary()), DEFVAL(""));
- ClassDB::bind_method(D_METHOD("add_object", "key", "size", "inline_align", "length"), &TextParagraph::add_object, DEFVAL(VALIGN_CENTER), DEFVAL(1));
- ClassDB::bind_method(D_METHOD("resize_object", "key", "size", "inline_align"), &TextParagraph::resize_object, DEFVAL(VALIGN_CENTER));
+ ClassDB::bind_method(D_METHOD("add_object", "key", "size", "inline_align", "length"), &TextParagraph::add_object, DEFVAL(INLINE_ALIGN_CENTER), DEFVAL(1));
+ ClassDB::bind_method(D_METHOD("resize_object", "key", "size", "inline_align"), &TextParagraph::resize_object, DEFVAL(INLINE_ALIGN_CENTER));
ClassDB::bind_method(D_METHOD("set_align", "align"), &TextParagraph::set_align);
ClassDB::bind_method(D_METHOD("get_align"), &TextParagraph::get_align);
@@ -290,13 +290,13 @@ void TextParagraph::set_bidi_override(const Vector<Vector2i> &p_override) {
dirty_lines = true;
}
-bool TextParagraph::add_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align, int p_length) {
+bool TextParagraph::add_object(Variant p_key, const Size2 &p_size, InlineAlign p_inline_align, int p_length) {
bool res = TS->shaped_text_add_object(rid, p_key, p_size, p_inline_align, p_length);
dirty_lines = true;
return res;
}
-bool TextParagraph::resize_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align) {
+bool TextParagraph::resize_object(Variant p_key, const Size2 &p_size, InlineAlign p_inline_align) {
bool res = TS->shaped_text_resize_object(rid, p_key, p_size, p_inline_align);
dirty_lines = true;
return res;
diff --git a/scene/resources/text_paragraph.h b/scene/resources/text_paragraph.h
index a34e745090..d0747a9e03 100644
--- a/scene/resources/text_paragraph.h
+++ b/scene/resources/text_paragraph.h
@@ -86,8 +86,8 @@ public:
void clear_dropcap();
bool add_string(const String &p_text, const Ref<Font> &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "");
- bool add_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align = VALIGN_CENTER, int p_length = 1);
- bool resize_object(Variant p_key, const Size2 &p_size, VAlign p_inline_align = VALIGN_CENTER);
+ bool add_object(Variant p_key, const Size2 &p_size, InlineAlign p_inline_align = INLINE_ALIGN_CENTER, int p_length = 1);
+ bool resize_object(Variant p_key, const Size2 &p_size, InlineAlign p_inline_align = INLINE_ALIGN_CENTER);
void set_align(HAlign p_align);
HAlign get_align() const;