forked from bartvdbraak/blender
Cleanup: de-dup popup/pie menu RNA definition
Also rename pupmenu -> popmenu
This commit is contained in:
parent
46a9038f60
commit
420e379e99
@ -137,12 +137,12 @@ class WindowManager(bpy_types.ID):
|
|||||||
|
|
||||||
def popup_menu(self, draw_func, title="", icon='NONE'):
|
def popup_menu(self, draw_func, title="", icon='NONE'):
|
||||||
import bpy
|
import bpy
|
||||||
popup = self.pupmenu_begin__internal(title, icon)
|
popup = self.popmenu_begin__internal(title, icon)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
draw_func(popup, bpy.context)
|
draw_func(popup, bpy.context)
|
||||||
finally:
|
finally:
|
||||||
self.pupmenu_end__internal(popup)
|
self.popmenu_end__internal(popup)
|
||||||
|
|
||||||
def popup_menu_pie(self, event, draw_func, title="", icon='NONE'):
|
def popup_menu_pie(self, event, draw_func, title="", icon='NONE'):
|
||||||
import bpy
|
import bpy
|
||||||
|
@ -1830,44 +1830,36 @@ static void rna_def_timer(BlenderRNA *brna)
|
|||||||
RNA_define_verify_sdna(1); /* not in sdna */
|
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;
|
StructRNA *srna;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
srna = RNA_def_struct(brna, "UIPopupMenu", NULL);
|
srna = RNA_def_struct(brna, rna_type, NULL);
|
||||||
RNA_def_struct_ui_text(srna, "PopupMenu", "");
|
/* UI name isn't visible, name same as type. */
|
||||||
RNA_def_struct_sdna(srna, "uiPopupMenu");
|
RNA_def_struct_ui_text(srna, rna_type, "");
|
||||||
|
RNA_def_struct_sdna(srna, c_type);
|
||||||
|
|
||||||
RNA_define_verify_sdna(0); /* not in sdna */
|
RNA_define_verify_sdna(0); /* not in sdna */
|
||||||
|
|
||||||
/* could wrap more, for now this is enough */
|
/* could wrap more, for now this is enough */
|
||||||
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
|
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
|
||||||
RNA_def_property_struct_type(prop, "UILayout");
|
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);
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
RNA_define_verify_sdna(1); /* not in sdna */
|
RNA_define_verify_sdna(1); /* not in sdna */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rna_def_popupmenu(BlenderRNA *brna)
|
||||||
|
{
|
||||||
|
rna_def_popup_menu_wrapper(brna, "UIPopupMenu", "uiPopupMenu", "rna_PopupMenu_layout_get");
|
||||||
|
}
|
||||||
|
|
||||||
static void rna_def_piemenu(BlenderRNA *brna)
|
static void rna_def_piemenu(BlenderRNA *brna)
|
||||||
{
|
{
|
||||||
StructRNA *srna;
|
rna_def_popup_menu_wrapper(brna, "UIPieMenu", "uiPieMenu", "rna_PieMenu_layout_get");
|
||||||
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_define_verify_sdna(1); /* not in sdna */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_def_window_stereo3d(BlenderRNA *brna)
|
static void rna_def_window_stereo3d(BlenderRNA *brna)
|
||||||
|
@ -298,7 +298,7 @@ static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, Point
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* popup menu wrapper */
|
/* 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;
|
PointerRNA r_ptr;
|
||||||
void *data;
|
void *data;
|
||||||
@ -310,7 +310,7 @@ static PointerRNA rna_PupMenuBegin(bContext *C, const char *title, int icon)
|
|||||||
return r_ptr;
|
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);
|
UI_popup_menu_end(C, handle->data);
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@ void RNA_api_wm(StructRNA *srna)
|
|||||||
|
|
||||||
|
|
||||||
/* wrap UI_popup_menu_begin */
|
/* 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);
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
||||||
parm = RNA_def_string(func, "title", NULL, 0, "", "");
|
parm = RNA_def_string(func, "title", NULL, 0, "", "");
|
||||||
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||||
@ -491,7 +491,7 @@ void RNA_api_wm(StructRNA *srna)
|
|||||||
RNA_def_function_return(func, parm);
|
RNA_def_function_return(func, parm);
|
||||||
|
|
||||||
/* wrap UI_popup_menu_end */
|
/* 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);
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
|
||||||
parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
|
parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", "");
|
||||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
|
||||||
|
Loading…
Reference in New Issue
Block a user