Makes the expression node to apply expression only when the focus leaves out
This commit is contained in:
parent
e2375f487c
commit
e70ea5d97b
2 changed files with 9 additions and 28 deletions
|
@ -701,7 +701,7 @@ void VisualShaderEditor::_update_graph() {
|
||||||
expression_box->set_context_menu_enabled(false);
|
expression_box->set_context_menu_enabled(false);
|
||||||
expression_box->set_show_line_numbers(true);
|
expression_box->set_show_line_numbers(true);
|
||||||
|
|
||||||
expression_box->connect("text_changed", this, "_set_expression", varray(nodes[n_i]), CONNECT_DEFERRED);
|
expression_box->connect("focus_exited", this, "_expression_focus_out", varray(expression_box, nodes[n_i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uniform.is_valid()) {
|
if (!uniform.is_valid()) {
|
||||||
|
@ -915,7 +915,7 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualShaderEditor::_set_expression(int p_node) {
|
void VisualShaderEditor::_expression_focus_out(Object *text_edit, int p_node) {
|
||||||
|
|
||||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||||
Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node);
|
Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node);
|
||||||
|
@ -923,24 +923,19 @@ void VisualShaderEditor::_set_expression(int p_node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEdit *expression_box = Object::cast_to<TextEdit>(node->get_control(0));
|
TextEdit *expression_box = Object::cast_to<TextEdit>(text_edit);
|
||||||
|
|
||||||
|
if (node->get_expression() == expression_box->get_text())
|
||||||
|
return;
|
||||||
|
|
||||||
undo_redo->create_action(TTR("Set expression"));
|
undo_redo->create_action(TTR("Set expression"));
|
||||||
undo_redo->add_do_method(node.ptr(), "set_expression", expression_box->get_text());
|
undo_redo->add_do_method(node.ptr(), "set_expression", expression_box->get_text());
|
||||||
undo_redo->add_undo_method(node.ptr(), "set_expression", node->get_expression());
|
undo_redo->add_undo_method(node.ptr(), "set_expression", node->get_expression());
|
||||||
undo_redo->add_do_method(this, "_start_rebuild_timer", 1.0);
|
undo_redo->add_do_method(this, "_rebuild");
|
||||||
undo_redo->add_undo_method(this, "_rebuild");
|
undo_redo->add_undo_method(this, "_rebuild");
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualShaderEditor::_start_rebuild_timer(int p_delay) {
|
|
||||||
build_timer->start(p_delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VisualShaderEditor::_rebuild_timeout() {
|
|
||||||
_rebuild();
|
|
||||||
}
|
|
||||||
|
|
||||||
void VisualShaderEditor::_rebuild() {
|
void VisualShaderEditor::_rebuild() {
|
||||||
EditorNode::get_singleton()->get_log()->clear();
|
EditorNode::get_singleton()->get_log()->clear();
|
||||||
visual_shader->rebuild();
|
visual_shader->rebuild();
|
||||||
|
@ -1797,9 +1792,7 @@ void VisualShaderEditor::_bind_methods() {
|
||||||
ClassDB::bind_method("_rebuild", &VisualShaderEditor::_rebuild);
|
ClassDB::bind_method("_rebuild", &VisualShaderEditor::_rebuild);
|
||||||
ClassDB::bind_method("_update_graph", &VisualShaderEditor::_update_graph);
|
ClassDB::bind_method("_update_graph", &VisualShaderEditor::_update_graph);
|
||||||
ClassDB::bind_method("_update_options_menu", &VisualShaderEditor::_update_options_menu);
|
ClassDB::bind_method("_update_options_menu", &VisualShaderEditor::_update_options_menu);
|
||||||
ClassDB::bind_method("_start_rebuild_timer", &VisualShaderEditor::_start_rebuild_timer);
|
ClassDB::bind_method("_expression_focus_out", &VisualShaderEditor::_expression_focus_out);
|
||||||
ClassDB::bind_method("_set_expression", &VisualShaderEditor::_set_expression);
|
|
||||||
ClassDB::bind_method("_rebuild_timeout", &VisualShaderEditor::_rebuild_timeout);
|
|
||||||
ClassDB::bind_method("_add_node", &VisualShaderEditor::_add_node);
|
ClassDB::bind_method("_add_node", &VisualShaderEditor::_add_node);
|
||||||
ClassDB::bind_method("_node_dragged", &VisualShaderEditor::_node_dragged);
|
ClassDB::bind_method("_node_dragged", &VisualShaderEditor::_node_dragged);
|
||||||
ClassDB::bind_method("_connection_request", &VisualShaderEditor::_connection_request);
|
ClassDB::bind_method("_connection_request", &VisualShaderEditor::_connection_request);
|
||||||
|
@ -2287,13 +2280,6 @@ VisualShaderEditor::VisualShaderEditor() {
|
||||||
add_child(property_editor);
|
add_child(property_editor);
|
||||||
|
|
||||||
property_editor->connect("variant_changed", this, "_port_edited");
|
property_editor->connect("variant_changed", this, "_port_edited");
|
||||||
|
|
||||||
// BUILD TIMER FOR EXPRESSION NODES
|
|
||||||
|
|
||||||
build_timer = memnew(Timer);
|
|
||||||
add_child(build_timer);
|
|
||||||
build_timer->connect("timeout", this, "_rebuild_timeout");
|
|
||||||
build_timer->set_one_shot(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualShaderEditorPlugin::edit(Object *p_object) {
|
void VisualShaderEditorPlugin::edit(Object *p_object) {
|
||||||
|
|
|
@ -84,8 +84,6 @@ class VisualShaderEditor : public VBoxContainer {
|
||||||
LineEdit *node_filter;
|
LineEdit *node_filter;
|
||||||
RichTextLabel *node_desc;
|
RichTextLabel *node_desc;
|
||||||
|
|
||||||
Timer *build_timer;
|
|
||||||
|
|
||||||
void _tools_menu_option(int p_idx);
|
void _tools_menu_option(int p_idx);
|
||||||
void _show_members_dialog(bool at_mouse_pos);
|
void _show_members_dialog(bool at_mouse_pos);
|
||||||
|
|
||||||
|
@ -184,10 +182,7 @@ class VisualShaderEditor : public VBoxContainer {
|
||||||
void _change_output_port_type(int p_type, int p_node, int p_port);
|
void _change_output_port_type(int p_type, int p_node, int p_port);
|
||||||
void _change_output_port_name(const String &p_text, Object *line_edit, int p_node, int p_port);
|
void _change_output_port_name(const String &p_text, Object *line_edit, int p_node, int p_port);
|
||||||
|
|
||||||
void _start_rebuild_timer(int p_delay);
|
void _expression_focus_out(Object *text_edit, int p_node);
|
||||||
|
|
||||||
void _set_expression(int p_node);
|
|
||||||
void _rebuild_timeout();
|
|
||||||
|
|
||||||
void _set_node_size(int p_type, int p_node, const Size2 &p_size);
|
void _set_node_size(int p_type, int p_node, const Size2 &p_size);
|
||||||
void _node_resized(const Vector2 &p_new_size, int p_type, int p_node);
|
void _node_resized(const Vector2 &p_new_size, int p_type, int p_node);
|
||||||
|
|
Loading…
Reference in a new issue