diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_screen.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 34 |
2 files changed, 23 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 167fce4406c..dcf6d6c3907 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -208,6 +208,7 @@ typedef struct PanelType { short region_type; /* For popovers, 0 for default. */ int ui_units_x; + int order; int flag; diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index faa16f4f146..0dbafbde71c 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -317,19 +317,21 @@ static StructRNA *rna_Panel_register(Main *bmain, pt->draw_header = (have_function[2]) ? panel_draw_header : NULL; pt->draw_header_preset = (have_function[3]) ? panel_draw_header_preset : NULL; - /* XXX use "no header" flag for some ordering of panels until we have real panel ordering */ - if (pt->flag & PNL_NO_HEADER) { - PanelType *pth = art->paneltypes.first; - while (pth && pth->flag & PNL_NO_HEADER) - pth = pth->next; - - if (pth) - BLI_insertlinkbefore(&art->paneltypes, pth, pt); - else - BLI_addtail(&art->paneltypes, pt); + /* Find position to insert panel based on order. */ + PanelType *pt_iter = art->paneltypes.last; + + for (; pt_iter; pt_iter = pt_iter->prev) { + /* No header has priority. */ + if ((pt->flag & PNL_NO_HEADER) && !(pt_iter->flag & PNL_NO_HEADER)) { + continue; + } + if (pt_iter->order <= pt->order) { + break; + } } - else - BLI_addtail(&art->paneltypes, pt); + + /* Insert into list. */ + BLI_insertlinkafter(&art->paneltypes, pt_iter, pt); if (parent) { pt->parent = parent; @@ -1347,6 +1349,14 @@ static void rna_def_panel(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); RNA_def_property_ui_text(prop, "Units X", "When set, defines popup panel width"); + prop = RNA_def_property(srna, "bl_order", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "type->order"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_def_property_ui_text( + prop, + "Order", + "Panels with lower numbers are default ordered before panels with higher numbers"); + prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_PIN); RNA_def_property_ui_text(prop, "Pin", ""); |