summaryrefslogtreecommitdiffstats
path: root/scene/gui/label.cpp
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2014-06-11 01:13:58 -0300
committerreduz <reduzio@gmail.com>2014-06-11 01:13:58 -0300
commitade32e5e904979965e15d810d80d1d93d3a15460 (patch)
treeea8bb7f52d1b1190a3462266730c2d5ba820e150 /scene/gui/label.cpp
parent9ae371519ccc7a6dc44e379f94f8cf1c564bc20a (diff)
parent359ea6088cbe6cdad49919eb1ee669cb73d28da0 (diff)
downloadredot-engine-ade32e5e904979965e15d810d80d1d93d3a15460.tar.gz
Merge pull request #476 from TheoXD/472_percent_visible
Made a uniform distribution of characters in Label::set_percent_visible(...
Diffstat (limited to 'scene/gui/label.cpp')
-rw-r--r--scene/gui/label.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index a2f837c3c4..b7918994d8 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -398,12 +398,15 @@ void Label::regenerate_word_cache() {
}
if (current=='\n') {
-
insert_newline=true;
} else {
total_char_cache++;
}
+ if (i<text.length() && text[i] == ' ') {
+ total_char_cache--; // do not count spaces
+ }
+
} else {
@@ -442,7 +445,8 @@ void Label::regenerate_word_cache() {
last_width=line_width;
}
-
+
+ total_char_cache -= line_count + 1; // do not count new lines (including the first one)
if (!autowrap) {
@@ -519,6 +523,7 @@ String Label::get_text() const {
return text;
}
+
void Label::set_visible_characters(int p_amount) {
visible_chars=p_amount;
@@ -582,7 +587,7 @@ void Label::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::INT, "valign", PROPERTY_HINT_ENUM,"Top,Center,Bottom,Fill" ),_SCS("set_valign"),_SCS("get_valign") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "autowrap"),_SCS("set_autowrap"),_SCS("has_autowrap") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "uppercase"),_SCS("set_uppercase"),_SCS("is_uppercase") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "percent_visible"),_SCS("set_percent_visible"),_SCS("get_percent_visible") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_percent_visible"),_SCS("get_percent_visible") );
}