diff options
-rw-r--r-- | source/blender/editors/space_node/drawnode.cc | 42 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.cc | 22 |
2 files changed, 14 insertions, 50 deletions
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 365a17c0a04..d4b7640cfe3 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -1556,7 +1556,6 @@ bool node_link_bezier_handles(const View2D *v2d, } /* in v0 and v3 we put begin/end points */ - int toreroute, fromreroute; if (link.fromsock) { vec[0][0] = link.fromsock->locx; vec[0][1] = link.fromsock->locy; @@ -1567,14 +1566,12 @@ bool node_link_bezier_handles(const View2D *v2d, link.fromsock->total_inputs); copy_v2_v2(vec[0], position); } - fromreroute = (link.fromnode && link.fromnode->type == NODE_REROUTE); } else { if (snode == nullptr) { return false; } copy_v2_v2(vec[0], cursor); - fromreroute = 0; } if (link.tosock) { vec[3][0] = link.tosock->locx; @@ -1586,14 +1583,12 @@ bool node_link_bezier_handles(const View2D *v2d, link.tosock->total_inputs); copy_v2_v2(vec[3], position); } - toreroute = (link.tonode && link.tonode->type == NODE_REROUTE); } else { if (snode == nullptr) { return false; } copy_v2_v2(vec[3], cursor); - toreroute = 0; } /* may be called outside of drawing (so pass spacetype) */ @@ -1607,37 +1602,12 @@ bool node_link_bezier_handles(const View2D *v2d, } const float dist = curving * 0.10f * fabsf(vec[0][0] - vec[3][0]); - const float deltax = vec[3][0] - vec[0][0]; - const float deltay = vec[3][1] - vec[0][1]; - /* check direction later, for top sockets */ - if (fromreroute) { - if (fabsf(deltax) > fabsf(deltay)) { - vec[1][1] = vec[0][1]; - vec[1][0] = vec[0][0] + (deltax > 0 ? dist : -dist); - } - else { - vec[1][0] = vec[0][0]; - vec[1][1] = vec[0][1] + (deltay > 0 ? dist : -dist); - } - } - else { - vec[1][0] = vec[0][0] + dist; - vec[1][1] = vec[0][1]; - } - if (toreroute) { - if (fabsf(deltax) > fabsf(deltay)) { - vec[2][1] = vec[3][1]; - vec[2][0] = vec[3][0] + (deltax > 0 ? -dist : dist); - } - else { - vec[2][0] = vec[3][0]; - vec[2][1] = vec[3][1] + (deltay > 0 ? -dist : dist); - } - } - else { - vec[2][0] = vec[3][0] - dist; - vec[2][1] = vec[3][1]; - } + + vec[1][0] = vec[0][0] + dist; + vec[1][1] = vec[0][1]; + + vec[2][0] = vec[3][0] - dist; + vec[2][1] = vec[3][1]; if (v2d && min_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) { return false; /* clipped */ diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 7f0c426922b..d39304284ad 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -2574,20 +2574,14 @@ static void reroute_node_draw( if (node.label[0] != '\0') { /* draw title (node label) */ BLI_strncpy(showname, node.label, sizeof(showname)); - uiDefBut(&block, - UI_BTYPE_LABEL, - 0, - showname, - (int)(rct.xmin - NODE_DYS), - (int)(rct.ymax), - (short)512, - (short)NODE_DY, - nullptr, - 0, - 0, - 0, - 0, - nullptr); + const short width = 512; + const int x = BLI_rctf_cent_x(&node.totr) - (width / 2); + const int y = node.totr.ymax; + + uiBut *label_but = uiDefBut( + &block, UI_BTYPE_LABEL, 0, showname, x, y, width, (short)NODE_DY, NULL, 0, 0, 0, 0, NULL); + + UI_but_drawflag_disable(label_but, UI_BUT_TEXT_LEFT); } /* only draw input socket. as they all are placed on the same position. |