Merge pull request #32833 from nekomatata/label-autowrap-fix

Allow Label autowrap to cut words when they exceed line width
This commit is contained in:
Rémi Verschelde 2019-10-22 12:29:49 +02:00 committed by GitHub
commit 1e0fb0dc14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -129,6 +129,7 @@ NodeDock::NodeDock() {
select_a_node = memnew(Label);
select_a_node->set_text(TTR("Select a single node to edit its signals and groups."));
select_a_node->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
select_a_node->set_v_size_flags(SIZE_EXPAND_FILL);
select_a_node->set_valign(Label::VALIGN_CENTER);
select_a_node->set_align(Label::ALIGN_CENTER);

View File

@ -452,6 +452,11 @@ void Label::regenerate_word_cache() {
current_word_size += char_width;
line_width += char_width;
total_char_cache++;
// allow autowrap to cut words when they exceed line width
if (autowrap && (current_word_size > width)) {
separatable = true;
}
}
if ((autowrap && (line_width >= width) && ((last && last->char_pos >= 0) || separatable)) || insert_newline) {