From 40d700c6fbc9f80904eb1861097cf9d3cbd14d1f Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 13 Jun 2022 18:27:50 +0200 Subject: UI: Use "bl_order" for UI child panels The "bl_order" property on add-on UI panels can be used to put them in a specific order regardless of the order of registering. This patch makes this ordering also possible for panels inside panels. Differential Revision: https://developer.blender.org/D15174 --- source/blender/makesrna/intern/rna_ui.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 1d0723851ad..dabb89bcd5e 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -393,7 +393,14 @@ static StructRNA *rna_Panel_register(Main *bmain, if (parent) { pt->parent = parent; - BLI_addtail(&parent->children, BLI_genericNodeN(pt)); + LinkData *pt_child_iter = parent->children.last; + for (; pt_child_iter; pt_child_iter = pt_child_iter->prev) { + PanelType *pt_child = pt_child_iter->data; + if (pt_child->order <= pt->order) { + break; + } + } + BLI_insertlinkafter(&parent->children, pt_child_iter, BLI_genericNodeN(pt)); } { -- cgit v1.2.3