UI: Fix cosmetic papercuts of the reroute node
Fix small cosmetic issues with the reroute node: 1. Remove special case that allowed curved links to attach vertically. 2. Center align the reroute node's label. The vertically attached node links could lead to kinks in the otherwise smooth curves. This would break the visual flow and make the link potentially intersect the node's label. The center alignment of the label gives more consistent results for different label lengths and also reduces the chance of the label interfering with the node links. Reviewed By: Hans Goudey, Pablo Vazquez Differential Revision: D14457
This commit is contained in:
parent
08b4b657b6
commit
ee1d5fb9e4
Notes:
blender-bot
2023-03-24 17:05:22 +01:00
Referenced by issue #98779, UI: Reroutes not connecting as expected, always defaulting to "s" shape Referenced by issue #98230, Regression: Automatic Constraint doesn't work if cursor is not moving
|
@ -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 */
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue