[Bf-blender-cvs] [d0aa8af9c92] custom-manipulators: Add wmManipulatorType, extract from wmManipulator

Campbell Barton noreply at git.blender.org
Wed Jun 7 21:30:36 CEST 2017


Commit: d0aa8af9c92b053ec604ba02596ba27d099385d0
Author: Campbell Barton
Date:   Thu Jun 8 04:59:33 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rBd0aa8af9c92b053ec604ba02596ba27d099385d0

Add wmManipulatorType, extract from wmManipulator

Having the type in mixed in with instance
made it hard to expose types to RNA/Python.

This disables face-map select,
we could enable it but it looks like face maps will be made to work
differently.

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

M	source/blender/editors/space_api/spacetypes.c
M	source/blender/editors/space_view3d/view3d_manipulators.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/transform/transform_manipulator2d.c
M	source/blender/makesrna/intern/rna_wm_manipulator.c
M	source/blender/windowmanager/intern/wm_init_exit.c
M	source/blender/windowmanager/manipulators/WM_manipulator_api.h
M	source/blender/windowmanager/manipulators/WM_manipulator_library.h
M	source/blender/windowmanager/manipulators/WM_manipulator_types.h
M	source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c
M	source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
M	source/blender/windowmanager/manipulators/intern/manipulator_library/cage_manipulator.c
M	source/blender/windowmanager/manipulators/intern/manipulator_library/dial_manipulator.c
M	source/blender/windowmanager/manipulators/intern/manipulator_library/facemap_manipulator.c
M	source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c
M	source/blender/windowmanager/manipulators/intern/wm_manipulator.c
M	source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
M	source/blender/windowmanager/manipulators/intern/wm_manipulatorgroup.c
M	source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c
M	source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h

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

diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 46ece1b8f6d..dd8e2cd2ee9 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -125,6 +125,23 @@ void ED_spacetypes_init(void)
 	ED_operatortypes_view2d();
 	ED_operatortypes_ui();
 
