浏览代码

Allow Label autowrap to cut words when they exceed line width

Fixes #30832
PouleyKetchoupp 5 年之前
父节点
当前提交
8df330bacd
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 1 0
      editor/node_dock.cpp
  2. 5 0
      scene/gui/label.cpp

+ 1 - 0
editor/node_dock.cpp

@@ -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);

+ 5 - 0
scene/gui/label.cpp

@@ -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) {