[Bf-blender-cvs] [80c9a97] wiggly-widgets: Add callbacks for operator initialization. Now a widget will directly call an operator and have its own handlers for input.

Antony Riakiotakis noreply at git.blender.org
Fri Oct 17 14:49:11 CEST 2014


Commit: 80c9a971f9e843f369cb4629cc41b2c3ea73c6fd
Author: Antony Riakiotakis
Date:   Fri Oct 17 12:29:59 2014 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB80c9a971f9e843f369cb4629cc41b2c3ea73c6fd

Add callbacks for operator initialization. Now a widget will directly
call an operator and have its own handlers for input.

No handlers implemented yet.

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

M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/object/object_lamp.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_generic_widgets.c
M	source/blender/windowmanager/intern/wm_widgets.c
M	source/blender/windowmanager/wm.h
M	source/blender/windowmanager/wm_event_system.h

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

diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 978163e..c650f24 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -46,6 +46,7 @@ struct wmKeyConfig;
 struct wmKeyMap;
 struct wmOperatorType;
 struct wmWindowManager;
+struct PointerRNA;
 
 void transform_keymap_for_space(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int spaceid);
 void transform_operatortypes(void);
@@ -164,10 +165,10 @@ typedef struct ManipulatorGroup {
 	struct wmWidget *rotate_z;
 } ManipulatorGroup;
 
-int WIDGET_manipulator_handler(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget);
+int WIDGET_manipulator_handler(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget, struct PointerRNA *ptr);
 
-int WIDGET_manipulator_handler_trans(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget);
-int WIDGET_manipulator_handler_rot(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget);
+int WIDGET_manipulator_handler_trans(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget, struct PointerRNA *ptr);
+int WIDGET_manipulator_handler_rot(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget, struct PointerRNA *ptr);
 
 void WIDGET_manipulator_render_3d_intersect(const struct bContext *C, struct wmWidget *widget, float scale, int selectionbase);
 void WIDGET_manipulator_draw(struct wmWidget *widget, const struct bContext *C, float scale);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 0770e1e..3eeb070 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -371,7 +371,6 @@ void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op, int *winx,
 #endif
 
 bool WIDGETGROUP_lamp_poll(struct wmWidgetGroup *wgroup, const struct bContext *C);
-int WIDGET_lamp_handler(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget);
 void WIDGETGROUP_lamp_update(struct wmWidgetGroup *wgroup, const struct bContext *C);
 
 /* render */
diff --git a/source/blender/editors/object/object_lamp.c b/source/blender/editors/object/object_lamp.c
index 56adb87..7278b47 100644
--- a/source/blender/editors/object/object_lamp.c
+++ b/source/blender/editors/object/object_lamp.c
@@ -195,21 +195,3 @@ void WIDGETGROUP_lamp_update(struct wmWidgetGroup *wgroup, const struct bContext
 	negate_v3_v3(dir, ob->obmat[2]);
 	WIDGET_arrow_set_direction(lamp, dir);
 }
-
-
-int WIDGET_lamp_handler(struct bContext *C, const struct wmEvent *UNUSED(event), struct wmWidget *UNUSED(widget))
-{
-
-	struct PointerRNA ptr;
-	wmOperatorType *ot = WM_operatortype_find("UI_OT_lamp_position", 0);
-
-	if (ot) {
-		WM_operator_properties_create_ptr(&ptr, ot);
-		WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr);
-
-		return OPERATOR_FINISHED;
-	}
-
-	printf("Widget error: operator not found");
-	return OPERATOR_CANCELLED;
-}
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index a896e9f..15391c7 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -707,37 +707,38 @@ static void view3d_widgets(void)
 	struct wmWidgetGroup *wgroup_light = WM_widgetgroup_new(WIDGETGROUP_lamp_poll, WIDGETGROUP_lamp_update, NULL, NULL);
 	
 	widget = WM_widget_new(WIDGET_manipulator_draw, 
-	                       WIDGET_manipulator_render_3d_intersect, 
-	                       NULL, 
-	                       WIDGET_manipulator_handler, NULL, false);
+	                       WIDGET_manipulator_render_3d_intersect,
+	                       NULL,
+	                       WIDGET_manipulator_handler,
+	                       NULL, NULL, false, NULL, NULL);
 	
 	WM_widget_register(wgroup_manipulator, widget);
 
