[Bf-blender-cvs] [420e379e99a] master: Cleanup: de-dup popup/pie menu RNA definition

Campbell Barton noreply at git.blender.org
Sun Apr 22 10:51:04 CEST 2018


Commit: 420e379e99a3351b2dd2a46989aa1d50bdf8abef
Author: Campbell Barton
Date:   Sun Apr 22 10:49:45 2018 +0200
Branches: master
https://developer.blender.org/rB420e379e99a3351b2dd2a46989aa1d50bdf8abef

Cleanup: de-dup popup/pie menu RNA definition

Also rename pupmenu -> popmenu

===================================================================

M	release/scripts/modules/bpy_types.py
M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/makesrna/intern/rna_wm_api.c

===================================================================

diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 600b29a6b2b..15d92cd6b61 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -137,12 +137,12 @@ class WindowManager(bpy_types.ID):
 
     def popup_menu(self, draw_func, title="", icon='NONE'):
         import bpy
-        popup = self.pupmenu_begin__internal(title, icon)
+        popup = self.popmenu_begin__internal(title, icon)
 
         try:
             draw_func(popup, bpy.context)
         finally:
-            self.pupmenu_end__internal(popup)
+            self.popmenu_end__internal(popup)
 
     def popup_menu_pie(self, event, draw_func, title="", icon='NONE'):
         import bpy
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)
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index cbbe50ccf03..d2cd72b2f1e 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -298,7 +298,7 @@ static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, Point
 }
 
 /* popup menu wrapper */
-static PointerRNA rna_PupMenuBegin(bContext *C, const char *title, int icon)
+static PointerRNA rna_PopMenuBegin(bContext *C, const char *title, int icon)
 {
 	PointerRNA r_ptr;
 	void *data;
@@ -310,7 +310,7 @@ static PointerRNA rna_PupMenuBegin(bContext *C, const char *title, int icon)
 	return r_ptr;
 }
 
-static void rna_PupMenuEnd(bContext *C, PointerRNA *handle)
+static void rna_PopMenuEnd(bContext *C, PointerRNA *handle)
 {
 	UI_popup_menu_end(C, handle->data);
 }
@@ -479,7 +479,7 @@ void RNA_api_wm(StructRNA *srna)
 
 
 	/* wrap UI_popup_menu_begin */
-	func = RNA_def_function(srna, "pupmenu_begin__internal", "rna_PupMenuBegin");
+	func = RNA_def_function(srna, "popmenu_begin__internal", "rna_PopMenuBegin");
 	RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
 	parm = RNA_def_string(func, "title", NULL, 0, "", "");
 	RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
@@ -491,7 +491,7 @@ void RNA_api_wm(StructRNA *srna)
 	RNA_def_function_return(func, parm);
 
 	/* wrap UI_popup_menu_end */
-	func = RNA_def_function(srna, "pupmenu_end__internal", "rna_PupMenuEnd");
+	func = RNA_def_function(srna, "popmenu_end__internal", "rna_PopMenuEnd");
 	RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
 	parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
 	RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);



More information about the Bf-blender-cvs mailing list