Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r--source/blender/editors/space_node/drawnode.cc20
-rw-r--r--source/blender/editors/space_node/node_context_path.cc2
-rw-r--r--source/blender/editors/space_node/node_draw.cc47
-rw-r--r--source/blender/editors/space_node/node_edit.cc14
-rw-r--r--source/blender/editors/space_node/node_intern.hh8
-rw-r--r--source/blender/editors/space_node/node_relationships.cc22
6 files changed, 72 insertions, 41 deletions
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc
index 28ac7a34fa8..afb205f9f9e 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -147,7 +147,7 @@ static void node_buts_curvefloat(uiLayout *layout, bContext *UNUSED(C), PointerR
} // namespace blender::ed::space_node
#define SAMPLE_FLT_ISNONE FLT_MAX
-/* Bad bad, 2.5 will do better? ... no it won't! */
+/* Bad! 2.5 will do better? ... no it won't! */
static float _sample_col[4] = {SAMPLE_FLT_ISNONE};
void ED_node_sample_set(const float col[4])
{
@@ -1967,9 +1967,10 @@ void node_draw_link_bezier(const bContext &C,
const bNodeLink &link,
const int th_col1,
const int th_col2,
- const int th_col3)
+ const int th_col3,
+ const bool selected)
{
- const float dim_factor = node_link_dim_factor(v2d, link);
+ const float dim_factor = selected ? 1.0f : node_link_dim_factor(v2d, link);
float thickness = 1.5f;
float dash_factor = 1.0f;
@@ -2025,19 +2026,17 @@ void node_draw_link_bezier(const bContext &C,
}
/* Highlight links connected to selected nodes. */
- const bool is_fromnode_selected = link.fromnode && link.fromnode->flag & SELECT;
- const bool is_tonode_selected = link.tonode && link.tonode->flag & SELECT;
- if (is_fromnode_selected || is_tonode_selected) {
+ if (selected) {
float color_selected[4];
UI_GetThemeColor4fv(TH_EDGE_SELECT, color_selected);
const float alpha = color_selected[3];
/* Interpolate color if highlight color is not fully transparent. */
if (alpha != 0.0) {
- if (is_fromnode_selected) {
+ if (link.fromsock) {
interp_v3_v3v3(colors[1], colors[1], color_selected, alpha);
}
- if (is_tonode_selected) {
+ if (link.tosock) {
interp_v3_v3v3(colors[2], colors[2], color_selected, alpha);
}
}
@@ -2102,7 +2101,8 @@ void node_draw_link_bezier(const bContext &C,
void node_draw_link(const bContext &C,
const View2D &v2d,
const SpaceNode &snode,
- const bNodeLink &link)
+ const bNodeLink &link,
+ const bool selected)
{
int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE;
@@ -2146,7 +2146,7 @@ void node_draw_link(const bContext &C,
}
}
- node_draw_link_bezier(C, v2d, snode, link, th_col1, th_col2, th_col3);
+ node_draw_link_bezier(C, v2d, snode, link, th_col1, th_col2, th_col3, selected);
}
} // namespace blender::ed::space_node
diff --git a/source/blender/editors/space_node/node_context_path.cc b/source/blender/editors/space_node/node_context_path.cc
index a76988a60d0..349fa92d06d 100644
--- a/source/blender/editors/space_node/node_context_path.cc
+++ b/source/blender/editors/space_node/node_context_path.cc
@@ -47,7 +47,7 @@ static void context_path_add_object_data(Vector<ui::ContextPathItem> &path, Obje
Light *light = (Light *)object.data;
ui::context_path_add_generic(path, RNA_Light, light);
}
- if (ELEM(object.type, OB_CURVE, OB_FONT, OB_SURF) && object.data) {
+ if (ELEM(object.type, OB_CURVES_LEGACY, OB_FONT, OB_SURF) && object.data) {
Curve *curve = (Curve *)object.data;
ui::context_path_add_generic(path, RNA_Curve, curve);
}
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index 455eceed293..1286f6a818c 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -660,7 +660,7 @@ static void node_draw_mute_line(const bContext &C,
GPU_blend(GPU_BLEND_ALPHA);
LISTBASE_FOREACH (const bNodeLink *, link, &node.internal_links) {
- node_draw_link_bezier(C, v2d, snode, *link, TH_WIRE_INNER, TH_WIRE_INNER, TH_WIRE);
+ node_draw_link_bezier(C, v2d, snode, *link, TH_WIRE_INNER, TH_WIRE_INNER, TH_WIRE, false);
}
GPU_blend(GPU_BLEND_NONE);
@@ -718,7 +718,12 @@ static void node_socket_draw_multi_input(const float color[4],
const int locx,
const int locy)
{
- const float outline_width = 1.0f;
+ /* The other sockets are drawn with the keyframe shader. There, the outline has a base thickness
+ * that can be varied but always scales with the size the socket is drawn at. Using `U.dpi_fac`
+ * has the the same effect here. It scales the outline correctly across different screen DPIs
+ * and UI scales without being affected by the 'line-width'. */
+ const float outline_width = NODE_SOCK_OUTLINE_SCALE * U.dpi_fac;
+
/* UI_draw_roundbox draws the outline on the outer side, so compensate for the outline width. */
const rctf rect = {
locx - width + outline_width * 0.5f,
@@ -1049,7 +1054,7 @@ static void node_socket_draw_nested(const bContext &C,
},
data,
MEM_freeN);
- /* Disable the button so that clicks on it are ignored the the link operator still works. */
+ /* Disable the button so that clicks on it are ignored the link operator still works. */
UI_but_flag_enable(but, UI_BUT_DISABLED);
UI_block_emboss_set(&block, old_emboss);
}
@@ -1060,7 +1065,7 @@ void ED_node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[
{
using namespace blender::ed::space_node;
- const float size = 2.25f * NODE_SOCKSIZE * scale;
+ const float size = NODE_SOCKSIZE_DRAW_MULIPLIER * NODE_SOCKSIZE * scale;
rcti draw_rect = *rect;
float outline_color[4] = {0};
@@ -1081,7 +1086,7 @@ void ED_node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[
GPU_program_point_size(true);
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_SHAPE);
- immUniform1f("outline_scale", 1.0f);
+ immUniform1f("outline_scale", NODE_SOCK_OUTLINE_SCALE);
immUniform2f("ViewportSize", -1.0f, -1.0f);
/* Single point. */
@@ -1232,13 +1237,14 @@ static void node_draw_sockets(const View2D &v2d,
GPU_blend(GPU_BLEND_ALPHA);
GPU_program_point_size(true);
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_SHAPE);
- immUniform1f("outline_scale", 1.0f);
+ immUniform1f("outline_scale", NODE_SOCK_OUTLINE_SCALE);
immUniform2f("ViewportSize", -1.0f, -1.0f);
/* Set handle size. */
+ const float socket_draw_size = NODE_SOCKSIZE * NODE_SOCKSIZE_DRAW_MULIPLIER;
float scale;
UI_view2d_scale_get(&v2d, &scale, nullptr);
- scale *= 2.25f * NODE_SOCKSIZE;
+ scale *= socket_draw_size;
if (!select_all) {
immBeginAtMost(GPU_PRIM_POINTS, total_input_len + total_output_len);
@@ -1251,7 +1257,10 @@ static void node_draw_sockets(const View2D &v2d,
continue;
}
if (select_all || (sock->flag & SELECT)) {
- selected_input_len++;
+ if (!(sock->flag & SOCK_MULTI_INPUT)) {
+ /* Don't add multi-input sockets here since they are drawn in a different batch. */
+ selected_input_len++;
+ }
continue;
}
/* Don't draw multi-input sockets here since they are drawn in a different batch. */
@@ -1318,6 +1327,10 @@ static void node_draw_sockets(const View2D &v2d,
if (nodeSocketIsHidden(sock)) {
continue;
}
+ /* Don't draw multi-input sockets here since they are drawn in a different batch. */
+ if (sock->flag & SOCK_MULTI_INPUT) {
+ continue;
+ }
if (select_all || (sock->flag & SELECT)) {
node_socket_draw_nested(C,
ntree,
@@ -1383,13 +1396,13 @@ static void node_draw_sockets(const View2D &v2d,
}
const bool is_node_hidden = (node.flag & NODE_HIDDEN);
- const float width = NODE_SOCKSIZE;
+ const float width = 0.5f * socket_draw_size;
float height = is_node_hidden ? width : node_socket_calculate_height(*socket) - width;
float color[4];
float outline_color[4];
node_socket_color_get(C, ntree, node_ptr, *socket, color);
- node_socket_outline_color_get(selected, socket->type, outline_color);
+ node_socket_outline_color_get(socket->flag & SELECT, socket->type, outline_color);
node_socket_draw_multi_input(color, outline_color, width, height, socket->locx, socket->locy);
}
@@ -2650,10 +2663,18 @@ static void node_draw_nodetree(const bContext &C,
nodelink_batch_start(snode);
LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
- if (!nodeLinkIsHidden(link)) {
- node_draw_link(C, region.v2d, snode, *link);
+ if (!nodeLinkIsHidden(link) && !nodeLinkIsSelected(link)) {
+ node_draw_link(C, region.v2d, snode, *link, false);
}
}
+
+ /* Draw selected node links after the unselected ones, so they are shown on top. */
+ LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
+ if (!nodeLinkIsHidden(link) && nodeLinkIsSelected(link)) {
+ node_draw_link(C, region.v2d, snode, *link, true);
+ }
+ }
+
nodelink_batch_end(snode);
GPU_blend(GPU_BLEND_NONE);
@@ -2838,7 +2859,7 @@ void node_draw_space(const bContext &C, ARegion &region)
GPU_line_smooth(true);
if (snode.runtime->linkdrag) {
for (const bNodeLink *link : snode.runtime->linkdrag->links) {
- node_draw_link(C, v2d, snode, *link);
+ node_draw_link(C, v2d, snode, *link, true);
}
}
GPU_line_smooth(false);
diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc
index 7b7aaef518b..b30be6ae0af 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -89,7 +89,7 @@ struct CompoJob {
float node_socket_calculate_height(const bNodeSocket &socket)
{
- float sock_height = NODE_SOCKSIZE * 2.0f;
+ float sock_height = NODE_SOCKSIZE * NODE_SOCKSIZE_DRAW_MULIPLIER;
if (socket.flag & SOCK_MULTI_INPUT) {
sock_height += max_ii(NODE_MULTI_INPUT_LINK_GAP * 0.5f * socket.total_inputs, NODE_SOCKSIZE);
}
@@ -1160,12 +1160,16 @@ bool node_find_indicated_socket(SpaceNode &snode,
{
rctf rect;
+ const float size_sock_padded = NODE_SOCKSIZE + 4;
+
*nodep = nullptr;
*sockp = nullptr;
/* check if we click in a socket */
LISTBASE_FOREACH (bNode *, node, &snode.edittree->nodes) {
- BLI_rctf_init_pt_radius(&rect, cursor, NODE_SOCKSIZE + 4);
+ BLI_rctf_init_pt_radius(&rect, cursor, size_sock_padded);
+ rctf node_visible;
+ BLI_rctf_init_pt_radius(&node_visible, cursor, size_sock_padded);
if (!(node->flag & NODE_HIDDEN)) {
/* extra padding inside and out - allow dragging on the text areas too */
@@ -1184,7 +1188,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
if (!nodeSocketIsHidden(sock)) {
if (sock->flag & SOCK_MULTI_INPUT && !(node->flag & NODE_HIDDEN)) {
if (cursor_isect_multi_input_socket(cursor, *sock)) {
- if (node == visible_node(snode, rect)) {
+ if (node == visible_node(snode, node_visible)) {
*nodep = node;
*sockp = sock;
return true;
@@ -1192,7 +1196,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
}
}
else if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
- if (node == visible_node(snode, rect)) {
+ if (node == visible_node(snode, node_visible)) {
*nodep = node;
*sockp = sock;
return true;
@@ -1205,7 +1209,7 @@ bool node_find_indicated_socket(SpaceNode &snode,
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (!nodeSocketIsHidden(sock)) {
if (BLI_rctf_isect_pt(&rect, sock->locx, sock->locy)) {
- if (node == visible_node(snode, rect)) {
+ if (node == visible_node(snode, node_visible)) {
*nodep = node;
*sockp = sock;
return true;
diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh
index 592db3f7877..319f97e57f5 100644
--- a/source/blender/editors/space_node/node_intern.hh
+++ b/source/blender/editors/space_node/node_intern.hh
@@ -104,6 +104,8 @@ ENUM_OPERATORS(NodeResizeDirection, NODE_RESIZE_LEFT);
#define NODE_HEIGHT(node) (node.height * UI_DPI_FAC)
#define NODE_MARGIN_X (1.2f * U.widget_unit)
#define NODE_SOCKSIZE (0.25f * U.widget_unit)
+#define NODE_SOCKSIZE_DRAW_MULIPLIER 2.25f
+#define NODE_SOCK_OUTLINE_SCALE 1.0f
#define NODE_MULTI_INPUT_LINK_GAP (0.25f * U.widget_unit)
#define NODE_RESIZE_MARGIN (0.20f * U.widget_unit)
#define NODE_LINK_RESOL 12
@@ -196,7 +198,8 @@ void nodelink_batch_end(SpaceNode &snode);
void node_draw_link(const bContext &C,
const View2D &v2d,
const SpaceNode &snode,
- const bNodeLink &link);
+ const bNodeLink &link,
+ bool selected);
/**
* Don't do shadows if th_col3 is -1.
*/
@@ -206,7 +209,8 @@ void node_draw_link_bezier(const bContext &C,
const bNodeLink &link,
int th_col1,
int th_col2,
- int th_col3);
+ int th_col3,
+ bool selected);
/** If v2d not nullptr, it clips and returns 0 if not visible. */
bool node_link_bezier_points(const View2D *v2d,
const SpaceNode *snode,
diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc
index 1cfa932356b..299e7e5658c 100644
--- a/source/blender/editors/space_node/node_relationships.cc
+++ b/source/blender/editors/space_node/node_relationships.cc
@@ -2436,16 +2436,18 @@ void ED_node_link_insert(Main *bmain, ScrArea *area)
bNodeSocket *best_input = get_main_socket(ntree, *node_to_insert, SOCK_IN);
bNodeSocket *best_output = get_main_socket(ntree, *node_to_insert, SOCK_OUT);
- /* Ignore main sockets when the types don't match. */
- if (best_input != nullptr && ntree.typeinfo->validate_link != nullptr &&
- !ntree.typeinfo->validate_link(static_cast<eNodeSocketDatatype>(old_link->fromsock->type),
- static_cast<eNodeSocketDatatype>(best_input->type))) {
- best_input = nullptr;
- }
- if (best_output != nullptr && ntree.typeinfo->validate_link != nullptr &&
- !ntree.typeinfo->validate_link(static_cast<eNodeSocketDatatype>(best_output->type),
- static_cast<eNodeSocketDatatype>(old_link->tosock->type))) {
- best_output = nullptr;
+ if (node_to_insert->type != NODE_REROUTE) {
+ /* Ignore main sockets when the types don't match. */
+ if (best_input != nullptr && ntree.typeinfo->validate_link != nullptr &&
+ !ntree.typeinfo->validate_link(static_cast<eNodeSocketDatatype>(old_link->fromsock->type),
+ static_cast<eNodeSocketDatatype>(best_input->type))) {
+ best_input = nullptr;
+ }
+ if (best_output != nullptr && ntree.typeinfo->validate_link != nullptr &&
+ !ntree.typeinfo->validate_link(static_cast<eNodeSocketDatatype>(best_output->type),
+ static_cast<eNodeSocketDatatype>(old_link->tosock->type))) {
+ best_output = nullptr;
+ }
}
bNode *from_node = old_link->fromnode;