summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorMax Hilbrunner <mhilbrunner@users.noreply.github.com>2021-09-07 21:43:43 +0200
committerGitHub <noreply@github.com>2021-09-07 21:43:43 +0200
commit3f6a01e848a4c5b59ac69cd7d807f0dc4545715b (patch)
treeb37520e0e47bfd78921b4dd8f165e1d8d1a9a2c7 /scene
parent58388f8cec58dbe29bfc21d01eea25994c08d650 (diff)
parentc50c5b9befae9ff106eb60a3c1a889678463d880 (diff)
Merge pull request #52145 from LeaoLuciano/linkbutton-translation-4.0
LinkButton's text now is automatically translated
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/link_button.cpp16
-rw-r--r--scene/gui/link_button.h1
2 files changed, 14 insertions, 3 deletions
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 419d49bccf..925e6f5b97 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -41,12 +41,16 @@ void LinkButton::_shape() {
} else {
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));
- text_buf->add_string(text, font, font_size, opentype_features, (language != "") ? language : TranslationServer::get_singleton()->get_tool_locale());
+ TS->shaped_text_set_bidi_override(text_buf->get_rid(), structured_text_parser(st_parser, st_args, xl_text));
+ 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) {
+ if (text == p_text) {
+ return;
+ }
text = p_text;
+ xl_text = atr(text);
_shape();
minimum_size_changed();
update();
@@ -141,7 +145,13 @@ Size2 LinkButton::get_minimum_size() const {
void LinkButton::_notification(int 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: {
update();
} break;
diff --git a/scene/gui/link_button.h b/scene/gui/link_button.h
index 7eaa9f88b6..231543c63c 100644
--- a/scene/gui/link_button.h
+++ b/scene/gui/link_button.h
@@ -47,6 +47,7 @@ public:
private:
String text;
+ String xl_text;
Ref<TextLine> text_buf;
UnderlineMode underline_mode = UNDERLINE_MODE_ALWAYS;