diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 34 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_api.c | 39 |
5 files changed, 74 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 3d149d9951a..76e523f1329 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2368,7 +2368,6 @@ struct uiPopupMenu { int mx, my; bool popup, slideout; - int startx, starty, maxrow; uiMenuCreateFunc menu_func; void *menu_arg; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 9aeb1166aa6..b18d3c83342 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -626,6 +626,7 @@ extern StructRNA RNA_TransformConstraint; extern StructRNA RNA_TransformSequence; extern StructRNA RNA_UILayout; extern StructRNA RNA_UIList; +extern StructRNA RNA_UIPopupMenu; extern StructRNA RNA_UVWarpModifier; extern StructRNA RNA_UVProjectModifier; extern StructRNA RNA_UVProjector; diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 6649d58d718..20b1d56b22e 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -3015,6 +3015,7 @@ void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret) return; } + BLI_assert(func->c_ret == NULL); func->c_ret = ret; RNA_def_function_output(func, ret); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index aae1581def6..1bd1e48e768 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -450,6 +450,8 @@ EnumPropertyItem wm_report_items[] = { #include "WM_api.h" +#include "UI_interface.h" + #include "BKE_idprop.h" #include "MEM_guardedalloc.h" @@ -561,6 +563,17 @@ static int rna_Event_unicode_length(PointerRNA *ptr) } } +static PointerRNA rna_PopupMenu_layout_get(PointerRNA *ptr) +{ + struct uiPopupMenu *pup = ptr->data; + uiLayout *layout = uiPupMenuLayout(pup); + + PointerRNA rptr; + RNA_pointer_create(ptr->id.data, &RNA_UILayout, layout, &rptr); + + return rptr; +} + static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value) { wmWindow *win = (wmWindow *)ptr->data; @@ -1659,6 +1672,26 @@ static void rna_def_timer(BlenderRNA *brna) RNA_define_verify_sdna(1); /* not in sdna */ } +static void rna_def_popupmenu(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "UIPopupMenu", NULL); + RNA_def_struct_ui_text(srna, "PopupMenu", ""); + RNA_def_struct_sdna(srna, "uiPopupMenu"); + + 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", + NULL, NULL, NULL); + + RNA_define_verify_sdna(1); /* not in sdna */ +} + static void rna_def_window(BlenderRNA *brna) { StructRNA *srna; @@ -2018,6 +2051,7 @@ void RNA_def_wm(BlenderRNA *brna) rna_def_operator_type_macro(brna); rna_def_event(brna); rna_def_timer(brna); + rna_def_popupmenu(brna); rna_def_window(brna); rna_def_windowmanager(brna); rna_def_keyconfig(brna); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index b747c8053df..5805bcefdb4 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -45,6 +45,7 @@ #ifdef RNA_RUNTIME +#include "UI_interface.h" #include "BKE_context.h" static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C) @@ -250,6 +251,24 @@ static void rna_KeyConfig_remove(wmWindowManager *wm, ReportList *reports, Point RNA_POINTER_INVALIDATE(keyconf_ptr); } +/* popup menu wrapper */ +static PointerRNA rna_PupMenuBegin(bContext *C, const char *title, int icon) +{ + PointerRNA r_ptr; + void *data; + + data = (void *)uiPupMenuBegin(C, title, icon); + + RNA_pointer_create(NULL, &RNA_UIPopupMenu, data, &r_ptr); + + return r_ptr; +} + +static void rna_PupMenuEnd(bContext *C, PointerRNA *handle) +{ + uiPupMenuEnd(C, handle->data); +} + #else #define WM_GEN_INVOKE_EVENT (1 << 0) @@ -348,7 +367,25 @@ void RNA_api_wm(StructRNA *srna) func = RNA_def_function(srna, "invoke_confirm", "rna_Operator_confirm"); RNA_def_function_ui_description(func, "Operator confirmation"); rna_generic_op_invoke(func, WM_GEN_INVOKE_EVENT | WM_GEN_INVOKE_RETURN); - + + + /* wrap uiPupMenuBegin */ + func = RNA_def_function(srna, "pupmenu_begin__internal", "rna_PupMenuBegin"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); + parm = RNA_def_string(func, "title", "", 0, "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(parm, icon_items); + /* return */ + parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", ""); + RNA_def_property_flag(parm, PROP_RNAPTR | PROP_NEVER_NULL); + RNA_def_function_return(func, parm); + + /* wrap uiPupMenuEnd */ + func = RNA_def_function(srna, "pupmenu_end__internal", "rna_PupMenuEnd"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); + parm = RNA_def_pointer(func, "menu", "UIPopupMenu", "", ""); + RNA_def_property_flag(parm, PROP_RNAPTR | PROP_NEVER_NULL); } void RNA_api_operator(StructRNA *srna) |