summaryrefslogtreecommitdiffstats
path: root/scene/gui/label.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/label.cpp')
-rw-r--r--scene/gui/label.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index dda9e4b128..cd500a62bc 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -68,6 +68,13 @@ int Label::get_line_height() const {
void Label::_notification(int p_what) {
+ if (p_what==NOTIFICATION_TRANSLATION_CHANGED) {
+
+ xl_text=XL_MESSAGE(text);
+ minimum_size_changed();
+ update();
+ }
+
if (p_what==NOTIFICATION_DRAW) {
if (clip || autowrap) {
@@ -240,8 +247,8 @@ void Label::_notification(int p_what) {
for (int i=0;i<from->word_len;i++) {
if (visible_chars < 0 || chars_total_shadow<visible_chars) {
- CharType c = text[i+pos];
- CharType n = text[i+pos+1];
+ CharType c = xl_text[i+pos];
+ CharType n = xl_text[i+pos+1];
if (uppercase) {
c=String::char_uppercase(c);
n=String::char_uppercase(c);
@@ -263,8 +270,8 @@ void Label::_notification(int p_what) {
for (int i=0;i<from->word_len;i++) {
if (visible_chars < 0 || chars_total<visible_chars) {
- CharType c = text[i+pos];
- CharType n = text[i+pos+1];
+ CharType c = xl_text[i+pos];
+ CharType n = xl_text[i+pos+1];
if (uppercase) {
c=String::char_uppercase(c);
n=String::char_uppercase(c);
@@ -319,9 +326,9 @@ int Label::get_longest_line_width() const {
int max_line_width=0;
int line_width=0;
- for (int i=0;i<text.size();i++) {
+ for (int i=0;i<xl_text.size();i++) {
- CharType current=text[i];
+ CharType current=xl_text[i];
if (uppercase)
current=String::char_uppercase(current);
@@ -335,7 +342,7 @@ int Label::get_longest_line_width() const {
}
} else {
- int char_width=font->get_char_size(current,text[i+1]).width;
+ int char_width=font->get_char_size(current,xl_text[i+1]).width;
line_width+=char_width;
}
@@ -396,9 +403,9 @@ void Label::regenerate_word_cache() {
WordCache *last=NULL;
- for (int i=0;i<text.size()+1;i++) {
+ for (int i=0;i<xl_text.size()+1;i++) {
- CharType current=i<text.length()?text[i]:' '; //always a space at the end, so the algo works
+ CharType current=i<xl_text.length()?xl_text[i]:' '; //always a space at the end, so the algo works
if (uppercase)
current=String::char_uppercase(current);
@@ -438,7 +445,7 @@ void Label::regenerate_word_cache() {
total_char_cache++;
}
- if (i<text.length() && text[i] == ' ') {
+ if (i<xl_text.length() && xl_text[i] == ' ') {
total_char_cache--; // do not count spaces
if (line_width > 0 || last==NULL || last->char_pos!=WordCache::CHAR_WRAPLINE) {
space_count++;
@@ -455,7 +462,7 @@ void Label::regenerate_word_cache() {
word_pos=i;
}
- char_width=font->get_char_size(current,text[i+1]).width;
+ char_width=font->get_char_size(current,xl_text[i+1]).width;
current_word_size+=char_width;
line_width+=char_width;
total_char_cache++;
@@ -541,12 +548,11 @@ Label::VAlign Label::get_valign() const{
void Label::set_text(const String& p_string) {
- String str = XL_MESSAGE(p_string);
- if (text==str)
+ if (text==p_string)
return;
-
- text=str;
+ text=p_string;
+ xl_text=XL_MESSAGE(p_string);
word_cache_dirty=true;
if (percent_visible<1)
visible_chars=get_total_character_count()*percent_visible;
@@ -693,7 +699,7 @@ Label::Label(const String &p_text) {
align=ALIGN_LEFT;
valign=VALIGN_TOP;
- text="";
+ xl_text="";
word_cache=NULL;
word_cache_dirty=true;
autowrap=false;