+	/* manipulator types */
+
+	/* FIXME */
+	extern void ED_manipulatortypes_dial(void);
+	extern void ED_manipulatortypes_arrow_2d(void);
+	extern void ED_manipulatortypes_arrow_3d(void);
+	extern void ED_manipulatortypes_facemap(void);
+	extern void ED_manipulatortypes_primitive(void);
+	extern void ED_manipulatortypes_cage(void);
+
+	ED_manipulatortypes_dial();
+	ED_manipulatortypes_arrow_2d();
+	ED_manipulatortypes_arrow_3d();
+	ED_manipulatortypes_facemap();
+	ED_manipulatortypes_primitive();
+	ED_manipulatortypes_cage();
+
 	/* register types for operators and manipulators */
 	spacetypes = BKE_spacetypes_list();
 	for (type = spacetypes->first; type; type = type->next) {
diff --git a/source/blender/editors/space_view3d/view3d_manipulators.c b/source/blender/editors/space_view3d/view3d_manipulators.c
index 146e3b98d53..68edfc24d1d 100644
--- a/source/blender/editors/space_view3d/view3d_manipulators.c
+++ b/source/blender/editors/space_view3d/view3d_manipulators.c
@@ -380,6 +380,7 @@ static bool WIDGETGROUP_armature_facemaps_poll(const bContext *C, wmManipulatorG
 	return false;
 }
 
+#if 0
 static void WIDGET_armature_facemaps_select(bContext *C, wmManipulator *widget, const int action)
 {
 	Object *ob = CTX_data_active_object(C);
@@ -398,6 +399,7 @@ static void WIDGET_armature_facemaps_select(bContext *C, wmManipulator *widget,
 			BLI_assert(0);
 	}
 }
+#endif
 
 /**
  * Get a string that equals a string generated using #armature_facemap_hashname_create,
@@ -438,7 +440,9 @@ static wmManipulator *armature_facemap_widget_create(wmManipulatorGroup *wgroup,
 
 	WM_manipulator_set_operator(widget, "TRANSFORM_OT_translate");
 	WM_manipulator_set_flag(widget, WM_MANIPULATOR_DRAW_HOVER, true);
+#if 0
 	WM_manipulator_set_fn_select(widget, WIDGET_armature_facemaps_select);
+#endif
 	PointerRNA *opptr = WM_manipulator_set_operator(widget, "TRANSFORM_OT_translate");
 	RNA_boolean_set(opptr, "release_confirm", true);
 
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index d1c8c08ec88..6d38037ab30 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1149,7 +1149,7 @@ static void WIDGETGROUP_manipulator_init(const bContext *UNUSED(C), wmManipulato
 		manipulator_get_axis_constraint(axis_idx, constraint_axis);
 
 		/* custom handler! */
-		WM_manipulator_set_fn_handler(axis, manipulator_handler);
+		WM_manipulator_set_fn_custom_handler(axis, manipulator_handler);
 
 		switch(axis_idx) {
 			case MAN_AXIS_TRANS_X:
diff --git a/source/blender/editors/transform/transform_manipulator2d.c b/source/blender/editors/transform/transform_manipulator2d.c
index 8eb2b356c32..1db6766e0c9 100644
--- a/source/blender/editors/transform/transform_manipulator2d.c
+++ b/source/blender/editors/transform/transform_manipulator2d.c
@@ -191,7 +191,7 @@ void WIDGETGROUP_manipulator2d_init(const bContext *UNUSED(C), wmManipulatorGrou
 		manipulator2d_get_axis_color(axis_idx, col, col_hi);
 
 		/* custom handler! */
-		WM_manipulator_set_fn_handler(axis, manipulator2d_handler);
+		WM_manipulator_set_fn_custom_handler(axis, manipulator2d_handler);
 		/* set up widget data */
 		MANIPULATOR_arrow2d_set_angle(axis, -M_PI_2 * axis_idx);
 		MANIPULATOR_arrow2d_set_line_len(axis, 0.8f);
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index a5f58e99c8f..2bd025b971a 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -71,6 +71,7 @@
 #  include "BPY_extern.h"
 #endif
 
+#if 0
 static void rna_manipulator_draw_cb(
         const struct bContext *C, struct wmManipulator *mpr)
 {
@@ -212,6 +213,7 @@ static void rna_manipulator_select_cb(
 	mgroup->type->ext.call((bContext *)C, &mgroup_ptr, func, &list);
 	RNA_parameter_list_free(&list);
 }
+#endif
 
 /* Order must match definitions from 'RNA_api_manipulatorgroup'. */
 enum {
@@ -227,6 +229,7 @@ enum {
 	MANIPULATOR_FN_SELECT				= (1 << 9),
 };
 
+#if 0
 static wmManipulator *rna_ManipulatorGroup_manipulator_new(wmManipulatorGroup *mgroup, const char *name)
 {
 	wmManipulator *mpr = WM_manipulator_new(mgroup, name);
@@ -264,6 +267,7 @@ static wmManipulator *rna_ManipulatorGroup_manipulator_new(wmManipulatorGroup *m
 
 	return mpr;
 }
+#endif
 
 static void rna_ManipulatorGroup_manipulator_remove(
         wmManipulatorGroup *mgroup, bContext *C, wmManipulator *manipulator)
@@ -586,11 +590,13 @@ static void rna_def_manipulators(BlenderRNA *brna, PropertyRNA *cprop)
 	RNA_def_struct_sdna(srna, "wmManipulatorGroup");
 	RNA_def_struct_ui_text(srna, "Manipulators", "Collection of manipulators");
 
+#if 0
 	func = RNA_def_function(srna, "new", "rna_ManipulatorGroup_manipulator_new");
 	RNA_def_function_ui_description(func, "Add manipulator");
 	RNA_def_string(func, "name", "Manipulator", 0, "", "Manipulator name"); /* optional */
 	parm = RNA_def_pointer(func, "manipulator", "Manipulator", "", "New manipulator");
 	RNA_def_function_return(func, parm);
+#endif
 
 	func = RNA_def_function(srna, "remove", "rna_ManipulatorGroup_manipulator_remove");
 	RNA_def_function_flag(func, FUNC_USE_CONTEXT);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 022502c9935..6cf27094e67 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -165,6 +165,7 @@ void WM_init(bContext *C, int argc, const char **argv)
 	wm_operatortype_init();
 	WM_menutype_init();
 	WM_uilisttype_init();
+	wm_manipulatortype_init();
 
 	BKE_undo_callback_wm_kill_jobs_set(wm_undo_kill_callback);
 
@@ -487,6 +488,7 @@ void WM_exit_ext(bContext *C, const bool do_python)
 	wm_dropbox_free();
 	WM_menutype_free();
 	WM_uilisttype_free();
+	wm_manipulatortype_free();
 	
 	/* all non-screen and non-space stuff editors did, like editmode */
 	if (C)
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index 7b4e7dc6ac6..f43c47005a9 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -37,9 +37,11 @@
 #define __WM_MANIPULATOR_API_H__
 
 struct ARegion;
+struct GHashIterator;
 struct Main;
 struct wmKeyConfig;
 struct wmManipulator;
+struct wmManipulatorType;
 struct wmManipulatorGroup;
 struct wmManipulatorGroupType;
 struct wmManipulatorMap;
@@ -52,6 +54,7 @@ struct wmManipulatorMapType_Params;
 /* wmManipulator */
 
 struct wmManipulator *WM_manipulator_new(
+        const struct wmManipulatorType *mpt,
         struct wmManipulatorGroup *mgroup, const char *name);
 void WM_manipulator_delete(
         ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *manipulator,
@@ -62,16 +65,7 @@ void WM_manipulator_set_property(struct wmManipulator *, int slot, struct Pointe
 struct PointerRNA *WM_manipulator_set_operator(struct wmManipulator *, const char *opname);
 
 /* callbacks */
-void WM_manipulator_set_fn_draw(struct wmManipulator *manipulator, wmManipulatorFnDraw fn);
-void WM_manipulator_set_fn_draw_select(struct wmManipulator *manipulator, wmManipulatorFnDrawSelect fn);
-void WM_manipulator_set_fn_intersect(struct wmManipulator *manipulator, wmManipulatorFnIntersect fn);
-void WM_manipulator_set_fn_handler(struct wmManipulator *manipulator, wmManipulatorFnHandler fn);
-void WM_manipulator_set_fn_prop_data_update(struct wmManipulator *mpr, wmManipulatorFnPropDataUpdate fn);
-void WM_manipulator_set_fn_final_position_get(struct wmManipulator *mpr, wmManipulatorFnFinalPositionGet fn);
-void WM_manipulator_set_fn_invoke(struct wmManipulator *mpr, wmManipulatorFnInvoke fn);
-void WM_manipulator_set_fn_exit(struct wmManipulator *mpr, wmManipulatorFnExit fn);
-void WM_manipulator_set_fn_cursor_get(struct wmManipulator *mpr, wmManipulatorFnCursorGet fn);
-void WM_manipulator_set_fn_select(struct wmManipulator *manipulator, wmManipulatorFnSelect fn);
+void WM_manipulator_set_fn_custom_handler(struct wmManipulator *manipulator, wmManipulatorFnHandler fn);
 
 void WM_manipulator_set_origin(struct wmManipulator *manipulator, const float origin[3]);
 void WM_manipulator_set_offset(struct wmManipulator *manipulator, const float offset[3]);
@@ -87,6 +81,12 @@ void WM_manipulator_set_color_highlight(struct wmManipulator *manipulator, const
 /* manipulator_library_presets.c */
 void WM_manipulator_draw_preset_box(const struct wmManipulator *manipulator, float mat[4][4], int select_id);
 
+/* wm_manipulator.c */
+const struct wmManipulatorType *WM_manipulatortype_find(const char *idname, bool quiet);
+void WM_manipulatortype_append(void (*mnpfunc)(struct wmManipulatorType *));
+void WM_manipulatortype_append_ptr(void (*mnpfunc)(struct wmManipulatorType *, void *), void *userdata);
+void WM_manipulatortype_iter(struct GHashIterator *ghi);
+
 /* -------------------------------------------------------------------- */
 /* wmManipulatorGroup */
 
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_library.h b/source/blender/windowmanager/manipulators/WM_manipulator_library.h
index 1e7106905e3..4e0c5b004c8 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_library.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_library.h
@@ -124,5 +124,12 @@ struct wmManipulator *MANIPULATOR_primitive_new(struct wmManipulatorGroup *mgrou
 void MANIPULATOR_primitive_set_direction(struct wmManipulator *manipulator, const float direction[3]);
 void MANIPULATOR_primitive_set_up_vector(struct wmManipulator *manipulator, const float direction[3]);
 
+extern void ED_manipulatortypes_dial(void)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list