45#include "RNA_prototypes.hh"
136 if (
node &&
node->idname == node_idname) {
159 if (gnode && !
exit) {
160 bNodeTree *ngroup = id_cast<bNodeTree *>(gnode->
id);
179 ot->
name =
"Edit Group";
181 ot->
idname =
"NODE_OT_group_edit";
220 if (!
node->is_group()) {
223 if (
node->is_custom_group()) {
236 ot->
name =
"Enter/Exit Group";
237 ot->
description =
"Enter or exit node group based on cursor location";
238 ot->
idname =
"NODE_OT_group_enter_exit";
268 if (
node.is_group_input() ||
node.is_group_output()) {
275 C, ngroup, copied_nodes, io_mapping, &group_node);
281 node->location[0] += center[0];
282 node->location[1] += center[1];
284 for (
bNode *
node : proxy_nodes.values()) {
285 node->location[0] += center[0];
286 node->location[1] += center[1];
294 for (
bNode *
node : proxy_nodes.values()) {
308 for (
bNode *
node : proxy_nodes.values()) {
323 if (
node->is_selected()) {
324 if (
node->idname == node_idname) {
325 if (
node->id !=
nullptr) {
347 ot->
name =
"Ungroup";
349 ot->
idname =
"NODE_OT_group_ungroup";
376 [](
const bNode *
node) {
return node->is_group_input() ||
node->is_group_output(); });
379 bmain, ngroup, nodes_to_move.
as_span(), ntree);
381 node->location[0] += offset[0];
382 node->location[1] += offset[1];
401 {
NODE_GS_COPY,
"COPY", 0,
"Copy",
"Copy to parent node tree, keep group intact"},
402 {
NODE_GS_MOVE,
"MOVE", 0,
"Move",
"Move to parent node tree, remove from group"},
403 {0,
nullptr, 0,
nullptr,
nullptr},
459 op_ptr = layout->
op(
"NODE_OT_group_separate",
IFACE_(
"Move"), ICON_NONE);
462 popup_menu_end(
C, pup);
470 ot->
name =
"Separate";
471 ot->
description =
"Separate selected nodes from the node group";
472 ot->
idname =
"NODE_OT_group_separate";
496 nodes_to_group.
remove(group_node);
497 return nodes_to_group;
517 const char *disabled_hint =
nullptr;
518 if (
node->typeinfo->poll_instance &&
519 !
node->typeinfo->poll_instance(
node, ngroup, &disabled_hint))
524 "Cannot add node '%s' in a group:\n %s",
537 ntree.ensure_topology_cache();
544 for (
const bNodeSocket *other_socket : socket->directly_linked_sockets()) {
545 if (nodes_to_group.
contains(
const_cast<bNode *
>(&other_socket->owner_node()))) {
552 if (sockets_connected_to_group(
node->input_sockets()) &&
553 sockets_connected_to_group(
node->output_sockets()))
561 for (
bNode *input_node : ntree.nodes_by_type(zone_type->input_idname)) {
562 if (
bNode *output_node = zone_type->get_corresponding_output(ntree, *input_node)) {
563 const bool input_selected = nodes_to_group.
contains(input_node);
564 const bool output_selected = nodes_to_group.
contains(output_node);
565 if (input_selected && !output_selected) {
568 "Cannot add zone input node '%s' to a group without its paired output '%s'",
573 if (output_selected && !input_selected) {
576 "Cannot add zone output node '%s' to a group without its paired input '%s'",
606 params, ntree,
nodes, group);
642 gnode->
id = id_cast<ID *>(ngroup);
667 if (!src_node.is_reroute()) {
677 params, src_node, *wrapper_group);
680 bmain, ntree, {&src_node}, *wrapper_group);
691 gnode->
id = &wrapper_group->
id;
696 if (!src_node.is_reroute()) {
702 ntree.ensure_topology_cache();
708 std::string old_node_name = src_node.
name;
738 bNode *gnode =
nullptr;
739 if (nodes_to_group.
size() == 1 && nodes_to_group[0]->declaration()) {
744 *
C, ntree, std::move(nodes_to_group), node_idname, ntree_idname);
748 bNodeTree *ngroup = id_cast<bNodeTree *>(gnode->
id);
767 ot->
name =
"Make Group";
768 ot->
description =
"Make group from selected nodes";
769 ot->
idname =
"NODE_OT_group_make";
795 if (!gnode || !gnode->
id) {
803 for (
const bNode *group : nodes_to_group) {
804 if (!group->is_group() || group->id ==
nullptr) {
829 ot->
name =
"Group Insert";
830 ot->
description =
"Insert selected nodes into a node group";
831 ot->
idname =
"NODE_OT_group_insert";
875 if (!parent_path_item) {
882 parent_ntree->ensure_topology_cache();
895 ot->
name =
"Set Default Group Node Width";
896 ot->
description =
"Set the width based on the parent group node in the current context";
897 ot->
idname =
"NODE_OT_default_group_width_set";
Functions and classes to work with Actions.
Blender kernel action and pose functionality.
#define BLI_SCOPED_DEFER(function_to_defer)
#define STRNCPY_UTF8(dst, src)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define ID_IS_EDITABLE(_id)
Read Blender memory allocation and freeing.
bool remove(const Key &key)
bool contains(const Key &key) const
int64_t remove_if(Predicate &&predicate)
Span< Key > as_span() const
void append(const T &value)
static NodeSetCopy from_predicate(Main &bmain, const bNodeTree &src_tree, FunctionRef< bool(const bNode &node)> node_predicate, bNodeTree &dst_tree)
static NodeSetCopy from_nodes(Main &bmain, const bNodeTree &src_tree, const Span< const bNode * > src_nodes, bNodeTree &dst_tree)
const Map< const bNode *, bNode * > & node_map() const
bNode * node_find_node_by_name(bNodeTree &ntree, StringRefNull name)
NodeColorTag node_color_tag(const bNode &node)
std::string node_label(const bNodeTree &ntree, const bNode &node)
void node_tree_free_tree(bNodeTree &ntree)
void node_remove_node(Main *bmain, bNodeTree &ntree, bNode &node, bool do_id_user, bool remove_animation=true)
bNode * node_get_active(bNodeTree &ntree)
bNode * node_add_node(const bContext *C, bNodeTree &ntree, UString idname, std::optional< int > unique_identifier=std::nullopt)
Span< const bNodeZoneType * > all_zone_types()
bool node_set_selected(bNode &node, bool select)
bool node_tree_contains_tree(const bNodeTree &tree_to_search_in, const bNodeTree &tree_to_search_for)
bNodeTree * node_tree_add_tree(Main *bmain, StringRef name, StringRef idname)
void node_set_active(bNodeTree &ntree, bNode &node)
void node_unique_name(bNodeTree &ntree, bNode &node)
static bool node_default_group_width_set_poll(bContext *C)
static bool node_group_operator_active_poll(bContext *C)
static bNode * node_group_make_from_node_declaration(bContext &C, bNodeTree &ntree, bNode &src_node, const UString node_idname)
static VectorSet< bNode * > get_nodes_to_group(bNodeTree &node_tree, bNode *group_node)
static wmOperatorStatus node_group_insert_exec(bContext *C, wmOperator *op)
static void node_group_make_insert_selected(const bContext &C, bNodeTree &ntree, bNode *gnode, const Span< bNode * > nodes)
static wmOperatorStatus node_default_group_width_set_exec(bContext *C, wmOperator *)
static void node_group_ungroup(bContext &C, bNodeTree &ntree, bNode &group_node)
bool node_deselect_all(bNodeTree &node_tree)
static wmOperatorStatus node_group_separate_invoke(bContext *C, wmOperator *, const wmEvent *)
static bool node_group_make_test_selected(bNodeTree &ntree, const VectorSet< bNode * > &nodes_to_group, const StringRef ntree_idname, ReportList &reports)
void NODE_OT_group_make(wmOperatorType *ot)
static const EnumPropertyItem node_group_separate_types[]
GroupInputOutputNodes connect_copied_nodes_to_interface(const bContext &C, const NodeSetCopy &copied_nodes, const NodeTreeInterfaceMapping &io_mapping)
void NODE_OT_group_insert(wmOperatorType *ot)
static bool node_group_separate_selected(Main &bmain, bNodeTree &ntree, bNodeTree &ngroup, const float2 &offset, const bool make_copy)
Map< std::string, bNode * > InterfaceProxyNodes
NodeTreeInterfaceMapping build_node_set_interface(const NodeSetInterfaceParams ¶ms, const bNodeTree &src_tree, const Span< bNode * > src_nodes, bNodeTree &dst_tree)
static wmOperatorStatus node_group_ungroup_exec(bContext *C, wmOperator *)
NodeTreeInterfaceMapping build_node_declaration_interface(const NodeSetInterfaceParams ¶ms, const bNode &src_node, bNodeTree &dst_tree)
static wmOperatorStatus node_group_separate_exec(bContext *C, wmOperator *op)
bNode * node_under_mouse_get(const SpaceNode &snode, const float2 mouse)
static wmOperatorStatus node_group_edit_exec(bContext *C, wmOperator *op)
UString node_group_idname(const bContext *C)
void update_nested_node_refs_after_ungroup(bNodeTree &dst_tree, const bNode &group_node, const NodeSetCopy &node_set_copy)
VectorSet< bNode * > get_selected_nodes(bNodeTree &node_tree)
static bNode * node_group_make_from_nodes(const bContext &C, bNodeTree &ntree, const Span< bNode * > nodes_to_group, const UString ntype, const StringRef ntreetype)
static bool node_group_operator_editable(bContext *C)
float2 space_node_group_offset(const SpaceNode &snode)
static wmOperatorStatus node_group_make_exec(bContext *C, wmOperator *op)
void connect_group_node_to_external_sockets(bNode &group_node, const NodeTreeInterfaceMapping &io_mapping)
void NODE_OT_group_edit(wmOperatorType *ot)
void NODE_OT_group_separate(wmOperatorType *ot)
bNode * find_common_parent_node(Span< bNode * > nodes)
NodeTreeInterfaceMapping map_group_node_interface(const NodeSetInterfaceParams ¶ms, const bNodeTree &tree, const bNode &group_node)
void NODE_OT_group_enter_exit(wmOperatorType *ot)
void NODE_OT_default_group_width_set(wmOperatorType *ot)
std::optional< Bounds< float2 > > node_location_bounds(Span< const bNode * > nodes)
static wmOperatorStatus node_group_enter_exit_invoke(bContext *C, wmOperator *, const wmEvent *event)
void NODE_OT_group_ungroup(wmOperatorType *ot)
void update_nested_node_refs_after_moving_nodes_into_group(bNodeTree &src_tree, const bNode &group_node, const NodeSetCopy &node_set_copy)
static StringRef group_ntree_idname(bContext *C)
float nearest_node_grid_coord(float co)
InterfaceProxyNodes connect_copied_nodes_to_external_sockets(bContext &C, const bNodeTree &src_tree, const NodeSetCopy &copied_nodes, const NodeTreeInterfaceMapping &io_mapping, const bNode *group_node)
static bNode * node_group_get_active(bContext *C, const UString node_idname)
Button * but_find_mouse_over(const ARegion *region, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
PopupMenu * popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
bool ED_node_is_compositor(const SpaceNode *snode)
bool ED_operator_node_active(bContext *C)
void ED_node_tree_push(ARegion *region, SpaceNode *snode, bNodeTree *ntree, bNode *gnode)
char * STRNCPY(char(&dst)[N], const char *src)
int RNA_enum_get(PointerRNA *ptr, const char *name)
bool ED_node_is_geometry(const SpaceNode *snode)
void ED_node_tree_pop(ARegion *region, SpaceNode *snode)
MINLINE void copy_v2_v2(float r[2], const float a[2])
bke::bNodeTreeType * ntreeType_Geometry
bke::bNodeTreeType * ntreeType_Composite
bool ED_node_is_shader(SpaceNode *snode)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
bool ED_operator_node_editable(bContext *C)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
const char * BKE_id_name(const ID &id)
struct bke::bNodeTreeType * ntreeType_Texture
void ED_preview_kill_jobs(wmWindowManager *wm, Main *bmain)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
VecBase< float, 2 > float2
void BKE_report(ReportList *reports, eReportType type, const char *message)
bool ED_node_is_texture(SpaceNode *snode)
wmWindowManager * CTX_wm_manager(const bContext *C)
void BKE_main_ensure_invariants(Main &bmain, std::optional< Span< ID * > > modified_ids=std::nullopt)
SpaceNode * CTX_wm_space_node(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
struct bke::bNodeTreeType * ntreeType_Shader
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void WM_event_handling_break(const bContext &C)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_ntree_update_tag_node_property(bNodeTree *ntree, bNode *node)
Main * CTX_data_main(const bContext *C)
void BKE_id_move_to_same_lib(Main &bmain, ID &id, const ID &owner_id)
void DEG_relations_tag_update(Main *bmain)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
bNodeTree * ED_node_tree_get(SpaceNode *snode, int level)
ARegion * CTX_wm_region(const bContext *C)
struct bNodeTree * edittree
struct bNodeTree * nodetree
ListBaseT< bNodeTreePath > treepath
struct bNodeTree * nodetree
struct bNodeTreePath * prev
int default_group_node_width
bNestedNodeRef * nested_node_refs
static constexpr int GroupMin
void operator_context_set(wm::OpCallContext opcontext)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
#define ISMOUSE_BUTTON(event_type)