Renamed the mx/my coordinates in SpaceNode to more descriptive 'cursor'. This follows the naming in the View3D space, since this vector is used for essentially the same purpose (adding nodes at a specific location), although not used for any transform origin and not displayed in the editor.
Note: While renaming DNA properties is usually dangerous and can break files, in this case it is possible because the mx/my values are only used at runtime.
This commit is contained in:
@@ -3185,8 +3185,7 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa
|
||||
}
|
||||
else {
|
||||
if (snode == NULL) return 0;
|
||||
vec[0][0] = snode->mx;
|
||||
vec[0][1] = snode->my;
|
||||
copy_v2_v2(vec[0], snode->cursor);
|
||||
fromreroute = 0;
|
||||
}
|
||||
if (link->tosock) {
|
||||
@@ -3196,8 +3195,7 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa
|
||||
}
|
||||
else {
|
||||
if (snode == NULL) return 0;
|
||||
vec[3][0] = snode->mx;
|
||||
vec[3][1] = snode->my;
|
||||
copy_v2_v2(vec[3], snode->cursor);
|
||||
toreroute = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -273,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");
|
||||
@@ -296,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);
|
||||
|
||||
@@ -989,11 +989,11 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode)
|
||||
else {
|
||||
/* check nodes front to back */
|
||||
for (node = ntree->nodes.last; node; node = node->prev) {
|
||||
if (BLI_in_rctf(&node->totr, snode->mx, snode->my))
|
||||
if (BLI_in_rctf(&node->totr, snode->cursor[0], snode->cursor[1]))
|
||||
break; /* first hit on node stops */
|
||||
}
|
||||
if (node) {
|
||||
int dir = node->typeinfo->resize_area_func(node, snode->mx, snode->my);
|
||||
int dir = node->typeinfo->resize_area_func(node, snode->cursor[0], snode->cursor[1]);
|
||||
cursor = node_get_resize_cursor(dir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,8 +797,8 @@ static void node_resize_init(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
|
||||
NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data");
|
||||
|
||||
op->customdata = nsw;
|
||||
nsw->mxstart = snode->mx;
|
||||
nsw->mystart = snode->my;
|
||||
nsw->mxstart = snode->cursor[0];
|
||||
nsw->mystart = snode->cursor[1];
|
||||
|
||||
/* store old */
|
||||
nsw->oldlocx = node->locx;
|
||||
@@ -936,8 +936,8 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
if (node) {
|
||||
/* convert mouse coordinates to v2d space */
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
|
||||
&snode->mx, &snode->my);
|
||||
dir = node->typeinfo->resize_area_func(node, snode->mx, snode->my);
|
||||
&snode->cursor[0], &snode->cursor[1]);
|
||||
dir = node->typeinfo->resize_area_func(node, snode->cursor[0], snode->cursor[1]);
|
||||
if (dir != 0) {
|
||||
node_resize_init(C, op, event, node, dir);
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
@@ -1051,10 +1051,10 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so
|
||||
/* check if we click in a socket */
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
|
||||
rect.xmin = snode->mx - (NODE_SOCKSIZE + 4);
|
||||
rect.ymin = snode->my - (NODE_SOCKSIZE + 4);
|
||||
rect.xmax = snode->mx + (NODE_SOCKSIZE + 4);
|
||||
rect.ymax = snode->my + (NODE_SOCKSIZE + 4);
|
||||
rect.xmin = snode->cursor[0] - (NODE_SOCKSIZE + 4);
|
||||
rect.ymin = snode->cursor[1] - (NODE_SOCKSIZE + 4);
|
||||
rect.xmax = snode->cursor[0] + (NODE_SOCKSIZE + 4);
|
||||
rect.ymax = snode->cursor[1] + (NODE_SOCKSIZE + 4);
|
||||
|
||||
if (!(node->flag & NODE_HIDDEN)) {
|
||||
/* extra padding inside and out - allow dragging on the text areas too */
|
||||
@@ -2052,8 +2052,8 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* place nodes around the mouse cursor. child nodes locations are relative to parent */
|
||||
if (!new_node->parent) {
|
||||
new_node->locx += snode->mx - centerx - gnode_x;
|
||||
new_node->locy += snode->my - centery - gnode_y;
|
||||
new_node->locx += snode->cursor[0] - centerx - gnode_x;
|
||||
new_node->locy += snode->cursor[1] - centery - gnode_y;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2076,7 +2076,7 @@ static int node_clipboard_paste_invoke(bContext *C, wmOperator *op, wmEvent *eve
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
/* convert mouse coordinates to v2d space */
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my);
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->cursor[0], &snode->cursor[1]);
|
||||
|
||||
return node_clipboard_paste_exec(C, op);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp)
|
||||
int y = win->eventstate->y - ar->winrct.ymin;
|
||||
|
||||
if (y < 60) y += 60;
|
||||
UI_view2d_region_to_view(&ar->v2d, x, y, &snode->mx, &snode->my);
|
||||
UI_view2d_region_to_view(&ar->v2d, x, y, &snode->cursor[0], &snode->cursor[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp)
|
||||
else node->flag &= ~NODE_TEST;
|
||||
}
|
||||
|
||||
/* 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]);
|
||||
|
||||
/* select previous selection before autoconnect */
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
|
||||
@@ -437,10 +437,10 @@ static int outside_group_rect(SpaceNode *snode)
|
||||
{
|
||||
bNode *gnode = node_tree_get_editgroup(snode->nodetree);
|
||||
if (gnode) {
|
||||
return (snode->mx < gnode->totr.xmin ||
|
||||
snode->mx >= gnode->totr.xmax ||
|
||||
snode->my < gnode->totr.ymin ||
|
||||
snode->my >= gnode->totr.ymax);
|
||||
return (snode->cursor[0] < gnode->totr.xmin ||
|
||||
snode->cursor[0] >= gnode->totr.xmax ||
|
||||
snode->cursor[1] < gnode->totr.ymin ||
|
||||
snode->cursor[1] >= gnode->totr.ymax);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -462,7 +462,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
in_out = nldrag->in_out;
|
||||
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
|
||||
&snode->mx, &snode->my);
|
||||
&snode->cursor[0], &snode->cursor[1]);
|
||||
|
||||
switch (event->type) {
|
||||
case MOUSEMOVE:
|
||||
@@ -708,7 +708,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
int detach = RNA_boolean_get(op->ptr, "detach");
|
||||
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
|
||||
&snode->mx, &snode->my);
|
||||
&snode->cursor[0], &snode->cursor[1]);
|
||||
|
||||
ED_preview_kill_jobs(C);
|
||||
|
||||
@@ -1139,7 +1139,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/* skip selected, those are the nodes we want to attach */
|
||||
if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT))
|
||||
continue;
|
||||
if (BLI_in_rctf(&frame->totr, snode->mx, snode->my))
|
||||
if (BLI_in_rctf(&frame->totr, snode->cursor[0], snode->cursor[1]))
|
||||
break;
|
||||
}
|
||||
if (frame) {
|
||||
@@ -1185,7 +1185,7 @@ static int node_attach_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
/* convert mouse coordinates to v2d space */
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my);
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->cursor[0], &snode->cursor[1]);
|
||||
|
||||
return node_attach_exec(C, op);
|
||||
}
|
||||
|
||||
@@ -330,8 +330,8 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i
|
||||
/* get mouse coordinates in view2d space */
|
||||
UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &mx, &my);
|
||||
/* node_find_indicated_socket uses snode->mx/my */
|
||||
snode->mx = mx;
|
||||
snode->my = my;
|
||||
snode->cursor[0] = mx;
|
||||
snode->cursor[1] = my;
|
||||
|
||||
if (extend) {
|
||||
/* first do socket selection, these generally overlap with nodes.
|
||||
|
||||
@@ -337,7 +337,7 @@ static void node_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
|
||||
|
||||
/* convert mouse coordinates to v2d space */
|
||||
UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin,
|
||||
&snode->mx, &snode->my);
|
||||
&snode->cursor[0], &snode->cursor[1]);
|
||||
|
||||
node_set_cursor(win, snode);
|
||||
}
|
||||
|
||||
@@ -879,7 +879,7 @@ typedef struct SpaceNode {
|
||||
|
||||
float xof, yof; /* offset for drawing the backdrop */
|
||||
float zoom; /* zoom for backdrop */
|
||||
float mx, my; /* mousepos for drawing socketless link */
|
||||
float cursor[2]; /* mouse pos for drawing socketless link and adding nodes */
|
||||
|
||||
struct bNodeTree *nodetree, *edittree;
|
||||
int treetype; /* treetype: as same nodetree->type */
|
||||
|
||||
@@ -3015,8 +3015,7 @@ static void rna_def_space_node(BlenderRNA *brna)
|
||||
|
||||
/* the mx/my "cursor" in the node editor is used only by operators to store the mouse position */
|
||||
prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "mx");
|
||||
RNA_def_property_array(prop, 2);
|
||||
RNA_def_property_float_sdna(prop, NULL, "cursor");
|
||||
RNA_def_property_ui_text(prop, "Cursor Location", "Location for adding new nodes");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user