-	manipulator->translate_x = WIDGET_arrow_new(0, WIDGET_manipulator_handler_trans, NULL);
+	manipulator->translate_x = WIDGET_arrow_new(0, WIDGET_manipulator_handler_trans, "TRANSFORM_OT_translate", NULL, NULL);
 	WIDGET_arrow_set_color(manipulator->translate_x, color_red);
 	WM_widget_register(wgroup_manipulator, manipulator->translate_x);
 
-	manipulator->translate_y = WIDGET_arrow_new(0, WIDGET_manipulator_handler_trans, SET_INT_IN_POINTER(1));
+	manipulator->translate_y = WIDGET_arrow_new(0, WIDGET_manipulator_handler_trans, "TRANSFORM_OT_translate", NULL, SET_INT_IN_POINTER(1));
 	WIDGET_arrow_set_color(manipulator->translate_y, color_green);
 	WM_widget_register(wgroup_manipulator, manipulator->translate_y);
 
-	manipulator->translate_z = WIDGET_arrow_new(0, WIDGET_manipulator_handler_trans, SET_INT_IN_POINTER(2));
+	manipulator->translate_z = WIDGET_arrow_new(0, WIDGET_manipulator_handler_trans, "TRANSFORM_OT_translate", NULL, SET_INT_IN_POINTER(2));
 	WIDGET_arrow_set_color(manipulator->translate_z, color_blue);
 	WM_widget_register(wgroup_manipulator, manipulator->translate_z);
 
-	manipulator->rotate_x = WIDGET_dial_new(UI_DIAL_STYLE_RING_CLIPPED, WIDGET_manipulator_handler_rot, NULL);
+	manipulator->rotate_x = WIDGET_dial_new(UI_DIAL_STYLE_RING_CLIPPED, WIDGET_manipulator_handler_rot, "TRANSFORM_OT_rotate", NULL, NULL);
 	WIDGET_dial_set_color(manipulator->rotate_x, color_red);
 	WM_widget_register(wgroup_manipulator, manipulator->rotate_x);
 
-	manipulator->rotate_y = WIDGET_dial_new(UI_DIAL_STYLE_RING_CLIPPED, WIDGET_manipulator_handler_rot, SET_INT_IN_POINTER(1));
+	manipulator->rotate_y = WIDGET_dial_new(UI_DIAL_STYLE_RING_CLIPPED, WIDGET_manipulator_handler_rot, "TRANSFORM_OT_rotate", NULL, SET_INT_IN_POINTER(1));
 	WIDGET_dial_set_color(manipulator->rotate_y, color_green);
 	WM_widget_register(wgroup_manipulator, manipulator->rotate_y);
 
-	manipulator->rotate_z = WIDGET_dial_new(UI_DIAL_STYLE_RING_CLIPPED, WIDGET_manipulator_handler_rot, SET_INT_IN_POINTER(2));
+	manipulator->rotate_z = WIDGET_dial_new(UI_DIAL_STYLE_RING_CLIPPED, WIDGET_manipulator_handler_rot, "TRANSFORM_OT_rotate", NULL, SET_INT_IN_POINTER(2));
 	WIDGET_dial_set_color(manipulator->rotate_z, color_blue);
 	WM_widget_register(wgroup_manipulator, manipulator->rotate_z);
 
