summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/file_dialog.cpp1
-rw-r--r--scene/gui/label.cpp88
-rw-r--r--scene/gui/label.h3
-rw-r--r--scene/gui/text_edit.cpp2
4 files changed, 59 insertions, 35 deletions
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 50ce657d2e..13cf87ac2b 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -92,7 +92,6 @@ void FileDialog::_file_entered(const String& p_file) {
}
void FileDialog::_save_confirm_pressed() {
-
String f=dir_access->get_current_dir().plus_file(file->get_text());
emit_signal("file_selected",f);
hide();
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 6afff81fde..1751d335ee 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -99,7 +99,7 @@ void Label::_notification(int p_what) {
int chars_total=0;
int vbegin=0,vsep=0;
-
+
if (lines_total && lines_total < lines_visible) {
@@ -136,10 +136,9 @@ void Label::_notification(int p_what) {
if (!wc)
return;
-
+ int c = 0;
int line=0;
while(wc) {
-
/* handle lines not meant to be drawn quickly */
if (line>line_to)
break;
@@ -170,8 +169,8 @@ void Label::_notification(int p_what) {
while(to && to->char_pos>=0) {
taken+=to->pixel_width;
- if (to!=from) {
- spaces++;
+ if (to!=from && to->space_count) {
+ spaces+=to->space_count;
}
to=to->next;
}
@@ -212,15 +211,15 @@ void Label::_notification(int p_what) {
ERR_PRINT("BUG");
return;
}
- if (from!=wc) {
+ if (from->space_count) {
/* spacing */
- x_ofs+=space_w;
+ x_ofs+=space_w*from->space_count;
if (can_fill && align==ALIGN_FILL && spaces) {
-
+
x_ofs+=int((size.width-(taken+space_w*spaces))/spaces);
}
-
-
+
+
}
@@ -253,7 +252,7 @@ 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];
@@ -361,11 +360,12 @@ void Label::regenerate_word_cache() {
int width=autowrap?get_size().width:get_longest_line_width();
Ref<Font> font = get_font("font");
-
+
int current_word_size=0;
int word_pos=0;
int line_width=0;
- int last_width=0;
+ int space_count=0;
+ int space_width=font->get_char_size(' ').width;
line_count=1;
total_char_cache=0;
@@ -374,16 +374,17 @@ void Label::regenerate_word_cache() {
for (int i=0;i<text.size()+1;i++) {
CharType current=i<text.length()?text[i]:' '; //always a space at the end, so the algo works
-
+
if (uppercase)
current=String::char_uppercase(current);
+ bool not_latin = current>=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57);
bool insert_newline=false;
-
+ int char_width;
+
if (current<33) {
-
+
if (current_word_size>0) {
-
WordCache *wc = memnew( WordCache );
if (word_cache) {
last->next=wc;
@@ -391,14 +392,16 @@ void Label::regenerate_word_cache() {
word_cache=wc;
}
last=wc;
-
+
wc->pixel_width=current_word_size;
wc->char_pos=word_pos;
wc->word_len=i-word_pos;
+ wc->space_count = space_count;
current_word_size=0;
-
+ space_count=0;
+
}
-
+
if (current=='\n') {
insert_newline=true;
@@ -408,26 +411,49 @@ void Label::regenerate_word_cache() {
if (i<text.length() && text[i] == ' ') {
total_char_cache--; // do not count spaces
+ if (line_width > 0 || last==NULL || last->char_pos!=WordCache::CHAR_WRAPLINE) {
+ space_count++;
+ line_width+=space_width;
+ }else {
+ space_count=0;
+ }
}
} else {
-
+ // latin characters
if (current_word_size==0) {
- if (line_width>0) // add a space before the new word if a word existed before
- line_width+=font->get_char_size(' ').width;
word_pos=i;
}
- int char_width=font->get_char_size(current).width;
+ char_width=font->get_char_size(current).width;
current_word_size+=char_width;
line_width+=char_width;
total_char_cache++;
}
-
- if ((autowrap && line_width>=width && last_width<width) || insert_newline) {
-
+
+ if ((autowrap && line_width>=width && (last && last->char_pos >= 0 || not_latin)) || insert_newline) {
+ if (not_latin) {
+ if (current_word_size>0) {
+ WordCache *wc = memnew( WordCache );
+ if (word_cache) {
+ last->next=wc;
+ } else {
+ word_cache=wc;
+ }
+ last=wc;
+
+ wc->pixel_width=current_word_size-char_width;
+ wc->char_pos=word_pos;
+ wc->word_len=i-word_pos;
+ wc->space_count = space_count;
+ current_word_size=char_width;
+ space_count=0;
+ word_pos=i;
+ }
+ }
+
WordCache *wc = memnew( WordCache );
if (word_cache) {
last->next=wc;
@@ -435,18 +461,16 @@ void Label::regenerate_word_cache() {
word_cache=wc;
}
last=wc;
-
+
wc->pixel_width=0;
wc->char_pos=insert_newline?WordCache::CHAR_NEWLINE:WordCache::CHAR_WRAPLINE;
line_width=current_word_size;
line_count++;
+ space_count=0;
-
}
- last_width=line_width;
-
}
//total_char_cache -= line_count + 1; // do not count new lines (including the first one)
@@ -465,7 +489,7 @@ void Label::regenerate_word_cache() {
set_max(line_count);
word_cache_dirty=false;
-
+
}
diff --git a/scene/gui/label.h b/scene/gui/label.h
index 3b0dddc1a3..81e3ab5676 100644
--- a/scene/gui/label.h
+++ b/scene/gui/label.h
@@ -75,8 +75,9 @@ private:
int char_pos; // if -1, then newline
int word_len;
int pixel_width;
+ int space_count;
WordCache *next;
- WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; }
+ WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; space_count=0;}
};
bool word_cache_dirty;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 1e82432165..6cdff20aaf 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1249,7 +1249,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
- if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec()-last_dblclk)<600) {
+ if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec()-last_dblclk)<600 && cursor.line==prev_line) {
//tripleclick select line
select(cursor.line,0,cursor.line,text[cursor.line].length());
last_dblclk=0;