[Bf-blender-cvs] [97f023fb2dd] custom-manipulators: WM: functions for assigning all manipulator callbacks
Campbell Barton
noreply at git.blender.org
Tue Jun 6 08:53:48 CEST 2017
Commit: 97f023fb2ddf4a2df5ba334b6a6ba986b926132b
Author: Campbell Barton
Date: Tue Jun 6 16:53:12 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rB97f023fb2ddf4a2df5ba334b6a6ba986b926132b
WM: functions for assigning all manipulator callbacks
- move callbacks into type struct
- rename render_3d_intersection -> draw_select
- add header for function signatures (needed for types and api headers).
===================================================================
M source/blender/editors/space_view3d/view3d_widgets.c
M source/blender/editors/transform/transform_manipulator.c
M source/blender/editors/transform/transform_manipulator2d.c
M source/blender/windowmanager/manipulators/WM_manipulator_api.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
A source/blender/windowmanager/manipulators/wm_manipulator_fn.h
M source/blender/windowmanager/manipulators/wm_manipulator_wmapi.h
===================================================================
diff --git a/source/blender/editors/space_view3d/view3d_widgets.c b/source/blender/editors/space_view3d/view3d_widgets.c
index e320a397486..1fb0f0701cc 100644
--- a/source/blender/editors/space_view3d/view3d_widgets.c
+++ b/source/blender/editors/space_view3d/view3d_widgets.c
@@ -403,7 +403,7 @@ 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);
- WM_manipulator_set_func_select(widget, WIDGET_armature_facemaps_select);
+ WM_manipulator_set_fn_select(widget, WIDGET_armature_facemaps_select);
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 df529b0054d..c652e2e0324 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1150,7 +1150,7 @@ static void WIDGETGROUP_manipulator_init(const bContext *UNUSED(C), wmManipulato
manipulator_get_axis_constraint(axis_idx, constraint_axis);
/* custom handler! */
- WM_manipulator_set_custom_handler(axis, manipulator_handler);
+ WM_manipulator_set_fn_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 b0ed816bd3f..5a2997a111e 100644
--- a/source/blender/editors/transform/transform_manipulator2d.c
+++ b/source/blender/editors/transform/transform_manipulator2d.c
@@ -192,7 +192,7 @@ void WIDGETGROUP_manipulator2d_init(const bContext *UNUSED(C), wmManipulatorGrou
manipulator2d_get_axis_color(axis_idx, col, col_hi);
/* custom handler! */
- WM_manipulator_set_custom_handler(axis, manipulator2d_handler);
+ WM_manipulator_set_fn_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/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index 1b504a9772c..76053ed48e0 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -39,31 +39,40 @@
struct ARegion;
struct Main;
struct wmKeyConfig;
+struct wmManipulator;
+struct wmManipulatorGroup;
struct wmManipulatorGroupType;
struct wmManipulatorMap;
struct wmManipulatorMapType;
struct wmManipulatorMapType_Params;
+#include "wm_manipulator_fn.h"
+
/* -------------------------------------------------------------------- */
/* wmManipulator */
struct wmManipulator *WM_manipulator_new(
- void (*draw)(const struct bContext *, struct wmManipulator *),
- void (*render_3d_intersection)(const struct bContext *, struct wmManipulator *, int),
- int (*intersect)(struct bContext *, const struct wmEvent *, struct wmManipulator *),
- int (*handler)(struct bContext *, const struct wmEvent *, struct wmManipulator *, const int));
+ struct wmManipulatorGroup *mgroup, const char *name);
void WM_manipulator_delete(
ListBase *manipulatorlist, struct wmManipulatorMap *mmap, struct wmManipulator *manipulator,
struct bContext *C);
+struct wmManipulatorGroup *WM_manipulator_get_parent_group(struct wmManipulator *manipulator);
void WM_manipulator_set_property(struct wmManipulator *, int slot, struct PointerRNA *ptr, const char *propname);
struct PointerRNA *WM_manipulator_set_operator(struct wmManipulator *, const char *opname);
-void WM_manipulator_set_custom_handler(
- struct wmManipulator *manipulator,
- int (*handler)(struct bContext *, const struct wmEvent *, struct wmManipulator *, const int));
-void WM_manipulator_set_func_select(
- struct wmManipulator *manipulator,
- void (*select)(struct bContext *, struct wmManipulator *, const int action)); /* wmManipulatorSelectFunc */
+
+/* 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_origin(struct wmManipulator *manipulator, const float origin[3]);
void WM_manipulator_set_offset(struct wmManipulator *manipulator, const float offset[3]);
void WM_manipulator_set_flag(struct wmManipulator *manipulator, const int flag, const bool enable);
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
index 9eeb5550ca2..5fb909b06cf 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
@@ -40,13 +40,10 @@
struct wmManipulatorGroupType;
struct wmManipulatorGroup;
+struct wmManipulator;
struct wmKeyConfig;
-typedef bool (*wmManipulatorGroupPollFunc)(const struct bContext *, struct wmManipulatorGroupType *) ATTR_WARN_UNUSED_RESULT;
-typedef void (*wmManipulatorGroupInitFunc)(const struct bContext *, struct wmManipulatorGroup *);
-typedef void (*wmManipulatorGroupRefreshFunc)(const struct bContext *, struct wmManipulatorGroup *);
-typedef void (*wmManipulatorGroupDrawPrepareFunc)(const struct bContext *, struct wmManipulatorGroup *);
-
+#include "wm_manipulator_fn.h"
/* -------------------------------------------------------------------- */
/* wmManipulator */
@@ -79,13 +76,13 @@ typedef struct wmManipulatorGroupType {
const char *name; /* manipulator-group name - displayed in UI (keymap editor) */
/* poll if manipulator-map should be visible */
- wmManipulatorGroupPollFunc poll;
+ wmManipulatorGroupFnPoll poll;
/* initially create manipulators and set permanent data - stuff you only need to do once */
- wmManipulatorGroupInitFunc init;
+ wmManipulatorGroupFnInit init;
/* refresh data, only called if recreate flag is set (WM_manipulatormap_tag_refresh) */
- wmManipulatorGroupRefreshFunc refresh;
+ wmManipulatorGroupFnRefresh refresh;
/* refresh data for drawing, called before each redraw */
- wmManipulatorGroupDrawPrepareFunc draw_prepare;
+ wmManipulatorGroupFnDrawPrepare draw_prepare;
/* keymap init callback for this manipulator-group */
struct wmKeyMap *(*keymap_init)(const struct wmManipulatorGroupType *, struct wmKeyConfig *);
@@ -103,6 +100,9 @@ typedef struct wmManipulatorGroupType {
int flag;
+ /* Weak, but needed to store which functions we have. */
+ int rna_func_flag;
+
/* if type is spawned from operator this is set here */
void *op;
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 ad5f2f6251b..842e66656a2 100644
--- a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c
@@ -193,12 +193,12 @@ struct wmManipulator *MANIPULATOR_arrow2d_new(wmManipulatorGroup *mgroup, const
{
ArrowManipulator2D *arrow = MEM_callocN(sizeof(ArrowManipulator2D), __func__);
- arrow->manipulator.draw = manipulator_arrow2d_draw;
- arrow->manipulator.invoke = manipulator_arrow2d_invoke;
-// arrow->manipulator.bind_to_prop = manipulator_arrow2d_bind_to_prop;
-// arrow->manipulator.handler = manipulator_arrow2d_handler;
- arrow->manipulator.intersect = manipulator_arrow2d_intersect;
-// arrow->manipulator.exit = manipulator_arrow2d_exit;
+ 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;
arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE;
arrow->line_len = 1.0f;
diff --git a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c b/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
index b2e04849c34..6e9abb9137e 100644
--- a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c
@@ -437,14 +437,14 @@ wmManipulator *MANIPULATOR_arrow_new(wmManipulatorGroup *mgroup, const char *nam
ArrowManipulator *arrow = MEM_callocN(sizeof(ArrowManipulator), name);
const float dir_default[3] = {0.0f, 0.0f, 1.0f};
- arrow->manipulator.draw = manipulator_arrow_draw;
- arrow->manipulator.get_final_position = manipulator_arrow_get_final_pos;
- arrow->manipulator.intersect = NULL;
- arrow->manipulator.handler = manipulator_arrow_handler;
- arrow->manipulator.invoke = manipulator_arrow_invoke;
- arrow->manipulator.render_3d_intersection = manipulator_arrow_render_3d_intersect;
- arrow->manipulator.prop_data_update = manipulator_arrow_prop_data_upda
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list