Commit: 008e16c83e3ae599f0ce536deafb968b6d27855e
Author: Campbell Barton
Date:   Wed Jun 7 22:01:30 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rB008e16c83e3ae599f0ce536deafb968b6d27855e

WM: move manipulator API into its own files

Getting to be a hassle to track multiple manipulator classes
and callbacks.

===================================================================

M       source/blender/makesrna/intern/CMakeLists.txt
M       source/blender/makesrna/intern/makesrna.c
M       source/blender/makesrna/intern/rna_internal.h
M       source/blender/makesrna/intern/rna_wm.c
M       source/blender/makesrna/intern/rna_wm_api.c
A       source/blender/makesrna/intern/rna_wm_manipulator.c
A       source/blender/makesrna/intern/rna_wm_manipulator_api.c

===================================================================

diff --git a/source/blender/makesrna/intern/CMakeLists.txt 
b/source/blender/makesrna/intern/CMakeLists.txt
index 899c9bf77a9..422de50f687 100644
--- a/source/blender/makesrna/intern/CMakeLists.txt
+++ b/source/blender/makesrna/intern/CMakeLists.txt
@@ -94,6 +94,7 @@ set(DEFSRC
        rna_userdef.c
        rna_vfont.c
        rna_wm.c
+       rna_wm_manipulator.c
        rna_workspace.c
        rna_world.c
 )
@@ -125,6 +126,7 @@ set(APISRC
        rna_ui_api.c
        rna_vfont_api.c
        rna_wm_api.c
+       rna_wm_manipulator_api.c
 )
 
 string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" 
