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
This commit is contained in:
committed by
Philipp Oeser
parent
8992e7ab2a
commit
686ffaaed9
@@ -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));
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user