[RTL] Decouple image width/height "in percent" properties. Add [hr] tag support.

This commit is contained in:
Pāvels Nadtočajevs
2025-06-09 23:29:49 +03:00
parent fc523ec5f6
commit a262747cdf
6 changed files with 181 additions and 24 deletions

View File

@ -17,6 +17,20 @@
<link title="Operating System Testing Demo">https://godotengine.org/asset-library/asset/2789</link>
</tutorials>
<methods>
<method name="add_hr">
<return type="void" />
<param index="0" name="width" type="int" default="90" />
<param index="1" name="height" type="int" default="2" />
<param index="2" name="color" type="Color" default="Color(1, 1, 1, 1)" />
<param index="3" name="alignment" type="int" enum="HorizontalAlignment" default="1" />
<param index="4" name="width_in_percent" type="bool" default="true" />
<param index="5" name="height_in_percent" type="bool" default="false" />
<description>
Adds a horizontal rule that can be used to separate content.
If [param width_in_percent] is set, [param width] values are percentages of the control width instead of pixels.
If [param height_in_percent] is set, [param height] values are percentages of the control width instead of pixels.
</description>
</method>
<method name="add_image">
<return type="void" />
<param index="0" name="image" type="Texture2D" />
@ -28,15 +42,17 @@
<param index="6" name="key" type="Variant" default="null" />
<param index="7" name="pad" type="bool" default="false" />
<param index="8" name="tooltip" type="String" default="&quot;&quot;" />
<param index="9" name="size_in_percent" type="bool" default="false" />
<param index="10" name="alt_text" type="String" default="&quot;&quot;" />
<param index="9" name="width_in_percent" type="bool" default="false" />
<param index="10" name="height_in_percent" type="bool" default="false" />
<param index="11" name="alt_text" type="String" default="&quot;&quot;" />
<description>
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.
If [param width] or [param height] is set to 0, the image size will be adjusted in order to keep the original aspect ratio.
If [param width] and [param height] are not set, but [param region] is, the region's rect will be used.
[param key] is an optional identifier, that can be used to modify the image via [method update_image].
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.
If [param size_in_percent] is set, [param width] and [param height] values are percentages of the control width instead of pixels.
If [param width_in_percent] is set, [param width] values are percentages of the control width instead of pixels.
If [param height_in_percent] is set, [param height] values are percentages of the control width instead of pixels.
[param alt_text] is used as the image description for assistive apps.
</description>
</method>
@ -655,7 +671,8 @@
<param index="7" name="region" type="Rect2" default="Rect2(0, 0, 0, 0)" />
<param index="8" name="pad" type="bool" default="false" />
<param index="9" name="tooltip" type="String" default="&quot;&quot;" />
<param index="10" name="size_in_percent" type="bool" default="false" />
<param index="10" name="width_in_percent" type="bool" default="false" />
<param index="11" name="height_in_percent" type="bool" default="false" />
<description>
Updates the existing images with the key [param key]. Only properties specified by [param mask] bits are updated. See [method add_image].
</description>
@ -939,6 +956,9 @@
<theme_item name="normal_font_size" data_type="font_size" type="int">
The default text font size.
</theme_item>
<theme_item name="horizontal_rule" data_type="icon" type="Texture2D">
The horizontal rule texture.
</theme_item>
<theme_item name="focus" data_type="style" type="StyleBox">
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.
</theme_item>