diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_node/node_edit.cc | 37 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.hh | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_select.cc | 40 |
3 files changed, 38 insertions, 41 deletions
diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 984eecc229c..f07a1205c6b 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -1473,43 +1473,6 @@ void NODE_OT_duplicate(wmOperatorType *ot) ot->srna, "keep_inputs", false, "Keep Inputs", "Keep the input links to duplicated nodes"); } -static bool node_select_check(const ListBase *lb) -{ - LISTBASE_FOREACH (const bNode *, node, lb) { - if (node->flag & NODE_SELECT) { - return true; - } - } - - return false; -} - -void node_select_all(ListBase *lb, int action) -{ - if (action == SEL_TOGGLE) { - if (node_select_check(lb)) { - action = SEL_DESELECT; - } - else { - action = SEL_SELECT; - } - } - - LISTBASE_FOREACH (bNode *, node, lb) { - switch (action) { - case SEL_SELECT: - nodeSetSelected(node, true); - break; - case SEL_DESELECT: - nodeSetSelected(node, false); - break; - case SEL_INVERT: - nodeSetSelected(node, !(node->flag & SELECT)); - break; - } - } -} - /* XXX: some code needing updating to operators. */ /* goes over all scenes, reads render layers */ diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh index 6754673cffc..c4f3227f274 100644 --- a/source/blender/editors/space_node/node_intern.hh +++ b/source/blender/editors/space_node/node_intern.hh @@ -288,8 +288,6 @@ float2 node_link_calculate_multi_input_position(const float2 &socket_position, int index, int total_inputs); -void node_select_all(ListBase *lb, int action); - float node_socket_calculate_height(const bNodeSocket &socket); void snode_set_context(const bContext &C); diff --git a/source/blender/editors/space_node/node_select.cc b/source/blender/editors/space_node/node_select.cc index 9ef26f963c5..563dadc511a 100644 --- a/source/blender/editors/space_node/node_select.cc +++ b/source/blender/editors/space_node/node_select.cc @@ -22,6 +22,7 @@ #include "BKE_context.h" #include "BKE_main.h" #include "BKE_node.h" +#include "BKE_node_runtime.hh" #include "BKE_workspace.h" #include "ED_node.h" /* own include */ @@ -1034,13 +1035,48 @@ void NODE_OT_select_lasso(wmOperatorType *ot) /** \name (De)select All Operator * \{ */ +static bool any_node_selected(const bNodeTree &node_tree) +{ + for (const bNode *node : node_tree.all_nodes()) { + if (node->flag & NODE_SELECT) { + return true; + } + } + return false; +} + static int node_select_all_exec(bContext *C, wmOperator *op) { SpaceNode &snode = *CTX_wm_space_node(C); - ListBase *node_lb = &snode.edittree->nodes; + bNodeTree &node_tree = *snode.edittree; + + node_tree.ensure_topology_cache(); + int action = RNA_enum_get(op->ptr, "action"); + if (action == SEL_TOGGLE) { + if (any_node_selected(node_tree)) { + action = SEL_DESELECT; + } + else { + action = SEL_SELECT; + } + } - node_select_all(node_lb, action); + switch (action) { + case SEL_SELECT: + for (bNode *node : node_tree.all_nodes()) { + nodeSetSelected(node, true); + } + break; + case SEL_DESELECT: + node_deselect_all(snode); + break; + case SEL_INVERT: + for (bNode *node : node_tree.all_nodes()) { + nodeSetSelected(node, !(node->flag & SELECT)); + } + break; + } node_sort(*snode.edittree); |