Skip to content

Commit a262747

Browse files
committed
[RTL] Decouple image width/height "in percent" properties. Add [hr] tag support.
1 parent fc523ec commit a262747

File tree

6 files changed

+181
-24
lines changed

6 files changed

+181
-24
lines changed

doc/classes/RichTextLabel.xml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@
1717
<link title="Operating System Testing Demo">https://godotengine.org/asset-library/asset/2789</link>
1818
</tutorials>
1919
<methods>
20+
<method name="add_hr">
21+
<return type="void" />
22+
<param index="0" name="width" type="int" default="90" />
23+
<param index="1" name="height" type="int" default="2" />
24+
<param index="2" name="color" type="Color" default="Color(1, 1, 1, 1)" />
25+
<param index="3" name="alignment" type="int" enum="HorizontalAlignment" default="1" />
26+
<param index="4" name="width_in_percent" type="bool" default="true" />
27+
<param index="5" name="height_in_percent" type="bool" default="false" />
28+
<description>
29+
Adds a horizontal rule that can be used to separate content.
30+
If [param width_in_percent] is set, [param width] values are percentages of the control width instead of pixels.
31+
If [param height_in_percent] is set, [param height] values are percentages of the control width instead of pixels.
32+
</description>
33+
</method>
2034
<method name="add_image">
2135
<return type="void" />
2236
<param index="0" name="image" type="Texture2D" />
@@ -28,15 +42,17 @@
2842
<param index="6" name="key" type="Variant" default="null" />
2943
<param index="7" name="pad" type="bool" default="false" />
3044
<param index="8" name="tooltip" type="String" default="&quot;&quot;" />
31-
<param index="9" name="size_in_percent" type="bool" default="false" />
32-
<param index="10" name="alt_text" type="String" default="&quot;&quot;" />
45+
<param index="9" name="width_in_percent" type="bool" default="false" />
46+
<param index="10" name="height_in_percent" type="bool" default="false" />
47+
<param index="11" name="alt_text" type="String" default="&quot;&quot;" />
3348
<description>
3449
Adds an image's opening and closing tags to the tag stack, optionally providing a [param width] and [param height] to resize the image, a [param color] to tint the image and a [param region] to only use parts of the image.
3550
If [param width] or [param height] is set to 0, the image size will be adjusted in order to keep the original aspect ratio.
3651
If [param width] and [param height] are not set, but [param region] is, the region's rect will be used.
3752
[param key] is an optional identifier, that can be used to modify the image via [method update_image].
3853
If [param pad] is set, and the image is smaller than the size specified by [param width] and [param height], the image padding is added to match the size instead of upscaling.
39-
If [param size_in_percent] is set, [param width] and [param height] values are percentages of the control width instead of pixels.
54+
If [param width_in_percent] is set, [param width] values are percentages of the control width instead of pixels.
55+
If [param height_in_percent] is set, [param height] values are percentages of the control width instead of pixels.
4056
[param alt_text] is used as the image description for assistive apps.
4157
</description>
4258
</method>
@@ -655,7 +671,8 @@
655671
<param index="7" name="region" type="Rect2" default="Rect2(0, 0, 0, 0)" />
656672
<param index="8" name="pad" type="bool" default="false" />
657673
<param index="9" name="tooltip" type="String" default="&quot;&quot;" />
658-
<param index="10" name="size_in_percent" type="bool" default="false" />
674+
<param index="10" name="width_in_percent" type="bool" default="false" />
675+
<param index="11" name="height_in_percent" type="bool" default="false" />
659676
<description>
660677
Updates the existing images with the key [param key]. Only properties specified by [param mask] bits are updated. See [method add_image].
661678
</description>
@@ -939,6 +956,9 @@
939956
<theme_item name="normal_font_size" data_type="font_size" type="int">
940957
The default text font size.
941958
</theme_item>
959+
<theme_item name="horizontal_rule" data_type="icon" type="Texture2D">
960+
The horizontal rule texture.
961+
</theme_item>
942962
<theme_item name="focus" data_type="style" type="StyleBox">
943963
The background used when the [RichTextLabel] is focused. The [theme_item focus] [StyleBox] is displayed [i]over[/i] the base [StyleBox], so a partially transparent [StyleBox] should be used to ensure the base [StyleBox] remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
944964
</theme_item>

misc/extension_api_validation/4.4-stable.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,12 @@ Validate extension JSON: Error: Field 'classes/GLTFBufferView/methods/set_byte_o
312312
Validate extension JSON: Error: Field 'classes/GLTFBufferView/methods/set_byte_stride/arguments/0': meta changed value in new API, from "int32" to "int64".
313313

314314
GLTFBufferView and GLTFAccessor now use int64 for offsets and lengths. Compatibility methods registered.
315+
316+
317+
GH-107347
318+
---------
319+
Validate extension JSON: Error: Field 'classes/RichTextLabel/methods/add_image/arguments': size changed value in new API, from 6 to 12.
320+
Validate extension JSON: Error: Field 'classes/RichTextLabel/methods/add_image/arguments': size changed value in new API, from 10 to 12.
321+
Validate extension JSON: Error: Field 'classes/RichTextLabel/methods/update_image/arguments': size changed value in new API, from 11 to 12.
322+
323+
Optional argument added. Compatibility methods registered.

