Renamed the mx/my coordinates in SpaceNode to more descriptive 'cursor'. This follows...
[blender.git] / source / blender / editors / space_node / node_add.c
index 20429d832b570457bb6056770a6fe8e5667bf957..7d007d024abe38c09ea180915b6fc01d8ee37b12 100644 (file)
@@ -155,13 +155,14 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
                bNodeLink *link;
                float insertPoint[2];
 
-               ED_preview_kill_jobs(C);
-
                for (link = snode->edittree->links.first; link; link = link->next) {
                        if (add_reroute_intersect_check(link, mcoords, i, insertPoint)) {
                                bNodeTemplate ntemp;
                                bNode *rerouteNode;
 
+                               /* always first */
+                               ED_preview_kill_jobs(C);
+
                                node_deselect_all(snode);
 
                                ntemp.type = NODE_REROUTE;
@@ -178,15 +179,17 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
                                link->fromnode = rerouteNode;
                                link->fromsock = rerouteNode->outputs.first;
 
-                               break; // add one reroute at the time.
+                               /* always last */
+                               ntreeUpdateTree(snode->edittree);
+                               snode_notify(C, snode);
+                               snode_dag_update(C, snode);
+
+                               return OPERATOR_FINISHED; // add one reroute at the time.
                        }
                }
 
-               ntreeUpdateTree(snode->edittree);
-               snode_notify(C, snode);
-               snode_dag_update(C, snode);
+               return OPERATOR_CANCELLED;
 
-               return OPERATOR_FINISHED;
        }
 
        return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
@@ -270,7 +273,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
 
        ED_preview_kill_jobs(C);
 
-       node = node_add_node(snode, bmain, scene, &ntemp, snode->mx, snode->my);
+       node = node_add_node(snode, bmain, scene, &ntemp, snode->cursor[0], snode->cursor[1]);
 
        if (!node) {
                BKE_report(op->reports, RPT_WARNING, "Could not add an image node");
@@ -293,7 +296,7 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        /* convert mouse coordinates to v2d space */
        UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
-                                &snode->mx, &snode->my);
+                                &snode->cursor[0], &snode->cursor[1]);
 
        if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name"))
                return node_add_file_exec(C, op);
@@ -316,7 +319,8 @@ void NODE_OT_add_file(wmOperatorType *ot)
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
-       WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);  //XXX TODO, relative_path
+       WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE,
+                                      WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);  //XXX TODO, relative_path
        RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Datablock name to assign");
 }