-	widget = WIDGET_arrow_new(0, WIDGET_lamp_handler, NULL);
+	widget = WIDGET_arrow_new(0, NULL, "UI_OT_lamp_position", NULL, NULL);
 	WM_widget_register(wgroup_light,  widget);
 	WIDGET_arrow_set_color(widget, color_lamp);
 
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index d2e437d..2380809 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1833,7 +1833,7 @@ void WIDGET_manipulator_render_3d_intersect(const bContext *C, wmWidget *UNUSED(
 }
 
 /* return 0; nothing happened */
-int WIDGET_manipulator_handler(bContext *C, const struct wmEvent *event, wmWidget *UNUSED(widget))
+int WIDGET_manipulator_handler(bContext *C, const struct wmEvent *event, wmWidget *UNUSED(widget), struct PointerRNA *opptr)
 {
 	ScrArea *sa = CTX_wm_area(C);
 	View3D *v3d = sa->spacedata.first;
@@ -1969,7 +1969,7 @@ int WIDGET_manipulator_handler(bContext *C, const struct wmEvent *event, wmWidge
 }
 
 /* return 0; nothing happened */
-int WIDGET_manipulator_handler_trans(bContext *C, const struct wmEvent *event, wmWidget *widget)
+int WIDGET_manipulator_handler_trans(bContext *C, const struct wmEvent *event, wmWidget *widget, struct PointerRNA *ptr)
 {
 	ScrArea *sa = CTX_wm_area(C);
 	View3D *v3d = sa->spacedata.first;
@@ -1977,13 +1977,10 @@ int WIDGET_manipulator_handler_trans(bContext *C, const struct wmEvent *event, w
 	int shift = event->shift;
 	int direction = GET_INT_FROM_POINTER(WM_widget_customdata(widget));
 
-	struct IDProperty *properties = NULL;	/* operator properties, assigned to ptr->data and can be written to a file */
-	struct PointerRNA *ptr = NULL;			/* rna pointer to access properties */
-	
 	if (!((v3d->twflag & V3D_USE_MANIPULATOR) && (v3d->twflag & V3D_DRAW_MANIPULATOR)) ||
 	    !(event->keymodifier == 0 || event->keymodifier == KM_SHIFT))
 	{
-		return OPERATOR_PASS_THROUGH;
+		;//return OPERATOR_PASS_THROUGH;
 	}
 	
 	if (shift) {
@@ -1996,54 +1993,35 @@ int WIDGET_manipulator_handler_trans(bContext *C, const struct wmEvent *event, w
 	else
 		constraint_axis[direction] = 1;
 	
-	WM_operator_properties_alloc(&ptr, &properties, "TRANSFORM_OT_translate");
 	/* Force orientation */
 	RNA_boolean_set(ptr, "release_confirm", true);
 	RNA_enum_set(ptr, "constraint_orientation", v3d->twmode);
 	RNA_boolean_set_array(ptr, "constraint_axis", constraint_axis);
 	RNA_boolean_set(ptr, "use_widget_input", true);
 
-	WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, ptr);
-	
-	if (ptr) {
-		WM_operator_properties_free(ptr);
-		MEM_freeN(ptr);
-	}
-	
 	return OPERATOR_FINISHED;
 }
 
 /* return 0; nothing happened */
-int WIDGET_manipulator_handler_rot(bContext *C, const struct wmEvent *event, wmWidget *widget)
+int WIDGET_manipulator_handler_rot(bContext *C, const struct wmEvent *UNUSED(event), wmWidget *widget, struct PointerRNA *ptr)
 {
 	ScrArea *sa = CTX_wm_area(C);
 	View3D *v3d = sa->spacedata.first;
 	int constraint_axis[3] = {0, 0, 0};
 	int direction = GET_INT_FROM_POINTER(WM_widget_customdata(widget));
 
-	struct IDProperty *properties = NULL;	/* operator properties, assigned to ptr->data and can be written to a file */
-	struct PointerRNA *ptr = NULL;			/* rna pointer to access properties */
-
-	if (!((v3d->twflag & V3D_USE_MANIPULATOR) && (v3d->twflag & V3D_DRAW_MANIPULATOR)) ||
-	    !(event->keymodifier == 0 || event->keymodifier == KM_SHIFT))
+	if (!(v3d->twflag & V3D_USE_MANIPULATOR) && (v3d->twflag & V3D_DRAW_MANIPULATOR))
 	{
-		return OPERATOR_PASS_THROUGH;
+		;//return OPERATOR_PASS_THROUGH;
 	}
 
 	constraint_axis[direction] = 1;
 
-	WM_operator_properties_alloc(&ptr, &properties, "TRANSFORM_OT_rotate");
 	/* Force orientation */
 	RNA_boolean_set(ptr, "release_confirm", true);
 	RNA_enum_set(ptr, "constraint_orientation", v3d->twmode);
 	RNA_boolean_set_array(ptr, "constraint_ax

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list