scene/gui/rich_text_label.compat.inc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ void RichTextLabel::_push_meta_bind_compat_89024(const Variant &p_meta) {
5151
}
5252

5353
void RichTextLabel::_add_image_bind_compat_80410(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color, InlineAlignment p_alignment, const Rect2 &p_region) {
54-
add_image(p_image, p_width, p_height, p_color, p_alignment, p_region, Variant(), false, String(), false, String());
54+
add_image(p_image, p_width, p_height, p_color, p_alignment, p_region, Variant(), false, String(), false, false, String());
5555
}
5656

5757
void RichTextLabel::_add_image_bind_compat_76829(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color, InlineAlignment p_alignment, const Rect2 &p_region, const Variant &p_key, bool p_pad, const String &p_tooltip, bool p_size_in_percent) {
58-
add_image(p_image, p_width, p_height, p_color, p_alignment, p_region, p_key, p_pad, p_tooltip, p_size_in_percent, String());
58+
add_image(p_image, p_width, p_height, p_color, p_alignment, p_region, p_key, p_pad, p_tooltip, p_size_in_percent, p_size_in_percent, String());
5959
}
6060

6161
void RichTextLabel::_push_table_bind_compat_76829(int p_columns, InlineAlignment p_alignment, int p_align_to_row) {
@@ -74,6 +74,14 @@ void RichTextLabel::_push_strikethrough_bind_compat_106300() {
7474
push_strikethrough(Color(0, 0, 0, 0));
7575
}
7676

77+
void RichTextLabel::_add_image_bind_compat_107347(const Ref<Texture2D> &p_image, int p_width, int p_height, const Color &p_color, InlineAlignment p_alignment, const Rect2 &p_region, const Variant &p_key, bool p_pad, const String &p_tooltip, bool p_size_in_percent, const String &p_alt_text) {
78+
add_image(p_image, p_width, p_height, p_color, p_alignment, p_region, p_key, p_pad, p_tooltip, p_size_in_percent, p_size_in_percent, p_alt_text);
79+
}
80+
81+
void RichTextLabel::_update_image_bind_compat_107347(const Variant &p_key, BitField<ImageUpdateMask> p_mask, const Ref<Texture2D> &p_image, int p_width, int p_height, const Color &p_color, InlineAlignment p_alignment, const Rect2 &p_region, bool p_pad, const String &p_tooltip, bool p_size_in_percent) {
82+
update_image(p_key, p_mask, p_image, p_width, p_height, p_color, p_alignment, p_region, p_pad, p_tooltip, p_size_in_percent, p_size_in_percent);
83+
}
84+
7785
void RichTextLabel::_bind_compatibility_methods() {
7886
ClassDB::bind_compatibility_method(D_METHOD("push_font", "font", "font_size"), &RichTextLabel::_push_font_bind_compat_79053);
7987
ClassDB::bind_compatibility_method(D_METHOD("set_table_column_expand", "column", "expand", "ratio"), &RichTextLabel::_set_table_column_expand_bind_compat_79053);
@@ -86,6 +94,8 @@ void RichTextLabel::_bind_compatibility_methods() {
8694
ClassDB::bind_compatibility_method(D_METHOD("remove_paragraph", "paragraph"), &RichTextLabel::_remove_paragraph_bind_compat_91098);
8795
ClassDB::bind_compatibility_method(D_METHOD("push_underline"), &RichTextLabel::_push_underline_bind_compat_106300);
8896
ClassDB::bind_compatibility_method(D_METHOD("push_strikethrough"), &RichTextLabel::_push_strikethrough_bind_compat_106300);
97+
ClassDB::bind_compatibility_method(D_METHOD("add_image", "image", "width", "height", "color", "inline_align", "region", "key", "pad", "tooltip", "size_in_percent", "alt_text"), &RichTextLabel::_add_image_bind_compat_107347, DEFVAL(0), DEFVAL(0), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(INLINE_ALIGNMENT_CENTER), DEFVAL(Rect2()), DEFVAL(Variant()), DEFVAL(false), DEFVAL(String()), DEFVAL(false), DEFVAL(String()));
98+
ClassDB::bind_compatibility_method(D_METHOD("update_image", "key", "mask", "image", "width", "height", "color", "inline_align", "region", "pad", "tooltip", "size_in_percent"), &RichTextLabel::_update_image_bind_compat_107347, DEFVAL(0), DEFVAL(0), DEFVAL(Color(1.0, 1.0, 1.0)), DEFVAL(INLINE_ALIGNMENT_CENTER), DEFVAL(Rect2()), DEFVAL(false), DEFVAL(String()), DEFVAL(false));
8999
}
90100

91101
#endif // DISABLE_DEPRECATED

0 commit comments

Comments
 (0)