From 686ffaaed9bff1e29feb037bc31f7f492ae958ea Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 24 Aug 2023 15:12:00 +0200 Subject: [PATCH] Fix #111174: dropped nodegroups from the asset browser show selector There was a difference between drag&drop assets from the asset browser vs. using the search menu (in that doing it from the menu would correctly hide the data-block selector on the nodegroup). Since drag&drop in the Node Editor uses `NODE_OT_add_group` (not `NODE_OT_add_group_asset` as the menu does), we have to add the hiding here too (for this, an operator property is added which is set in `node_group_drop_copy` if we are dropping an asset. Alternatively, we could use `NODE_OT_add_group_asset`, too, but that would require somehow setting the "asset" context pointer from the dropbox copy function [how to do this wasnt obvious for me]. In that case, we would need to set up a separate dropbox with appropriate poll functions (so there would be one for asset groups and for the the other groups). Pull Request: https://projects.blender.org/blender/blender/pulls/111427 --- source/blender/editors/space_node/node_add.cc | 12 ++++++++++++ source/blender/editors/space_node/space_node.cc | 2 ++ 2 files changed, 14 insertions(+) diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 17737f3d1b6..6b970a7add1 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -312,6 +312,11 @@ static int node_add_group_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Could not add node group"); return OPERATOR_CANCELLED; } + if (!RNA_boolean_get(op->ptr, "show_datablock_in_node")) { + /* By default, don't show the data-block selector since it's not usually necessary for assets. + */ + group_node->flag &= ~NODE_OPTIONS; + } group_node->id = &node_group->id; id_us_plus(group_node->id); @@ -371,6 +376,13 @@ void NODE_OT_add_group(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; WM_operator_properties_id_lookup(ot, true); + + PropertyRNA *prop = RNA_def_boolean(ot->srna, + "show_datablock_in_node", + true, + "Show the datablock selector in the node", + ""); + RNA_def_property_flag(prop, (PropertyFlag)(PROP_SKIP_SAVE | PROP_HIDDEN)); } /** \} */ diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index 32803e166cb..b5eec4baf7d 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -707,6 +707,8 @@ static void node_group_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop) ID *id = WM_drag_get_local_ID_or_import_from_asset(C, drag, 0); RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid)); + + RNA_boolean_set(drop->ptr, "show_datablock_in_node", (drag->type != WM_DRAG_ASSET)); } static void node_id_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)