Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Complex Text Layouts] Refactor RichTextLabel. #42595

Merged
merged 1 commit into from
Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions doc/classes/CharFXTransform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,6 @@
<methods>
</methods>
<members>
<member name="absolute_index" type="int" setter="set_absolute_index" getter="get_absolute_index" default="0">
The index of the current character (starting from 0). Setting this property won't affect drawing.
</member>
<member name="character" type="int" setter="set_character" getter="get_character" default="0">
The Unicode codepoint the character will use. This only affects non-whitespace characters. [method @GDScript.ord] can be useful here. For example, the following will replace all characters with asterisks:
[codeblocks]
[gdscript]
# `char_fx` is the CharFXTransform parameter from `_process_custom_fx()`.
# See the RichTextEffect documentation for details.
char_fx.character = ord("*")
[/gdscript]
[csharp]
// `char_fx` is the CharFXTransform parameter from `_process_custom_fx()`.
// See the RichTextEffect documentation for details.
charFx.Character = char.GetNumericValue('*');
[/csharp]
[/codeblocks]
</member>
<member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )">
The color the character will be drawn with.
</member>
Expand All @@ -45,11 +27,20 @@
{"foo": "hello", "bar": true, "baz": 42, "color": Color(1, 1, 1, 1)}
[/codeblock]
</member>
<member name="font" type="RID" setter="set_font" getter="get_font">
Font resource used to render glyph.
</member>
<member name="glyph_index" type="int" setter="set_glyph_index" getter="get_glyph_index" default="0">
Font specific glyph index.
</member>
<member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )">
The position offset the character will be drawn with (in pixels).
</member>
<member name="relative_index" type="int" setter="set_relative_index" getter="get_relative_index" default="0">
The index of the current character (starting from 0). Setting this property won't affect drawing.
<member name="outline" type="bool" setter="set_outline" getter="is_outline" default="false">
If [code]ture[/code], FX transform is called for outline drawing. Setting this property won't affect drawing.
</member>
<member name="range" type="Vector2i" setter="set_range" getter="get_range" default="Vector2i( 0, 0 )">
Absolute character range in the string, corresponding to the glyph. Setting this property won't affect drawing.
</member>
<member name="visible" type="bool" setter="set_visibility" getter="is_visible" default="true">
If [code]true[/code], the character will be drawn. If [code]false[/code], the character will be hidden. Characters around hidden characters will reflow to take the space of hidden characters. If this is not desired, set their [member color] to [code]Color(1, 1, 1, 0)[/code] instead.
Expand Down
191 changes: 164 additions & 27 deletions doc/classes/RichTextLabel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
</argument>
<argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )">
</argument>
<argument index="4" name="inline_align" type="int" enum="VAlign" default="0">
</argument>
<description>
Adds an image's opening and closing tags to the tag stack, optionally providing a [code]width[/code] and [code]height[/code] to resize the image and a [code]color[/code] to tint the image.
If [code]width[/code] or [code]height[/code] is set to 0, the image size will be adjusted in order to keep the original aspect ratio.
Expand Down Expand Up @@ -132,15 +134,6 @@
Terminates the current tag. Use after [code]push_*[/code] methods to close BBCodes manually. Does not need to follow [code]add_*[/code] methods.
</description>
</method>
<method name="push_align">
<return type="void">
</return>
<argument index="0" name="align" type="int" enum="RichTextLabel.Align">
</argument>
<description>
Adds an [code][align][/code] tag based on the given [code]align[/code] value. See [enum Align] for possible values.
</description>
</method>
<method name="push_bold">
<return type="void">
</return>
Expand Down Expand Up @@ -180,6 +173,24 @@
Adds a [code][font][/code] tag to the tag stack. Overrides default fonts for its duration.
</description>
</method>
<method name="push_font_features">
<return type="void">
</return>
<argument index="0" name="opentype_features" type="Dictionary">
</argument>
<description>
Adds a [code][ot_feature][/code] tag to the tag stack. Overrides default OpenType font feature for its duration.
</description>
</method>
<method name="push_font_size">
<return type="void">
</return>
<argument index="0" name="font_size" type="int">
</argument>
<description>
Adds a [code][font_size][/code] tag to the tag stack. Overrides default font size for its duration.
</description>
</method>
<method name="push_indent">
<return type="void">
</return>
Expand All @@ -199,10 +210,14 @@
<method name="push_list">
<return type="void">
</return>
<argument index="0" name="type" type="int" enum="RichTextLabel.ListType">
<argument index="0" name="level" type="int">
</argument>
<argument index="1" name="type" type="int" enum="RichTextLabel.ListType">
</argument>
<argument index="2" name="capitalize" type="bool">
</argument>
<description>
Adds a [code][list][/code] tag to the tag stack. Similar to the BBCodes [code][ol][/code] or [code][ul][/code], but supports more list types. Not fully implemented!
Adds [code][ol][/code] or [code][ul][/code] tag to the tag stack. Multiplies [code]level[/code] by current [member tab_size] to determine new margin length.
</description>
</method>
<method name="push_meta">
Expand All @@ -228,6 +243,39 @@
Adds a [code][font][/code] tag with a normal font to the tag stack.
</description>
</method>
<method name="push_outline_color">
<return type="void">
</return>
<argument index="0" name="color" type="Color">
</argument>
<description>
Adds a [code][outline_color][/code] tag to the tag stack. Adds text outline for its duration.
</description>
</method>
<method name="push_outline_size">
<return type="void">
</return>
<argument index="0" name="outline_size" type="int">
</argument>
<description>
Adds a [code][outline_size][/code] tag to the tag stack. Overrides default text outline size for its duration.
</description>
</method>
<method name="push_paragraph">
<return type="void">
</return>
<argument index="0" name="align" type="int" enum="RichTextLabel.Align">
</argument>
<argument index="1" name="base_direction" type="int" enum="Control.TextDirection" default="0">
</argument>
<argument index="2" name="language" type="String" default="&quot;&quot;">
</argument>
<argument index="3" name="st_parser" type="int" enum="Control.StructuredTextParser" default="0">
</argument>
<description>
Adds a [code][p][/code] tag to the tag stack.
</description>
</method>
<method name="push_strikethrough">
<return type="void">
</return>
Expand All @@ -240,8 +288,10 @@
</return>
<argument index="0" name="columns" type="int">
</argument>
<argument index="1" name="inline_align" type="int" enum="VAlign" default="0">
</argument>
<description>
Adds a [code][table=columns][/code] tag to the tag stack.
Adds a [code][table=columns,inline_align][/code] tag to the tag stack.
</description>
</method>
<method name="push_underline">
Expand Down Expand Up @@ -270,6 +320,46 @@
Scrolls the window's top line to match [code]line[/code].
</description>
</method>
<method name="set_cell_border_color">
<return type="void">
</return>
<argument index="0" name="color" type="Color">
</argument>
<description>
Sets color of a table cell border.
</description>
</method>
<method name="set_cell_padding">
<return type="void">
</return>
<argument index="0" name="padding" type="Rect2">
</argument>
<description>
Sets inner padding of a table cell.
</description>
</method>
<method name="set_cell_row_background_color">
<return type="void">
</return>
<argument index="0" name="odd_row_bg" type="Color">
</argument>
<argument index="1" name="even_row_bg" type="Color">
</argument>
<description>
Sets color of a table cell. Separate colors for alternating rows can be specified.
</description>
</method>
<method name="set_cell_size_override">
<return type="void">
</return>
<argument index="0" name="min_size" type="Vector2">
</argument>
<argument index="1" name="max_size" type="Vector2">
</argument>
<description>
Sets minimum and maximum size overrides for a table cell.
</description>
</method>
<method name="set_table_column_expand">
<return type="void">
</return>
Expand Down Expand Up @@ -302,6 +392,9 @@
If [code]true[/code], the label's height will be automatically updated to fit its content.
[b]Note:[/b] This property is used as a workaround to fix issues with [RichTextLabel] in [Container]s, but it's unreliable in some cases and will be removed in future versions.
</member>
<member name="language" type="String" setter="set_language" getter="get_language" default="&quot;&quot;">
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
</member>
<member name="meta_underlined" type="bool" setter="set_meta_underline" getter="is_meta_underlined" default="true">
If [code]true[/code], the label underlines meta tags such as [code][url]{text}[/url][/code].
</member>
Expand All @@ -322,13 +415,22 @@
<member name="selection_enabled" type="bool" setter="set_selection_enabled" getter="is_selection_enabled" default="false">
If [code]true[/code], the label allows text selection.
</member>
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
Set BiDi algorithm override for the structured text.
</member>
<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]">
Set additional options for BiDi override.
</member>
<member name="tab_size" type="int" setter="set_tab_size" getter="get_tab_size" default="4">
The number of spaces associated with a single tab length. Does not affect [code]\t[/code] in text tags, only indent tags.
</member>
<member name="text" type="String" setter="set_text" getter="get_text" default="&quot;&quot;">
The raw text of the label.
When set, clears the tag stack and adds a raw text tag to the top of it. Does not parse BBCodes. Does not modify [member bbcode_text].
</member>
<member name="text_direction" type="int" setter="set_text_direction" getter="get_text_direction" enum="Control.TextDirection" default="0">
Base text writing direction.
</member>
<member name="visible_characters" type="int" setter="set_visible_characters" getter="get_visible_characters" default="-1">
The restricted number of characters to display in the label. If [code]-1[/code], all characters will be displayed.
</member>
Expand Down Expand Up @@ -375,7 +477,10 @@
<constant name="LIST_LETTERS" value="1" enum="ListType">
Each list item has a letter marker.
</constant>
<constant name="LIST_DOTS" value="2" enum="ListType">
<constant name="LIST_ROMAN" value="2" enum="ListType">
Each list item has a roman number marker.
</constant>
<constant name="LIST_DOTS" value="3" enum="ListType">
Each list item has a filled circle marker.
</constant>
<constant name="ITEM_FRAME" value="0" enum="ItemType">
Expand All @@ -388,42 +493,56 @@
</constant>
<constant name="ITEM_FONT" value="4" enum="ItemType">
</constant>
<constant name="ITEM_COLOR" value="5" enum="ItemType">
<constant name="ITEM_FONT_SIZE" value="5" enum="ItemType">
</constant>
<constant name="ITEM_FONT_FEATURES" value="6" enum="ItemType">
</constant>
<constant name="ITEM_UNDERLINE" value="6" enum="ItemType">
<constant name="ITEM_COLOR" value="7" enum="ItemType">
</constant>
<constant name="ITEM_STRIKETHROUGH" value="7" enum="ItemType">
<constant name="ITEM_OUTLINE_SIZE" value="8" enum="ItemType">
</constant>
<constant name="ITEM_ALIGN" value="8" enum="ItemType">
<constant name="ITEM_OUTLINE_COLOR" value="9" enum="ItemType">
</constant>
<constant name="ITEM_INDENT" value="9" enum="ItemType">
<constant name="ITEM_UNDERLINE" value="10" enum="ItemType">
</constant>
<constant name="ITEM_LIST" value="10" enum="ItemType">
<constant name="ITEM_STRIKETHROUGH" value="11" enum="ItemType">
</constant>
<constant name="ITEM_TABLE" value="11" enum="ItemType">
<constant name="ITEM_PARAGRAPH" value="12" enum="ItemType">
</constant>
<constant name="ITEM_FADE" value="12" enum="ItemType">
<constant name="ITEM_INDENT" value="13" enum="ItemType">
</constant>
<constant name="ITEM_SHAKE" value="13" enum="ItemType">
<constant name="ITEM_LIST" value="14" enum="ItemType">
</constant>
<constant name="ITEM_WAVE" value="14" enum="ItemType">
<constant name="ITEM_TABLE" value="15" enum="ItemType">
</constant>
<constant name="ITEM_TORNADO" value="15" enum="ItemType">
<constant name="ITEM_FADE" value="16" enum="ItemType">
</constant>
<constant name="ITEM_RAINBOW" value="16" enum="ItemType">
<constant name="ITEM_SHAKE" value="17" enum="ItemType">
</constant>
<constant name="ITEM_CUSTOMFX" value="18" enum="ItemType">
<constant name="ITEM_WAVE" value="18" enum="ItemType">
</constant>
<constant name="ITEM_META" value="17" enum="ItemType">
<constant name="ITEM_TORNADO" value="19" enum="ItemType">
</constant>
<constant name="ITEM_RAINBOW" value="20" enum="ItemType">
</constant>
<constant name="ITEM_CUSTOMFX" value="22" enum="ItemType">
</constant>
<constant name="ITEM_META" value="21" enum="ItemType">
</constant>
</constants>
<theme_items>
<theme_item name="bold_font" type="Font">
The font used for bold text.
</theme_item>
<theme_item name="bold_font_size" type="int">
The font size used for bold text.
</theme_item>
<theme_item name="bold_italics_font" type="Font">
The font used for bold italics text.
</theme_item>
<theme_item name="bold_italics_font_size" type="int">
The font size used for bold italics text.
</theme_item>
<theme_item name="default_color" type="Color" default="Color( 1, 1, 1, 1 )">
The default text color.
</theme_item>
Expand All @@ -439,18 +558,27 @@
<theme_item name="italics_font" type="Font">
The font used for italics text.
</theme_item>
<theme_item name="italics_font_size" type="int">
The font size used for italics text.
</theme_item>
<theme_item name="line_separation" type="int" default="1">
The vertical space between lines.
</theme_item>
<theme_item name="mono_font" type="Font">
The font used for monospace text.
</theme_item>
<theme_item name="mono_font_size" type="int">
The font size used for monospace text.
</theme_item>
<theme_item name="normal" type="StyleBox">
The normal background for the [RichTextLabel].
</theme_item>
<theme_item name="normal_font" type="Font">
The default text font.
</theme_item>
<theme_item name="normal_font_size" type="int">
The default text font size.
</theme_item>
<theme_item name="selection_color" type="Color" default="Color( 0.1, 0.1, 1, 0.8 )">
The color of the selection box.
</theme_item>
Expand All @@ -463,9 +591,18 @@
<theme_item name="shadow_offset_y" type="int" default="1">
The vertical offset of the font's shadow.
</theme_item>
<theme_item name="table_border" type="Color" default="Color( 0, 0, 0, 0 )">
The default cell border color.
</theme_item>
<theme_item name="table_even_row_bg" type="Color" default="Color( 0, 0, 0, 0 )">
The default background color for even rows.
</theme_item>
<theme_item name="table_hseparation" type="int" default="3">
The horizontal separation of elements in a table.
</theme_item>
<theme_item name="table_odd_row_bg" type="Color" default="Color( 0, 0, 0, 0 )">
The default background color for odd rows.
</theme_item>
<theme_item name="table_vseparation" type="int" default="3">
The vertical separation of elements in a table.
</theme_item>
Expand Down
Loading