[Bf-blender-cvs] [3b23685c7dc] master: Cleanup: simplify node modal select implementation

Brecht Van Lommel noreply at git.blender.org
Tue Oct 1 21:53:31 CEST 2019


Commit: 3b23685c7dc16588bcc18045a1ba8c01671574c3
Author: Brecht Van Lommel
Date:   Tue Oct 1 21:47:19 2019 +0200
Branches: master
https://developer.blender.org/rB3b23685c7dc16588bcc18045a1ba8c01671574c3

Cleanup: simplify node modal select implementation

Ref T63994

===================================================================

M	source/blender/editors/space_node/node_select.c

===================================================================

diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 450cf28cce1..b66cd0d3069 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -430,11 +430,9 @@ void node_select_single(bContext *C, bNode *node)
 }
 
 static int node_mouse_select(bContext *C,
+                             wmOperator *op,
                              const int mval[2],
-                             const bool extend,
-                             const bool socket_select,
-                             const bool deselect_all,
-                             const bool wait_to_deselect_others)
+                             bool wait_to_deselect_others)
 {
   Main *bmain = CTX_data_main(C);
   SpaceNode *snode = CTX_wm_space_node(C);
@@ -445,8 +443,15 @@ static int node_mouse_select(bContext *C,
   float cursor[2];
   int ret_value = OPERATOR_CANCELLED;
 
-  /* Waiting to deselect others is only allowed for basic selection. */
-  BLI_assert(!(extend || socket_select) || !wait_to_deselect_others);
+  const bool extend = RNA_boolean_get(op->ptr, "extend");
+  /* always do socket_select when extending selection. */
+  const bool socket_select = extend || RNA_boolean_get(op->ptr, "socket_select");
+  const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
+
+  /* These cases are never modal. */
+  if (extend || socket_select) {
+    wait_to_deselect_others = false;
+  }
 
   /* get mouse coordinates in view2d space */
   UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &cursor[0], &cursor[1]);
@@ -552,19 +557,13 @@ static int node_mouse_select(bContext *C,
 
 static int node_select_exec(bContext *C, wmOperator *op)
 {
-  int mval[2];
-
   /* get settings from RNA properties for operator */
+  int mval[2];
   mval[0] = RNA_int_get(op->ptr, "mouse_x");
   mval[1] = RNA_int_get(op->ptr, "mouse_y");
 
-  const bool extend = RNA_boolean_get(op->ptr, "extend");
-  /* always do socket_select when extending selection. */
-  const bool socket_select = extend || RNA_boolean_get(op->ptr, "socket_select");
-  const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
-
   /* perform the select */
-  const int ret_value = node_mouse_select(C, mval, extend, socket_select, deselect_all, false);
+  const int ret_value = node_mouse_select(C, op, mval, false);
 
   /* allow tweak event to work too */
   return ret_value | OPERATOR_PASS_THROUGH;
@@ -579,19 +578,9 @@ static int node_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
   mval[0] = RNA_int_get(op->ptr, "mouse_x");
   mval[1] = RNA_int_get(op->ptr, "mouse_y");
 
-  const bool extend = RNA_boolean_get(op->ptr, "extend");
-  /* always do socket_select when extending selection. */
-  const bool socket_select = extend || RNA_boolean_get(op->ptr, "socket_select");
-  const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
-
-  /* These cases are never modal. */
-  if (extend || socket_select) {
-    return node_select_exec(C, op);
-  }
-
   if (init_event_type == 0) {
     if (event->val == KM_PRESS) {
-      const int ret_value = node_mouse_select(C, mval, extend, socket_select, deselect_all, true);
+      const int ret_value = node_mouse_select(C, op, mval, true);
 
       op->customdata = POINTER_FROM_INT((int)event->type);
       if (ret_value & OPERATOR_RUNNING_MODAL) {
@@ -603,11 +592,12 @@ static int node_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
       /* If we are in init phase, and cannot validate init of modal operations,
        * just fall back to basic exec.
        */
-      return node_select_exec(C, op);
+      const int ret_value = node_mouse_select(C, op, mval, false);
+      return ret_value | OPERATOR_PASS_THROUGH;
     }
   }
   else if (event->type == init_event_type && event->val == KM_RELEASE) {
-    const int ret_value = node_mouse_select(C, mval, extend, socket_select, deselect_all, false);
+    const int ret_value = node_mouse_select(C, op, mval, false);
     return ret_value | OPERATOR_PASS_THROUGH;
   }
   else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {



More information about the Bf-blender-cvs mailing list