[RTL] Fix custom effects not updating.

This commit is contained in:
Pāvels Nadtočajevs 2025-03-05 22:55:35 +02:00
parent 1ba4dbb164
commit 9f8d8b7c4e
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
3 changed files with 15 additions and 3 deletions

View file

@ -525,6 +525,12 @@
Adds a [code skip-lint][u][/code] tag to the tag stack.
</description>
</method>
<method name="reload_effects">
<return type="void" />
<description>
Reloads custom effects. Useful when [member custom_effects] is modified manually.
</description>
</method>
<method name="remove_paragraph">
<return type="bool" />
<param index="0" name="paragraph" type="int" />

View file

@ -6356,9 +6356,7 @@ float RichTextLabel::get_visible_ratio() const {
void RichTextLabel::set_effects(Array p_effects) {
custom_effects = p_effects;
if (!stack_externally_modified && use_bbcode) {
parse_bbcode(atr(text));
}
reload_effects();
}
Array RichTextLabel::get_effects() {
@ -6371,8 +6369,14 @@ void RichTextLabel::install_effect(const Variant effect) {
ERR_FAIL_COND_MSG(rteffect.is_null(), "Invalid RichTextEffect resource.");
custom_effects.push_back(effect);
reload_effects();
}
void RichTextLabel::reload_effects() {
if (!stack_externally_modified && use_bbcode) {
internal_stack_editing = true;
parse_bbcode(atr(text));
internal_stack_editing = false;
}
}
@ -6580,6 +6584,7 @@ void RichTextLabel::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_effects", "effects"), &RichTextLabel::set_effects);
ClassDB::bind_method(D_METHOD("get_effects"), &RichTextLabel::get_effects);
ClassDB::bind_method(D_METHOD("install_effect", "effect"), &RichTextLabel::install_effect);
ClassDB::bind_method(D_METHOD("reload_effects"), &RichTextLabel::reload_effects);
ClassDB::bind_method(D_METHOD("get_menu"), &RichTextLabel::get_menu);
ClassDB::bind_method(D_METHOD("is_menu_visible"), &RichTextLabel::is_menu_visible);

View file

@ -881,6 +881,7 @@ public:
Array get_effects();
void install_effect(const Variant effect);
void reload_effects();
virtual Size2 get_minimum_size() const override;