From 420e379e99a3351b2dd2a46989aa1d50bdf8abef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Apr 2018 10:49:45 +0200 Subject: Cleanup: de-dup popup/pie menu RNA definition Also rename pupmenu -> popmenu --- source/blender/makesrna/intern/rna_wm.c | 34 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'source/blender/makesrna/intern/rna_wm.c') diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 265758eb5c3..b71eca3d850 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1830,44 +1830,36 @@ static void rna_def_timer(BlenderRNA *brna) RNA_define_verify_sdna(1); /* not in sdna */ } -static void rna_def_popupmenu(BlenderRNA *brna) +static void rna_def_popup_menu_wrapper( + BlenderRNA *brna, const char *rna_type, const char *c_type, const char *layout_get_fn) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "UIPopupMenu", NULL); - RNA_def_struct_ui_text(srna, "PopupMenu", ""); - RNA_def_struct_sdna(srna, "uiPopupMenu"); + srna = RNA_def_struct(brna, rna_type, NULL); + /* UI name isn't visible, name same as type. */ + RNA_def_struct_ui_text(srna, rna_type, ""); + RNA_def_struct_sdna(srna, c_type); RNA_define_verify_sdna(0); /* not in sdna */ /* could wrap more, for now this is enough */ prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "UILayout"); - RNA_def_property_pointer_funcs(prop, "rna_PopupMenu_layout_get", + RNA_def_property_pointer_funcs(prop, layout_get_fn, NULL, NULL, NULL); RNA_define_verify_sdna(1); /* not in sdna */ } -static void rna_def_piemenu(BlenderRNA *brna) +static void rna_def_popupmenu(BlenderRNA *brna) { - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "UIPieMenu", NULL); - RNA_def_struct_ui_text(srna, "PieMenu", ""); - RNA_def_struct_sdna(srna, "uiPieMenu"); - - RNA_define_verify_sdna(0); /* not in sdna */ - - /* could wrap more, for now this is enough */ - prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "UILayout"); - RNA_def_property_pointer_funcs(prop, "rna_PieMenu_layout_get", - NULL, NULL, NULL); + rna_def_popup_menu_wrapper(brna, "UIPopupMenu", "uiPopupMenu", "rna_PopupMenu_layout_get"); +} - RNA_define_verify_sdna(1); /* not in sdna */ +static void rna_def_piemenu(BlenderRNA *brna) +{ + rna_def_popup_menu_wrapper(brna, "UIPieMenu", "uiPieMenu", "rna_PieMenu_layout_get"); } static void rna_def_window_stereo3d(BlenderRNA *brna) -- cgit v1.2.3