forked from blender/blender
Node panels: Enable new node group interfaces #1
@ -447,9 +447,15 @@ static bNodeTreeInterfacePanel *rna_NodeTreeInterfaceItems_new_panel(
|
|||||||
bool default_closed,
|
bool default_closed,
|
||||||
bNodeTreeInterfacePanel *parent)
|
bNodeTreeInterfacePanel *parent)
|
||||||
{
|
{
|
||||||
if (parent != nullptr && !interface->find_item(parent->item)) {
|
if (parent != nullptr) {
|
||||||
BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Parent is not part of the interface");
|
if (!interface->find_item(parent->item)) {
|
||||||
return nullptr;
|
BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Parent is not part of the interface");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (!(parent->flag & NODE_INTERFACE_PANEL_ALLOW_CHILD_PANELS)) {
|
||||||
|
BKE_report(reports, RPT_WARNING, "Parent panel does not allow child panels");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeTreeInterfacePanelFlag flag = NodeTreeInterfacePanelFlag(0);
|
NodeTreeInterfacePanelFlag flag = NodeTreeInterfacePanelFlag(0);
|
||||||
@ -479,9 +485,17 @@ static bNodeTreeInterfaceItem *rna_NodeTreeInterfaceItems_copy_to_parent(
|
|||||||
bNodeTreeInterfaceItem *item,
|
bNodeTreeInterfaceItem *item,
|
||||||
bNodeTreeInterfacePanel *parent)
|
bNodeTreeInterfacePanel *parent)
|
||||||
{
|
{
|
||||||
if (parent != nullptr && !interface->find_item(parent->item)) {
|
if (parent != nullptr) {
|
||||||
BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Parent is not part of the interface");
|
if (!interface->find_item(parent->item)) {
|
||||||
return nullptr;
|
BKE_report(reports, RPT_ERROR_INVALID_INPUT, "Parent is not part of the interface");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (item->item_type == NODE_INTERFACE_PANEL &&
|
||||||
|
!(parent->flag & NODE_INTERFACE_PANEL_ALLOW_CHILD_PANELS))
|
||||||
|
{
|
||||||
|
BKE_report(reports, RPT_WARNING, "Parent panel does not allow child panels");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent == nullptr) {
|
if (parent == nullptr) {
|
||||||
@ -559,10 +573,18 @@ static void rna_NodeTreeInterfaceItems_move(
|
|||||||
static void rna_NodeTreeInterfaceItems_move_to_parent(ID *id,
|
static void rna_NodeTreeInterfaceItems_move_to_parent(ID *id,
|
||||||
bNodeTreeInterface *interface,
|
bNodeTreeInterface *interface,
|
||||||
Main *bmain,
|
Main *bmain,
|
||||||
|
ReportList *reports,
|
||||||
bNodeTreeInterfaceItem *item,
|
bNodeTreeInterfaceItem *item,
|
||||||
bNodeTreeInterfacePanel *parent,
|
bNodeTreeInterfacePanel *parent,
|
||||||
int to_index)
|
int to_index)
|
||||||
{
|
{
|
||||||
|
if (item->item_type == NODE_INTERFACE_PANEL &&
|
||||||
|
!(parent->flag & NODE_INTERFACE_PANEL_ALLOW_CHILD_PANELS))
|
||||||
|
{
|
||||||
|
BKE_report(reports, RPT_WARNING, "Parent panel does not allow child panels");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
interface->move_item_to_parent(*item, parent, to_index);
|
interface->move_item_to_parent(*item, parent, to_index);
|
||||||
|
|
||||||
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
|
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
|
||||||
@ -892,6 +914,12 @@ static void rna_def_node_interface_panel(BlenderRNA *brna)
|
|||||||
RNA_def_property_struct_type(prop, "NodeTreeInterfaceItem");
|
RNA_def_property_struct_type(prop, "NodeTreeInterfaceItem");
|
||||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
RNA_def_property_ui_text(prop, "Items", "Items in the node panel");
|
RNA_def_property_ui_text(prop, "Items", "Items in the node panel");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "is_child_panel_allowed", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_sdna(prop, nullptr, "flag", NODE_INTERFACE_PANEL_ALLOW_CHILD_PANELS);
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
RNA_def_property_ui_text(
|
||||||
|
prop, "Is Child Panel Allowed", "True if the panel can contain child panels");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_def_node_tree_interface_items_api(StructRNA *srna)
|
static void rna_def_node_tree_interface_items_api(StructRNA *srna)
|
||||||
@ -931,7 +959,8 @@ static void rna_def_node_tree_interface_items_api(StructRNA *srna)
|
|||||||
0,
|
0,
|
||||||
"Socket Type",
|
"Socket Type",
|
||||||
"Type of socket generated on nodes");
|
"Type of socket generated on nodes");
|
||||||
/* Note: itemf callback works for the function parameter, it does not require a data pointer. */
|
/* Note: itemf callback works for the function parameter, it does not require a data pointer.
|
||||||
|
*/
|
||||||
RNA_def_property_enum_funcs(
|
RNA_def_property_enum_funcs(
|
||||||
parm, nullptr, nullptr, "rna_NodeTreeInterfaceSocket_socket_type_itemf");
|
parm, nullptr, nullptr, "rna_NodeTreeInterfaceSocket_socket_type_itemf");
|
||||||
RNA_def_pointer(
|
RNA_def_pointer(
|
||||||
@ -994,7 +1023,7 @@ static void rna_def_node_tree_interface_items_api(StructRNA *srna)
|
|||||||
|
|
||||||
func = RNA_def_function(srna, "move_to_parent", "rna_NodeTreeInterfaceItems_move_to_parent");
|
func = RNA_def_function(srna, "move_to_parent", "rna_NodeTreeInterfaceItems_move_to_parent");
|
||||||
RNA_def_function_ui_description(func, "Move an item to a new panel and/or position.");
|
RNA_def_function_ui_description(func, "Move an item to a new panel and/or position.");
|
||||||
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
|
RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
|
||||||
parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "The item to remove");
|
parm = RNA_def_pointer(func, "item", "NodeTreeInterfaceItem", "Item", "The item to remove");
|
||||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
||||||
parm = RNA_def_pointer(
|
parm = RNA_def_pointer(
|
||||||
|
@ -280,8 +280,11 @@ class NodeGroupInterfaceTests:
|
|||||||
self.assertSequenceEqual([s.name for s in group_node.inputs], ["Input 0", "Input 1"])
|
self.assertSequenceEqual([s.name for s in group_node.inputs], ["Input 0", "Input 1"])
|
||||||
self.assertSequenceEqual([s.name for s in group_node.outputs], ["Output 0", "Output 1"])
|
self.assertSequenceEqual([s.name for s in group_node.outputs], ["Output 0", "Output 1"])
|
||||||
|
|
||||||
|
# Nested panel is not allowed, should produce error messages.
|
||||||
|
self.assertFalse(panel0.is_child_panel_allowed)
|
||||||
panel1 = tree.interface.new_panel("Panel 1", parent=panel0)
|
panel1 = tree.interface.new_panel("Panel 1", parent=panel0)
|
||||||
self.assertSequenceEqual(tree.interface.ui_items, [in0, out0, panel0, in1, out1, panel1])
|
self.assertIsNone(panel1)
|
||||||
|
self.assertSequenceEqual(tree.interface.ui_items, [in0, out0, panel0, in1, out1])
|
||||||
self.assertSequenceEqual([s.name for s in group_node.inputs], ["Input 0", "Input 1"])
|
self.assertSequenceEqual([s.name for s in group_node.inputs], ["Input 0", "Input 1"])
|
||||||
self.assertSequenceEqual([s.name for s in group_node.outputs], ["Output 0", "Output 1"])
|
self.assertSequenceEqual([s.name for s in group_node.outputs], ["Output 0", "Output 1"])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user