[Bf-blender-cvs] [575db256dbb] blender2.8: WM: add wmManipulatorType, from wmManipulator

Campbell Barton noreply at git.blender.org
Wed Jun 7 21:29:26 CEST 2017


Commit: 575db256dbb54cc013c729157115ba4be8c7b13e
Author: Campbell Barton
Date:   Thu Jun 8 05:27:14 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB575db256dbb54cc013c729157115ba4be8c7b13e

WM: add wmManipulatorType, from wmManipulator

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

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

M	source/blender/editors/space_api/spacetypes.c
M	source/blender/editors/transform/transform_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/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 3a431eb82df..acc197bcc5b 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -125,6 +125,22 @@ 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_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/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/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 bffd7607fd0..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]);
@@ -84,6 +78,15 @@ void WM_manipulator_set_color(struct wmManipulator *manipulator, const float col
 void WM_manipulator_get_color_highlight(const struct wmManipulator *manipulator, float col_hi[4]);
 void WM_manipulator_set_color_highlight(struct wmManipulator *manipulator, const float col[4]);
 
+/* 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);
+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);
+
 #endif  /* __WM_MANIPULATOR_LIBRARY_H__ */
 
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
index 5fb909b06cf..01f5d1c0199 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
@@ -64,6 +64,51 @@ enum {
 	WM_MANIPULATOR_HIDDEN      = (1 << 3),
 };
 
+typedef struct wmManipulatorType {
+	struct wmManipulatorGroupType *next, *prev;
+
+	const char *idname; /* MAX_NAME */
+
+	uint size;
+
+	/* could become wmManipulatorType */
+	/* draw manipulator */
+	wmManipulatorFnDraw draw;
+
+	/* determines 3d intersection by rendering the manipulator in a selection routine. */
+	wmManipulatorFnDrawSelect draw_select;
+
+	/* determine if the mouse intersects with the manipulator. The calculation should be done in the callback itself */
+	wmManipulatorFnIntersect intersect;
+
+	/* handler used by the manipulator. Usually handles interaction tied to a manipulator type */
+	wmManipulatorFnHandler handler;
+
+	/* manipulator-specific handler to update manipulator attributes based on the property value */
+	wmManipulatorFnPropDataUpdate prop_data_update;
+
+	/* returns the final position which may be different from the origin, depending on the manipulator.
+	 * used in calculations of scale */
+	wmManipulatorFnFinalPositionGet position_get;
+
+	/* activate a manipulator state when the user clicks on it */
+	wmManipulatorFnInvoke invoke;
+
+	/* called when manipulator tweaking is done - used to free data and reset property when cancelling */
+	wmManipulatorFnExit exit;
+
+	wmManipulatorFnCursorGet cursor_get;
+
+	/* called when manipulator selection state changes */
+	wmManipulatorFnSelect select;
+
+	/* maximum number of properties attached to the manipulator */
+	int prop_len_max;
+
+	/* RNA integration */
+	ExtensionRNA ext;
+} wmManipulatorType;
+
 
 /* -------------------------------------------------------------------- */
 /* wmManipulatorGroup */
diff --git a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c b/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c
index 106e1f97990..0cec342dd06 100644
--- a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c
@@ -55,6 +55,7 @@
 #include "WM_types.h"
 
 /* own includes */
+#include "WM_manipulator_api.h"
 #include "WM_manipulator_types.h"
 #include "wm_manipulator_wmapi.h"
 #include "WM_manipulator_library.h"
@@ -191,21 +192,14 @@ static int manipulator_arrow2d_intersect(
 
 struct wmManipulator *MANIPULATOR_arrow2d_new(wmManipulatorGroup *mgroup, const char *name)
 {
-	ArrowManipulator2D *arrow = MEM_callocN(sizeof(ArrowManipulator2D), __func__);
-
-	arrow->manipulator.type.draw = manipulator_arrow2d_draw;
-	arrow->manipulator.type.invoke = manipulator_arrow2d_invoke;
-//	arrow->manipulator.type.bind_to_prop = manipulator_arrow2d_bind_to_prop;
-//	arrow->manipulator.type.handler = manipulator_arrow2d_handler;
-	arrow->manipulator.type.intersect = manipulator_arrow2d_intersect;
-//	arrow->manipulator.type.exit = manipulator_arrow2d_exit;
+	const wmManipulatorType *mpt = WM_manipulatortype_find("MANIPULATOR_WT_arrow_2d", false);
+	ArrowManipulator2D *arrow = (ArrowManipulator2D *)WM_manipulator_new(mpt, mgroup, name);
+
 	arrow->mani

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list