diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_api.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 677ea92aea1..b9f0ae22fd2 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -71,6 +71,8 @@ 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 wmManipulatorGroupType *wm_manipulatorgrouptype_find_for_add_remove(ReportList *reports, const char *idname) +{ + wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, true); + if (wgt == NULL) { + BKE_reportf(reports, RPT_ERROR, "Manipulator group type '%s' not found!", idname); + return NULL; + } + if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) { + BKE_reportf(reports, RPT_ERROR, "Manipulator group '%s' has 'PERSISTENT' option set!", idname); + return NULL; + } + return wgt; +} + +static void rna_manipulator_group_type_add(ReportList *reports, const char *idname) +{ + wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname); + if (wgt != NULL) { + WM_manipulator_group_type_add_ptr(wgt); + } +} + +static void rna_manipulator_group_type_remove(Main *bmain, ReportList *reports, const char *idname) +{ + wmManipulatorGroupType *wgt = wm_manipulatorgrouptype_find_for_add_remove(reports, idname); + if (wgt != NULL) { + WM_manipulator_group_type_remove_ptr(bmain, wgt); + } +} + /* placeholder data for final implementation of a true progressbar */ static struct wmStaticProgress { float min; @@ -426,6 +459,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, "manipulator_group_type_add", "rna_manipulator_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, "", "Manipulator group type name"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + + func = RNA_def_function(srna, "manipulator_group_type_remove", "rna_manipulator_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, "", "Manipulator 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"); |