Merge pull request #52145 from LeaoLuciano/linkbutton-translation-4.0
LinkButton's text now is automatically translated
This commit is contained in:
commit
3f6a01e848
|
@ -41,12 +41,16 @@ void LinkButton::_shape() {
|
||||||
} else {
|
} else {
|
||||||
text_buf->set_direction((TextServer::Direction)text_direction);
|
text_buf->set_direction((TextServer::Direction)text_direction);
|
||||||
}
|
}
|
||||||
TS->shaped_text_set_bidi_override(text_buf->get_rid(), structured_text_parser(st_parser, st_args, text));
|
TS->shaped_text_set_bidi_override(text_buf->get_rid(), structured_text_parser(st_parser, st_args, xl_text));
|
||||||
text_buf->add_string(text, font, font_size, opentype_features, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale());
|
text_buf->add_string(xl_text, font, font_size, opentype_features, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkButton::set_text(const String &p_text) {
|
void LinkButton::set_text(const String &p_text) {
|
||||||
|
if (text == p_text) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
text = p_text;
|
text = p_text;
|
||||||
|
xl_text = atr(text);
|
||||||
_shape();
|
_shape();
|
||||||
minimum_size_changed();
|
minimum_size_changed();
|
||||||
update();
|
update();
|
||||||
|
@ -141,7 +145,13 @@ Size2 LinkButton::get_minimum_size() const {
|
||||||
|
|
||||||
void LinkButton::_notification(int p_what) {
|
void LinkButton::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_TRANSLATION_CHANGED:
|
case NOTIFICATION_TRANSLATION_CHANGED: {
|
||||||
|
xl_text = atr(text);
|
||||||
|
_shape();
|
||||||
|
|
||||||
|
minimum_size_changed();
|
||||||
|
update();
|
||||||
|
} break;
|
||||||
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
|
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
|
||||||
update();
|
update();
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String text;
|
String text;
|
||||||
|
String xl_text;
|
||||||
Ref<TextLine> text_buf;
|
Ref<TextLine> text_buf;
|
||||||
UnderlineMode underline_mode = UNDERLINE_MODE_ALWAYS;
|
UnderlineMode underline_mode = UNDERLINE_MODE_ALWAYS;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue