Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_manipulator.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm_manipulator.c1007
1 files changed, 1005 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index 06e31688a8a..030f1a1628c 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -63,6 +63,7 @@
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_workspace.h"
+#include "BKE_utildefines.h"
#include "MEM_guardedalloc.h"
@@ -75,6 +76,171 @@
/** \name Manipulator API
* \{ */
+static void rna_manipulator_draw_cb(
+ const struct bContext *C, struct wmManipulator *mpr)
+{
+ extern FunctionRNA rna_Manipulator_draw_func;
+ wmManipulatorGroup *mgroup = mpr->parent_mgroup;
+ PointerRNA mpr_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
+ /* RNA_struct_find_function(&mpr_ptr, "draw"); */
+ func = &rna_Manipulator_draw_func;
+ RNA_parameter_list_create(&list, &mpr_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+static void rna_manipulator_draw_select_cb(
+ const struct bContext *C, struct wmManipulator *mpr, int select_id)
+{
+ extern FunctionRNA rna_Manipulator_draw_select_func;
+ wmManipulatorGroup *mgroup = mpr->parent_mgroup;
+ PointerRNA mpr_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
+ /* RNA_struct_find_function(&mpr_ptr, "draw_select"); */
+ func = &rna_Manipulator_draw_select_func;
+ RNA_parameter_list_create(&list, &mpr_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ RNA_parameter_set_lookup(&list, "select_id", &select_id);
+ mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+static int rna_manipulator_test_select_cb(
+ struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event)
+{
+ extern FunctionRNA rna_Manipulator_test_select_func;
+ wmManipulatorGroup *mgroup = mpr->parent_mgroup;
+ PointerRNA mpr_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
+ /* RNA_struct_find_function(&mpr_ptr, "test_select"); */
+ func = &rna_Manipulator_test_select_func;
+ RNA_parameter_list_create(&list, &mpr_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ RNA_parameter_set_lookup(&list, "event", &event);
+ mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+
+ void *ret;
+ RNA_parameter_get_lookup(&list, "intersect_id", &ret);
+ int intersect_id = *(int *)ret;
+
+ RNA_parameter_list_free(&list);
+ return intersect_id;
+}
+
+static void rna_manipulator_modal_cb(
+ struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event, int tweak)
+{
+ extern FunctionRNA rna_Manipulator_modal_func;
+ wmManipulatorGroup *mgroup = mpr->parent_mgroup;
+ PointerRNA mpr_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
+ /* RNA_struct_find_function(&mpr_ptr, "modal"); */
+ func = &rna_Manipulator_modal_func;
+ RNA_parameter_list_create(&list, &mpr_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ RNA_parameter_set_lookup(&list, "event", &event);
+ RNA_parameter_set_lookup(&list, "tweak", &tweak);
+ mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+static void rna_manipulator_setup_cb(
+ struct wmManipulator *mpr)
+{
+ extern FunctionRNA rna_Manipulator_setup_func;
+ wmManipulatorGroup *mgroup = mpr->parent_mgroup;
+ PointerRNA mpr_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
+ /* RNA_struct_find_function(&mpr_ptr, "setup"); */
+ func = &rna_Manipulator_setup_func;
+ RNA_parameter_list_create(&list, &mpr_ptr, func);
+ mgroup->type->ext.call((bContext *)NULL, &mpr_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+
+static void rna_manipulator_invoke_cb(
+ struct bContext *C, struct wmManipulator *mpr, const struct wmEvent *event)
+{
+ extern FunctionRNA rna_Manipulator_invoke_func;
+ wmManipulatorGroup *mgroup = mpr->parent_mgroup;
+ PointerRNA mpr_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
+ /* RNA_struct_find_function(&mpr_ptr, "invoke"); */
+ func = &rna_Manipulator_invoke_func;
+ RNA_parameter_list_create(&list, &mpr_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ RNA_parameter_set_lookup(&list, "event", &event);
+ mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+static void rna_manipulator_exit_cb(
+ struct bContext *C, struct wmManipulator *mpr, bool cancel)
+{
+ extern FunctionRNA rna_Manipulator_exit_func;
+ wmManipulatorGroup *mgroup = mpr->parent_mgroup;
+ PointerRNA mpr_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
+ /* RNA_struct_find_function(&mpr_ptr, "exit"); */
+ func = &rna_Manipulator_exit_func;
+ RNA_parameter_list_create(&list, &mpr_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ {
+ int cancel_i = cancel;
+ RNA_parameter_set_lookup(&list, "cancel", &cancel_i);
+ }
+ mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+static void rna_manipulator_select_cb(
+ struct bContext *C, struct wmManipulator *mpr, int action)
+{
+ extern FunctionRNA rna_Manipulator_select_func;
+ wmManipulatorGroup *mgroup = mpr->parent_mgroup;
+ PointerRNA mpr_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ RNA_pointer_create(NULL, mpr->type->ext.srna, mpr, &mpr_ptr);
+ /* RNA_struct_find_function(&mpr_ptr, "select"); */
+ func = &rna_Manipulator_select_func;
+ RNA_parameter_list_create(&list, &mpr_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ RNA_parameter_set_lookup(&list, "action", &action);
+ mgroup->type->ext.call((bContext *)C, &mpr_ptr, func, &list);
+ RNA_parameter_list_free(&list);
+}
+
+/* just to work around 'const char *' warning and to ensure this is a python op */
+static void rna_Manipulator_bl_idname_set(PointerRNA *ptr, const char *value)
+{
+ wmManipulator *data = ptr->data;
+ char *str = (char *)data->type->idname;
+ if (!str[0]) {
+ BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
+ }
+ else {
+ assert(!"setting the bl_idname on a non-builtin operator");
+ }
+}
+
static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr)
{
#if 0
@@ -83,7 +249,7 @@ static wmManipulator *rna_ManipulatorProperties_find_operator(PointerRNA *ptr)
/* We could try workaruond this lookup, but not trivial. */
for (bScreen *screen = G.main->screen.first; screen; screen = screen->id.next) {
- IDProperty *properties = (IDProperty *)ptr->data;
+ IDProperty *properties = ptr->data;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->manipulator_map) {
@@ -127,10 +293,202 @@ static IDProperty *rna_ManipulatorProperties_idprops(PointerRNA *ptr, bool creat
static PointerRNA rna_Manipulator_properties_get(PointerRNA *ptr)
{
- wmManipulator *mpr = (wmManipulator *)ptr->data;
+ wmManipulator *mpr = ptr->data;
return rna_pointer_inherit_refine(ptr, mpr->type->srna, mpr->properties);
}
+/* wmManipulator.float */
+#define RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(func_id, member_id) \
+static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ return mpr->member_id; \
+} \
+static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ mpr->member_id = value; \
+}
+/* wmManipulator.float[len] */
+#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \
+static void rna_Manipulator_##func_id##_get(PointerRNA *ptr, float value[len]) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ memcpy(value, mpr->member_id, sizeof(float[len])); \
+} \
+static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, const float value[len]) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ memcpy(mpr->member_id, value, sizeof(float[len])); \
+}
+
+/* wmManipulator.flag */
+#define RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(func_id, member_id, flag_value) \
+static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ return (mpr->member_id & flag_value) != 0; \
+} \
+static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, int value) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ BKE_BIT_TEST_SET(mpr->member_id, value, flag_value); \
+}
+
+#define RNA_MANIPULATOR_FLAG_RO_DEF(func_id, member_id, flag_value) \
+static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
+{ \
+ wmManipulator *mpr = ptr->data; \
+ return (mpr->member_id & flag_value) != 0; \
+}
+
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 4);
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 4);
+
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16);
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16);
+
+RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis);
+RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(line_width, line_width);
+
+RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_MANIPULATOR_DRAW_HOVER);
+RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_active, flag, WM_MANIPULATOR_DRAW_ACTIVE);
+RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_MANIPULATOR_DRAW_VALUE);
+RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_MANIPULATOR_HIDDEN);
+
+/* wmManipulator.state */
+RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGHLIGHT);
+RNA_MANIPULATOR_FLAG_RO_DEF(state_is_active, state, WM_MANIPULATOR_STATE_ACTIVE);
+RNA_MANIPULATOR_FLAG_RO_DEF(state_select, state, WM_MANIPULATOR_STATE_SELECT);
+
+static void rna_Manipulator_name_get(PointerRNA *ptr, char *value)
+{
+ wmManipulator *mpr = ptr->data;
+ strcpy(value, mpr->name);
+}
+
+static void rna_Manipulator_name_set(PointerRNA *ptr, const char *value)
+{
+ wmManipulator *mpr = ptr->data;
+ WM_manipulator_name_set(mpr->parent_mgroup, mpr, value);
+}
+
+static int rna_Manipulator_name_length(PointerRNA *ptr)
+{
+ wmManipulator *mpr = ptr->data;
+ return strlen(mpr->name);
+}
+
+#ifdef WITH_PYTHON
+
+static void rna_Manipulator_unregister(struct Main *bmain, StructRNA *type);
+void BPY_RNA_manipulator_wrapper(wmManipulatorType *wgt, void *userdata);
+
+static StructRNA *rna_Manipulator_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+{
+ struct {
+ char idname[MAX_NAME];
+ } temp_buffers;
+
+ wmManipulatorType dummywt = {NULL};
+ wmManipulator dummymnp = {NULL};
+ PointerRNA mnp_ptr;
+
+ /* Two sets of functions. */
+ int have_function[8];
+
+ /* setup dummy manipulator & manipulator type to store static properties in */
+ dummymnp.type = &dummywt;
+ dummywt.idname = temp_buffers.idname;
+ RNA_pointer_create(NULL, &RNA_Manipulator, &dummymnp, &mnp_ptr);
+
+ /* Clear so we can detect if it's left unset. */
+ temp_buffers.idname[0] = '\0';
+
+ /* validate the python class */
+ if (validate(&mnp_ptr, data, have_function) != 0)
+ return NULL;
+
+ if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
+ BKE_reportf(reports, RPT_ERROR, "Registering manipulator class: '%s' is too long, maximum length is %d",
+ identifier, (int)sizeof(temp_buffers.idname));
+ return NULL;
+ }
+
+ /* check if we have registered this manipulator type before, and remove it */
+ {
+ const wmManipulatorType *wt = WM_manipulatortype_find(dummywt.idname, true);
+ if (wt && wt->ext.srna) {
+ rna_Manipulator_unregister(bmain, wt->ext.srna);
+ }
+ }
+
+ /* create a new manipulator type */
+ dummywt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywt.idname, &RNA_Manipulator);
+ /* manipulator properties are registered separately */
+ RNA_def_struct_flag(dummywt.ext.srna, STRUCT_NO_IDPROPERTIES);
+ dummywt.ext.data = data;
+ dummywt.ext.call = call;
+ dummywt.ext.free = free;
+
+ {
+ int i = 0;
+ dummywt.draw = (have_function[i++]) ? rna_manipulator_draw_cb : NULL;
+ dummywt.draw_select = (have_function[i++]) ? rna_manipulator_draw_select_cb : NULL;
+ dummywt.test_select = (have_function[i++]) ? rna_manipulator_test_select_cb : NULL;
+ dummywt.modal = (have_function[i++]) ? rna_manipulator_modal_cb : NULL;
+// dummywt.property_update = (have_function[i++]) ? rna_manipulator_property_update : NULL;
+// dummywt.position_get = (have_function[i++]) ? rna_manipulator_position_get : NULL;
+ dummywt.setup = (have_function[i++]) ? rna_manipulator_setup_cb : NULL;
+ dummywt.invoke = (have_function[i++]) ? rna_manipulator_invoke_cb : NULL;
+ dummywt.exit = (have_function[i++]) ? rna_manipulator_exit_cb : NULL;
+ dummywt.select = (have_function[i++]) ? rna_manipulator_select_cb : NULL;
+
+ BLI_assert(i == ARRAY_SIZE(have_function));
+ }
+
+ RNA_def_struct_duplicate_pointers(dummywt.ext.srna);
+
+ /* use duplicated string */
+ dummywt.idname = dummywt.ext.srna->identifier;
+
+ WM_manipulatortype_append_ptr(BPY_RNA_manipulator_wrapper, (void *)&dummywt);
+
+ /* update while blender is running */
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+
+ return dummywt.ext.srna;
+}
+
+static void rna_Manipulator_unregister(struct Main *UNUSED(bmain), StructRNA *type)
+{
+ wmManipulatorType *wt = RNA_struct_blender_type_get(type);
+
+ /* TODO, remove widgets from interface! */
+
+ if (!wt)
+ return;
+
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+
+ RNA_struct_free_extension(type, &wt->ext);
+
+ WM_manipulatortype_remove_ptr(wt);
+
+ RNA_struct_free(&BLENDER_RNA, type);
+}
+
+static void **rna_Manipulator_instance(PointerRNA *ptr)
+{
+ wmManipulator *mpr = ptr->data;
+ return &mpr->py_instance;
+}
+
+#endif /* WITH_PYTHON */
+
+
static StructRNA *rna_Manipulator_refine(PointerRNA *mnp_ptr)
{
wmManipulator *mpr = mnp_ptr->data;
@@ -142,6 +500,296 @@ static StructRNA *rna_Manipulator_refine(PointerRNA *mnp_ptr)
/** \name Manipulator Group API
* \{ */
+static wmManipulator *rna_ManipulatorGroup_manipulator_new(
+ wmManipulatorGroup *mgroup, ReportList *reports, const char *idname, const char *name)
+{
+ const wmManipulatorType *wt = WM_manipulatortype_find(idname, true);
+ if (wt == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "ManipulatorType '%s' not known", idname);
+ return NULL;
+ }
+ wmManipulator *mpr = WM_manipulator_new_ptr(wt, mgroup, name, NULL);
+ return mpr;
+}
+
+static void rna_ManipulatorGroup_manipulator_remove(
+ wmManipulatorGroup *mgroup, bContext *C, wmManipulator *mpr)
+{
+ WM_manipulator_free(&mgroup->manipulators, mgroup->parent_mmap, mpr, C);
+}
+
+static void rna_ManipulatorGroup_manipulator_clear(
+ wmManipulatorGroup *mgroup, bContext *C)
+{
+ while (mgroup->manipulators.first) {
+ WM_manipulator_free(&mgroup->manipulators, mgroup->parent_mmap, mgroup->manipulators.first, C);
+ }
+}
+
+static void rna_ManipulatorGroup_name_get(PointerRNA *ptr, char *value)
+{
+ wmManipulatorGroup *mgroup = ptr->data;
+ strcpy(value, mgroup->type->name);
+}
+
+static int rna_ManipulatorGroup_name_length(PointerRNA *ptr)
+{
+ wmManipulatorGroup *mgroup = ptr->data;
+ return strlen(mgroup->type->name);
+}
+
+/* just to work around 'const char *' warning and to ensure this is a python op */
+static void rna_ManipulatorGroup_bl_idname_set(PointerRNA *ptr, const char *value)
+{
+ wmManipulatorGroup *data = ptr->data;
+ char *str = (char *)data->type->idname;
+ if (!str[0])
+ BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
+ else
+ assert(!"setting the bl_idname on a non-builtin operator");
+}
+
+static void rna_ManipulatorGroup_bl_label_set(PointerRNA *ptr, const char *value)
+{
+ wmManipulatorGroup *data = ptr->data;
+ char *str = (char *)data->type->name;
+ if (!str[0])
+ BLI_strncpy(str, value, MAX_NAME); /* utf8 already ensured */
+ else
+ assert(!"setting the bl_label on a non-builtin operator");
+}
+
+static int rna_ManipulatorGroup_has_reports_get(PointerRNA *ptr)
+{
+ wmManipulatorGroup *mgroup = ptr->data;
+ return (mgroup->reports && mgroup->reports->list.first);
+}
+
+#ifdef WITH_PYTHON
+
+static bool rna_manipulatorgroup_poll_cb(const bContext *C, wmManipulatorGroupType *wgt)
+{
+
+ extern FunctionRNA rna_ManipulatorGroup_poll_func;
+
+ PointerRNA ptr;
+ ParameterList list;
+ FunctionRNA *func;
+ void *ret;
+ int visible;
+
+ RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */
+ func = &rna_ManipulatorGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
+
+ RNA_parameter_list_create(&list, &ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ wgt->ext.call((bContext *)C, &ptr, func, &list);
+
+ RNA_parameter_get_lookup(&list, "visible", &ret);
+ visible = *(int *)ret;
+
+ RNA_parameter_list_free(&list);
+
+ return visible;
+}
+
+static void rna_manipulatorgroup_setup_cb(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ extern FunctionRNA rna_ManipulatorGroup_setup_func;
+
+ PointerRNA mgroup_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
+ func = &rna_ManipulatorGroup_setup_func; /* RNA_struct_find_function(&wgroupr, "setup"); */
+
+ RNA_parameter_list_create(&list, &mgroup_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list);
+
+ RNA_parameter_list_free(&list);
+}
+
+static wmKeyMap *rna_manipulatorgroup_setup_keymap_cb(const wmManipulatorGroupType *wgt, wmKeyConfig *config)
+{
+ extern FunctionRNA rna_ManipulatorGroup_setup_keymap_func;
+ const char *wgroupname = wgt->name;
+ void *ret;
+
+ PointerRNA ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, wgt->ext.srna, NULL, &ptr); /* dummy */
+ func = &rna_ManipulatorGroup_setup_keymap_func; /* RNA_struct_find_function(&wgroupr, "setup_keymap"); */
+
+ RNA_parameter_list_create(&list, &ptr, func);
+ RNA_parameter_set_lookup(&list, "keyconfig", &config);
+ RNA_parameter_set_lookup(&list, "manipulator_group", &wgroupname);
+ wgt->ext.call(NULL, &ptr, func, &list);
+
+ RNA_parameter_get_lookup(&list, "keymap", &ret);
+ wmKeyMap *keymap = *(wmKeyMap **)ret;
+
+ RNA_parameter_list_free(&list);
+
+ return keymap;
+}
+
+static void rna_manipulatorgroup_refresh_cb(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ extern FunctionRNA rna_ManipulatorGroup_refresh_func;
+
+ PointerRNA mgroup_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
+ func = &rna_ManipulatorGroup_refresh_func; /* RNA_struct_find_function(&wgroupr, "refresh"); */
+
+ RNA_parameter_list_create(&list, &mgroup_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list);
+
+ RNA_parameter_list_free(&list);
+}
+
+static void rna_manipulatorgroup_draw_prepare_cb(const bContext *C, wmManipulatorGroup *mgroup)
+{
+ extern FunctionRNA rna_ManipulatorGroup_draw_prepare_func;
+
+ PointerRNA mgroup_ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
+ func = &rna_ManipulatorGroup_draw_prepare_func; /* RNA_struct_find_function(&wgroupr, "draw_prepare"); */
+
+ RNA_parameter_list_create(&list, &mgroup_ptr, func);
+ RNA_parameter_set_lookup(&list, "context", &C);
+ mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list);
+
+ RNA_parameter_list_free(&list);
+}
+
+void BPY_RNA_manipulatorgroup_wrapper(wmManipulatorGroupType *wgt, void *userdata);
+
+static StructRNA *rna_ManipulatorGroup_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+{
+ struct {
+ char name[MAX_NAME];
+ char idname[MAX_NAME];
+ } temp_buffers;
+
+ wmManipulatorGroupType dummywgt = {NULL};
+ wmManipulatorGroup dummywg = {NULL};
+ PointerRNA wgptr;
+
+ /* Two sets of functions. */
+ int have_function[5];
+
+ /* setup dummy manipulatorgroup & manipulatorgroup type to store static properties in */
+ dummywg.type = &dummywgt;
+ dummywgt.name = temp_buffers.name;
+ dummywgt.idname = temp_buffers.idname;
+
+ RNA_pointer_create(NULL, &RNA_ManipulatorGroup, &dummywg, &wgptr);
+
+ /* Clear so we can detect if it's left unset. */
+ temp_buffers.idname[0] = temp_buffers.name[0] = '\0';
+
+ /* validate the python class */
+ if (validate(&wgptr, data, have_function) != 0)
+ return NULL;
+
+ if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
+ BKE_reportf(reports, RPT_ERROR, "Registering manipulatorgroup class: '%s' is too long, maximum length is %d",
+ identifier, (int)sizeof(temp_buffers.idname));
+ return NULL;
+ }
+
+ /* check if the area supports widgets */
+ const struct wmManipulatorMapType_Params wmap_params = {
+ .spaceid = dummywgt.mmap_params.spaceid,
+ .regionid = dummywgt.mmap_params.regionid,
+ };
+
+ wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wmap_params);
+ if (mmap_type == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "Area type does not support manipulators");
+ return NULL;
+ }
+
+ /* check if we have registered this manipulatorgroup type before, and remove it */
+ {
+ wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(dummywgt.idname, true);
+ if (wgt && wgt->ext.srna) {
+ WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt);
+ WM_manipulatorgrouptype_remove_ptr(wgt);
+
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+ }
+ }
+
+ /* create a new manipulatorgroup type */
+ dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_ManipulatorGroup);
+ RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* manipulatorgroup properties are registered separately */
+ dummywgt.ext.data = data;
+ dummywgt.ext.call = call;
+ dummywgt.ext.free = free;
+
+ /* We used to register widget group types like this, now we do it similar to
+ * operator types. Thus we should be able to do the same as operator types now. */
+ dummywgt.poll = (have_function[0]) ? rna_manipulatorgroup_poll_cb : NULL;
+ dummywgt.setup_keymap = (have_function[1]) ? rna_manipulatorgroup_setup_keymap_cb : NULL;
+ dummywgt.setup = (have_function[2]) ? rna_manipulatorgroup_setup_cb : NULL;
+ dummywgt.refresh = (have_function[3]) ? rna_manipulatorgroup_refresh_cb : NULL;
+ dummywgt.draw_prepare = (have_function[4]) ? rna_manipulatorgroup_draw_prepare_cb : NULL;
+
+ RNA_def_struct_duplicate_pointers(dummywgt.ext.srna);
+ dummywgt.idname = dummywgt.ext.srna->identifier;
+ dummywgt.name = dummywgt.ext.srna->name;
+
+ wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr(
+ BPY_RNA_manipulatorgroup_wrapper, (void *)&dummywgt);
+
+ if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) {
+ WM_manipulator_group_add_ptr_ex(wgt, mmap_type);
+
+ /* update while blender is running */
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+ }
+
+ return dummywgt.ext.srna;
+}
+
+static void rna_ManipulatorGroup_unregister(struct Main *bmain, StructRNA *type)
+{
+ wmManipulatorGroupType *wgt = RNA_struct_blender_type_get(type);
+
+ if (!wgt)
+ return;
+
+ WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
+
+ RNA_struct_free_extension(type, &wgt->ext);
+
+ WM_manipulator_group_remove_ptr(bmain, wgt);
+
+ RNA_struct_free(&BLENDER_RNA, type);
+}
+
+static void **rna_ManipulatorGroup_instance(PointerRNA *ptr)
+{
+ wmManipulatorGroup *mgroup = ptr->data;
+ return &mgroup->py_instance;
+}
+
+#endif /* WITH_PYTHON */
+
static StructRNA *rna_ManipulatorGroup_refine(PointerRNA *mgroup_ptr)
{
wmManipulatorGroup *mgroup = mgroup_ptr->data;
@@ -165,10 +813,32 @@ static void rna_def_manipulators(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
RNA_def_property_srna(cprop, "Manipulators");
srna = RNA_def_struct(brna, "Manipulators", NULL);
RNA_def_struct_sdna(srna, "wmManipulatorGroup");
RNA_def_struct_ui_text(srna, "Manipulators", "Collection of manipulators");
+
+ func = RNA_def_function(srna, "new", "rna_ManipulatorGroup_manipulator_new");
+ RNA_def_function_ui_description(func, "Add manipulator");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_string(func, "type", "Type", 0, "", "Manipulator identifier"); /* optional */
+ RNA_def_string(func, "name", "Name", 0, "", "Manipulator name"); /* optional */
+ parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove", "rna_ManipulatorGroup_manipulator_remove");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Delete manipulator");
+ parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+
+ func = RNA_def_function(srna, "clear", "rna_ManipulatorGroup_manipulator_clear");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ RNA_def_function_ui_description(func, "Delete all manipulators");
}
@@ -177,18 +847,222 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
PropertyRNA *prop;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
RNA_def_property_srna(cprop, "Manipulator");
srna = RNA_def_struct(brna, "Manipulator", NULL);
RNA_def_struct_sdna(srna, "wmManipulator");
RNA_def_struct_ui_text(srna, "Manipulator", "Collection of manipulators");
RNA_def_struct_refine_func(srna, "rna_Manipulator_refine");
+#ifdef WITH_PYTHON
+ RNA_def_struct_register_funcs(
+ srna,
+ "rna_Manipulator_register",
+ "rna_Manipulator_unregister",
+ "rna_Manipulator_instance");
+#endif
+ RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+
prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "ManipulatorProperties");
RNA_def_property_ui_text(prop, "Properties", "");
RNA_def_property_pointer_funcs(prop, "rna_Manipulator_properties_get", NULL, NULL, NULL);
+ /* -------------------------------------------------------------------- */
+ /* Registerable Variables */
+
+ RNA_define_verify_sdna(0); /* not in sdna */
+
+ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->idname");
+ RNA_def_property_string_maxlength(prop, MAX_NAME);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Manipulator_bl_idname_set");
+ /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
+ RNA_def_property_flag(prop, PROP_REGISTER);
+
+ RNA_define_verify_sdna(1); /* not in sdna */
+
+ /* wmManipulator.draw */
+ func = RNA_def_function(srna, "draw", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ /* wmManipulator.draw_select */
+ func = RNA_def_function(srna, "draw_select", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_int(func, "select_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
+
+ /* wmManipulator.test_select */
+ func = RNA_def_function(srna, "test_select", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "event", "Event", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_int(func, "intersect_id", 0, 0, INT_MAX, "", "", 0, INT_MAX);
+ RNA_def_function_return(func, parm);
+
+ /* wmManipulator.handler */
+ static EnumPropertyItem tweak_actions[] = {
+ {WM_MANIPULATOR_TWEAK_PRECISE, "PRECISE", 0, "Precise", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+ func = RNA_def_function(srna, "modal", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "event", "Event", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ /* TODO, shuold be a enum-flag */
+ parm = RNA_def_enum(func, "tweak", tweak_actions, 0, "Tweak", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_property_flag(parm, PROP_ENUM_FLAG);
+
+ /* wmManipulator.property_update */
+ /* TODO */
+
+ /* wmManipulator.setup */
+ func = RNA_def_function(srna, "setup", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+
+ /* wmManipulator.invoke */
+ func = RNA_def_function(srna, "invoke", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "event", "Event", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ /* wmManipulator.exit */
+ func = RNA_def_function(srna, "exit", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_boolean(func, "cancel", 0, "Cancel, otherwise confirm", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
+ /* wmManipulator.cursor_get */
+ /* TODO */
+
+ /* wmManipulator.select */
+ /* TODO, de-duplicate! */
+ static EnumPropertyItem select_actions[] = {
+ {SEL_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle selection for all elements"},
+ {SEL_SELECT, "SELECT", 0, "Select", "Select all elements"},
+ {SEL_DESELECT, "DESELECT", 0, "Deselect", "Deselect all elements"},
+ {SEL_INVERT, "INVERT", 0, "Invert", "Invert selection of all elements"},
+ {0, NULL, 0, NULL, NULL}
+ };
+ func = RNA_def_function(srna, "select", NULL);
+ RNA_def_function_ui_description(func, "");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_enum(func, "action", select_actions, 0, "Action", "Selection action to execute");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
+
+ /* -------------------------------------------------------------------- */
+ /* Instance Variables */
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(
+ prop, "rna_Manipulator_name_get", "rna_Manipulator_name_length", "rna_Manipulator_name_set");
+ RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
+
+ prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_array(prop, 4);
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_color_get", "rna_Manipulator_color_set", NULL);
+
+ prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_array(prop, 4);
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_color_hi_get", "rna_Manipulator_color_hi_set", NULL);
+ RNA_def_property_ui_text(prop, "Color", "");
+
+ prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
+ RNA_def_property_ui_text(prop, "Basis Matrix", "");
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_basis_get", "rna_Manipulator_matrix_basis_set", NULL);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "matrix_offset", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
+ RNA_def_property_ui_text(prop, "Offset Matrix", "");
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_offset_get", "rna_Manipulator_matrix_offset_set", NULL);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_ui_text(prop, "Scale Basis", "");
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_scale_basis_get", "rna_Manipulator_scale_basis_set", NULL);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_MATRIX);
+ RNA_def_property_ui_text(prop, "Line Width", "");
+ RNA_def_property_float_funcs(prop, "rna_Manipulator_line_width_get", "rna_Manipulator_line_width_set", NULL);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ /* wmManipulator.flag */
+ /* WM_MANIPULATOR_HIDDEN */
+ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Manipulator_flag_hide_get", "rna_Manipulator_flag_hide_set");
+ RNA_def_property_ui_text(prop, "Hide", "");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_MANIPULATOR_DRAW_HOVER */
+ prop = RNA_def_property(srna, "use_draw_hover", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Manipulator_flag_use_draw_hover_get", "rna_Manipulator_flag_use_draw_hover_set");
+ RNA_def_property_ui_text(prop, "Draw Hover", "");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_MANIPULATOR_DRAW_ACTIVE */
+ prop = RNA_def_property(srna, "use_draw_active", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Manipulator_flag_use_draw_active_get", "rna_Manipulator_flag_use_draw_active_set");
+ RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+ /* WM_MANIPULATOR_DRAW_VALUE */
+ prop = RNA_def_property(srna, "use_draw_value", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(
+ prop, "rna_Manipulator_flag_use_draw_value_get", "rna_Manipulator_flag_use_draw_value_set");
+ RNA_def_property_ui_text(prop, "Draw Value", "Show an indicator for the current value while dragging");
+ RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+ /* wmManipulator.state (readonly) */
+ /* WM_MANIPULATOR_STATE_HIGHLIGHT */
+ prop = RNA_def_property(srna, "is_highlight", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_highlight_get", NULL);
+ RNA_def_property_ui_text(prop, "Highlight", "");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ /* WM_MANIPULATOR_STATE_ACTIVE */
+ prop = RNA_def_property(srna, "is_active", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_active_get", NULL);
+ RNA_def_property_ui_text(prop, "Highlight", "");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ /* WM_MANIPULATOR_STATE_SELECT */
+ prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_select_get", NULL);
+ RNA_def_property_ui_text(prop, "Select", "");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ RNA_api_manipulator(srna);
+
srna = RNA_def_struct(brna, "ManipulatorProperties", NULL);
RNA_def_struct_ui_text(srna, "Manipulator Properties", "Input properties of an Manipulator");
RNA_def_struct_refine_func(srna, "rna_ManipulatorProperties_refine");
@@ -201,10 +1075,137 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
srna = RNA_def_struct(brna, "ManipulatorGroup", NULL);
RNA_def_struct_ui_text(srna, "ManipulatorGroup", "Storage of an operator being executed, or registered after execution");
RNA_def_struct_sdna(srna, "wmManipulatorGroup");
RNA_def_struct_refine_func(srna, "rna_ManipulatorGroup_refine");
+#ifdef WITH_PYTHON
+ RNA_def_struct_register_funcs(
+ srna,
+ "rna_ManipulatorGroup_register",
+ "rna_ManipulatorGroup_unregister",
+ "rna_ManipulatorGroup_instance");
+#endif
+ RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
+
+ /* -------------------------------------------------------------------- */
+ /* Registration */
+
+ RNA_define_verify_sdna(0); /* not in sdna */
+
+ prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->idname");
+ RNA_def_property_string_maxlength(prop, MAX_NAME);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_idname_set");
+ RNA_def_property_flag(prop, PROP_REGISTER);
+ RNA_def_struct_name_property(srna, prop);
+
+ prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->name");
+ RNA_def_property_string_maxlength(prop, MAX_NAME); /* else it uses the pointer size! */
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ManipulatorGroup_bl_label_set");
+ /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
+ RNA_def_property_flag(prop, PROP_REGISTER);
+
+ prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.spaceid");
+ RNA_def_property_enum_items(prop, rna_enum_space_type_items);
+ RNA_def_property_flag(prop, PROP_REGISTER);
+ RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in");
+
+ prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type->mmap_params.regionid");
+ RNA_def_property_enum_items(prop, rna_enum_region_type_items);
+ RNA_def_property_flag(prop, PROP_REGISTER);
+ RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in");
+
+ /* bl_options */
+ static EnumPropertyItem manipulatorgroup_flag_items[] = {
+ {WM_MANIPULATORGROUPTYPE_3D, "3D", 0, "3D",
+ "Use in 3D viewport"},
+ {WM_MANIPULATORGROUPTYPE_SCALE, "SCALE", 0, "Scale",
+ "Scale to respect zoom (otherwise zoom independent draw size)"},
+ {WM_MANIPULATORGROUPTYPE_DEPTH_3D, "DEPTH_3D", 0, "Depth 3D",
+ "Supports culled depth by other objects in the view"},
+ {WM_MANIPULATORGROUPTYPE_SELECT, "SELECT", 0, "Select",
+ "Supports selection"},
+ {WM_MANIPULATORGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent",
+ ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+ prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "type->flag");
+ RNA_def_property_enum_items(prop, manipulatorgroup_flag_items);
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
+ RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
+
+ RNA_define_verify_sdna(1); /* not in sdna */
+
+
+ /* Functions */
+
+ /* poll */
+ func = RNA_def_function(srna, "poll", NULL);
+ RNA_def_function_ui_description(func, "Test if the manipulator group can be called or not");
+ RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ /* keymap_init */
+ func = RNA_def_function(srna, "setup_keymap", NULL);
+ RNA_def_function_ui_description(
+ func,
+ "Initialize keymaps for this manipulator group, use fallback keymap when not present");
+ RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "keyconf", "KeyConfig", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_property(func, "manipulator_group", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(parm, "Manipulator Group", "Manipulator Group ID");
+ // RNA_def_property_string_default(parm, "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ /* return */
+ parm = RNA_def_pointer(func, "keymap", "KeyMap", "", "");
+ RNA_def_property_flag(parm, PROP_NEVER_NULL);
+ RNA_def_function_return(func, parm);
+
+ /* setup */
+ func = RNA_def_function(srna, "setup", NULL);
+ RNA_def_function_ui_description(func, "Create manipulators function for the manipulator group");
+ RNA_def_function_flag(func, FUNC_REGISTER);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ /* refresh */
+ func = RNA_def_function(srna, "refresh", NULL);
+ RNA_def_function_ui_description(func, "Refresh data (called on common state changes such as selection)");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ func = RNA_def_function(srna, "draw_prepare", NULL);
+ RNA_def_function_ui_description(func, "Run before each redraw");
+ RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ parm = RNA_def_pointer(func, "context", "Context", "", "");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+
+ /* -------------------------------------------------------------------- */
+ /* Instance Variables */
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_ManipulatorGroup_name_get", "rna_ManipulatorGroup_name_length", NULL);
+ RNA_def_property_ui_text(prop, "Name", "");
+
+ prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
+ RNA_def_property_boolean_funcs(prop, "rna_ManipulatorGroup_has_reports_get", NULL);
+ RNA_def_property_ui_text(prop, "Has Reports",
+ "ManipulatorGroup has a set of reports (warnings and errors) from last execution");
+
RNA_define_verify_sdna(0); /* not in sdna */
@@ -221,6 +1222,8 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna)
rna_def_manipulators(brna, prop);
RNA_define_verify_sdna(1); /* not in sdna */
+
+ RNA_api_manipulatorgroup(srna);
}
void RNA_def_wm_manipulator(BlenderRNA *brna)