Add node list param to GraphEdit::delete_nodes_request signal
This commit is contained in:
parent
e86d840d4f
commit
32b9818965
|
@ -212,8 +212,9 @@
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="delete_nodes_request">
|
<signal name="delete_nodes_request">
|
||||||
|
<argument index="0" name="nodes" type="Array" />
|
||||||
<description>
|
<description>
|
||||||
Emitted when a GraphNode is attempted to be removed from the GraphEdit.
|
Emitted when a GraphNode is attempted to be removed from the GraphEdit. Provides a list of node names to be removed (all selected nodes, excluding nodes without closing button).
|
||||||
</description>
|
</description>
|
||||||
</signal>
|
</signal>
|
||||||
<signal name="disconnection_request">
|
<signal name="disconnection_request">
|
||||||
|
|
|
@ -1950,10 +1950,11 @@ void VisualShaderEditor::_paste_nodes() {
|
||||||
_dup_update_excluded(type, copy_nodes_excluded_buffer); // to prevent selection of previous copies at new paste
|
_dup_update_excluded(type, copy_nodes_excluded_buffer); // to prevent selection of previous copies at new paste
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualShaderEditor::_on_nodes_delete() {
|
void VisualShaderEditor::_on_nodes_delete(const Array &p_nodes) {
|
||||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||||
List<int> to_erase;
|
List<int> to_erase;
|
||||||
|
|
||||||
|
if (p_nodes.empty()) {
|
||||||
for (int i = 0; i < graph->get_child_count(); i++) {
|
for (int i = 0; i < graph->get_child_count(); i++) {
|
||||||
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
|
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
|
||||||
if (gn) {
|
if (gn) {
|
||||||
|
@ -1962,6 +1963,11 @@ void VisualShaderEditor::_on_nodes_delete() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < p_nodes.size(); i++) {
|
||||||
|
to_erase.push_back(p_nodes[i].operator String().to_int());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (to_erase.empty()) {
|
if (to_erase.empty()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -183,7 +183,7 @@ class VisualShaderEditor : public VBoxContainer {
|
||||||
void _node_selected(Object *p_node);
|
void _node_selected(Object *p_node);
|
||||||
|
|
||||||
void _delete_request(int);
|
void _delete_request(int);
|
||||||
void _on_nodes_delete();
|
void _on_nodes_delete(const Array &p_nodes);
|
||||||
|
|
||||||
void _node_changed(int p_id);
|
void _node_changed(int p_id);
|
||||||
|
|
||||||
|
|
|
@ -1831,11 +1831,12 @@ void VisualScriptEditor::_on_nodes_paste() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualScriptEditor::_on_nodes_delete() {
|
void VisualScriptEditor::_on_nodes_delete(const Array &p_nodes) {
|
||||||
// delete all the selected nodes
|
// delete all the selected nodes
|
||||||
|
|
||||||
List<int> to_erase;
|
List<int> to_erase;
|
||||||
|
|
||||||
|
if (p_nodes.empty()) {
|
||||||
for (int i = 0; i < graph->get_child_count(); i++) {
|
for (int i = 0; i < graph->get_child_count(); i++) {
|
||||||
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
|
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
|
||||||
if (gn) {
|
if (gn) {
|
||||||
|
@ -1844,6 +1845,11 @@ void VisualScriptEditor::_on_nodes_delete() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < graph->get_child_count(); i++) {
|
||||||
|
to_erase.push_back(p_nodes[i].operator String().to_int());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (to_erase.empty()) {
|
if (to_erase.empty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -4253,7 +4259,7 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_
|
||||||
void VisualScriptEditor::_menu_option(int p_what) {
|
void VisualScriptEditor::_menu_option(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case EDIT_DELETE_NODES: {
|
case EDIT_DELETE_NODES: {
|
||||||
_on_nodes_delete();
|
_on_nodes_delete(Array());
|
||||||
} break;
|
} break;
|
||||||
case EDIT_TOGGLE_BREAKPOINT: {
|
case EDIT_TOGGLE_BREAKPOINT: {
|
||||||
List<String> reselect;
|
List<String> reselect;
|
||||||
|
@ -4288,7 +4294,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
|
||||||
} break;
|
} break;
|
||||||
case EDIT_CUT_NODES: {
|
case EDIT_CUT_NODES: {
|
||||||
_on_nodes_copy();
|
_on_nodes_copy();
|
||||||
_on_nodes_delete();
|
_on_nodes_delete(Array());
|
||||||
} break;
|
} break;
|
||||||
case EDIT_PASTE_NODES: {
|
case EDIT_PASTE_NODES: {
|
||||||
_on_nodes_paste();
|
_on_nodes_paste();
|
||||||
|
|
|
@ -257,7 +257,7 @@ class VisualScriptEditor : public ScriptEditorBase {
|
||||||
|
|
||||||
void _on_nodes_copy();
|
void _on_nodes_copy();
|
||||||
void _on_nodes_paste();
|
void _on_nodes_paste();
|
||||||
void _on_nodes_delete();
|
void _on_nodes_delete(const Array &p_nodes);
|
||||||
void _on_nodes_duplicate();
|
void _on_nodes_duplicate();
|
||||||
|
|
||||||
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
||||||
|
|
|
@ -1370,7 +1370,18 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k->get_scancode() == KEY_DELETE && k->is_pressed()) {
|
if (k->get_scancode() == KEY_DELETE && k->is_pressed()) {
|
||||||
emit_signal("delete_nodes_request");
|
Array nodes;
|
||||||
|
|
||||||
|
for (int i = 0; i < get_child_count(); i++) {
|
||||||
|
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i));
|
||||||
|
if (gn) {
|
||||||
|
if (gn->is_selected() && gn->is_close_button_visible()) {
|
||||||
|
nodes.push_back(gn->get_name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit_signal("delete_nodes_request", nodes);
|
||||||
accept_event();
|
accept_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1746,7 +1757,7 @@ void GraphEdit::_bind_methods() {
|
||||||
ADD_SIGNAL(MethodInfo("node_unselected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
ADD_SIGNAL(MethodInfo("node_unselected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
|
||||||
ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
|
ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
|
||||||
ADD_SIGNAL(MethodInfo("connection_from_empty", PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
|
ADD_SIGNAL(MethodInfo("connection_from_empty", PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
|
||||||
ADD_SIGNAL(MethodInfo("delete_nodes_request"));
|
ADD_SIGNAL(MethodInfo("delete_nodes_request", PropertyInfo(Variant::ARRAY, "nodes")));
|
||||||
ADD_SIGNAL(MethodInfo("_begin_node_move"));
|
ADD_SIGNAL(MethodInfo("_begin_node_move"));
|
||||||
ADD_SIGNAL(MethodInfo("_end_node_move"));
|
ADD_SIGNAL(MethodInfo("_end_node_move"));
|
||||||
ADD_SIGNAL(MethodInfo("scroll_offset_changed", PropertyInfo(Variant::VECTOR2, "ofs")));
|
ADD_SIGNAL(MethodInfo("scroll_offset_changed", PropertyInfo(Variant::VECTOR2, "ofs")));
|
||||||
|
|
Loading…
Reference in New Issue