diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_api.c | 107 |
1 files changed, 105 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 3015d56e1ee..f8a9b00c724 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -71,6 +71,8 @@ const EnumPropertyItem rna_enum_window_cursor_items[] = { #include "UI_interface.h" #include "BKE_context.h" +#include "WM_types.h" + static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); @@ -115,6 +117,37 @@ static void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer) WM_event_remove_timer(wm, timer->win, timer); } + +static wmGizmoGroupType *wm_gizmogrouptype_find_for_add_remove(ReportList *reports, const char *idname) +{ + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, true); + if (gzgt == NULL) { + BKE_reportf(reports, RPT_ERROR, "Gizmo group type '%s' not found!", idname); + return NULL; + } + if (gzgt->flag & WM_GIZMOGROUPTYPE_PERSISTENT) { + BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' has 'PERSISTENT' option set!", idname); + return NULL; + } + return gzgt; +} + +static void rna_gizmo_group_type_add(ReportList *reports, const char *idname) +{ + wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); + if (gzgt != NULL) { + WM_gizmo_group_type_add_ptr(gzgt); + } +} + +static void rna_gizmo_group_type_remove(Main *bmain, ReportList *reports, const char *idname) +{ + wmGizmoGroupType *gzgt = wm_gizmogrouptype_find_for_add_remove(reports, idname); + if (gzgt != NULL) { + WM_gizmo_group_type_remove_ptr(bmain, gzgt); + } +} + /* placeholder data for final implementation of a true progressbar */ static struct wmStaticProgress { float min; @@ -342,6 +375,24 @@ static void rna_PopMenuEnd(bContext *C, PointerRNA *handle) UI_popup_menu_end(C, handle->data); } +/* popover wrapper */ +static PointerRNA rna_PopoverBegin(bContext *C, int ui_units_x) +{ + PointerRNA r_ptr; + void *data; + + data = (void *)UI_popover_begin(C, U.widget_unit * ui_units_x); + + RNA_pointer_create(NULL, &RNA_UIPopover, data, &r_ptr); + + return r_ptr; +} + +static void rna_PopoverEnd(bContext *C, PointerRNA *handle, wmKeyMap *keymap) +{ + UI_popover_end(C, handle->data, keymap); +} + /* pie menu wrapper */ static PointerRNA rna_PieMenuBegin(bContext *C, const char *title, int icon, PointerRNA *event) { @@ -360,6 +411,18 @@ static void rna_PieMenuEnd(bContext *C, PointerRNA *handle) UI_pie_menu_end(C, handle->data); } +static PointerRNA rna_WindoManager_operator_properties_last(const char *idname) +{ + wmOperatorType *ot = WM_operatortype_find(idname, true); + + if (ot != NULL) { + PointerRNA ptr; + WM_operator_last_properties_ensure(ot, &ptr); + return ptr; + } + return PointerRNA_NULL; +} + #else #define WM_GEN_INVOKE_EVENT (1 << 0) @@ -453,6 +516,18 @@ void RNA_api_wm(StructRNA *srna) parm = RNA_def_pointer(func, "timer", "Timer", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); + func = RNA_def_function(srna, "gizmo_group_type_add", "rna_gizmo_group_type_add"); + RNA_def_function_ui_description(func, "Activate an existing widget group (when the persistent option isn't set)"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_REPORTS); + parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + func = RNA_def_function(srna, "gizmo_group_type_remove", "rna_gizmo_group_type_remove"); + RNA_def_function_ui_description(func, "De-activate a widget group (when the persistent option isn't set)"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_MAIN | FUNC_USE_REPORTS); + parm = RNA_def_string(func, "identifier", NULL, 0, "", "Gizmo group type name"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* Progress bar interface */ func = RNA_def_function(srna, "progress_begin", "rna_progress_begin"); RNA_def_function_ui_description(func, "Start progress report"); @@ -521,7 +596,24 @@ void RNA_api_wm(StructRNA *srna) 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 | PARM_REQUIRED); + + /* wrap UI_popover_begin */ + func = RNA_def_function(srna, "popover_begin__internal", "rna_PopoverBegin"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); + RNA_def_property(func, "ui_units_x", PROP_INT, PROP_UNSIGNED); + /* return */ + parm = RNA_def_pointer(func, "menu", "UIPopover", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); + RNA_def_function_return(func, parm); + + /* wrap UI_popover_end */ + func = RNA_def_function(srna, "popover_end__internal", "rna_PopoverEnd"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); + parm = RNA_def_pointer(func, "menu", "UIPopover", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED); + RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Active key map"); + /* wrap uiPieMenuBegin */ func = RNA_def_function(srna, "piemenu_begin__internal", "rna_PieMenuBegin"); @@ -541,7 +633,18 @@ void RNA_api_wm(StructRNA *srna) func = RNA_def_function(srna, "piemenu_end__internal", "rna_PieMenuEnd"); RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "menu", "UIPieMenu", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR | PARM_REQUIRED); + + /* access last operator options (optionally create). */ + func = RNA_def_function(srna, "operator_properties_last", "rna_WindoManager_operator_properties_last"); + RNA_def_function_flag(func, FUNC_NO_SELF); + parm = RNA_def_string(func, "operator", NULL, 0, "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return */ + parm = RNA_def_pointer(func, "result", "OperatorProperties", "", ""); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); + RNA_def_function_return(func, parm); + } void RNA_api_operator(StructRNA *srna) @@ -822,10 +925,10 @@ void RNA_api_keyconfigs(StructRNA *srna) parm = RNA_def_pointer(func, "properties", "OperatorProperties", "", ""); RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); RNA_def_boolean(func, "is_hotkey", 0, "Hotkey", "Event is not a modifier"); - parm = RNA_def_pointer(func, "item", "KeyMapItem", "", ""); - RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); parm = RNA_def_pointer(func, "keymap", "KeyMap", "", ""); RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_OUTPUT); + parm = RNA_def_pointer(func, "item", "KeyMapItem", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_RNAPTR); RNA_def_function_return(func, parm); RNA_def_function(srna, "update", "rna_KeyConfig_update"); /* WM_keyconfig_update */ |