Merge branch 'master' into refactor-mesh-position-generic
This commit is contained in:
commit
11e3f22c3d
|
@ -169,7 +169,10 @@ class bNodeSocketRuntime : NonCopyable, NonMovable {
|
|||
float locx = 0;
|
||||
float locy = 0;
|
||||
|
||||
/* Runtime-only cache of the number of input links, for multi-input sockets. */
|
||||
/**
|
||||
* Runtime-only cache of the number of input links, for multi-input sockets,
|
||||
* including dragged node links that aren't actually in the tree.
|
||||
*/
|
||||
short total_inputs = 0;
|
||||
|
||||
/** Only valid when #topology_cache_is_dirty is false. */
|
||||
|
|
|
@ -182,11 +182,9 @@ void ED_node_tag_update_id(ID *id)
|
|||
|
||||
namespace blender::ed::space_node {
|
||||
|
||||
static void node_socket_add_tooltip_in_node_editor(TreeDrawContext * /*tree_draw_ctx*/,
|
||||
const bNodeTree *ntree,
|
||||
const bNode *node,
|
||||
const bNodeSocket *sock,
|
||||
uiLayout *layout);
|
||||
static void node_socket_add_tooltip_in_node_editor(const bNodeTree &ntree,
|
||||
const bNodeSocket &sock,
|
||||
uiLayout &layout);
|
||||
|
||||
/** Return true when \a a should be behind \a b and false otherwise. */
|
||||
static bool compare_node_depth(const bNode *a, const bNode *b)
|
||||
|
@ -273,7 +271,7 @@ void node_sort(bNodeTree &ntree)
|
|||
}
|
||||
}
|
||||
|
||||
static Array<uiBlock *> node_uiblocks_init(const bContext &C, Span<bNode *> nodes)
|
||||
static Array<uiBlock *> node_uiblocks_init(const bContext &C, const Span<bNode *> nodes)
|
||||
{
|
||||
Array<uiBlock *> blocks(nodes.size());
|
||||
/* Add node uiBlocks in drawing order - prevents events going to overlapping nodes. */
|
||||
|
@ -318,7 +316,7 @@ float2 node_from_view(const bNode &node, const float2 &co)
|
|||
* Based on settings and sockets in node, set drawing rect info.
|
||||
*/
|
||||
static void node_update_basis(const bContext &C,
|
||||
TreeDrawContext &tree_draw_ctx,
|
||||
const TreeDrawContext & /*tree_draw_ctx*/,
|
||||
bNodeTree &ntree,
|
||||
bNode &node,
|
||||
uiBlock &block)
|
||||
|
@ -350,7 +348,7 @@ static void node_update_basis(const bContext &C,
|
|||
bool add_output_space = false;
|
||||
|
||||
int buty;
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node.outputs) {
|
||||
for (bNodeSocket *socket : node.output_sockets()) {
|
||||
if (!socket->is_visible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -382,7 +380,7 @@ static void node_update_basis(const bContext &C,
|
|||
const char *socket_label = nodeSocketLabel(socket);
|
||||
socket->typeinfo->draw((bContext *)&C, row, &sockptr, &nodeptr, IFACE_(socket_label));
|
||||
|
||||
node_socket_add_tooltip_in_node_editor(&tree_draw_ctx, &ntree, &node, socket, row);
|
||||
node_socket_add_tooltip_in_node_editor(ntree, *socket, *row);
|
||||
|
||||
UI_block_align_end(&block);
|
||||
UI_block_layout_resolve(&block, nullptr, &buty);
|
||||
|
@ -473,7 +471,7 @@ static void node_update_basis(const bContext &C,
|
|||
}
|
||||
|
||||
/* Input sockets. */
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) {
|
||||
for (bNodeSocket *socket : node.input_sockets()) {
|
||||
if (!socket->is_visible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -515,7 +513,7 @@ static void node_update_basis(const bContext &C,
|
|||
const char *socket_label = nodeSocketLabel(socket);
|
||||
socket->typeinfo->draw((bContext *)&C, row, &sockptr, &nodeptr, IFACE_(socket_label));
|
||||
|
||||
node_socket_add_tooltip_in_node_editor(&tree_draw_ctx, &ntree, &node, socket, row);
|
||||
node_socket_add_tooltip_in_node_editor(ntree, *socket, *row);
|
||||
|
||||
UI_block_align_end(&block);
|
||||
UI_block_layout_resolve(&block, nullptr, &buty);
|
||||
|
@ -566,12 +564,12 @@ static void node_update_hidden(bNode &node, uiBlock &block)
|
|||
loc.y = round(loc.y);
|
||||
|
||||
/* Calculate minimal radius. */
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) {
|
||||
for (const bNodeSocket *socket : node.input_sockets()) {
|
||||
if (socket->is_visible()) {
|
||||
totin++;
|
||||
}
|
||||
}
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node.outputs) {
|
||||
for (const bNodeSocket *socket : node.output_sockets()) {
|
||||
if (socket->is_visible()) {
|
||||
totout++;
|
||||
}
|
||||
|
@ -592,7 +590,7 @@ static void node_update_hidden(bNode &node, uiBlock &block)
|
|||
float rad = float(M_PI) / (1.0f + float(totout));
|
||||
float drad = rad;
|
||||
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node.outputs) {
|
||||
for (bNodeSocket *socket : node.output_sockets()) {
|
||||
if (socket->is_visible()) {
|
||||
/* Round the socket location to stop it from jiggling. */
|
||||
socket->runtime->locx = round(node.runtime->totr.xmax - hiddenrad + sinf(rad) * hiddenrad);
|
||||
|
@ -604,7 +602,7 @@ static void node_update_hidden(bNode &node, uiBlock &block)
|
|||
/* Input sockets. */
|
||||
rad = drad = -float(M_PI) / (1.0f + float(totin));
|
||||
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) {
|
||||
for (bNodeSocket *socket : node.input_sockets()) {
|
||||
if (socket->is_visible()) {
|
||||
/* Round the socket location to stop it from jiggling. */
|
||||
socket->runtime->locx = round(node.runtime->totr.xmin + hiddenrad + sinf(rad) * hiddenrad);
|
||||
|
@ -784,17 +782,12 @@ void node_socket_color_get(const bContext &C,
|
|||
{
|
||||
PointerRNA ptr;
|
||||
BLI_assert(RNA_struct_is_a(node_ptr.type, &RNA_Node));
|
||||
RNA_pointer_create((ID *)&ntree, &RNA_NodeSocket, &const_cast<bNodeSocket &>(sock), &ptr);
|
||||
RNA_pointer_create(
|
||||
&const_cast<ID &>(ntree.id), &RNA_NodeSocket, &const_cast<bNodeSocket &>(sock), &ptr);
|
||||
|
||||
sock.typeinfo->draw_color((bContext *)&C, &ptr, &node_ptr, r_color);
|
||||
}
|
||||
|
||||
struct SocketTooltipData {
|
||||
const bNodeTree *ntree;
|
||||
const bNode *node;
|
||||
const bNodeSocket *socket;
|
||||
};
|
||||
|
||||
static void create_inspection_string_for_generic_value(const bNodeSocket &socket,
|
||||
const GPointer value,
|
||||
std::stringstream &ss)
|
||||
|
@ -1084,35 +1077,33 @@ static bool node_socket_has_tooltip(const bNodeTree &ntree, const bNodeSocket &s
|
|||
return false;
|
||||
}
|
||||
|
||||
static char *node_socket_get_tooltip(const bContext *C,
|
||||
const bNodeTree *ntree,
|
||||
const bNode * /*node*/,
|
||||
const bNodeSocket *socket)
|
||||
static char *node_socket_get_tooltip(const SpaceNode *snode,
|
||||
const bNodeTree &ntree,
|
||||
const bNodeSocket &socket)
|
||||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
TreeDrawContext tree_draw_ctx;
|
||||
if (snode != nullptr) {
|
||||
if (ntree->type == NTREE_GEOMETRY) {
|
||||
if (ntree.type == NTREE_GEOMETRY) {
|
||||
tree_draw_ctx.geo_tree_log = geo_log::GeoModifierLog::get_tree_log_for_node_editor(*snode);
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream output;
|
||||
if (socket->runtime->declaration != nullptr) {
|
||||
const blender::nodes::SocketDeclaration &socket_decl = *socket->runtime->declaration;
|
||||
if (socket.runtime->declaration != nullptr) {
|
||||
const blender::nodes::SocketDeclaration &socket_decl = *socket.runtime->declaration;
|
||||
blender::StringRef description = socket_decl.description;
|
||||
if (!description.is_empty()) {
|
||||
output << TIP_(description.data());
|
||||
}
|
||||
}
|
||||
|
||||
if (ntree->type == NTREE_GEOMETRY && tree_draw_ctx.geo_tree_log != nullptr) {
|
||||
if (ntree.type == NTREE_GEOMETRY && tree_draw_ctx.geo_tree_log != nullptr) {
|
||||
if (!output.str().empty()) {
|
||||
output << ".\n\n";
|
||||
}
|
||||
|
||||
std::optional<std::string> socket_inspection_str = create_socket_inspection_string(
|
||||
tree_draw_ctx, *socket);
|
||||
tree_draw_ctx, socket);
|
||||
if (socket_inspection_str.has_value()) {
|
||||
output << *socket_inspection_str;
|
||||
}
|
||||
|
@ -1124,51 +1115,65 @@ static char *node_socket_get_tooltip(const bContext *C,
|
|||
}
|
||||
|
||||
if (output.str().empty()) {
|
||||
output << nodeSocketLabel(socket);
|
||||
output << nodeSocketLabel(&socket);
|
||||
}
|
||||
|
||||
return BLI_strdup(output.str().c_str());
|
||||
}
|
||||
|
||||
static void node_socket_add_tooltip_in_node_editor(TreeDrawContext * /*tree_draw_ctx*/,
|
||||
const bNodeTree *ntree,
|
||||
const bNode *node,
|
||||
const bNodeSocket *sock,
|
||||
uiLayout *layout)
|
||||
static void node_socket_add_tooltip_in_node_editor(const bNodeTree &ntree,
|
||||
const bNodeSocket &sock,
|
||||
uiLayout &layout)
|
||||
{
|
||||
if (!node_socket_has_tooltip(*ntree, *sock)) {
|
||||
if (!node_socket_has_tooltip(ntree, sock)) {
|
||||
return;
|
||||
}
|
||||
uiLayoutSetTooltipFunc(
|
||||
&layout,
|
||||
[](bContext *C, void *argN, const char * /*tip*/) {
|
||||
const SpaceNode &snode = *CTX_wm_space_node(C);
|
||||
const bNodeTree &ntree = *snode.edittree;
|
||||
const int index_in_tree = POINTER_AS_INT(argN);
|
||||
ntree.ensure_topology_cache();
|
||||
return node_socket_get_tooltip(&snode, ntree, *ntree.all_sockets()[index_in_tree]);
|
||||
},
|
||||
POINTER_FROM_INT(sock.index_in_tree()),
|
||||
nullptr,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, uiLayout &layout)
|
||||
{
|
||||
if (!node_socket_has_tooltip(ntree, sock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct SocketTooltipData {
|
||||
const bNodeTree *ntree;
|
||||
const bNodeSocket *socket;
|
||||
};
|
||||
|
||||
SocketTooltipData *data = MEM_cnew<SocketTooltipData>(__func__);
|
||||
data->ntree = ntree;
|
||||
data->node = node;
|
||||
data->socket = sock;
|
||||
data->ntree = &ntree;
|
||||
data->socket = &sock;
|
||||
|
||||
uiLayoutSetTooltipFunc(
|
||||
layout,
|
||||
&layout,
|
||||
[](bContext *C, void *argN, const char * /*tip*/) {
|
||||
SocketTooltipData *data = static_cast<SocketTooltipData *>(argN);
|
||||
return node_socket_get_tooltip(C, data->ntree, data->node, data->socket);
|
||||
const SpaceNode *snode = CTX_wm_space_node(C);
|
||||
return node_socket_get_tooltip(snode, *data->ntree, *data->socket);
|
||||
},
|
||||
data,
|
||||
MEM_dupallocN,
|
||||
MEM_freeN);
|
||||
}
|
||||
|
||||
void node_socket_add_tooltip(const bNodeTree &ntree,
|
||||
const bNode &node,
|
||||
const bNodeSocket &sock,
|
||||
uiLayout &layout)
|
||||
{
|
||||
node_socket_add_tooltip_in_node_editor(nullptr, &ntree, &node, &sock, &layout);
|
||||
}
|
||||
|
||||
static void node_socket_draw_nested(const bContext &C,
|
||||
bNodeTree &ntree,
|
||||
const bNodeTree &ntree,
|
||||
PointerRNA &node_ptr,
|
||||
uiBlock &block,
|
||||
bNodeSocket &sock,
|
||||
const bNodeSocket &sock,
|
||||
const uint pos_id,
|
||||
const uint col_id,
|
||||
const uint shape_id,
|
||||
|
@ -1219,19 +1224,17 @@ static void node_socket_draw_nested(const bContext &C,
|
|||
0,
|
||||
nullptr);
|
||||
|
||||
SocketTooltipData *data = MEM_new<SocketTooltipData>(__func__);
|
||||
data->ntree = &ntree;
|
||||
data->node = static_cast<const bNode *>(node_ptr.data);
|
||||
data->socket = &sock;
|
||||
|
||||
UI_but_func_tooltip_set(
|
||||
but,
|
||||
[](bContext *C, void *argN, const char * /*tip*/) {
|
||||
SocketTooltipData *data = (SocketTooltipData *)argN;
|
||||
return node_socket_get_tooltip(C, data->ntree, data->node, data->socket);
|
||||
const SpaceNode &snode = *CTX_wm_space_node(C);
|
||||
const bNodeTree &ntree = *snode.edittree;
|
||||
const int index_in_tree = POINTER_AS_INT(argN);
|
||||
ntree.ensure_topology_cache();
|
||||
return node_socket_get_tooltip(&snode, ntree, *ntree.all_sockets()[index_in_tree]);
|
||||
},
|
||||
data,
|
||||
MEM_freeN);
|
||||
POINTER_FROM_INT(sock.index_in_tree()),
|
||||
nullptr);
|
||||
/* 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);
|
||||
|
@ -1365,11 +1368,13 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv)
|
|||
/* Common handle function for operator buttons that need to select the node first. */
|
||||
static void node_toggle_button_cb(bContext *C, void *node_argv, void *op_argv)
|
||||
{
|
||||
bNode *node = (bNode *)node_argv;
|
||||
SpaceNode &snode = *CTX_wm_space_node(C);
|
||||
bNodeTree &node_tree = *snode.edittree;
|
||||
bNode &node = *node_tree.node_by_id(POINTER_AS_INT(node_argv));
|
||||
const char *opname = (const char *)op_argv;
|
||||
|
||||
/* Select & activate only the button's node. */
|
||||
node_select_single(*C, *node);
|
||||
node_select_single(*C, node);
|
||||
|
||||
WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
|
||||
}
|
||||
|
@ -1386,21 +1391,19 @@ static void node_draw_shadow(const SpaceNode &snode,
|
|||
|
||||
static void node_draw_sockets(const View2D &v2d,
|
||||
const bContext &C,
|
||||
bNodeTree &ntree,
|
||||
bNode &node,
|
||||
const bNodeTree &ntree,
|
||||
const bNode &node,
|
||||
uiBlock &block,
|
||||
const bool draw_outputs,
|
||||
const bool select_all)
|
||||
{
|
||||
const uint total_input_len = BLI_listbase_count(&node.inputs);
|
||||
const uint total_output_len = BLI_listbase_count(&node.outputs);
|
||||
|
||||
if (total_input_len + total_output_len == 0) {
|
||||
if (node.input_sockets().is_empty() && node.output_sockets().is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PointerRNA node_ptr;
|
||||
RNA_pointer_create((ID *)&ntree, &RNA_Node, &node, &node_ptr);
|
||||
RNA_pointer_create(
|
||||
&const_cast<ID &>(ntree.id), &RNA_Node, &const_cast<bNode &>(node), &node_ptr);
|
||||
|
||||
bool selected = false;
|
||||
|
||||
|
@ -1425,12 +1428,12 @@ static void node_draw_sockets(const View2D &v2d,
|
|||
scale *= socket_draw_size;
|
||||
|
||||
if (!select_all) {
|
||||
immBeginAtMost(GPU_PRIM_POINTS, total_input_len + total_output_len);
|
||||
immBeginAtMost(GPU_PRIM_POINTS, node.input_sockets().size() + node.output_sockets().size());
|
||||
}
|
||||
|
||||
/* Socket inputs. */
|
||||
short selected_input_len = 0;
|
||||
LISTBASE_FOREACH (bNodeSocket *, sock, &node.inputs) {
|
||||
int selected_input_len = 0;
|
||||
for (const bNodeSocket *sock : node.input_sockets()) {
|
||||
if (!sock->is_visible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1461,9 +1464,9 @@ static void node_draw_sockets(const View2D &v2d,
|
|||
}
|
||||
|
||||
/* Socket outputs. */
|
||||
short selected_output_len = 0;
|
||||
int selected_output_len = 0;
|
||||
if (draw_outputs) {
|
||||
LISTBASE_FOREACH (bNodeSocket *, sock, &node.outputs) {
|
||||
for (const bNodeSocket *sock : node.output_sockets()) {
|
||||
if (!sock->is_visible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1501,7 +1504,7 @@ static void node_draw_sockets(const View2D &v2d,
|
|||
|
||||
if (selected_input_len) {
|
||||
/* Socket inputs. */
|
||||
LISTBASE_FOREACH (bNodeSocket *, sock, &node.inputs) {
|
||||
for (const bNodeSocket *sock : node.input_sockets()) {
|
||||
if (!sock->is_visible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1531,7 +1534,7 @@ static void node_draw_sockets(const View2D &v2d,
|
|||
|
||||
if (selected_output_len) {
|
||||
/* Socket outputs. */
|
||||
LISTBASE_FOREACH (bNodeSocket *, sock, &node.outputs) {
|
||||
for (const bNodeSocket *sock : node.output_sockets()) {
|
||||
if (!sock->is_visible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1565,7 +1568,7 @@ static void node_draw_sockets(const View2D &v2d,
|
|||
|
||||
/* Draw multi-input sockets after the others because they are drawn with `UI_draw_roundbox`
|
||||
* rather than with `GL_POINT`. */
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) {
|
||||
for (const bNodeSocket *socket : node.input_sockets()) {
|
||||
if (!socket->is_visible()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1657,7 +1660,7 @@ static char *node_errors_tooltip_fn(bContext * /*C*/, void *argN, const char * /
|
|||
|
||||
#define NODE_HEADER_ICON_SIZE (0.8f * U.widget_unit)
|
||||
|
||||
static void node_add_unsupported_compositor_operation_error_message_button(bNode &node,
|
||||
static void node_add_unsupported_compositor_operation_error_message_button(const bNode &node,
|
||||
uiBlock &block,
|
||||
const rctf &rect,
|
||||
float &icon_offset)
|
||||
|
@ -1681,8 +1684,8 @@ static void node_add_unsupported_compositor_operation_error_message_button(bNode
|
|||
UI_block_emboss_set(&block, UI_EMBOSS);
|
||||
}
|
||||
|
||||
static void node_add_error_message_button(TreeDrawContext &tree_draw_ctx,
|
||||
bNode &node,
|
||||
static void node_add_error_message_button(const TreeDrawContext &tree_draw_ctx,
|
||||
const bNode &node,
|
||||
uiBlock &block,
|
||||
const rctf &rect,
|
||||
float &icon_offset)
|
||||
|
@ -1731,7 +1734,7 @@ static void node_add_error_message_button(TreeDrawContext &tree_draw_ctx,
|
|||
}
|
||||
|
||||
static std::optional<std::chrono::nanoseconds> node_get_execution_time(
|
||||
TreeDrawContext &tree_draw_ctx, const bNodeTree &ntree, const bNode &node)
|
||||
const TreeDrawContext &tree_draw_ctx, const bNodeTree &ntree, const bNode &node)
|
||||
{
|
||||
const geo_log::GeoTreeLog *tree_log = tree_draw_ctx.geo_tree_log;
|
||||
if (tree_log == nullptr) {
|
||||
|
@ -1899,7 +1902,7 @@ static std::optional<NodeExtraInfoRow> node_get_accessed_attributes_row(
|
|||
GEO_NODE_REMOVE_ATTRIBUTE,
|
||||
GEO_NODE_INPUT_NAMED_ATTRIBUTE)) {
|
||||
/* Only show the overlay when the name is passed in from somewhere else. */
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) {
|
||||
for (const bNodeSocket *socket : node.input_sockets()) {
|
||||
if (STREQ(socket->name, "Name")) {
|
||||
if (!socket->is_directly_linked()) {
|
||||
return std::nullopt;
|
||||
|
@ -2031,7 +2034,6 @@ static void node_draw_extra_info_panel(TreeDrawContext &tree_draw_ctx,
|
|||
uiBlock &block)
|
||||
{
|
||||
Vector<NodeExtraInfoRow> extra_info_rows = node_get_extra_info(tree_draw_ctx, snode, node);
|
||||
|
||||
if (extra_info_rows.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -2042,7 +2044,7 @@ static void node_draw_extra_info_panel(TreeDrawContext &tree_draw_ctx,
|
|||
|
||||
const float width = (node.width - 6.0f) * U.dpi_fac;
|
||||
|
||||
if (node.type == NODE_FRAME) {
|
||||
if (node.is_frame()) {
|
||||
extra_info_rect.xmin = rct.xmin;
|
||||
extra_info_rect.xmax = rct.xmin + 95.0f * U.dpi_fac;
|
||||
extra_info_rect.ymin = rct.ymin + 2.0f * U.dpi_fac;
|
||||
|
@ -2090,7 +2092,7 @@ static void node_draw_basis(const bContext &C,
|
|||
const View2D &v2d,
|
||||
const SpaceNode &snode,
|
||||
bNodeTree &ntree,
|
||||
bNode &node,
|
||||
const bNode &node,
|
||||
uiBlock &block,
|
||||
bNodeInstanceKey key)
|
||||
{
|
||||
|
@ -2157,7 +2159,10 @@ static void node_draw_basis(const bContext &C,
|
|||
0,
|
||||
0,
|
||||
"");
|
||||
UI_but_func_set(but, node_toggle_button_cb, &node, (void *)"NODE_OT_preview_toggle");
|
||||
UI_but_func_set(but,
|
||||
node_toggle_button_cb,
|
||||
POINTER_FROM_INT(node.identifier),
|
||||
(void *)"NODE_OT_preview_toggle");
|
||||
/* XXX this does not work when node is activated and the operator called right afterwards,
|
||||
* since active ID is not updated yet (needs to process the notifier).
|
||||
* This can only work as visual indicator! */
|
||||
|
@ -2183,7 +2188,10 @@ static void node_draw_basis(const bContext &C,
|
|||
0,
|
||||
0,
|
||||
"");
|
||||
UI_but_func_set(but, node_toggle_button_cb, &node, (void *)"NODE_OT_group_edit");
|
||||
UI_but_func_set(but,
|
||||
node_toggle_button_cb,
|
||||
POINTER_FROM_INT(node.identifier),
|
||||
(void *)"NODE_OT_group_edit");
|
||||
if (node.id) {
|
||||
UI_but_icon_indicator_number_set(but, ID_REAL_USERS(node.id));
|
||||
}
|
||||
|
@ -2228,7 +2236,8 @@ static void node_draw_basis(const bContext &C,
|
|||
"");
|
||||
/* Selection implicitly activates the node. */
|
||||
const char *operator_idname = is_active ? "NODE_OT_deactivate_viewer" : "NODE_OT_select";
|
||||
UI_but_func_set(but, node_toggle_button_cb, &node, (void *)operator_idname);
|
||||
UI_but_func_set(
|
||||
but, node_toggle_button_cb, POINTER_FROM_INT(node.identifier), (void *)operator_idname);
|
||||
UI_block_emboss_set(&block, UI_EMBOSS);
|
||||
}
|
||||
|
||||
|
@ -2262,7 +2271,10 @@ static void node_draw_basis(const bContext &C,
|
|||
0.0f,
|
||||
"");
|
||||
|
||||
UI_but_func_set(but, node_toggle_button_cb, &node, (void *)"NODE_OT_hide_toggle");
|
||||
UI_but_func_set(but,
|
||||
node_toggle_button_cb,
|
||||
POINTER_FROM_INT(node.identifier),
|
||||
(void *)"NODE_OT_hide_toggle");
|
||||
UI_block_emboss_set(&block, UI_EMBOSS);
|
||||
}
|
||||
|
||||
|
@ -2490,7 +2502,10 @@ static void node_draw_hidden(const bContext &C,
|
|||
0.0f,
|
||||
"");
|
||||
|
||||
UI_but_func_set(but, node_toggle_button_cb, &node, (void *)"NODE_OT_hide_toggle");
|
||||
UI_but_func_set(but,
|
||||
node_toggle_button_cb,
|
||||
POINTER_FROM_INT(node.identifier),
|
||||
(void *)"NODE_OT_hide_toggle");
|
||||
UI_block_emboss_set(&block, UI_EMBOSS);
|
||||
}
|
||||
|
||||
|
@ -2636,27 +2651,18 @@ void node_set_cursor(wmWindow &win, SpaceNode &snode, const float2 &cursor)
|
|||
|
||||
static void count_multi_input_socket_links(bNodeTree &ntree, SpaceNode &snode)
|
||||
{
|
||||
Map<bNodeSocket *, int> counts;
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
|
||||
if (link->tosock->flag & SOCK_MULTI_INPUT) {
|
||||
int &count = counts.lookup_or_add(link->tosock, 0);
|
||||
count++;
|
||||
for (bNode *node : ntree.all_nodes()) {
|
||||
for (bNodeSocket *socket : node->input_sockets()) {
|
||||
if (socket->is_multi_input()) {
|
||||
socket->runtime->total_inputs = socket->directly_linked_links().size();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Count temporary links going into this socket. */
|
||||
if (snode.runtime->linkdrag) {
|
||||
for (const bNodeLink &link : snode.runtime->linkdrag->links) {
|
||||
if (link.tosock && (link.tosock->flag & SOCK_MULTI_INPUT)) {
|
||||
int &count = counts.lookup_or_add(link.tosock, 0);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (bNode *node : ntree.all_nodes()) {
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
||||
if (socket->flag & SOCK_MULTI_INPUT) {
|
||||
socket->runtime->total_inputs = counts.lookup_default(socket, 0);
|
||||
link.tosock->runtime->total_inputs++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2749,12 +2755,12 @@ static void node_update_nodetree(const bContext &C,
|
|||
for (const int i : nodes.index_range()) {
|
||||
bNode &node = *nodes[i];
|
||||
uiBlock &block = *blocks[i];
|
||||
if (node.type == NODE_FRAME) {
|
||||
if (node.is_frame()) {
|
||||
/* Frame sizes are calculated after all other nodes have calculating their #totr. */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node.type == NODE_REROUTE) {
|
||||
if (node.is_reroute()) {
|
||||
reroute_node_prepare_for_draw(node);
|
||||
}
|
||||
else {
|
||||
|
@ -2770,7 +2776,7 @@ static void node_update_nodetree(const bContext &C,
|
|||
/* Now calculate the size of frame nodes, which can depend on the size of other nodes.
|
||||
* Update nodes in reverse, so children sizes get updated before parents. */
|
||||
for (int i = nodes.size() - 1; i >= 0; i--) {
|
||||
if (nodes[i]->type == NODE_FRAME) {
|
||||
if (nodes[i]->is_frame()) {
|
||||
frame_node_prepare_for_draw(*nodes[i], nodes);
|
||||
}
|
||||
}
|
||||
|
@ -2973,10 +2979,10 @@ static void node_draw(const bContext &C,
|
|||
uiBlock &block,
|
||||
bNodeInstanceKey key)
|
||||
{
|
||||
if (node.type == NODE_FRAME) {
|
||||
if (node.is_frame()) {
|
||||
frame_node_draw(C, tree_draw_ctx, region, snode, ntree, node, block);
|
||||
}
|
||||
else if (node.type == NODE_REROUTE) {
|
||||
else if (node.is_reroute()) {
|
||||
reroute_node_draw(C, region, ntree, node, block);
|
||||
}
|
||||
else {
|
||||
|
@ -3025,14 +3031,14 @@ static void node_draw_nodetree(const bContext &C,
|
|||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
nodelink_batch_start(snode);
|
||||
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
|
||||
LISTBASE_FOREACH (const bNodeLink *, link, &ntree.links) {
|
||||
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) {
|
||||
LISTBASE_FOREACH (const bNodeLink *, link, &ntree.links) {
|
||||
if (!nodeLinkIsHidden(link) && nodeLinkIsSelected(link)) {
|
||||
node_draw_link(C, region.v2d, snode, *link, true);
|
||||
}
|
||||
|
@ -3110,9 +3116,9 @@ static bool realtime_compositor_is_in_use(const bContext &context)
|
|||
}
|
||||
|
||||
const Main *main = CTX_data_main(&context);
|
||||
LISTBASE_FOREACH (bScreen *, screen, &main->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
|
||||
LISTBASE_FOREACH (const bScreen *, screen, &main->screens) {
|
||||
LISTBASE_FOREACH (const ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (const SpaceLink *, space, &area->spacedata) {
|
||||
if (space->spacetype != SPACE_VIEW3D) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -155,10 +155,7 @@ void node_socket_color_get(const bContext &C,
|
|||
|
||||
void node_draw_space(const bContext &C, ARegion ®ion);
|
||||
|
||||
void node_socket_add_tooltip(const bNodeTree &ntree,
|
||||
const bNode &node,
|
||||
const bNodeSocket &sock,
|
||||
uiLayout &layout);
|
||||
void node_socket_add_tooltip(const bNodeTree &ntree, const bNodeSocket &sock, uiLayout &layout);
|
||||
|
||||
/**
|
||||
* Sort nodes by selection: unselected nodes first, then selected,
|
||||
|
|
|
@ -897,7 +897,7 @@ static void ui_node_draw_input(
|
|||
uiItemDecoratorR(split_wrapper.decorate_column, nullptr, nullptr, 0);
|
||||
}
|
||||
|
||||
node_socket_add_tooltip(ntree, node, input, *row);
|
||||
node_socket_add_tooltip(ntree, input, *row);
|
||||
|
||||
/* clear */
|
||||
node.flag &= ~NODE_TEST;
|
||||
|
|
Loading…
Reference in New Issue