"${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}")
diff --git a/source/blender/makesrna/intern/makesrna.c 
b/source/blender/makesrna/intern/makesrna.c
index babca789361..496c24de4ef 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3364,6 +3364,7 @@ static RNAProcessItem PROCESS_ITEMS[] = {
        {"rna_userdef.c", NULL, RNA_def_userdef},
        {"rna_vfont.c", "rna_vfont_api.c", RNA_def_vfont},
        {"rna_wm.c", "rna_wm_api.c", RNA_def_wm},
+       {"rna_wm_manipulator.c", "rna_wm_manipulator_api.c", 
RNA_def_wm_manipulator},
        {"rna_workspace.c", NULL, RNA_def_workspace},
        {"rna_world.c", NULL, RNA_def_world},
        {"rna_movieclip.c", NULL, RNA_def_movieclip},
diff --git a/source/blender/makesrna/intern/rna_internal.h 
b/source/blender/makesrna/intern/rna_internal.h
index 18374c09999..59866d67921 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -186,6 +186,7 @@ void RNA_def_ui(struct BlenderRNA *brna);
 void RNA_def_userdef(struct BlenderRNA *brna);
 void RNA_def_vfont(struct BlenderRNA *brna);
 void RNA_def_wm(struct BlenderRNA *brna);
+void RNA_def_wm_manipulator(struct BlenderRNA *brna);
 void RNA_def_workspace(struct BlenderRNA *brna);
 void RNA_def_world(struct BlenderRNA *brna);
 void RNA_def_movieclip(struct BlenderRNA *brna);
diff --git a/source/blender/makesrna/intern/rna_wm.c 
b/source/blender/makesrna/intern/rna_wm.c
index 095162fc229..c80c0169fda 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -31,7 +31,6 @@
 #include "DNA_userdef_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_windowmanager_types.h"
-#include "DNA_manipulator_types.h"
 
 #include "BLI_utildefines.h"
 
@@ -457,14 +456,6 @@ EnumPropertyItem rna_enum_wm_report_items[] = {
        {0, NULL, 0, NULL, NULL}
 };
 
-EnumPropertyItem rna_enum_wm_manipulator_type_items[] = {
-       {WT_TRANSLATE, "TRANSLATE", ICON_MAN_TRANS, "Translate", "Add a widget 
for moving objects"},
-       {WT_ROTATE,    "ROTATE",    ICON_MAN_ROT,   "Rotate",    "Add a widget 
for rotating objects"},
-       {WT_SCALE,     "SCALE",     ICON_MAN_SCALE, "Scale",     "Add a widget 
for scaling objects"},
-       {WT_CUSTOM, "CUSTOM", ICON_OUTLINER_DATA_ARMATURE, "Custom", "Add a 
user defined widget that affects a specified property"},
-       {0, NULL, 0, NULL, NULL}
-};
-
 #ifdef RNA_RUNTIME
 
 #include <assert.h>
@@ -553,244 +544,6 @@ static PointerRNA rna_Operator_properties_get(PointerRNA 
*ptr)
        return rna_pointer_inherit_refine(ptr, op->type->srna, op->properties);
 }
 
-static void rna_manipulator_draw_cb(
-        const struct bContext *C, struct wmManipulator *mpr)
-{
-       extern FunctionRNA rna_ManipulatorGroup_manipulator_draw_func;
-       wmManipulatorGroup *mgroup = WM_manipulator_get_parent_group(mpr);
-       PointerRNA mgroup_ptr;
-       ParameterList list;
-       FunctionRNA *func;
-       RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
-       /* RNA_struct_find_function(&mgroup_ptr, "manipulator_draw"); */
-       func = &rna_ManipulatorGroup_manipulator_draw_func;
-       RNA_parameter_list_create(&list, &mgroup_ptr, func);
-       RNA_parameter_set_lookup(&list, "context", &C);
-       RNA_parameter_set_lookup(&list, "manipulator", &mpr);
-       mgroup->type->ext.call((bContext *)C, &mgroup_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_ManipulatorGroup_manipulator_draw_select_func;
-       wmManipulatorGroup *mgroup = WM_manipulator_get_parent_group(mpr);
-       PointerRNA mgroup_ptr;
-       ParameterList list;
-       FunctionRNA *func;
-       RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
-       /* RNA_struct_find_function(&mgroup_ptr, "manipulator_draw_select"); */
-       func = &rna_ManipulatorGroup_manipulator_draw_select_func;
-       RNA_parameter_list_create(&list, &mgroup_ptr, func);
-       RNA_parameter_set_lookup(&list, "context", &C);
-       RNA_parameter_set_lookup(&list, "manipulator", &mpr);
-       RNA_parameter_set_lookup(&list, "select_id", &select_id);
-       mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list);
-       RNA_parameter_list_free(&list);
-}
-
-static int rna_manipulator_intersect_cb(
-        struct bContext *C, struct wmManipulator *mpr, const struct wmEvent 
*event)
-{
-       extern FunctionRNA rna_ManipulatorGroup_manipulator_intersect_func;
-       wmManipulatorGroup *mgroup = WM_manipulator_get_parent_group(mpr);
-       PointerRNA mgroup_ptr;
-       ParameterList list;
-       FunctionRNA *func;
-       RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
-       /* RNA_struct_find_function(&mgroup_ptr, "manipulator_draw_select"); */
-       func = &rna_ManipulatorGroup_manipulator_intersect_func;
-       RNA_parameter_list_create(&list, &mgroup_ptr, func);
-       RNA_parameter_set_lookup(&list, "context", &C);
-       RNA_parameter_set_lookup(&list, "manipulator", &mpr);
-       RNA_parameter_set_lookup(&list, "event", &event);
-       mgroup->type->ext.call((bContext *)C, &mgroup_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_handler_cb(
-        struct bContext *C, struct wmManipulator *mpr, const struct wmEvent 
*event, int tweak)
-{
-       extern FunctionRNA rna_ManipulatorGroup_manipulator_handler_func;
-       wmManipulatorGroup *mgroup = WM_manipulator_get_parent_group(mpr);
-       PointerRNA mgroup_ptr;
-       ParameterList list;
-       FunctionRNA *func;
-       RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
-       /* RNA_struct_find_function(&mgroup_ptr, "manipulator_draw_select"); */
-       func = &rna_ManipulatorGroup_manipulator_handler_func;
-       RNA_parameter_list_create(&list, &mgroup_ptr, func);
-       RNA_parameter_set_lookup(&list, "context", &C);
-       RNA_parameter_set_lookup(&list, "manipulator", &mpr);
-       RNA_parameter_set_lookup(&list, "event", &event);
-       RNA_parameter_set_lookup(&list, "tweak", &tweak);
-       mgroup->type->ext.call((bContext *)C, &mgroup_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_ManipulatorGroup_manipulator_invoke_func;
-       wmManipulatorGroup *mgroup = WM_manipulator_get_parent_group(mpr);
-       PointerRNA mgroup_ptr;
-       ParameterList list;
-       FunctionRNA *func;
-       RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
-       /* RNA_struct_find_function(&mgroup_ptr, "manipulator_draw_select"); */
-       func = &rna_ManipulatorGroup_manipulator_invoke_func;
-       RNA_parameter_list_create(&list, &mgroup_ptr, func);
-       RNA_parameter_set_lookup(&list, "context", &C);
-       RNA_parameter_set_lookup(&list, "manipulator", &mpr);
-       RNA_parameter_set_lookup(&list, "event", &event);
-       mgroup->type->ext.call((bContext *)C, &mgroup_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_ManipulatorGroup_manipulator_exit_func;
-       wmManipulatorGroup *mgroup = WM_manipulator_get_parent_group(mpr);
-       PointerRNA mgroup_ptr;
-       ParameterList list;
-       FunctionRNA *func;
-       RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
-       /* RNA_struct_find_function(&mgroup_ptr, "manipulator_draw_select"); */
-       func = &rna_ManipulatorGroup_manipulator_exit_func;
-       RNA_parameter_list_create(&list, &mgroup_ptr, func);
-       RNA_parameter_set_lookup(&list, "context", &C);
-       RNA_parameter_set_lookup(&list, "manipulator", &mpr);
-       {
-               int cancel_i = cancel;
-               RNA_parameter_set_lookup(&list, "cancel", &cancel_i);
-       }
-       mgroup->type->ext.call((bContext *)C, &mgroup_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_ManipulatorGroup_manipulator_select_func;
-       wmManipulatorGroup *mgroup = WM_manipulator_get_parent_group(mpr);
-       PointerRNA mgroup_ptr;
-       ParameterList list;
-       FunctionRNA *func;
-       RNA_pointer_create(NULL, mgroup->type->ext.srna, mgroup, &mgroup_ptr);
-       /* RNA_struct_find_function(&mgroup_ptr, "manipulator_draw_select"); */
-       func = &rna_ManipulatorGroup_manipulator_select_func;
-       RNA_parameter_list_create(&list, &mgroup_ptr, func);
-       RNA_parameter_set_lookup(&list, "context", &C);
-       RNA_parameter_set_lookup(&list, "manipulator", &mpr);
-       RNA_parameter_set_lookup(&list, "action", &action);
-       mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list);
-       RNA_parameter_list_free(&list);
-}
-
-/* Order must match definitions from 'RNA_api_manipulatorgroup'. */
-enum {
-       MANIPULATOR_FN_DRAW                                     = (1 << 0),
-       MANIPULATOR_FN_DRAW_SELECT                      = (1 << 1),
-       MANIPULATOR_FN_INTERSECT                        = (1 << 2),
-       MANIPULATOR_FN_HANDLER                          = (1 << 3),
-       MANIPULATOR_FN_PROP_DATA_UPDATE         = (1 << 4),
-       MANIPULATOR_FN_FINAL_POSITION_GET       = (1 << 5),
-       MANIPULATOR_FN_INVOKE                           = (1 << 6),
-       MANIPULATOR_FN_EXIT                                     = (1 << 7),
-       MANIPULATOR_FN_CURSOR_GET                       = (1 << 8),
-       MANIPULATOR_FN_SELECT                           = (1 << 9),
-};
-
-static wmManipulator *rna_ManipulatorGroup_manipulator_new(wmManipulatorGroup 
*mgroup, const char *name)
-{
-       wmManipulator *mpr = WM_manipulator_new(mgroup, name);
-
-       if (mgroup->type->rna_func_flag & MANIPULATOR_FN_DRAW) {
-               WM_manipulator_set_fn_draw(mpr, rna_manipulator_draw_cb);
-       }
-       if (mgroup->type->rna_func_flag & MANIPULATOR_FN_DRAW_SELECT) {
-               WM_manipulator_set_fn_draw_select(mpr, 
rna_manipulator_draw_select_cb);
-       }
-       if (mgroup->type->rna_func_flag & MANIPULATOR_FN_INTERSECT)

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to