浏览代码

Merge pull request #48829 from Chaosus/vs_comment_node_fixes

Prevents VisualShaderNodeComment from overlapping its content
Rémi Verschelde 4 年之前
父节点
当前提交
6580d1798a
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      editor/plugins/visual_shader_editor_plugin.cpp

+ 6 - 1
editor/plugins/visual_shader_editor_plugin.cpp

@@ -349,6 +349,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
 	Ref<VisualShaderNodeGroupBase> group_node = Object::cast_to<VisualShaderNodeGroupBase>(vsnode.ptr());
 	Ref<VisualShaderNodeGroupBase> group_node = Object::cast_to<VisualShaderNodeGroupBase>(vsnode.ptr());
 	bool is_group = !group_node.is_null();
 	bool is_group = !group_node.is_null();
 
 
+	bool is_comment = false;
+
 	Ref<VisualShaderNodeExpression> expression_node = Object::cast_to<VisualShaderNodeExpression>(group_node.ptr());
 	Ref<VisualShaderNodeExpression> expression_node = Object::cast_to<VisualShaderNodeExpression>(group_node.ptr());
 	bool is_expression = !expression_node.is_null();
 	bool is_expression = !expression_node.is_null();
 	String expression = "";
 	String expression = "";
@@ -392,13 +394,13 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
 	if (is_resizable) {
 	if (is_resizable) {
 		Ref<VisualShaderNodeComment> comment_node = Object::cast_to<VisualShaderNodeComment>(vsnode.ptr());
 		Ref<VisualShaderNodeComment> comment_node = Object::cast_to<VisualShaderNodeComment>(vsnode.ptr());
 		if (comment_node.is_valid()) {
 		if (comment_node.is_valid()) {
+			is_comment = true;
 			node->set_comment(true);
 			node->set_comment(true);
 
 
 			Label *comment_label = memnew(Label);
 			Label *comment_label = memnew(Label);
 			node->add_child(comment_label);
 			node->add_child(comment_label);
 			comment_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
 			comment_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
 			comment_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
 			comment_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
-			comment_label->set_mouse_filter(Control::MouseFilter::MOUSE_FILTER_STOP);
 			comment_label->set_text(comment_node->get_description());
 			comment_label->set_text(comment_node->get_description());
 		}
 		}
 	}
 	}
@@ -773,6 +775,9 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
 
 
 	if (!uniform.is_valid()) {
 	if (!uniform.is_valid()) {
 		VisualShaderEditor::get_singleton()->graph->add_child(node);
 		VisualShaderEditor::get_singleton()->graph->add_child(node);
+		if (is_comment) {
+			VisualShaderEditor::get_singleton()->graph->move_child(node, 0); // to prevents a bug where comment node overlaps its content
+		}
 		VisualShaderEditor::get_singleton()->_update_created_node(node);
 		VisualShaderEditor::get_singleton()->_update_created_node(node);
 		if (is_resizable) {
 		if (is_resizable) {
 			VisualShaderEditor::get_singleton()->call_deferred("_set_node_size", (int)p_type, p_id, size);
 			VisualShaderEditor::get_singleton()->call_deferred("_set_node_size", (int)p_type, p_id, size);