Fix #118769: Remove parent parameter from new_panel function

Nested panels are not supported currently, and this parameter serves no
actual purposes. Only the root panel supports adding child panels and it
is not user-accessible (adding the root panel is done using a nullptr
for the parent).

Pull Request: https://projects.blender.org/blender/blender/pulls/118792
This commit is contained in:
Lukas Tönne
2024-02-27 13:30:13 +01:00
parent c926b65132
commit b1636bc781
2 changed files with 8 additions and 33 deletions

View File

@@ -530,32 +530,19 @@ static bNodeTreeInterfaceSocket *rna_NodeTreeInterfaceItems_new_socket(
return socket;
}
static bNodeTreeInterfacePanel *rna_NodeTreeInterfaceItems_new_panel(
ID *id,
bNodeTreeInterface *interface,
Main *bmain,
ReportList *reports,
const char *name,
const char *description,
bool default_closed,
bNodeTreeInterfacePanel *parent)
static bNodeTreeInterfacePanel *rna_NodeTreeInterfaceItems_new_panel(ID *id,
bNodeTreeInterface *interface,
Main *bmain,
ReportList *reports,
const char *name,
const char *description,
bool default_closed)
{
if (parent != nullptr) {
if (!interface->find_item(parent->item)) {
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);
SET_FLAG_FROM_TEST(flag, default_closed, NODE_INTERFACE_PANEL_DEFAULT_CLOSED);
bNodeTreeInterfacePanel *panel = interface->add_panel(
name ? name : "", description ? description : "", flag, parent);
name ? name : "", description ? description : "", flag, nullptr);
if (panel == nullptr) {
BKE_report(reports, RPT_ERROR, "Unable to create panel");
@@ -1178,11 +1165,6 @@ static void rna_def_node_tree_interface_items_api(StructRNA *srna)
RNA_def_boolean(
func, "default_closed", false, "Default Closed", "Panel is closed by default on new nodes");
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
RNA_def_pointer(func,
"parent",
"NodeTreeInterfacePanel",
"Parent",
"Add panel as a child of the parent panel");
/* return value */
parm = RNA_def_pointer(func, "item", "NodeTreeInterfacePanel", "Panel", "New panel");
RNA_def_function_return(func, parm);

View File

@@ -272,13 +272,6 @@ 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.outputs], ["Output 0", "Output 1"])
# Nested panel is not allowed and should return None.
panel1 = tree.interface.new_panel("Panel 1", parent=panel0)
self.assertIsNone(panel1)
self.assertSequenceEqual(tree.interface.items_tree, [out0, in0, panel0, out1, in1])
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"])
def do_test_remove(self, socket_type):
tree, group_node = self.make_group_and_instance()